configdialog: Update icons in ThemeChanged event
[lxde/liblxqt.git] / configdialog / lxqtconfigdialog.h
1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
4 * LXQt - a lightweight, Qt based, desktop toolset
5 * http://razor-qt.org
6 *
7 * Copyright (C) 2012 Alec Moskvin <alecm@gmx.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * END_COMMON_COPYRIGHT_HEADER */
24
25 #ifndef LXQTCONFIGDIALOG_H
26 #define LXQTCONFIGDIALOG_H
27
28 #include "lxqtsettings.h"
29 #include <QDialog>
30 #include <QAbstractButton>
31 #include <QDialogButtonBox>
32 #include "lxqtglobals.h"
33
34 namespace Ui {
35 class ConfigDialog;
36 }
37
38 namespace LXQt
39 {
40
41 class LXQT_API ConfigDialog : public QDialog
42 {
43 Q_OBJECT
44
45 public:
46 explicit ConfigDialog(const QString& title, Settings* settings, QWidget* parent = 0);
47
48 ~ConfigDialog();
49
50 /*!
51 * Sets buttons in button bar
52 */
53 void setButtons(QDialogButtonBox::StandardButtons buttons);
54
55 /*!
56 * Add a page to the configure dialog
57 */
58 void addPage(QWidget* page, const QString& name, const QString& iconName="application-x-executable");
59
60 /*!
61 * Add a page to the configure dialog, attempting several alternative icons to find one in the theme
62 */
63 void addPage(QWidget* page, const QString& name, const QStringList& iconNames);
64
65 /*!
66 * Show page containing the widget in parameter
67 */
68 void showPage(QWidget *page);
69
70
71
72 signals:
73 /*!
74 * This signal is emitted when the user pressed the "Reset" button.
75 * Settings should be re-read and the widgets should be set accordingly.
76 */
77 void reset();
78
79 /*!
80 * This is emitted whenever the window is closed and settings need to be saved.
81 * It is only necessary if additional actions need to be performed - Settings are handled automatically.
82 */
83 void save();
84
85 /*!
86 * This is emitted when some button in the buttonbar is clicked.
87 */
88 void clicked(QDialogButtonBox::StandardButton);
89
90 protected:
91 Settings* mSettings;
92 virtual bool event(QEvent * event) override;
93 virtual void closeEvent(QCloseEvent* event) override;
94
95 private:
96 SettingsCache* mCache;
97 QList<QStringList> mIcons;
98 QSize mMaxSize;
99 Ui::ConfigDialog* ui;
100
101 private slots:
102 void dialogButtonsAction(QAbstractButton* button);
103 void updateIcons();
104
105 };
106
107 } // namespace LXQt
108 #endif // LXQTCONFIGDIALOG_H