mirror of
https://github.com/tnodir/fort
synced 2024-11-14 21:55:37 +00:00
UI: Options: Interface: Add "Style" combobox
This commit is contained in:
parent
c6caa13199
commit
8c0b5c5931
@ -50,6 +50,7 @@ void IfacePage::onResetToDefault()
|
||||
{
|
||||
m_comboLanguage->setCurrentIndex(0);
|
||||
m_comboTheme->setCurrentIndex(0);
|
||||
m_comboStyle->setCurrentText(IniUser::styleDefault());
|
||||
m_cbUseSystemLocale->setChecked(true);
|
||||
m_cbExcludeCapture->setChecked(false);
|
||||
|
||||
@ -118,6 +119,12 @@ void IfacePage::onEditResetted()
|
||||
setThemeEdited(false);
|
||||
WindowManager::updateTheme(confManager()->iniUser());
|
||||
}
|
||||
|
||||
// Style
|
||||
if (styleEdited()) {
|
||||
setStyleEdited(false);
|
||||
WindowManager::updateStyle(confManager()->iniUser());
|
||||
}
|
||||
}
|
||||
|
||||
void IfacePage::onRetranslateUi()
|
||||
@ -132,6 +139,8 @@ void IfacePage::onRetranslateUi()
|
||||
m_labelLanguage->setText(tr("Language:"));
|
||||
m_labelTheme->setText(tr("Theme:"));
|
||||
retranslateComboTheme();
|
||||
m_labelStyle->setText(tr("Style:"));
|
||||
retranslateComboStyle();
|
||||
m_cbUseSystemLocale->setText(tr("Use System Regional Settings"));
|
||||
m_cbExcludeCapture->setText(tr("Exclude from screen capture"));
|
||||
m_cbExplorerMenu->setText(tr("Windows Explorer integration"));
|
||||
@ -179,6 +188,15 @@ void IfacePage::retranslateComboTheme()
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
void IfacePage::retranslateComboStyle()
|
||||
{
|
||||
const QStringList list = { IniUser::styleDefault(), "Windows11" };
|
||||
|
||||
ControlUtil::setComboBoxTexts(m_comboStyle, list);
|
||||
|
||||
updateStyle();
|
||||
}
|
||||
|
||||
void IfacePage::retranslateComboHotKey()
|
||||
{
|
||||
// Sync with TrayIcon::retranslateUi() & HotKey::list[]
|
||||
@ -296,6 +314,9 @@ void IfacePage::setupGlobalBox()
|
||||
// Theme Row
|
||||
auto themeLayout = setupThemeLayout();
|
||||
|
||||
// Style Row
|
||||
auto styleLayout = setupStyleLayout();
|
||||
|
||||
m_cbUseSystemLocale =
|
||||
ControlUtil::createCheckBox(iniUser()->useSystemLocale(), [&](bool checked) {
|
||||
iniUser()->setUseSystemLocale(checked);
|
||||
@ -317,6 +338,7 @@ void IfacePage::setupGlobalBox()
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->addLayout(langLayout);
|
||||
layout->addLayout(themeLayout);
|
||||
layout->addLayout(styleLayout);
|
||||
layout->addWidget(m_cbUseSystemLocale);
|
||||
layout->addWidget(m_cbExcludeCapture);
|
||||
layout->addWidget(m_cbExplorerMenu);
|
||||
@ -379,6 +401,26 @@ QLayout *IfacePage::setupThemeLayout()
|
||||
return ControlUtil::createRowLayout(m_labelTheme, m_comboTheme);
|
||||
}
|
||||
|
||||
QLayout *IfacePage::setupStyleLayout()
|
||||
{
|
||||
m_labelStyle = ControlUtil::createLabel();
|
||||
|
||||
m_comboStyle = ControlUtil::createComboBox({}, [&](int index) {
|
||||
const auto style = m_comboStyle->itemText(index);
|
||||
|
||||
if (iniUser()->style() != style) {
|
||||
setStyleEdited(true);
|
||||
iniUser()->setStyle(style);
|
||||
ctrl()->setIniUserEdited();
|
||||
|
||||
WindowManager::updateStyle(*iniUser());
|
||||
}
|
||||
});
|
||||
m_comboStyle->setFixedWidth(200);
|
||||
|
||||
return ControlUtil::createRowLayout(m_labelStyle, m_comboStyle);
|
||||
}
|
||||
|
||||
void IfacePage::setupHotKeysBox()
|
||||
{
|
||||
m_cbHotKeysEnabled = ControlUtil::createCheckBox(iniUser()->hotKeyEnabled(), [&](bool checked) {
|
||||
@ -703,3 +745,9 @@ void IfacePage::updateTheme()
|
||||
const auto colorScheme = IniUser::colorSchemeByName(iniUser()->theme());
|
||||
m_comboTheme->setCurrentIndex(colorScheme);
|
||||
}
|
||||
|
||||
void IfacePage::updateStyle()
|
||||
{
|
||||
const auto style = iniUser()->style();
|
||||
m_comboStyle->setCurrentText(style);
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ public:
|
||||
bool themeEdited() const { return m_themeEdited; }
|
||||
void setThemeEdited(bool v) { m_themeEdited = v; }
|
||||
|
||||
bool styleEdited() const { return m_styleEdited; }
|
||||
void setStyleEdited(bool v) { m_styleEdited = v; }
|
||||
|
||||
public slots:
|
||||
void onResetToDefault() override;
|
||||
|
||||
@ -32,6 +35,7 @@ protected slots:
|
||||
|
||||
private:
|
||||
void retranslateComboTheme();
|
||||
void retranslateComboStyle();
|
||||
void retranslateComboHotKey();
|
||||
void retranslateComboTrayEvent();
|
||||
void retranslateComboTrayAction();
|
||||
@ -44,6 +48,7 @@ private:
|
||||
QLayout *setupLangLayout();
|
||||
void setupComboLanguage();
|
||||
QLayout *setupThemeLayout();
|
||||
QLayout *setupStyleLayout();
|
||||
void setupHotKeysBox();
|
||||
void refreshEditShortcut();
|
||||
QLayout *setupComboHotKeyLayout();
|
||||
@ -61,11 +66,13 @@ private:
|
||||
void setupConfirmationsBox();
|
||||
|
||||
void updateTheme();
|
||||
void updateStyle();
|
||||
|
||||
private:
|
||||
bool m_explorerEdited : 1 = false;
|
||||
bool m_languageEdited : 1 = false;
|
||||
bool m_themeEdited : 1 = false;
|
||||
bool m_styleEdited : 1 = false;
|
||||
|
||||
QGroupBox *m_gbGlobal = nullptr;
|
||||
QGroupBox *m_gbHotKeys = nullptr;
|
||||
@ -78,6 +85,8 @@ private:
|
||||
QComboBox *m_comboLanguage = nullptr;
|
||||
QLabel *m_labelTheme = nullptr;
|
||||
QComboBox *m_comboTheme = nullptr;
|
||||
QLabel *m_labelStyle = nullptr;
|
||||
QComboBox *m_comboStyle = nullptr;
|
||||
QCheckBox *m_cbUseSystemLocale = nullptr;
|
||||
QCheckBox *m_cbExcludeCapture = nullptr;
|
||||
QCheckBox *m_cbExplorerMenu = nullptr;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QProcess>
|
||||
#include <QStyle>
|
||||
#include <QStyleFactory>
|
||||
#include <QStyleHints>
|
||||
|
||||
#include <conf/confmanager.h>
|
||||
@ -36,12 +35,6 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("manager.window");
|
||||
|
||||
void setupAppStyle()
|
||||
{
|
||||
QStyle *style = QStyleFactory::create("Fusion");
|
||||
QApplication::setStyle(style);
|
||||
}
|
||||
|
||||
inline bool isWindowVisible(WidgetWindow *w)
|
||||
{
|
||||
return w && w->isVisible();
|
||||
@ -53,7 +46,6 @@ WindowManager::WindowManager(QObject *parent) : QObject(parent) { }
|
||||
|
||||
void WindowManager::setUp()
|
||||
{
|
||||
setupAppStyle();
|
||||
setupAppPalette();
|
||||
|
||||
setupMainWindow();
|
||||
@ -99,19 +91,19 @@ QFont WindowManager::defaultFont()
|
||||
|
||||
void WindowManager::setupAppPalette()
|
||||
{
|
||||
const auto refreshAppPalette = [] {
|
||||
const QPalette palette = QApplication::style()->standardPalette();
|
||||
|
||||
QApplication::setPalette(palette);
|
||||
};
|
||||
|
||||
refreshAppPalette();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
connect(QApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, refreshAppPalette);
|
||||
connect(QApplication::styleHints(), &QStyleHints::colorSchemeChanged, this,
|
||||
&WindowManager::refreshAppPalette);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowManager::refreshAppPalette()
|
||||
{
|
||||
const QPalette palette = QApplication::style()->standardPalette();
|
||||
|
||||
QApplication::setPalette(palette);
|
||||
}
|
||||
|
||||
void WindowManager::setupMainWindow()
|
||||
{
|
||||
m_mainWindow = new MainWindow();
|
||||
@ -225,6 +217,7 @@ void WindowManager::setupConfManager()
|
||||
void WindowManager::setupByIniUser(const IniUser &ini)
|
||||
{
|
||||
updateTheme(ini);
|
||||
updateStyle(ini);
|
||||
updateTrayIconVisibility(ini);
|
||||
updateGraphWindowVisibility(ini);
|
||||
}
|
||||
@ -240,6 +233,13 @@ void WindowManager::updateTheme(const IniUser &ini)
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowManager::updateStyle(const IniUser &ini)
|
||||
{
|
||||
QApplication::setStyle(ini.style());
|
||||
|
||||
refreshAppPalette();
|
||||
}
|
||||
|
||||
void WindowManager::updateTrayIconVisibility(const IniUser &ini)
|
||||
{
|
||||
if (ini.trayShowIcon()) {
|
||||
|
@ -62,8 +62,6 @@ signals:
|
||||
void windowVisibilityChanged(WindowCode code, bool isVisible);
|
||||
|
||||
public slots:
|
||||
void setupAppPalette();
|
||||
|
||||
void setupTrayIcon();
|
||||
void showTrayIcon();
|
||||
void closeTrayIcon();
|
||||
@ -137,8 +135,12 @@ public slots:
|
||||
static bool activateModalWidget();
|
||||
|
||||
static void updateTheme(const IniUser &ini);
|
||||
static void updateStyle(const IniUser &ini);
|
||||
|
||||
private:
|
||||
void setupAppPalette();
|
||||
static void refreshAppPalette();
|
||||
|
||||
void setupMainWindow();
|
||||
void closeMainWindow();
|
||||
|
||||
|
@ -60,6 +60,10 @@ public:
|
||||
QString theme() const { return valueText("base/theme"); }
|
||||
void setTheme(const QString &v) { setValue("base/theme", v); }
|
||||
|
||||
static QString styleDefault() { return "Fusion"; }
|
||||
QString style() const { return valueText("base/style", styleDefault()); }
|
||||
void setStyle(const QString &v) { setValue("base/style", v, styleDefault()); }
|
||||
|
||||
bool hotKeyEnabled() const { return valueBool("hotKey/enabled"); }
|
||||
void setHotKeyEnabled(bool v) { setValue("hotKey/enabled", v); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user