Skip to content

Commit

Permalink
chore: update the file
Browse files Browse the repository at this point in the history
  • Loading branch information
x-tools-author committed Sep 29, 2024
1 parent 8b24eba commit 7e11371
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 24 additions & 11 deletions Source/App/StyleSheetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace xTools {

bool StyleSheetManager::m_enableStylesheet = false;
bool StyleSheetManager::m_awaysEnableStylesheet = false;
StyleSheetManager::StyleSheetManager(QObject* parent)
: acss::QtAdvancedStylesheet(parent)
{
Expand Down Expand Up @@ -81,20 +82,27 @@ StyleSheetManager::StyleSheetManager(QObject* parent)
qInfo() << "The current style is:" << currentStyle();
qInfo() << "The current theme is:" << currentTheme();

bool checked = enableStylesheet();
QAction* action = new QAction(tr("Enable Stylesheet"));
action->setCheckable(true);
action->setChecked(checked);
if (checked) {
m_themeActionGroup = new QActionGroup(this);
m_themeMenu = new QMenu(tr("Application Stylesheet"));
if (m_awaysEnableStylesheet) {
updateApplicationStylesheet();
}
} else {
bool checked = enableStylesheet();
QAction* action = new QAction(tr("Enable Stylesheet"));
action->setCheckable(true);
action->setChecked(checked);
if (checked) {
updateApplicationStylesheet();
}

connect(action, &QAction::triggered, this, &StyleSheetManager::setApplicationStylesheetEnabled);
connect(action,
&QAction::triggered,
this,
&StyleSheetManager::setApplicationStylesheetEnabled);

m_themeActionGroup = new QActionGroup(this);
m_themeMenu = new QMenu(tr("Application Stylesheet"));
m_themeMenu->addAction(action);
m_themeMenu->addSeparator();
m_themeMenu->addAction(action);
m_themeMenu->addSeparator();
}

loadThemes();
}
Expand All @@ -117,6 +125,11 @@ void StyleSheetManager::setEnableStyleSheetDefaultValue(bool enabled)
m_enableStylesheet = enabled;
}

void StyleSheetManager::setAwaysEnableStylesheet(bool enabled)
{
m_awaysEnableStylesheet = enabled;
}

QString StyleSheetManager::themeName()
{
QString ret = xTools::Settings::instance()->value("themeName").toString();
Expand Down
2 changes: 2 additions & 0 deletions Source/App/StyleSheetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ class StyleSheetManager : public acss::QtAdvancedStylesheet
static StyleSheetManager& singleton();
QMenu* themeMenu() const;
static void setEnableStyleSheetDefaultValue(bool enabled);
static void setAwaysEnableStylesheet(bool enabled);

private:
QMenu* m_themeMenu;
QActionGroup* m_themeActionGroup;
QMap<QString, QString> m_nameFriendlyNameMap;
QMap<QString, QString> m_primaryColorMap;
static bool m_enableStylesheet;
static bool m_awaysEnableStylesheet;

private:
QString themeName();
Expand Down

0 comments on commit 7e11371

Please sign in to comment.