Skip to content

Commit

Permalink
feat: allow to switch base Qt theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jan 8, 2024
1 parent cb1e43e commit 924b290
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 35 deletions.
4 changes: 4 additions & 0 deletions src/gui/src/main-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QNetworkProxy>
#include <QShortcut>
#include <QStringList>
#include <QStyleFactory>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
#include <QSysInfo>
#endif
Expand Down Expand Up @@ -80,6 +81,9 @@ void MainWindow::init(const QStringList &args, const QMap<QString, QString> &par

m_themeLoader = new ThemeLoader(savePath("themes/", true, false), m_settings, this);
m_themeLoader->setTheme(m_settings->value("theme", "Default").toString());
const QStringList baseStyles = QStyleFactory::keys();
const QString defaultStyle = !baseStyles.isEmpty() ? baseStyles.first() : "";
qApp->setStyle(m_settings->value("baseStyle", defaultStyle).toString());
ui->setupUi(this);

if (m_settings->value("Log/show", true).toBool()) {
Expand Down
12 changes: 11 additions & 1 deletion src/gui/src/settings/options-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QSqlDatabase>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QStyleFactory>
#include <QtConcurrent>
#include <ui_options-window.h>
#include <algorithm>
Expand Down Expand Up @@ -316,11 +317,17 @@ OptionsWindow::OptionsWindow(Profile *profile, ThemeLoader *themeLoader, QWidget
}

// Themes
QStringList themes = m_themeLoader->getAllThemes();
const QStringList themes = m_themeLoader->getAllThemes();
for (const QString &theme : themes) {
ui->comboTheme->addItem(theme, theme);
}
ui->comboTheme->setCurrentText(settings->value("theme", "Default").toString());
const QStringList baseStyles = QStyleFactory::keys();
const QString defaultStyle = !baseStyles.isEmpty() ? baseStyles.first() : "";
for (const QString &style : baseStyles) {
ui->comboBaseStyle->addItem(style, style);
}
ui->comboBaseStyle->setCurrentText(settings->value("baseStyle", defaultStyle).toString());

ui->checkViewerSingleWindow->setChecked(settings->value("Viewer/singleWindow", false).toBool());
const QStringList positions { "top", "left", "auto" };
Expand Down Expand Up @@ -1075,6 +1082,9 @@ void OptionsWindow::save()
}
settings->setValue("Interface/scaleFontSize", ui->checkScaleFontSize->isChecked());
}
const QString baseStyle = ui->comboBaseStyle->currentText();
qApp->setStyle(baseStyle);
settings->setValue("baseStyle", baseStyle);

settings->setValue("whitelistedtags", ui->lineWhitelist->text());
settings->setValue("add", ui->lineAdd->text());
Expand Down
78 changes: 44 additions & 34 deletions src/gui/src/settings/options-window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
<width>473</width>
<height>466</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollAreaWidgetLayout">
Expand Down Expand Up @@ -1444,14 +1444,14 @@
<item row="0" column="1">
<widget class="QComboBox" name="comboTheme"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="labelThumbnailUpscale">
<property name="text">
<string>Thumbnail scaling</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="spinThumbnailUpscale">
<property name="suffix">
<string>%</string>
Expand All @@ -1464,14 +1464,24 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkThumbnailSmartSize">
<property name="text">
<string>Use bigger thumbnail sizes as needed when available</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Favorites display</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="comboFavoritesDisplay">
<item>
<property name="text">
Expand Down Expand Up @@ -1510,14 +1520,14 @@
</item>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_39">
<property name="text">
<string>Hide favorites</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QSpinBox" name="spinHideFavorites">
<property name="maximum">
<number>1000</number>
Expand All @@ -1527,7 +1537,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_40">
<property name="font">
<font>
Expand All @@ -1542,14 +1552,14 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_41">
<property name="text">
<string>Source's type display</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="comboSources">
<item>
<property name="text">
Expand All @@ -1573,14 +1583,14 @@
</item>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_42">
<property name="text">
<string>Displayed letters</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QComboBox" name="comboSourcesLetters">
Expand Down Expand Up @@ -1616,7 +1626,7 @@
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_43">
<property name="font">
<font>
Expand All @@ -1631,58 +1641,58 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="checkPreloadAllTabs">
<property name="text">
<string>Preload all tabs when restoring a previous session</string>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="checkScaleFontSize">
<property name="text">
<string>Scale font size</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="labelAcceptDialogue">
<property name="text">
<string>Accept dialogue</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QKeySequenceEdit" name="keyAcceptDialogue">
<property name="keySequence">
<string>Ctrl+N</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLabel" name="labelDeclineDialogue">
<property name="text">
<string>Decline dialogue</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QKeySequenceEdit" name="keyDeclineDialogue">
<property name="keySequence">
<string>Ctrl+N</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QCheckBox" name="checkScaleFontSize">
<property name="text">
<string>Scale font size</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<item row="1" column="1">
<widget class="QComboBox" name="comboBaseStyle"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkThumbnailSmartSize">
<item row="1" column="0">
<widget class="QLabel" name="labelBaseStyle">
<property name="text">
<string>Use bigger thumbnail sizes as needed when available</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Base style</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 924b290

Please sign in to comment.