BibleTime
btconfigdialog.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include <QDialog>
16 
17 #include <QIcon>
18 #include <QObject>
19 #include <QString>
20 #include <QWidget>
21 #include <Qt>
22 
23 
24 class QListWidget;
25 class QListWidgetItem;
26 class QStackedWidget;
27 
28 /**
29 * Base class for configuration dialogs. A dialog which has a page chooser (icons
30 * + text) at the left, widget pages and a buttonbox.
31 *
32 * Usage: add BtConfigPage pages with addPage(), add a button box with addButtonBox().
33 * Connect the button box signals. Use setAttribute(Qt::WA_DeleteOnClose) if you want
34 * an auto-destroying window.
35 */
36 class BtConfigDialog : public QDialog {
37 
38  Q_OBJECT
39 
40 public: // types:
41 
42  /** Base class for configuration dialog pages. */
43  class Page : public QWidget {
44 
45  friend class BtConfigDialog;
46 
47  public: // methods:
48 
49  Page(QIcon const & icon, QWidget * const parent = nullptr);
50  ~Page() noexcept override;
51 
52  void setHeaderText(QString const & headerText);
53 
54  virtual void save() const = 0;
55 
56  private: // fields:
57 
59  bool m_ownsListWidgetItem = true;
60 
61  };
62 
63 public: // methods:
64 
65  BtConfigDialog(QWidget * const parent = nullptr,
66  Qt::WindowFlags const flags = Qt::WindowFlags());
67 
68  /**
69  \brief Adds the page to this dialog, taking ownership.
70  \param[in] page pointer to the page to add.
71  */
72  void addPage(Page * const pageWidget);
73 
74  void save();
75 
76 Q_SIGNALS:
77 
79 
80 private: // fields:
81 
82  QListWidget * const m_contentsList;
83  QStackedWidget * const m_pageWidget;
84  int m_maxItemWidth = 0;
85 
86 };
void setHeaderText(QString const &headerText)
virtual void save() const =0
QListWidgetItem *const m_listWidgetItem
Page(QIcon const &icon, QWidget *const parent=nullptr)
~Page() noexcept override
void addPage(Page *const pageWidget)
Adds the page to this dialog, taking ownership.
QListWidget *const m_contentsList
QStackedWidget *const m_pageWidget
void signalSettingsChanged()