KCMUtils

kcmultidialog.h
1/*
2 SPDX-FileCopyrightText: 2000 Matthias Elter <elter@kde.org>
3 SPDX-FileCopyrightText: 2003 Daniel Molkentin <molkentin@kde.org>
4 SPDX-FileCopyrightText: 2003, 2006 Matthias Kretz <kretz@kde.org>
5 SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KCMULTIDIALOG_H
11#define KCMULTIDIALOG_H
12
13#include <QScrollArea>
14#include <QScrollBar>
15
16#include <KPageDialog>
17#include <KPluginMetaData>
18
19#include "kcmutils_export.h"
20
21class KCMultiDialogPrivate;
22
23/**
24 * @short A class that offers a KPageDialog containing config modules
25 *
26 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
27 */
28class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
29{
31
32public:
33 /**
34 * Constructs a new KCMultiDialog
35 *
36 * @param parent The parent widget
37 **/
38 explicit KCMultiDialog(QWidget *parent = nullptr);
39
40 /**
41 * Destructor
42 **/
43 ~KCMultiDialog() override;
44
45 /**
46 * Add a module to the dialog. Its position will be determined based on the @c X-KDE-Weight value.
47 * @param metaData KPluginMetaData that will be used to load the plugin
48 * @param args The arguments that should be given to the KCModule when it is created
49 */
50 KPageWidgetItem *addModule(const KPluginMetaData &metaData, const QVariantList &args = {});
51
52 /**
53 * Removes all modules from the dialog.
54 */
55 void clear();
56
57 /**
58 * Show or hide an indicator when settings have changed from their default value
59 *
60 * @since 6.0
61 */
62 void setDefaultsIndicatorsVisible(bool show);
63
64Q_SIGNALS:
65 /**
66 * Emitted after all KCModules have been told to save their configuration.
67 *
68 * The applyClicked and okClicked signals are emitted before the
69 * configuration is saved.
70 */
72
73protected:
74 void closeEvent(QCloseEvent *event) override;
75 void showEvent(QShowEvent *event) override;
76
77protected Q_SLOTS:
78 /**
79 * This slot is called when the user presses the "Default" Button.
80 * You can reimplement it if needed.
81 *
82 * @note Make sure you call the original implementation.
83 **/
84 void slotDefaultClicked();
85
86 /**
87 * This slot is called when the user presses the "Reset" Button.
88 * You can reimplement it if needed.
89 *
90 * @note Make sure you call the original implementation.
91 */
92 void slotUser1Clicked();
93
94 /**
95 * This slot is called when the user presses the "Apply" Button.
96 * You can reimplement it if needed.
97 *
98 * @note Make sure you call the original implementation.
99 **/
100 void slotApplyClicked();
101
102 /**
103 * This slot is called when the user presses the "OK" Button.
104 * You can reimplement it if needed.
105 *
106 * @note Make sure you call the original implementation.
107 **/
108 void slotOkClicked();
109
110 /**
111 * This slot is called when the user presses the "Help" Button.
112 * It reads the X-DocPath field of the currently selected KControl
113 * module's .desktop file to find the path to the documentation,
114 * which it then attempts to load.
115 *
116 * You can reimplement this slot if needed.
117 *
118 * @note Make sure you call the original implementation.
119 **/
120 void slotHelpClicked();
121
122private:
123 friend KCMultiDialogPrivate;
124 const std::unique_ptr<KCMultiDialogPrivate> d;
125};
126
127/**
128 * @brief Custom QScrollArea class that doesn't limit its size hint
129 *
130 * See original QScrollArea::sizeHint() function,
131 * where the size hint is bound by 36*24 font heights
132 *
133 * Workaround for https://bugreports.qt.io/browse/QTBUG-10459
134 */
135
136class UnboundScrollArea : public QScrollArea
137{
139public:
140 QSize sizeHint() const override
141 {
142 if (widget()) {
143 // Try to avoid horizontal scrollbar, which just scrolls a scrollbar width.
144 // We always need to reserve space for the vertical scroll bar,
145 // because we can’t know here whether vertical scrolling will be used.
146 QSize withScrollbar = widget()->sizeHint();
147 withScrollbar.rwidth() += verticalScrollBar()->sizeHint().width() + 4;
148 return withScrollbar;
149 } else {
150 return QScrollArea::sizeHint();
151 }
152 }
153
154 explicit UnboundScrollArea(QWidget *w)
155 : QScrollArea(w)
156 {
157 }
158 ~UnboundScrollArea() override = default;
159};
160
161#endif
void slotApplyClicked()
This slot is called when the user presses the "Apply" Button.
void slotOkClicked()
This slot is called when the user presses the "OK" Button.
~KCMultiDialog() override
Destructor.
KCMultiDialog(QWidget *parent=nullptr)
Constructs a new KCMultiDialog.
void slotUser1Clicked()
This slot is called when the user presses the "Reset" Button.
KPageWidgetItem * addModule(const KPluginMetaData &metaData, const QVariantList &args={})
Add a module to the dialog.
void configCommitted()
Emitted after all KCModules have been told to save their configuration.
void slotDefaultClicked()
This slot is called when the user presses the "Default" Button.
void slotHelpClicked()
This slot is called when the user presses the "Help" Button.
KPageDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
QScrollBar * verticalScrollBar() const const
virtual void closeEvent(QCloseEvent *e) override
virtual void showEvent(QShowEvent *event) override
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
QScrollArea(QWidget *parent)
virtual QSize sizeHint() const const override
QWidget * widget() const const
virtual QSize sizeHint() const const override
int & rwidth()
int width() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:51:31 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.