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 SETTINGSDIALOG_H
18#define SETTINGSDIALOG_H
19
20#include <QAbstractItemModel>
21#include <QDialog>
22#include <QStandardItemModel>
23#include <memory>
24
25class SettingsWidget;
26namespace Ui {
27class SettingsDialog;
28}
29
30class SettingsDialog;
31using PSettingsDialog = std::shared_ptr<SettingsDialog>;
32class SettingsDialog : public QDialog
33{
34 Q_OBJECT
35
36public:
37 enum {
38 GetWidgetIndexRole = Qt::UserRole + 1
39 };
40 explicit SettingsDialog(QWidget *parent = nullptr);
41 ~SettingsDialog();
42
43 void addWidget(SettingsWidget* pWidget);
44
45 void selectFirstWidget();
46
47 static PSettingsDialog optionDialog();
48 static PSettingsDialog projectOptionDialog();
49
50 bool setCurrentWidget(const QString &widgetName, const QString &groupName);
51
52 bool appShouldQuit() const;
53
54private slots:
55 void closeAndQuit();
56 void widget_settings_changed(bool value);
57 void on_widgetsView_clicked(const QModelIndex &index);
58
59 void on_btnCancel_pressed();
60
61 void on_btnApply_pressed();
62
63 void on_btnOk_pressed();
64private:
65 void saveCurrentPageSettings(bool confirm);
66private:
67 Ui::SettingsDialog *ui;
68 QList<SettingsWidget*> mSettingWidgets;
69 QStandardItemModel model;
70 bool mAppShouldQuit;
71
72// CompilerSetOptionWidget *pCompilerSetOptionWidget;
73// CompilerAutolinkWidget *pCompilerAutolinkWidget;
74// EditorGeneralWidget *pEditorGeneralWidget;
75// EditorFontWidget *pEditorFontWidget;
76// EditorClipboardWidget *pEditorClipboardWidget;
77// EditorColorSchemeWidget *pEditorColorSchemeWidget;
78// EnvironmentAppearenceWidget *pEnvironmentAppearenceWidget;
79// EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
80// EditorCodeCompletionWidget *pEditorCodeCompletionWidget;
81// EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
82// EditorAutoSaveWidget *pEditorAutoSaveWidget;
83// EditorMiscWidget *pEditorMiscWidget;
84// ExecutorGeneralWidget *pExecutorGeneralWidget;
85// DebugGeneralWidget *pDebugGeneralWidget;
86// FormatterGeneralWidget *pFormatterGeneralWidget;
87
88
89 // QWidget interface
90protected:
91 void closeEvent(QCloseEvent *event) override;
92};
93
94#endif // SETTINGSDIALOG_H
95