blob: dce22aba1ad2773625bbe900f9eff5c12f009504 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#ifndef BTCONFIGDIALOG_H
#define BTCONFIGDIALOG_H
#include <QDialog>
#include <QDebug>
#include <QWidget>
class BtConfigPage;
class QDialogButtonBox;
class QLabel;
class QListWidget;
class QListWidgetItem;
class QStackedWidget;
class QVBoxLayout;
/**
* Base class for configuration dialogs. A dialog which has a page chooser (icons
* + text) at the left, widget pages and a buttonbox.
*
* Usage: add BtConfigPage pages with addPage(), add a button box with addButtonBox().
* Connect the button box signals. Use setAttribute(Qt::WA_DeleteOnClose) if you want
* an auto-destroying window.
*/
class BtConfigDialog : public QDialog {
Q_OBJECT
public:
BtConfigDialog(QWidget *parent = 0);
virtual ~BtConfigDialog();
/** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
void addPage(BtConfigPage* pageWidget);
/** Adds a button box to the lower edge of the dialog. */
void addButtonBox(QDialogButtonBox* buttonBox);
public slots:
/** Changes the current page using the given index number. */
void slotChangePage(int newIndex);
private:
QListWidget* m_contentsList;
QStackedWidget* m_pageWidget;
QVBoxLayout* m_pageLayout;
int m_maxItemWidth;
int m_previousPageIndex;
};
/**
* Base class for configuration dialog pages.
*/
class BtConfigPage : public QWidget {
Q_OBJECT
friend class BtConfigDialog;
public:
/**
Constructs a configuration dialog base, with QVBoxLayout as layout() and a header
label as the first widget in this layout.
\param[in] parent The parent widget.
*/
BtConfigPage(QWidget *parent = 0);
virtual ~BtConfigPage();
/** Implement these to return the correct values.
* For example: header(){return tr("General");}
*/
virtual const QIcon &icon() const = 0;
virtual QString header() const = 0;
inline BtConfigDialog *parentDialog() const {
return m_parentDialog;
}
private:
BtConfigDialog *m_parentDialog;
};
#endif
|