From e5434add8f21af2931ed39be358f9a390007c55c Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 13 Sep 2025 22:30:35 +0800 Subject: [PATCH 01/14] U liteappoption.cpp: 1.minimal test: editor theme follow app theme: hardcoded editor light/dark theme --- liteidex/src/liteapp/liteappoption.cpp | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index 0bb6b292e..e4b23a2c8 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -144,6 +144,43 @@ QString LiteAppOption::mimeType() const return OPTION_LITEAPP; } +bool guess_dark(QString qss){ + // printf("--- guess_dark: %s\n", qss.toStdString().c_str()); + QString dark_keywords[] = { "black", "dark", "night" }; + QString dark_names[] = { "carbon", "detroit-future", "gray", "sublime" }; + + QString qss_lower = qss.toLower(); + + for (const QString &keyword : dark_keywords) { + if (qss_lower.contains(keyword)) { + // qDebug() << "= guess dark by keyword:" << keyword; + return true; + } + } + if (qss_lower.endsWith(".qss")) { + qss_lower.chop(4); + } + for (const QString &theme : dark_names) { + if (qss_lower == theme) { + // qDebug() << "= guess dark by name:" << theme; + return true; + } + } + + return false; +} + +void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp){ + //----1.check if dark + bool is_dark = guess_dark(qss); + qDebug() << "auto_editor_theme:" << qss << "is_dark?" << is_dark; + + //----2.apply editor theme (hard-coded theme) + QString style = is_dark? "sublime.xml": "visualstudio.xml"; + QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; + m_liteApp->editorManager()->loadColorStyleScheme(styleFile); +} + void LiteAppOption::save() { bool storeLocal = ui->storeLocalCheckBox->isChecked(); @@ -225,6 +262,9 @@ void LiteAppOption::save() m_liteApp->settings()->setValue(LITEAPP_QSS,qss); QString styleSheet = QLatin1String(f.readAll()); qApp->setStyleSheet(styleSheet); + + //chen: auto editor theme + auto_editor_theme(qss, m_liteApp); } } From a8a3ed387fa9b42551c46814abb95682f3fa59bc Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 13 Sep 2025 22:53:34 +0800 Subject: [PATCH 02/14] U main.cpp: 2.minimal test: app theme follow system theme: hardcoded app light/dark theme --- liteidex/src/liteapp/main.cpp | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/liteidex/src/liteapp/main.cpp b/liteidex/src/liteapp/main.cpp index cfd5d1542..4389f8d03 100644 --- a/liteidex/src/liteapp/main.cpp +++ b/liteidex/src/liteapp/main.cpp @@ -90,6 +90,66 @@ class LiteIDEApplication : public QApplication { }; #endif + +#include + +//chen: +extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); + +void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_liteApp){ + // QFile f(resPath+"/liteapp/qss/"+qss); + QFile f(m_liteApp->resourcePath()+"/liteapp/qss/"+qss); + if (f.open(QFile::ReadOnly)) { + QString styleSheet = QLatin1String(f.readAll()); + app.setStyleSheet(styleSheet); + } + + auto_editor_theme(qss, m_liteApp); +} + +void monit_system_theme_change(QApplication *app, LiteApi::IApplication *m_liteApp){ + qDebug()<< "=== monit_system_theme_change..."; + + // 启动 gsettings monitor 进程 + // gsettings monitor org.gnome.desktop.interface color-scheme + QProcess *proc = new QProcess(app); + proc->setProcessChannelMode(QProcess::MergedChannels); + proc->start("gsettings", {"monitor", "org.gnome.desktop.interface", "color-scheme"}); + + // 初始读取一次 + { + QProcess getProc; + getProc.start("gsettings", {"get", "org.gnome.desktop.interface", "color-scheme"}); + getProc.waitForFinished(); + QString theme = getProc.readAllStandardOutput().trimmed(); + theme = theme.remove("'"); + qDebug() << "== system theme current:" << theme; + + //----- 0. init theme + bool is_dark = theme.contains("dark", Qt::CaseInsensitive); + QString qss = is_dark ? "gray.qss" : "default.qss"; + auto_app_theme(qss, *app, m_liteApp); + } + + // 监听变化 + QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app, m_liteApp]() { + while (proc->canReadLine()) { + QString line = QString::fromUtf8(proc->readLine()).trimmed(); + if (line.contains("color-scheme")) { + QString theme = line.section(' ', -1); // 取最后一个单词 + theme = theme.remove("'"); + qDebug() << "== system theme changed:" << theme; + + bool is_dark = theme.contains("dark", Qt::CaseInsensitive); + QString qss = is_dark ? "gray.qss" : "default.qss"; + //------- 1. auto theme + auto_app_theme(qss, *app, m_liteApp); + } + } + }); + +} + #ifdef LITEAPP_LIBRARY int liteapp_main(int argc, char *argv[]) #else @@ -224,6 +284,10 @@ int main(int argc, char *argv[]) app.liteApp = liteApp; #endif + //chen: auto editor theme + auto_editor_theme(qss, liteApp); + monit_system_theme_change(&app, liteApp); + foreach(QString file, fileList) { QFileInfo f(file); if (f.isFile()) { From 9f2ee9bc7bd8feb76fd38f27df456d93e29c4d26 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 11:29:15 +0800 Subject: [PATCH 03/14] U liteeditor*.{h,cpp,ui}: 3. add editor_dark_theme option --- .../plugins/liteeditor/liteeditor_global.h | 1 + .../plugins/liteeditor/liteeditoroption.cpp | 23 +++++++++++ .../plugins/liteeditor/liteeditoroption.ui | 41 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/liteidex/src/plugins/liteeditor/liteeditor_global.h b/liteidex/src/plugins/liteeditor/liteeditor_global.h index a9c401cc2..599ae4a99 100644 --- a/liteidex/src/plugins/liteeditor/liteeditor_global.h +++ b/liteidex/src/plugins/liteeditor/liteeditor_global.h @@ -41,6 +41,7 @@ #define OPTION_LITEEDITOR "option/liteeditor" #define EDITOR_STYLE "editor/style" +#define EDITOR_STYLE_DARK "editor/style_dark" #define EDITOR_FAMILY "editor/family" #define EDITOR_FONTSIZE "editor/fontsize" #define EDITOR_FONTZOOM "editor/fontzoom" diff --git a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp index 082e20ec0..3fd83bd22 100755 --- a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp +++ b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp @@ -30,6 +30,7 @@ #include #include #include +#include //lite_memory_check_begin #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) @@ -128,6 +129,12 @@ void LiteEditorOption::save() QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; m_liteApp->editorManager()->loadColorStyleScheme(styleFile); } + // CHEN: save style_dark + QString style_dark = ui->styleComboBox_dark->currentText(); + if (style_dark != m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString()) { + m_liteApp->settings()->setValue(EDITOR_STYLE_DARK,style_dark); + qDebug() << "=== editor_dark_theme save:" << style_dark; + } bool noprintCheck = ui->noprintCheckBox->isChecked(); bool autoIndent = ui->autoIndentCheckBox->isChecked(); @@ -229,23 +236,39 @@ void LiteEditorOption::load() ui->fontZoomSpinBox->setValue(fontZoom); + //CHEN: load style_dark + QString styleName_dark = m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString(); QString styleName = m_liteApp->settings()->value(EDITOR_STYLE,"default.xml").toString(); QString stylePath = m_liteApp->resourcePath()+"/liteeditor/color"; QDir dir(stylePath); + int index_dark = -1; int index = -1; if (!QFileInfo(stylePath,styleName).exists()) { styleName = "default.xml"; } + + //----- CHEN: 加载可选 editor theme ui->styleComboBox->clear(); + ui->styleComboBox_dark->clear(); foreach(QFileInfo info, dir.entryInfoList(QStringList() << "*.xml")) { ui->styleComboBox->addItem(info.fileName()); + ui->styleComboBox_dark->addItem(info.fileName()); if (info.fileName() == styleName) { index = ui->styleComboBox->count()-1; } + if (info.fileName() == styleName_dark) { + index_dark = ui->styleComboBox_dark->count()-1; + } } if (index >= 0 && index < ui->styleComboBox->count()) { ui->styleComboBox->setCurrentIndex(index); } + if (index_dark >= 0 && index_dark < ui->styleComboBox_dark->count()) { + ui->styleComboBox_dark->setCurrentIndex(index_dark); + } + ui->styleComboBox_dark->addItem("NOT SET"); + qDebug() << "=== editor_dark_theme load:" << styleName_dark; + bool noprintCheck = m_liteApp->settings()->value(EDITOR_NOPRINTCHECK,true).toBool(); bool autoIndent = m_liteApp->settings()->value(EDITOR_AUTOINDENT,true).toBool(); bool autoBraces0 = m_liteApp->settings()->value(EDITOR_AUTOBRACE0,true).toBool(); diff --git a/liteidex/src/plugins/liteeditor/liteeditoroption.ui b/liteidex/src/plugins/liteeditor/liteeditoroption.ui index 3deb9c9a0..3f3557156 100644 --- a/liteidex/src/plugins/liteeditor/liteeditoroption.ui +++ b/liteidex/src/plugins/liteeditor/liteeditoroption.ui @@ -191,6 +191,47 @@ + + + + + + Dark: + + + + + + + + 0 + 0 + + + + + + + + Edit + + + + + + + Qt::Horizontal + + + + 37 + 17 + + + + + + From 83694433019ebfe0a881f49d1b1d569230211b7b Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 12:37:33 +0800 Subject: [PATCH 04/14] U liteappoption.cpp: 3. use editor_dark_theme option --- liteidex/src/liteapp/liteappoption.cpp | 27 ++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index e4b23a2c8..ba8a7ff5b 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -173,12 +173,27 @@ bool guess_dark(QString qss){ void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp){ //----1.check if dark bool is_dark = guess_dark(qss); - qDebug() << "auto_editor_theme:" << qss << "is_dark?" << is_dark; - - //----2.apply editor theme (hard-coded theme) - QString style = is_dark? "sublime.xml": "visualstudio.xml"; - QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; - m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + qDebug() << "--- auto_editor_theme guess_dark:" << qss << (is_dark ? "dark" : "light"); + + //----2.get editor settings + #define EDITOR_STYLE "editor/style" + #define EDITOR_STYLE_DARK "editor/style_dark" + QString styleName = m_liteApp->settings()->value(EDITOR_STYLE,"default.xml").toString(); + QString styleName_dark = m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString(); + + //----3.apply editor theme + if (is_dark && styleName_dark != "NOT SET") { + // styleName = styleName_dark; + qDebug() << "=== auto_editor_theme dark:" << styleName_dark; + QString style = styleName_dark; + QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; + m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + }else{ + qDebug() << "=== auto_editor_theme light:" << styleName; + QString style = styleName; + QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; + m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + } } void LiteAppOption::save() From 0ba97239aeca00bbe8531bb61e9681019e6a6232 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 12:52:51 +0800 Subject: [PATCH 05/14] U liteapp*.{h,cpp,ui}: 5. add app_dark_theme option --- liteidex/src/liteapp/liteapp_global.h | 1 + liteidex/src/liteapp/liteappoption.cpp | 22 +++++++++++++++ liteidex/src/liteapp/liteappoption.ui | 39 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/liteidex/src/liteapp/liteapp_global.h b/liteidex/src/liteapp/liteapp_global.h index e10cdd7af..b73691580 100644 --- a/liteidex/src/liteapp/liteapp_global.h +++ b/liteidex/src/liteapp/liteapp_global.h @@ -53,6 +53,7 @@ #define LITEAPP_EDITTABSENABLEWHELL "LiteApp/EditTabEnableWhell" #define LITEAPP_SHOWEDITTOOLBAR "LiteApp/ShowEditToolbar" #define LITEAPP_QSS "LiteApp/Qss" +#define LITEAPP_QSS_DARK "LiteApp/Qss_dark" #define LITEAPP_FULLSCREEN "LiteApp/FullScreen" #define LITEAPP_WINSTATE "LiteApp/WinState" #define LITEAPP_SHORTCUTS "keybord_shortcuts/" diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index ba8a7ff5b..cce81f24f 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -102,6 +102,12 @@ LiteAppOption::LiteAppOption(LiteApi::IApplication *app,QObject *parent) : foreach (QFileInfo info, qssDir.entryInfoList(QStringList() << "*.qss")) { ui->qssComboBox->addItem(info.fileName()); } + + // qss dark: init + foreach (QFileInfo info, qssDir.entryInfoList(QStringList() << "*.qss")) { + ui->qssComboBox_dark->addItem(info.fileName()); + } + ui->qssComboBox_dark->addItem(QString("NOT SET")); } // if (libgopher.isValid()) { @@ -282,6 +288,15 @@ void LiteAppOption::save() auto_editor_theme(qss, m_liteApp); } } + // qss dark: save + QString qss_dark = ui->qssComboBox_dark->currentText(); + if (!qss_dark.isEmpty()) { + m_liteApp->settings()->setValue(LITEAPP_QSS_DARK,qss_dark); + + //chen: auto editor theme + // auto_editor_theme(qss, m_liteApp); + } + qDebug() << "=== save qss, qss_dark:" << qss << qss_dark; bool customelIcon = ui->customIconCheckBox->isChecked(); m_liteApp->settings()->setValue(LITEIDE_CUSTOMEICON,customelIcon); @@ -346,6 +361,13 @@ void LiteAppOption::load() if (index >= 0 && index < ui->qssComboBox->count()) { ui->qssComboBox->setCurrentIndex(index); } + //qss dark: load + QString qss_dark = m_liteApp->settings()->value(LITEAPP_QSS_DARK,"NOT SET").toString(); + int index2 = ui->qssComboBox_dark->findText(qss_dark,Qt::MatchFixedString); + if (index2 >= 0 && index < ui->qssComboBox_dark->count()) { + ui->qssComboBox_dark->setCurrentIndex(index2); + } + qDebug() << "=== load qss, qss_dark:" << qss << qss_dark << index2; int max = m_liteApp->settings()->value(LITEAPP_MAXRECENTFILES,32).toInt(); //ui->maxRecentLineEdit->setText(QString("%1").arg(max)); diff --git a/liteidex/src/liteapp/liteappoption.ui b/liteidex/src/liteapp/liteappoption.ui index 9d61dc5d7..0775b6c2a 100644 --- a/liteidex/src/liteapp/liteappoption.ui +++ b/liteidex/src/liteapp/liteappoption.ui @@ -178,6 +178,45 @@ + + + + + + + + Theme Dark + + + + + + Theme: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + From 3aadec84acde5a7a85616963826f331e61d5bab7 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 13:21:53 +0800 Subject: [PATCH 06/14] U main.cpp: improve auto_app_theme: use instance from LiteApp::appList --- liteidex/src/liteapp/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/liteidex/src/liteapp/main.cpp b/liteidex/src/liteapp/main.cpp index 4389f8d03..608642a44 100644 --- a/liteidex/src/liteapp/main.cpp +++ b/liteidex/src/liteapp/main.cpp @@ -105,6 +105,11 @@ void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_lit } auto_editor_theme(qss, m_liteApp); + // foreach(LiteApi::IApplication *liteApp, m_liteApp->appList()) { + // foreach(LiteApi::IApplication *liteApp, m_liteApp->instanceList()) { + // qDebug() << " >>> auto_app_theme: - instance:" << liteApp; + // auto_editor_theme(qss, liteApp); + // } } void monit_system_theme_change(QApplication *app, LiteApi::IApplication *m_liteApp){ @@ -132,18 +137,23 @@ void monit_system_theme_change(QApplication *app, LiteApi::IApplication *m_liteA } // 监听变化 - QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app, m_liteApp]() { + // QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app, m_liteApp]() { + QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app]() { while (proc->canReadLine()) { QString line = QString::fromUtf8(proc->readLine()).trimmed(); if (line.contains("color-scheme")) { QString theme = line.section(' ', -1); // 取最后一个单词 theme = theme.remove("'"); qDebug() << "== system theme changed:" << theme; + // qDebug() << "== system theme changed:" << theme << m_liteApp; bool is_dark = theme.contains("dark", Qt::CaseInsensitive); QString qss = is_dark ? "gray.qss" : "default.qss"; //------- 1. auto theme - auto_app_theme(qss, *app, m_liteApp); + // auto_app_theme(qss, *app, m_liteApp); + foreach(LiteApi::IApplication *liteApp, LiteApp::appList()) { + auto_app_theme(qss, *app, liteApp); + } } } }); From 143dbec1b186a16947dbb336fa9f958b8100bc26 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 13:57:40 +0800 Subject: [PATCH 07/14] U liteappoption.cpp: improve auto_editor_theme() --- liteidex/src/liteapp/liteappoption.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index cce81f24f..1454a8640 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -176,10 +176,20 @@ bool guess_dark(QString qss){ return false; } +extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); + void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp){ //----1.check if dark bool is_dark = guess_dark(qss); - qDebug() << "--- auto_editor_theme guess_dark:" << qss << (is_dark ? "dark" : "light"); + qDebug() << "--- auto_editor_theme guess_dark:" << qss << (is_dark ? "dark" : "light") << " //app:" << m_liteApp; + + auto_editor_theme(is_dark, m_liteApp); +} + +void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp){ + //----1.check if dark + // bool is_dark = guess_dark(qss); + // qDebug() << "--- auto_editor_theme guess_dark:" << (is_dark ? "dark" : "light") << " //app:" << m_liteApp; //----2.get editor settings #define EDITOR_STYLE "editor/style" From 6057fca1ac56602cdd6b80b2274ae189d9bae90a Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 14:00:12 +0800 Subject: [PATCH 08/14] U liteapp.{cpp,h}, main.cpp: improve auto_editor_theme: add ::s_darkMode --- liteidex/src/liteapp/liteapp.cpp | 9 +++++++++ liteidex/src/liteapp/liteapp.h | 1 + liteidex/src/liteapp/main.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/liteidex/src/liteapp/liteapp.cpp b/liteidex/src/liteapp/liteapp.cpp index aed788a00..0a1b81279 100644 --- a/liteidex/src/liteapp/liteapp.cpp +++ b/liteidex/src/liteapp/liteapp.cpp @@ -74,6 +74,10 @@ #define LITEIDE_VERSION "X38.4" +//chen +extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); +extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); + QString LiteApp::getRootPath() { @@ -136,6 +140,9 @@ IApplication* LiteApp::NewApplication(const QString &sessionName, IApplication * { LiteApp *app = new LiteApp; app->load(sessionName,baseApp); + + //chen: improve for new app instance + auto_editor_theme(LiteApp::s_darkMode, app); return app; } @@ -154,6 +161,8 @@ QMap LiteApp::s_cookie; QList LiteApp::s_appList; +bool LiteApp::s_darkMode; + LiteApp::LiteApp() : m_rootPath(LiteApp::getRootPath()), m_applicationPath(QApplication::applicationDirPath()), diff --git a/liteidex/src/liteapp/liteapp.h b/liteidex/src/liteapp/liteapp.h index a36bca8e4..c2d60e1a8 100644 --- a/liteidex/src/liteapp/liteapp.h +++ b/liteidex/src/liteapp/liteapp.h @@ -159,6 +159,7 @@ protected slots: public: static QMap s_cookie; static QList s_appList; + static bool s_darkMode; //app dark or light protected: QAction *m_newAct; QAction *m_openFileAct; diff --git a/liteidex/src/liteapp/main.cpp b/liteidex/src/liteapp/main.cpp index 608642a44..7a0677939 100644 --- a/liteidex/src/liteapp/main.cpp +++ b/liteidex/src/liteapp/main.cpp @@ -95,6 +95,8 @@ class LiteIDEApplication : public QApplication { //chen: extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); +extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); +extern bool guess_dark(QString qss); void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_liteApp){ // QFile f(resPath+"/liteapp/qss/"+qss); @@ -103,8 +105,11 @@ void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_lit QString styleSheet = QLatin1String(f.readAll()); app.setStyleSheet(styleSheet); } + + LiteApp::s_darkMode = guess_dark(qss); + auto_editor_theme(LiteApp::s_darkMode, m_liteApp); - auto_editor_theme(qss, m_liteApp); + // auto_editor_theme(qss, m_liteApp); // foreach(LiteApi::IApplication *liteApp, m_liteApp->appList()) { // foreach(LiteApi::IApplication *liteApp, m_liteApp->instanceList()) { // qDebug() << " >>> auto_app_theme: - instance:" << liteApp; From d29b2670f3220eda51a8d6bdd03286e87ec1517b Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 20:17:17 +0800 Subject: [PATCH 09/14] A thememanager.cpp,h: add thememanager class --- liteidex/src/liteapp/thememanager.cpp | 252 ++++++++++++++++++++++++++ liteidex/src/liteapp/thememanager.h | 38 ++++ 2 files changed, 290 insertions(+) create mode 100644 liteidex/src/liteapp/thememanager.cpp create mode 100644 liteidex/src/liteapp/thememanager.h diff --git a/liteidex/src/liteapp/thememanager.cpp b/liteidex/src/liteapp/thememanager.cpp new file mode 100644 index 000000000..f78591617 --- /dev/null +++ b/liteidex/src/liteapp/thememanager.cpp @@ -0,0 +1,252 @@ + +#include +#include +#include +#include + +#include "liteapp.h" + +#ifndef Q_OS_LINUX + #define Q_OS_LINUX 11 +#endif + +class ThemeManager : public QObject { + Q_OBJECT + +public: + //single instance + static ThemeManager* instance(QObject *parent = nullptr) { + static ThemeManager* _instance = nullptr; + if (!_instance) { + _instance = new ThemeManager(parent); + } + return _instance; + } + + explicit ThemeManager(QObject *parent = nullptr); + + static bool system_dark_mode; + static bool app_dark_mode; + static QApplication *app; + + static void monit_system_theme(QApplication *app); + + static void app_theme_changed(QString qss); + static void editor_theme_changed(); + static bool guess_app_theme_dark(QString qss); + + static void apply_to_liteApp(LiteApp *liteApp); + +signals: + void system_theme_change(bool dark_mode); + void app_theme_change(bool dark_mode); + +public slots: + void setting_changed(); + void system_theme_onchange(bool dark_mode); + + +}; + +// Static member initialization +bool ThemeManager::system_dark_mode = false; +bool ThemeManager::app_dark_mode = false; +QApplication *ThemeManager::app; + +void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); +void auto_app_theme(bool is_dark, QApplication &app, LiteApi::IApplication *m_liteApp); + +ThemeManager::ThemeManager(QObject *parent) : QObject(parent) { + +} + +void ThemeManager::apply_to_liteApp(LiteApp *liteApp) { + if (!liteApp) return; + + auto_editor_theme(LiteApp::s_darkMode, liteApp); +} + +void ThemeManager::system_theme_onchange(bool dark_mode) { + foreach(LiteApi::IApplication *liteApp, LiteApp::appList()) { + // auto_app_theme(qss, *app, liteApp); + // auto_app_theme(dark_mode, *app, liteApp); + auto_app_theme(dark_mode, *ThemeManager::app, liteApp); + } +} + +void ThemeManager::app_theme_changed(QString qss){ + bool is_dark = guess_app_theme_dark(qss); + if (is_dark != app_dark_mode) { + app_dark_mode = is_dark; + emit instance()->app_theme_change(app_dark_mode); + } +} +void ThemeManager::editor_theme_changed(){ + qDebug()<< "=== editor_thene_changed: need reload!"; +} + +bool ThemeManager::guess_app_theme_dark(QString qss){ + // printf("--- guess_dark: %s\n", qss.toStdString().c_str()); + QString dark_keywords[] = { "black", "dark", "night" }; + QString dark_names[] = { "carbon", "detroit-future", "gray", "sublime" }; + + QString qss_lower = qss.toLower(); + + for (const QString &keyword : dark_keywords) { + if (qss_lower.contains(keyword)) { + // qDebug() << "= guess dark by keyword:" << keyword; + return true; + } + } + if (qss_lower.endsWith(".qss")) { + qss_lower.chop(4); + } + for (const QString &theme : dark_names) { + if (qss_lower == theme) { + // qDebug() << "= guess dark by name:" << theme; + return true; + } + } + + return false; +} + +void ThemeManager::monit_system_theme(QApplication *app) { +// void ThemeManager::monit_system_theme(QObject *app) { + // monitor system theme and emit signal if changed + + ThemeManager::app = app; + +#if defined(Q_OS_LINUX) + + qDebug()<< "=== monit_system_theme_change..."; + + // 启动 gsettings monitor 进程 + // gsettings monitor org.gnome.desktop.interface color-scheme + QProcess *proc = new QProcess(app); + proc->setProcessChannelMode(QProcess::MergedChannels); + proc->start("gsettings", {"monitor", "org.gnome.desktop.interface", "color-scheme"}); + + // 初始读取一次 + { + QProcess getProc; + getProc.start("gsettings", {"get", "org.gnome.desktop.interface", "color-scheme"}); + getProc.waitForFinished(); + QString theme = getProc.readAllStandardOutput().trimmed(); + theme = theme.remove("'"); + qDebug() << "== system theme current:" << theme; + + //----- 0. init theme + bool is_dark = theme.contains("dark", Qt::CaseInsensitive); + system_dark_mode = is_dark; + // emit instance()->system_theme_change(system_dark_mode); + instance()->system_theme_onchange(system_dark_mode); + } + + // 监听变化 + QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app]() { + while (proc->canReadLine()) { + QString line = QString::fromUtf8(proc->readLine()).trimmed(); + if (line.contains("color-scheme")) { + QString theme = line.section(' ', -1); // 取最后一个单词 + theme = theme.remove("'"); + qDebug() << "== system theme changed:" << theme; + + bool is_dark = theme.contains("dark", Qt::CaseInsensitive); + + bool new_mode = is_dark; + if (new_mode != system_dark_mode) { + system_dark_mode = new_mode; + // emit instance()->system_theme_change(system_dark_mode); + + instance()->system_theme_onchange(system_dark_mode); + } + } + } + }); + +#elif defined(Q_OS_WIN) + +#elif defined(Q_OS_MAC) + +#else + +#endif +} + + +bool guess_dark(QString qss){ + // printf("--- guess_dark: %s\n", qss.toStdString().c_str()); + QString dark_keywords[] = { "black", "dark", "night" }; + QString dark_names[] = { "carbon", "detroit-future", "gray", "sublime" }; + + QString qss_lower = qss.toLower(); + + for (const QString &keyword : dark_keywords) { + if (qss_lower.contains(keyword)) { + // qDebug() << "= guess dark by keyword:" << keyword; + return true; + } + } + if (qss_lower.endsWith(".qss")) { + qss_lower.chop(4); + } + for (const QString &theme : dark_names) { + if (qss_lower == theme) { + // qDebug() << "= guess dark by name:" << theme; + return true; + } + } + + return false; +} + +void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp){ + //----1.check if dark + // bool is_dark = guess_dark(qss); + // qDebug() << "--- auto_editor_theme guess_dark:" << (is_dark ? "dark" : "light") << " //app:" << m_liteApp; + + //----2.get editor settings + #define EDITOR_STYLE "editor/style" + #define EDITOR_STYLE_DARK "editor/style_dark" + QString styleName = m_liteApp->settings()->value(EDITOR_STYLE,"default.xml").toString(); + QString styleName_dark = m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString(); + + //----3.apply editor theme + if (is_dark && styleName_dark != "NOT SET") { + // styleName = styleName_dark; + qDebug() << "=== auto_editor_theme dark:" << styleName_dark; + QString style = styleName_dark; + QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; + m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + }else{ + qDebug() << "=== auto_editor_theme light:" << styleName; + QString style = styleName; + QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; + m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + } +} + +void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_liteApp){ + // QFile f(resPath+"/liteapp/qss/"+qss); + QFile f(m_liteApp->resourcePath()+"/liteapp/qss/"+qss); + if (f.open(QFile::ReadOnly)) { + QString styleSheet = QLatin1String(f.readAll()); + app.setStyleSheet(styleSheet); + } + + LiteApp::s_darkMode = guess_dark(qss); + auto_editor_theme(LiteApp::s_darkMode, m_liteApp); + + // auto_editor_theme(qss, m_liteApp); + // foreach(LiteApi::IApplication *liteApp, m_liteApp->appList()) { + // foreach(LiteApi::IApplication *liteApp, m_liteApp->instanceList()) { + // qDebug() << " >>> auto_app_theme: - instance:" << liteApp; + // auto_editor_theme(qss, liteApp); + // } +} + +void auto_app_theme(bool is_dark, QApplication &app, LiteApi::IApplication *m_liteApp){ + QString qss = is_dark ? "gray.qss" : "default.qss"; + auto_app_theme(qss, app, m_liteApp); +} diff --git a/liteidex/src/liteapp/thememanager.h b/liteidex/src/liteapp/thememanager.h new file mode 100644 index 000000000..4c63caf0d --- /dev/null +++ b/liteidex/src/liteapp/thememanager.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +#include "liteapp.h" + +class ThemeManager : public QObject { + Q_OBJECT + +public: + static ThemeManager* instance(QObject *parent = nullptr); + + explicit ThemeManager(QObject *parent = nullptr); + + static bool system_dark_mode; + static bool app_dark_mode; + + //init + static void monit_system_theme(QApplication *app); + + //call when change + static void app_theme_changed(QString qss); + static void editor_theme_changed(); + + //call when liteApp created + static void apply_to_liteApp(LiteApp *liteApp); +private: + static bool guess_app_theme_dark(QString qss); + +signals: + void system_theme_change(bool dark_mode); + void app_theme_change(bool dark_mode); + +public slots: + void setting_changed(); +}; \ No newline at end of file From 3f63599b7c3b36ee64ef085404afd02d7688c7eb Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 20:18:58 +0800 Subject: [PATCH 10/14] U liteapp.pro: add thememanager --- liteidex/src/liteapp/liteapp.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/liteidex/src/liteapp/liteapp.pro b/liteidex/src/liteapp/liteapp.pro index 6eb9d257c..13cae7ad9 100644 --- a/liteidex/src/liteapp/liteapp.pro +++ b/liteidex/src/liteapp/liteapp.pro @@ -75,6 +75,7 @@ SOURCES += main.cpp\ folderprojectfactory.cpp \ goproxy.cpp \ htmlwidgetmanager.cpp \ + thememanager.cpp \ textbrowserhtmlwidget.cpp \ splitwindowstyle.cpp \ sidewindowstyle.cpp \ @@ -110,6 +111,7 @@ HEADERS += mainwindow.h \ goproxy.h \ cdrv.h \ htmlwidgetmanager.h \ + thememanager.h \ textbrowserhtmlwidget.h \ windowstyle.h \ splitwindowstyle.h \ From a7a4b26cca534866a31c67b74911e8d030bb6534 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 14 Sep 2025 20:20:52 +0800 Subject: [PATCH 11/14] U liteapp.cpp,liteappoption.cpp,liteeditoroption.cpp,main.cpp: use thememanager --- liteidex/src/liteapp/liteapp.cpp | 7 +- liteidex/src/liteapp/liteappoption.cpp | 66 +-------------- liteidex/src/liteapp/main.cpp | 82 +++---------------- .../plugins/liteeditor/liteeditoroption.cpp | 8 ++ 4 files changed, 28 insertions(+), 135 deletions(-) diff --git a/liteidex/src/liteapp/liteapp.cpp b/liteidex/src/liteapp/liteapp.cpp index 0a1b81279..681123ab7 100644 --- a/liteidex/src/liteapp/liteapp.cpp +++ b/liteidex/src/liteapp/liteapp.cpp @@ -62,6 +62,9 @@ #include #include #include + +#include "thememanager.h" + //lite_memory_check_begin #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC @@ -142,7 +145,9 @@ IApplication* LiteApp::NewApplication(const QString &sessionName, IApplication * app->load(sessionName,baseApp); //chen: improve for new app instance - auto_editor_theme(LiteApp::s_darkMode, app); + // auto_editor_theme(LiteApp::s_darkMode, app); + ThemeManager::apply_to_liteApp(app); + return app; } diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index 1454a8640..5a6e43b57 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -34,6 +34,8 @@ #include #include +#include "thememanager.h" + //lite_memory_check_begin #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC @@ -150,67 +152,6 @@ QString LiteAppOption::mimeType() const return OPTION_LITEAPP; } -bool guess_dark(QString qss){ - // printf("--- guess_dark: %s\n", qss.toStdString().c_str()); - QString dark_keywords[] = { "black", "dark", "night" }; - QString dark_names[] = { "carbon", "detroit-future", "gray", "sublime" }; - - QString qss_lower = qss.toLower(); - - for (const QString &keyword : dark_keywords) { - if (qss_lower.contains(keyword)) { - // qDebug() << "= guess dark by keyword:" << keyword; - return true; - } - } - if (qss_lower.endsWith(".qss")) { - qss_lower.chop(4); - } - for (const QString &theme : dark_names) { - if (qss_lower == theme) { - // qDebug() << "= guess dark by name:" << theme; - return true; - } - } - - return false; -} - -extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); - -void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp){ - //----1.check if dark - bool is_dark = guess_dark(qss); - qDebug() << "--- auto_editor_theme guess_dark:" << qss << (is_dark ? "dark" : "light") << " //app:" << m_liteApp; - - auto_editor_theme(is_dark, m_liteApp); -} - -void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp){ - //----1.check if dark - // bool is_dark = guess_dark(qss); - // qDebug() << "--- auto_editor_theme guess_dark:" << (is_dark ? "dark" : "light") << " //app:" << m_liteApp; - - //----2.get editor settings - #define EDITOR_STYLE "editor/style" - #define EDITOR_STYLE_DARK "editor/style_dark" - QString styleName = m_liteApp->settings()->value(EDITOR_STYLE,"default.xml").toString(); - QString styleName_dark = m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString(); - - //----3.apply editor theme - if (is_dark && styleName_dark != "NOT SET") { - // styleName = styleName_dark; - qDebug() << "=== auto_editor_theme dark:" << styleName_dark; - QString style = styleName_dark; - QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; - m_liteApp->editorManager()->loadColorStyleScheme(styleFile); - }else{ - qDebug() << "=== auto_editor_theme light:" << styleName; - QString style = styleName; - QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; - m_liteApp->editorManager()->loadColorStyleScheme(styleFile); - } -} void LiteAppOption::save() { @@ -295,7 +236,8 @@ void LiteAppOption::save() qApp->setStyleSheet(styleSheet); //chen: auto editor theme - auto_editor_theme(qss, m_liteApp); + // auto_editor_theme(qss, m_liteApp); + ThemeManager::app_theme_changed(qss); } } // qss dark: save diff --git a/liteidex/src/liteapp/main.cpp b/liteidex/src/liteapp/main.cpp index 7a0677939..51b50f644 100644 --- a/liteidex/src/liteapp/main.cpp +++ b/liteidex/src/liteapp/main.cpp @@ -41,6 +41,9 @@ #include "liteapp.h" #include "goproxy.h" #include "cdrv.h" + +#include "thememanager.h" + //lite_memory_check_begin #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC @@ -91,79 +94,12 @@ class LiteIDEApplication : public QApplication { #endif -#include //chen: -extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); -extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); -extern bool guess_dark(QString qss); - -void auto_app_theme(QString qss, QApplication &app, LiteApi::IApplication *m_liteApp){ - // QFile f(resPath+"/liteapp/qss/"+qss); - QFile f(m_liteApp->resourcePath()+"/liteapp/qss/"+qss); - if (f.open(QFile::ReadOnly)) { - QString styleSheet = QLatin1String(f.readAll()); - app.setStyleSheet(styleSheet); - } - - LiteApp::s_darkMode = guess_dark(qss); - auto_editor_theme(LiteApp::s_darkMode, m_liteApp); - - // auto_editor_theme(qss, m_liteApp); - // foreach(LiteApi::IApplication *liteApp, m_liteApp->appList()) { - // foreach(LiteApi::IApplication *liteApp, m_liteApp->instanceList()) { - // qDebug() << " >>> auto_app_theme: - instance:" << liteApp; - // auto_editor_theme(qss, liteApp); - // } -} - -void monit_system_theme_change(QApplication *app, LiteApi::IApplication *m_liteApp){ - qDebug()<< "=== monit_system_theme_change..."; - - // 启动 gsettings monitor 进程 - // gsettings monitor org.gnome.desktop.interface color-scheme - QProcess *proc = new QProcess(app); - proc->setProcessChannelMode(QProcess::MergedChannels); - proc->start("gsettings", {"monitor", "org.gnome.desktop.interface", "color-scheme"}); - - // 初始读取一次 - { - QProcess getProc; - getProc.start("gsettings", {"get", "org.gnome.desktop.interface", "color-scheme"}); - getProc.waitForFinished(); - QString theme = getProc.readAllStandardOutput().trimmed(); - theme = theme.remove("'"); - qDebug() << "== system theme current:" << theme; - - //----- 0. init theme - bool is_dark = theme.contains("dark", Qt::CaseInsensitive); - QString qss = is_dark ? "gray.qss" : "default.qss"; - auto_app_theme(qss, *app, m_liteApp); - } +// extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); +// extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); +// extern bool guess_dark(QString qss); - // 监听变化 - // QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app, m_liteApp]() { - QObject::connect(proc, &QProcess::readyReadStandardOutput, app, [proc, app]() { - while (proc->canReadLine()) { - QString line = QString::fromUtf8(proc->readLine()).trimmed(); - if (line.contains("color-scheme")) { - QString theme = line.section(' ', -1); // 取最后一个单词 - theme = theme.remove("'"); - qDebug() << "== system theme changed:" << theme; - // qDebug() << "== system theme changed:" << theme << m_liteApp; - - bool is_dark = theme.contains("dark", Qt::CaseInsensitive); - QString qss = is_dark ? "gray.qss" : "default.qss"; - //------- 1. auto theme - // auto_app_theme(qss, *app, m_liteApp); - foreach(LiteApi::IApplication *liteApp, LiteApp::appList()) { - auto_app_theme(qss, *app, liteApp); - } - } - } - }); - -} #ifdef LITEAPP_LIBRARY int liteapp_main(int argc, char *argv[]) @@ -300,8 +236,10 @@ int main(int argc, char *argv[]) #endif //chen: auto editor theme - auto_editor_theme(qss, liteApp); - monit_system_theme_change(&app, liteApp); + ThemeManager themeManager(&app); + ThemeManager::monit_system_theme(&app); + // auto_editor_theme(qss, liteApp); + // monit_system_theme_change(&app, liteApp); foreach(QString file, fileList) { QFileInfo f(file); diff --git a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp index 3fd83bd22..cdf023e7f 100755 --- a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp +++ b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp @@ -32,6 +32,8 @@ #include #include +#include "../liteapp/thememanager.h" + //lite_memory_check_begin #if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC @@ -124,16 +126,22 @@ void LiteEditorOption::save() m_liteApp->settings()->setValue(EDITOR_FONTZOOM,fontZoom); QString style = ui->styleComboBox->currentText(); + bool theme_changed = false; if (style != m_liteApp->settings()->value(EDITOR_STYLE,"default.xml").toString()) { m_liteApp->settings()->setValue(EDITOR_STYLE,style); QString styleFile = m_liteApp->resourcePath()+"/liteeditor/color/"+style; m_liteApp->editorManager()->loadColorStyleScheme(styleFile); + theme_changed = true; } // CHEN: save style_dark QString style_dark = ui->styleComboBox_dark->currentText(); if (style_dark != m_liteApp->settings()->value(EDITOR_STYLE_DARK,"NOT SET").toString()) { m_liteApp->settings()->setValue(EDITOR_STYLE_DARK,style_dark); qDebug() << "=== editor_dark_theme save:" << style_dark; + theme_changed = true; + } + if(theme_changed){ + ThemeManager::editor_theme_changed(); } bool noprintCheck = ui->noprintCheckBox->isChecked(); From e01164a1c1f6199dc592379256e572b7a44162a7 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 21 Sep 2025 14:31:24 +0800 Subject: [PATCH 12/14] U liteapp.cpp,liteappoption.cpp,main.cpp: clean debug code --- liteidex/src/liteapp/liteapp.cpp | 5 ----- liteidex/src/liteapp/liteappoption.cpp | 2 -- liteidex/src/liteapp/main.cpp | 10 ---------- 3 files changed, 17 deletions(-) diff --git a/liteidex/src/liteapp/liteapp.cpp b/liteidex/src/liteapp/liteapp.cpp index 681123ab7..6c1b93cbe 100644 --- a/liteidex/src/liteapp/liteapp.cpp +++ b/liteidex/src/liteapp/liteapp.cpp @@ -77,10 +77,6 @@ #define LITEIDE_VERSION "X38.4" -//chen -extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); -extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); - QString LiteApp::getRootPath() { @@ -145,7 +141,6 @@ IApplication* LiteApp::NewApplication(const QString &sessionName, IApplication * app->load(sessionName,baseApp); //chen: improve for new app instance - // auto_editor_theme(LiteApp::s_darkMode, app); ThemeManager::apply_to_liteApp(app); return app; diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index 5a6e43b57..e0014f889 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -152,7 +152,6 @@ QString LiteAppOption::mimeType() const return OPTION_LITEAPP; } - void LiteAppOption::save() { bool storeLocal = ui->storeLocalCheckBox->isChecked(); @@ -236,7 +235,6 @@ void LiteAppOption::save() qApp->setStyleSheet(styleSheet); //chen: auto editor theme - // auto_editor_theme(qss, m_liteApp); ThemeManager::app_theme_changed(qss); } } diff --git a/liteidex/src/liteapp/main.cpp b/liteidex/src/liteapp/main.cpp index 51b50f644..982f8d28e 100644 --- a/liteidex/src/liteapp/main.cpp +++ b/liteidex/src/liteapp/main.cpp @@ -93,14 +93,6 @@ class LiteIDEApplication : public QApplication { }; #endif - - -//chen: -// extern void auto_editor_theme(QString qss, LiteApi::IApplication *m_liteApp); -// extern void auto_editor_theme(bool is_dark , LiteApi::IApplication *m_liteApp); -// extern bool guess_dark(QString qss); - - #ifdef LITEAPP_LIBRARY int liteapp_main(int argc, char *argv[]) #else @@ -238,8 +230,6 @@ int main(int argc, char *argv[]) //chen: auto editor theme ThemeManager themeManager(&app); ThemeManager::monit_system_theme(&app); - // auto_editor_theme(qss, liteApp); - // monit_system_theme_change(&app, liteApp); foreach(QString file, fileList) { QFileInfo f(file); From c1286f242910c100a7f2e6dff8ec831cd11f9ac6 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 21 Sep 2025 14:46:11 +0800 Subject: [PATCH 13/14] U thememanager.cpp,h: add todo stuff --- liteidex/src/liteapp/thememanager.cpp | 10 +++++++--- liteidex/src/liteapp/thememanager.h | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/liteidex/src/liteapp/thememanager.cpp b/liteidex/src/liteapp/thememanager.cpp index f78591617..253004b55 100644 --- a/liteidex/src/liteapp/thememanager.cpp +++ b/liteidex/src/liteapp/thememanager.cpp @@ -1,4 +1,7 @@ +// Module: thememanager.cpp +// Creator: yurenchen + #include #include #include @@ -118,7 +121,8 @@ void ThemeManager::monit_system_theme(QApplication *app) { ThemeManager::app = app; #if defined(Q_OS_LINUX) - + // TODO: implement it for other desktop environment (currently only gnome is supported) + // TODO: improve it without run a gsettings process (currently need gsettings cmd) qDebug()<< "=== monit_system_theme_change..."; // 启动 gsettings monitor 进程 @@ -166,9 +170,9 @@ void ThemeManager::monit_system_theme(QApplication *app) { }); #elif defined(Q_OS_WIN) - + // TODO: implement it for windows11 #elif defined(Q_OS_MAC) - + // TODO: implement it for macos #else #endif diff --git a/liteidex/src/liteapp/thememanager.h b/liteidex/src/liteapp/thememanager.h index 4c63caf0d..3bf47fcfa 100644 --- a/liteidex/src/liteapp/thememanager.h +++ b/liteidex/src/liteapp/thememanager.h @@ -1,3 +1,7 @@ + +// Module: thememanager.cpp +// Creator: yurenchen + #pragma once #include From f7fbd9ed5d6a4f2c3d0c6bdeb9a61fee744e1b05 Mon Sep 17 00:00:00 2001 From: chen Date: Sun, 21 Sep 2025 14:55:45 +0800 Subject: [PATCH 14/14] U liteappoption.cpp, liteeditoroption.cpp: add todo stuff --- liteidex/src/liteapp/liteappoption.cpp | 1 + liteidex/src/plugins/liteeditor/liteeditoroption.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/liteidex/src/liteapp/liteappoption.cpp b/liteidex/src/liteapp/liteappoption.cpp index e0014f889..8cb653226 100644 --- a/liteidex/src/liteapp/liteappoption.cpp +++ b/liteidex/src/liteapp/liteappoption.cpp @@ -247,6 +247,7 @@ void LiteAppOption::save() // auto_editor_theme(qss, m_liteApp); } qDebug() << "=== save qss, qss_dark:" << qss << qss_dark; + // TODO: improve the dark/light settings UI bool customelIcon = ui->customIconCheckBox->isChecked(); m_liteApp->settings()->setValue(LITEIDE_CUSTOMEICON,customelIcon); diff --git a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp index cdf023e7f..8c36d7489 100755 --- a/liteidex/src/plugins/liteeditor/liteeditoroption.cpp +++ b/liteidex/src/plugins/liteeditor/liteeditoroption.cpp @@ -143,6 +143,7 @@ void LiteEditorOption::save() if(theme_changed){ ThemeManager::editor_theme_changed(); } + // TODO: improve the dark/light settings UI bool noprintCheck = ui->noprintCheckBox->isChecked(); bool autoIndent = ui->autoIndentCheckBox->isChecked();