KWidgetsAddons

kpagedialog.cpp
1/*
2 This file is part of the KDE Libraries
3 SPDX-FileCopyrightText: 1999-2001 Mirko Boehm <mirko@kde.org>
4 SPDX-FileCopyrightText: 1999-2001 Espen Sand <espen@kde.org>
5 SPDX-FileCopyrightText: 1999-2001 Holger Freyther <freyther@kde.org>
6 SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10
11#include "kpagedialog.h"
12#include "kpagedialog_p.h"
13
14#include <QLayout>
15#include <QStyle>
16
18 : KPageDialog(*new KPageDialogPrivate(this), nullptr, parent, flags)
19{
20}
21
23 : KPageDialog(*new KPageDialogPrivate(this), widget, parent, flags)
24{
25 Q_ASSERT(widget);
26}
27
28KPageDialog::KPageDialog(KPageDialogPrivate &dd, KPageWidget *widget, QWidget *parent, Qt::WindowFlags flags)
29 : QDialog(parent, flags)
30 , d_ptr(&dd)
31{
33 if (widget) {
34 widget->setParent(this);
35 d->mPageWidget = widget;
36 } else {
37 d->mPageWidget = new KPageWidget(this);
38 }
39 d->mButtonBox = new QDialogButtonBox(this);
40 d->mButtonBox->setObjectName(QStringLiteral("buttonbox"));
41 d->mButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
42 d->init();
43}
44
46
48{
50
51 d->mPageWidget->setFaceType(static_cast<KPageWidget::FaceType>(faceType));
52
53 // Use zero margins for dialogs with the sidebar style so that the sidebar
54 // can be flush with the window edge; margins for the content are added
55 // automatically
56 layout()->setContentsMargins(0, 0, 0, 0);
57}
58
60{
62
63 return d->mPageWidget->addPage(widget, name);
64}
65
67{
69
70 d->mPageWidget->addPage(item);
71}
72
74{
76
77 return d->mPageWidget->insertPage(before, widget, name);
78}
79
81{
83
84 d->mPageWidget->insertPage(before, item);
85}
86
88{
90
91 return d->mPageWidget->addSubPage(parent, widget, name);
92}
93
95{
97
98 d->mPageWidget->addSubPage(parent, item);
99}
100
102{
104
105 d->mPageWidget->removePage(item);
106}
107
109{
111
112 d->mPageWidget->setCurrentPage(item);
113}
114
116{
117 Q_D(const KPageDialog);
118
119 return d->mPageWidget->currentPage();
120}
121
123{
125
126 d->mButtonBox->setStandardButtons(buttons);
127}
128
130{
131 Q_D(const KPageDialog);
132
133 return d->mButtonBox->button(which);
134}
135
137{
139
140 d->mButtonBox->addButton(button, QDialogButtonBox::ActionRole);
141}
142
144{
146
147 return d->mPageWidget;
148}
149
151{
153
154 delete d->mPageWidget;
155 d->mPageWidget = widget;
156 d->init();
157}
158
160{
161 Q_D(const KPageDialog);
162
163 return d->mPageWidget;
164}
165
167{
169
170 return d->mButtonBox;
171}
172
174{
175 Q_D(const KPageDialog);
176
177 return d->mButtonBox;
178}
179
181{
183
184 delete d->mButtonBox;
185 d->mButtonBox = box;
186 d->init();
187}
188
189#include "moc_kpagedialog.cpp"
A dialog base class which can handle multiple pages.
Definition kpagedialog.h:78
QDialogButtonBox * buttonBox()
Returns the button box of the dialog or a null pointer if no button box is set.
KPageWidgetItem * addPage(QWidget *widget, const QString &name)
Adds a new top level page to the dialog.
KPageWidgetItem * insertPage(KPageWidgetItem *before, QWidget *widget, const QString &name)
Inserts a new page in the dialog.
FaceType
The face types supported.
Definition kpagedialog.h:86
KPageWidgetItem * addSubPage(KPageWidgetItem *parent, QWidget *widget, const QString &name)
Inserts a new sub page in the dialog.
~KPageDialog() override
Destroys the page dialog.
KPageWidget * pageWidget()
Returns the page widget of the dialog or a null pointer if no page widget is set.
void setButtonBox(QDialogButtonBox *box)
Set the button box of the dialog.
void addActionButton(QAbstractButton *button)
Set an action button.
QPushButton * button(QDialogButtonBox::StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or a null pointer if the standard...
void setCurrentPage(KPageWidgetItem *item)
Sets the page which is associated with the given KPageWidgetItem to be the current page and emits the...
KPageWidgetItem * currentPage() const
Returns the KPageWidgetItem for the current page or a null pointer if there is no current page.
void removePage(KPageWidgetItem *item)
Removes the page associated with the given KPageWidgetItem.
void setStandardButtons(QDialogButtonBox::StandardButtons buttons)
Sets the collection of standard buttons displayed by this dialog.
KPageDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Creates a new page dialog.
void setFaceType(FaceType faceType)
Sets the face type of the dialog.
void setPageWidget(KPageWidget *widget)
Set the page widget of the dialog.
FaceType
This enum is used to decide which type of navigation view shall be used in the page view.
Definition kpageview.h:62
KPageWidgetItem is used by KPageWidget and represents a page.
Page widget with many layouts (faces).
Definition kpagewidget.h:25
void setContentsMargins(const QMargins &margins)
QObject * parent() const const
typedef WindowFlags
QLayout * layout() const const
void setParent(QWidget *parent)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:52:13 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.