File indexing completed on 2025-01-05 04:47:09
0001 /* 0002 SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "servermanager.h" 0010 0011 #include <QPointer> 0012 #include <QWidget> 0013 0014 namespace Ui 0015 { 0016 class ErrorOverlay; 0017 } 0018 0019 namespace Akonadi 0020 { 0021 /** 0022 * @internal 0023 * Overlay widget to block Akonadi-dependent widgets if the Akonadi server 0024 * is unavailable. 0025 * @todo handle initial parent == 0 case correctly, reparent later and hide as long as parent widget is 0 0026 * @todo fix hiding in dock widget tabs 0027 */ 0028 class ErrorOverlay : public QWidget 0029 { 0030 Q_OBJECT 0031 public: 0032 /** 0033 * Create an overlay widget for @p baseWidget. 0034 * @p baseWidget must not be null. 0035 * @p parent must not be equal to @p baseWidget 0036 */ 0037 explicit ErrorOverlay(QWidget *baseWidget, QWidget *parent = nullptr); 0038 ~ErrorOverlay() override; 0039 0040 protected: 0041 bool eventFilter(QObject *object, QEvent *event) override; 0042 0043 private: 0044 void reposition(); 0045 0046 private Q_SLOTS: 0047 void startClicked(); 0048 void quitClicked(); 0049 void selfTestClicked(); 0050 void serverStateChanged(Akonadi::ServerManager::State state); 0051 0052 private: 0053 QPointer<QWidget> mBaseWidget; 0054 bool mPreviousState = false; 0055 bool mOverlayActive = false; 0056 bool mBaseWidgetIsParent = false; 0057 QScopedPointer<Ui::ErrorOverlay> ui; 0058 }; 0059 0060 }