diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-08-08 16:23:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-22 06:47:05 +0200 |
commit | 5ba72276c48aafd3179cf96a32eedfe8cc68646d (patch) | |
tree | 32795f947344faa2168cb8133f69811a2a199f58 /src/widgets | |
parent | 04bc63f2d642d2144757ef1ab5e65b5518d534f5 (diff) |
QMessageBox - move layout handling
This patch moves some layout handling to a new function.
That will be helpful later since we can re-use the new function.
Change-Id: I4cc846f9958d9530ec2b07292093b94bd27ee055
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 995d279e13..2467f07d91 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -201,6 +201,7 @@ public: detectedEscapeButton(0), informativeLabel(0) { } void init(const QString &title = QString(), const QString &text = QString()); + void setupLayout(); void _q_buttonClicked(QAbstractButton *); QAbstractButton *findButton(int button0, int button1, int button2, int flags); @@ -271,7 +272,6 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) label->setContentsMargins(2, 0, 0, 0); label->setIndent(9); #endif - icon = QMessageBox::NoIcon; iconLabel = new QLabel; iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label")); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -281,7 +281,24 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q)); QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), q, SLOT(_q_buttonClicked(QAbstractButton*))); + setupLayout(); + if (!title.isEmpty() || !text.isEmpty()) { + q->setWindowTitle(title); + q->setText(text); + } + q->setModal(true); +#ifdef Q_OS_MAC + QFont f = q->font(); + f.setBold(true); + label->setFont(f); +#endif + icon = QMessageBox::NoIcon; +} +void QMessageBoxPrivate::setupLayout() +{ + Q_Q(QMessageBox); + delete q->layout(); QGridLayout *grid = new QGridLayout; #ifndef Q_OS_MAC grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop); @@ -304,17 +321,6 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) grid->setSizeConstraint(QLayout::SetNoConstraint); q->setLayout(grid); - if (!title.isEmpty() || !text.isEmpty()) { - q->setWindowTitle(title); - q->setText(text); - } - q->setModal(true); - -#ifdef Q_OS_MAC - QFont f = q->font(); - f.setBold(true); - label->setFont(f); -#endif retranslateStrings(); } |