1 | /* |
---|---|
2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) |
3 | * |
4 | * This program is free software: you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation, either version 3 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | */ |
17 | #ifndef EDITORCOLORSCHEMEWIDGET_H |
18 | #define EDITORCOLORSCHEMEWIDGET_H |
19 | |
20 | #include "settingswidget.h" |
21 | #include "../colorscheme.h" |
22 | |
23 | #include <QMenu> |
24 | #include <QStandardItemModel> |
25 | |
26 | namespace Ui { |
27 | class EditorColorSchemeWidget; |
28 | } |
29 | |
30 | class EditorColorSchemeWidget : public SettingsWidget |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | enum { |
36 | NameRole = Qt::UserRole+1 |
37 | }; |
38 | explicit EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent = nullptr); |
39 | ~EditorColorSchemeWidget(); |
40 | |
41 | public slots: |
42 | void onItemSelectionChanged(); |
43 | void onSettingChanged(); |
44 | void onForegroundChanged(); |
45 | void onBackgroundChanged(); |
46 | void onFontStyleChanged(); |
47 | void changeSchemeComboFont(); |
48 | |
49 | private: |
50 | void addDefine(const QString& name, PColorSchemeItemDefine define); |
51 | PColorSchemeItem getCurrentItem(); |
52 | PColorScheme getCurrentScheme(); |
53 | void connectModificationSlots(); |
54 | void disconnectModificationSlots(); |
55 | void setCurrentSchemeModified(); |
56 | |
57 | private: |
58 | Ui::EditorColorSchemeWidget *ui; |
59 | QStandardItemModel mDefinesModel; |
60 | QFont mDefaultSchemeComboFont; |
61 | QFont mModifiedSchemeComboFont; |
62 | QSet<QString> mModifiedSchemes; |
63 | QMenu mMenu; |
64 | std::shared_ptr<QHash<StatementKind, std::shared_ptr<ColorSchemeItem> > > mStatementColors; |
65 | |
66 | // SettingsWidget interface |
67 | protected: |
68 | void doLoad() override; |
69 | void doSave() override; |
70 | |
71 | private slots: |
72 | void on_actionCopy_Scheme_triggered(); |
73 | void on_btnSchemeMenu_pressed(); |
74 | void on_actionImport_Scheme_triggered(); |
75 | void on_actionRename_Scheme_triggered(); |
76 | void on_actionReset_Scheme_triggered(); |
77 | void on_actionExport_Scheme_triggered(); |
78 | void on_actionDelete_Scheme_triggered(); |
79 | }; |
80 | |
81 | #endif // EDITORCOLORSCHEMEWIDGET_H |
82 |