SILICON
Loading...
Searching...
No Matches
settingsWindow.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
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 <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <ui/lifetime.hpp>
21
22#include <QDialog>
23#include <QVector>
24
26
27class QAction;
28class QByteArray;
29class QComboBox;
30class QDialogButtonBox;
31class QFormLayout;
32class QKeySequenceEdit;
33class QPushButton;
34class QSettings;
35class QSpinBox;
36
37
38namespace SILICON::ui {
39
48
52class SettingsWindow : public QDialog {
53 Q_OBJECT
54
55public:
62 explicit SettingsWindow(const QString& appName, QVector<ShortcutSetting> shortcuts,
63 QWidget* parent = nullptr);
64
65private:
67 void loadSettings();
69 bool saveSettings();
71 void importSettings();
73 void exportSettings();
75 bool importSettingsStore(QSettings& importedSettings);
77 QByteArray exportSettingsContent();
79 void restoreDefaults();
81 void addShortcutEditor(const ShortcutSetting& shortcut);
83 void applySettings();
85 void writeVisibleSettings(QSettings& target) const;
86
88
89 QVector<ShortcutSetting> shortcuts;
90 QVector<QKeySequenceEdit*> shortcutEditors;
91
92 QComboBox* themeCombo;
95 QFormLayout* keybindingsLayout;
96 QPushButton* importButton;
97 QPushButton* exportButton;
99 QDialogButtonBox* buttonBox;
101};
102
103} // namespace SILICON::ui
QVector< ShortcutSetting > shortcuts
void loadSettings()
Loads persisted settings into the visible editors.
bool saveSettings()
Writes the current editor state to disk and applies it to the app.
void restoreDefaults()
Resets the visible editors to their declared default values.
void importSettings()
Imports settings from an external TOML file into the active store.
QSpinBox * maxTransitionsPerDeltaCycleSpinBox
void writeVisibleSettings(QSettings &target) const
Writes the currently visible values to a target settings store.
void addShortcutEditor(const ShortcutSetting &shortcut)
Adds one key sequence editor row for a shortcut setting.
QByteArray exportSettingsContent()
Serializes the visible settings to TOML bytes.
QVector< QKeySequenceEdit * > shortcutEditors
bool importSettingsStore(QSettings &importedSettings)
Applies settings from another settings store.
SettingsWindow(const QString &appName, QVector< ShortcutSetting > shortcuts, QWidget *parent=nullptr)
Builds the settings dialog for one application namespace.
void exportSettings()
Exports the current settings to an external TOML file.
void applySettings()
Applies the visible settings to the running application state.
QSettings wrapper configured to read and write SILICON TOML settings files.
Shortcut row shown in the settings dialog.
SILICON::ui::settings::Definition setting
Describes a persisted setting entry.