diff --git a/NEWS.md b/NEWS.md
index 2b5d37e3..0fec4332 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -8,6 +8,7 @@ Red Panda C++ Version 0.14.4
- enhancement: auto find compiler sets when run for the first time
- enhancement: git - remotes
- enhancement: rename "open folder" to "choose working folder"
+ - enhancement: let user choose app theme when first run
Red Panda C++ Version 0.14.3
- fix: wrong code completion font size, when screen dpi changed
diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro
index c54c486e..2f10f371 100644
--- a/RedPandaIDE/RedPandaIDE.pro
+++ b/RedPandaIDE/RedPandaIDE.pro
@@ -104,6 +104,7 @@ SOURCES += \
vcs/gitutils.cpp \
widgets/aboutdialog.cpp \
widgets/bookmarkmodel.cpp \
+ widgets/choosethemedialog.cpp \
widgets/classbrowser.cpp \
widgets/codecompletionlistview.cpp \
widgets/codecompletionpopup.cpp \
@@ -245,6 +246,7 @@ HEADERS += \
vcs/gitutils.h \
widgets/aboutdialog.h \
widgets/bookmarkmodel.h \
+ widgets/choosethemedialog.h \
widgets/classbrowser.h \
widgets/codecompletionlistview.h \
widgets/codecompletionpopup.h \
@@ -346,6 +348,7 @@ FORMS += \
vcs/gitremotedialog.ui \
vcs/gitresetdialog.ui \
widgets/aboutdialog.ui \
+ widgets/choosethemedialog.ui \
widgets/cpudialog.ui \
mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \
diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts
index 7e7c49e1..727263a3 100644
--- a/RedPandaIDE/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts
@@ -428,6 +428,30 @@ p, li { white-space: pre-wrap; }
凯尔特语系
+
+ ChooseThemeDialog
+
+
+
+
+ 选择主题
+
+
+
+
+ 深色主题
+
+
+
+
+ 浅色主题
+
+
+
+
+ 确定
+
+
CodeSnippetsManager
@@ -3684,7 +3708,7 @@ Are you really want to continue?
-
+
@@ -3719,27 +3743,27 @@ Are you really want to continue?
编辑
-
+
-
+
项目
-
-
+
+
监视
-
-
+
+
结构
-
-
+
+
文件
@@ -3752,7 +3776,7 @@ Are you really want to continue?
-
+
调试
@@ -3785,7 +3809,7 @@ Are you really want to continue?
-
+
查找
@@ -3904,7 +3928,7 @@ Are you really want to continue?
-
+
工具输出
@@ -4104,7 +4128,7 @@ Are you really want to continue?
-
+
试题集
@@ -4160,20 +4184,20 @@ Are you really want to continue?
-
+
TODO
-
+
书签
-
+
试题
@@ -4626,70 +4650,70 @@ Are you really want to continue?
C++参考手册
-
+
C参考手册
-
+
显示全部工具面板
-
+
Create Repository
创建Git仓库
-
+
提交(Commit)
-
+
撤销(Revert)
-
+
回滚(Reset)
-
+
添加文件
-
+
还原(Restore)
-
+
官方网站
-
+
分支切换(Switch)
-
+
合并(Merge)
-
+
Log
显示日志(Log)
-
+
远程仓库...
@@ -4698,50 +4722,50 @@ Are you really want to continue?
工具窗口栏
-
+
状态栏
-
+
Ctrl+Backspace
-
+
中断
-
+
删除到单词开头
-
+
Ctrl+Shift+B
-
+
删除到单词结尾
-
+
Ctrl+Shift+E
-
+
Add Class...
新建类...
-
+
New Header
新建头文件...
@@ -4751,47 +4775,47 @@ Are you really want to continue?
插入行
-
+
删除当前行
-
+
Ctrl+D
-
+
复制当前行
-
+
Ctrl+E
-
+
删除当前单词
-
+
Ctrl+Shift+D
-
+
删除到行尾
-
+
Ctrl+Del
-
+
删除到行首
@@ -4825,12 +4849,11 @@ Are you really want to continue?
在文件视图中定位
-
- 打开文件夹
+ 打开文件夹
-
+
运行参数...
@@ -5440,6 +5463,8 @@ Are you really want to continue?
你真的要删除它吗?
+
+
选择工作文件夹
@@ -6704,7 +6729,7 @@ Are you really want to continue?
QApplication
-
+
错误
@@ -6758,23 +6783,23 @@ Are you really want to continue?
-
-
+
+
错误
-
+
无法创建配置文件夹"%1"
-
+
无法写入配置文件夹"%1"
-
+
无法载入自动链接设置
@@ -7409,7 +7434,7 @@ Are you really want to continue?
无法解析试题集文件"%1":%2
-
+
<由Git自动生成>
diff --git a/RedPandaIDE/icons.qrc b/RedPandaIDE/icons.qrc
index e9da85bc..8080f3dd 100644
--- a/RedPandaIDE/icons.qrc
+++ b/RedPandaIDE/icons.qrc
@@ -109,4 +109,10 @@
images/associations/template.ico
images/dark-close.svg
+
+ images/demos/dark.png
+ images/demos/dark-zh_CN.png
+ images/demos/light.png
+ images/demos/light-zh_CN.png
+
diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp
index ed90e17c..7a1f3a80 100644
--- a/RedPandaIDE/main.cpp
+++ b/RedPandaIDE/main.cpp
@@ -35,6 +35,8 @@
#include "platform.h"
#include "parser/parserutils.h"
#include "editorlist.h"
+#include "widgets/choosethemedialog.h"
+#include "thememanager.h"
#ifdef Q_OS_WIN
#include
#endif
@@ -109,6 +111,21 @@ QString getSettingFilename(const QString& filepath, bool& firstRun) {
return filename;
}
+void setTheme(const QString& theme) {
+ pSettings->environment().setTheme(theme);
+ ThemeManager themeManager;
+ PAppTheme appTheme = themeManager.theme(theme);
+ if (appTheme && !appTheme->defaultColorScheme().isEmpty()) {
+ pSettings->editor().setColorScheme(appTheme->defaultColorScheme());
+ pSettings->editor().save();
+ }
+ if (appTheme && !appTheme->defaultIconSet().isEmpty()) {
+ pSettings->environment().setIconSet(appTheme->defaultIconSet());
+ }
+ pSettings->environment().save();
+
+}
+
int main(int argc, char *argv[])
{
//QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@@ -157,6 +174,18 @@ int main(int argc, char *argv[])
pSettings->compilerSets().saveSets();
}
pSettings->load();
+ if (firstRun) {
+ //set theme
+ ChooseThemeDialog themeDialog;
+ themeDialog.exec();
+ switch (themeDialog.theme()) {
+ case ChooseThemeDialog::Theme::Dark:
+ setTheme("dark");
+ break;
+ default:
+ setTheme("default");
+ }
+ }
auto settings = std::unique_ptr(pSettings);
//Color scheme settings must be loaded after translation
diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp
index 78c593a2..5650ee23 100644
--- a/RedPandaIDE/settings.cpp
+++ b/RedPandaIDE/settings.cpp
@@ -5058,7 +5058,7 @@ void Settings::UI::doLoad()
mBottomPanelIndex = intValue("bottom_panel_index",0);
mLeftPanelOpenned = boolValue("left_panel_openned",true);
mLeftPanelWidth = intValue("left_panel_width",250);
- mLeftPanelIndex = intValue("left_panel_index",2);
+ mLeftPanelIndex = intValue("left_panel_index",0);
mClassBrowserSortAlpha = boolValue("class_browser_sort_alphabetically",true);
mClassBrowserSortType = boolValue("class_browser_sort_by_type",true);
mClassBrowserShowInherited = boolValue("class_browser_show_inherited",true);
diff --git a/RedPandaIDE/widgets/choosethemedialog.cpp b/RedPandaIDE/widgets/choosethemedialog.cpp
new file mode 100644
index 00000000..8471c1d4
--- /dev/null
+++ b/RedPandaIDE/widgets/choosethemedialog.cpp
@@ -0,0 +1,28 @@
+#include "choosethemedialog.h"
+#include "ui_choosethemedialog.h"
+
+ChooseThemeDialog::ChooseThemeDialog(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::ChooseThemeDialog)
+{
+ ui->setupUi(this);
+ ui->rbDark->setChecked(true);
+}
+
+ChooseThemeDialog::~ChooseThemeDialog()
+{
+ delete ui;
+}
+
+ChooseThemeDialog::Theme ChooseThemeDialog::theme()
+{
+ if (ui->rbDark->isChecked())
+ return Theme::Dark;
+ return Theme::Light;
+}
+
+void ChooseThemeDialog::on_btnOk_clicked()
+{
+ accept();
+}
+
diff --git a/RedPandaIDE/widgets/choosethemedialog.h b/RedPandaIDE/widgets/choosethemedialog.h
new file mode 100644
index 00000000..a4c905f9
--- /dev/null
+++ b/RedPandaIDE/widgets/choosethemedialog.h
@@ -0,0 +1,30 @@
+#ifndef CHOOSETHEMEDIALOG_H
+#define CHOOSETHEMEDIALOG_H
+
+#include
+
+namespace Ui {
+class ChooseThemeDialog;
+}
+
+class ChooseThemeDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ enum class Theme {
+ Dark,
+ Light
+ };
+ explicit ChooseThemeDialog(QWidget *parent = nullptr);
+ ~ChooseThemeDialog();
+ Theme theme();
+
+private slots:
+ void on_btnOk_clicked();
+
+private:
+ Ui::ChooseThemeDialog *ui;
+};
+
+#endif // CHOOSETHEMEDIALOG_H
diff --git a/RedPandaIDE/widgets/choosethemedialog.ui b/RedPandaIDE/widgets/choosethemedialog.ui
new file mode 100644
index 00000000..30d09ba9
--- /dev/null
+++ b/RedPandaIDE/widgets/choosethemedialog.ui
@@ -0,0 +1,129 @@
+
+
+ ChooseThemeDialog
+
+
+
+ 0
+ 0
+ 1041
+ 593
+
+
+
+ Choose Theme
+
+
+ -
+
+
+ Choose Theme
+
+
+
-
+
+
+ Dark Theme
+
+
+
+ -
+
+
+ QFrame::Box
+
+
+ QFrame::Sunken
+
+
+
+
+
+ :/demos/dark.png
+
+
+
+ -
+
+
+ Light Theme
+
+
+
+ -
+
+
+ QFrame::Box
+
+
+ QFrame::Sunken
+
+
+
+
+
+ :/demos/light.png
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 77
+
+
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 1828
+ 20
+
+
+
+
+ -
+
+
+ Ok
+
+
+
+
+
+
+
+
+
+
+
+
+