nsbaci 1.0
Loading...
Searching...
No Matches
preferencesDialog.h
Go to the documentation of this file.
1
9
10#ifndef PREFERENCESDIALOG_H
11#define PREFERENCESDIALOG_H
12
13#include <QCheckBox>
14#include <QComboBox>
15#include <QDialog>
16#include <QLabel>
17#include <QListWidget>
18#include <QPushButton>
19#include <QSettings>
20#include <QSpinBox>
21#include <QStackedWidget>
22#include <QString>
23#include <QVBoxLayout>
24
25namespace nsbaci::ui {
26
30enum class Theme { Dark, Light };
31
39 // Appearance
40 Theme theme = Theme::Dark;
41 int editorFontSize = 11;
42
43 // Editor
44 int tabWidth = 4;
45 bool showLineNumbers = true;
46 bool wordWrap = false;
47
48 // General
49 bool restoreLastFile = false;
50 QString lastFilePath;
51};
52
60class PreferencesDialog : public QDialog {
61 Q_OBJECT
62
63 public:
64 explicit PreferencesDialog(const Preferences& current,
65 QWidget* parent = nullptr);
66 ~PreferencesDialog() override = default;
67
72 Preferences result() const;
73
74 // ---- Static persistence helpers ----
75
77 static Preferences load();
78
80 static void save(const Preferences& prefs);
81
82 signals:
88
89 private slots:
90 void onCategoryChanged(int currentRow);
91 void onAccept();
92 void onRestoreDefaults();
93
94 private:
95 void setupUi();
96 QWidget* createAppearancePage();
97 QWidget* createEditorPage();
98 QWidget* createGeneralPage();
99 void applyDialogStyle();
100 void populateFromPreferences(const Preferences& prefs);
101
102 // UI elements
103 QListWidget* categoryList = nullptr;
104 QStackedWidget* pages = nullptr;
105
106 // Appearance widgets
107 QComboBox* themeCombo = nullptr;
108 QSpinBox* fontSizeSpin = nullptr;
109
110 // Editor widgets
111 QComboBox* tabWidthCombo = nullptr;
112 QCheckBox* lineNumbersCheck = nullptr;
113 QCheckBox* wordWrapCheck = nullptr;
114
115 // General widgets
116 QCheckBox* restoreLastFileCheck = nullptr;
117
118 QPushButton* okButton = nullptr;
119 QPushButton* cancelButton = nullptr;
120 QPushButton* defaultsButton = nullptr;
121
122 // Snapshot of the preferences we were opened with
123 Preferences currentPrefs;
124};
125
126} // namespace nsbaci::ui
127
128#endif // PREFERENCESDIALOG_H
Preferences result() const
Returns the (possibly modified) preferences after the dialog is accepted.
Definition preferencesDialog.cpp:43
static Preferences load()
Load preferences from QSettings.
Definition preferencesDialog.cpp:65
static void save(const Preferences &prefs)
Save preferences to QSettings.
Definition preferencesDialog.cpp:89
void preferencesChanged(const nsbaci::ui::Preferences &prefs)
Emitted when the user accepts the dialog with changed preferences.
User interface namespace for nsbaci.
Definition drawingWidget.cpp:18
Theme
Enumerates the available application themes.
Definition preferencesDialog.h:30
Holds all user-configurable preferences.
Definition preferencesDialog.h:38