diff options
Diffstat (limited to 'src/widgets/widgets')
128 files changed, 564 insertions, 1516 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 1a5b8db33c..c0bd8bce5a 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -1058,7 +1058,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Up: next = false; - // fall through + Q_FALLTHROUGH(); case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Down: { @@ -1100,6 +1100,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) break; } default: +#ifndef QT_NO_SHORTCUT if (e->matches(QKeySequence::Cancel) && d->down) { setDown(false); repaint(); //flush paint event before invoking potentially expensive operation @@ -1107,6 +1108,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) d->emitReleased(); return; } +#endif e->ignore(); } } diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index bd18c394f2..7bf0e0b9d6 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTBUTTON_H #define QABSTRACTBUTTON_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qicon.h> #include <QtGui/qkeysequence.h> #include <QtWidgets/qwidget.h> diff --git a/src/widgets/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h index f65a0527fc..8f67c0d367 100644 --- a/src/widgets/widgets/qabstractbutton_p.h +++ b/src/widgets/widgets/qabstractbutton_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qabstractbutton.h" #include "QtCore/qbasictimer.h" diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 1482b990a6..5b31e4467f 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -60,7 +60,7 @@ #include <private/qapplication_p.h> -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -168,7 +168,7 @@ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored), viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), xoffset(0), yoffset(0), viewportFilter(0) -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN , singleFingerPanEnabled(false) #endif { @@ -321,7 +321,7 @@ void QAbstractScrollAreaPrivate::init() #endif } -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) { singleFingerPanEnabled = on; @@ -329,7 +329,7 @@ void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) if (dd) dd->winSetupGestures(); } -#endif // Q_DEAD_CODE_FROM_QT4_WIN +#endif void QAbstractScrollAreaPrivate::layoutChildren() { @@ -350,7 +350,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, hbar); const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, vbar); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC QWidget * const window = q->window(); // Use small scroll bars for tool windows, to match the native size grip. @@ -393,7 +393,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // If the scroll bars are at the very right and bottom of the window we // move their positions to be aligned with the size grip. -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC // Check if a native sizegrip is present. bool hasMacReverseSizeGrip = false; bool hasMacSizeGrip = false; @@ -446,7 +446,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() if (hasCornerWidget && ((needv && vscrollOverlap == 0) || (needh && hscrollOverlap == 0))) cornerOffset = extPoint; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC // Also move the scroll bars if they are covered by the native Mac size grip. if (hasMacSizeGrip) cornerOffset = extPoint; @@ -463,7 +463,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() else cornerPaintingRect = QRect(); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (hasMacReverseSizeGrip) reverseCornerPaintingRect = QRect(controlsRect.bottomRight() + QPoint(1, 1) - extPoint, extSize); else @@ -488,14 +488,11 @@ void QAbstractScrollAreaPrivate::layoutChildren() if (needh) { QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (hasMacReverseSizeGrip) horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0); #endif if (!hasCornerWidget && htransient) -#ifdef Q_OS_MAC - if (QSysInfo::macVersion() >= QSysInfo::MV_10_8) -#endif horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0); scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect)); scrollBarContainers[Qt::Horizontal]->raise(); @@ -504,9 +501,6 @@ void QAbstractScrollAreaPrivate::layoutChildren() if (needv) { QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1)); if (!hasCornerWidget && vtransient) -#ifdef Q_OS_MAC - if (QSysInfo::macVersion() >= QSysInfo::MV_10_8) -#endif verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y()); scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect)); scrollBarContainers[Qt::Vertical]->raise(); @@ -608,7 +602,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget) d->viewport->setParent(this); d->viewport->setFocusProxy(this); d->viewport->installEventFilter(d->viewportFilter.data()); -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC #ifndef QT_NO_GESTURES d->viewport->grabGesture(Qt::PanGesture); #endif @@ -1035,7 +1029,7 @@ bool QAbstractScrollArea::event(QEvent *e) QPainter p(this); style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this); } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (d->reverseCornerPaintingRect.isValid()) { option.rect = d->reverseCornerPaintingRect; QPainter p(this); @@ -1114,7 +1108,7 @@ bool QAbstractScrollArea::event(QEvent *e) hBar->setValue(se->contentPos().x()); vBar->setValue(se->contentPos().y()); -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN typedef BOOL (*PtrBeginPanningFeedback)(HWND); typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL); typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL); @@ -1316,7 +1310,7 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e) void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); - if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal) + if (e->orientation() == Qt::Horizontal) QApplication::sendEvent(d->hbar, e); else QApplication::sendEvent(d->vbar, e); @@ -1538,13 +1532,13 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y) void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() { layoutChildren(); -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN // Need to re-subscribe to gestures as the content changes to make sure we // enable/disable panning when needed. QWidgetPrivate *dd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(viewport)); if (dd) dd->winSetupGestures(); -#endif // Q_DEAD_CODE_FROM_QT4_WIN +#endif } QPoint QAbstractScrollAreaPrivate::contentsOffset() const diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index 9f8ea27408..476914b781 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTSCROLLAREA_H #define QABSTRACTSCROLLAREA_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h index 5239f72ec4..a3af77b11b 100644 --- a/src/widgets/widgets/qabstractscrollarea_p.h +++ b/src/widgets/widgets/qabstractscrollarea_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qframe_p.h" #include "qabstractscrollarea.h" @@ -84,7 +85,7 @@ public: QWidget *viewport; QWidget *cornerWidget; QRect cornerPaintingRect; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC QRect reverseCornerPaintingRect; #endif int left, top, right, bottom; // viewport margin @@ -111,7 +112,7 @@ public: { return q_func()->viewportEvent(event); } QScopedPointer<QObject> viewportFilter; -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN bool singleFingerPanEnabled; void setSingleFingerPanEnabled(bool on = true); #endif diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 4221ff40ef..cc6a407bf8 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -721,7 +721,7 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb offset_accumulated = 0; offset_accumulated += stepsToScrollF; -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC // Don't scroll more than one page in any case: stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); #else @@ -933,7 +933,7 @@ void QAbstractSlider::changeEvent(QEvent *ev) d->repeatActionTimer.stop(); setSliderDown(false); } - // fall through... + Q_FALLTHROUGH(); default: QWidget::changeEvent(ev); } diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h index 4f8d12fd49..86d6830f10 100644 --- a/src/widgets/widgets/qabstractslider.h +++ b/src/widgets/widgets/qabstractslider.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTSLIDER_H #define QABSTRACTSLIDER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h index e78cf7a27c..600616061a 100644 --- a/src/widgets/widgets/qabstractslider_p.h +++ b/src/widgets/widgets/qabstractslider_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtCore/qbasictimer.h" #include "QtCore/qelapsedtimer.h" #include "private/qwidget_p.h" diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index 8d31c1f503..d93489e663 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTSPINBOX_H #define QABSTRACTSPINBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtGui/qvalidator.h> diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index a54659ecaa..47ca10a183 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qabstractspinbox.h" #ifndef QT_NO_SPINBOX diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index 58da20540f..ff931b1ee0 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -40,6 +40,7 @@ #ifndef QBUTTONGROUP_H #define QBUTTONGROUP_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qbuttongroup_p.h b/src/widgets/widgets/qbuttongroup_p.h index 95a72eb4fd..b94dd170b4 100644 --- a/src/widgets/widgets/qbuttongroup_p.h +++ b/src/widgets/widgets/qbuttongroup_p.h @@ -45,6 +45,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/qbuttongroup.h> #ifndef QT_NO_BUTTONGROUP diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index a8c031ac1b..b0ded70c4a 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -1578,7 +1578,7 @@ protected: { Q_UNUSED(e) -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC QStyleOptionToolButton opt; initStyleOption(&opt); diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h index ef473cba94..7780065117 100644 --- a/src/widgets/widgets/qcalendarwidget.h +++ b/src/widgets/widgets/qcalendarwidget.h @@ -40,6 +40,7 @@ #ifndef QCALENDARWIDGET_H #define QCALENDARWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtCore/qdatetime.h> diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp index 19369d6cb1..d4ba17b08e 100644 --- a/src/widgets/widgets/qcheckbox.cpp +++ b/src/widgets/widgets/qcheckbox.cpp @@ -204,10 +204,8 @@ QCheckBox::QCheckBox(QWidget *parent) */ QCheckBox::QCheckBox(const QString &text, QWidget *parent) - : QAbstractButton (*new QCheckBoxPrivate, parent) + : QCheckBox(parent) { - Q_D(QCheckBox); - d->init(); setText(text); } diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h index 70aac38488..22f26b6667 100644 --- a/src/widgets/widgets/qcheckbox.h +++ b/src/widgets/widgets/qcheckbox.h @@ -40,6 +40,7 @@ #ifndef QCHECKBOX_H #define QCHECKBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index e255a95ea2..52e7962109 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -66,7 +66,7 @@ #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <qdebug.h> -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) #include <private/qcore_mac_p.h> #include <private/qmacstyle_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> @@ -415,7 +415,7 @@ void QComboBoxPrivateContainer::leaveEvent(QEvent *) { // On Mac using the Mac style we want to clear the selection // when the mouse moves outside the popup. -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC QStyleOptionComboBox opt = comboStyleOption(); if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) view->clearSelection(); @@ -676,7 +676,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) case Qt::Key_Down: if (!(keyEvent->modifiers() & Qt::AltModifier)) break; - // fall through + Q_FALLTHROUGH(); case Qt::Key_F4: combo->hidePopup(); return true; @@ -3148,7 +3148,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e) return; } else if (e->modifiers() & Qt::ControlModifier) break; // pass to line edit for auto completion - // fall through + Q_FALLTHROUGH(); case Qt::Key_PageDown: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 095a06fe31..2da1ceb047 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -40,6 +40,7 @@ #ifndef QCOMBOBOX_H #define QCOMBOBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtWidgets/qabstractitemdelegate.h> #include <QtCore/qabstractitemmodel.h> diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 3c92b09e9a..7ca077abf9 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qcombobox.h" #ifndef QT_NO_COMBOBOX diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp index 2ec8b1c41a..b6ec2a8d31 100644 --- a/src/widgets/widgets/qcommandlinkbutton.cpp +++ b/src/widgets/widgets/qcommandlinkbutton.cpp @@ -281,23 +281,18 @@ QCommandLinkButton::QCommandLinkButton(QWidget *parent) */ QCommandLinkButton::QCommandLinkButton(const QString &text, QWidget *parent) - : QPushButton(*new QCommandLinkButtonPrivate, parent) + : QCommandLinkButton(parent) { - Q_D(QCommandLinkButton); setText(text); - d->init(); } /*! Constructs a command link with a \a text, a \a description, and a \a parent. */ QCommandLinkButton::QCommandLinkButton(const QString &text, const QString &description, QWidget *parent) - : QPushButton(*new QCommandLinkButtonPrivate, parent) + : QCommandLinkButton(text, parent) { - Q_D(QCommandLinkButton); - setText(text); setDescription(description); - d->init(); } /*! diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h index c794b60506..4f81651ce4 100644 --- a/src/widgets/widgets/qcommandlinkbutton.h +++ b/src/widgets/widgets/qcommandlinkbutton.h @@ -40,6 +40,7 @@ #ifndef QCOMMANDLINKBUTTON_H #define QCOMMANDLINKBUTTON_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qpushbutton.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 7fe569a042..c5eab55a53 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1125,7 +1125,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event) select = false; break; } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC else #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled()) diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index f050061dea..c261ce369b 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -40,6 +40,7 @@ #ifndef QDATETIMEEDIT_H #define QDATETIMEEDIT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qdatetime.h> #include <QtCore/qvariant.h> #include <QtWidgets/qabstractspinbox.h> diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index be7bc213a2..6889bda041 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qcombobox.h" #include "QtWidgets/qcalendarwidget.h" #include "QtWidgets/qspinbox.h" diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h index 7884d9fe27..3629ebf8f6 100644 --- a/src/widgets/widgets/qdial.h +++ b/src/widgets/widgets/qdial.h @@ -41,6 +41,7 @@ #ifndef QDIAL_H #define QDIAL_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractslider.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 4ed326576c..23158cf82f 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -411,7 +411,7 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut else addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC // Since mnemonics is off by default on Mac, we add a Cmd-D // shortcut here to e.g. make the "Don't Save" button work nativly: if (sbutton == QDialogButtonBox::Discard) @@ -462,9 +462,8 @@ void QDialogButtonBoxPrivate::retranslateStrings() \sa orientation, addButton() */ QDialogButtonBox::QDialogButtonBox(QWidget *parent) - : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0) + : QDialogButtonBox(Qt::Horizontal, parent) { - d_func()->initLayout(); } /*! @@ -487,10 +486,8 @@ QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent) \sa orientation, addButton() */ QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent) - : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0) + : QDialogButtonBox(buttons, Qt::Horizontal, parent) { - d_func()->initLayout(); - d_func()->createStandardButtons(buttons); } /*! @@ -501,9 +498,8 @@ QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent) */ QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation, QWidget *parent) - : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0) + : QDialogButtonBox(orientation, parent) { - d_func()->initLayout(); d_func()->createStandardButtons(buttons); } diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h index dfec453c67..699547c32f 100644 --- a/src/widgets/widgets/qdialogbuttonbox.h +++ b/src/widgets/widgets/qdialogbuttonbox.h @@ -40,6 +40,7 @@ #ifndef QDIALOGBUTTONBOX_H #define QDIALOGBUTTONBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 50be36ae93..63f8172bf6 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1493,8 +1493,10 @@ bool QDockAreaLayoutInfo::hasFixedSize() const return perp(o, minimumSize()) == perp(o, maximumSize()); } - -void QDockAreaLayoutInfo::apply(bool animate) +/*! \internal + Applies the layout and returns the activated QDockWidget or nullptr. + */ +QDockWidget *QDockAreaLayoutInfo::apply(bool animate) { QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator; @@ -1533,6 +1535,8 @@ void QDockAreaLayoutInfo::apply(bool animate) } #endif // QT_NO_TABBAR + QDockWidget *activated = nullptr; + for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; @@ -1561,6 +1565,7 @@ void QDockAreaLayoutInfo::apply(bool animate) } else if (r.isValid() && (geo.right() < 0 || geo.bottom() < 0)) { emit dw->visibilityChanged(true); + activated = dw; } } } @@ -1568,6 +1573,8 @@ void QDockAreaLayoutInfo::apply(bool animate) if (*sep == 1) updateSeparatorWidgets(); #endif //QT_NO_TABBAR + + return activated; } static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over) @@ -1928,7 +1935,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> QDockAreaLayoutItem item(new QDockWidgetItem(widget)); if (flags & StateFlagFloating) { bool drawer = false; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support +#if 0 // Used to be included in Qt4 for Q_WS_MAC // drawer support extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp drawer = qt_mac_is_macdrawer(widget); @@ -1943,7 +1950,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> int x, y, w, h; stream >> x >> y >> w >> h; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support +#if 0 // Used to be included in Qt4 for Q_WS_MAC // drawer support if (drawer) { mainWindow->window()->createWinId(); widget->window()->createWinId(); @@ -2043,7 +2050,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const } j++; -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC sepWidget->raise(); #endif QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); @@ -3078,7 +3085,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) dockWidget->d_func()->setWindowState(true, true, r); } dockWidget->setVisible(!placeHolder->hidden); -#ifdef Q_DEAD_CODE_FROM_QT4_X11 +#if 0 // Used to be included in Qt4 for Q_WS_X11 if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag dockWidget->d_func()->setWindowState(true); #endif @@ -3309,7 +3316,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const } j++; -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC sepWidget->raise(); #endif QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index bc9d418783..f22a3d2de2 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtCore/qrect.h" #include "QtCore/qpair.h" #include "QtCore/qlist.h" @@ -174,7 +175,7 @@ public: QList<int> indexOf(QWidget *widget) const; QList<int> indexOfPlaceHolder(const QString &objectName) const; - void apply(bool animate); + QDockWidget *apply(bool animate); void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip, const QPoint &mouse) const; diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index aec798e2e4..1df7259aba 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -58,7 +58,7 @@ #include "qdockwidget_p.h" #include "qmainwindowlayout_p.h" -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <private/qmacstyle_mac_p.h> @@ -230,7 +230,7 @@ bool QDockWidgetLayout::nativeWindowDeco() const */ bool QDockWidgetLayout::wmSupportsNativeWindowDeco() { -#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID) +#if defined(Q_OS_ANDROID) return false; #else static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive); @@ -916,7 +916,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { startDrag(); -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN grabMouseWhileInWindow(); #else q->grabMouse(); @@ -966,7 +966,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) QWidget *tl = q->topLevelWidget(); QRect geo = tl->geometry(); QRect titleRect = tl->frameGeometry(); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { titleRect.setTop(geo.top()); titleRect.setBottom(geo.bottom()); @@ -1225,10 +1225,8 @@ QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags) \sa setWindowTitle() */ QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QWidget(*new QDockWidgetPrivate, parent, flags) + : QDockWidget(parent, flags) { - Q_D(QDockWidget); - d->init(); setWindowTitle(title); } @@ -1510,7 +1508,7 @@ bool QDockWidget::event(QEvent *event) if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event))) return true; break; -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN case QEvent::Leave: if (d->state != 0 && d->state->dragging && !d->state->nca) { // This is a workaround for loosing the mouse on Vista. diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index e0aaf54d0e..7b3f8d0ddb 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -40,6 +40,7 @@ #ifndef QDYNAMICDOCKWIDGET_H #define QDYNAMICDOCKWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 765747b101..94a3ad3b34 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qstyleoption.h" #include "private/qwidget_p.h" #include "QtWidgets/qboxlayout.h" diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index a2ba50695a..ecd85c2ca7 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -110,7 +110,7 @@ QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f) QAlphaWidget::~QAlphaWidget() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) // Restore user-defined opacity value if (widget) widget->setWindowOpacity(1); @@ -144,7 +144,7 @@ void QAlphaWidget::run(int time) checkTime.start(); showWidget = true; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) qApp->installEventFilter(this); widget->setWindowOpacity(0.0); widget->show(); @@ -202,10 +202,13 @@ bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) render(); break; case QEvent::KeyPress: { +#ifndef QT_NO_SHORTCUT QKeyEvent *ke = (QKeyEvent*)e; if (ke->matches(QKeySequence::Cancel)) { showWidget = false; - } else { + } else +#endif + { duration = 0; } render(); @@ -251,7 +254,7 @@ void QAlphaWidget::render() else alpha = 1; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) if (alpha >= 1 || !showWidget) { anim.stop(); qApp->removeEventFilter(this); @@ -268,10 +271,6 @@ void QAlphaWidget::render() if (widget) { if (!showWidget) { -#ifdef Q_OS_WIN - setEnabled(true); - setFocus(); -#endif // Q_OS_WIN widget->hide(); } else { //Since we are faking the visibility of the widget @@ -288,7 +287,7 @@ void QAlphaWidget::render() pm = QPixmap::fromImage(mixedImage); repaint(); } -#endif // defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#endif // defined(Q_OS_WIN) } /* diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h index a1b2032e05..a1fc6d345d 100644 --- a/src/widgets/widgets/qfocusframe.h +++ b/src/widgets/widgets/qfocusframe.h @@ -40,6 +40,7 @@ #ifndef QFOCUSFRAME_H #define QFOCUSFRAME_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h index 0db077cd87..c409d33fef 100644 --- a/src/widgets/widgets/qfontcombobox.h +++ b/src/widgets/widgets/qfontcombobox.h @@ -40,6 +40,7 @@ #ifndef QFONTCOMBOBOX_H #define QFONTCOMBOBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qcombobox.h> #include <QtGui/qfontdatabase.h> diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h index e38ec60d42..986915a28f 100644 --- a/src/widgets/widgets/qframe.h +++ b/src/widgets/widgets/qframe.h @@ -40,6 +40,7 @@ #ifndef QFRAME_H #define QFRAME_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h index 54d2ba869d..e3c101e87c 100644 --- a/src/widgets/widgets/qframe_p.h +++ b/src/widgets/widgets/qframe_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qwidget_p.h" #include "qframe.h" diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 5bdd6f20e6..a9b32ae065 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -194,10 +194,8 @@ QGroupBox::QGroupBox(QWidget *parent) */ QGroupBox::QGroupBox(const QString &title, QWidget *parent) - : QWidget(*new QGroupBoxPrivate, parent, 0) + : QGroupBox(parent) { - Q_D(QGroupBox); - d->init(); setTitle(title); } diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h index 0bff3aa6f9..a132d48e16 100644 --- a/src/widgets/widgets/qgroupbox.h +++ b/src/widgets/widgets/qgroupbox.h @@ -40,6 +40,7 @@ #ifndef QGROUPBOX_H #define QGROUPBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index f8a3be366e..2fbc42330d 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -138,21 +138,17 @@ void QKeySequenceEditPrivate::finishEditing() /*! Constructs a QKeySequenceEdit widget with the given \a parent. */ -QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) : - QWidget(*new QKeySequenceEditPrivate, parent, 0) +QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) + : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, 0) { - Q_D(QKeySequenceEdit); - d->init(); } /*! Constructs a QKeySequenceEdit widget with the given \a keySequence and \a parent. */ -QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) : - QWidget(*new QKeySequenceEditPrivate, parent, 0) +QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) + : QKeySequenceEdit(parent) { - Q_D(QKeySequenceEdit); - d->init(); setKeySequence(keySequence); } diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h index 85a2177d32..81339a9852 100644 --- a/src/widgets/widgets/qkeysequenceedit.h +++ b/src/widgets/widgets/qkeysequenceedit.h @@ -41,6 +41,7 @@ #ifndef QKEYSEQUENCEEDIT_H #define QKEYSEQUENCEEDIT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index a85530645c..67e60b4032 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -52,6 +52,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qkeysequenceedit.h" #include <private/qwidget_p.h> diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 5db1013fd2..76713d9880 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -233,10 +233,8 @@ QLabel::QLabel(QWidget *parent, Qt::WindowFlags f) \sa setText(), setAlignment(), setFrameStyle(), setIndent() */ QLabel::QLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) - : QFrame(*new QLabelPrivate(), parent, f) + : QLabel(parent, f) { - Q_D(QLabel); - d->init(); setText(text); } diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index 46a2ce8ee4..1f76937a63 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -40,6 +40,7 @@ #ifndef QLABEL_H #define QLABEL_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h index dce9ba7168..d13c05fc99 100644 --- a/src/widgets/widgets/qlabel_p.h +++ b/src/widgets/widgets/qlabel_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qlabel.h" #include "private/qtextdocumentlayout_p.h" diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 543a7aee11..aa052ef5cb 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -188,8 +188,8 @@ static QString int2string(int num, int base, int ndigits, bool *oflow) } while (n != 0); len = ndigits - len; if (len > 0) - s.fill(QLatin1Char(' '), len); - s += QString::fromLatin1(p); + s += QString(len, QLatin1Char(' ')); + s += QLatin1String(p); } break; } @@ -338,11 +338,8 @@ static const char *getSegments(char ch) // gets list of segments f */ QLCDNumber::QLCDNumber(QWidget *parent) - : QFrame(*new QLCDNumberPrivate, parent) + : QLCDNumber(5, parent) { - Q_D(QLCDNumber); - d->ndigits = 5; - d->init(); } diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h index 1169862193..33669fa900 100644 --- a/src/widgets/widgets/qlcdnumber.h +++ b/src/widgets/widgets/qlcdnumber.h @@ -40,6 +40,7 @@ #ifndef QLCDNUMBER_H #define QLCDNUMBER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 56965923b7..dd5f5325b1 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp #endif @@ -260,10 +260,8 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const \sa setText(), setMaxLength() */ QLineEdit::QLineEdit(QWidget* parent) - : QWidget(*new QLineEditPrivate, parent,0) + : QLineEdit(QString(), parent) { - Q_D(QLineEdit); - d->init(QString()); } /*! @@ -575,7 +573,7 @@ void QLineEdit::setEchoMode(EchoMode mode) setInputMethodHints(imHints); d->control->setEchoMode(mode); update(); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (hasFocus()) qt_mac_secure_keyboard(mode == Password || mode == NoEcho); #endif @@ -1812,7 +1810,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e) if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) d->setCursorVisible(true); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) qt_mac_secure_keyboard(true); #endif @@ -1860,7 +1858,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) if (hasAcceptableInput() || d->control->fixup()) emit editingFinished(); } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) qt_mac_secure_keyboard(false); #endif @@ -1911,13 +1909,19 @@ void QLineEdit::paintEvent(QPaintEvent *) if (d->shouldShowPlaceholderText()) { if (!d->placeholderText.isEmpty()) { + const Qt::LayoutDirection layoutDir = d->placeholderText.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; + const Qt::Alignment alignPhText = QStyle::visualAlignment(layoutDir, QFlag(d->alignment)); QColor col = pal.text().color(); col.setAlpha(128); QPen oldpen = p.pen(); p.setPen(col); - QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); - p.drawText(lineRect, va, elidedText); + Qt::LayoutDirection oldLayoutDir = p.layoutDirection(); + p.setLayoutDirection(layoutDir); + + const QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); + p.drawText(lineRect, alignPhText, elidedText); p.setPen(oldpen); + p.setLayoutDirection(oldLayoutDir); } } diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 12fd998c45..1bdcfaf848 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -40,6 +40,7 @@ #ifndef QLINEEDIT_H #define QLINEEDIT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> #include <QtGui/qtextcursor.h> #include <QtCore/qstring.h> diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index a14cd66398..0a08aefab3 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtWidgets/private/qtwidgetsglobal_p.h> #ifndef QT_NO_LINEEDIT #include "private/qwidget_p.h" diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h index c53cc643cd..d926ef8569 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h @@ -40,6 +40,7 @@ #ifndef QCOCOAVIEWCONTAINER_H #define QCOCOAVIEWCONTAINER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/QWidget> Q_FORWARD_DECLARE_OBJC_CLASS(NSView); diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index 3145ab1553..b4f2b8959e 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -92,20 +92,6 @@ QT_BEGIN_NAMESPACE -namespace { -// TODO use QtMacExtras copy of this function when available. -inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePlatformFunction(const QByteArray &functionName) -{ - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - QPlatformNativeInterface::NativeResourceForIntegrationFunction function = - nativeInterface->nativeResourceFunctionForIntegration(functionName); - if (Q_UNLIKELY(!function)) - qWarning() << "Qt could not resolve function" << functionName - << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()"; - return function; -} -} //namespsace - class QMacCocoaViewContainerPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMacCocoaViewContainer) @@ -136,12 +122,8 @@ QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate() QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *view, QWidget *parent) : QWidget(*new QMacCocoaViewContainerPrivate, parent, 0) { - - if (view) - setCocoaView(view); - - // QMacCocoaViewContainer requires a native window handle. setAttribute(Qt::WA_NativeWindow); + setCocoaView(view); } /*! @@ -172,13 +154,23 @@ void QMacCocoaViewContainer::setCocoaView(NSView *view) [view retain]; d->nsview = view; - // Create window and platformwindow - winId(); - QPlatformWindow *platformWindow = this->windowHandle()->handle(); - - // Set the new view as the content view for the window. - typedef void (*SetWindowContentViewFunction)(QPlatformWindow *window, NSView *nsview); - reinterpret_cast<SetWindowContentViewFunction>(resolvePlatformFunction("setwindowcontentview"))(platformWindow, view); + QWindow *window = windowHandle(); + + // Note that we only set the flag on the QWindow, and not the QWidget. + // These two are not in sync, so from a QWidget standpoint the widget + // is not a Window, and hence will be shown when the parent widget is + // shown, like all QWidget children. + window->setFlags(Qt::ForeignWindow); + window->setProperty("_q_foreignWinId", view ? WId(view) : QVariant()); + + // Destroying the platform window implies hiding the window, and we + // also lose the geometry information that the platform window kept, + // and fall back to the stale QWindow geometry, so we update the two + // based on the widget visibility and geometry, which is up to date. + window->destroy(); + window->setVisible(isVisible()); + window->setGeometry(geometry()); + window->create(); [oldView release]; } diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index 559f15f287..84389f16df 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -40,13 +40,13 @@ #ifndef QMACNATIVEWIDGET_H #define QMACNATIVEWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/QWidget> Q_FORWARD_DECLARE_OBJC_CLASS(NSView); QT_BEGIN_NAMESPACE -class QMacNativeWidgetPrivate; class Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget { Q_OBJECT @@ -59,9 +59,6 @@ public: protected: bool event(QEvent *ev); - -private: - Q_DECLARE_PRIVATE(QMacNativeWidget) }; QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index a8f1a3745d..936bd35187 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -89,8 +89,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration(functionName); if (Q_UNLIKELY(!function)) - qWarning() << "Qt could not resolve function" << functionName - << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()"; + qWarning("Qt could not resolve function %s from " + "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()", + functionName.constData()); return function; } } //namespsace diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index b8472e025e..e32e379198 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -61,7 +61,7 @@ #ifdef Q_OS_OSX #include <qpa/qplatformnativeinterface.h> #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> QT_BEGIN_NAMESPACE @@ -80,7 +80,7 @@ public: #ifdef Q_OS_OSX , useUnifiedToolBar(false) #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC , useHIToolBar(false) , activateUnifiedToolbarAfterFullScreen(false) #endif @@ -95,7 +95,7 @@ public: #ifdef Q_OS_OSX bool useUnifiedToolBar; #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC bool useHIToolBar; bool activateUnifiedToolbarAfterFullScreen; #endif @@ -377,6 +377,18 @@ void QMainWindowPrivate::init() \sa setToolButtonStyle() */ +#ifndef QT_NO_DOCKWIDGET +/*! + \fn void QMainWindow::tabifiedDockWidgetActivated(QDockWidget *dockWidget) + + This signal is emitted when the tabified dock widget is activated by + selecting the tab. The activated dock widget is passed in \a dockWidget. + + \since 5.8 + \sa tabifyDockWidget(), tabifiedDockWidgets() +*/ +#endif + /*! Constructs a QMainWindow with the given \a parent and the specified widget \a flags. @@ -1100,7 +1112,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget d_func()->layout->removeWidget(dockwidget); // in case it was already in here addDockWidget(area, dockwidget, orientation); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support +#if 0 // Used to be included in Qt4 for Q_WS_MAC //drawer support QMacAutoReleasePool pool; extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp if (qt_mac_is_macdrawer(dockwidget)) { @@ -1504,7 +1516,7 @@ bool QMainWindow::event(QEvent *event) if (!d->explicitIconSize) setIconSize(QSize()); break; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC case QEvent::Show: if (unifiedTitleAndToolBarOnMac()) d->layout->syncUnifiedToolbarVisibility(); @@ -1523,7 +1535,7 @@ bool QMainWindow::event(QEvent *event) } } break; -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) case QEvent::CursorChange: // CursorChange events are triggered as mouse moves to new widgets even @@ -1579,7 +1591,7 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) } #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC Q_D(QMainWindow); if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) return; @@ -1614,7 +1626,7 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const #ifdef Q_OS_OSX return d_func()->useUnifiedToolBar; #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); #endif return false; diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index aab1448b8f..9bd7eb1cd8 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -40,6 +40,7 @@ #ifndef QDYNAMICMAINWINDOW_H #define QDYNAMICMAINWINDOW_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtWidgets/qtabwidget.h> @@ -195,6 +196,9 @@ public Q_SLOTS: Q_SIGNALS: void iconSizeChanged(const QSize &iconSize); void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); +#ifndef QT_NO_DOCKWIDGET + void tabifiedDockWidgetActivated(QDockWidget *dockWidget); +#endif protected: #ifndef QT_NO_CONTEXTMENU diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index b138c42ba2..8df197e05c 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -70,7 +70,7 @@ #include <private/qapplication_p.h> #include <private/qlayoutengine_p.h> #include <private/qwidgetresizehandler_p.h> -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC # include <private/qcore_mac_p.h> # include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -1129,11 +1129,11 @@ void QMainWindowLayout::removeToolBar(QToolBar *toolbar) QObject::disconnect(parentWidget(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (usesHIToolBar(toolbar)) { removeFromMacToolbar(toolbar); } else -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif { removeWidget(toolbar); } @@ -1148,7 +1148,7 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, bool) { validateToolBarArea(area); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if ((area == Qt::TopToolBarArea) && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { insertIntoMacToolbar(0, toolbar); @@ -1174,11 +1174,11 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, */ void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar) { -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (usesHIToolBar(before)) { insertIntoMacToolbar(before, toolbar); } else -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif { addChildWidget(toolbar); QLayoutItem * item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar); @@ -1207,7 +1207,7 @@ Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const case QInternal::BottomDock: return Qt::BottomToolBarArea; default: break; } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (pos == QInternal::DockCount) { if (qtoolbarsInUnifiedToolbarList.contains(toolbar)) return Qt::TopToolBarArea; @@ -1230,7 +1230,7 @@ void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar void QMainWindowLayout::toggleToolBarsVisible() { bool updateNonUnifiedParts = true; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { // If we hit this case, someone has pressed the "toolbar button" which will // toggle the unified toolbar visibility, because that's what the user wants. @@ -1698,7 +1698,11 @@ void QMainWindowLayout::tabChanged() QDockAreaLayoutInfo *info = dockInfo(tb); if (info == 0) return; - info->apply(false); + + QDockWidget *activated = info->apply(false); + + if (activated) + emit static_cast<QMainWindow *>(parentWidget())->tabifiedDockWidgetActivated(activated); if (QWidget *w = centralWidget()) w->raise(); @@ -1872,7 +1876,7 @@ QSize QMainWindowLayout::minimumSize() const const QSize sbMin = statusbar ? statusbar->minimumSize() : QSize(0, 0); minSize = QSize(qMax(sbMin.width(), minSize.width()), sbMin.height() + minSize.height()); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC const QSize storedSize = minSize; int minWidth = 0; foreach (QToolBar *toolbar, qtoolbarsInUnifiedToolbarList) { @@ -2182,7 +2186,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay #endif // QT_NO_DOCKWIDGET , widgetAnimator(this) , pluggingWidget(0) -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC , blockVisiblityCheck(false) #endif { @@ -2209,7 +2213,7 @@ QMainWindowLayout::~QMainWindowLayout() layoutState.deleteAllLayoutItems(); layoutState.deleteCentralWidgetItem(); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC cleanUpMacToolbarItems(); #endif @@ -2577,7 +2581,7 @@ bool QMainWindowLayout::restoreState(QDataStream &stream) // HIToolbar. bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const { -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC Q_UNUSED(toolbar); return false; #else diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 4f2e8078d3..6e8b965431 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qmainwindow.h" #ifndef QT_NO_MAINWINDOW @@ -324,7 +325,7 @@ private: #ifndef QT_NO_TABBAR void updateTabBarShapes(); #endif -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *); static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event, void *data); @@ -357,7 +358,7 @@ public: QUnifiedToolbarSurface *unifiedSurface; void updateUnifiedToolbarOffset(); -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif }; #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG_STREAM) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index b42ebe7e48..183f1c2848 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -160,7 +160,7 @@ #include <QApplication> #include <QStyle> -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_STYLE_MAC) #include <private/qmacstyle_mac_p.h> #endif #include <QChildEvent> @@ -2493,7 +2493,7 @@ bool QMdiArea::event(QEvent *event) { Q_D(QMdiArea); switch (event->type()) { -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN // QWidgetPrivate::hide_helper activates another sub-window when closing a // modal dialog on Windows (see activateWindow() inside the ifdef). case QEvent::WindowUnblocked: @@ -2557,7 +2557,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); // Ingore key events without a Ctrl modifier (except for press/release on the modifier itself). -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (!(keyEvent->modifiers() & Qt::MetaModifier) && keyEvent->key() != Qt::Key_Meta) #else if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control) @@ -2576,7 +2576,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) // 3) Ctrl-Shift-Tab (Tab, Tab, ...) -> iterate through all windows in the opposite // direction (activatePreviousSubWindow()) switch (keyEvent->key()) { -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC case Qt::Key_Meta: #else case Qt::Key_Control: @@ -2670,9 +2670,8 @@ void QMdiArea::paintEvent(QPaintEvent *paintEvent) { Q_D(QMdiArea); QPainter painter(d->viewport); - const QVector<QRect> &exposedRects = paintEvent->region().rects(); - for (int i = 0; i < exposedRects.size(); ++i) - painter.fillRect(exposedRects.at(i), d->background); + for (const QRect &exposedRect : paintEvent->region()) + painter.fillRect(exposedRect, d->background); } /*! diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h index b093c4bb4b..44a40948af 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -40,6 +40,7 @@ #ifndef QMDIAREA_H #define QMDIAREA_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractscrollarea.h> #include <QtWidgets/qtabwidget.h> diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index dde7b1a7ce..353144a6ab 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qmdiarea.h" #include "qmdisubwindow.h" diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 610cb1201f..2fff2fc729 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -280,7 +280,7 @@ static inline bool isHoverControl(QStyle::SubControl control) return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel; } -#if defined(Q_DEAD_CODE_FROM_QT4_WIN) +#if 0 // Used to be included in Qt4 for Q_WS_WIN static inline QRgb colorref2qrgb(COLORREF col) { return qRgb(GetRValue(col),GetGValue(col),GetBValue(col)); @@ -412,6 +412,10 @@ bool ControlLabel::event(QEvent *event) { if (event->type() == QEvent::WindowIconChange) updateWindowIcon(); + else if (event->type() == QEvent::StyleChange) { + updateWindowIcon(); + setFixedSize(label.size()); + } #ifndef QT_NO_TOOLTIP else if (event->type() == QEvent::ToolTip) { QStyleOptionTitleBar options; @@ -480,7 +484,8 @@ void ControlLabel::updateWindowIcon() QIcon menuIcon = windowIcon(); if (menuIcon.isNull()) menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget()); - label = menuIcon.pixmap(16, 16); + const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, 0, parentWidget()); + label = menuIcon.pixmap(iconSize); update(); } @@ -556,7 +561,8 @@ QSize ControllerWidget::sizeHint() const ensurePolished(); QStyleOptionComplex opt; initStyleOption(&opt); - QSize size(48, 16); + const int buttonSize = style()->pixelMetric(QStyle::PM_TitleBarButtonSize, &opt, mdiArea); + QSize size(3 * buttonSize, buttonSize); return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea); } @@ -1769,7 +1775,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const if (isChildOfTabbedQMdiArea(q)) return false; -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_OS_WINCE_WM) +#if defined(Q_OS_DARWIN) && !defined(QT_NO_STYLE_MAC) Q_UNUSED(isChildOfQMdiSubWindow); return true; #else @@ -1926,7 +1932,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const QPalette newPalette = q->palette(); bool colorsInitialized = false; -#ifdef Q_DEAD_CODE_FROM_QT4_WIN // ask system properties on windows +#if 0 // Used to be included in Qt4 for Q_WS_WIN // ask system properties on windows #ifndef SPI_GETGRADIENTCAPTIONS #define SPI_GETGRADIENTCAPTIONS 0x1008 #endif @@ -1962,7 +1968,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const newPalette.color(QPalette::Inactive, QPalette::Highlight)); } } -#endif // Q_DEAD_CODE_FROM_QT4_WIN +#endif if (!colorsInitialized) { newPalette.setColor(QPalette::Active, QPalette::Highlight, newPalette.color(QPalette::Active, QPalette::Highlight)); diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index 54ef33befa..e2bb533ddf 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -40,6 +40,7 @@ #ifndef QMDISUBWINDOW_H #define QMDISUBWINDOW_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 4faf421a92..46a8e99d0a 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qmdisubwindow.h" #ifndef QT_NO_MDIAREA diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index eba17783ec..36a8a96b79 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -153,12 +153,19 @@ void QMenuPrivate::init() scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; } - setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu()); sloppyState.initialize(q); delayState.initialize(q); mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q); } +QPlatformMenu *QMenuPrivate::createPlatformMenu() +{ + Q_Q(QMenu); + if (platformMenu.isNull()) + q->setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu()); + return platformMenu.data(); +} + void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) { Q_Q(QMenu); @@ -809,6 +816,93 @@ void QMenuPrivate::updateLayoutDirection() } } +void QMenuPrivate::drawScroller(QPainter *painter, QMenuPrivate::ScrollerTearOffItem::Type type, const QRect &rect) +{ + if (!painter || rect.isEmpty()) + return; + + if (!scroll || !(scroll->scrollFlags & (QMenuPrivate::QMenuScroller::ScrollUp + | QMenuPrivate::QMenuScroller::ScrollDown))) + return; + + Q_Q(QMenu); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(q); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.rect = rect; + menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; + menuOpt.state |= QStyle::State_Enabled; + if (type == QMenuPrivate::ScrollerTearOffItem::ScrollDown) + menuOpt.state |= QStyle::State_DownArrow; + + painter->setClipRect(menuOpt.rect); + q->style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, painter, q); +} + +void QMenuPrivate::drawTearOff(QPainter *painter, const QRect &rect) +{ + if (!painter || rect.isEmpty()) + return; + + if (!tearoff) + return; + + Q_Q(QMenu); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(q); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.rect = rect; + menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; + if (tearoffHighlighted) + menuOpt.state |= QStyle::State_Selected; + + painter->setClipRect(menuOpt.rect); + q->style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, painter, q); +} + +QMenuPrivate::ScrollerTearOffItem::ScrollerTearOffItem(QMenuPrivate::ScrollerTearOffItem::Type type, QMenuPrivate *mPrivate, QWidget *parent, Qt::WindowFlags f) + : QWidget(parent, f), menuPrivate(mPrivate), scrollType(type) +{ + if (parent) + setMouseTracking(parent->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, parent)); +} + +void QMenuPrivate::ScrollerTearOffItem::paintEvent(QPaintEvent *e) +{ + if (!e->rect().intersects(rect())) + return; + + QPainter p(this); + QWidget *parent = parentWidget(); + + //paint scroll up / down arrows + menuPrivate->drawScroller(&p, scrollType, QRect(0, 0, width(), menuPrivate->scrollerHeight())); + //paint the tear off + if (scrollType == QMenuPrivate::ScrollerTearOffItem::ScrollUp) { + QRect rect(0, 0, width(), parent->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, parent)); + if (menuPrivate->scroll && menuPrivate->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) + rect.translate(0, menuPrivate->scrollerHeight()); + menuPrivate->drawTearOff(&p, rect); + } +} + +void QMenuPrivate::ScrollerTearOffItem::updateScrollerRects(const QRect &rect) +{ + if (rect.isEmpty()) + setVisible(false); + else { + setGeometry(rect); + raise(); + setVisible(true); + } +} + /*! Returns the action associated with this menu. @@ -1479,10 +1573,9 @@ QMenu::QMenu(QWidget *parent) \sa title */ QMenu::QMenu(const QString &title, QWidget *parent) - : QWidget(*new QMenuPrivate, parent, Qt::Popup) + : QMenu(parent) { Q_D(QMenu); - d->init(); d->menuAction->setText(title); } @@ -2533,58 +2626,78 @@ void QMenu::paintEvent(QPaintEvent *e) menuOpt.tabWidth = 0; style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this); + //calculate the scroll up / down rect + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + QRect scrollUpRect, scrollDownRect; + if (d->scroll) { + if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) + scrollUpRect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight()); + + if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) + scrollDownRect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2), + d->scrollerHeight()); + } + + //calculate the tear off rect + QRect tearOffRect; + if (d->tearoff) { + tearOffRect.setRect(fw, fw, width() - (fw * 2), + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) + tearOffRect.translate(0, d->scrollerHeight()); + } + //draw the items that need updating.. + QRect scrollUpTearOffRect = scrollUpRect.united(tearOffRect); for (int i = 0; i < d->actions.count(); ++i) { QAction *action = d->actions.at(i); - QRect adjustedActionRect = d->actionRects.at(i); - if (!e->rect().intersects(adjustedActionRect) + QRect actionRect = d->actionRects.at(i); + if (!e->rect().intersects(actionRect) || d->widgetItems.value(action)) continue; //set the clip region to be extra safe (and adjust for the scrollers) + emptyArea -= QRegion(actionRect); + + QRect adjustedActionRect = actionRect; + if (adjustedActionRect.intersects(scrollUpTearOffRect)) { + if (adjustedActionRect.bottom() <= scrollUpTearOffRect.bottom()) + continue; + else + adjustedActionRect.setTop(scrollUpTearOffRect.bottom()+1); + } + + if (adjustedActionRect.intersects(scrollDownRect)) { + if (adjustedActionRect.top() >= scrollDownRect.top()) + continue; + else + adjustedActionRect.setBottom(scrollDownRect.top()-1); + } + QRegion adjustedActionReg(adjustedActionRect); - emptyArea -= adjustedActionReg; p.setClipRegion(adjustedActionReg); QStyleOptionMenuItem opt; initStyleOption(&opt, action); - opt.rect = adjustedActionRect; + opt.rect = actionRect; style()->drawControl(QStyle::CE_MenuItem, &opt, &p, this); } - const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); - //draw the scroller regions.. - if (d->scroll) { - menuOpt.menuItemType = QStyleOptionMenuItem::Scroller; - menuOpt.state |= QStyle::State_Enabled; - if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) { - menuOpt.rect.setRect(fw, fw, width() - (fw * 2), d->scrollerHeight()); - emptyArea -= QRegion(menuOpt.rect); - p.setClipRect(menuOpt.rect); - style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); - } - if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) { - menuOpt.rect.setRect(fw, height() - d->scrollerHeight() - fw, width() - (fw * 2), - d->scrollerHeight()); - emptyArea -= QRegion(menuOpt.rect); - menuOpt.state |= QStyle::State_DownArrow; - p.setClipRect(menuOpt.rect); - style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p, this); - } - } - //paint the tear off.. - if (d->tearoff) { - menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; - menuOpt.rect.setRect(fw, fw, width() - (fw * 2), - style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); - if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) - menuOpt.rect.translate(0, d->scrollerHeight()); - emptyArea -= QRegion(menuOpt.rect); - p.setClipRect(menuOpt.rect); - menuOpt.state = QStyle::State_None; - if (d->tearoffHighlighted) - menuOpt.state |= QStyle::State_Selected; - style()->drawControl(QStyle::CE_MenuTearoff, &menuOpt, &p, this); + emptyArea -= QRegion(scrollUpTearOffRect); + emptyArea -= QRegion(scrollDownRect); + + if (d->scrollUpTearOffItem || d->scrollDownItem) { + if (d->scrollUpTearOffItem) + d->scrollUpTearOffItem->updateScrollerRects(scrollUpTearOffRect); + if (d->scrollDownItem) + d->scrollDownItem->updateScrollerRects(scrollDownRect); + } else { + //paint scroll up /down + d->drawScroller(&p, QMenuPrivate::ScrollerTearOffItem::ScrollUp, scrollUpRect); + d->drawScroller(&p, QMenuPrivate::ScrollerTearOffItem::ScrollDown, scrollDownRect); + //paint the tear off.. + d->drawTearOff(&p, tearOffRect); } + //draw border if (fw) { QRegion borderReg; @@ -2603,7 +2716,7 @@ void QMenu::paintEvent(QPaintEvent *e) style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this); } - //finally the rest of the space + //finally the rest of the spaces p.setClipRegion(emptyArea); menuOpt.state = QStyle::State_None; menuOpt.menuItemType = QStyleOptionMenuItem::EmptyArea; @@ -2730,7 +2843,10 @@ QMenu::event(QEvent *e) if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down || kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right || kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return - || kev->matches(QKeySequence::Cancel)) { +#ifndef QT_NO_SHORTCUT + || kev->matches(QKeySequence::Cancel) +#endif + ) { e->accept(); return true; } @@ -2978,7 +3094,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) key_consumed = true; break; } - //FALL THROUGH + Q_FALLTHROUGH(); case Qt::Key_Left: { if (d->currentAction && !d->scroll) { QAction *nextAction = 0; @@ -3025,6 +3141,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this)) break; // for motif, fall through + Q_FALLTHROUGH(); #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Select: #endif @@ -3057,7 +3174,11 @@ void QMenu::keyPressEvent(QKeyEvent *e) key_consumed = false; } - if (!key_consumed && (e->matches(QKeySequence::Cancel) + if (!key_consumed && ( + false +#ifndef QT_NO_SHORTCUT + || e->matches(QKeySequence::Cancel) +#endif #ifdef QT_KEYPAD_NAVIGATION || e->key() == Qt::Key_Back #endif @@ -3271,7 +3392,9 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *i item->setIcon(QIcon()); } item->setVisible(action->isVisible()); +#ifndef QT_NO_SHORTCUT item->setShortcut(action->shortcut()); +#endif item->setCheckable(action->isCheckable()); item->setChecked(action->isChecked()); item->setHasExclusiveGroup(action->actionGroup() && action->actionGroup()->isExclusive()); @@ -3305,8 +3428,17 @@ void QMenu::actionEvent(QActionEvent *e) } if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) { QWidget *widget = wa->requestWidget(this); - if (widget) + if (widget) { d->widgetItems.insert(wa, widget); + if (d->scroll) { + if (!d->scrollUpTearOffItem) + d->scrollUpTearOffItem = + new QMenuPrivate::ScrollerTearOffItem(QMenuPrivate::ScrollerTearOffItem::ScrollUp, d, this); + if (!d->scrollDownItem) + d->scrollDownItem = + new QMenuPrivate::ScrollerTearOffItem(QMenuPrivate::ScrollerTearOffItem::ScrollDown, d, this); + } + } } } else if (e->type() == QEvent::ActionRemoved) { e->action()->disconnect(this); @@ -3354,17 +3486,6 @@ void QMenu::actionEvent(QActionEvent *e) d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators); } -#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) - if (!d->wce_menu) - d->wce_menu = new QMenuPrivate::QWceMenuPrivate; - if (e->type() == QEvent::ActionAdded) - d->wce_menu->addAction(e->action(), d->wce_menu->findAction(e->before())); - else if (e->type() == QEvent::ActionRemoved) - d->wce_menu->removeAction(e->action()); - else if (e->type() == QEvent::ActionChanged) - d->wce_menu->syncAction(e->action()); -#endif - if (isVisible()) { d->updateActionRects(); resize(sizeHint()); diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 7dda38456a..bcbd0a95c4 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -40,14 +40,12 @@ #ifndef QMENU_H #define QMENU_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtCore/qstring.h> #include <QtGui/qicon.h> #include <QtWidgets/qaction.h> -#ifdef Q_OS_WINCE -#include <windef.h> // for HMENU -#endif #ifdef Q_OS_OSX Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); #endif @@ -85,11 +83,17 @@ public: QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0); #ifdef Q_QDOC + template<typename PointerToMemberFunction> QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0); + template<typename Functor> QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0); + template<typename Functor> QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0); + template<typename PointerToMemberFunction> QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0); + template<typename Functor> QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0); + template<typename Functor> QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0); #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) @@ -208,9 +212,6 @@ public: QPlatformMenu *platformMenu(); void setPlatformMenu(QPlatformMenu *platformMenu); -#ifdef Q_OS_WINCE - HMENU wceMenu(); -#endif #ifdef Q_OS_OSX NSMenu* toNSMenu(); void setAsDockMenu(); @@ -249,10 +250,6 @@ protected: bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const; -#ifdef Q_OS_WINCE - QAction* wceCommands(uint command); -#endif - private Q_SLOTS: void internalDelayedPopup(); diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm index 82379c6509..f9f3ad08dc 100644 --- a/src/widgets/widgets/qmenu_mac.mm +++ b/src/widgets/widgets/qmenu_mac.mm @@ -62,8 +62,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration(functionName); if (Q_UNLIKELY(!function)) - qWarning() << "Qt could not resolve function" << functionName - << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()"; + qWarning("Qt could not resolve function %s from " + "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()", + functionName.constData()); return function; } } //namespsace @@ -79,11 +80,12 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla */ NSMenu *QMenu::toNSMenu() { + Q_D(QMenu); // Call into the cocoa platform plugin: qMenuToNSMenu(platformMenu()) QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu"); if (function) { typedef void* (*QMenuToNSMenuFunction)(QPlatformMenu *platformMenu); - return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuToNSMenuFunction>(function)(platformMenu())); + return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuToNSMenuFunction>(function)(d->createPlatformMenu())); } return nil; } @@ -97,11 +99,12 @@ NSMenu *QMenu::toNSMenu() */ void QMenu::setAsDockMenu() { + Q_D(QMenu); // Call into the cocoa platform plugin: setDockMenu(platformMenu()) QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("setdockmenu"); if (function) { typedef void (*SetDockMenuFunction)(QPlatformMenu *platformMenu); - reinterpret_cast<SetDockMenuFunction>(function)(platformMenu()); + reinterpret_cast<SetDockMenuFunction>(function)(d->createPlatformMenu()); } } diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 56904f51d6..64291e842f 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qmenubar.h" #include "QtWidgets/qstyleoption.h" #include "QtCore/qdatetime.h" @@ -68,15 +69,6 @@ QT_BEGIN_NAMESPACE class QTornOffMenu; class QEventLoop; -#ifdef Q_OS_WINCE -struct QWceMenuAction { - uint command; - QPointer<QAction> action; - HMENU menuHandle; - QWceMenuAction() : menuHandle(0), command(0) {} -}; -#endif - template <typename T> class QSetValueOnDestroy { @@ -284,22 +276,18 @@ public: cancelAction(0), #endif scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), - hasCheckableItems(0), doChildEffects(false), platformMenu(0) - -#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) - ,wce_menu(0) -#endif + hasCheckableItems(0), doChildEffects(false), platformMenu(0), + scrollUpTearOffItem(nullptr), scrollDownItem(nullptr) { } + ~QMenuPrivate() { delete scroll; if (!platformMenu.isNull() && !platformMenu->parent()) delete platformMenu.data(); -#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) - delete wce_menu; -#endif } void init(); + QPlatformMenu *createPlatformMenu(); void setPlatformMenu(QPlatformMenu *menu); void syncPlatformMenu(); #ifdef Q_OS_OSX @@ -457,32 +445,25 @@ public: QPointer<QAction> actionAboutToTrigger; -#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) - struct QWceMenuPrivate { - QList<QWceMenuAction*> actionItems; - HMENU menuHandle; - QWceMenuPrivate(); - ~QWceMenuPrivate(); - void addAction(QAction *, QWceMenuAction* =0); - void addAction(QWceMenuAction *, QWceMenuAction* =0); - void syncAction(QWceMenuAction *); - inline void syncAction(QAction *a) { syncAction(findAction(a)); } - void removeAction(QWceMenuAction *); - void rebuild(); - inline void removeAction(QAction *a) { removeAction(findAction(a)); } - inline QWceMenuAction *findAction(QAction *a) { - for(int i = 0; i < actionItems.size(); i++) { - QWceMenuAction *act = actionItems[i]; - if(a == act->action) - return act; - } - return 0; - } - } *wce_menu; - HMENU wceMenu(); - QAction* wceCommands(uint command); -#endif QPointer<QWidget> noReplayFor; + + class ScrollerTearOffItem : public QWidget { + public: + enum Type { ScrollUp, ScrollDown }; + ScrollerTearOffItem(Type type, QMenuPrivate *mPrivate, + QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + void updateScrollerRects(const QRect &rect); + + private: + QMenuPrivate *menuPrivate; + Type scrollType; + }; + ScrollerTearOffItem *scrollUpTearOffItem; + ScrollerTearOffItem *scrollDownItem; + + void drawScroller(QPainter *painter, ScrollerTearOffItem::Type type, const QRect &rect); + void drawTearOff(QPainter *painter, const QRect &rect); }; #endif // QT_NO_MENU diff --git a/src/widgets/widgets/qmenu_wince.cpp b/src/widgets/widgets/qmenu_wince.cpp deleted file mode 100644 index d7397746fc..0000000000 --- a/src/widgets/widgets/qmenu_wince.cpp +++ /dev/null @@ -1,666 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Native menubars are only supported for Windows Mobile not the standard SDK/generic WinCE -#ifdef Q_OS_WINCE -#include "qmenu.h" -#include "qt_windows.h" -#include "qapplication.h" -#include "qmainwindow.h" -#include "qtoolbar.h" -#include "qevent.h" -#include "qstyle.h" -#include "qdebug.h" -#include "qwidgetaction.h" -#include <private/qapplication_p.h> -#include <private/qmenu_p.h> -#include <private/qmenubar_p.h> - -#include "qmenu_wince_resource_p.h" - -#include <QtCore/qlibrary.h> -#include <commctrl.h> -#if Q_OS_WINCE_WM -# include <windowsm.h> -#endif - -#ifndef QT_NO_MENUBAR - -#ifndef SHCMBF_EMPTYBAR -#define SHCMBF_EMPTYBAR 0x0001 -#endif - -#ifndef SHCMBM_GETSUBMENU -#define SHCMBM_GETSUBMENU (WM_USER + 401) -#endif - -#ifdef Q_OS_WINCE_WM -# define SHMBOF_NODEFAULT 0x00000001 -# define SHMBOF_NOTIFY 0x00000002 -# define SHCMBM_OVERRIDEKEY (WM_USER + 0x193) -#endif - -extern bool qt_wince_is_smartphone();//defined in qguifunctions_wce.cpp -extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wce.cpp - -QT_BEGIN_NAMESPACE - -static uint qt_wce_menu_static_cmd_id = 200; -static QList<QMenuBar*> nativeMenuBars; - -struct qt_SHMENUBARINFO -{ - DWORD cbSize; - HWND hwndParent; - DWORD dwFlags; - UINT nToolBarId; - HINSTANCE hInstRes; - int nBmpId; - int cBmpImages; - HWND hwndMB; - COLORREF clrBk; -}; - -typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*); -typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL); - -static bool aygResolved = false; -static AygCreateMenuBar ptrCreateMenuBar = 0; -static AygEnableSoftKey ptrEnableSoftKey = 0; - -static void resolveAygLibs() -{ - if (!aygResolved) { - aygResolved = true; - QLibrary aygLib(QLatin1String("aygshell")); - ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar"); - ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey"); - } -} - -static void qt_wce_enable_soft_key(HWND handle, uint command) -{ - resolveAygLibs(); - if (ptrEnableSoftKey) - ptrEnableSoftKey(handle, command, false, true); -} - -static void qt_wce_disable_soft_key(HWND handle, uint command) -{ - resolveAygLibs(); - if (ptrEnableSoftKey) - ptrEnableSoftKey(handle, command, false, false); -} - -static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list) -{ - for(QList<QWceMenuAction*>::Iterator it = list->begin(); it != list->end(); ++it) { - QWceMenuAction *action = (*it); - delete action; - action = 0; - } - list->clear(); -} - -//search for first QuitRole in QMenuBar -static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems) -{ - QAction *returnAction = 0; - for (int i = 0; i < actionItems.size(); ++i) { - QAction *action = actionItems.at(i); - if (action->menuRole() == QAction::QuitRole) - returnAction = action; - else - if (action->menu()) - returnAction = qt_wce_get_quit_action(action->menu()->actions()); - if (returnAction) - return returnAction; //return first action found - } - return 0; //nothing found; -} - -static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems) -{ - for (int i = 0; i < actionItems.size(); ++i) { - if (actionItems.at(i)->action->menuRole() == QAction::QuitRole) - return actionItems.at(i)->action; - else if (actionItems.at(i)->action->menu()) { - QAction *returnAction = qt_wce_get_quit_action(actionItems.at(i)->action->menu()->actions()); - if (returnAction) - return returnAction; - } - } - return 0; -} - -static HMODULE qt_wce_get_module_handle() -{ - HMODULE module = 0; //handle to resources - if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic - if (!(module = GetModuleHandle(L"QtGuid4"))) //debug dynamic - module = (HINSTANCE)qWinAppInst(); //static - Q_ASSERT_X(module, "qt_wce_get_module_handle()", "cannot get handle to module?"); - return module; -} - -static void qt_wce_change_command(HWND menuHandle, int item, int command) -{ -TBBUTTONINFOA tbbi; - memset(&tbbi,0,sizeof(tbbi)); - tbbi.cbSize = sizeof(tbbi); - tbbi.dwMask = TBIF_COMMAND; - tbbi.idCommand = command; - SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); -} - -static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText) -{ - TBBUTTONINFOA tbbi; - memset(&tbbi,0,sizeof(tbbi)); - tbbi.cbSize = sizeof(tbbi); - tbbi.dwMask = TBIF_TEXT; - QString text = newText; - text.remove(QChar::fromLatin1('&')); - tbbi.pszText = (LPSTR) text.utf16(); - SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi); -} - -static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0) -{ - resolveAygLibs(); - - if (ptrCreateMenuBar) { - qt_SHMENUBARINFO mbi; - memset(&mbi, 0, sizeof(qt_SHMENUBARINFO)); - mbi.cbSize = sizeof(qt_SHMENUBARINFO); - mbi.hwndParent = parentHandle; - mbi.hInstRes = resourceHandle; - mbi.dwFlags = flags; - mbi.nToolBarId = toolbarID; - - if (ptrCreateMenuBar(&mbi)) { -#ifdef Q_OS_WINCE_WM - // Tell the menu bar that we want to override hot key behaviour. - LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, - SHMBOF_NODEFAULT | SHMBOF_NOTIFY); - SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam); -#endif - return mbi.hwndMB; - } - } - return 0; -} - -static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action) -{ - Q_ASSERT_X(menu, "AppendMenu", "menu is 0"); - if (action->action->isVisible()) { - int flags; - action->action->isEnabled() ? flags = MF_ENABLED : flags = MF_GRAYED; - - QString text = action->action->iconText(); - text.remove(QChar::fromLatin1('&')); - if (action->action->isSeparator()) { - AppendMenu (menu, MF_SEPARATOR , 0, 0); - } - else if (action->action->menu()) { - text.remove(QChar::fromLatin1('&')); - AppendMenu (menu, MF_STRING | flags | MF_POPUP, - (UINT) action->action->menu()->wceMenu(), reinterpret_cast<const wchar_t *> (text.utf16())); - } - else { - AppendMenu (menu, MF_STRING | flags, action->command, reinterpret_cast<const wchar_t *> (text.utf16())); - } - if (action->action->isCheckable()) - if (action->action->isChecked()) - CheckMenuItem(menu, action->command, MF_BYCOMMAND | MF_CHECKED); - else - CheckMenuItem(menu, action->command, MF_BYCOMMAND | MF_UNCHECKED); - } -} - -// Removes all items from the menu without destroying the handles. -static void qt_wce_clear_menu(HMENU hMenu) -{ - while (RemoveMenu(hMenu, 0, MF_BYPOSITION)); -} - -/*! - \internal - - This function refreshes the native Windows CE menu. -*/ - -void QMenuBar::wceRefresh() -{ - for (int i = 0; i < nativeMenuBars.size(); ++i) - nativeMenuBars.at(i)->d_func()->wceRefresh(); -} - -void QMenuBarPrivate::wceRefresh() -{ - DrawMenuBar(wce_menubar->menubarHandle); -} - -/*! - \internal - - This function sends native Windows CE commands to Qt menus. -*/ - -QAction* QMenu::wceCommands(uint command) -{ - Q_D(QMenu); - return d->wceCommands(command); -} - -/*! - \internal - - This function sends native Windows CE commands to Qt menu bars - and all their child menus. -*/ - -void QMenuBar::wceCommands(uint command) -{ - const HWND hwndActiveWindow = GetActiveWindow(); - for (int i = 0; i < nativeMenuBars.size(); ++i) { - QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func(); - if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle) - nativeMenuBar->wceCommands(command); - } -} - -bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command) -{ - QAction *foundAction = 0; - for (int i = 0; i < actions.size(); ++i) { - QWceMenuAction *action = actions.at(i); - if (action->action->menu()) { - foundAction = action->action->menu()->wceCommands(command); - if (foundAction) - break; - } - else if (action->command == command) { - action->action->activate(QAction::Trigger); - return true; - } - } - if (foundAction) { - emit q_func()->triggered(foundAction); - return true; - } - return false; -} - -void QMenuBarPrivate::wceCommands(uint command) -{ - if (wceClassicMenu) { - for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i) - wceEmitSignals(wce_menubar->actionItemsClassic.at(i), command); - } else { - if (wceEmitSignals(wce_menubar->actionItems, command)) { - return; - } - else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button - wceEmitSignals(wce_menubar->actionItemsLeftButton, command); - } - else if ((wce_menubar->leftButtonAction) && (command == wce_menubar->leftButtonCommand)) { - emit q_func()->triggered(wce_menubar->leftButtonAction); - wce_menubar->leftButtonAction->activate(QAction::Trigger); - } - } -} - -QAction *QMenuPrivate::wceCommands(uint command) -{ - QAction *foundAction = 0; - for (int i = 0; i < wce_menu->actionItems.size(); ++i) { - if (foundAction) - break; - QWceMenuAction *action = wce_menu->actionItems.at(i); - if (action->action->menu()) { - foundAction = action->action->menu()->d_func()->wceCommands(command); - } - else if (action->command == command) { - activateAction(action->action, QAction::Trigger); - return action->action; - } - } - if (foundAction) - emit q_func()->triggered(foundAction); - return foundAction; -} - -void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent) -{ - Q_Q(QMenuBar); - wce_menubar = new QWceMenuBarPrivate(this); - - wce_menubar->parentWindowHandle = parent ? QApplicationPrivate::getHWNDForWidget(parent) : - QApplicationPrivate::getHWNDForWidget(q); - wce_menubar->leftButtonAction = defaultAction; - - wce_menubar->menubarHandle = qt_wce_create_menubar(wce_menubar->parentWindowHandle, (HINSTANCE)qWinAppInst(), 0, SHCMBF_EMPTYBAR); - Q_ASSERT_X(wce_menubar->menubarHandle, "wceCreateMenuBar", "cannot create empty menu bar"); - DrawMenuBar(wce_menubar->menubarHandle); - nativeMenuBars.append(q); - wceClassicMenu = (!qt_wince_is_smartphone() && !qt_wince_is_pocket_pc()); -} - -void QMenuBarPrivate::wceDestroyMenuBar() -{ - Q_Q(QMenuBar); - int index = nativeMenuBars.indexOf(q); - nativeMenuBars.removeAt(index); - if (wce_menubar) { - delete wce_menubar; - wce_menubar = 0; - } -} - -QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar) -: menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0), - leftButtonAction(0), leftButtonIsMenu(false), d(menubar) -{ -} - -QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate() -{ - if (menubarHandle) - DestroyWindow(menubarHandle); - qt_wce_delete_action_list(&actionItems); - qt_wce_delete_action_list(&actionItemsLeftButton); - - for (int i=0; i<actionItemsClassic.size(); ++i) - if (!actionItemsClassic.value(i).empty()) - qt_wce_delete_action_list(&actionItemsClassic[i]); - actionItemsClassic.clear(); - - menubarHandle = 0; - menuHandle = 0; - leftButtonMenuHandle = 0; - leftButtonCommand = 0; - QMenuBar::wceRefresh(); -} - -QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() -: menuHandle(0) -{ -} - -QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() -{ - qt_wce_delete_action_list(&actionItems); - if (menuHandle) - DestroyMenu(menuHandle); -} - -void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) -{ - QWceMenuAction *action = new QWceMenuAction; - action->action = a; - action->command = qt_wce_menu_static_cmd_id++; - addAction(action, before); -} - -void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) -{ - if (!action) - return; - int before_index = actionItems.indexOf(before); - if (before_index < 0) { - before = 0; - before_index = actionItems.size(); - } - actionItems.insert(before_index, action); - rebuild(); -} - -/*! - \internal - - This function will return the HMENU used to create the native - Windows CE menu bar bindings. -*/ - -HMENU QMenu::wceMenu() -{ - return d_func()->wceMenu(); -} - -HMENU QMenuPrivate::wceMenu() -{ - if (!wce_menu) - wce_menu = new QWceMenuPrivate; - if (!wce_menu->menuHandle) - wce_menu->rebuild(); - return wce_menu->menuHandle; -} - -void QMenuPrivate::QWceMenuPrivate::rebuild() -{ - if (!menuHandle) - menuHandle = CreatePopupMenu(); - else - qt_wce_clear_menu(menuHandle); - - for (int i = 0; i < actionItems.size(); ++i) { - QWceMenuAction *action = actionItems.at(i); - action->menuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action); - } - QMenuBar::wceRefresh(); -} - -void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *) -{ - rebuild(); -} - -void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action) -{ - actionItems.removeAll(action); - delete action; - rebuild(); -} - -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QAction *before) -{ - QWceMenuAction *action = new QWceMenuAction; - action->action = a; - action->command = qt_wce_menu_static_cmd_id++; - addAction(action, findAction(before)); -} - -void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before) -{ - if (!action) - return; - int before_index = actionItems.indexOf(before); - if (before_index < 0) { - before = 0; - before_index = actionItems.size(); - } - actionItems.insert(before_index, action); - rebuild(); -} - -void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*) -{ - QMenuBar::wceRefresh(); - rebuild(); -} - -void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action) -{ - actionItems.removeAll(action); - delete action; - rebuild(); -} - -void QMenuBarPrivate::_q_updateDefaultAction() -{ - if (wce_menubar) - wce_menubar->rebuild(); -} - -void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() -{ - d->q_func()->resize(0,0); - parentWindowHandle = d->q_func()->parentWidget() ? QApplicationPrivate::getHWNDForWidget(d->q_func()->parentWidget()) : - QApplicationPrivate::getHWNDForWidget(d->q_func()); - if (d->wceClassicMenu) { - QList<QAction*> actions = d->actions; - int maxEntries; - int resourceHandle; - if (actions.size() < 5) { - maxEntries = 4; - resourceHandle = IDR_MAIN_MENU3; - } else if (actions.size() < 7) { - maxEntries = 6; - resourceHandle = IDR_MAIN_MENU4; - } - else { - maxEntries = 8; - resourceHandle = IDR_MAIN_MENU5; - } - Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); - qt_wce_clear_menu(menuHandle); - DestroyWindow(menubarHandle); - menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle); - Q_ASSERT_X(menubarHandle, "rebuild classic menu", "cannot create menubar from resource"); - DrawMenuBar(menubarHandle); - QList<int> menu_ids; - QList<int> item_ids; - menu_ids << IDM_MENU1 << IDM_MENU2 << IDM_MENU3 << IDM_MENU4 << IDM_MENU5 << IDM_MENU6 << IDM_MENU7 << IDM_MENU8; - item_ids << IDM_ITEM1 << IDM_ITEM2 << IDM_ITEM3 << IDM_ITEM4 << IDM_ITEM5 << IDM_ITEM6 << IDM_ITEM7 << IDM_ITEM8; - - for (int i = 0; i < actionItemsClassic.size(); ++i) - if (!actionItemsClassic.value(i).empty()) - qt_wce_delete_action_list(&actionItemsClassic[i]); - actionItemsClassic.clear(); - - for (int i = 0; i < actions.size(); ++i) { - qt_wce_rename_menu_item(menubarHandle, menu_ids.at(i), actions.at(i)->text()); - QList<QAction *> subActions = actions.at(i)->menu()->actions(); - HMENU subMenuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0 , menu_ids.at(i)); - DeleteMenu(subMenuHandle, item_ids.at(i), MF_BYCOMMAND); - for (int c = 0; c < subActions.size(); ++c) { - QList<QWceMenuAction*> list; - actionItemsClassic.append(list); - QWceMenuAction *action = new QWceMenuAction; - action->action = subActions.at(c); - action->command = qt_wce_menu_static_cmd_id++; - action->menuHandle = subMenuHandle; - actionItemsClassic.last().append(action); - qt_wce_insert_action(subMenuHandle, action); - } - } - for (int i = actions.size();i<maxEntries;++i) { - qt_wce_rename_menu_item(menubarHandle, menu_ids.at(i), QString()); - qt_wce_disable_soft_key(menubarHandle, menu_ids.at(i)); - } - } else { - leftButtonAction = d->defaultAction; - if (!leftButtonAction) - leftButtonAction = qt_wce_get_quit_action(actionItems); - - leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu()); - Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); - qt_wce_clear_menu(menuHandle); - DestroyWindow(menubarHandle); - if (leftButtonIsMenu) { - menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU2); - Q_ASSERT_X(menubarHandle, "rebuild !created left menubar", "cannot create menubar from resource"); - menuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_MENU); - Q_ASSERT_X(menuHandle, "rebuild !created", "IDM_MENU not found - invalid resource?"); - DeleteMenu(menuHandle, IDM_ABOUT, MF_BYCOMMAND); - leftButtonMenuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_LEFTMENU); - Q_ASSERT_X(leftButtonMenuHandle, "rebuild !created", "IDM_LEFTMENU not found - invalid resource?"); - DeleteMenu(leftButtonMenuHandle, IDM_VIEW, MF_BYCOMMAND); - } else { - menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU); - Q_ASSERT_X(menubarHandle, "rebuild !created no left menubar", "cannot create menubar from resource"); - menuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_MENU); - Q_ASSERT_X(menuHandle, "rebuild !created", "IDM_MENU not found - invalid resource?"); - DeleteMenu(menuHandle, IDM_ABOUT, MF_BYCOMMAND); - leftButtonMenuHandle = 0; - leftButtonCommand = qt_wce_menu_static_cmd_id++; - qt_wce_change_command(menubarHandle, IDM_EXIT, leftButtonCommand); - } - - if (actionItems.size() == 0) { - qt_wce_rename_menu_item(menubarHandle, IDM_MENU, QLatin1String("")); - qt_wce_disable_soft_key(menubarHandle, IDM_MENU); - } - for (int i = 0; i < actionItems.size(); ++i) { - QWceMenuAction *action = actionItems.at(i); - action->menuHandle = menuHandle; - qt_wce_insert_action(menuHandle, action); - } - if (!leftButtonIsMenu) { - if (leftButtonAction) { - qt_wce_rename_menu_item(menubarHandle, leftButtonCommand, leftButtonAction->text()); - qt_wce_enable_soft_key(menubarHandle, leftButtonCommand); - } else { - qt_wce_rename_menu_item(menubarHandle, leftButtonCommand, QLatin1String("")); - qt_wce_disable_soft_key(menubarHandle, leftButtonCommand); - } - } else { - qt_wce_rename_menu_item(menubarHandle, IDM_LEFTMENU, leftButtonAction->text()); - QList<QAction *> actions = leftButtonAction->menu()->actions(); - qt_wce_delete_action_list(&actionItemsLeftButton); - for (int i=0; i<actions.size(); ++i) { - QWceMenuAction *action = new QWceMenuAction; - action->action = actions.at(i); - action->command = qt_wce_menu_static_cmd_id++; - action->menuHandle = leftButtonMenuHandle; - actionItemsLeftButton.append(action); - qt_wce_insert_action(leftButtonMenuHandle, action); - } - } - } - DrawMenuBar(menubarHandle); -} - -QT_END_NAMESPACE - -#endif //QT_NO_MENUBAR -#endif //Q_OS_WINCE diff --git a/src/widgets/widgets/qmenu_wince.rc b/src/widgets/widgets/qmenu_wince.rc deleted file mode 100644 index 0bcd32c7e5..0000000000 --- a/src/widgets/widgets/qmenu_wince.rc +++ /dev/null @@ -1,231 +0,0 @@ -#include "qmenu_wince_resource_p.h" - -#include <commctrl.h> -#include "winuser.h" - -#if defined (_DEBUG) && defined(QT_SHARED) -#include "Qt5Widgetsd_resource.rc" -#elif defined(QT_SHARED) -#include "Qt5Widgets_resource.rc" -#endif - -#define DIALOGEX DIALOG DISCARDABLE -#define SHMENUBAR RCDATA -#define I_IMAGENONE (-2) -#define NOMENU 0xFFFF - -IDR_MAIN_MENU MENU DISCARDABLE -BEGIN - POPUP "Menu" - BEGIN - MENUITEM "About", IDM_ABOUT - END -END - -IDR_MAIN_MENU2 MENU DISCARDABLE -BEGIN - POPUP "Menu" - BEGIN - MENUITEM "About", IDM_ABOUT - END - POPUP "Display" - BEGIN - MENUITEM "View", IDM_VIEW - END -END - - -IDR_MAIN_MENU3 MENU DISCARDABLE -BEGIN - POPUP "Menu1" - BEGIN - MENUITEM "Item1", IDM_ITEM1 - END - POPUP "Menu2" - BEGIN - MENUITEM "Item2", IDM_ITEM2 - END - POPUP "Menu3" - BEGIN - MENUITEM "Item3", IDM_ITEM3 - END - POPUP "Menu4" - BEGIN - MENUITEM "Item4", IDM_ITEM4 - END -END - -IDR_MAIN_MENU4 MENU DISCARDABLE -BEGIN - POPUP "Menu1" - BEGIN - MENUITEM "Item1", IDM_ITEM1 - END - POPUP "Menu2" - BEGIN - MENUITEM "Item2", IDM_ITEM2 - END - POPUP "Menu3" - BEGIN - MENUITEM "Item3", IDM_ITEM3 - END - POPUP "Menu4" - BEGIN - MENUITEM "Item4", IDM_ITEM4 - END - POPUP "Menu5" - BEGIN - MENUITEM "Item5", IDM_ITEM5 - END - POPUP "Menu6" - BEGIN - MENUITEM "Item6", IDM_ITEM6 - END -END - -IDR_MAIN_MENU5 MENU DISCARDABLE -BEGIN - POPUP "Menu1" - BEGIN - MENUITEM "Item1", IDM_ITEM1 - END - POPUP "Menu2" - BEGIN - MENUITEM "Item2", IDM_ITEM2 - END - POPUP "Menu3" - BEGIN - MENUITEM "Item3", IDM_ITEM3 - END - POPUP "Menu4" - BEGIN - MENUITEM "Item4", IDM_ITEM4 - END - POPUP "Menu5" - BEGIN - MENUITEM "Item5", IDM_ITEM5 - END - POPUP "Menu6" - BEGIN - MENUITEM "Item6", IDM_ITEM6 - END - POPUP "Menu7" - BEGIN - MENUITEM "Item7", IDM_ITEM7 - END - POPUP "Menu8" - BEGIN - MENUITEM "Item8", IDM_ITEM8 - END -END - -STRINGTABLE -BEGIN - IDS_EXIT "Exit" - IDS_MENU "Menu" - IDS_LEFTMENU "Display" - IDS_MENU1 "Menu__1" - IDS_MENU2 "Menu__2" - IDS_MENU3 "Menu__3" - IDS_MENU4 "Menu__4" - IDS_MENU5 "Menu__5" - IDS_MENU6 "Menu__6" - IDS_MENU7 "Menu__7" - IDS_MENU8 "Menu__8" -END - -IDR_MAIN_MENU SHMENUBAR DISCARDABLE -BEGIN - IDR_MAIN_MENU, - 2, - - I_IMAGENONE, IDM_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, - IDS_EXIT, 0, NOMENU, - - I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU, 0, 0, -END - -IDR_MAIN_MENU2 SHMENUBAR DISCARDABLE -BEGIN - IDR_MAIN_MENU2, - 2, - - I_IMAGENONE, IDM_LEFTMENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_LEFTMENU, 0, 1, - - I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU, 0, 0, -END - -IDR_MAIN_MENU3 SHMENUBAR DISCARDABLE -BEGIN - IDR_MAIN_MENU3, - 4, - - I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU1, 0, 0, - - I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU2, 0, 1, - - I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU3, 0, 2, - - I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU4, 0, 3, -END - -IDR_MAIN_MENU4 SHMENUBAR DISCARDABLE -BEGIN - IDR_MAIN_MENU4, - 6, - - I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU1, 0, 0, - - I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU2, 0, 1, - - I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU3, 0, 2, - - I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU4, 0, 3, - - I_IMAGENONE, IDM_MENU5, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU5, 0, 4, - - I_IMAGENONE, IDM_MENU6, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU6, 0, 5, -END - -IDR_MAIN_MENU5 SHMENUBAR DISCARDABLE -BEGIN - IDR_MAIN_MENU5, - 8, - - I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU1, 0, 0, - - I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU2, 0, 1, - - I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU3, 0, 2, - - I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU4, 0, 3, - - I_IMAGENONE, IDM_MENU5, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU5, 0, 4, - - I_IMAGENONE, IDM_MENU6, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU6, 0, 5, - - I_IMAGENONE, IDM_MENU7, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU7, 0, 6, - - I_IMAGENONE, IDM_MENU8, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MENU8, 0, 7, -END diff --git a/src/widgets/widgets/qmenu_wince_resource_p.h b/src/widgets/widgets/qmenu_wince_resource_p.h deleted file mode 100644 index 3bd83d934f..0000000000 --- a/src/widgets/widgets/qmenu_wince_resource_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// 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 -// version without notice, or even be removed. -// -// We mean it. -// - - -#define IDR_MAIN_MENU 102 -#define IDR_MAIN_MENU2 103 -#define IDR_MAIN_MENU3 104 -#define IDS_EXIT 105 -#define IDS_MENU 106 -#define IDS_LEFTMENU 107 -#define IDM_ABOUT 108 -#define IDM_VIEW 109 -#define IDM_ITEM1 108 -#define IDM_ITEM2 109 -#define IDM_ITEM3 110 -#define IDM_ITEM4 111 -#define IDM_ITEM5 112 -#define IDM_ITEM6 113 -#define IDM_ITEM7 114 -#define IDM_ITEM8 115 -#define IDS_MENU1 116 -#define IDS_MENU2 117 -#define IDS_MENU3 118 -#define IDS_MENU4 119 -#define IDS_MENU5 120 -#define IDS_MENU6 121 -#define IDS_MENU7 122 -#define IDS_MENU8 123 -#define IDR_MAIN_MENU4 124 -#define IDR_MAIN_MENU5 125 -#define IDM_EXIT 40000 -#define IDM_MENU 40001 -#define IDM_LEFTMENU 40002 -#define IDM_MENU1 40003 -#define IDM_MENU2 40004 -#define IDM_MENU3 40005 -#define IDM_MENU4 40006 -#define IDM_MENU5 40007 -#define IDM_MENU6 40008 -#define IDM_MENU7 40009 -#define IDM_MENU8 40010 - diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 8b5f370fc3..63fe09f77e 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -64,10 +64,6 @@ #include "qmenubar_p.h" #include "qdebug.h" -#ifdef Q_OS_WINCE -extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp -#endif - QT_BEGIN_NAMESPACE class QMenuBarExtension : public QToolButton @@ -695,16 +691,6 @@ void QMenuBarPrivate::init() if (platformMenuBar) q->hide(); -#ifdef Q_OS_WINCE - if (qt_wince_is_mobile()) { - wceCreateMenuBar(q->parentWidget()); - if(wce_menubar) - q->hide(); - } - else { - QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); - } -#endif q->setBackgroundRole(QPalette::Button); handleReparent(); q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); @@ -754,11 +740,6 @@ QMenuBar::~QMenuBar() Q_D(QMenuBar); delete d->platformMenuBar; d->platformMenuBar = 0; - -#ifdef Q_OS_WINCE - if (qt_wince_is_mobile()) - d->wceDestroyMenuBar(); -#endif } /*! @@ -1124,11 +1105,13 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) key_consumed = false; } +#ifndef QT_NO_SHORTCUT if (!key_consumed && e->matches(QKeySequence::Cancel)) { d->setCurrentAction(0); d->setKeyboardMode(false); key_consumed = true; } +#endif if(!key_consumed && (!e->modifiers() || @@ -1209,6 +1192,10 @@ QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action) QPlatformMenu *platformMenu = action->menu()->platformMenu(); if (!platformMenu && platformMenuBar) { platformMenu = platformMenuBar->createMenu(); + // QPlatformMenuBar::createMenu() was introduced in Qt 5.7. Not all third party + // platform themes are using it, so fallback to QPlatformTheme::createPlatformMenu(). + if (!platformMenu) + platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); if (platformMenu) action->menu()->setPlatformMenu(platformMenu); } @@ -1225,11 +1212,7 @@ void QMenuBar::actionEvent(QActionEvent *e) d->itemsDirty = true; if (d->platformMenuBar) { -#if !defined(Q_OS_WINCE) QPlatformMenuBar *nativeMenuBar = d->platformMenuBar; -#else - QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar; -#endif if (!nativeMenuBar) return; @@ -1381,11 +1364,6 @@ void QMenuBarPrivate::handleReparent() platformMenuBar->handleReparent(0); } } - -#ifdef Q_OS_WINCE - if (qt_wince_is_mobile() && wce_menubar) - wce_menubar->rebuild(); -#endif } /*! @@ -1445,6 +1423,7 @@ bool QMenuBar::event(QEvent *e) case QEvent::Show: d->_q_updateLayout(); break; +#ifndef QT_NO_SHORTCUT case QEvent::ShortcutOverride: { QKeyEvent *kev = static_cast<QKeyEvent*>(e); //we only filter out escape if there is a current action @@ -1454,8 +1433,7 @@ bool QMenuBar::event(QEvent *e) } } break; - - +#endif #ifndef QT_NO_WHATSTHIS case QEvent::QueryWhatsThis: e->setAccepted(d->whatsThis.size()); @@ -1846,55 +1824,6 @@ QPlatformMenuBar *QMenuBar::platformMenuBar() } /*! - \since 4.4 - - Sets the default action to \a act. - - The default action is assigned to the left soft key. The menu is assigned - to the right soft key. - - Currently there is only support for the default action on Windows - Mobile. On all other platforms this method is not available. - - \sa defaultAction() -*/ - -#ifdef Q_OS_WINCE -void QMenuBar::setDefaultAction(QAction *act) -{ - Q_D(QMenuBar); - if (d->defaultAction == act) - return; - if (qt_wince_is_mobile()) - if (d->defaultAction) { - disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); - disconnect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction())); - } - d->defaultAction = act; - if (qt_wince_is_mobile()) - if (d->defaultAction) { - connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction())); - connect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction())); - } - if (d->wce_menubar) { - d->wce_menubar->rebuild(); - } -} - -/*! - \since 4.4 - - Returns the current default action. - - \sa setDefaultAction() -*/ -QAction *QMenuBar::defaultAction() const -{ - return d_func()->defaultAction; -} -#endif - -/*! \fn void QMenuBar::triggered(QAction *action) This signal is emitted when an action in a menu belonging to this menubar diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index d3f5e503ac..ec15155710 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -40,6 +40,7 @@ #ifndef QMENUBAR_H #define QMENUBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qmenu.h> QT_BEGIN_NAMESPACE @@ -95,13 +96,6 @@ public: void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner); QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const; -#ifdef Q_OS_WINCE - void setDefaultAction(QAction *); - QAction *defaultAction() const; - - static void wceCommands(uint command); - static void wceRefresh(); -#endif #ifdef Q_OS_OSX NSMenu* toNSMenu(); #endif @@ -141,10 +135,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int)) Q_PRIVATE_SLOT(d_func(), void _q_updateLayout()) -#ifdef Q_OS_WINCE - Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction()) -#endif - friend class QMenu; friend class QMenuPrivate; friend class QWindowsStyle; diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index bdff169451..f5409b9762 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qstyleoption.h" #include <private/qmenu_p.h> // Mac needs what in this file! #include <qpa/qplatformmenu.h> @@ -66,17 +67,11 @@ public: QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0), closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0), doChildEffects(false), platformMenuBar(0) + { } -#ifdef Q_OS_WINCE - , wce_menubar(0), wceClassicMenu(false) -#endif - { } ~QMenuBarPrivate() { delete platformMenuBar; -#ifdef Q_OS_WINCE - delete wce_menubar; -#endif } void init(); @@ -116,10 +111,6 @@ public: void _q_internalShortcutActivated(int); void _q_updateLayout(); -#ifdef Q_OS_WINCE - void _q_updateDefaultAction(); -#endif - //extra widgets in the menubar QPointer<QWidget> leftWidget, rightWidget; QMenuBarExtension *extension; @@ -143,47 +134,6 @@ public: QPlatformMenu *getPlatformMenu(QAction *action); inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); } - -#ifdef Q_OS_WINCE - void wceCreateMenuBar(QWidget *); - void wceDestroyMenuBar(); - struct QWceMenuBarPrivate { - QList<QWceMenuAction*> actionItems; - QList<QWceMenuAction*> actionItemsLeftButton; - QList<QList<QWceMenuAction*>> actionItemsClassic; - HMENU menuHandle; - HMENU leftButtonMenuHandle; - HWND menubarHandle; - HWND parentWindowHandle; - bool leftButtonIsMenu; - QPointer<QAction> leftButtonAction; - QMenuBarPrivate *d; - int leftButtonCommand; - - QWceMenuBarPrivate(QMenuBarPrivate *menubar); - ~QWceMenuBarPrivate(); - void addAction(QAction *, QAction *); - void addAction(QAction *, QWceMenuAction* =0); - void addAction(QWceMenuAction *, QWceMenuAction* =0); - void syncAction(QWceMenuAction *); - inline void syncAction(QAction *a) { syncAction(findAction(a)); } - void removeAction(QWceMenuAction *); - void rebuild(); - inline void removeAction(QAction *a) { removeAction(findAction(a)); } - inline QWceMenuAction *findAction(QAction *a) { - for(int i = 0; i < actionItems.size(); i++) { - QWceMenuAction *act = actionItems[i]; - if(a == act->action) - return act; - } - return 0; - } - } *wce_menubar; - bool wceClassicMenu; - void wceCommands(uint command); - void wceRefresh(); - bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command); -#endif }; #endif // QT_NO_MENUBAR diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 27f1b16f60..7e01f6f3d5 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -811,7 +811,7 @@ void QPlainTextEditPrivate::init(const QString &txt) viewport->setCursor(Qt::IBeamCursor); #endif originalOffsetY = 0; -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN setSingleFingerPanEnabled(true); #endif } diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 021308493a..432ec85a57 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -40,6 +40,7 @@ #ifndef QPLAINTEXTEDIT_H #define QPLAINTEXTEDIT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtextedit.h> #include <QtWidgets/qabstractscrollarea.h> diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index f5a027be42..f0dd1c0ed4 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qabstractscrollarea_p.h" #include "QtGui/qtextdocumentfragment.h" #include "QtWidgets/qscrollbar.h" diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h index 5ab702e9d0..2dbb7240c5 100644 --- a/src/widgets/widgets/qprogressbar.h +++ b/src/widgets/widgets/qprogressbar.h @@ -40,6 +40,7 @@ #ifndef QPROGRESSBAR_H #define QPROGRESSBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index a3bb06c063..3b1440edb6 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -56,10 +56,10 @@ #include "qdebug.h" #include "qlayoutitem.h" #include "qdialogbuttonbox.h" -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include "private/qmacstyle_mac_p.h" #include "private/qmacstyle_mac_p_p.h" -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" @@ -254,11 +254,9 @@ QPushButton::QPushButton(QWidget *parent) */ QPushButton::QPushButton(const QString &text, QWidget *parent) - : QAbstractButton(*new QPushButtonPrivate, parent) + : QPushButton(parent) { - Q_D(QPushButton); setText(text); - d->init(); } @@ -270,12 +268,10 @@ QPushButton::QPushButton(const QString &text, QWidget *parent) */ QPushButton::QPushButton(const QIcon& icon, const QString &text, QWidget *parent) - : QAbstractButton(*new QPushButtonPrivate, parent) + : QPushButton(*new QPushButtonPrivate, parent) { - Q_D(QPushButton); setText(text); setIcon(icon); - d->init(); } /*! \internal @@ -419,7 +415,7 @@ QSize QPushButton::sizeHint() const QString s(text()); bool empty = s.isEmpty(); if (empty) - s = QString::fromLatin1("XXXX"); + s = QStringLiteral("XXXX"); QFontMetrics fm = fontMetrics(); QSize sz = fm.size(Qt::TextShowMnemonic, s); if(!empty || !w) @@ -679,7 +675,7 @@ bool QPushButton::event(QEvent *e) return QAbstractButton::event(e); } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC /*! \reimp */ bool QPushButton::hitButton(const QPoint &pos) const { @@ -708,7 +704,7 @@ bool QPushButtonPrivate::hitButton(const QPoint &pos) q->rect().height() - QMacStylePrivate::PushButtonBottomOffset); return roundedRect.contains(pos); } -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif QT_END_NAMESPACE diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index 0afd99bccc..859ac247fb 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -40,6 +40,7 @@ #ifndef QPUSHBUTTON_H #define QPUSHBUTTON_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE @@ -86,9 +87,9 @@ public Q_SLOTS: protected: bool event(QEvent *e) Q_DECL_OVERRIDE; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC bool hitButton(const QPoint &pos) const; -#endif // Q_DEAD_CODE_FROM_QT4_MAC +#endif void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h index 048f8aad2d..ee41c345c8 100644 --- a/src/widgets/widgets/qpushbutton_p.h +++ b/src/widgets/widgets/qpushbutton_p.h @@ -40,6 +40,7 @@ #ifndef QPUSHBUTTON_P_H #define QPUSHBUTTON_P_H +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qabstractbutton_p.h" // @@ -70,7 +71,7 @@ public: inline void init() { resetLayoutItemMargins(); } static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC bool hitButton(const QPoint &pos); #endif #ifndef QT_NO_MENU diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp index 55a584078a..284c5f56cf 100644 --- a/src/widgets/widgets/qradiobutton.cpp +++ b/src/widgets/widgets/qradiobutton.cpp @@ -155,10 +155,8 @@ QRadioButton::~QRadioButton() */ QRadioButton::QRadioButton(const QString &text, QWidget *parent) - : QAbstractButton(*new QRadioButtonPrivate, parent) + : QRadioButton(parent) { - Q_D(QRadioButton); - d->init(); setText(text); } diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h index 76f5c1aae4..2dcb0d0fdf 100644 --- a/src/widgets/widgets/qradiobutton.h +++ b/src/widgets/widgets/qradiobutton.h @@ -40,6 +40,7 @@ #ifndef QRADIOBUTTON_H #define QRADIOBUTTON_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp index 123c955684..c91f837093 100644 --- a/src/widgets/widgets/qrubberband.cpp +++ b/src/widgets/widgets/qrubberband.cpp @@ -47,7 +47,7 @@ #include "qstyle.h" #include "qstyleoption.h" -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC # include <private/qt_mac_p.h> # include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -142,12 +142,12 @@ QRubberBand::QRubberBand(Shape s, QWidget *p) Q_D(QRubberBand); d->shape = s; setAttribute(Qt::WA_TransparentForMouseEvents); -#ifndef Q_DEAD_CODE_FROM_QT4_WIN +#if 1 // Used to be excluded in Qt4 for Q_WS_WIN setAttribute(Qt::WA_NoSystemBackground); -#endif //Q_DEAD_CODE_FROM_QT4_WIN +#endif setAttribute(Qt::WA_WState_ExplicitShowHide); setVisible(false); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (isWindow()) { createWinId(); extern OSWindowRef qt_mac_window_for(const QWidget *); //qwidget_mac.cpp diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h index 30ca96abef..217261bf75 100644 --- a/src/widgets/widgets/qrubberband.h +++ b/src/widgets/widgets/qrubberband.h @@ -40,6 +40,7 @@ #ifndef QRUBBERBAND_H #define QRUBBERBAND_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h index c530ed23ed..92ce287566 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -40,6 +40,7 @@ #ifndef QSCROLLAREA_H #define QSCROLLAREA_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractscrollarea.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index c628d1485e..f7c0725dbe 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtWidgets/private/qtwidgetsglobal_p.h> #ifndef QT_NO_SCROLLAREA diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 7dd41f6a0c..79bfedb8c4 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -348,10 +348,8 @@ void QScrollBar::initStyleOption(QStyleOptionSlider *option) const initial \l {QAbstractSlider::value} {value} of 0. */ QScrollBar::QScrollBar(QWidget *parent) - : QAbstractSlider(*new QScrollBarPrivate, parent) + : QScrollBar(Qt::Vertical, parent) { - d_func()->orientation = Qt::Vertical; - d_func()->init(); } /*! @@ -397,12 +395,6 @@ void QScrollBarPrivate::init() q->setSizePolicy(sp); q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); q->setAttribute(Qt::WA_OpaquePaintEvent); - -#if !defined(QT_NO_CONTEXTMENU) && defined(Q_OS_WINCE) - if (!q->style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, q)) { - q->setContextMenuPolicy(Qt::PreventContextMenu); - } -#endif } #ifndef QT_NO_CONTEXTMENU diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h index 4c4a374917..2b8a110c99 100644 --- a/src/widgets/widgets/qscrollbar.h +++ b/src/widgets/widgets/qscrollbar.h @@ -40,6 +40,7 @@ #ifndef QSCROLLBAR_H #define QSCROLLBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtWidgets/qabstractslider.h> diff --git a/src/widgets/widgets/qscrollbar_p.h b/src/widgets/widgets/qscrollbar_p.h index 97ea27afdb..e748edf6a9 100644 --- a/src/widgets/widgets/qscrollbar_p.h +++ b/src/widgets/widgets/qscrollbar_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qabstractslider_p.h" #include "qstyle.h" diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index dd0b383d2b..5150601366 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -52,7 +52,7 @@ #include "qdebug.h" #include <QDesktopWidget> -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include <private/qt_mac_p.h> #endif @@ -82,7 +82,7 @@ public: Qt::Corner m_corner; bool gotMousePress; QPointer<QWidget> tlw; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC void updateMacSizer(bool hide) const; #endif Qt::Corner corner() const; @@ -120,7 +120,7 @@ public: updateTopLevelWidget(); if (tlw && showSizeGrip) { Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC sizeGripNotVisibleState |= Qt::WindowMaximized; #endif // Don't show the size grip if the tlw is maximized or in full screen mode. @@ -142,7 +142,7 @@ QSizeGripPrivate::QSizeGripPrivate() { } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC void QSizeGripPrivate::updateMacSizer(bool hide) const { Q_Q(const QSizeGrip); @@ -225,7 +225,7 @@ void QSizeGripPrivate::init() Q_Q(QSizeGrip); m_corner = q->isLeftToRight() ? Qt::BottomRightCorner : Qt::BottomLeftCorner; -#if !defined(QT_NO_CURSOR) && !defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if !defined(QT_NO_CURSOR) && !0 /* Used to be included in Qt4 for Q_WS_MAC */ q->setCursor(m_corner == Qt::TopLeftCorner || m_corner == Qt::BottomRightCorner ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor); #endif @@ -438,7 +438,7 @@ void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/) return; d->m_corner = d->corner(); -#if !defined(QT_NO_CURSOR) && !defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if !defined(QT_NO_CURSOR) && !0 /* Used to be included in Qt4 for Q_WS_MAC */ setCursor(d->m_corner == Qt::TopLeftCorner || d->m_corner == Qt::BottomRightCorner ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor); #endif @@ -449,7 +449,7 @@ void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/) */ void QSizeGrip::showEvent(QShowEvent *showEvent) { -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC d_func()->updateMacSizer(false); #endif QWidget::showEvent(showEvent); @@ -460,7 +460,7 @@ void QSizeGrip::showEvent(QShowEvent *showEvent) */ void QSizeGrip::hideEvent(QHideEvent *hideEvent) { -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC d_func()->updateMacSizer(true); #endif QWidget::hideEvent(hideEvent); @@ -484,7 +484,7 @@ bool QSizeGrip::eventFilter(QObject *o, QEvent *e) return QWidget::eventFilter(o, e); } Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC sizeGripNotVisibleState |= Qt::WindowMaximized; #endif // Don't show the size grip if the tlw is maximized or in full screen mode. diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h index a0e7de4fd8..831b146dd2 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -40,6 +40,7 @@ #ifndef QSIZEGRIP_H #define QSIZEGRIP_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp index 7b675fccbd..744a43253a 100644 --- a/src/widgets/widgets/qslider.cpp +++ b/src/widgets/widgets/qslider.cpp @@ -284,10 +284,8 @@ QStyle::SubControl QSliderPrivate::newHoverControl(const QPoint &pos) Constructs a vertical slider with the given \a parent. */ QSlider::QSlider(QWidget *parent) - : QAbstractSlider(*new QSliderPrivate, parent) + : QSlider(Qt::Vertical, parent) { - d_func()->orientation = Qt::Vertical; - d_func()->init(); } /*! diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h index 66b52c99bd..33b90ece06 100644 --- a/src/widgets/widgets/qslider.h +++ b/src/widgets/widgets/qslider.h @@ -40,6 +40,7 @@ #ifndef QSLIDER_H #define QSLIDER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractslider.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index 3464aa86e6..2e77f0be7a 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -40,6 +40,7 @@ #ifndef QSPINBOX_H #define QSPINBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractspinbox.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index 23588004a7..de58d86592 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -40,6 +40,7 @@ #ifndef QSPLASHSCREEN_H #define QSPLASHSCREEN_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtGui/qpixmap.h> #include <QtWidgets/qwidget.h> diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 17b7a9ebb3..910904e96e 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -941,11 +941,8 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w) \sa setOrientation() */ QSplitter::QSplitter(QWidget *parent) - : QFrame(*new QSplitterPrivate, parent) + : QSplitter(Qt::Horizontal, parent) { - Q_D(QSplitter); - d->orient = Qt::Horizontal; - d->init(); } diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index a99bc1c78f..9cfde9fed3 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -40,6 +40,7 @@ #ifndef QSPLITTER_H #define QSPLITTER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> #include <QtWidgets/qsizepolicy.h> diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index 8bd44fab2b..4422d9a8a4 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qframe_p.h" #include "qrubberband.h" diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h index 266c59134b..36088ae033 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -40,6 +40,7 @@ #ifndef QSTACKEDWIDGET_H #define QSTACKEDWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index 7de1d92acf..bdf728ead2 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -87,7 +87,7 @@ public: int savedStrut; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC QPoint dragStart; #endif @@ -746,12 +746,9 @@ bool QStatusBar::event(QEvent *e) // On Mac OS X Leopard it is possible to drag the window by clicking // on the tool bar on most applications. -#ifndef Q_DEAD_CODE_FROM_QT4_MAC +#if 1 // Used to be excluded in Qt4 for Q_WS_MAC return QWidget::event(e); #else - if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_4) - return QWidget::event(e); - // Enable drag-click only if the status bar is the status bar for a // QMainWindow with a unifed toolbar. if (parent() == 0 || qobject_cast<QMainWindow *>(parent()) == 0 || diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index 45416e46b3..aaabb99a27 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -40,6 +40,7 @@ #ifndef QSTATUSBAR_H #define QSTATUSBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 73d5d73f92..6e34198f67 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -63,7 +63,7 @@ #ifndef QT_NO_TABBAR -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -1927,7 +1927,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event) d->moveTabFinished(d->pressedIndex); d->pressedIndex = d->indexAtPos(event->pos()); -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC d->previousPressedIndex = d->pressedIndex; #endif if (d->validIndex(d->pressedIndex)) { @@ -2009,7 +2009,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) update(); } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { int newPressedIndex = d->indexAtPos(event->pos()); if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { @@ -2107,7 +2107,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) event->ignore(); return; } -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC d->previousPressedIndex = -1; #endif if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { @@ -2552,6 +2552,34 @@ QWidget *QTabBar::tabButton(int index, ButtonPosition position) const return d->tabList.at(index).rightWidget; } +#ifndef QT_NO_ACCESSIBILITY +/*! + Sets the accessibleName of the tab at position \a index to \a name. +*/ +void QTabBar::setAccessibleTabName(int index, const QString &name) +{ + Q_D(QTabBar); + if (QTabBarPrivate::Tab *tab = d->at(index)) { + tab->accessibleName = name; + QAccessibleEvent event(this, QAccessible::NameChanged); + event.setChild(index); + QAccessible::updateAccessibility(&event); + } +} + +/*! + Returns the accessibleName of the tab at position \a index, or an empty + string if \a index is out of range. +*/ +QString QTabBar::accessibleTabName(int index) const +{ + Q_D(const QTabBar); + if (const QTabBarPrivate::Tab *tab = d->at(index)) + return tab->accessibleName; + return QString(); +} +#endif // QT_NO_ACCESSIBILITY + CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent) { diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index 138c5470c6..71ca58c993 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -40,6 +40,7 @@ #ifndef QTABBAR_H #define QTABBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> QT_BEGIN_NAMESPACE @@ -172,6 +173,11 @@ public: bool changeCurrentOnDrag() const; void setChangeCurrentOnDrag(bool change); +#ifndef QT_NO_ACCESSIBILITY + QString accessibleTabName(int index) const; + void setAccessibleTabName(int index, const QString &name); +#endif + public Q_SLOTS: void setCurrentIndex(int index); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index a73c3e11e2..e8d5503fdf 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qtabbar.h" #include "private/qwidget_p.h" @@ -90,7 +91,7 @@ public: selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false), switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(0) -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC , previousPressedIndex(-1) #endif {} @@ -131,6 +132,9 @@ public: QWidget *rightWidget; int lastTab; int dragOffset; +#ifndef QT_NO_ACCESSIBILITY + QString accessibleName; +#endif #ifndef QT_NO_ANIMATION ~Tab() { delete animation; } @@ -224,7 +228,7 @@ public: int switchTabTimerId; QMovableTabWidget *movingTab; -#ifdef Q_DEAD_CODE_FROM_QT4_MAC +#if 0 // Used to be included in Qt4 for Q_WS_MAC int previousPressedIndex; #endif // shared by tabwidget and qtabbar diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index c931fb9b83..59fcea223f 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -40,6 +40,7 @@ #ifndef QTABWIDGET_H #define QTABWIDGET_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qwidget.h> #include <QtGui/qicon.h> diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h index 018c617f88..48b64d1216 100644 --- a/src/widgets/widgets/qtextbrowser.h +++ b/src/widgets/widgets/qtextbrowser.h @@ -40,6 +40,7 @@ #ifndef QTEXTBROWSER_H #define QTEXTBROWSER_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtextedit.h> #include <QtCore/qurl.h> diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index f354495e70..66bf2919eb 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -184,7 +184,7 @@ void QTextEditPrivate::init(const QString &html) #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); #endif -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN setSingleFingerPanEnabled(true); #endif } diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 68ad54152b..3b523e3ed0 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -40,6 +40,7 @@ #ifndef QTEXTEDIT_H #define QTEXTEDIT_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractscrollarea.h> #include <QtGui/qtextdocument.h> #include <QtGui/qtextoption.h> diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h index c2f41aca66..cca315ce30 100644 --- a/src/widgets/widgets/qtextedit_p.h +++ b/src/widgets/widgets/qtextedit_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "private/qabstractscrollarea_p.h" #include "QtGui/qtextdocumentfragment.h" #include "QtWidgets/qscrollbar.h" diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index e7d3f841d5..2a0912df0a 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -322,7 +322,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) startDrag(moving); if (!moving && !wasDragging) { -#ifdef Q_DEAD_CODE_FROM_QT4_WIN +#if 0 // Used to be included in Qt4 for Q_WS_WIN grabMouseWhileInWindow(); #else q->grabMouse(); @@ -520,10 +520,8 @@ QToolBar::QToolBar(QWidget *parent) \sa setWindowTitle() */ QToolBar::QToolBar(const QString &title, QWidget *parent) - : QWidget(*new QToolBarPrivate, parent, 0) + : QToolBar(parent) { - Q_D(QToolBar); - d->init(); setWindowTitle(title); } @@ -1186,17 +1184,6 @@ bool QToolBar::event(QEvent *event) if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))) return true; break; -#ifdef Q_OS_WINCE - case QEvent::ContextMenu: - { - QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event); - QWidget* child = childAt(contextMenuEvent->pos()); - QAbstractButton* button = qobject_cast<QAbstractButton*>(child); - if (button) - button->setDown(false); - } - break; -#endif case QEvent::Leave: if (d->state != 0 && d->state->dragging) { #ifdef Q_OS_WIN diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 774d47b913..d361513bbf 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -40,6 +40,7 @@ #ifndef QDYNAMICTOOLBAR_H #define QDYNAMICTOOLBAR_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qaction.h> #include <QtWidgets/qwidget.h> @@ -100,11 +101,17 @@ public: QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member); #ifdef Q_QDOC + template<typename PointerToMemberFunction> QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method); + template<typename Functor> QAction *addAction(const QString &text, Functor functor); + template<typename Functor> QAction *addAction(const QString &text, const QObject *context, Functor functor); + template<typename PointerToMemberFunction> QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method); + template<typename Functor> QAction *addAction(const QIcon &icon, const QString &text, Functor functor); + template<typename Functor> QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor); #else // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 7782b56962..616f53f717 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qtoolbar.h" #include "QtWidgets/qaction.h" #include "private/qwidget_p.h" diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index a1ae68130c..901f04cf14 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QList> #include <QSize> #include <QRect> diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h index ea159ce986..c4d803165c 100644 --- a/src/widgets/widgets/qtoolbarextension_p.h +++ b/src/widgets/widgets/qtoolbarextension_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qtoolbutton.h" QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index 1f93f04a53..9a81c4e50e 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/qlayout.h> #include <private/qlayoutengine_p.h> #include <QVector> diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h index 38e1f130f6..8c9cf9f46a 100644 --- a/src/widgets/widgets/qtoolbarseparator_p.h +++ b/src/widgets/widgets/qtoolbarseparator_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtWidgets/qwidget.h" QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h index 2e32668193..6556d8a202 100644 --- a/src/widgets/widgets/qtoolbox.h +++ b/src/widgets/widgets/qtoolbox.h @@ -40,6 +40,7 @@ #ifndef QTOOLBOX_H #define QTOOLBOX_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qframe.h> #include <QtGui/qicon.h> diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 7b6114b5c1..95d159f12d 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -40,6 +40,7 @@ #ifndef QTOOLBUTTON_H #define QTOOLBUTTON_H +#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h index 4f16f7b3e5..90be22c271 100644 --- a/src/widgets/widgets/qwidgetanimator_p.h +++ b/src/widgets/widgets/qwidgetanimator_p.h @@ -44,13 +44,14 @@ // W A R N I N G // ------------- // -// This file is not part of the Qt API. It exists for the convenience -// of the QLibrary class. This header file may change from -// version to version without notice, or even be removed. +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <qobject.h> #include <qhash.h> #include <qpointer.h> diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 8b6b76c55e..9b65dc43d1 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -72,7 +72,7 @@ int QWidgetLineControl::redoTextLayout() const QTextLine l = m_textLayout.createLine(); m_textLayout.endLayout(); -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (m_threadChecks) m_textLayoutThread = QThread::currentThread(); #endif @@ -441,7 +441,7 @@ QRect QWidgetLineControl::anchorRect() const { if (!hasSelectedText()) return cursorRect(); - return rectForPos(m_selstart < m_selend ? m_selstart : m_selend); + return rectForPos(m_cursor == m_selstart ? m_selend : m_selstart); } /*! diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 5e52e29a51..d4a4534fb5 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtWidgets/private/qtwidgetsglobal_p.h> #ifndef QT_NO_LINEEDIT #include "private/qwidget_p.h" @@ -91,7 +91,7 @@ public: m_selstart(0), m_selend(0), m_passwordEchoEditing(false) , m_passwordEchoTimer(0) , m_passwordMaskDelay(-1) -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if 0 // Used to be included in Qt4 for Q_WS_MAC , m_threadChecks(false) , m_textLayoutThread(0) #endif @@ -382,14 +382,14 @@ public: QTextLayout *textLayout() const { -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if 0 // Used to be included in Qt4 for Q_WS_MAC if (m_threadChecks && QThread::currentThread() != m_textLayoutThread) redoTextLayout(); #endif return &m_textLayout; } -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if 0 // Used to be included in Qt4 for Q_WS_MAC void setThreadChecks(bool threadChecks) { m_threadChecks = threadChecks; @@ -512,7 +512,7 @@ private: } int redoTextLayout() const; -#if defined(Q_DEAD_CODE_FROM_QT4_MAC) +#if 0 // Used to be included in Qt4 for Q_WS_MAC bool m_threadChecks; mutable QThread *m_textLayoutThread; #endif diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 2a7b1eeecc..016598849b 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -120,7 +120,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos()))) return false; if (e->button() == Qt::LeftButton) { -#if defined(Q_DEAD_CODE_FROM_QT4_X11) +#if 0 // Used to be included in Qt4 for Q_WS_X11 /* Implicit grabs do not stop the X server from changing the cursor in children, which looks *really* bad when @@ -134,7 +134,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) # else widget->grabMouse(); # endif // QT_NO_CURSOR -#endif // Q_DEAD_CODE_FROM_QT4_X11 +#endif buttonDown = false; emit activate(); bool me = movingEnabled; diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index b955d8b7c3..7bb7d6cd94 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtCore/qobject.h" #include "QtCore/qpoint.h" diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 4e47f30b84..b45f4fff74 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtGui/qtextdocument.h> #include <QtGui/qtextoption.h> #include <QtGui/qtextcursor.h> diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index fea72d98ff..35027ff82a 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "QtGui/qtextdocumentfragment.h" #include "QtWidgets/qscrollbar.h" #include "QtGui/qtextcursor.h" diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 784055ed62..abba3e0472 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -155,19 +155,3 @@ macx { widgets/qmacnativewidget_mac.mm \ widgets/qmaccocoaviewcontainer_mac.mm } - -wince { - SOURCES += widgets/qmenu_wince.cpp - HEADERS += widgets/qmenu_wince_resource_p.h - RC_FILE = widgets/qmenu_wince.rc - !static: QMAKE_WRITE_DEFAULT_RC = 1 - !isEmpty(QT_LIBINFIX) { - ORIG_RCFILE = $${TARGET}_resource.rc - copyrcc.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} - copyrcc.input = ORIG_RCFILE - CONFIG(debug, debug|release):copyrcc.output = $${ORIG_TARGET}d_resource.rc - else:copyrcc.output = $${ORIG_TARGET}_resource.rc - copyrcc.CONFIG = target_predeps no_link - QMAKE_EXTRA_COMPILERS += copyrcc - } -} |