FOSSredder 0.5.0
Loading...
Searching...
No Matches
SettingsViewModel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QObject>
9#include <QString>
10#include <QVariantList>
11#include <qqmlintegration.h>
12
13namespace ui {
14
15class Actions;
16class LanguageService;
17class Navigation;
18class Settings;
19
23class SettingsViewModel : public QObject {
24 Q_OBJECT
25 QML_NAMED_ELEMENT(SettingsViewModel)
26
27 Q_PROPERTY(int currentCategory READ currentCategory NOTIFY changed)
28 Q_PROPERTY(QVariantList categoryRows READ categoryRows NOTIFY changed)
29 Q_PROPERTY(
31 Q_PROPERTY(QVariantList languageOptions READ languageOptions NOTIFY changed)
32 Q_PROPERTY(int languageIndex READ languageIndex NOTIFY changed)
33 Q_PROPERTY(QVariantList themeModeOptions READ themeModeOptions NOTIFY changed)
34 Q_PROPERTY(int themeModeIndex READ themeModeIndex NOTIFY changed)
35
36 Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY changed)
37 Q_PROPERTY(QString themeMode READ themeMode WRITE setThemeMode NOTIFY changed)
39 NOTIFY changed)
41 NOTIFY changed)
42 Q_PROPERTY(
44 Q_PROPERTY(QString importDefaultPath READ importDefaultPath WRITE
46 Q_PROPERTY(QString importPoppler READ importPoppler WRITE setImportPoppler
47 NOTIFY changed)
48 Q_PROPERTY(QString importOpenCv READ importOpenCv WRITE setImportOpenCv NOTIFY
49 changed)
50 Q_PROPERTY(QString importTesseract READ importTesseract WRITE
52 Q_PROPERTY(QString importParser READ importParser WRITE setImportParser NOTIFY
53 changed)
54 Q_PROPERTY(QString importMatcher READ importMatcher WRITE setImportMatcher
55 NOTIFY changed)
56 Q_PROPERTY(QString exportDefaultDirectory READ exportDefaultDirectory WRITE
58 Q_PROPERTY(int exportArchiveFormat READ exportArchiveFormat WRITE
62 Q_PROPERTY(bool toolbarShowBooking READ toolbarShowBooking WRITE
64 Q_PROPERTY(bool toolbarShowImport READ toolbarShowImport WRITE
66 Q_PROPERTY(bool toolbarShowActors READ toolbarShowActors WRITE
68 Q_PROPERTY(bool toolbarShowExport READ toolbarShowExport WRITE
72 Q_PROPERTY(bool toolbarShowAnalysis READ toolbarShowAnalysis WRITE
74 Q_PROPERTY(bool toolbarShowContracts READ toolbarShowContracts WRITE
76 Q_PROPERTY(bool toolbarShowAnnual READ toolbarShowAnnual WRITE
78 Q_PROPERTY(bool toolbarShowSettings READ toolbarShowSettings WRITE
80
81public:
86 explicit SettingsViewModel(QObject* parent = nullptr);
87
92 void setNavigation(Navigation* value);
93
98 void setSettings(Settings* value);
99
104 void setActions(Actions* value);
105
111
116 int currentCategory() const;
117
122 QVariantList categoryRows() const;
123
128 bool canNavigateCategories() const noexcept;
129
134 QVariantList languageOptions() const;
135
140 int languageIndex() const;
141
146 QVariantList themeModeOptions() const;
147
152 int themeModeIndex() const;
153
158 QString language() const;
159
164 void setLanguage(const QString& value);
165
170 QString themeMode() const;
171
176 void setThemeMode(const QString& value);
177
182 bool autosaveOnClose() const;
183
188 void setAutosaveOnClose(bool value);
189
194 QVariantList autosaveIntervalOptions() const;
195
200 int autosaveIntervalIndex() const;
201
206 QString importDefaultPath() const;
207
212 void setImportDefaultPath(const QString& value);
213
218 QString importPoppler() const;
219
224 void setImportPoppler(const QString& value);
225
230 QString importOpenCv() const;
231
236 void setImportOpenCv(const QString& value);
237
242 QString importTesseract() const;
243
248 void setImportTesseract(const QString& value);
249
254 QString importParser() const;
255
260 void setImportParser(const QString& value);
261
266 QString importMatcher() const;
267
272 void setImportMatcher(const QString& value);
273
278 QString exportDefaultDirectory() const;
279
284 void setExportDefaultDirectory(const QString& value);
285
290 int exportArchiveFormat() const;
291
296 void setExportArchiveFormat(int value);
297
302 bool exportIncludeFormulas() const;
303
308 void setExportIncludeFormulas(bool value);
309
314 bool toolbarShowBooking() const;
315
320 void setToolbarShowBooking(bool value);
321
326 bool toolbarShowImport() const;
327
332 void setToolbarShowImport(bool value);
333
338 bool toolbarShowActors() const;
339
344 void setToolbarShowActors(bool value);
345
350 bool toolbarShowExport() const;
351
356 void setToolbarShowExport(bool value);
357
362 bool toolbarShowProperties() const;
363
368 void setToolbarShowProperties(bool value);
369
374 bool toolbarShowAnalysis() const;
375
380 void setToolbarShowAnalysis(bool value);
381
386 bool toolbarShowContracts() const;
387
392 void setToolbarShowContracts(bool value);
393
398 bool toolbarShowAnnual() const;
399
404 void setToolbarShowAnnual(bool value);
405
410 bool toolbarShowSettings() const;
411
416 void setToolbarShowSettings(bool value);
417
421 Q_INVOKABLE void activate();
422
427 Q_INVOKABLE void navigateCategory(int delta);
428
433 Q_INVOKABLE void selectCategory(int category);
434
438 Q_INVOKABLE void saveSettings();
439
443 Q_INVOKABLE void resetSettings();
444
449 Q_INVOKABLE void selectLanguageAt(int index);
450
455 Q_INVOKABLE void selectThemeModeAt(int index);
456
461 Q_INVOKABLE void selectAutosaveIntervalAt(int index);
462
466 Q_INVOKABLE void browseImportPath();
467
471 Q_INVOKABLE void browseExportDirectory();
472
473signals:
477 void changed();
478
479private:
484 int firstCategory() const noexcept;
489 int lastCategory() const noexcept;
494 void bindNavigation(Navigation* value);
499 void bindSettings(Settings* value);
504 void bindActions(Actions* value);
508 void emitChanged();
509
510 Navigation* navigation_ = nullptr;
511 Settings* settings_ = nullptr;
512 Actions* actions_ = nullptr;
513 LanguageService* languageService_ = nullptr;
514};
515
516} // namespace ui
Owns the main window actions and exposes them to QML.
Definition AppActions.h:18
Manages the active UI language and the available translation options.
Stores the active top-level shell section and settings sub-section.
Definition Navigation.h:15
Stores and exposes globally persisted UI settings for settings-related views.
Definition Settings.h:19
Q_INVOKABLE void selectAutosaveIntervalAt(int index)
Selects an autosave interval option by index.
void setToolbarShowActors(bool value)
Updates whether the actor toolbar entry is visible.
void setToolbarShowAnnual(bool value)
Updates whether the annual toolbar entry is visible.
void setAutosaveOnClose(bool value)
Updates whether autosave on close is enabled.
void setLanguageService(LanguageService *value)
Sets the language service used to build language options.
void setImportDefaultPath(const QString &value)
Updates the default import path.
void setToolbarShowProperties(bool value)
Updates whether the property toolbar entry is visible.
void setNavigation(Navigation *value)
Sets the shell navigation object used by the settings page.
Q_INVOKABLE void saveSettings()
Persists the current settings values.
void setExportDefaultDirectory(const QString &value)
Updates the default export directory.
void setToolbarShowSettings(bool value)
Updates whether the settings toolbar entry is visible.
void setLanguage(const QString &value)
Updates the configured language code.
void setToolbarShowImport(bool value)
Updates whether the import toolbar entry is visible.
void setThemeMode(const QString &value)
Updates the configured theme mode.
SettingsViewModel(QObject *parent=nullptr)
Creates the settings view model.
void changed()
Emitted when settings view model state changed.
void setImportParser(const QString &value)
Updates the configured import parser key.
Q_INVOKABLE void selectCategory(int category)
Selects a settings category.
void setToolbarShowExport(bool value)
Updates whether the export toolbar entry is visible.
void setExportIncludeFormulas(bool value)
Updates whether exported spreadsheets include formulas.
void setToolbarShowContracts(bool value)
Updates whether the contract toolbar entry is visible.
void setImportTesseract(const QString &value)
Updates the configured Tesseract path.
QVariantList autosaveIntervalOptions
Q_INVOKABLE void selectLanguageAt(int index)
Selects a language option by index.
void setImportMatcher(const QString &value)
Updates the configured import matcher key.
void setToolbarShowAnalysis(bool value)
Updates whether the analysis toolbar entry is visible.
Q_INVOKABLE void browseExportDirectory()
Opens a browser for the export default directory.
Q_INVOKABLE void selectThemeModeAt(int index)
Selects a theme mode option by index.
Q_INVOKABLE void browseImportPath()
Opens a browser for the import default path.
void setImportOpenCv(const QString &value)
Updates the configured OpenCV path.
Q_INVOKABLE void resetSettings()
Resets settings values to defaults.
void setImportPoppler(const QString &value)
Updates the configured Poppler path.
void setExportArchiveFormat(int value)
Updates the configured export archive format index.
void setToolbarShowBooking(bool value)
Updates whether the booking toolbar entry is visible.
void setSettings(Settings *value)
Sets the settings state object used for persisted settings values.
Q_INVOKABLE void activate()
Activates the settings page state.
Q_INVOKABLE void navigateCategory(int delta)
Navigates settings categories by a relative delta.
void setActions(Actions *value)
Sets shell actions used for file browsing.