configpage.h
1 //------------------------------------------------------------------------------
2 // configpage.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 
24 #ifndef _CONFIG_PAGE_H_
25 #define _CONFIG_PAGE_H_
26 
27 #include "dptr.h"
28 #include "global.h"
29 #include "serverapi/polymorphism.h"
30 #include <QWidget>
31 
44 class MAIN_EXPORT ConfigPage : public QWidget
45 {
46  Q_OBJECT
47 
48 public:
51  {
56  };
57 
58  ConfigPage(QWidget *parent = nullptr);
59  virtual ~ConfigPage() override;
60 
66  bool allowSave();
71  bool areSettingsAlreadyRead();
72 
80  virtual QIcon icon() const = 0;
81 
86  virtual QString name() const = 0;
87 
92  void setAllowSave(bool b);
96  void read();
103  void reject();
109  bool save();
113  virtual QString title() const;
114 
143  virtual Validation validate();
144 
145 signals:
153  void appearanceChanged();
158  void restartNeeded();
159 
166  void validationRequested();
167 
168 protected:
172  virtual void readSettings() = 0;
173 
177  virtual void saveSettings() = 0;
178 
179  POLYMORPHIC_SETTER_DECLARE(void, ConfigPage, reject, ())
180  void reject_default();
181 
182 private:
183  DPtr<ConfigPage> d;
184 };
185 
186 #endif