aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/style.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/style.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/style.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/style.cpp b/SQLiteStudio3/guiSQLiteStudio/style.cpp
new file mode 100644
index 0000000..525a832
--- /dev/null
+++ b/SQLiteStudio3/guiSQLiteStudio/style.cpp
@@ -0,0 +1,48 @@
+#include "style.h"
+#include "themetuner.h"
+#include "common/global.h"
+#include "mainwindow.h"
+#include <QApplication>
+#include <QToolTip>
+
+Style* Style::instance = nullptr;
+
+Style* Style::getInstance()
+{
+ if (instance == nullptr)
+ instance = new Style(QApplication::style());
+
+ return instance;
+}
+
+const ExtendedPalette& Style::extendedPalette() const
+{
+ return extPalette;
+}
+
+void Style::setStyle(QStyle *style, const QString &styleName)
+{
+ setBaseStyle(style);
+
+ QApplication::setPalette(initialPalette); // reset palette, cause styles don't provide
+ // full palette when changed in runtime (i.e. windowsvista)
+ QApplication::setStyle(this);
+ QApplication::setPalette(standardPalette());
+ THEME_TUNER->tuneTheme(styleName);
+ QToolTip::setPalette(standardPalette());
+
+ extPalette.styleChanged(this, styleName);
+
+ MAINWINDOW->getMdiArea()->setBackground(extPalette.mdiAreaBase());
+}
+
+QString Style::name() const
+{
+ return baseStyle()->objectName();
+}
+
+Style::Style(QStyle *style)
+ : QProxyStyle(style)
+{
+ initialPalette = style->standardPalette();
+}