diff options
Diffstat (limited to 'src/widgets')
29 files changed, 146 insertions, 80 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index ea3b88468b..397a58a5d4 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -41,7 +41,6 @@ #include <qaccessible.h> #include <qapplication.h> -#include <qabstractbutton.h> #include <qevent.h> #include <qheaderview.h> #include <qtabbar.h> diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index c95b5b1097..e7db53c251 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -103,11 +103,13 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QToolButton")) { iface = new QAccessibleToolButton(widget); #endif // QT_NO_TOOLBUTTON +#if QT_CONFIG(abstractbutton) } else if (classname == QLatin1String("QCheckBox") || classname == QLatin1String("QRadioButton") || classname == QLatin1String("QPushButton") || classname == QLatin1String("QAbstractButton")) { iface = new QAccessibleButton(widget); +#endif } else if (classname == QLatin1String("QDialog")) { iface = new QAccessibleWidget(widget, QAccessible::Dialog); } else if (classname == QLatin1String("QMessageBox")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 40aca37f11..7f77f7c524 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -64,7 +64,6 @@ #include <QAbstractItemView> #include <QDockWidget> #include <QMainWindow> -#include <QAbstractButton> #include <private/qdockwidget_p.h> #include <QFocusFrame> diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 113172ff5a..a53e5eaf30 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -39,7 +39,9 @@ #include "simplewidgets_p.h" +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> +#endif #if QT_CONFIG(checkbox) #include <qcheckbox.h> #endif @@ -80,6 +82,7 @@ extern QList<QWidget*> childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); +#if QT_CONFIG(abstractbutton) /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -267,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c } return QStringList(); } - +#endif // QT_CONFIG(abstractbutton) #ifndef QT_NO_TOOLBUTTON /*! @@ -519,7 +522,7 @@ QString QAccessibleDisplay::imageDescription() const #ifndef QT_NO_TOOLTIP return widget()->toolTip(); #else - return QString::null; + return QString(); #endif } diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index 8bd0af8261..1e4ae5ab67 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -65,6 +65,7 @@ class QToolButton; class QGroupBox; class QProgressBar; +#if QT_CONFIG(abstractbutton) class QAccessibleButton : public QAccessibleWidget { Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) @@ -83,6 +84,7 @@ public: protected: QAbstractButton *button() const; }; +#endif #ifndef QT_NO_TOOLBUTTON class QAccessibleToolButton : public QAccessibleButton diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 99e1bd6940..14e4d10d38 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -117,6 +117,12 @@ "condition": "features.tableview", "output": [ "publicFeature", "feature" ] }, + "abstractbutton": { + "label": "QAbstractButton", + "purpose": "Abstract base class of button widgets, providing functionality common to buttons.", + "section": "Widgets", + "output": [ "publicFeature" ] + }, "commandlinkbutton": { "label": "QCommandLinkButton", "purpose": "Provides a Vista style command link button.", @@ -193,6 +199,7 @@ "label": "QRadioButton", "purpose": "Provides a radio button with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "spinbox": { @@ -234,20 +241,21 @@ "label": "QCheckBox(", "purpose": "Provides a checkbox with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "pushbutton": { "label": "QPushButton", "purpose": "Provides a command button.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature" ] }, "toolbutton": { "label": "QToolButton", "purpose": "Provides quick-access buttons to commands and options.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature", "feature" ] }, "toolbar": { @@ -274,7 +282,7 @@ "label": "QButtonGroup", "purpose": "Supports organizing groups of button widgets.", "section": "Widgets", - "condition": "features.groupbox", + "condition": "features.abstractbutton && features.groupbox", "output": [ "publicFeature", "feature" ] }, "mainwindow": { diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index bd5bf08bb8..f2b8b66fed 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -4516,7 +4516,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) otherwise, \a matrix \e replaces the current matrix. \a combine is false by default. - To simplify interation with items using a transformed view, QGraphicsItem + To simplify interaction with items using a transformed view, QGraphicsItem provides mapTo... and mapFrom... functions that can translate between items' and the scene's coordinates. For example, you can call mapToScene() to map an item coordiate to a scene coordinate, or mapFromScene() to map diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index c7cc1d155e..ed6482a8bc 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -49,7 +49,9 @@ #include <qevent.h> #include <qbitarray.h> #include <qscrollbar.h> +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> +#endif #include <private/qtableview_p.h> #include <private/qheaderview_p.h> #include <private/qscrollbar_p.h> @@ -578,6 +580,7 @@ bool QSpanCollection::checkConsistency() const } #endif +#if QT_CONFIG(abstractbutton) class QTableCornerButton : public QAbstractButton { Q_OBJECT @@ -600,6 +603,7 @@ public: style()->drawControl(QStyle::CE_Header, &opt, &painter, this); } }; +#endif void QTableViewPrivate::init() { @@ -619,9 +623,11 @@ void QTableViewPrivate::init() tabKeyNavigation = true; +#if QT_CONFIG(abstractbutton) cornerWidget = new QTableCornerButton(q); cornerWidget->setFocusPolicy(Qt::NoFocus); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); +#endif } /*! @@ -2121,6 +2127,7 @@ void QTableView::updateGeometries() if (d->horizontalHeader->isHidden()) QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); +#if QT_CONFIG(abstractbutton) // update cornerWidget if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) { d->cornerWidget->setHidden(true); @@ -2128,6 +2135,7 @@ void QTableView::updateGeometries() d->cornerWidget->setHidden(false); d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); } +#endif // update scroll bars @@ -2642,6 +2650,7 @@ bool QTableView::wordWrap() const return d->wrapItemText; } +#if QT_CONFIG(abstractbutton) /*! \property QTableView::cornerButtonEnabled \brief whether the button in the top-left corner is enabled @@ -2664,6 +2673,7 @@ bool QTableView::isCornerButtonEnabled() const Q_D(const QTableView); return d->cornerWidget->isEnabled(); } +#endif /*! \internal diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index 8c9ac379bc..b1c38d521f 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -58,7 +58,9 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) +#if QT_CONFIG(abstractbutton) Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) +#endif public: explicit QTableView(QWidget *parent = Q_NULLPTR); @@ -103,8 +105,10 @@ public: void setWordWrap(bool on); bool wordWrap() const; +#if QT_CONFIG(abstractbutton) void setCornerButtonEnabled(bool enable); bool isCornerButtonEnabled() const; +#endif QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE; void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 2ca158d657..d2f45d557d 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -192,7 +192,9 @@ public: QVector<int> rowsToUpdate; QHeaderView *horizontalHeader; QHeaderView *verticalHeader; +#if QT_CONFIG(abstractbutton) QWidget *cornerWidget; +#endif bool sortingEnabled; bool geometryRecursionBlock; QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index ee0c28ec76..51793bf060 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -767,7 +767,7 @@ QWidgetItemV2::QWidgetItemV2(QWidget *widget) QWidgetItemV2::~QWidgetItemV2() { if (wid) { - QWidgetPrivate *wd = wid->d_func(); + auto *wd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(wid)); if (wd->widgetItem == this) wd->widgetItem = 0; } diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 4d45782170..e401444e6e 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -537,6 +537,7 @@ public: w(widget) { } void beginPaint() Q_DECL_OVERRIDE; + void endPaint() Q_DECL_OVERRIDE; QOpenGLWidget *w; }; @@ -634,6 +635,16 @@ void QOpenGLWidgetPaintDevicePrivate::beginPaint() } } +void QOpenGLWidgetPaintDevicePrivate::endPaint() +{ + QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(w)); + if (!wd->initialized) + return; + + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0; +} + void QOpenGLWidgetPaintDevice::ensureActiveTarget() { QOpenGLWidgetPaintDevicePrivate *d = static_cast<QOpenGLWidgetPaintDevicePrivate *>(d_ptr.data()); @@ -646,6 +657,9 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget() else wd->fbo->bind(); + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbo->handle(); + // When used as a viewport, drawing is done via opening a QPainter on the widget // without going through paintEvent(). We will have to make sure a glFlush() is done // before the texture is accessed also in this case. diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 62d723bea5..1452bb36ae 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9199,7 +9199,8 @@ bool QWidget::event(QEvent *event) const QWindow *win = te->window; d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); } - d->updateFont(d->data.fnt); + if (d->data.fnt.d->dpi != logicalDpiY()) + d->updateFont(d->data.fnt); #ifndef QT_NO_OPENGL d->renderToTextureReallyDirty = 1; #endif diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 1267907303..98d45587f0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -45,7 +45,8 @@ #include <qcombobox.h> #if QT_CONFIG(pushbutton) #include <qpushbutton.h> -#else +#endif +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> #endif #include <qpainter.h> @@ -55,7 +56,6 @@ #include <qmainwindow.h> #include <qfont.h> #include <qgroupbox.h> -#include <qprocess.h> #include <qpixmapcache.h> #include <qscrollbar.h> #include <qspinbox.h> @@ -66,7 +66,6 @@ #include <qsplitter.h> #include <qprogressbar.h> #include <qwizard.h> -#include <qlibrary.h> #include <qdrawutil.h> #include <private/qstylehelper_p.h> #include <private/qdrawhelper_p.h> @@ -3284,7 +3283,10 @@ void QFusionStyle::polish(QApplication *app) void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) #endif @@ -3325,7 +3327,10 @@ void QFusionStyle::polish(QPalette &pal) void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) #endif diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d9d30efc8b..47193f2a84 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1076,11 +1076,6 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) verticalShift = -verticalShift; tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding); - const bool selected = opt->state & QStyle::State_Selected; - if (selected) { - tr.setTop(tr.top() - verticalShift); - tr.setRight(tr.right() - horizontalShift); - } // left widget if (!opt->leftButtonSize.isEmpty()) { @@ -2487,7 +2482,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case QAquaSizeUnknown: const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt); if (tb && tb->documentMode) - ret = 24; + ret = 30; else ret = QCommonStyle::pixelMetric(metric, opt, widget); break; @@ -6584,7 +6579,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = sz.transposed(); int defaultTabHeight; int extraHSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); - int extraVSpace = proxy()->pixelMetric(PM_TabBarTabVSpace, tab, widget); QFontMetrics fm = opt->fontMetrics; switch (AquaSize) { case QAquaSizeUnknown: @@ -6604,13 +6598,13 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool setWidth = false; if (differentFont || !tab->icon.isNull()) { sz.rheight() = qMax(defaultTabHeight, sz.height()); - sz.rwidth() += extraHSpace; } else { QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text); sz.rheight() = qMax(defaultTabHeight, textSize.height()); - sz.rwidth() = textSize.width() + extraVSpace; + sz.rwidth() = textSize.width(); setWidth = true; } + sz.rwidth() += extraHSpace; if (vertTabs) sz = sz.transposed(); @@ -6724,7 +6718,15 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, break; } case CT_Menu: { - sz = csz; + if (proxy() == this) { + sz = csz; + } else { + QStyleHintReturnMask menuMask; + QStyleOption myOption = *opt; + myOption.rect.setSize(sz); + if (proxy()->styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) + sz = menuMask.region.boundingRect().size(); + } break; } case CT_HeaderSection:{ const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt); diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 59f6e893b1..9bbd0995a5 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -95,7 +95,6 @@ #include <qtableview.h> #include <qwizard.h> #include <qdebug.h> -#include <qlibrary.h> #include <qdatetimeedit.h> #include <qmath.h> #include <qpair.h> diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 7dc1c35333..2b9f042862 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4269,6 +4269,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelButtonTool: case PE_PanelButtonCommand: +#if QT_CONFIG(abstractbutton) if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) { //the window style will draw the borders ParentStyle::drawPrimitive(pe, opt, p, w); @@ -4277,6 +4278,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } return; } +#endif if (!rule.hasNativeBorder()) { rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); return; diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index ec7c2caad3..db358e6f6c 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -58,7 +58,6 @@ #include <private/qwindowsxpstyle_p_p.h> #include <private/qstyleanimation_p.h> #include <private/qpaintengine_raster_p.h> -#include <qlibrary.h> #include <qpaintengine.h> #include <qwidget.h> #include <qapplication.h> diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f3c6069f8a..b50c4b6be4 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1139,7 +1139,10 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!QWindowsXPStylePrivate::useXP()) return; - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif || qobject_cast<QToolButton*>(widget) || qobject_cast<QTabBar*>(widget) #ifndef QT_NO_COMBOBOX @@ -1211,7 +1214,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget) // already in the map might be old (other style). d->cleanupHandleMap(); } - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif || qobject_cast<QToolButton*>(widget) || qobject_cast<QTabBar*>(widget) #ifndef QT_NO_COMBOBOX diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7bf0e0b9d6..4e438bd851 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -45,6 +45,8 @@ #include <QtGui/qkeysequence.h> #include <QtWidgets/qwidget.h> +QT_REQUIRE_CONFIG(abstractbutton); + QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index d091d1e970..abdd946c49 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -65,7 +65,6 @@ #include <private/qt_cocoa_helpers_mac_p.h> #endif #ifdef Q_OS_WIN -# include <qlibrary.h> # include <qt_windows.h> #endif diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 5a789c2d66..a3e55114bb 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -711,8 +711,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) return; // Remove it from the standard button hash first and then from the roles - if (QPushButton *pushButton = qobject_cast<QPushButton *>(button)) - d->standardButtonHash.remove(pushButton); + d->standardButtonHash.remove(reinterpret_cast<QPushButton *>(button)); for (int i = 0; i < NRoles; ++i) { QList<QAbstractButton *> &list = d->buttonLists[i]; for (int j = 0; j < list.count(); ++j) { @@ -878,7 +877,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonDestroyed() Q_Q(QDialogButtonBox); if (QObject *object = q->sender()) { QBoolBlocker skippy(internalRemove); - q->removeButton(static_cast<QAbstractButton *>(object)); + q->removeButton(reinterpret_cast<QAbstractButton *>(object)); } } diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index fa0cff45c9..39e072234e 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -41,7 +41,9 @@ #include "qevent.h" #include "qdrawutil.h" #include "qapplication.h" +#if QT_CONFIG(abstractbutton) #include "qabstractbutton.h" +#endif #include "qstyle.h" #include "qstyleoption.h" #include <limits.h> @@ -972,12 +974,14 @@ bool QLabel::event(QEvent *e) QShortcutEvent *se = static_cast<QShortcutEvent *>(e); if (se->shortcutId() == d->shortcutId) { QWidget * w = d->buddy; - QAbstractButton *button = qobject_cast<QAbstractButton *>(w); if (w->focusPolicy() != Qt::NoFocus) w->setFocus(Qt::ShortcutFocusReason); +#if QT_CONFIG(abstractbutton) + QAbstractButton *button = qobject_cast<QAbstractButton *>(w); if (button && !se->isAmbiguous()) button->animateClick(); else +#endif window()->setAttribute(Qt::WA_KeyboardFocusChange); return true; } diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 5ea86a592e..b348c8090d 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1856,7 +1856,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar() topLevelWindow->removeEventFilter(q); if (baseWidget && !drawTitleBarWhenMaximized()) topLevelWindow->setWindowModified(false); - originalTitle = QString::null; + originalTitle.clear(); } #endif // QT_NO_MENUBAR @@ -2760,7 +2760,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) #ifndef QT_NO_MENUBAR } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { - d->originalTitle = QString::null; + d->originalTitle.clear(); if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle()) d->updateWindowTitle(true); else diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 295fb7d89c..4e55f0b132 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -401,17 +401,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const itemsDirty = 0; } -QSize QMenuPrivate::adjustMenuSizeForScreen(const QRect &screen) -{ - Q_Q(QMenu); - QSize ret = screen.size(); - itemsDirty = true; - updateActionRects(screen); - const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - ret.setWidth(actionRects.at(getLastVisibleAction()).right() + fw); - return ret; -} - int QMenuPrivate::getLastVisibleAction() const { //let's try to get the last visible action @@ -2266,7 +2255,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction) else pos = p; - QSize size = sizeHint(); + const QSize menuSizeHint(sizeHint()); + QSize size = menuSizeHint; QRect screen; #ifndef QT_NO_GRAPHICSVIEW bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); @@ -2279,13 +2269,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction) bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); // if the screens have very different geometries and the menu is too big, we have to recalculate - if (size.height() > screen.height() || size.width() > screen.width()) { - size = d->adjustMenuSizeForScreen(screen); - adjustToDesktop = true; - } - // Layout is not right, we might be able to save horizontal space - if (d->ncols >1 && size.height() < screen.height()) { - size = d->adjustMenuSizeForScreen(screen); + if ((size.height() > screen.height() || size.width() > screen.width()) || + // Layout is not right, we might be able to save horizontal space + (d->ncols >1 && size.height() < screen.height())) { + size.setWidth(qMin(menuSizeHint.width(), screen.width() - desktopFrame * 2)); + size.setHeight(qMin(menuSizeHint.height(), screen.height() - desktopFrame * 2)); adjustToDesktop = true; } @@ -2338,7 +2326,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->mousePopupPos = mouse; const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse)); - const QSize menuSize(sizeHint()); if (adjustToDesktop) { // handle popup falling "off screen" if (isRightToLeft()) { @@ -2372,7 +2359,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (pos.y() < screen.top() + desktopFrame) pos.setY(screen.top() + desktopFrame); - if (pos.y() + menuSize.height() - 1 > screen.bottom() - desktopFrame) { + if (pos.y() + menuSizeHint.height() - 1 > screen.bottom() - desktopFrame) { if (d->scroll) { d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); int y = qMax(screen.y(),pos.y()); @@ -2385,29 +2372,29 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget); - if (caused && caused->geometry().width() + menuSize.width() + subMenuOffset < screen.width()) { + if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) { QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction)); const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft()); parentActionRect.moveTopLeft(actionTopLeft); if (isRightToLeft()) { - if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset) + if ((pos.x() + menuSizeHint.width() > parentActionRect.left() - subMenuOffset) && (pos.x() < parentActionRect.right())) { - pos.rx() = parentActionRect.left() - menuSize.width(); + pos.rx() = parentActionRect.left() - menuSizeHint.width(); if (pos.x() < screen.x()) pos.rx() = parentActionRect.right(); - if (pos.x() + menuSize.width() > screen.x() + screen.width()) + if (pos.x() + menuSizeHint.width() > screen.x() + screen.width()) pos.rx() = screen.x(); } } else { if ((pos.x() < parentActionRect.right() + subMenuOffset) - && (pos.x() + menuSize.width() > parentActionRect.left())) + && (pos.x() + menuSizeHint.width() > parentActionRect.left())) { pos.rx() = parentActionRect.right(); - if (pos.x() + menuSize.width() > screen.x() + screen.width()) - pos.rx() = parentActionRect.left() - menuSize.width(); + if (pos.x() + menuSizeHint.width() > screen.x() + screen.width()) + pos.rx() = parentActionRect.left() - menuSizeHint.width(); if (pos.x() < screen.x()) - pos.rx() = screen.x() + screen.width() - menuSize.width(); + pos.rx() = screen.x() + screen.width() - menuSizeHint.width(); } } } @@ -3515,11 +3502,22 @@ void QMenu::internalDelayedPopup() d->activeMenu->d_func()->causedPopup.widget = this; d->activeMenu->d_func()->causedPopup.action = d->currentAction; + QRect screen; +#ifndef QT_NO_GRAPHICSVIEW + bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + if (isEmbedded) + screen = d->popupGeometry(this); + else +#endif + screen = d->popupGeometry(QApplication::desktop()->screenNumber(pos())); + int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); const QRect actionRect(d->actionRect(d->currentAction)); - const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); + QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); + if (subMenuPos.x() > screen.right()) + subMenuPos.setX(QCursor::pos().x()); - d->activeMenu->popup(rightPos); + d->activeMenu->popup(subMenuPos); d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); #if !defined(Q_OS_DARWIN) diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 64291e842f..898fa3161b 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -311,7 +311,6 @@ public: mutable uint ncols : 4; //4 bits is probably plenty uint collapsibleSeparators : 1; uint toolTipsVisible : 1; - QSize adjustMenuSizeForScreen(const QRect & screen); int getLastVisibleAction() const; bool activationRecursionGuard; diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 95d159f12d..e2470524da 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -41,13 +41,14 @@ #define QTOOLBUTTON_H #include <QtWidgets/qtwidgetsglobal.h> + +#if QT_CONFIG(toolbutton) + #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE -#ifndef QT_NO_TOOLBUTTON - class QToolButtonPrivate; class QMenu; class QStyleOptionToolButton; @@ -134,8 +135,8 @@ private: }; -#endif // QT_NO_TOOLBUTTON - QT_END_NAMESPACE +#endif // QT_CONFIG(toolbutton) + #endif // QTOOLBUTTON_H diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 016598849b..dc7353a6ca 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -112,9 +112,9 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) return false; } - QMouseEvent *e = (QMouseEvent*)ee; - switch (e->type()) { + switch (ee->type()) { case QEvent::MouseButtonPress: { + QMouseEvent *e = static_cast<QMouseEvent *>(ee); if (w->isMaximized()) break; if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos()))) @@ -155,7 +155,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) case QEvent::MouseButtonRelease: if (w->isMaximized()) break; - if (e->button() == Qt::LeftButton) { + if (static_cast<QMouseEvent *>(ee)->button() == Qt::LeftButton) { moveResizeMode = false; buttonDown = false; widget->releaseMouse(); @@ -171,6 +171,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) case QEvent::MouseMove: { if (w->isMaximized()) break; + QMouseEvent *e = static_cast<QMouseEvent *>(ee); buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); // safety, state machine broken! bool me = movingEnabled; movingEnabled = (me && o == widget && (buttonDown || moveResizeMode)); @@ -184,11 +185,11 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) } } break; case QEvent::KeyPress: - keyPressEvent((QKeyEvent*)e); + keyPressEvent(static_cast<QKeyEvent *>(ee)); break; case QEvent::ShortcutOverride: if (buttonDown) { - ((QKeyEvent*)ee)->accept(); + ee->accept(); return true; } break; diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index f67640e40f..22e083a3d4 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qbuttongroup.h \ widgets/qbuttongroup_p.h \ - widgets/qabstractbutton.h \ - widgets/qabstractbutton_p.h \ widgets/qabstractspinbox.h \ widgets/qabstractspinbox_p.h \ widgets/qcalendarwidget.h \ @@ -76,7 +74,6 @@ HEADERS += \ SOURCES += \ widgets/qbuttongroup.cpp \ - widgets/qabstractbutton.cpp \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ widgets/qcombobox.cpp \ @@ -128,6 +125,15 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp +qtConfig(abstractbutton) { + HEADERS += \ + widgets/qabstractbutton.h \ + widgets/qabstractbutton_p.h + + SOURCES += \ + widgets/qabstractbutton.cpp +} + qtConfig(abstractslider) { HEADERS += \ widgets/qabstractslider.h \ |