Changeset View
Changeset View
Standalone View
Standalone View
src/kpagedialog.cpp
Show All 20 Lines | |||||
21 | * Boston, MA 02110-1301, USA. | 21 | * Boston, MA 02110-1301, USA. | ||
22 | * | 22 | * | ||
23 | */ | 23 | */ | ||
24 | 24 | | |||
25 | #include "kpagedialog.h" | 25 | #include "kpagedialog.h" | ||
26 | #include "kpagedialog_p.h" | 26 | #include "kpagedialog_p.h" | ||
27 | 27 | | |||
28 | #include <QLayout> | 28 | #include <QLayout> | ||
29 | #include <QStyle> | ||||
29 | 30 | | |||
30 | KPageDialog::KPageDialog(QWidget *parent, Qt::WindowFlags flags) | 31 | KPageDialog::KPageDialog(QWidget *parent, Qt::WindowFlags flags) | ||
31 | : QDialog(parent, flags), | 32 | : QDialog(parent, flags), | ||
32 | d_ptr(new KPageDialogPrivate(this)) | 33 | d_ptr(new KPageDialogPrivate(this)) | ||
33 | { | 34 | { | ||
34 | Q_D(KPageDialog); | 35 | Q_D(KPageDialog); | ||
35 | d->mPageWidget = new KPageWidget(this); | 36 | d->mPageWidget = new KPageWidget(this); | ||
36 | d->mPageWidget->layout()->setContentsMargins(0, 0, 0, 0); | | |||
37 | 37 | | |||
38 | d->mButtonBox = new QDialogButtonBox(this); | 38 | d->mButtonBox = new QDialogButtonBox(this); | ||
39 | d->mButtonBox->setObjectName(QStringLiteral("buttonbox")); | 39 | d->mButtonBox->setObjectName(QStringLiteral("buttonbox")); | ||
40 | d->mButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | 40 | d->mButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
41 | 41 | | |||
42 | d->init(); | 42 | d->init(); | ||
43 | } | 43 | } | ||
44 | 44 | | |||
Show All 31 Lines | |||||
76 | 76 | | |||
77 | KPageDialog::~KPageDialog() | 77 | KPageDialog::~KPageDialog() | ||
78 | { | 78 | { | ||
79 | delete d_ptr; | 79 | delete d_ptr; | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | void KPageDialog::setFaceType(FaceType faceType) | 82 | void KPageDialog::setFaceType(FaceType faceType) | ||
83 | { | 83 | { | ||
84 | d_func()->mPageWidget->setFaceType(static_cast<KPageWidget::FaceType>(faceType)); | 84 | KPageWidget *pageWidget = d_func()->mPageWidget; | ||
85 | pageWidget->setFaceType(static_cast<KPageWidget::FaceType>(faceType)); | ||||
85 | 86 | | |||
86 | if (faceType == Tabbed) { | 87 | // Use zero margins for dialogs with the sidebar style so that the sidebar | ||
87 | layout()->setContentsMargins(6, 6, 6, 6); | 88 | // can be flush with the window edge; margins for the content are added | ||
88 | } else { | 89 | // automatically | ||
90 | if (faceType == KPageWidget::Auto || faceType == KPageWidget::List){ | ||||
89 | layout()->setContentsMargins(0, 0, 0, 0); | 91 | layout()->setContentsMargins(0, 0, 0, 0); | ||
92 | } else { | ||||
93 | const QStyle *style = pageWidget->style(); | ||||
94 | layout()->setContentsMargins( | ||||
95 | style->pixelMetric(QStyle::PM_LayoutLeftMargin), | ||||
96 | style->pixelMetric(QStyle::PM_LayoutTopMargin), | ||||
97 | style->pixelMetric(QStyle::PM_LayoutRightMargin), | ||||
98 | style->pixelMetric(QStyle::PM_LayoutBottomMargin) | ||||
99 | ); | ||||
90 | } | 100 | } | ||
91 | } | 101 | } | ||
92 | 102 | | |||
93 | KPageWidgetItem *KPageDialog::addPage(QWidget *widget, const QString &name) | 103 | KPageWidgetItem *KPageDialog::addPage(QWidget *widget, const QString &name) | ||
94 | { | 104 | { | ||
95 | return d_func()->mPageWidget->addPage(widget, name); | 105 | return d_func()->mPageWidget->addPage(widget, name); | ||
96 | } | 106 | } | ||
97 | 107 | | |||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |