aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/options/OptionsWidget_theme.cpp
diff options
context:
space:
mode:
authorGravatar ctrlaltca2024-07-15 21:32:05 +0200
committerGravatar GitHub2024-07-15 21:32:05 +0200
commitf2005924313b18a2869f63e6298f715ce4f13aa4 (patch)
tree2883c237f03887d70cb67fba6d256567f7e632b0 /src/modules/options/OptionsWidget_theme.cpp
parentForce app_id to be set in more places (#2661) (diff)
downloadKVIrc-f2005924313b18a2869f63e6298f715ce4f13aa4.tar.gz
KVIrc-f2005924313b18a2869f63e6298f715ce4f13aa4.tar.bz2
KVIrc-f2005924313b18a2869f63e6298f715ce4f13aa4.zip
Add an option to let the user choose the qt style used by the app (#2663)
* Remove hardcoded usage of Fusion style on Gtk; add an option to use a custom Qt Style (like Fusion on Windows, supporting dark mode) * Update src/modules/options/OptionsWidget_theme.cpp Co-authored-by: Alexey Sokolov <alexey+github@asokolov.org>
Diffstat (limited to 'src/modules/options/OptionsWidget_theme.cpp')
-rw-r--r--src/modules/options/OptionsWidget_theme.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/modules/options/OptionsWidget_theme.cpp b/src/modules/options/OptionsWidget_theme.cpp
index d2637267e..f4d3cc8eb 100644
--- a/src/modules/options/OptionsWidget_theme.cpp
+++ b/src/modules/options/OptionsWidget_theme.cpp
@@ -31,7 +31,9 @@
#include "KviTalToolTip.h"
#include <QLayout>
+#include <QStyleFactory>
+#define DEFAULT_QT_STYLE "Default"
OptionsWidget_theme::OptionsWidget_theme(QWidget * parent)
: KviOptionsWidget(parent)
{
@@ -44,12 +46,38 @@ OptionsWidget_theme::OptionsWidget_theme(QWidget * parent)
KVI_OPTION_BOOL(KviOption_boolUseGlobalApplicationFont));
connect(b, SIGNAL(toggled(bool)), f, SLOT(setEnabled(bool)));
- addRowSpacer(0, 3, 1, 3);
+ addLabel(0, 3, 0, 3, __tr2qs_ctx("Qt Style:", "options"));
+ m_pQtStyle = new QComboBox(this);
+ addWidgetToLayout(m_pQtStyle, 1, 3, 1, 3);
+ m_pQtStyle->addItem(DEFAULT_QT_STYLE);
+ for (const QString& key : QStyleFactory::keys()) {
+ m_pQtStyle->addItem(key);
+ }
+ if(KVI_OPTION_STRING(KviOption_stringQtStyle).isEmpty()) {
+ m_pQtStyle->setCurrentText(DEFAULT_QT_STYLE);
+ } else {
+ m_pQtStyle->setCurrentText(KVI_OPTION_STRING(KviOption_stringQtStyle));
+ }
+
+ addRowSpacer(0, 4, 1, 4);
}
OptionsWidget_theme::~OptionsWidget_theme()
= default;
+void OptionsWidget_theme::commit()
+{
+ KviOptionsWidget::commit();
+
+ if(m_pQtStyle->currentText() == DEFAULT_QT_STYLE) {
+ KVI_OPTION_STRING(KviOption_stringQtStyle) = "";
+ } else {
+ KVI_OPTION_STRING(KviOption_stringQtStyle) = m_pQtStyle->currentText();
+ QApplication::setStyle(QStyleFactory::create(KVI_OPTION_STRING(KviOption_stringQtStyle)));
+ QApplication::setPalette(style()->standardPalette());
+ }
+}
+
OptionsWidget_themeTransparency::OptionsWidget_themeTransparency(QWidget * parent)
: KviOptionsWidget(parent)
{