1 /************************************************************************ 2 ** 3 ** Copyright (C) 2019-2020 Kevin B. Hendricks, Stratford Ontario Canada 4 ** Copyright (C) 2011 John Schember <john@nachtimwald.com> 5 ** 6 ** This file is part of PageEdit. 7 ** 8 ** PageEdit is free software: you can redistribute it and/or modify 9 ** it under the terms of the GNU General Public License as published by 10 ** the Free Software Foundation, either version 3 of the License, or 11 ** (at your option) any later version. 12 ** 13 ** PageEdit is distributed in the hope that it will be useful, 14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ** GNU General Public License for more details. 17 ** 18 ** You should have received a copy of the GNU General Public License 19 ** along with PageEdit. If not, see <http://www.gnu.org/licenses/>. 20 ** 21 *************************************************************************/ 22 23 #pragma once 24 #ifndef PREFERENCES_H 25 #define PREFERENCES_H 26 27 #include <QWidget> 28 #include <QDialog> 29 #include "PreferencesWidget.h" 30 31 #include "ui_Preferences.h" 32 33 /** 34 * Allows the user to change settings related to how the application functions. 35 * 36 * The preferecnes exposed are instances of PreferencesWidget. They are loaded 37 * and dynamically displayed based upon which one is seleted. 38 */ 39 class Preferences : public QDialog 40 { 41 42 Q_OBJECT 43 44 public: 45 46 enum AvailablePreferences { 47 AppearancePrefs = 0, 48 GeneralPrefs = 1 49 }; 50 51 52 Preferences(QWidget *parent = 0); ~Preferences()53 ~Preferences() {}; 54 55 /** 56 * Check this after dialog closes to determine if PageEdit needs restarting. 57 */ 58 bool isRestartRequired(); 59 60 bool isReloadPreviewRequired(); 61 62 void makeActive(int); 63 64 private slots: 65 /** 66 * Load the PreferencesWidget that the user has selected. 67 */ 68 void selectPWidget(QListWidgetItem *current, QListWidgetItem *previous = 0); 69 /** 70 * Saves settings the user has selected. 71 * 72 * Saves the state of the dialog. 73 * Also, calls saveSettings for each loaded PreferencesWidget. 74 */ 75 void saveSettings(); 76 77 void openPreferencesLocation(); 78 79 private: 80 /** 81 * Read settings for the dialog. 82 * 83 * Each PreferencesWidget upon creation will load it's own settings. 84 */ 85 void readSettings(); 86 /** 87 * Adds the given preferences with to the dialog. 88 * 89 * The widget is added to the list of available widgets and when the 90 * entry in the list is selected the widget it shown in the widget display 91 * area to the right of the avaliable widget list. 92 * 93 * @param widget The PreferencesWidget to add to the dialog. 94 */ 95 void appendPreferenceWidget(PreferencesWidget *widget); 96 97 void extendUI(); 98 /** 99 * Connect signals to slots used by this dialog. 100 */ 101 void connectSignalsSlots(); 102 103 bool m_restartPageEdit; 104 bool m_reloadPreview; 105 106 Ui::Preferences ui; 107 }; 108 109 #endif // PREFERENCES_H 110