diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h b/SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h new file mode 100644 index 0000000..eee49d5 --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/common/widgetstateindicator.h @@ -0,0 +1,99 @@ +#ifndef WIDGETSTATEINDICATOR_H +#define WIDGETSTATEINDICATOR_H + +#include "guiSQLiteStudio_global.h" +#include <QObject> + +class QLabel; +class QGraphicsDropShadowEffect; +class QGraphicsColorizeEffect; +class QSequentialAnimationGroup; + +class GUI_API_EXPORT WidgetStateIndicator : public QObject +{ + Q_OBJECT + public: + enum class Mode + { + INFO, + ERROR, + WARNING, + HINT + }; + + enum class PositionMode + { + DEFAULT, + GROUP_BOX, + LABEL, + CHECK_BOX, + }; + + ~WidgetStateIndicator(); + + void setMode(Mode mode); + void show(const QString& msg = QString(), bool animated = true); + void hide(); + void setVisible(bool visible, const QString& msg = QString()); + void release(); + void info(const QString& msg, bool animated = true); + void warn(const QString& msg, bool animated = true); + void error(const QString& msg, bool animated = true); + void hint(const QString& msg, bool animated = true); + + static bool exists(QWidget* widget); + static WidgetStateIndicator* getInstance(QWidget* widget); + + PositionMode getPositionMode() const; + void setPositionMode(const PositionMode& value); + + protected: + bool eventFilter(QObject *obj, QEvent *ev); + + private: + explicit WidgetStateIndicator(QWidget *widget); + + void initLabel(); + void initEffects(); + void initGlowEffects(); + void initHighlightingEffects(); + void initAnimations(); + void initPositionMode(); + void finalInit(); + void setMessage(const QString& msg); + void clearMessage(); + void detectWindowParent(); + QWidget* findParentWindow(QWidget* w); + bool shouldHide(); + bool shouldShow(); + + QWidget* labelParent = nullptr; + QLabel* label = nullptr; + Mode mode = Mode::ERROR; + QWidget* widget = nullptr; + QString message; + QGraphicsColorizeEffect* highlightingEffect = nullptr; + QGraphicsDropShadowEffect* glowEffect = nullptr; + QSequentialAnimationGroup* animation = nullptr; + bool widgetVisible = false; + bool visibilityRequested = false; + QWidget* windowParent = nullptr; + PositionMode positionMode = PositionMode::DEFAULT; + + static QHash<QWidget*,WidgetStateIndicator*> instances; + + private slots: + void updateMode(); + void updatePosition(); + void updatePositionDefault(); + void updatePositionGroupBox(); + void updatePositionLabel(); + void updatePositionCheckBox(); + void updateVisibility(); + +}; + +#define INDICATOR(w) WidgetStateIndicator::getInstance(w) +#define EXISTS_INDICATOR(w) WidgetStateIndicator::exists(w) + +#endif // WIDGETSTATEINDICATOR_H |
