diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qplatformdialoghelper.cpp | 37 | ||||
-rw-r--r-- | src/gui/kernel/qplatformdialoghelper.h | 22 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 2 |
4 files changed, 58 insertions, 5 deletions
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index b456c1ca31..b787629f6a 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -44,6 +44,7 @@ #include <QtCore/QSharedData> #include <QtCore/QSettings> #include <QtCore/QUrl> +#include <QtCore/QVector> #include <QtGui/QColor> #include <algorithm> @@ -786,7 +787,8 @@ class QMessageDialogOptionsPrivate : public QSharedData public: QMessageDialogOptionsPrivate() : icon(QMessageDialogOptions::NoIcon), - buttons(QPlatformDialogHelper::Ok) + buttons(QPlatformDialogHelper::Ok), + nextCustomButtonId(QPlatformDialogHelper::LastButton + 1) {} QString windowTitle; @@ -795,6 +797,8 @@ public: QString informativeText; QString detailedText; QPlatformDialogHelper::StandardButtons buttons; + QVector<QMessageDialogOptions::CustomButton> customButtons; + int nextCustomButtonId; }; QMessageDialogOptions::QMessageDialogOptions(QMessageDialogOptionsPrivate *dd) @@ -886,6 +890,35 @@ QPlatformDialogHelper::StandardButtons QMessageDialogOptions::standardButtons() return d->buttons; } +int QMessageDialogOptions::addButton(const QString &label, QPlatformDialogHelper::ButtonRole role, + void *buttonImpl) +{ + const CustomButton b(d->nextCustomButtonId++, label, role, buttonImpl); + d->customButtons.append(b); + return b.id; +} + +static inline bool operator==(const QMessageDialogOptions::CustomButton &a, + const QMessageDialogOptions::CustomButton &b) { + return a.id == b.id; +} + +void QMessageDialogOptions::removeButton(int id) +{ + d->customButtons.removeOne(CustomButton(id)); +} + +const QVector<QMessageDialogOptions::CustomButton> &QMessageDialogOptions::customButtons() +{ + return d->customButtons; +} + +const QMessageDialogOptions::CustomButton *QMessageDialogOptions::customButton(int id) +{ + int i = d->customButtons.indexOf(CustomButton(id)); + return (i < 0 ? nullptr : &d->customButtons.at(i)); +} + QPlatformDialogHelper::ButtonRole QPlatformDialogHelper::buttonRole(QPlatformDialogHelper::StandardButton button) { switch (button) { diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h index 3000bd1af1..2c050535d8 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -460,6 +460,26 @@ public: void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); QPlatformDialogHelper::StandardButtons standardButtons() const; + struct CustomButton { + explicit CustomButton( + int id = -1, const QString &label = QString(), + QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::InvalidRole, + void *button = nullptr) : + label(label), role(role), id(id), button(button) + {} + + QString label; + QPlatformDialogHelper::ButtonRole role; + int id; + void *button; // strictly internal use only + }; + + int addButton(const QString &label, QPlatformDialogHelper::ButtonRole role, + void *buttonImpl = nullptr); + void removeButton(int id); + const QVector<CustomButton> &customButtons(); + const CustomButton *customButton(int id); + private: QMessageDialogOptionsPrivate *d; }; diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 358ff16930..9614be7f3e 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -72,7 +72,7 @@ QPlatformScreen::~QPlatformScreen() This function is called when Qt needs to be able to grab the content of a window. - Returnes the content of the window specified with the WId handle within the boundaries of + Returns the content of the window specified with the WId handle within the boundaries of QRect(x,y,width,height). */ QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index e83f76fb06..50f05721f7 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -140,7 +140,7 @@ void QPlatformWindow::setGeometry(const QRect &rect) } /*! - Returnes the current geometry of a window + Returns the current geometry of a window */ QRect QPlatformWindow::geometry() const { |