Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions liteidex/src/liteapp/liteapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
#include <QComboBox>
#include <QProcessEnvironment>
#include <QDebug>

#include "thememanager.h"

//lite_memory_check_begin
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
Expand Down Expand Up @@ -136,6 +139,10 @@ IApplication* LiteApp::NewApplication(const QString &sessionName, IApplication *
{
LiteApp *app = new LiteApp;
app->load(sessionName,baseApp);

//chen: improve for new app instance
ThemeManager::apply_to_liteApp(app);

return app;
}

Expand All @@ -154,6 +161,8 @@ QMap<QString,QVariant> LiteApp::s_cookie;

QList<IApplication*> LiteApp::s_appList;

bool LiteApp::s_darkMode;

LiteApp::LiteApp()
: m_rootPath(LiteApp::getRootPath()),
m_applicationPath(QApplication::applicationDirPath()),
Expand Down
1 change: 1 addition & 0 deletions liteidex/src/liteapp/liteapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected slots:
public:
static QMap<QString,QVariant> s_cookie;
static QList<IApplication*> s_appList;
static bool s_darkMode; //app dark or light
protected:
QAction *m_newAct;
QAction *m_openFileAct;
Expand Down
2 changes: 2 additions & 0 deletions liteidex/src/liteapp/liteapp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SOURCES += main.cpp\
folderprojectfactory.cpp \
goproxy.cpp \
htmlwidgetmanager.cpp \
thememanager.cpp \
textbrowserhtmlwidget.cpp \
splitwindowstyle.cpp \
sidewindowstyle.cpp \
Expand Down Expand Up @@ -110,6 +111,7 @@ HEADERS += mainwindow.h \
goproxy.h \
cdrv.h \
htmlwidgetmanager.h \
thememanager.h \
textbrowserhtmlwidget.h \
windowstyle.h \
splitwindowstyle.h \
Expand Down
1 change: 1 addition & 0 deletions liteidex/src/liteapp/liteapp_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
28 changes: 28 additions & 0 deletions liteidex/src/liteapp/liteappoption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <QMessageBox>
#include <QDebug>

#include "thememanager.h"

//lite_memory_check_begin
#if defined(WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
Expand Down Expand Up @@ -102,6 +104,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()) {
Expand Down Expand Up @@ -225,8 +233,21 @@ void LiteAppOption::save()
m_liteApp->settings()->setValue(LITEAPP_QSS,qss);
QString styleSheet = QLatin1String(f.readAll());
qApp->setStyleSheet(styleSheet);

//chen: auto editor theme
ThemeManager::app_theme_changed(qss);
}
}
// 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;
// TODO: improve the dark/light settings UI

bool customelIcon = ui->customIconCheckBox->isChecked();
m_liteApp->settings()->setValue(LITEIDE_CUSTOMEICON,customelIcon);
Expand Down Expand Up @@ -291,6 +312,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));
Expand Down
39 changes: 39 additions & 0 deletions liteidex/src/liteapp/liteappoption.ui
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,45 @@
</item>
</layout>
</item>

<!-- dark theme -->
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11_">
<item>
<widget class="QGroupBox" name="groupBox_6_">
<property name="title">
<string>Theme Dark</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6_">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Theme:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="qssComboBox_dark"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>

<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
Expand Down
7 changes: 7 additions & 0 deletions liteidex/src/liteapp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -224,6 +227,10 @@ int main(int argc, char *argv[])
app.liteApp = liteApp;
#endif

//chen: auto editor theme
ThemeManager themeManager(&app);
ThemeManager::monit_system_theme(&app);

foreach(QString file, fileList) {
QFileInfo f(file);
if (f.isFile()) {
Expand Down
Loading