Warning, file /frameworks/kwidgetsaddons/src/kpagedialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE Libraries 0003 SPDX-FileCopyrightText: 1999-2001 Mirko Boehm <mirko@kde.org> 0004 SPDX-FileCopyrightText: 1999-2001 Espen Sand <espen@kde.org> 0005 SPDX-FileCopyrightText: 1999-2001 Holger Freyther <freyther@kde.org> 0006 SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org> 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 0011 #include "kpagedialog.h" 0012 #include "kpagedialog_p.h" 0013 0014 #include <QLayout> 0015 #include <QStyle> 0016 0017 KPageDialog::KPageDialog(QWidget *parent, Qt::WindowFlags flags) 0018 : KPageDialog(*new KPageDialogPrivate(this), nullptr, parent, flags) 0019 { 0020 } 0021 0022 KPageDialog::KPageDialog(KPageWidget *widget, QWidget *parent, Qt::WindowFlags flags) 0023 : KPageDialog(*new KPageDialogPrivate(this), widget, parent, flags) 0024 { 0025 Q_ASSERT(widget); 0026 } 0027 0028 KPageDialog::KPageDialog(KPageDialogPrivate &dd, KPageWidget *widget, QWidget *parent, Qt::WindowFlags flags) 0029 : QDialog(parent, flags) 0030 , d_ptr(&dd) 0031 { 0032 Q_D(KPageDialog); 0033 if (widget) { 0034 widget->setParent(this); 0035 d->mPageWidget = widget; 0036 } else { 0037 d->mPageWidget = new KPageWidget(this); 0038 } 0039 d->mButtonBox = new QDialogButtonBox(this); 0040 d->mButtonBox->setObjectName(QStringLiteral("buttonbox")); 0041 d->mButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0042 d->init(); 0043 } 0044 0045 KPageDialog::~KPageDialog() = default; 0046 0047 void KPageDialog::setFaceType(FaceType faceType) 0048 { 0049 Q_D(KPageDialog); 0050 0051 d->mPageWidget->setFaceType(static_cast<KPageWidget::FaceType>(faceType)); 0052 0053 // Use zero margins for dialogs with the sidebar style so that the sidebar 0054 // can be flush with the window edge; margins for the content are added 0055 // automatically 0056 if (faceType == KPageDialog::Auto || faceType == KPageDialog::List || faceType == KPageDialog::FlatList) { 0057 layout()->setContentsMargins(0, 0, 0, 0); 0058 } else { 0059 const QStyle *style = d->mPageWidget->style(); 0060 layout()->setContentsMargins(style->pixelMetric(QStyle::PM_LayoutLeftMargin), 0061 style->pixelMetric(QStyle::PM_LayoutTopMargin), 0062 style->pixelMetric(QStyle::PM_LayoutRightMargin), 0063 style->pixelMetric(QStyle::PM_LayoutBottomMargin)); 0064 } 0065 } 0066 0067 KPageWidgetItem *KPageDialog::addPage(QWidget *widget, const QString &name) 0068 { 0069 Q_D(KPageDialog); 0070 0071 return d->mPageWidget->addPage(widget, name); 0072 } 0073 0074 void KPageDialog::addPage(KPageWidgetItem *item) 0075 { 0076 Q_D(KPageDialog); 0077 0078 d->mPageWidget->addPage(item); 0079 } 0080 0081 KPageWidgetItem *KPageDialog::insertPage(KPageWidgetItem *before, QWidget *widget, const QString &name) 0082 { 0083 Q_D(KPageDialog); 0084 0085 return d->mPageWidget->insertPage(before, widget, name); 0086 } 0087 0088 void KPageDialog::insertPage(KPageWidgetItem *before, KPageWidgetItem *item) 0089 { 0090 Q_D(KPageDialog); 0091 0092 d->mPageWidget->insertPage(before, item); 0093 } 0094 0095 KPageWidgetItem *KPageDialog::addSubPage(KPageWidgetItem *parent, QWidget *widget, const QString &name) 0096 { 0097 Q_D(KPageDialog); 0098 0099 return d->mPageWidget->addSubPage(parent, widget, name); 0100 } 0101 0102 void KPageDialog::addSubPage(KPageWidgetItem *parent, KPageWidgetItem *item) 0103 { 0104 Q_D(KPageDialog); 0105 0106 d->mPageWidget->addSubPage(parent, item); 0107 } 0108 0109 void KPageDialog::removePage(KPageWidgetItem *item) 0110 { 0111 Q_D(KPageDialog); 0112 0113 d->mPageWidget->removePage(item); 0114 } 0115 0116 void KPageDialog::setCurrentPage(KPageWidgetItem *item) 0117 { 0118 Q_D(KPageDialog); 0119 0120 d->mPageWidget->setCurrentPage(item); 0121 } 0122 0123 KPageWidgetItem *KPageDialog::currentPage() const 0124 { 0125 Q_D(const KPageDialog); 0126 0127 return d->mPageWidget->currentPage(); 0128 } 0129 0130 void KPageDialog::setStandardButtons(QDialogButtonBox::StandardButtons buttons) 0131 { 0132 Q_D(KPageDialog); 0133 0134 d->mButtonBox->setStandardButtons(buttons); 0135 } 0136 0137 QPushButton *KPageDialog::button(QDialogButtonBox::StandardButton which) const 0138 { 0139 Q_D(const KPageDialog); 0140 0141 return d->mButtonBox->button(which); 0142 } 0143 0144 void KPageDialog::addActionButton(QAbstractButton *button) 0145 { 0146 Q_D(KPageDialog); 0147 0148 d->mButtonBox->addButton(button, QDialogButtonBox::ActionRole); 0149 } 0150 0151 KPageWidget *KPageDialog::pageWidget() 0152 { 0153 Q_D(KPageDialog); 0154 0155 return d->mPageWidget; 0156 } 0157 0158 void KPageDialog::setPageWidget(KPageWidget *widget) 0159 { 0160 Q_D(KPageDialog); 0161 0162 delete d->mPageWidget; 0163 d->mPageWidget = widget; 0164 d->init(); 0165 } 0166 0167 const KPageWidget *KPageDialog::pageWidget() const 0168 { 0169 Q_D(const KPageDialog); 0170 0171 return d->mPageWidget; 0172 } 0173 0174 QDialogButtonBox *KPageDialog::buttonBox() 0175 { 0176 Q_D(KPageDialog); 0177 0178 return d->mButtonBox; 0179 } 0180 0181 const QDialogButtonBox *KPageDialog::buttonBox() const 0182 { 0183 Q_D(const KPageDialog); 0184 0185 return d->mButtonBox; 0186 } 0187 0188 void KPageDialog::setButtonBox(QDialogButtonBox *box) 0189 { 0190 Q_D(KPageDialog); 0191 0192 delete d->mButtonBox; 0193 d->mButtonBox = box; 0194 d->init(); 0195 } 0196 0197 #include "moc_kpagedialog.cpp"