diff options
Diffstat (limited to 'src/widgets')
22 files changed, 323 insertions, 262 deletions
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index a2bf14b25b..c598a5b4cb 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -826,6 +826,9 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones } // else both are "none" which is the default - no need to set them + if (block.textDirection() == Qt::RightToLeft) + attrs["writing-mode"] = QStringLiteral("rl"); + QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment(); attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" )); diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri index 53d1985fb5..206b394ed6 100644 --- a/src/widgets/dialogs/dialogs.pri +++ b/src/widgets/dialogs/dialogs.pri @@ -2,7 +2,6 @@ HEADERS += \ dialogs/qcolordialog.h \ - dialogs/qcolordialog_p.h \ dialogs/qfscompleter_p.h \ dialogs/qdialog.h \ dialogs/qdialog_p.h \ diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 5f3161f39f..914ee8ec9c 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include "qcolordialog_p.h" +#include "qcolordialog.h" #ifndef QT_NO_COLORDIALOG @@ -49,6 +49,7 @@ #include "qpixmap.h" #include "qpushbutton.h" #include "qsettings.h" +#include "qsharedpointer.h" #include "qstyle.h" #include "qstyleoption.h" #include "qvalidator.h" @@ -58,13 +59,132 @@ #include "qscreen.h" #include "qcursor.h" #include "qtimer.h" +#include "qwindow.h" + +#include "private/qdialog_p.h" #include <algorithm> QT_BEGIN_NAMESPACE +namespace { +class QColorLuminancePicker; +class QColorPicker; +class QColorShower; +class QWellArray; +class QColorPickingEventFilter; +} // unnamed namespace + +class QColorDialogPrivate : public QDialogPrivate +{ + Q_DECLARE_PUBLIC(QColorDialog) + +public: + enum SetColorMode { + ShowColor = 0x1, + SelectColor = 0x2, + SetColorAll = ShowColor | SelectColor + }; + + QColorDialogPrivate() : options(new QColorDialogOptions) +#ifdef Q_OS_WIN32 + , updateTimer(0) +#endif + {} + + QPlatformColorDialogHelper *platformColorDialogHelper() const + { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); } + + void init(const QColor &initial); + void initWidgets(); + QRgb currentColor() const; + QColor currentQColor() const; + void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll); + void setCurrentRgbColor(QRgb rgb); + void setCurrentQColor(const QColor &color); + bool selectColor(const QColor &color); + QColor grabScreenColor(const QPoint &p); + + int currentAlpha() const; + void setCurrentAlpha(int a); + void showAlpha(bool b); + bool isAlphaVisible() const; + void retranslateStrings(); + + void _q_addCustom(); + + void _q_newHsv(int h, int s, int v); + void _q_newColorTypedIn(QRgb rgb); + void _q_nextCustom(int, int); + void _q_newCustom(int, int); + void _q_newStandard(int, int); + void _q_pickScreenColor(); + void _q_updateColorPicking(); + void updateColorLabelText(const QPoint &); + void updateColorPicking(const QPoint &pos); + void releaseColorPicking(); + bool handleColorPickingMouseMove(QMouseEvent *e); + bool handleColorPickingMouseButtonRelease(QMouseEvent *e); + bool handleColorPickingKeyPress(QKeyEvent *e); + + bool canBeNativeDialog() const Q_DECL_OVERRIDE; + + QWellArray *custom; + QWellArray *standard; + + QDialogButtonBox *buttons; + QVBoxLayout *leftLay; + QColorPicker *cp; + QColorLuminancePicker *lp; + QColorShower *cs; + QLabel *lblBasicColors; + QLabel *lblCustomColors; + QLabel *lblScreenColorInfo; + QPushButton *ok; + QPushButton *cancel; + QPushButton *addCusBt; + QPushButton *screenColorPickerButton; + QColor selectedQColor; + int nextCust; + bool smallDisplay; + bool screenColorPicking; + QColorPickingEventFilter *colorPickingEventFilter; + QRgb beforeScreenColorPicking; + QSharedPointer<QColorDialogOptions> options; + + QPointer<QObject> receiverToDisconnectOnClose; + QByteArray memberToDisconnectOnClose; +#ifdef Q_OS_WIN32 + QTimer *updateTimer; + QWindow dummyTransparentWindow; +#endif + +#ifdef Q_DEAD_CODE_FROM_QT4_MAC + void openCocoaColorPanel(const QColor &initial, + QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options); + void closeCocoaColorPanel(); + void releaseCocoaColorPanelDelegate(); + void setCocoaPanelColor(const QColor &color); + + inline void done(int result) { q_func()->done(result); } + inline QColorDialog *colorDialog() { return q_func(); } + + void *delegate; + + static bool sharedColorPanelAvailable; + + void _q_macRunNativeAppModalPanel(); + void mac_nativeDialogModalHelp(); +#endif +private: + virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE; + virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE; +}; + //////////// QWellArray BEGIN +namespace { + struct QWellArrayData; class QWellArray : public QWidget @@ -446,6 +566,8 @@ private: QColorDialogPrivate *m_dp; }; +} // unnamed namespace + /*! Returns the number of custom colors supported by QColorDialog. All color dialogs share the same custom colors. @@ -506,6 +628,8 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v) c.getHsv(&h, &s, &v); } +namespace { + class QColorWell : public QWellArray { public: @@ -975,8 +1099,8 @@ private: QColorDialog *colorDialog; QGridLayout *gl; - friend class QColorDialog; - friend class QColorDialogPrivate; + friend class QT_PREPEND_NAMESPACE(QColorDialog); + friend class QT_PREPEND_NAMESPACE(QColorDialogPrivate); }; class QColorShowLabel : public QFrame @@ -1265,6 +1389,8 @@ QColorShower::QColorShower(QColorDialog *parent) retranslateStrings(); } +} // unnamed namespace + inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); } inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); } inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); } diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index 16339f56c4..43c7716ef6 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -113,7 +113,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor()) Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking()) - friend class QColorShower; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions) diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h deleted file mode 100644 index 1a881eae70..0000000000 --- a/src/widgets/dialogs/qcolordialog_p.h +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCOLORDIALOG_P_H -#define QCOLORDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// to version without notice, or even be removed. -// -// We mean it. -// -// - -#include "private/qdialog_p.h" -#include "qcolordialog.h" -#include "qsharedpointer.h" -#include "qwindow.h" - -#ifndef QT_NO_COLORDIALOG - -QT_BEGIN_NAMESPACE - -class QColorLuminancePicker; -class QColorPicker; -class QColorShower; -class QDialogButtonBox; -class QLabel; -class QVBoxLayout; -class QPushButton; -class QWellArray; -class QColorPickingEventFilter; -class QTimer; - -class QColorDialogPrivate : public QDialogPrivate -{ - Q_DECLARE_PUBLIC(QColorDialog) - -public: - enum SetColorMode { - ShowColor = 0x1, - SelectColor = 0x2, - SetColorAll = ShowColor | SelectColor - }; - - QColorDialogPrivate() : options(new QColorDialogOptions) -#ifdef Q_OS_WIN32 - , updateTimer(0) -#endif - {} - - QPlatformColorDialogHelper *platformColorDialogHelper() const - { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); } - - void init(const QColor &initial); - void initWidgets(); - QRgb currentColor() const; - QColor currentQColor() const; - void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll); - void setCurrentRgbColor(QRgb rgb); - void setCurrentQColor(const QColor &color); - bool selectColor(const QColor &color); - QColor grabScreenColor(const QPoint &p); - - int currentAlpha() const; - void setCurrentAlpha(int a); - void showAlpha(bool b); - bool isAlphaVisible() const; - void retranslateStrings(); - - void _q_addCustom(); - - void _q_newHsv(int h, int s, int v); - void _q_newColorTypedIn(QRgb rgb); - void _q_nextCustom(int, int); - void _q_newCustom(int, int); - void _q_newStandard(int, int); - void _q_pickScreenColor(); - void _q_updateColorPicking(); - void updateColorLabelText(const QPoint &); - void updateColorPicking(const QPoint &pos); - void releaseColorPicking(); - bool handleColorPickingMouseMove(QMouseEvent *e); - bool handleColorPickingMouseButtonRelease(QMouseEvent *e); - bool handleColorPickingKeyPress(QKeyEvent *e); - - bool canBeNativeDialog() const Q_DECL_OVERRIDE; - - QWellArray *custom; - QWellArray *standard; - - QDialogButtonBox *buttons; - QVBoxLayout *leftLay; - QColorPicker *cp; - QColorLuminancePicker *lp; - QColorShower *cs; - QLabel *lblBasicColors; - QLabel *lblCustomColors; - QLabel *lblScreenColorInfo; - QPushButton *ok; - QPushButton *cancel; - QPushButton *addCusBt; - QPushButton *screenColorPickerButton; - QColor selectedQColor; - int nextCust; - bool smallDisplay; - bool screenColorPicking; - QColorPickingEventFilter *colorPickingEventFilter; - QRgb beforeScreenColorPicking; - QSharedPointer<QColorDialogOptions> options; - - QPointer<QObject> receiverToDisconnectOnClose; - QByteArray memberToDisconnectOnClose; -#ifdef Q_OS_WIN32 - QTimer *updateTimer; - QWindow dummyTransparentWindow; -#endif - -#ifdef Q_DEAD_CODE_FROM_QT4_MAC - void openCocoaColorPanel(const QColor &initial, - QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options); - void closeCocoaColorPanel(); - void releaseCocoaColorPanelDelegate(); - void setCocoaPanelColor(const QColor &color); - - inline void done(int result) { q_func()->done(result); } - inline QColorDialog *colorDialog() { return q_func(); } - - void *delegate; - - static bool sharedColorPanelAvailable; - - void _q_macRunNativeAppModalPanel(); - void mac_nativeDialogModalHelp(); -#endif -private: - virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE; - virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE; -}; - -#endif // QT_NO_COLORDIALOG - -QT_END_NAMESPACE - -#endif // QCOLORDIALOG_P_H diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index 4c3a5497d4..855bae3c9f 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -47,9 +47,10 @@ #include "qpixmap.h" #include "qmetaobject.h" #include "qthread.h" -#include "qqueue.h" #include "qset.h" +#include <queue> + #include <stdio.h> #include <stdlib.h> @@ -68,16 +69,18 @@ public: QCheckBox * again; QTextEdit * errors; QLabel * icon; - QQueue<QPair<QString, QString> > pending; + std::queue<QPair<QString, QString> > pending; QSet<QString> doNotShow; QSet<QString> doNotShowType; QString currentMessage; QString currentType; + bool isMessageToBeShown(const QString &message, const QString &type) const; bool nextPending(); void retranslateStrings(); }; +namespace { class QErrorMessageTextView : public QTextEdit { public: @@ -87,6 +90,7 @@ public: virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; virtual QSize sizeHint() const Q_DECL_OVERRIDE; }; +} // unnamed namespace QSize QErrorMessageTextView::minimumSizeHint() const { @@ -217,29 +221,32 @@ QErrorMessage::QErrorMessage(QWidget * parent) : QDialog(*new QErrorMessagePrivate, parent) { Q_D(QErrorMessage); - QGridLayout * grid = new QGridLayout(this); + d->icon = new QLabel(this); -#ifndef QT_NO_MESSAGEBOX - d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); - d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); -#endif - grid->addWidget(d->icon, 0, 0, Qt::AlignTop); d->errors = new QErrorMessageTextView(this); - grid->addWidget(d->errors, 0, 1); d->again = new QCheckBox(this); - d->again->setChecked(true); - grid->addWidget(d->again, 1, 1, Qt::AlignTop); d->ok = new QPushButton(this); + QGridLayout * grid = new QGridLayout(this); + + connect(d->ok, SIGNAL(clicked()), this, SLOT(accept())); + grid->addWidget(d->icon, 0, 0, Qt::AlignTop); + grid->addWidget(d->errors, 0, 1); + grid->addWidget(d->again, 1, 1, Qt::AlignTop); + grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter); + grid->setColumnStretch(1, 42); + grid->setRowStretch(0, 42); +#ifndef QT_NO_MESSAGEBOX + d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information)); + d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop); +#endif + d->again->setChecked(true); #if defined(Q_OS_WINCE) d->ok->setFixedSize(0,0); #endif - connect(d->ok, SIGNAL(clicked()), this, SLOT(accept())); d->ok->setFocus(); - grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter); - grid->setColumnStretch(1, 42); - grid->setRowStretch(0, 42); + d->retranslateStrings(); } @@ -265,11 +272,13 @@ QErrorMessage::~QErrorMessage() void QErrorMessage::done(int a) { Q_D(QErrorMessage); - if (!d->again->isChecked() && !d->currentMessage.isEmpty() && d->currentType.isEmpty()) { - d->doNotShow.insert(d->currentMessage); - } - if (!d->again->isChecked() && !d->currentType.isEmpty()) { - d->doNotShowType.insert(d->currentType); + if (!d->again->isChecked()) { + if (d->currentType.isEmpty()) { + if (!d->currentMessage.isEmpty()) + d->doNotShow.insert(d->currentMessage); + } else { + d->doNotShowType.insert(d->currentType); + } } d->currentMessage.clear(); d->currentType.clear(); @@ -301,20 +310,27 @@ QErrorMessage * QErrorMessage::qtHandler() /*! \internal */ +bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const +{ + return !message.isEmpty() + && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type)); +} + bool QErrorMessagePrivate::nextPending() { - while (!pending.isEmpty()) { - QPair<QString,QString> pendingMessage = pending.dequeue(); - QString message = pendingMessage.first; - QString type = pendingMessage.second; - if (!message.isEmpty() && ((type.isEmpty() && !doNotShow.contains(message)) || (!type.isEmpty() && !doNotShowType.contains(type)))) { + while (!pending.empty()) { + QPair<QString,QString> &pendingMessage = pending.front(); + QString message = qMove(pendingMessage.first); + QString type = qMove(pendingMessage.second); + pending.pop(); + if (isMessageToBeShown(message, type)) { #ifndef QT_NO_TEXTHTMLPARSER errors->setHtml(message); #else errors->setPlainText(message); #endif - currentMessage = message; - currentType = type; + currentMessage = qMove(message); + currentType = qMove(type); return true; } } @@ -333,12 +349,7 @@ bool QErrorMessagePrivate::nextPending() void QErrorMessage::showMessage(const QString &message) { - Q_D(QErrorMessage); - if (d->doNotShow.contains(message)) - return; - d->pending.enqueue(qMakePair(message,QString())); - if (!isVisible() && d->nextPending()) - show(); + showMessage(message, QString()); } /*! @@ -358,9 +369,9 @@ void QErrorMessage::showMessage(const QString &message) void QErrorMessage::showMessage(const QString &message, const QString &type) { Q_D(QErrorMessage); - if (d->doNotShow.contains(message) && d->doNotShowType.contains(type)) + if (!d->isMessageToBeShown(message, type)) return; - d->pending.push_back(qMakePair(message,type)); + d->pending.push(qMakePair(message, type)); if (!isVisible() && d->nextPending()) show(); } diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h index 1e3554fa36..ffa708ea23 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.h +++ b/src/widgets/graphicsview/qgraphicssceneevent.h @@ -40,7 +40,9 @@ #include <QtCore/qrect.h> #include <QtGui/qpolygon.h> #include <QtCore/qset.h> +#if QT_DEPRECATED_SINCE(5, 5) #include <QtCore/qhash.h> +#endif QT_BEGIN_NAMESPACE diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 822690942e..dcacea4777 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt if (index == -1) return 0; + addChildWidget(to); QLayoutItem *newitem = new QWidgetItem(to); newitem->setAlignment(item->alignment()); QLayoutItem *r = d->replaceAt(index, newitem); if (!r) delete newitem; - else - addChildWidget(to); return r; } diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 8a800ab9d0..51bf6e4684 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -37,7 +37,6 @@ #include <qapplication.h> #include <qdesktopwidget.h> #include <qevent.h> -#include <qhash.h> #include <qlabel.h> #include <qpointer.h> #include <qstyle.h> diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 5fb4695687..1e437c4fb7 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -42,7 +42,6 @@ #include "qscreen.h" #include "qpainter.h" #include "qtimer.h" -#include "qhash.h" #include "qaction.h" #include "qcursor.h" #include "qbitmap.h" diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b2ea83c991..b49fd9b3b6 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -37,7 +37,6 @@ #include "qcursor.h" #include "qdesktopwidget_p.h" #include "qevent.h" -#include "qhash.h" #include "qlayout.h" #include "qmenu.h" #include "qmetaobject.h" @@ -100,6 +99,7 @@ #include "qwindowcontainer_p.h" +#include <QtPlatformHeaders/qxcbwindowfunctions.h> // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -704,7 +704,7 @@ void QWidget::setAutoFillBackground(bool enabled) close(). \row \li Top-level windows \li - \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText, + \l windowModified, \l windowTitle, \l windowIcon, \l isActiveWindow, activateWindow(), \l minimized, showMinimized(), \l maximized, showMaximized(), \l fullScreen, showFullScreen(), showNormal(). @@ -5939,7 +5939,7 @@ void QWidget::unsetLocale() window title, if set. This is done by the QPA plugin, so it is shown to the user, but isn't part of the windowTitle string. - \sa windowIcon, windowIconText, windowModified, windowFilePath + \sa windowIcon, windowModified, windowFilePath */ QString QWidget::windowTitle() const { @@ -6034,7 +6034,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title) void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) { - Q_UNUSED(iconText); + Q_Q(QWidget); + // ### The QWidget property is deprecated, but the XCB window function is not. + // It should remain available for the rare application that needs it. + if (QWindow *window = q->windowHandle()) + QXcbWindowFunctions::setWmWindowIconText(window, iconText); } /*! @@ -6044,6 +6048,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) new \a iconText as an argument. \since 5.2 + \obsolete + + This signal is deprecated. */ void QWidget::setWindowIconText(const QString &iconText) @@ -6094,7 +6101,7 @@ void QWidget::setWindowTitle(const QString &title) has been set, windowIcon() returns the application icon (QApplication::windowIcon()). - \sa windowIconText, windowTitle + \sa windowTitle */ QIcon QWidget::windowIcon() const { @@ -6110,8 +6117,15 @@ QIcon QWidget::windowIcon() const void QWidgetPrivate::setWindowIcon_helper() { + Q_Q(QWidget); QEvent e(QEvent::WindowIconChange); - QApplication::sendEvent(q_func(), &e); + + // Do not send the event if the widget is a top level. + // In that case, setWindowIcon_sys does it, and event propagation from + // QWidgetWindow to the top level QWidget ensures that the event reaches + // the top level anyhow + if (!q->windowHandle()) + QApplication::sendEvent(q, &e); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(children.at(i)); if (w && !w->isWindow()) @@ -6154,10 +6168,15 @@ void QWidgetPrivate::setWindowIcon_sys() /*! \property QWidget::windowIconText - \brief the widget's icon text + \brief the text to be displayed on the icon of a minimized window This property only makes sense for windows. If no icon - text has been set, this functions returns an empty string. + text has been set, this accessor returns an empty string. + It is only implemented on the X11 platform, and only certain + window managers use this window property. + + \obsolete + This property is deprecated. \sa windowIcon, windowTitle */ @@ -12796,6 +12815,65 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast<QWidget*>(newParent)); } +#ifndef QT_NO_DEBUG_STREAM + +static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) +{ + const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount); + const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute")); + debug << ", attributes=["; + int count = 0; + for (int a = 0; a < Qt::WA_AttributeCount; ++a) { + if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) { + if (count++) + debug << ','; + debug << me.valueToKey(a); + } + } + debug << ']'; +} + +QDebug operator<<(QDebug debug, const QWidget *widget) +{ + const QDebugStateSaver saver(debug); + debug.nospace(); + if (widget) { + debug << widget->metaObject()->className() << '(' << (void *)widget; + if (!widget->objectName().isEmpty()) + debug << ", name=" << widget->objectName(); + if (debug.verbosity() > 2) { + const QRect geometry = widget->geometry(); + const QRect frameGeometry = widget->frameGeometry(); + if (widget->isVisible()) + debug << ", visible"; + if (!widget->isEnabled()) + debug << ", disabled"; + debug << ", states=" << widget->windowState() + << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags(); + formatWidgetAttributes(debug, widget); + if (widget->isWindow()) + debug << ", window"; + debug << ", " << geometry.width() << 'x' << geometry.height() + << forcesign << geometry.x() << geometry.y() << noforcesign; + if (frameGeometry != geometry) { + const QMargins margins(geometry.x() - frameGeometry.x(), + geometry.y() - frameGeometry.y(), + frameGeometry.right() - geometry.right(), + frameGeometry.bottom() - geometry.bottom()); + debug << ", margins=" << margins; + } + debug << ", devicePixelRatio=" << widget->devicePixelRatio(); + if (const WId wid = widget->internalWinId()) + debug << ", winId=0x" << hex << wid << dec; + } + debug << ')'; + } else { + debug << "QWidget(0x0)"; + } + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index c3913e9d45..782c892a32 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -89,6 +89,9 @@ class QGraphicsEffect; class QRasterWindowSurface; class QUnifiedToolbarSurface; class QPixmap; +#ifndef QT_NO_DEBUG_STREAM +class QDebug; +#endif class QWidgetData { @@ -165,7 +168,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow) Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow) - Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) + Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow) Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow) #ifndef QT_NO_TOOLTIP @@ -858,6 +861,10 @@ inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const #define QWIDGETSIZE_MAX ((1<<24)-1) +#ifndef QT_NO_DEBUG_STREAM +Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *); +#endif + QT_END_NAMESPACE #endif // QWIDGET_H diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ba8c16e838..efe7d9415b 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -161,7 +161,7 @@ bool QWidgetWindow::event(QEvent *event) if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set - return m_widget->event(event); + return QCoreApplication::sendEvent(m_widget, event); } switch (event->type()) { @@ -303,7 +303,7 @@ bool QWidgetWindow::event(QEvent *event) break; } - if (m_widget->event(event) && event->type() != QEvent::Timer) + if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer) return true; return QWindow::event(event); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 6d722c680b..f87542ffa8 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -40,7 +40,6 @@ #include <qpushbutton.h> #include <qpainter.h> #include <qdir.h> -#include <qhash.h> #include <qstyleoption.h> #include <qapplication.h> #include <qmainwindow.h> diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 4993457b32..86b5632d2e 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2393,6 +2393,13 @@ static bool unstylable(const QWidget *w) return true; } #endif + +#ifndef QT_NO_TABBAR + if (w->metaObject() == &QWidget::staticMetaObject + && qobject_cast<const QTabBar*>(w->parentWidget())) + return true; // The moving tab of a QTabBar +#endif + return false; } diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index f1a4a390e1..3d1206b369 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -50,7 +50,6 @@ #ifndef QT_NO_STYLE_WINDOWS #include <qlist.h> -#include <qhash.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 2b153d53d9..2752c56c65 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -52,6 +52,8 @@ #include <private/qguiapplication_p.h> #include <qdebug.h> +#include <QtPlatformHeaders/qxcbwindowfunctions.h> +#include <QtPlatformHeaders/qxcbintegrationfunctions.h> #ifndef QT_NO_SYSTEMTRAYICON QT_BEGIN_NAMESPACE @@ -112,17 +114,11 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) // window to ParentRelative (so that it inherits the background of its X11 parent window), call // xcb_clear_region before painting (so that the inherited background is visible) and then grab // the just-drawn background from the X11 server. - bool hasAlphaChannel = false; - QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "systrayVisualHasAlphaChannel", Qt::DirectConnection, - Q_RETURN_ARG(bool, hasAlphaChannel)); + bool hasAlphaChannel = QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannel(); setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel); if (!hasAlphaChannel) { createWinId(); - QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "setParentRelativeBackPixmap", Qt::DirectConnection, - Q_ARG(const QWindow *, windowHandle()) - ); + QXcbWindowFunctions::setParentRelativeBackPixmap(windowHandle()); // XXX: This is actually required, but breaks things ("QWidget::paintEngine: Should no // longer be called"). Why is this needed? When the widget is drawn, we use tricks to grab @@ -143,15 +139,9 @@ bool QSystemTrayIconSys::addToTray() createWinId(); setMouseTracking(true); - bool requestResult = false; - if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "requestSystemTrayWindowDock", Qt::DirectConnection, - Q_RETURN_ARG(bool, requestResult), - Q_ARG(const QWindow *, windowHandle())) - || !requestResult) { - qWarning("requestSystemTrayWindowDock failed."); + if (!QXcbWindowFunctions::requestSystemTrayWindowDock(windowHandle())) return false; - } + if (!background.isNull()) background = QPixmap(); show(); @@ -171,15 +161,7 @@ void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *) QRect QSystemTrayIconSys::globalGeometry() const { - QRect result; - if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(), - "systemTrayWindowGlobalGeometry", Qt::DirectConnection, - Q_RETURN_ARG(QRect, result), - Q_ARG(const QWindow *, windowHandle())) - || !result.isValid()) { - qWarning("systemTrayWindowGlobalGeometry failed."); - } - return result; + return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle()); } void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev) diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 3fdfdcc22f..b69b94f3b9 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -57,7 +57,6 @@ #include "QtGui/qpainter.h" #include "QtWidgets/qstyle.h" #include "QtWidgets/qstyleoption.h" -#include "QtCore/qhash.h" #include "QtCore/qpair.h" #include "QtCore/qtimer.h" #include "private/qwidget_p.h" diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index e71b9616fc..af0f2515fe 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2244,6 +2244,22 @@ QRect QDockAreaLayoutInfo::tabContentRect() const return result; } + +int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const +{ + Q_ASSERT(tabbed && tabBar); + quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex)); + for (int i = 0; i < item_list.count(); ++i) { + if (tabId(item_list.at(i)) == data) + return i; + } + return -1; +} + +void QDockAreaLayoutInfo::moveTab(int from, int to) +{ + item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to)); +} #endif // QT_NO_TABBAR /****************************************************************************** diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 7c67466c7b..64fae7ebf6 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -208,6 +208,9 @@ public: QSize tabBarSizeHint() const; QSet<QTabBar*> usedTabBars() const; + + int tabIndexToListIndex(int) const; + void moveTab(int from, int to); #endif // QT_NO_TABBAR }; diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 046666f571..3620aa04fc 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1280,7 +1280,9 @@ QTabBar *QMainWindowLayout::getTabBar() result->setDrawBase(true); result->setElideMode(Qt::ElideRight); result->setDocumentMode(_documentMode); + result->setMovable(true); connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged())); + connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved); } usedTabBars.insert(result); @@ -1316,6 +1318,16 @@ void QMainWindowLayout::tabChanged() if (QWidget *w = centralWidget()) w->raise(); } + +void QMainWindowLayout::tabMoved(int from, int to) +{ + QTabBar *tb = qobject_cast<QTabBar*>(sender()); + Q_ASSERT(tb); + QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb); + Q_ASSERT(info); + + info->moveTab(from, to); +} #endif // QT_NO_TABBAR bool QMainWindowLayout::startSeparatorMove(const QPoint &pos) diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 9f84ee95db..8ccb4d303f 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -286,6 +286,7 @@ private Q_SLOTS: #ifndef QT_NO_DOCKWIDGET #ifndef QT_NO_TABBAR void tabChanged(); + void tabMoved(int from, int to); #endif #endif private: |