diff options
author | Anton Lundin <glance@acc.umu.se> | 2014-07-02 22:59:32 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-04 07:33:08 -0700 |
commit | 77a55db9d3e2e618c64f810a8bb664aa01ca7d22 (patch) | |
tree | a1ea361401721b73e86924a5140c048658cfe93e /qt-ui/kmessagewidget.cpp | |
parent | c16d4ca5d5325422425a54df9252b73706918e28 (diff) | |
download | subsurface-77a55db9d3e2e618c64f810a8bb664aa01ca7d22.tar.gz |
Use QDialogButtonBox in KMessageWidget
QDialogButtonBox can auto-choose the order of the actions based on the
current interfaces guidelines, but in this case its a guessing game.
It does a half-decent job off guessing.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/kmessagewidget.cpp')
-rw-r--r-- | qt-ui/kmessagewidget.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/qt-ui/kmessagewidget.cpp b/qt-ui/kmessagewidget.cpp index 2f9ac6870..e03d10c75 100644 --- a/qt-ui/kmessagewidget.cpp +++ b/qt-ui/kmessagewidget.cpp @@ -21,7 +21,7 @@ #include <QEvent> #include <QGridLayout> -#include <QHBoxLayout> +#include <QDialogButtonBox> #include <QLabel> #include <QPainter> #include <QShowEvent> @@ -92,27 +92,32 @@ void KMessageWidgetPrivate::createLayout() layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop); layout->addWidget(textLabel, 0, 1); - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(); + QDialogButtonBox *buttonLayout = new QDialogButtonBox(); + //buttonLayout->addStretch(); Q_FOREACH (QToolButton *button, buttons) { // For some reason, calling show() is necessary if wordwrap is true, // otherwise the buttons do not show up. It is not needed if // wordwrap is false. button->show(); - buttonLayout->addWidget(button); + buttonLayout->addButton(button, QDialogButtonBox::QDialogButtonBox::AcceptRole); } - buttonLayout->addWidget(closeButton); - layout->addItem(buttonLayout, 1, 0, 1, 2); + buttonLayout->addButton(closeButton, QDialogButtonBox::RejectRole); + layout->addWidget(buttonLayout, 1, 0, 1, 2, Qt::AlignHCenter | Qt::AlignTop); } else { + bool closeButtonVisible = closeButton->isVisible(); QHBoxLayout *layout = new QHBoxLayout(content); layout->addWidget(iconLabel); layout->addWidget(textLabel); + QDialogButtonBox *buttonLayout = new QDialogButtonBox(); Q_FOREACH (QToolButton *button, buttons) { - layout->addWidget(button); + buttonLayout->addButton(button, QDialogButtonBox::QDialogButtonBox::AcceptRole); } - layout->addWidget(closeButton); + buttonLayout->addButton(closeButton, QDialogButtonBox::RejectRole); + // Something gets changed when added to the buttonLayout + closeButton->setVisible(closeButtonVisible); + layout->addWidget(buttonLayout); }; if (q->isVisible()) { |