diff options
Diffstat (limited to 'src/widgets')
72 files changed, 568 insertions, 537 deletions
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index c96d213e7b..27e6b09dc7 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -273,22 +273,6 @@ QRect QAccessibleWidget::rect() const return QRect(wpos.x(), wpos.y(), w->width(), w->height()); } -QT_BEGIN_INCLUDE_NAMESPACE -#include <private/qobject_p.h> -QT_END_INCLUDE_NAMESPACE - -class QACConnectionObject : public QObject -{ - Q_DECLARE_PRIVATE(QObject) -public: - inline bool isSender(const QObject *receiver, const char *signal) const - { return d_func()->isSender(receiver, signal); } - inline QObjectList receiverList(const char *signal) const - { return d_func()->receiverList(signal); } - inline QObjectList senderList() const - { return d_func()->senderList(); } -}; - /*! Registers \a signal as a controlling signal. @@ -347,9 +331,9 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel if (match & QAccessible::Controlled) { QObjectList allReceivers; - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); + QObject *connectionObject = object(); for (int sig = 0; sig < d->primarySignals.count(); ++sig) { - const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1()); + const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1()); allReceivers += receivers; } diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 5692a16bce..3cdd9a5f04 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -282,7 +282,7 @@ void QDialogPrivate::deletePlatformHelper() progress dialogs, where the user must have the ability to interact with the dialog, e.g. to cancel a long running operation. If you use show() and setModal(true) together to perform a long operation, - you must call QApplication::processEvents() periodically during + you must call QCoreApplication::processEvents() periodically during processing to enable the user to interact with the dialog. (See QProgressDialog.) @@ -691,7 +691,7 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e) if (p.data()->exec(e->globalPos()) == wt) { QHelpEvent e(QEvent::WhatsThis, w->rect().center(), w->mapToGlobal(w->rect().center())); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } delete p.data(); } @@ -826,7 +826,7 @@ QT_WARNING_POP #endif if (fw && !fw->hasFocus()) { QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); - QApplication::sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index 51a3e080bf..f0ec2c0102 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -295,7 +295,7 @@ QErrorMessage * QErrorMessage::qtHandler() if (!qtMessageHandler) { qtMessageHandler = new QErrorMessage(0); qAddPostRoutine(deleteStaticcQErrorMessage); // clean up - qtMessageHandler->setWindowTitle(QApplication::applicationName()); + qtMessageHandler->setWindowTitle(QCoreApplication::applicationName()); qInstallMessageHandler(jump); } return qtMessageHandler; diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a778fd3a45..b521f50f40 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1390,7 +1390,7 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath) if (d->rootDir.path() == longNewPath) return d->index(rootPath()); - bool showDrives = (longNewPath.isEmpty() || longNewPath == d->myComputer()); + bool showDrives = (longNewPath.isEmpty() || longNewPath == QFileSystemModelPrivate::myComputer()); if (!showDrives && !newPathDir.exists()) return d->index(rootPath()); diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 2b81180ecb..cd296ca020 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -432,7 +432,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) k->key() == Qt::Key_PageDown)) { int ci = d->sizeList->currentItem(); - (void)QApplication::sendEvent(d->sizeList, k); + QCoreApplication::sendEvent(d->sizeList, k); if (ci != d->sizeList->currentItem() && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) @@ -680,7 +680,7 @@ void QFontDialogPrivate::updateSampleFont(const QFont &newFont) void QFontDialogPrivate::_q_writingSystemHighlighted(int index) { writingSystem = QFontDatabase::WritingSystem(index); - sampleEdit->setText(fdb.writingSystemSample(writingSystem)); + sampleEdit->setText(QFontDatabase::writingSystemSample(writingSystem)); updateFamilies(); } diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 9bfea06a54..8dad212692 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1508,7 +1508,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) if (d->detailsText) textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator; #endif - QApplication::clipboard()->setText(textToCopy); + QGuiApplication::clipboard()->setText(textToCopy); return; } #endif // Q_OS_WIN diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 078dd6463b..e1a6bce5b1 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -643,7 +643,7 @@ int QProgressDialog::value() const \warning If the progress dialog is modal (see QProgressDialog::QProgressDialog()), - setValue() calls QApplication::processEvents(), so take care that + setValue() calls QCoreApplication::processEvents(), so take care that this does not cause undesirable re-entrancy in your code. For example, don't use a QProgressDialog inside a paintEvent()! @@ -659,7 +659,7 @@ void QProgressDialog::setValue(int progress) if (d->shown_once) { if (isModal()) - QApplication::processEvents(); + QCoreApplication::processEvents(); } else { if ((!d->setValue_called && progress == 0 /* for compat with Qt < 5.4 */) || progress == minimum()) { d->starttime.start(); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index f428114bbe..4d28dda7c7 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -2577,7 +2577,7 @@ void QWizard::setWizardStyle(WizardStyle style) //Send a resizeevent since the antiflicker widget probably needs a new size //because of the backbutton in the window title QResizeEvent ev(geometry().size(), geometry().size()); - QApplication::sendEvent(this, &ev); + QCoreApplication::sendEvent(this, &ev); } #endif d->updateLayout(); diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf index 5d7262fca1..6e04372a8b 100644 --- a/src/widgets/doc/qtwidgets.qdocconf +++ b/src/widgets/doc/qtwidgets.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtWidgets description = Qt Widgets Reference Documentation diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 9335ff78c9..236582ef3f 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -1912,7 +1912,7 @@ \section3 Custom sorting models - QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up + QSortFilterProxyModel instances use std::stable_sort() function to set up mappings between items in the source model and those in the proxy model, allowing a sorted hierarchy of items to be exposed to views without modifying the structure of the source model. To provide custom sorting behavior, reimplement the diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp index ca0aef9e27..8b52b57580 100644 --- a/src/widgets/graphicsview/qgraphicslayout.cpp +++ b/src/widgets/graphicsview/qgraphicslayout.cpp @@ -338,7 +338,7 @@ void QGraphicsLayout::invalidate() } if (layoutItem && !layoutItem->isLayout()) { // If a layout has a parent that is not a layout it must be a QGraphicsWidget. - QApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(static_cast<QGraphicsWidget *>(layoutItem), new QEvent(QEvent::LayoutRequest)); } } } diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index ae1eeffa2b..59ed7acd72 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -108,7 +108,7 @@ Qt::LayoutDirection QGraphicsLayoutPrivate::visualDirection() const if (maybeWidget->isWidget()) return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection(); } - return QApplication::layoutDirection(); + return QGuiApplication::layoutDirection(); } static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem) diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index e9f092020f..f1b01fbb4d 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -342,7 +342,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event) Q_ASSERT(receiver); do { - bool res = QApplication::sendEvent(receiver, event); + bool res = QCoreApplication::sendEvent(receiver, event); if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget)) break; receiver = receiver->parentWidget(); @@ -356,9 +356,9 @@ void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::Focu { QFocusEvent event(QEvent::FocusOut, reason); QPointer<QWidget> widgetGuard = widget; - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); if (widgetGuard && event.isAccepted()) - QApplication::sendEvent(widget->style(), &event); + QCoreApplication::sendEvent(widget->style(), &event); } /*! @@ -865,7 +865,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) case QEvent::ShortcutOverride: { QWidget *focusWidget = d->widget->focusWidget(); while (focusWidget) { - QApplication::sendEvent(focusWidget, event); + QCoreApplication::sendEvent(focusWidget, event); if (event->isAccepted()) return true; focusWidget = focusWidget->parentWidget(); @@ -878,7 +878,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier? QWidget *focusWidget = d->widget->focusWidget(); while (focusWidget) { - bool res = QApplication::sendEvent(focusWidget, event); + const bool res = QCoreApplication::sendEvent(focusWidget, event); if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) { event->accept(); break; @@ -897,7 +897,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event); QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint(); QHelpEvent e(QEvent::ToolTip, pos, he->screenPos()); - QApplication::sendEvent(d->lastWidgetUnderMouse, &e); + QCoreApplication::sendEvent(d->lastWidgetUnderMouse, &e); event->setAccepted(e.isAccepted()); return e.isAccepted(); } @@ -919,7 +919,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->widget, event); else - QApplication::sendEvent(d->widget, event); + QCoreApplication::sendEvent(d->widget, event); if (event->isAccepted()) return true; @@ -1044,7 +1044,7 @@ void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *even // Send mouse event. ### Doesn't propagate the event. QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()), pos.toPoint(), globalPos, event->modifiers()); - QApplication::sendEvent(receiver, &contextMenuEvent); + QCoreApplication::sendEvent(receiver, &contextMenuEvent); event->setAccepted(contextMenuEvent.isAccepted()); } @@ -1065,7 +1065,7 @@ void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event) QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers()); proxyDragEnter.setAccepted(event->isAccepted()); - QApplication::sendEvent(d->widget, &proxyDragEnter); + QCoreApplication::sendEvent(d->widget, &proxyDragEnter); event->setAccepted(proxyDragEnter.isAccepted()); if (proxyDragEnter.isAccepted()) // we discard answerRect event->setDropAction(proxyDragEnter.dropAction()); @@ -1082,7 +1082,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) if (!d->widget || !d->dragDropWidget) return; QDragLeaveEvent proxyDragLeave; - QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave); d->dragDropWidget = 0; #endif } @@ -1112,7 +1112,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) // Try to enter before we leave QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); dragEnter.setDropAction(event->proposedAction()); - QApplication::sendEvent(receiver, &dragEnter); + QCoreApplication::sendEvent(receiver, &dragEnter); event->setAccepted(dragEnter.isAccepted()); event->setDropAction(dragEnter.dropAction()); if (!event->isAccepted()) { @@ -1124,14 +1124,14 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropWidget) { QDragLeaveEvent dragLeave; - QApplication::sendEvent(d->dragDropWidget, &dragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave); } d->dragDropWidget = receiver; } QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); event->setDropAction(d->lastDropAction); - QApplication::sendEvent(receiver, &dragMove); + QCoreApplication::sendEvent(receiver, &dragMove); event->setAccepted(dragMove.isAccepted()); event->setDropAction(dragMove.dropAction()); if (event->isAccepted()) @@ -1144,7 +1144,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropWidget) { // Leave the last drag drop item QDragLeaveEvent dragLeave; - QApplication::sendEvent(d->dragDropWidget, &dragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave); d->dragDropWidget = 0; } // Propagate @@ -1165,7 +1165,7 @@ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event) if (d->widget && d->dragDropWidget) { QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint(); QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); - QApplication::sendEvent(d->dragDropWidget, &dropEvent); + QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent); event->setAccepted(dropEvent.isAccepted()); d->dragDropWidget = 0; } @@ -1464,7 +1464,7 @@ void QGraphicsProxyWidget::inputMethodEvent(QInputMethodEvent *event) Q_D(const QGraphicsProxyWidget); QWidget *focusWidget = d->widget->focusWidget(); if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) - QApplication::sendEvent(focusWidget, event); + QCoreApplication::sendEvent(focusWidget, event); } /*! diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index e5bd65d61e..2cdbdc2072 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -114,7 +114,7 @@ Another responsibility that QGraphicsScene has, is to propagate events from QGraphicsView. To send an event to a scene, you construct an event that inherits QEvent, and then send it using, for example, - QApplication::sendEvent(). event() is responsible for dispatching + QCoreApplication::sendEvent(). event() is responsible for dispatching the event to the individual items. Some common events are handled by convenience event handlers. For example, key press events are handled by keyPressEvent(), and mouse press events are handled by mousePressEvent(). @@ -451,7 +451,7 @@ void QGraphicsScenePrivate::_q_polishItems() } if (itemd->isWidget) { QEvent event(QEvent::Polish); - QApplication::sendEvent((QGraphicsWidget *)item, &event); + QCoreApplication::sendEvent((QGraphicsWidget *)item, &event); } } @@ -774,7 +774,7 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin // Update activate state. activePanel = panel; QEvent event(QEvent::ActivationChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); // Activate if (panel) { @@ -1243,7 +1243,7 @@ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) return false; if (QGraphicsObject *o = item->toGraphicsObject()) { bool spont = event->spontaneous(); - if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event)) + if (spont ? qt_sendSpontaneousEvent(o, event) : QCoreApplication::sendEvent(o, event)) return true; event->spont = spont; } @@ -1569,7 +1569,7 @@ void QGraphicsScenePrivate::updateFont(const QFont &font) // Send the scene a FontChange event. QEvent event(QEvent::FontChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } /*! @@ -1593,7 +1593,7 @@ void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette) */ void QGraphicsScenePrivate::resolvePalette() { - QPalette naturalPalette = QApplication::palette(); + QPalette naturalPalette = QGuiApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); updatePalette(resolvedPalette); @@ -1626,7 +1626,7 @@ void QGraphicsScenePrivate::updatePalette(const QPalette &palette) // Send the scene a PaletteChange event. QEvent event(QEvent::PaletteChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } /*! @@ -3548,10 +3548,10 @@ bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event) switch (event->type()) { case QEvent::ApplicationPaletteChange: - QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); + QCoreApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); break; case QEvent::ApplicationFontChange: - QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); + QCoreApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); break; default: break; @@ -5605,7 +5605,7 @@ void QGraphicsScene::setStyle(QStyle *style) // Notify the scene. QEvent event(QEvent::StyleChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); // Notify all widgets that don't have a style explicitly set. const auto items_ = items(); @@ -5613,7 +5613,7 @@ void QGraphicsScene::setStyle(QStyle *style) if (item->isWidget()) { QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); if (!widget->testAttribute(Qt::WA_SetStyle)) - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } } } @@ -5686,7 +5686,7 @@ QPalette QGraphicsScene::palette() const void QGraphicsScene::setPalette(const QPalette &palette) { Q_D(QGraphicsScene); - QPalette naturalPalette = QApplication::palette(); + QPalette naturalPalette = QGuiApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); d->setPalette_helper(resolvedPalette); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 5fe520132f..3ec9668cde 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -667,7 +667,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(scene, &mouseEvent); else - QApplication::sendEvent(scene, &mouseEvent); + QCoreApplication::sendEvent(scene, &mouseEvent); // Remember whether the last event was accepted or not. lastMouseEvent.setAccepted(mouseEvent.isAccepted()); @@ -1716,7 +1716,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) if (isActiveWindow() && isVisible()) { QEvent windowDeactivate(QEvent::WindowDeactivate); - QApplication::sendEvent(d->scene, &windowDeactivate); + QCoreApplication::sendEvent(d->scene, &windowDeactivate); } if(hasFocus()) d->scene->clearFocus(); @@ -1744,7 +1744,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) if (isActiveWindow() && isVisible()) { QEvent windowActivate(QEvent::WindowActivate); - QApplication::sendEvent(d->scene, &windowActivate); + QCoreApplication::sendEvent(d->scene, &windowActivate); } } else { d->recalculateContentSize(); @@ -2809,7 +2809,7 @@ bool QGraphicsView::event(QEvent *event) switch (event->type()) { case QEvent::ShortcutOverride: if (d->scene) - return QApplication::sendEvent(d->scene, event); + return QCoreApplication::sendEvent(d->scene, event); break; case QEvent::KeyPress: if (d->scene) { @@ -2821,7 +2821,7 @@ bool QGraphicsView::event(QEvent *event) // and the base implementation will call QGraphicsView's // focusNextPrevChild() function. If the event is ignored, // we fall back to standard tab focus handling. - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (event->isAccepted()) return true; // Ensure the event doesn't propagate just because the @@ -2850,10 +2850,10 @@ bool QGraphicsView::viewportEvent(QEvent *event) switch (event->type()) { case QEvent::Enter: - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::WindowActivate: - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::WindowDeactivate: // ### This is a temporary fix for until we get proper mouse @@ -2862,19 +2862,19 @@ bool QGraphicsView::viewportEvent(QEvent *event) // Remove all popups when the scene loses focus. if (!d->scene->d_func()->popupWidgets.isEmpty()) d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst()); - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::Show: if (d->scene && isActiveWindow()) { QEvent windowActivate(QEvent::WindowActivate); - QApplication::sendEvent(d->scene, &windowActivate); + QCoreApplication::sendEvent(d->scene, &windowActivate); } break; case QEvent::Hide: // spontaneous event will generate a WindowDeactivate. if (!event->spontaneous() && d->scene && isActiveWindow()) { QEvent windowDeactivate(QEvent::WindowDeactivate); - QApplication::sendEvent(d->scene, &windowDeactivate); + QCoreApplication::sendEvent(d->scene, &windowDeactivate); } break; case QEvent::Leave: { @@ -2892,7 +2892,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) Q_ASSERT(event->d == 0); QScopedValueRollback<QEventPrivate *> rb(event->d); event->d = reinterpret_cast<QEventPrivate *>(viewport()); - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; } #ifndef QT_NO_TOOLTIP @@ -2902,7 +2902,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) helpEvent.setWidget(viewport()); helpEvent.setScreenPos(toolTip->globalPos()); helpEvent.setScenePos(mapToScene(toolTip->pos())); - QApplication::sendEvent(d->scene, &helpEvent); + QCoreApplication::sendEvent(d->scene, &helpEvent); toolTip->setAccepted(helpEvent.isAccepted()); return true; } @@ -2940,7 +2940,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); touchEvent->setTarget(viewport()); QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); - (void) QApplication::sendEvent(d->scene, touchEvent); + QCoreApplication::sendEvent(d->scene, touchEvent); } else { event->ignore(); } @@ -2957,7 +2957,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) if (d->scene && d->sceneInteractionAllowed) { QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event); gestureEvent->setWidget(viewport()); - (void) QApplication::sendEvent(d->scene, gestureEvent); + QCoreApplication::sendEvent(d->scene, gestureEvent); } return true; } @@ -2992,7 +2992,7 @@ void QGraphicsView::contextMenuEvent(QContextMenuEvent *event) contextEvent.setModifiers(event->modifiers()); contextEvent.setReason((QGraphicsSceneContextMenuEvent::Reason)(event->reason())); contextEvent.setAccepted(event->isAccepted()); - QApplication::sendEvent(d->scene, &contextEvent); + QCoreApplication::sendEvent(d->scene, &contextEvent); event->setAccepted(contextEvent.isAccepted()); } #endif // QT_NO_CONTEXTMENU @@ -3012,7 +3012,7 @@ void QGraphicsView::dropEvent(QDropEvent *event) d->populateSceneDragDropEvent(&sceneEvent, event); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. event->setAccepted(sceneEvent.isAccepted()); @@ -3043,7 +3043,7 @@ void QGraphicsView::dragEnterEvent(QDragEnterEvent *event) d->storeDragDropEvent(&sceneEvent); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. if (sceneEvent.isAccepted()) { @@ -3081,7 +3081,7 @@ void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) d->lastDragDropEvent = 0; // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. if (sceneEvent.isAccepted()) @@ -3105,7 +3105,7 @@ void QGraphicsView::dragMoveEvent(QDragMoveEvent *event) d->storeDragDropEvent(&sceneEvent); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Ignore the originating event if the scene ignored the scene event. event->setAccepted(sceneEvent.isAccepted()); @@ -3123,7 +3123,7 @@ void QGraphicsView::focusInEvent(QFocusEvent *event) d->updateInputMethodSensitivity(); QAbstractScrollArea::focusInEvent(event); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); // Pass focus on if the scene cannot accept focus. if (!d->scene || !event->isAccepted()) QAbstractScrollArea::focusInEvent(event); @@ -3145,7 +3145,7 @@ void QGraphicsView::focusOutEvent(QFocusEvent *event) Q_D(QGraphicsView); QAbstractScrollArea::focusOutEvent(event); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); } /*! @@ -3158,7 +3158,7 @@ void QGraphicsView::keyPressEvent(QKeyEvent *event) QAbstractScrollArea::keyPressEvent(event); return; } - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (!event->isAccepted()) QAbstractScrollArea::keyPressEvent(event); } @@ -3171,7 +3171,7 @@ void QGraphicsView::keyReleaseEvent(QKeyEvent *event) Q_D(QGraphicsView); if (!d->scene || !d->sceneInteractionAllowed) return; - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (!event->isAccepted()) QAbstractScrollArea::keyReleaseEvent(event); } @@ -3210,7 +3210,7 @@ void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the original mouse event accepted state. const bool isAccepted = mouseEvent.isAccepted(); @@ -3261,7 +3261,7 @@ void QGraphicsView::mousePressEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the original mouse event accepted state. bool isAccepted = mouseEvent.isAccepted(); @@ -3397,7 +3397,7 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the last mouse event selected state. d->lastMouseEvent.setAccepted(mouseEvent.isAccepted()); @@ -3433,7 +3433,7 @@ void QGraphicsView::wheelEvent(QWheelEvent *event) wheelEvent.setDelta(event->delta()); wheelEvent.setOrientation(event->orientation()); wheelEvent.setAccepted(false); - QApplication::sendEvent(d->scene, &wheelEvent); + QCoreApplication::sendEvent(d->scene, &wheelEvent); event->setAccepted(wheelEvent.isAccepted()); if (!event->isAccepted()) QAbstractScrollArea::wheelEvent(event); @@ -3720,7 +3720,7 @@ void QGraphicsView::inputMethodEvent(QInputMethodEvent *event) { Q_D(QGraphicsView); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); } /*! diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index cd647a5db1..643f073085 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -390,7 +390,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QGraphicsSceneMoveEvent event; event.setOldPos(oldPos); event.setNewPos(pos()); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); if (wd->inSetPos) { //set the new pos d->geom.moveTopLeft(pos()); @@ -413,10 +413,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QGraphicsLayout *lay = wd->layout; if (QGraphicsLayout::instantInvalidatePropagation()) { if (!lay || lay->isActivated()) { - QApplication::sendEvent(this, &re); + QCoreApplication::sendEvent(this, &re); } } else { - QApplication::sendEvent(this, &re); + QCoreApplication::sendEvent(this, &re); } } } @@ -427,7 +427,7 @@ relayoutChildrenAndReturn: if (QGraphicsLayout *lay = wd->layout) { if (!lay->isActivated()) { QEvent layoutRequest(QEvent::LayoutRequest); - QApplication::sendEvent(this, &layoutRequest); + QCoreApplication::sendEvent(this, &layoutRequest); } } } @@ -507,7 +507,7 @@ void QGraphicsWidget::setContentsMargins(QMarginsF margins) updateGeometry(); QEvent e(QEvent::ContentsRectChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -963,7 +963,7 @@ void QGraphicsWidget::setStyle(QStyle *style) // Deliver StyleChange to the widget itself (doesn't propagate). QEvent event(QEvent::StyleChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! @@ -1028,7 +1028,7 @@ void QGraphicsWidget::setFont(const QFont &font) By default, this property contains the application's default palette. - \sa QApplication::palette(), QGraphicsScene::palette, QPalette::resolve() + \sa QGuiApplication::palette(), QGraphicsScene::palette, QPalette::resolve() */ QPalette QGraphicsWidget::palette() const { @@ -1100,7 +1100,7 @@ void QGraphicsWidget::updateGeometry() // This is for custom layouting QGraphicsWidget *parentWid = parentWidget(); //### if (parentWid->isVisible()) - QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); } else { /** * If this is the topmost widget, post a LayoutRequest event to the widget. @@ -1108,7 +1108,7 @@ void QGraphicsWidget::updateGeometry() * widgets in one go. This will make a relayout flicker-free. */ if (QGraphicsLayout::instantInvalidatePropagation()) - QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest)); } if (!QGraphicsLayout::instantInvalidatePropagation()) { bool wasResized = testAttribute(Qt::WA_Resized); @@ -1145,14 +1145,14 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & case ItemEnabledHasChanged: { // Send EnabledChange after the enabled state has changed. QEvent event(QEvent::EnabledChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemVisibleChange: if (value.toBool()) { // Send Show event before the item has been shown. QShowEvent event; - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); bool resized = testAttribute(Qt::WA_Resized); if (!resized) { adjustSize(); @@ -1168,7 +1168,7 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & if (!value.toBool()) { // Send Hide event after the item has been hidden. QHideEvent event; - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } break; case ItemPositionHasChanged: @@ -1177,25 +1177,25 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & case ItemParentChange: { // Deliver ParentAboutToChange. QEvent event(QEvent::ParentAboutToChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemParentHasChanged: { // Deliver ParentChange. QEvent event(QEvent::ParentChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemCursorHasChanged: { // Deliver CursorChange. QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemToolTipHasChanged: { // Deliver ToolTipChange. QEvent event(QEvent::ToolTipChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } default: @@ -1930,7 +1930,7 @@ int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutCont if (sequence.isEmpty()) return 0; // ### setAttribute(Qt::WA_GrabbedShortcut); - return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher); + return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher); } /*! @@ -1954,7 +1954,7 @@ void QGraphicsWidget::releaseShortcut(int id) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0); } /*! @@ -1975,7 +1975,7 @@ void QGraphicsWidget::setShortcutEnabled(int id, bool enabled) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, id, this, 0); } /*! @@ -1990,7 +1990,7 @@ void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0); } #endif @@ -2068,7 +2068,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) } QActionEvent e(QEvent::ActionAdded, action, before); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -2111,7 +2111,7 @@ void QGraphicsWidget::removeAction(QAction *action) if (d->actions.removeAll(action)) { QActionEvent e(QEvent::ActionRemoved, action); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } @@ -2404,7 +2404,7 @@ QPainterPath QGraphicsWidget::shape() const bool QGraphicsWidget::close() { QCloseEvent closeEvent; - QApplication::sendEvent(this, &closeEvent); + QCoreApplication::sendEvent(this, &closeEvent); if (!closeEvent.isAccepted()) { return false; } diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index ce027c1319..cc08b1c566 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -190,7 +190,7 @@ void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette) // Notify change. QEvent event(QEvent::PaletteChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) @@ -212,7 +212,7 @@ void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direc // Send the notification event to this widget item. QEvent e(QEvent::LayoutDirectionChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QGraphicsWidgetPrivate::resolveLayoutDirection() @@ -226,9 +226,9 @@ void QGraphicsWidgetPrivate::resolveLayoutDirection() } else if (scene) { // ### shouldn't the scene have a layoutdirection really? how does // ### QGraphicsWidget get changes from QApplication::layoutDirection? - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } else { - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } } @@ -290,7 +290,7 @@ void QGraphicsWidgetPrivate::updateFont(const QFont &font) return; // Notify change. QEvent event(QEvent::FontChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } QFont QGraphicsWidgetPrivate::naturalWidgetFont() const diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 1d1c144bb8..6ff0fe8132 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -180,7 +180,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index QString statustip = model->data(index, Qt::StatusTipRole).toString(); if (parent && (shouldClearStatusTip || !statustip.isEmpty())) { QStatusTipEvent tip(statustip); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); shouldClearStatusTip = !statustip.isEmpty(); } #endif @@ -189,7 +189,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index if (parent && shouldClearStatusTip) { QString emptyString; QStatusTipEvent tip( emptyString ); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); } #endif emit q->viewportEntered(); @@ -521,7 +521,7 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged() the mouse was pressed on is specified by \a index. The signal is only emitted when the index is valid. - Use the QApplication::mouseButtons() function to get the state + Use the QGuiApplication::mouseButtons() function to get the state of the mouse buttons. \sa activated(), clicked(), doubleClicked(), entered() @@ -1713,7 +1713,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event) if (d->shouldClearStatusTip && d->parent) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(d->parent, &tip); + QCoreApplication::sendEvent(d->parent, &tip); d->shouldClearStatusTip = false; } #endif @@ -2338,7 +2338,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (d->model) variant = d->model->data(currentIndex(), Qt::DisplayRole); if (variant.type() == QVariant::String) - QApplication::clipboard()->setText(variant.toString()); + QGuiApplication::clipboard()->setText(variant.toString()); event->accept(); } #endif @@ -2845,7 +2845,7 @@ void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndE } QPointer<QWidget> ed = editor; - QApplication::sendPostedEvents(editor, 0); + QCoreApplication::sendPostedEvents(editor, 0); editor = ed; if (!isPersistent && editor) @@ -3957,7 +3957,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM keyModifiers = (static_cast<const QInputEvent*>(event))->modifiers(); break; default: - keyModifiers = QApplication::keyboardModifiers(); + keyModifiers = QGuiApplication::keyboardModifiers(); } } switch (d->selectionMode) { @@ -4015,7 +4015,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand( const QModelIndex &index, const QEvent *event) const { - Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers(); + Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); if (event) { switch (event->type()) { case QEvent::MouseMove: { @@ -4425,7 +4425,7 @@ bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *even w->setFocus(); if (event) - QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); + QCoreApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); return true; } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index b94c31fb42..13a1bbd8eb 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1086,7 +1086,7 @@ QString QDirModel::filePath(const QModelIndex &index) const if (d->indexValid(index)) { QFileInfo fi = fileInfo(index); if (d->resolveSymlinks && fi.isSymLink()) - fi = d->resolvedInfo(fi); + fi = QDirModelPrivate::resolvedInfo(fi); return QDir::cleanPath(fi.absoluteFilePath()); } return QString(); // root path @@ -1108,7 +1108,7 @@ QString QDirModel::fileName(const QModelIndex &index) const if (QFileSystemEntry::isRootPath(path)) return path; if (d->resolveSymlinks && info.isSymLink()) - info = d->resolvedInfo(info); + info = QDirModelPrivate::resolvedInfo(info); return info.fileName(); } diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 1fcd5bdef2..be80843b07 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2896,7 +2896,7 @@ bool QHeaderView::viewportEvent(QEvent *e) case QEvent::Wheel: { QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea *>(parentWidget()); if (asa) - return QApplication::sendEvent(asa->viewport(), e); + return QCoreApplication::sendEvent(asa->viewport(), e); break; } default: break; diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 641b15f85b..25facd1484 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -821,13 +821,13 @@ void QListView::wheelEvent(QWheelEvent *e) if (e->spontaneous()) qt_sendSpontaneousEvent(d->hbar, &hwe); else - QApplication::sendEvent(d->hbar, &hwe); + QCoreApplication::sendEvent(d->hbar, &hwe); e->setAccepted(hwe.isAccepted()); } else { - QApplication::sendEvent(d->vbar, e); + QCoreApplication::sendEvent(d->vbar, e); } } else { - QApplication::sendEvent(d->hbar, e); + QCoreApplication::sendEvent(d->hbar, e); } } #endif // QT_CONFIG(wheelevent) diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index f6631199d6..19ad65692b 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -47,15 +47,15 @@ #include "qlist.h" #include "qstylehints.h" #include <private/qshortcutmap_p.h> -#include <private/qapplication_p.h> +#include <private/qguiapplication_p.h> #if QT_CONFIG(menu) #include <private/qmenu_p.h> #endif #include <private/qdebug_p.h> #define QAPP_CHECK(functionName) \ - if (Q_UNLIKELY(!qApp)) { \ - qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ + if (Q_UNLIKELY(!QCoreApplication::instance())) { \ + qWarning("QAction: Initialize Q(Gui)Application before calling '" functionName "'."); \ return; \ } @@ -75,24 +75,18 @@ static QString qt_strippedText(QString s) } -QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), - visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), - iconVisibleInMenu(-1), - shortcutVisibleInContextMenu(-1), - menuRole(QAction::TextHeuristicRole), - priority(QAction::NormalPriority) -{ -#ifndef QT_NO_SHORTCUT - shortcutId = 0; - shortcutContext = Qt::WindowShortcut; - autorepeat = true; +QActionPrivate::QActionPrivate() : +#if QT_CONFIG(shortcut) + autorepeat(1), #endif -} - -QActionPrivate::~QActionPrivate() + enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), + checked(0), separator(0), fontSet(false), + iconVisibleInMenu(-1), shortcutVisibleInContextMenu(-1) { } +QActionPrivate::~QActionPrivate() = default; + bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) { #if !QT_CONFIG(statustip) @@ -101,7 +95,7 @@ bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) #else if(QObject *object = widget ? widget : parent) { QStatusTipEvent tip(str); - QApplication::sendEvent(object, &tip); + QCoreApplication::sendEvent(object, &tip); return true; } #endif @@ -114,20 +108,20 @@ void QActionPrivate::sendDataChanged() QActionEvent e(QEvent::ActionChanged, q); for (int i = 0; i < widgets.size(); ++i) { QWidget *w = widgets.at(i); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } #if QT_CONFIG(graphicsview) for (int i = 0; i < graphicsWidgets.size(); ++i) { QGraphicsWidget *w = graphicsWidgets.at(i); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } #endif - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); emit q->changed(); } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void QActionPrivate::redoGrab(QShortcutMap &map) { Q_Q(QAction); @@ -345,7 +339,7 @@ QWidget *QAction::parentWidget() const QObject *ret = parent(); while (ret && !ret->isWidgetType()) ret = ret->parent(); - return (QWidget*)ret; + return static_cast<QWidget*>(ret); } /*! @@ -374,7 +368,7 @@ QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const } #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) /*! \property QAction::shortcut \brief the action's primary shortcut key @@ -391,7 +385,7 @@ void QAction::setShortcut(const QKeySequence &shortcut) return; d->shortcut = shortcut; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -420,8 +414,8 @@ void QAction::setShortcuts(const QList<QKeySequence> &shortcuts) d->shortcut = primary; d->alternateShortcuts = listCopy; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -485,8 +479,8 @@ void QAction::setShortcutContext(Qt::ShortcutContext context) return; QAPP_CHECK("setShortcutContext"); d->shortcutContext = context; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -513,8 +507,8 @@ void QAction::setAutoRepeat(bool on) return; QAPP_CHECK("setAutoRepeat"); d->autorepeat = on; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -573,12 +567,12 @@ QAction::~QAction() #endif if (d->group) d->group->removeAction(this); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (d->shortcutId && qApp) { - qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->shortcutId, this); for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { const int id = d->alternateShortcutIds.at(i); - qApp->d_func()->shortcutMap.removeShortcut(id, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this); } } #endif @@ -1027,8 +1021,8 @@ void QAction::setEnabled(bool b) return; QAPP_CHECK("setEnabled"); d->enabled = b; -#ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); +#if QT_CONFIG(shortcut) + d->setShortcutEnabled(b, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); } @@ -1061,8 +1055,8 @@ void QAction::setVisible(bool b) d->forceInvisible = !b; d->visible = b; d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; -#ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); +#if QT_CONFIG(shortcut) + d->setShortcutEnabled(d->enabled, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); } @@ -1080,7 +1074,7 @@ bool QAction::isVisible() const bool QAction::event(QEvent *e) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast<QShortcutEvent *>(e); Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), @@ -1285,7 +1279,7 @@ void QAction::setIconVisibleInMenu(bool visible) d->iconVisibleInMenu = visible; // Only send data changed if we really need to. if (oldValue != -1 - || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus)) { + || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus)) { d->sendDataChanged(); } } @@ -1295,7 +1289,7 @@ bool QAction::isIconVisibleInMenu() const { Q_D(const QAction); if (d->iconVisibleInMenu == -1) { - return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); + return !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); } return d->iconVisibleInMenu; } @@ -1323,7 +1317,7 @@ void QAction::setShortcutVisibleInContextMenu(bool visible) d->shortcutVisibleInContextMenu = visible; // Only send data changed if we really need to. if (oldValue != -1 - || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) { + || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) { d->sendDataChanged(); } } @@ -1351,7 +1345,7 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) d << " toolTip=" << action->toolTip(); if (action->isCheckable()) d << " checked=" << action->isChecked(); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (!action->shortcut().isEmpty()) d << " shortcut=" << action->shortcut(); #endif diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index 84bf92d2ac..f7693f4dde 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -72,7 +72,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed) Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed) Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed) @@ -129,7 +129,7 @@ public: void setSeparator(bool b); bool isSeparator() const; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void setShortcut(const QKeySequence &shortcut); QKeySequence shortcut() const; diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 19ae47c7b9..6b6ca8076f 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -89,15 +89,15 @@ public: QString tooltip; QString statustip; QString whatsthis; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) QKeySequence shortcut; QList<QKeySequence> alternateShortcuts; #endif QVariant userData; -#ifndef QT_NO_SHORTCUT - int shortcutId; +#if QT_CONFIG(shortcut) + int shortcutId = 0; QVector<int> alternateShortcutIds; - Qt::ShortcutContext shortcutContext; + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut; uint autorepeat : 1; #endif QFont font; @@ -112,19 +112,17 @@ public: int iconVisibleInMenu : 2; // Only has values -1, 0, and 1 int shortcutVisibleInContextMenu : 2; // Only has values -1, 0, and 1 - QAction::MenuRole menuRole; - QAction::Priority priority; + QAction::MenuRole menuRole = QAction::TextHeuristicRole; + QAction::Priority priority = QAction::NormalPriority; - QList<QWidget *> widgets; + QWidgetList widgets; #if QT_CONFIG(graphicsview) QList<QGraphicsWidget *> graphicsWidgets; #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void redoGrab(QShortcutMap &map); void redoGrabAlternate(QShortcutMap &map); void setShortcutEnabled(bool enable, QShortcutMap &map); - - static QShortcutMap *globalMap; #endif // QT_NO_SHORTCUT void sendDataChanged(); diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index ab42b1c7aa..1d9213de0c 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -42,7 +42,6 @@ #ifndef QT_NO_ACTION #include "qaction_p.h" -#include "qapplication.h" #include "qevent.h" #include "qlist.h" @@ -73,7 +72,7 @@ void QActionGroupPrivate::_q_actionChanged() { Q_Q(QActionGroup); QAction *action = qobject_cast<QAction*>(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionChanged", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionChanged", "internal error"); if (exclusionPolicy != QActionGroup::ExclusionPolicy::None) { if (action->isChecked()) { if (action != current) { @@ -91,7 +90,7 @@ void QActionGroupPrivate::_q_actionTriggered() { Q_Q(QActionGroup); QAction *action = qobject_cast<QAction*>(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionTriggered", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionTriggered", "internal error"); emit q->triggered(action); } @@ -99,7 +98,7 @@ void QActionGroupPrivate::_q_actionHovered() { Q_Q(QActionGroup); QAction *action = qobject_cast<QAction*>(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionHovered", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionHovered", "internal error"); emit q->hovered(action); } @@ -363,10 +362,10 @@ void QActionGroup::setEnabled(bool b) { Q_D(QActionGroup); d->enabled = b; - for(QList<QAction*>::const_iterator it = d->actions.constBegin(); it != d->actions.constEnd(); ++it) { - if(!(*it)->d_func()->forceDisabled) { - (*it)->setEnabled(b); - (*it)->d_func()->forceDisabled = false; + for (auto action : qAsConst(d->actions)) { + if (!action->d_func()->forceDisabled) { + action->setEnabled(b); + action->d_func()->forceDisabled = false; } } } @@ -400,10 +399,10 @@ void QActionGroup::setVisible(bool b) { Q_D(QActionGroup); d->visible = b; - for(QList<QAction*>::Iterator it = d->actions.begin(); it != d->actions.end(); ++it) { - if(!(*it)->d_func()->forceInvisible) { - (*it)->setVisible(b); - (*it)->d_func()->forceInvisible = false; + for (auto action : qAsConst(d->actions)) { + if (!action->d_func()->forceInvisible) { + action->setVisible(b); + action->d_func()->forceInvisible = false; } } } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 526bf0a0ff..c922aecceb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -111,6 +111,9 @@ #include <qtwidgets_tracepoints_p.h> +#include <algorithm> +#include <iterator> + //#define ALIEN_DEBUG static void initResources() @@ -622,7 +625,7 @@ void QApplicationPrivate::initialize() if (qt_is_gui_used) initializeMultitouch(); - if (QApplication::desktopSettingsAware()) + if (QGuiApplication::desktopSettingsAware()) if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); } @@ -1172,7 +1175,7 @@ void QApplication::setStyle(QStyle *style) QWidget *w = *it; if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) { QEvent e(QEvent::StyleChange); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); w->update(); } } @@ -1189,7 +1192,7 @@ void QApplication::setStyle(QStyle *style) if (QApplicationPrivate::focus_widget) { QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason); - QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); + QCoreApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); QApplicationPrivate::focus_widget->update(); } } @@ -1551,7 +1554,7 @@ void QApplication::setFont(const QFont &font, const char *className) if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { // Send ApplicationFontChange to qApp itself, and to the widgets. QEvent e(QEvent::ApplicationFontChange); - QApplication::sendEvent(QApplication::instance(), &e); + QCoreApplication::sendEvent(QApplication::instance(), &e); QWidgetList wids = QApplication::allWidgets(); for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) { @@ -1565,7 +1568,7 @@ void QApplication::setFont(const QFont &font, const char *className) QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list; for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin(); it != scenes.constEnd(); ++it) { - QApplication::sendEvent(*it, &e); + QCoreApplication::sendEvent(*it, &e); } #endif // QT_CONFIG(graphicsview) } @@ -1658,12 +1661,12 @@ void QApplicationPrivate::notifyWindowIconChanged() QWidgetList QApplication::topLevelWidgets() { QWidgetList list; - QWidgetList all = allWidgets(); - - for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) { - QWidget *w = *it; - if (w->isWindow() && w->windowType() != Qt::Desktop) - list.append(w); + if (QWidgetPrivate::allWidgets != nullptr) { + const auto isTopLevelWidget = [] (const QWidget *w) { + return w->isWindow() && w->windowType() != Qt::Desktop; + }; + std::copy_if(QWidgetPrivate::allWidgets->cbegin(), QWidgetPrivate::allWidgets->cend(), + std::back_inserter(list), isTopLevelWidget); } return list; } @@ -1739,16 +1742,16 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) #endif QFocusEvent out(QEvent::FocusOut, reason); QPointer<QWidget> that = prev; - QApplication::sendEvent(prev, &out); + QCoreApplication::sendEvent(prev, &out); if (that) - QApplication::sendEvent(that->style(), &out); + QCoreApplication::sendEvent(that->style(), &out); } if(focus && QApplicationPrivate::focus_widget == focus) { QFocusEvent in(QEvent::FocusIn, reason); QPointer<QWidget> that = focus; - QApplication::sendEvent(focus, &in); + QCoreApplication::sendEvent(focus, &in); if (that) - QApplication::sendEvent(that->style(), &in); + QCoreApplication::sendEvent(that->style(), &in); } emit qApp->focusChanged(prev, focus_widget); } @@ -1924,7 +1927,7 @@ bool QApplication::event(QEvent *e) } if (showToolTip) { QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos); - QApplication::sendEvent(d->toolTipWidget, &e); + QCoreApplication::sendEvent(d->toolTipWidget, &e); if (e.isAccepted()) { QStyle *s = d->toolTipWidget->style(); int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, 0, d->toolTipWidget, 0); @@ -2036,7 +2039,7 @@ void QApplication::setActiveWindow(QWidget* act) QGuiApplication::inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); - QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); + QCoreApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); } QApplicationPrivate::active_window = window; @@ -2111,7 +2114,7 @@ QWidget *qt_tlw_for_window(QWindow *wnd) wnd = wnd->parent(); } if (wnd) { - const auto tlws = qApp->topLevelWidgets(); + const auto tlws = QApplication::topLevelWidgets(); for (QWidget *tlw : tlws) { if (tlw->windowHandle() == wnd) return tlw; @@ -2205,12 +2208,12 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con #if 0 if (leave) { QEvent e(QEvent::Leave); - QApplication::sendEvent(leave, & e); + QCoreApplication::sendEvent(leave, & e); } if (enter) { const QPoint windowPos = enter->window()->mapFromGlobal(globalPos); QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos); - QApplication::sendEvent(enter, & e); + QCoreApplication::sendEvent(enter, & e); } return; #endif @@ -2271,12 +2274,12 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con for (int i = 0; i < leaveList.size(); ++i) { auto *w = leaveList.at(i); if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { - QApplication::sendEvent(w, &leaveEvent); + QCoreApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { Q_ASSERT(instance()); QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos), - QApplication::keyboardModifiers()); + QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -2292,11 +2295,11 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { const QPointF localPos = w->mapFromGlobal(globalPos); QEnterEvent enterEvent(localPos, windowPos, globalPosF); - QApplication::sendEvent(w, &enterEvent); + QCoreApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1), - QApplication::keyboardModifiers()); + QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -2644,7 +2647,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, if (spontaneous) result = QApplication::sendSpontaneousEvent(receiver, event); else - result = QApplication::sendEvent(receiver, event); + result = QCoreApplication::sendEvent(receiver, event); } if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease @@ -2898,7 +2901,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } #ifndef QT_NO_DEBUG - d->checkReceiverThread(receiver); + QCoreApplicationPrivate::checkReceiverThread(receiver); #endif if (receiver->isWindowType()) { @@ -3666,7 +3669,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) // send to all application event filters if (threadRequiresCoreApplication() - && receiver->d_func()->threadData->thread == mainThread() + && receiver->d_func()->threadData->thread.loadAcquire() == mainThread() && sendThroughApplicationEventFilters(receiver, e)) { filtered = true; return filtered; @@ -3818,7 +3821,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) } else if (popupWidgets->count() == 1) { // this was the first popup if (QWidget *fw = QApplication::focusWidget()) { QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); - QApplication::sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } } } @@ -4383,7 +4386,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QTouchEvent touchEvent(eventType, device, - QApplication::keyboardModifiers(), + QGuiApplication::keyboardModifiers(), it.value().first, it.value().second); bool containsPress = updateTouchPointsForWidget(widget, &touchEvent); @@ -4426,7 +4429,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp) { - QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers()); + QTouchEvent touchEvent(QEvent::TouchCancel, device, QGuiApplication::keyboardModifiers()); touchEvent.setTimestamp(timestamp); QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); @@ -4462,12 +4465,12 @@ void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const const QWidgetList widgets = QApplication::allWidgets(); for (auto widget : widgets) { if (toAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className))) - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } #if QT_CONFIG(graphicsview) for (auto scene : qAsConst(scene_list)) - QApplication::sendEvent(scene, &event); + QCoreApplication::sendEvent(scene, &event); #endif // QT_CONFIG(graphicsview) } diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index a368f379ad..76d8533271 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -172,7 +172,7 @@ void QBoxLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *b rightDelta = w->geometry().right() - itm->geometry().right(); } QWidget *w = q->parentWidget(); - Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QApplication::layoutDirection(); + Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QGuiApplication::layoutDirection(); if (layoutDirection == Qt::RightToLeft) qSwap(leftDelta, rightDelta); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 9146ba84c8..6f7527c013 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -2178,7 +2178,7 @@ void QFormLayoutPrivate::arrangeWidgets(const QVector<QLayoutStruct>& layouts, Q int i; const int rr = m_matrix.rowCount(); QWidget *w = q->parentWidget(); - Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QApplication::layoutDirection(); + Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QGuiApplication::layoutDirection(); Qt::Alignment formAlignment = fixedAlignment(q->formAlignment(), layoutDirection); int leftOffset = 0; diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index ff7bc1eccf..1555c2a73a 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -707,7 +707,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, foreach(QGesture *g, gestures) event.setAccepted(g, false); - QApplication::sendEvent(receiver, &event); + QCoreApplication::sendEvent(receiver, &event); bool eventAccepted = event.isAccepted(); const auto eventGestures = event.gestures(); for (QGesture *gesture : eventGestures) { @@ -734,7 +734,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value(); QGestureEvent event(it.value()); - QApplication::sendEvent(it.key(), &event); + QCoreApplication::sendEvent(it.key(), &event); bool eventAccepted = event.isAccepted(); const auto eventGestures = event.gestures(); for (QGesture *gesture : eventGestures) { diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index f71d038a5f..3ce81a390b 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1040,7 +1040,7 @@ void QLayout::update() if (layout->d_func()->topLevel) { Q_ASSERT(layout->parent()->isWidgetType()); QWidget *mw = static_cast<QWidget*>(layout->parent()); - QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest)); break; } layout = static_cast<QLayout*>(layout->parent()); @@ -1366,7 +1366,7 @@ QRect QLayout::alignmentRect(const QRect &r) const y += (r.height() - s.height()) / 2; QWidget *parent = parentWidget(); - a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a); + a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QGuiApplication::layoutDirection(), a); if (a & Qt::AlignRight) x += (r.width() - s.width()); else if (!(a & Qt::AlignLeft)) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index ae7729b49b..451b18d8d3 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -1432,7 +1432,7 @@ bool QOpenGLWidget::event(QEvent *e) Q_D(QOpenGLWidget); switch (e->type()) { case QEvent::WindowChangeInternal: - if (qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + if (QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) break; if (d->initialized) d->reset(); @@ -1445,7 +1445,7 @@ bool QOpenGLWidget::event(QEvent *e) { // Special case: did grabFramebuffer() for a hidden widget that then became visible. // Recreate all resources since the context now needs to share with the TLW's. - if (!qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) d->reset(); } if (!d->initialized && !size().isEmpty() && window()->windowHandle()) { diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index a680ff7913..a4ebcdfc84 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -96,8 +96,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) QWindow *qwindow = QGuiApplication::focusWindow(); if (qwindow && qwindow->isActive()) { while (qwindow) { - QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow); - if (widgetWindow) { + if (auto widgetWindow = qobject_cast<QWidgetWindow *>(qwindow)) { active_window = widgetWindow->widget(); break; } @@ -110,27 +109,25 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) return false; #ifndef QT_NO_ACTION - if (QAction *a = qobject_cast<QAction *>(object)) + if (auto a = qobject_cast<QAction *>(object)) return correctActionContext(context, a, active_window); #endif #if QT_CONFIG(graphicsview) - if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(object)) + if (auto gw = qobject_cast<QGraphicsWidget *>(object)) return correctGraphicsWidgetContext(context, gw, active_window); #endif - QWidget *w = qobject_cast<QWidget *>(object); + auto w = qobject_cast<QWidget *>(object); if (!w) { - QShortcut *s = qobject_cast<QShortcut *>(object); - if (s) + if (auto s = qobject_cast<QShortcut *>(object)) w = s->parentWidget(); } if (!w) { - QWindow *qwindow = qobject_cast<QWindow *>(object); + auto qwindow = qobject_cast<QWindow *>(object); while (qwindow) { - QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow); - if (widget_window) { + if (auto widget_window = qobject_cast<QWidgetWindow *>(qwindow)) { w = widget_window->widget(); break; } @@ -148,7 +145,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge { bool visible = w->isVisible(); #if QT_CONFIG(menubar) - if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) { + if (auto menuBar = qobject_cast<QMenuBar *>(w)) { if (auto *pmb = menuBar->platformMenuBar()) { if (menuBar->parentWidget()) { visible = true; @@ -166,7 +163,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge return false; if (context == Qt::ApplicationShortcut) - return QApplicationPrivate::tryModalHelper(w, 0); // true, unless w is shadowed by a modal dialog + return QApplicationPrivate::tryModalHelper(w, nullptr); // true, unless w is shadowed by a modal dialog if (context == Qt::WidgetShortcut) return w == QApplication::focusWidget(); @@ -181,18 +178,23 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge // Below is Qt::WindowShortcut context QWidget *tlw = w->window(); #if QT_CONFIG(graphicsview) - if (QWExtra *topData = static_cast<QWidgetPrivate *>(QObjectPrivate::get(tlw))->extra) { + if (auto topData = static_cast<QWidgetPrivate *>(QObjectPrivate::get(tlw))->extra) { if (topData->proxyWidget) { - bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window); + bool res = correctGraphicsWidgetContext(context, topData->proxyWidget, active_window); return res; } } #endif - /* if a floating tool window is active, keep shortcuts on the - * parent working */ - if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) { - active_window = active_window->parentWidget()->window(); + if (active_window && active_window != tlw) { + /* if a floating tool window is active, keep shortcuts on the parent working. + * and if a popup window is active (f.ex a completer), keep shortcuts on the + * focus proxy working */ + if (active_window->windowType() == Qt::Tool && active_window->parentWidget()) { + active_window = active_window->parentWidget()->window(); + } else if (active_window->windowType() == Qt::Popup && active_window->focusProxy()) { + active_window = active_window->focusProxy()->window(); + } } if (active_window != tlw) { @@ -228,7 +230,7 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW { bool visible = w->isVisible(); #if defined(Q_OS_DARWIN) && QT_CONFIG(menubar) - if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) + if (!QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) visible = true; #endif @@ -239,9 +241,9 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW // Applicationwide shortcuts are always reachable unless their owner // is shadowed by modality. In QGV there's no modality concept, but we // must still check if all views are shadowed. - QList<QGraphicsView *> views = w->scene()->views(); - for (int i = 0; i < views.size(); ++i) { - if (QApplicationPrivate::tryModalHelper(views.at(i), 0)) + const auto &views = w->scene()->views(); + for (auto view : views) { + if (QApplicationPrivate::tryModalHelper(view, nullptr)) return true; } return false; @@ -253,7 +255,7 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW if (context == Qt::WidgetWithChildrenShortcut) { const QGraphicsItem *ti = w->scene()->focusItem(); if (ti && ti->isWidget()) { - const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti); + const auto *tw = static_cast<const QGraphicsWidget *>(ti); while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup)) tw = tw->parentWidget(); return tw == w; @@ -264,10 +266,9 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW // Below is Qt::WindowShortcut context // Find the active view (if any). - QList<QGraphicsView *> views = w->scene()->views(); - QGraphicsView *activeView = 0; - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); + const auto &views = w->scene()->views(); + QGraphicsView *activeView = nullptr; + for (auto view : views) { if (view->window() == active_window) { activeView = view; break; @@ -286,15 +287,14 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW #ifndef QT_NO_ACTION static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) { - const QList<QWidget *> &widgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->widgets; + const QWidgetList &widgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->widgets; #if defined(DEBUG_QSHORTCUTMAP) if (widgets.isEmpty()) qDebug() << a << "not connected to any widgets; won't trigger"; #endif - for (int i = 0; i < widgets.size(); ++i) { - QWidget *w = widgets.at(i); + for (auto w : widgets) { #if QT_CONFIG(menu) - if (QMenu *menu = qobject_cast<QMenu *>(w)) { + if (auto menu = qobject_cast<QMenu *>(w)) { #ifdef Q_OS_DARWIN // On Mac, menu item shortcuts are processed before reaching any window. // That means that if a menu action shortcut has not been already processed @@ -320,14 +320,13 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge } #if QT_CONFIG(graphicsview) - const QList<QGraphicsWidget *> &graphicsWidgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->graphicsWidgets; + const auto &graphicsWidgets = static_cast<QActionPrivate *>(QObjectPrivate::get(a))->graphicsWidgets; #if defined(DEBUG_QSHORTCUTMAP) if (graphicsWidgets.isEmpty()) qDebug() << a << "not connected to any widgets; won't trigger"; #endif - for (int i = 0; i < graphicsWidgets.size(); ++i) { - QGraphicsWidget *w = graphicsWidgets.at(i); - if (correctGraphicsWidgetContext(context, w, active_window)) + for (auto graphicsWidget : graphicsWidgets) { + if (correctGraphicsWidgetContext(context, graphicsWidget, active_window)) return true; } #endif @@ -428,12 +427,12 @@ class QShortcutPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QShortcut) public: - QShortcutPrivate() : sc_context(Qt::WindowShortcut), sc_enabled(true), sc_autorepeat(true), sc_id(0) {} + QShortcutPrivate() = default; QKeySequence sc_sequence; - Qt::ShortcutContext sc_context; - bool sc_enabled; - bool sc_autorepeat; - int sc_id; + Qt::ShortcutContext sc_context = Qt::WindowShortcut; + bool sc_enabled = true; + bool sc_autorepeat = true; + int sc_id = 0; QString sc_whatsthis; void redoGrab(QShortcutMap &map); }; @@ -467,7 +466,7 @@ void QShortcutPrivate::redoGrab(QShortcutMap &map) QShortcut::QShortcut(QWidget *parent) : QObject(*new QShortcutPrivate, parent) { - Q_ASSERT(parent != 0); + Q_ASSERT(parent != nullptr); } /*! @@ -488,7 +487,7 @@ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, Q_D(QShortcut); d->sc_context = context; d->sc_sequence = key; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); if (member) connect(this, SIGNAL(activated()), parent, member); if (ambiguousMember) @@ -502,7 +501,7 @@ QShortcut::~QShortcut() { Q_D(QShortcut); if (qApp) - qApp->d_func()->shortcutMap.removeShortcut(d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->sc_id, this); } /*! @@ -523,7 +522,7 @@ void QShortcut::setKey(const QKeySequence &key) return; QAPP_CHECK("setKey"); d->sc_sequence = key; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); } QKeySequence QShortcut::key() const @@ -554,7 +553,7 @@ void QShortcut::setEnabled(bool enable) return; QAPP_CHECK("setEnabled"); d->sc_enabled = enable; - qApp->d_func()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); } bool QShortcut::isEnabled() const @@ -582,7 +581,7 @@ void QShortcut::setContext(Qt::ShortcutContext context) return; QAPP_CHECK("setContext"); d->sc_context = context; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); } Qt::ShortcutContext QShortcut::context() const @@ -634,7 +633,7 @@ void QShortcut::setAutoRepeat(bool on) return; QAPP_CHECK("setAutoRepeat"); d->sc_autorepeat = on; - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); } bool QShortcut::autoRepeat() const @@ -662,7 +661,7 @@ bool QShortcut::event(QEvent *e) Q_D(QShortcut); bool handled = false; if (d->sc_enabled && e->type() == QEvent::Shortcut) { - QShortcutEvent *se = static_cast<QShortcutEvent *>(e); + auto se = static_cast<QShortcutEvent *>(e); if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){ #if QT_CONFIG(whatsthis) if (QWhatsThis::inWhatsThisMode()) { diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 4a798a7490..a48eae6628 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -263,7 +263,7 @@ void QWhatsThat::mouseReleaseEvent(QMouseEvent* e) anchor.clear(); if (!href.isEmpty()) { QWhatsThisClickedEvent e(href); - if (QApplication::sendEvent(widget, &e)) + if (QCoreApplication::sendEvent(widget, &e)) return; } } @@ -380,7 +380,7 @@ void QWhatsThisPrivate::notifyToplevels(QEvent *e) { const QWidgetList toplevels = QApplication::topLevelWidgets(); for (auto *w : toplevels) - QApplication::sendEvent(w, e); + QCoreApplication::sendEvent(w, e); } QWhatsThisPrivate *QWhatsThisPrivate::instance = 0; @@ -394,7 +394,7 @@ QWhatsThisPrivate::QWhatsThisPrivate() QPoint pos = QCursor::pos(); if (QWidget *w = QApplication::widgetAt(pos)) { QHelpEvent e(QEvent::QueryWhatsThis, w->mapFromGlobal(pos), pos); - bool sentEvent = QApplication::sendEvent(w, &e); + const bool sentEvent = QCoreApplication::sendEvent(w, &e); #ifdef QT_NO_CURSOR Q_UNUSED(sentEvent); #else @@ -439,7 +439,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) if (me->button() == Qt::RightButton || customWhatsThis) return false; QHelpEvent e(QEvent::WhatsThis, me->pos(), me->globalPos()); - if (!QApplication::sendEvent(w, &e) || !e.isAccepted()) + if (!QCoreApplication::sendEvent(w, &e) || !e.isAccepted()) leaveOnMouseRelease = true; } break; @@ -448,12 +448,12 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) { QMouseEvent *me = static_cast<QMouseEvent*>(e); QHelpEvent e(QEvent::QueryWhatsThis, me->pos(), me->globalPos()); - bool sentEvent = QApplication::sendEvent(w, &e); + const bool sentEvent = QCoreApplication::sendEvent(w, &e); #ifdef QT_NO_CURSOR Q_UNUSED(sentEvent); #else - QApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())? - Qt::ForbiddenCursor:Qt::WhatsThisCursor); + QGuiApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())? + Qt::ForbiddenCursor:Qt::WhatsThisCursor); #endif Q_FALLTHROUGH(); } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2176c612d0..89b0e56297 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -359,7 +359,7 @@ void QWidgetPrivate::scrollChildren(int dx, int dy) w->d_func()->setWSGeometry(); w->d_func()->setDirtyOpaqueRegion(); QMoveEvent e(r.topLeft(), oldp); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } } @@ -435,13 +435,13 @@ void QWidget::setEditFocus(bool on) if (!on && QWidgetPrivate::editingWidget == f) { QWidgetPrivate::editingWidget = 0; QEvent event(QEvent::LeaveEditFocus); - QApplication::sendEvent(f, &event); - QApplication::sendEvent(f->style(), &event); + QCoreApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f->style(), &event); } else if (on) { QWidgetPrivate::editingWidget = f; QEvent event(QEvent::EnterEditFocus); - QApplication::sendEvent(f, &event); - QApplication::sendEvent(f->style(), &event); + QCoreApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f->style(), &event); } } #endif @@ -1223,8 +1223,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) q->create(); QEvent e(QEvent::Create); - QApplication::sendEvent(q, &e); - QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); + QCoreApplication::sendEvent(q, &e); + QCoreApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); extraPaintEngine = 0; @@ -1255,8 +1255,10 @@ void QWidgetPrivate::createRecursively() QWindow *QWidgetPrivate::windowHandle(WindowHandleMode mode) const { if (mode == WindowHandleMode::Direct || mode == WindowHandleMode::Closest) { - if (QTLWExtra *x = maybeTopData()) - return x->window; + if (QTLWExtra *x = maybeTopData()) { + if (x->window != nullptr || mode == WindowHandleMode::Direct) + return x->window; + } } if (mode == WindowHandleMode::Closest) { if (auto nativeParent = q_func()->nativeParentWidget()) { @@ -1624,7 +1626,7 @@ QWidget::~QWidget() // Remove all shortcuts grabbed by this // widget, unless application is closing if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut)) - qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, QKeySequence()); #endif // delete layout while we still are a valid widget @@ -1732,7 +1734,7 @@ QWidget::~QWidget() if (!d->children.isEmpty()) d->deleteChildren(); - QApplication::removePostedEvents(this); + QCoreApplication::removePostedEvents(this); QT_TRY { destroy(); // platform-dependent cleanup @@ -2044,7 +2046,7 @@ void QWidgetPrivate::propagatePaletteChange() QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); QEvent pc(QEvent::PaletteChange); - QApplication::sendEvent(q, &pc); + QCoreApplication::sendEvent(q, &pc); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget*>(children.at(i)); if (w && (!w->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) @@ -2848,7 +2850,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate) #endif QEvent e(QEvent::StyleChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); #ifndef QT_NO_STYLE_STYLESHEET // dereference the old stylesheet style @@ -3066,7 +3068,7 @@ void QWidget::overrideWindowState(Qt::WindowStates newstate) { QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); data->window_state = newstate; - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3128,7 +3130,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) activateWindow(); QWindowStateChangeEvent e(oldstate); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3354,7 +3356,7 @@ void QWidget::insertAction(QAction *before, QAction *action) apriv->widgets.append(this); QActionEvent e(QEvent::ActionAdded, action, before); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3392,7 +3394,7 @@ void QWidget::removeAction(QAction *action) if (d->actions.removeAll(action)) { QActionEvent e(QEvent::ActionRemoved, action); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } @@ -3499,7 +3501,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) } #endif //QT_NO_IM QEvent e(QEvent::EnabledChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } /*! @@ -4566,7 +4568,7 @@ void QWidget::setForegroundRole(QPalette::ColorRole role) the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color". - \sa QApplication::palette(), QWidget::font(), {Qt Style Sheets} + \sa QGuiApplication::palette(), QWidget::font(), {Qt Style Sheets} */ const QPalette &QWidget::palette() const { @@ -4629,7 +4631,7 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const )) { if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) { - if (!naturalPalette.isCopyOf(QApplication::palette())) { + if (!naturalPalette.isCopyOf(QGuiApplication::palette())) { QPalette inheritedPalette = p->palette(); inheritedPalette.resolve(inheritedMask); naturalPalette = inheritedPalette.resolve(naturalPalette); @@ -4895,7 +4897,7 @@ void QWidgetPrivate::updateFont(const QFont &font) #endif QEvent e(QEvent::FontChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) @@ -4913,14 +4915,14 @@ void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) } } QEvent e(QEvent::LayoutDirectionChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidgetPrivate::resolveLayoutDirection() { Q_Q(const QWidget); if (!q->testAttribute(Qt::WA_SetLayoutDirection)) - setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); + setLayoutDirection_helper(q->isWindow() ? QGuiApplication::layoutDirection() : q->parentWidget()->layoutDirection()); } /*! @@ -5040,7 +5042,7 @@ void QWidget::setCursor(const QCursor &cursor) d->setCursor_sys(cursor); QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } void QWidgetPrivate::setCursor_sys(const QCursor &cursor) @@ -5062,7 +5064,7 @@ void QWidget::unsetCursor() d->unsetCursor_sys(); QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } void QWidgetPrivate::unsetCursor_sys() @@ -5260,7 +5262,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, static void sendResizeEvents(QWidget *target) { QResizeEvent e(target->size(), QSize()); - QApplication::sendEvent(target, &e); + QCoreApplication::sendEvent(target, &e); const QObjectList children = target->children(); for (int i = 0; i < children.size(); ++i) { @@ -6014,7 +6016,7 @@ void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) } } QEvent e(QEvent::LocaleChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidget::setLocale(const QLocale &locale) @@ -6189,7 +6191,7 @@ void QWidget::setWindowIconText(const QString &iconText) d->setWindowIconText_helper(iconText); QEvent e(QEvent::IconTextChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); emit windowIconTextChanged(iconText); } @@ -6213,7 +6215,7 @@ void QWidget::setWindowTitle(const QString &title) d->setWindowTitle_helper(title); QEvent e(QEvent::WindowTitleChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); emit windowTitleChanged(title); } @@ -6251,11 +6253,11 @@ void QWidgetPrivate::setWindowIcon_helper() // QWidgetWindow to the top level QWidget ensures that the event reaches // the top level anyhow if (!q->windowHandle()) - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(children.at(i)); if (w && !w->isWindow()) - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } @@ -6598,7 +6600,7 @@ void QWidget::setFocus(Qt::FocusReason reason) if (reason != Qt::NoFocusReason) { QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); - QApplication::sendEvent(prev, &focusAboutToChange); + QCoreApplication::sendEvent(prev, &focusAboutToChange); } } @@ -6625,9 +6627,9 @@ void QWidget::setFocus(Qt::FocusReason reason) // Send event to self QFocusEvent event(QEvent::FocusOut, reason); QPointer<QWidget> that = previousProxyFocus; - QApplication::sendEvent(previousProxyFocus, &event); + QCoreApplication::sendEvent(previousProxyFocus, &event); if (that) - QApplication::sendEvent(that->style(), &event); + QCoreApplication::sendEvent(that->style(), &event); } if (!isHidden()) { #if QT_CONFIG(graphicsview) @@ -6639,9 +6641,9 @@ void QWidget::setFocus(Qt::FocusReason reason) // Send event to self QFocusEvent event(QEvent::FocusIn, reason); QPointer<QWidget> that = f; - QApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f, &event); if (that) - QApplication::sendEvent(that->style(), &event); + QCoreApplication::sendEvent(that->style(), &event); } } } @@ -6748,7 +6750,7 @@ void QWidget::clearFocus() QGuiApplication::inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); - QApplication::sendEvent(this, &focusAboutToChange); + QCoreApplication::sendEvent(this, &focusAboutToChange); } QWidget *w = this; @@ -7395,11 +7397,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isMove) { QMoveEvent e(q->pos(), oldPos); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } if (isResize) { QResizeEvent e(r.size(), olds); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); if (q->windowHandle()) q->update(); } @@ -7697,13 +7699,13 @@ void QWidgetPrivate::updateContentsRect() if (q->isVisible()) { q->update(); QResizeEvent e(q->data->crect.size(), q->data->crect.size()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } else { q->setAttribute(Qt::WA_PendingResizeEvent, true); } QEvent e(QEvent::ContentsRectChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } /*! @@ -7999,13 +8001,13 @@ void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disable if (q->testAttribute(Qt::WA_PendingMoveEvent)) { QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); q->setAttribute(Qt::WA_PendingMoveEvent, false); } if (q->testAttribute(Qt::WA_PendingResizeEvent)) { QResizeEvent e(data.crect.size(), QSize()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); q->setAttribute(Qt::WA_PendingResizeEvent, false); } @@ -8115,7 +8117,7 @@ void QWidgetPrivate::show_helper() // send the show event before showing the window QShowEvent showEvent; - QApplication::sendEvent(q, &showEvent); + QCoreApplication::sendEvent(q, &showEvent); show_sys(); @@ -8138,7 +8140,7 @@ void QWidgetPrivate::show_helper() // is spinnning; otherwise it might not show up on particular platforms. // This makes QSplashScreen behave the same on all platforms. if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen) - QApplication::processEvents(); + QCoreApplication::processEvents(); data.in_show = false; // reset qws optimization } @@ -8164,9 +8166,9 @@ void QWidgetPrivate::show_sys() } if (renderToTexture && !q->isWindow()) - QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); + QCoreApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); else - QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); + QCoreApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) || q->testAttribute(Qt::WA_OutsideWSRange)) { @@ -8254,7 +8256,7 @@ void QWidgetPrivate::hide_helper() } QHideEvent hideEvent; - QApplication::sendEvent(q, &hideEvent); + QCoreApplication::sendEvent(q, &hideEvent); hideChildren(false); // next bit tries to move the focus if the focus widget is now @@ -8425,7 +8427,7 @@ void QWidgetPrivate::setVisible(bool visible) } QEvent showToParentEvent(QEvent::ShowToParent); - QApplication::sendEvent(q, &showToParentEvent); + QCoreApplication::sendEvent(q, &showToParentEvent); } else { // hide #if 0 // Used to be included in Qt4 for Q_WS_WIN // reset WS_DISABLED style in a Blocked window @@ -8456,11 +8458,11 @@ void QWidgetPrivate::setVisible(bool visible) if (q->parentWidget()->d_func()->layout) q->parentWidget()->d_func()->layout->invalidate(); else if (q->parentWidget()->isVisible()) - QApplication::postEvent(q->parentWidget(), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(q->parentWidget(), new QEvent(QEvent::LayoutRequest)); } QEvent hideToParentEvent(QEvent::HideToParent); - QApplication::sendEvent(q, &hideToParentEvent); + QCoreApplication::sendEvent(q, &hideToParentEvent); } } @@ -8535,7 +8537,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) if (spontaneous) { QApplication::sendSpontaneousEvent(widget, &e); } else { - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); if (widget->internalWinId() && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) { // hide_sys() on an ancestor won't have any affect on this @@ -8570,7 +8572,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode) if (mode == CloseWithSpontaneousEvent) QApplication::sendSpontaneousEvent(q, &e); else - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); if (!that.isNull() && !e.isAccepted()) { data.is_closing = 0; return false; @@ -9085,7 +9087,7 @@ bool QWidget::event(QEvent *event) setAttribute(Qt::WA_WState_Polished); if (!QApplication::font(this).isCopyOf(QApplication::font())) d->resolveFont(); - if (!QApplication::palette(this).isCopyOf(QApplication::palette())) + if (!QApplication::palette(this).isCopyOf(QGuiApplication::palette())) d->resolvePalette(); } break; @@ -9109,7 +9111,7 @@ bool QWidget::event(QEvent *event) #if QT_CONFIG(statustip) if (d->statusTip.size()) { QStatusTipEvent tip(d->statusTip); - QApplication::sendEvent(const_cast<QWidget *>(this), &tip); + QCoreApplication::sendEvent(const_cast<QWidget *>(this), &tip); } #endif enterEvent(event); @@ -9120,7 +9122,7 @@ bool QWidget::event(QEvent *event) if (d->statusTip.size()) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(const_cast<QWidget *>(this), &tip); + QCoreApplication::sendEvent(const_cast<QWidget *>(this), &tip); } #endif leaveEvent(event); @@ -9271,7 +9273,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(childList.at(i)); if (w && w->isVisible() && !w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } break; } @@ -9282,7 +9284,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); if (o) - QApplication::sendEvent(o, event); + QCoreApplication::sendEvent(o, event); } } update(); @@ -9321,7 +9323,7 @@ bool QWidget::event(QEvent *event) QWidget *w = static_cast<QWidget *>(o); // do not forward the event to child windows; QApplication does this for us if (!w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } } } @@ -9373,7 +9375,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(childList.at(i)); if (w && w->isVisible() && !w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } break; } @@ -9482,8 +9484,8 @@ void QWidget::changeEvent(QEvent * event) break; case QEvent::ThemeChange: - if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop - && qApp && !QApplication::closingDown()) { + if (QGuiApplication::desktopSettingsAware() && windowType() != Qt::Desktop + && qApp && !QCoreApplication::closingDown()) { if (testAttribute(Qt::WA_WState_Polished)) QApplication::style()->unpolish(this); if (testAttribute(Qt::WA_WState_Polished)) @@ -10550,7 +10552,7 @@ void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) if (parent->d_func()->layout) parent->d_func()->layout->invalidate(); else if (parent->isVisible()) - QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); } } } @@ -10704,7 +10706,7 @@ static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) QWidgetPrivate *d = QWidgetPrivate::get(widget); if (d->renderToTexture) { QEvent e(QEvent::WindowChangeInternal); - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); } for (int i = 0; i < d->children.size(); ++i) { @@ -10753,7 +10755,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; if (newParent && parent && !desktopWidget) { - if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) + if (testAttribute(Qt::WA_NativeWindow) && !QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) setAttribute(Qt::WA_NativeWindow); @@ -10766,7 +10768,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) } if (newParent) { QEvent e(QEvent::ParentAboutToChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } if (newParent && isAncestorOf(focusWidget())) @@ -10839,7 +10841,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) // send and post remaining QObject events if (parent && d->sendChildEvents) { QChildEvent e(QEvent::ChildAdded, this); - QApplication::sendEvent(parent, &e); + QCoreApplication::sendEvent(parent, &e); } //### already hidden above ---> must probably do something smart on the mac @@ -10857,7 +10859,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) } QEvent e(QEvent::ParentChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } #ifndef QT_NO_OPENGL //renderToTexture widgets also need to know when their top-level window changes @@ -11220,7 +11222,7 @@ void QWidgetPrivate::update(T r) return; if (q->testAttribute(Qt::WA_WState_InPaintEvent)) { - QApplication::postEvent(q, new QUpdateLaterEvent(clipped)); + QCoreApplication::postEvent(q, new QUpdateLaterEvent(clipped)); return; } @@ -11257,7 +11259,7 @@ void QWidgetPrivate::macUpdateSizeAttribute() { Q_Q(QWidget); QEvent event(QEvent::MacSizeChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(children.at(i)); if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) @@ -11313,7 +11315,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) setAttribute(Qt::WA_DropSiteRegistered, false); QEvent e(QEvent::AcceptDropsChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_DropSiteRegistered: { @@ -11396,11 +11398,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; case Qt::WA_MouseTracking: { QEvent e(QEvent::MouseTrackingChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_TabletTracking: { QEvent e(QEvent::TabletTrackingChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_NativeWindow: { d->createTLExtra(); @@ -11413,7 +11415,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) QGuiApplication::inputMethod()->commit(); QGuiApplication::inputMethod()->update(Qt::ImEnabled); } - if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) + if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); @@ -11515,10 +11517,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } break; case Qt::WA_TranslucentBackground: - if (on) { + if (on) setAttribute(Qt::WA_NoSystemBackground); - d->updateIsTranslucent(); - } + d->updateIsTranslucent(); break; case Qt::WA_AcceptTouchEvents: @@ -11649,7 +11650,7 @@ void QWidget::setWindowModified(bool mod) d->setWindowModified_helper(); QEvent e(QEvent::ModifiedChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::setWindowModified_helper() @@ -11695,7 +11696,7 @@ void QWidget::setToolTip(const QString &s) d->toolTip = s; QEvent event(QEvent::ToolTipChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } QString QWidget::toolTip() const @@ -11872,7 +11873,7 @@ int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) if (key.isEmpty()) return 0; setAttribute(Qt::WA_GrabbedShortcut); - return qApp->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); + return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); } /*! @@ -11894,7 +11895,7 @@ void QWidget::releaseShortcut(int id) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0); } /*! @@ -11913,7 +11914,7 @@ void QWidget::setShortcutEnabled(int id, bool enable) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enable, id, this, 0); } /*! @@ -11928,7 +11929,7 @@ void QWidget::setShortcutAutoRepeat(int id, bool enable) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); } #endif // QT_NO_SHORTCUT @@ -11983,7 +11984,7 @@ void QWidget::raise() QWindowContainer::parentWasRaised(this); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::raise_sys() @@ -12033,7 +12034,7 @@ void QWidget::lower() QWindowContainer::parentWasLowered(this); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::lower_sys() @@ -12080,7 +12081,7 @@ void QWidget::stackUnder(QWidget* w) d->stackUnder_sys(w); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::stackUnder_sys(QWidget*) diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 595beeaf47..ab33649b3e 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -491,11 +491,11 @@ void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, UpdateTime updateTi switch (updateTime) { case UpdateLater: updateRequestSent = true; - QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority); + QCoreApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority); break; case UpdateNow: { QEvent event(QEvent::UpdateRequest); - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); break; } } @@ -1507,7 +1507,7 @@ void QWidgetPrivate::invalidateBackingStore(const T &r) if (r.isEmpty()) return; - if (QApplication::closingDown()) + if (QCoreApplication::closingDown()) return; Q_Q(QWidget); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index a5d9eee49d..ba10083829 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -155,7 +155,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) // Enable QOpenGLWidget/QQuickWidget children if the platform plugin supports it, // and the application developer has not explicitly disabled it. if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { + && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { setSurfaceType(QSurface::RasterGLSurface); } connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); @@ -496,8 +496,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) static const QEvent::Type contextMenuTrigger = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ? QEvent::MouseButtonRelease : QEvent::MouseButtonPress; - if (qApp->d_func()->inPopupMode()) { - QWidget *activePopupWidget = qApp->activePopupWidget(); + if (QApplicationPrivate::inPopupMode()) { + QWidget *activePopupWidget = QApplication::activePopupWidget(); QPoint mapped = event->pos(); if (activePopupWidget != m_widget) mapped = activePopupWidget->mapFromGlobal(event->globalPos()); @@ -577,7 +577,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) } } - if (qApp->activePopupWidget() != activePopupWidget + if (QApplication::activePopupWidget() != activePopupWidget && qt_replay_popup_mouse_event && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { if (m_widget->windowType() != Qt::Popup) @@ -680,7 +680,7 @@ void QWidgetWindow::handleTouchEvent(QTouchEvent *event) if (event->type() == QEvent::TouchCancel) { QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp()); event->accept(); - } else if (qApp->d_func()->inPopupMode()) { + } else if (QApplicationPrivate::inPopupMode()) { // Ignore touch events for popups. This will cause QGuiApplication to synthesise mouse // events instead, which QWidgetWindow::handleMouseEvent will forward correctly: event->ignore(); @@ -744,7 +744,7 @@ void QWidgetWindow::updateMargins() static void sendScreenChangeRecursively(QWidget *widget) { QEvent e(QEvent::ScreenChangeInternal); - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); QWidgetPrivate *d = QWidgetPrivate::get(widget); for (int i = 0; i < d->children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 4b289d2d33..fd8581edbb 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -223,7 +223,7 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: // Otherwise we may end up with BadMatch failures on X11. if (embeddedWindow->surfaceType() == QSurface::RasterSurface && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) + && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) embeddedWindow->setSurfaceType(QSurface::RasterGLSurface); d->window = embeddedWindow; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 9e701995a4..7b53f5272c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1253,12 +1253,12 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w *iconRect = QRect(tr.left() + offsetX, tr.center().y() - tabIconSize.height() / 2, tabIconSize.width(), tabIconSize.height()); if (!verticalTabs) - *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); + *iconRect = QStyle::visualRect(opt->direction, opt->rect, *iconRect); tr.setLeft(tr.left() + tabIconSize.width() + 4); } if (!verticalTabs) - tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); + tr = QStyle::visualRect(opt->direction, opt->rect, tr); *textRect = tr; } @@ -4835,7 +4835,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_MessageBoxIconSize: #ifdef Q_OS_MAC - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { ret = 64; // No DPI scaling, it's handled elsewhere. } else #endif @@ -5460,14 +5460,14 @@ static QIcon clearTextIcon(bool rtl) QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, const QWidget *widget) const { - const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); + const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft()); #ifdef QT_NO_IMAGEFORMAT_PNG Q_UNUSED(widget); Q_UNUSED(sp); #else QPixmap pixmap; - if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { + if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (sp) { case SP_DialogYesButton: case SP_DialogOkButton: @@ -5829,7 +5829,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption const QWidget *widget) const { QIcon icon; - const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); + const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft()); #ifdef Q_OS_WIN switch (standardIcon) { @@ -5881,7 +5881,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption #endif - if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { + if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (standardIcon) { case SP_DirHomeIcon: icon = QIcon::fromTheme(QLatin1String("user-home")); @@ -6057,13 +6057,13 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption default: break; } - } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) + } // if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) if (!icon.isNull()) return icon; #if defined(Q_OS_MAC) - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { switch (standardIcon) { case SP_DirIcon: { // A rather special case @@ -6129,7 +6129,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption default: break; } - } // if (QApplication::desktopSettingsAware()) + } // if (QGuiApplication::desktopSettingsAware()) #endif // Q_OS_MAC switch (standardIcon) { diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 2c1132da19..6cbed34c3a 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -560,7 +560,7 @@ QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pi x += w - pixmapWidth; else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) x += w/2 - pixmapWidth/2; - else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft()) + else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QGuiApplication::isRightToLeft()) x += w - pixmapWidth; result = QRect(x, y, pixmapWidth, pixmapHeight); return result; @@ -624,7 +624,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const { qreal scale = pixmap.devicePixelRatio(); - QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); + QRect aligned = alignedRect(QGuiApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); QRect inter = aligned.intersected(rect); painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width() * scale, inter.height() *scale); diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 88031a9f1e..4faf98a0a3 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -151,7 +151,7 @@ QT_BEGIN_NAMESPACE QStyleOption::QStyleOption(int version, int type) : version(version), type(type), state(QStyle::State_None), - direction(QApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) + direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) { } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c1f498cd0c..ea653459d3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -909,7 +909,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject *object) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { - QPalette palette = QApplication::palette(); // ###: ideally widget's palette + QPalette palette = QGuiApplication::palette(); // ###: ideally widget's palette ValueExtractor v(declarations, palette); features = v.extractStyleFeatures(); @@ -2734,7 +2734,7 @@ static void updateObjects(const QList<const QObject *>& objects) for (const QObject *object : objects) { if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object))) { widget->style()->polish(widget); - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } } } @@ -6073,7 +6073,7 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const w->d_func()->directFontResolveMask = font.resolve(); QEvent e(QEvent::FontChange); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 3c0478b84e..c13f6e637d 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -84,6 +84,7 @@ #include <qpa/qplatformscreen.h> #include <private/qguiapplication_p.h> #include <private/qhighdpiscaling_p.h> +#include <private/qwidget_p.h> #include <private/qstylehelper_p.h> #if QT_CONFIG(animation) @@ -244,11 +245,12 @@ void QWindowsStyle::polish(QApplication *app) if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) app->installEventFilter(this); - d->activeCaptionColor = app->palette().highlight().color(); - d->activeGradientCaptionColor = app->palette().highlight() .color(); - d->inactiveCaptionColor = app->palette().dark().color(); - d->inactiveGradientCaptionColor = app->palette().dark().color(); - d->inactiveCaptionText = app->palette().window().color(); + const auto &palette = QGuiApplication::palette(); + d->activeGradientCaptionColor = palette.highlight().color(); + d->activeCaptionColor = d->activeGradientCaptionColor; + d->inactiveGradientCaptionColor = palette.dark().color(); + d->inactiveCaptionColor = d->inactiveGradientCaptionColor; + d->inactiveCaptionText = palette.window().color(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //fetch native title bar colors if(app->desktopSettingsAware()){ diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index e41f7e7573..ee0418b5b8 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -145,7 +145,9 @@ #include "QtWidgets/qscrollbar.h" #include "QtCore/qdir.h" +#if QT_CONFIG(stringlistmodel) #include "QtCore/qstringlistmodel.h" +#endif #if QT_CONFIG(dirmodel) #include "QtWidgets/qdirmodel.h" #endif @@ -1504,7 +1506,7 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e) case QEvent::InputMethod: case QEvent::ShortcutOverride: - QApplication::sendEvent(d->widget, e); + QCoreApplication::sendEvent(d->widget, e); break; default: diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index a8b2a00a80..55ec93c7d3 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -228,7 +228,7 @@ public: // we did send a press, so we need to fake a release now // release all pressed mouse buttons - /* Qt::MouseButtons mouseButtons = QApplication::mouseButtons(); + /* Qt::MouseButtons mouseButtons = QGuiApplication::mouseButtons(); for (int i = 0; i < 32; ++i) { if (mouseButtons & (1 << i)) { Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i); @@ -237,7 +237,7 @@ public: qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, - b, mouseButtons, QApplication::keyboardModifiers()); + b, mouseButtons, QGuiApplication::keyboardModifiers()); sendMouseEvent(&re); } }*/ @@ -246,8 +246,8 @@ public: qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway, - mouseButton, QApplication::mouseButtons() & ~mouseButton, - QApplication::keyboardModifiers(), mouseEventSource); + mouseButton, QGuiApplication::mouseButtons() & ~mouseButton, + QGuiApplication::keyboardModifiers(), mouseEventSource); sendMouseEvent(&re, RegrabMouseAfterwards); // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release! } diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 70e5f3678e..0c7bb94a91 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -151,11 +151,11 @@ bool QSystemTrayIconSys::event(QEvent *e) { switch (e->type()) { case QEvent::ToolTip: - QApplication::sendEvent(q, e); + QCoreApplication::sendEvent(q, e); break; #if QT_CONFIG(wheelevent) case QEvent::Wheel: - return QApplication::sendEvent(q, e); + return QCoreApplication::sendEvent(q, e); #endif default: break; diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 5ea8330db2..b9e0d3280f 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1086,7 +1086,7 @@ bool QAbstractScrollArea::event(QEvent *e) QScrollBar *vBar = verticalScrollBar(); QPointF delta = g->delta(); if (!delta.isNull()) { - if (QApplication::isRightToLeft()) + if (QGuiApplication::isRightToLeft()) delta.rx() *= -1; int newX = hBar->value() - delta.x(); int newY = vBar->value() - delta.y(); @@ -1325,9 +1325,9 @@ void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); if (e->orientation() == Qt::Horizontal) - QApplication::sendEvent(d->hbar, e); + QCoreApplication::sendEvent(d->hbar, e); else - QApplication::sendEvent(d->vbar, e); + QCoreApplication::sendEvent(d->vbar, e); } #endif diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 04276aa400..e6e9939a10 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -333,7 +333,7 @@ void QAbstractSpinBox::setReadOnly(bool enable) d->readOnly = enable; d->edit->setReadOnly(enable); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); update(); } @@ -574,10 +574,10 @@ QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const if (d->wrapping) return StepEnabled(StepUpEnabled | StepDownEnabled); StepEnabled ret = StepNone; - if (d->variantCompare(d->value, d->maximum) < 0) { + if (QAbstractSpinBoxPrivate::variantCompare(d->value, d->maximum) < 0) { ret |= StepUpEnabled; } - if (d->variantCompare(d->value, d->minimum) > 0) { + if (QAbstractSpinBoxPrivate::variantCompare(d->value, d->minimum) > 0) { ret |= StepDownEnabled; } return ret; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index a052f2df79..0b52747b6a 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2618,7 +2618,7 @@ bool QComboBoxPrivate::showNativePopup() // We need to fake one here to un-press the button. QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers()); - qApp->sendEvent(q, &mouseReleased); + QCoreApplication::sendEvent(q, &mouseReleased); #endif return true; @@ -2915,7 +2915,7 @@ void QComboBox::hidePopup() bool didFade = false; if (needFade) { #if defined(Q_OS_MAC) - QPlatformNativeInterface *platformNativeInterface = qApp->platformNativeInterface(); + QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); int at = platformNativeInterface->metaObject()->indexOfMethod("fadeWindow()"); if (at != -1) { QMetaMethod windowFade = platformNativeInterface->metaObject()->method(at); diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 642f35c638..45c72e24d4 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -645,7 +645,7 @@ QDateTimeEdit::Section QDateTimeEdit::currentSection() const if (QApplication::keypadNavigationEnabled() && d->focusOnButton) return NoSection; #endif - return d->convertToPublic(d->sectionType(d->currentSectionIndex)); + return QDateTimeEditPrivate::convertToPublic(d->sectionType(d->currentSectionIndex)); } void QDateTimeEdit::setCurrentSection(Section section) @@ -659,7 +659,7 @@ void QDateTimeEdit::setCurrentSection(Section section) int index = d->currentSectionIndex + 1; for (int i=0; i<2; ++i) { while (index < size) { - if (d->convertToPublic(d->sectionType(index)) == section) { + if (QDateTimeEditPrivate::convertToPublic(d->sectionType(index)) == section) { d->edit->setCursorPosition(d->sectionPos(index)); QDTEDEBUG << d->sectionPos(index); return; @@ -685,7 +685,7 @@ QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const Q_D(const QDateTimeEdit); if (index < 0 || index >= d->sectionNodes.size()) return NoSection; - return d->convertToPublic(d->sectionType(index)); + return QDateTimeEditPrivate::convertToPublic(d->sectionType(index)); } /*! @@ -879,7 +879,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) } d->formatExplicitlySet = true; - d->sections = d->convertSections(d->display); + d->sections = QDateTimeEditPrivate::convertSections(d->display); d->clearCache(); d->currentSectionIndex = qMin(d->currentSectionIndex, d->sectionNodes.size() - 1); @@ -2306,13 +2306,31 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event) style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this); } +/* + Returns the string for AM and PM markers. + + If a translation for "AM" and "PM" is installed, then use that. + Otherwise, use the default implementation, which uses the locale. +*/ QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const { + QString original; + QString translated; if (ap == AmText) { - return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); + original = QLatin1String(cs == UpperCase ? "AM" : "am"); + translated = (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); } else { - return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); + original = QLatin1String(cs == UpperCase ? "PM" : "pm"); + translated = (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); } + + // This logic fails if a translation exists but doesn't change the string, + // which we can accept as a corner-case for which a locale-derived answer + // will be acceptable. + if (original != translated) + return translated; + + return QDateTimeParser::getAmPmText(ap, cs); } int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 54504d124b..55ae42db04 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1678,12 +1678,9 @@ int QDockAreaLayoutInfo::prev(int index) const return -1; } +#if QT_CONFIG(tabbar) void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) { -#if !QT_CONFIG(tabbar) - Q_UNUSED(index); - Q_UNUSED(dockWidgetItem); -#else if (tabbed) { item_list.append(QDockAreaLayoutItem(dockWidgetItem)); updateTabBar(); @@ -1699,8 +1696,8 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) new_info->updateTabBar(); new_info->setCurrentTab(dockWidgetItem->widget()); } -#endif // QT_CONFIG(tabbar) } +#endif // QT_CONFIG(tabbar) void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem) @@ -3137,6 +3134,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do removePlaceHolder(dockWidget->objectName()); } +#if QT_CONFIG(tabbar) void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) { const QList<int> path = indexOf(first); @@ -3149,6 +3147,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) removePlaceHolder(second->objectName()); } +#endif // QT_CONFIG(tabbar) void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index ab9c0c476c..81384bd1b7 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -144,7 +144,9 @@ public: void remove(const QList<int> &path); void unnest(int index); void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem); +#if QT_CONFIG(tabbar) void tab(int index, QLayoutItem *dockWidgetItem); +#endif QDockAreaLayoutItem &item(const QList<int> &path); QDockAreaLayoutInfo *info(const QList<int> &path); QDockAreaLayoutInfo *info(QWidget *widget); @@ -275,7 +277,9 @@ public: bool restoreDockWidget(QDockWidget *dockWidget); void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget, Qt::Orientation orientation); +#if QT_CONFIG(tabbar) void tabifyDockWidget(QDockWidget *first, QDockWidget *second); +#endif void resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o); void apply(bool animate); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index b8b6c12bf3..28a7cee2a0 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -267,9 +267,11 @@ QDockWidgetLayout::~QDockWidgetLayout() bool QDockWidgetLayout::nativeWindowDeco() const { bool floating = parentWidget()->isWindow(); +#if QT_CONFIG(tabbar) if (auto groupWindow = qobject_cast<const QDockWidgetGroupWindow *>(parentWidget()->parentWidget())) floating = floating || groupWindow->tabLayoutInfo(); +#endif return nativeWindowDeco(floating); } @@ -1556,8 +1558,10 @@ bool QDockWidget::event(QEvent *event) const QObjectList &siblings = win->children(); onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; } +#if QT_CONFIG(tabbar) if (!isFloating() && layout != 0 && onTop) layout->raise(this); +#endif break; } case QEvent::WindowActivate: @@ -1590,7 +1594,7 @@ bool QDockWidget::event(QEvent *event) // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, - QApplication::mouseButtons(), QApplication::keyboardModifiers()); + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); } break; diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index bcc8d7815d..9463641369 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -569,8 +569,8 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) if (!w) return; - QApplication::sendPostedEvents(w, QEvent::Move); - QApplication::sendPostedEvents(w, QEvent::Resize); + QCoreApplication::sendPostedEvents(w, QEvent::Move); + QCoreApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; // those can be popups - they would steal the focus, but are disabled @@ -591,8 +591,8 @@ void qFadeEffect(QWidget* w, int time) if (!w) return; - QApplication::sendPostedEvents(w, QEvent::Move); - QApplication::sendPostedEvents(w, QEvent::Resize); + QCoreApplication::sendPostedEvents(w, QEvent::Move); + QCoreApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 09b7687d8e..68e3de05bc 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -84,7 +84,7 @@ #include "qkeysequence.h" #define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus) \ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \ - && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + && !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else #define ACCEL_KEY(k) QString() @@ -684,10 +684,10 @@ QSize QLineEdit::sizeHint() const ensurePolished(); QFontMetrics fm(font()); const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); - int h = qMax(fm.height(), iconSize - 2) + 2*d->verticalMargin + int h = qMax(fm.height(), iconSize - 2) + 2 * QLineEditPrivate::verticalMargin + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; - int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2*d->horizontalMargin + int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2 * QLineEditPrivate::horizontalMargin + d->effectiveLeftTextMargin() + d->effectiveRightTextMargin() + d->leftmargin + d->rightmargin; // "some" QStyleOptionFrame opt; @@ -708,7 +708,7 @@ QSize QLineEdit::minimumSizeHint() const Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm = fontMetrics(); - int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) + int h = fm.height() + qMax(2 * QLineEditPrivate::verticalMargin, fm.leading()) + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; int w = fm.maxWidth() @@ -1606,7 +1606,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e) } #endif #ifndef QT_NO_CLIPBOARD - if (QApplication::clipboard()->supportsSelection()) { + if (QGuiApplication::clipboard()->supportsSelection()) { if (e->button() == Qt::LeftButton) { d->control->copy(QClipboard::Selection); } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) { @@ -1960,17 +1960,18 @@ void QLineEdit::paintEvent(QPaintEvent *) Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); switch (va & Qt::AlignVertical_Mask) { case Qt::AlignBottom: - d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin; + d->vscroll = r.y() + r.height() - fm.height() - QLineEditPrivate::verticalMargin; break; case Qt::AlignTop: - d->vscroll = r.y() + d->verticalMargin; + d->vscroll = r.y() + QLineEditPrivate::verticalMargin; break; default: //center d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; break; } - QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); + QRect lineRect(r.x() + QLineEditPrivate::horizontalMargin, d->vscroll, + r.width() - 2 * QLineEditPrivate::horizontalMargin, fm.height()); if (d->shouldShowPlaceholderText()) { if (!d->placeholderText.isEmpty()) { @@ -2206,7 +2207,7 @@ QMenu *QLineEdit::createStandardContextMenu() if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); - action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty()); + action->setEnabled(!d->control->isReadOnly() && !QGuiApplication::clipboard()->text().isEmpty()); setActionIcon(action, QStringLiteral("edit-paste")); connect(action, SIGNAL(triggered()), SLOT(paste())); } diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 9c4c46f2d6..16ed699137 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1138,6 +1138,7 @@ void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, d_func()->layout->splitDockWidget(after, dockwidget, orientation); } +#if QT_CONFIG(tabbar) /*! \fn void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) @@ -1164,9 +1165,6 @@ void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const { QList<QDockWidget*> ret; -#if !QT_CONFIG(tabbar) - Q_UNUSED(dockwidget); -#else const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); if (info && info->tabbed && info->tabBar) { for(int i = 0; i < info->item_list.count(); ++i) { @@ -1180,9 +1178,9 @@ QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) co } } } -#endif return ret; } +#endif // QT_CONFIG(tabbar) /*! diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 85e3f87d77..c69451fa3e 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -171,8 +171,10 @@ public: Qt::Orientation orientation); void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, Qt::Orientation orientation); +#if QT_CONFIG(tabbar) void tabifyDockWidget(QDockWidget *first, QDockWidget *second); QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const; +#endif void removeDockWidget(QDockWidget *dockwidget); bool restoreDockWidget(QDockWidget *dockwidget); diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index b8f997b782..0fb3a86cf8 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -292,25 +292,31 @@ bool QDockWidgetGroupWindow::event(QEvent *e) switch (e->type()) { case QEvent::Close: +#if QT_CONFIG(tabbar) // Forward the close to the QDockWidget just as if its close button was pressed if (QDockWidget *dw = activeTabbedDockWidget()) { e->ignore(); dw->close(); adjustFlags(); } +#endif return true; case QEvent::Move: +#if QT_CONFIG(tabbar) // Let QDockWidgetPrivate::moseEvent handle the dragging if (QDockWidget *dw = activeTabbedDockWidget()) static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e)); +#endif return true; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: +#if QT_CONFIG(tabbar) // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop if (QDockWidget *dw = activeTabbedDockWidget()) static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e)); +#endif return true; case QEvent::ChildAdded: if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child())) @@ -347,6 +353,7 @@ QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const return static_cast<QDockWidgetGroupLayout *>(layout())->dockAreaLayoutInfo(); } +#if QT_CONFIG(tabbar) /*! \internal If this is a floating tab bar returns the currently the QDockWidgetGroupWindow that contains tab, otherwise, return nullptr; @@ -383,7 +390,6 @@ const QDockAreaLayoutInfo *QDockWidgetGroupWindow::tabLayoutInfo() const QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const { QDockWidget *dw = nullptr; -#if QT_CONFIG(tabbar) const QDockAreaLayoutInfo *info = tabLayoutInfo(); if (!info) return nullptr; @@ -405,9 +411,9 @@ QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const dw = qobject_cast<QDockWidget *>(item.widgetItem->widget()); } } -#endif return dw; } +#endif // QT_CONFIG(tabbar) /*! \internal Destroy or hide this window if there is no more QDockWidget in it. @@ -461,7 +467,11 @@ void QDockWidgetGroupWindow::adjustFlags() Qt::WindowFlags oldFlags = windowFlags(); Qt::WindowFlags flags = oldFlags; +#if QT_CONFIG(tabbar) QDockWidget *top = activeTabbedDockWidget(); +#else + QDockWidget *top = nullptr; +#endif if (!top) { // nested tabs, show window decoration flags = ((oldFlags & ~Qt::FramelessWindowHint) | Qt::CustomizeWindowHint | Qt::WindowTitleHint); @@ -507,6 +517,7 @@ void QDockWidgetGroupWindow::adjustFlags() bool QDockWidgetGroupWindow::hasNativeDecos() const { +#if QT_CONFIG(tabbar) QDockWidget *dw = activeTabbedDockWidget(); if (!dw) // We have a group of nested QDockWidgets (not just floating tabs) return true; @@ -515,6 +526,9 @@ bool QDockWidgetGroupWindow::hasNativeDecos() const return false; return dw->titleBarWidget() == nullptr; +#else + return true; +#endif } /* @@ -531,16 +545,18 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP savedState = *layoutInfo(); QMainWindow::DockOptions opts = static_cast<QMainWindow *>(parentWidget())->dockOptions(); + QDockAreaLayoutInfo newState = savedState; bool nestingEnabled = (opts & QMainWindow::AllowNestedDocks) && !(opts & QMainWindow::ForceTabbedDocks); QDockAreaLayoutInfo::TabMode tabMode = +#if !QT_CONFIG(tabbar) + QDockAreaLayoutInfo::NoTabs; +#else nestingEnabled ? QDockAreaLayoutInfo::AllowTabs : QDockAreaLayoutInfo::ForceTabs; if (auto group = qobject_cast<QDockWidgetGroupWindow *>(widgetItem->widget())) { if (!group->tabLayoutInfo()) tabMode = QDockAreaLayoutInfo::NoTabs; } - - QDockAreaLayoutInfo newState = savedState; if (newState.tabbed) { // insertion into a top-level tab newState.item_list = { QDockAreaLayoutItem(new QDockAreaLayoutInfo(newState)) }; @@ -548,6 +564,7 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP newState.tabbed = false; newState.tabBar = nullptr; } +#endif auto newGapPos = newState.gapIndex(mousePos, nestingEnabled, tabMode); Q_ASSERT(!newGapPos.isEmpty()); @@ -1498,14 +1515,6 @@ void QMainWindowLayout::addDockWidget(Qt::DockWidgetArea area, invalidate(); } -void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) -{ - addChildWidget(second); - layoutState.dockAreaLayout.tabifyDockWidget(first, second); - emit second->dockLocationChanged(dockWidgetArea(first)); - invalidate(); -} - bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget) { addChildWidget(dockwidget); @@ -1517,6 +1526,14 @@ bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget) } #if QT_CONFIG(tabbar) +void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) +{ + addChildWidget(second); + layoutState.dockAreaLayout.tabifyDockWidget(first, second); + emit second->dockLocationChanged(dockWidgetArea(first)); + invalidate(); +} + bool QMainWindowLayout::documentMode() const { return _documentMode; @@ -1535,20 +1552,15 @@ void QMainWindowLayout::setDocumentMode(bool enabled) for (QTabBar *bar : qAsConst(unusedTabBars)) bar->setDocumentMode(_documentMode); } -#endif // QT_CONFIG(tabbar) void QMainWindowLayout::setVerticalTabsEnabled(bool enabled) { -#if !QT_CONFIG(tabbar) - Q_UNUSED(enabled); -#else if (verticalTabsEnabled == enabled) return; verticalTabsEnabled = enabled; updateTabBarShapes(); -#endif // QT_CONFIG(tabbar) } #if QT_CONFIG(tabwidget) @@ -1609,7 +1621,6 @@ static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWid } #endif // QT_CONFIG(tabwidget) -#if QT_CONFIG(tabbar) void QMainWindowLayout::updateTabBarShapes() { #if QT_CONFIG(tabwidget) @@ -1851,19 +1862,17 @@ void QMainWindowLayout::tabMoved(int from, int to) info->moveTab(from, to); } -#endif // QT_CONFIG(tabbar) void QMainWindowLayout::raise(QDockWidget *widget) { -#if QT_CONFIG(tabbar) QDockAreaLayoutInfo *info = dockInfo(widget); if (info == 0) return; if (!info->tabbed) return; info->setCurrentTab(widget); -#endif } +#endif // QT_CONFIG(tabbar) #endif // QT_CONFIG(dockwidget) @@ -2329,7 +2338,7 @@ void QMainWindowLayout::setDockOptions(QMainWindow::DockOptions opts) dockOptions = opts; -#if QT_CONFIG(dockwidget) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar) setVerticalTabsEnabled(opts & QMainWindow::VerticalTabs); #endif @@ -2413,7 +2422,7 @@ static bool unplugGroup(QMainWindowLayout *layout, QLayoutItem **item, */ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) { -#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) auto *groupWindow = qobject_cast<const QDockWidgetGroupWindow *>(widget->parentWidget()); if (!widget->isWindow() && groupWindow) { if (group && groupWindow->tabLayoutInfo()) { @@ -2525,10 +2534,10 @@ void QMainWindowLayout::updateGapIndicator() #endif // QT_CONFIG(rubberband) } +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) { QTabBar::Shape result = QTabBar::RoundedSouth; -#if QT_CONFIG(tabwidget) if (qobject_cast<QDockWidget *>(w)) { switch (static_cast<QDockWidgetPrivate *>(qt_widget_private(w))->tabPosition) { case QTabWidget::North: @@ -2545,9 +2554,9 @@ static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) break; } } -#endif // tabwidget return result; } +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) { @@ -2591,6 +2600,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (!w->geometry().contains(mousePos)) continue; +#if QT_CONFIG(tabwidget) if (auto dropTo = qobject_cast<QDockWidget *>(w)) { // dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two // tabs @@ -2612,6 +2622,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) w = floatingTabs; widget->raise(); // raise, as our newly created drop target is now on top } +#endif Q_ASSERT(qobject_cast<QDockWidgetGroupWindow *>(w)); auto group = static_cast<QDockWidgetGroupWindow *>(w); if (group->hover(widgetItem, group->mapFromGlobal(mousePos))) { diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 7cdb8ead2f..967b713096 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -337,8 +337,10 @@ public: explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr) : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; +#if QT_CONFIG(tabbar) const QDockAreaLayoutInfo *tabLayoutInfo() const; QDockWidget *activeTabbedDockWidget() const; +#endif void destroyOrHideIfEmpty(); void adjustFlags(); bool hasNativeDecos() const; @@ -494,13 +496,13 @@ public: void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, Qt::Orientation orientation); - void tabifyDockWidget(QDockWidget *first, QDockWidget *second); Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const; + bool restoreDockWidget(QDockWidget *dockwidget); +#if QT_CONFIG(tabbar) + void tabifyDockWidget(QDockWidget *first, QDockWidget *second); void raise(QDockWidget *widget); void setVerticalTabsEnabled(bool enabled); - bool restoreDockWidget(QDockWidget *dockwidget); -#if QT_CONFIG(tabbar) QDockAreaLayoutInfo *dockInfo(QWidget *w); bool _documentMode; bool documentMode() const; diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index fe3d1663a8..c7b7e5bf97 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -2525,7 +2525,7 @@ bool QMdiArea::event(QEvent *event) case QEvent::WindowIconChange: foreach (QMdiSubWindow *window, d->childWindows) { if (sanityCheck(window, "QMdiArea::WindowIconChange")) - QApplication::sendEvent(window, event); + QCoreApplication::sendEvent(window, event); } break; case QEvent::Hide: diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 685c5e159e..474cce983c 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1826,7 +1826,7 @@ void QMdiSubWindowPrivate::showButtonsInMenuBar(QMenuBar *menuBar) // Make sure topLevelWindow->contentsRect returns correct geometry. // topLevelWidget->updateGeoemtry will not do the trick here since it will post the event. QEvent event(QEvent::LayoutRequest); - QApplication::sendEvent(topLevelWindow, &event); + QCoreApplication::sendEvent(topLevelWindow, &event); } } @@ -1936,7 +1936,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const #ifndef COLOR_GRADIENTINACTIVECAPTION #define COLOR_GRADIENTINACTIVECAPTION 28 #endif - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { newPalette.setColor(QPalette::Active, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION))); newPalette.setColor(QPalette::Inactive, QPalette::Highlight, @@ -1986,7 +1986,7 @@ void QMdiSubWindowPrivate::updateActions() for (int i = 0; i < NumWindowStateActions; ++i) setVisible(WindowStateAction(i), false); -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) && QT_CONFIG(action) if (q_func()->style()->inherits("QMacStyle")) for (int i = 0; i < NumWindowStateActions; ++i) if (QAction *action = actions[i]) @@ -3050,7 +3050,7 @@ void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent) d->setActive(false); if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) { QChildEvent childRemoved(QEvent::ChildRemoved, this); - QApplication::sendEvent(parentWidget(), &childRemoved); + QCoreApplication::sendEvent(parentWidget(), &childRemoved); } closeEvent->accept(); } diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 7b6a1b6da8..72653b377d 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -264,7 +264,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w)); } else { QStyleOption opt; - item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); + item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); } } else { item->setIcon(QIcon()); @@ -907,7 +907,7 @@ void QMenuPrivate::updateLayoutDirection() else if (QWidget *w = q->parentWidget()) setLayoutDirection_helper(w->layoutDirection()); else - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } } @@ -1335,7 +1335,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) if (e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); - QApplication::sendEvent(caused, &new_e); + QCoreApplication::sendEvent(caused, &new_e); return true; } } @@ -1543,7 +1543,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) if (d->currentAction && d->currentAction == action && !d->currentAction->isSeparator()) { option->state |= QStyle::State_Selected - | (d->mouseDown ? QStyle::State_Sunken : QStyle::State_None); + | (QMenuPrivate::mouseDown ? QStyle::State_Sunken : QStyle::State_None); } option->menuHasCheckableItems = d->hasCheckableItems; @@ -2362,7 +2362,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) QRect screen; #if QT_CONFIG(graphicsview) - bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this); if (isEmbedded) screen = d->popupGeometry(); else @@ -2698,8 +2698,8 @@ void QMenu::hideEvent(QHideEvent *) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) mb->d_func()->setCurrentAction(0); #endif - if (d->mouseDown == this) - d->mouseDown = 0; + if (QMenuPrivate::mouseDown == this) + QMenuPrivate::mouseDown = nullptr; d->hasHadMouse = false; if (d->activeMenu) d->hideMenu(d->activeMenu); @@ -2874,7 +2874,7 @@ void QMenu::mousePressEvent(QMouseEvent *e) d->hideUpToMenuBar(); return; } - d->mouseDown = this; + QMenuPrivate::mouseDown = this; QAction *action = d->actionAt(e->pos()); d->setCurrentAction(action, 20); @@ -2889,12 +2889,12 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) Q_D(QMenu); if (d->aboutToHide || d->mouseEventTaken(e)) return; - if(d->mouseDown != this) { - d->mouseDown = 0; + if (QMenuPrivate::mouseDown != this) { + QMenuPrivate::mouseDown = nullptr; return; } - d->mouseDown = 0; + QMenuPrivate::mouseDown = nullptr; d->setSyncAction(); QAction *action = d->actionAt(e->pos()); @@ -2995,7 +2995,7 @@ QMenu::event(QEvent *e) d->updateActionRects(); break; } case QEvent::Show: - d->mouseDown = 0; + QMenuPrivate::mouseDown = nullptr; d->updateActionRects(); d->sloppyState.reset(); if (d->currentAction) @@ -3385,7 +3385,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) { QAction *oldAct = mb->d_func()->currentAction; - QApplication::sendEvent(mb, e); + QCoreApplication::sendEvent(mb, e); if (mb->d_func()->currentAction != oldAct) key_consumed = true; } @@ -3428,7 +3428,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) } if (e->buttons()) - d->mouseDown = this; + QMenuPrivate::mouseDown = this; if (d->activeMenu) d->activeMenu->d_func()->setCurrentAction(0); @@ -3593,7 +3593,7 @@ void QMenu::internalDelayedPopup() QRect screen; #if QT_CONFIG(graphicsview) - bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this); if (isEmbedded) screen = d->popupGeometry(); else diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 9a60f1477d..3d31a3b73a 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -404,7 +404,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat } else if (previousAction) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(q, &tip); + QCoreApplication::sendEvent(q, &tip); #endif } if (fw) @@ -701,7 +701,7 @@ void QMenuBarPrivate::init() q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); q->setAttribute(Qt::WA_CustomWhatsThis); - if (!QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar)) + if (!QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar)) platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); if (platformMenuBar) diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 4a875975a4..397304ec44 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -1588,7 +1588,7 @@ bool QPlainTextEdit::event(QEvent *e) d->originalOffsetY = vBar->value(); QPointF offset = g->offset(); if (!offset.isNull()) { - if (QApplication::isRightToLeft()) + if (QGuiApplication::isRightToLeft()) offset.rx() *= -1; // QPlainTextEdit scrolls by lines only in vertical direction QFontMetrics fm(document()->defaultFont()); @@ -2649,7 +2649,7 @@ void QPlainTextEdit::setReadOnly(bool ro) d->control->setTextInteractionFlags(flags); setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 97a3a12336..61ea81c892 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -384,7 +384,7 @@ void QSpinBox::setMinimum(int minimum) { Q_D(QSpinBox); const QVariant m(minimum); - d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); + d->setRange(m, (QSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m)); } /*! @@ -412,7 +412,7 @@ void QSpinBox::setMaximum(int maximum) { Q_D(QSpinBox); const QVariant m(maximum); - d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); + d->setRange((QSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); } /*! @@ -864,7 +864,7 @@ void QDoubleSpinBox::setMinimum(double minimum) Q_D(QDoubleSpinBox); d->actualMin = minimum; const QVariant m(d->round(minimum)); - d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); + d->setRange(m, (QDoubleSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m)); } /*! @@ -895,7 +895,7 @@ void QDoubleSpinBox::setMaximum(double maximum) Q_D(QDoubleSpinBox); d->actualMax = maximum; const QVariant m(d->round(maximum)); - d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); + d->setRange((QDoubleSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); } /*! diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index bf6bf1c7c9..e39ef6d1cd 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -111,7 +111,7 @@ public: The user can hide the splash screen by clicking on it with the mouse. Since the splash screen is typically displayed before the event loop has started running, it is necessary to periodically - call QApplication::processEvents() to receive the mouse clicks. + call QCoreApplication::processEvents() to receive the mouse clicks. It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded @@ -170,13 +170,13 @@ void QSplashScreen::mousePressEvent(QMouseEvent *) /*! This overrides QWidget::repaint(). It differs from the standard repaint - function in that it also calls QApplication::processEvents() to ensure + function in that it also calls QCoreApplication::processEvents() to ensure the updates are displayed, even when there is no event loop present. */ void QSplashScreen::repaint() { QWidget::repaint(); - QApplication::processEvents(); + QCoreApplication::processEvents(); } /*! diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index b13f4da9d2..f6f56c12d1 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -843,7 +843,7 @@ void QTabBarPrivate::refresh() // be safe in case a subclass is also handling move with the tabs if (pressedIndex != -1 && movable - && QApplication::mouseButtons() == Qt::NoButton) { + && QGuiApplication::mouseButtons() == Qt::NoButton) { moveTabFinished(pressedIndex); if (!validIndex(pressedIndex)) pressedIndex = -1; diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index bee1021950..7a77f86de2 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -57,7 +57,6 @@ #endif #include <qtextobject.h> #include <qdesktopservices.h> -#include <qmimedatabase.h> QT_BEGIN_NAMESPACE @@ -313,13 +312,17 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType if (data.type() == QVariant::String) { txt = data.toString(); } else if (data.type() == QVariant::ByteArray) { + if (type == QTextDocument::HtmlResource) { #if QT_CONFIG(textcodec) - QByteArray ba = data.toByteArray(); - QTextCodec *codec = Qt::codecForHtml(ba); - txt = codec->toUnicode(ba); + QByteArray ba = data.toByteArray(); + QTextCodec *codec = Qt::codecForHtml(ba); + txt = codec->toUnicode(ba); #else - txt = data.toString(); + txt = data.toString(); #endif + } else { + txt = QString::fromUtf8(data.toByteArray()); + } } if (Q_UNLIKELY(txt.isEmpty())) qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData()); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 01f7c34f93..8599573e5a 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -167,7 +167,9 @@ void QTextEditPrivate::init(const QString &html) QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool))); QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged())); +#if QT_CONFIG(cursor) QObject::connect(control, SIGNAL(blockMarkerHovered(QTextBlock)), q, SLOT(_q_hoveredBlockWithMarkerChanged(QTextBlock))); +#endif QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus())); @@ -230,6 +232,7 @@ void QTextEditPrivate::_q_cursorPositionChanged() #endif } +#if QT_CONFIG(cursor) void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) { Q_Q(QTextEdit); @@ -244,6 +247,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) } viewport->setCursor(cursor); } +#endif void QTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode) { @@ -2260,7 +2264,7 @@ void QTextEdit::setReadOnly(bool ro) d->control->setTextInteractionFlags(flags); setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 09ef44b7b2..5c8a3c7793 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -331,7 +331,9 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars()) Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &)) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged()) +#if QT_CONFIG(cursor) Q_PRIVATE_SLOT(d_func(), void _q_hoveredBlockWithMarkerChanged(const QTextBlock &)) +#endif friend class QTextEditControl; friend class QTextDocument; friend class QWidgetTextControl; diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index bcf5a40ae3..fcaafbc581 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1172,7 +1172,7 @@ bool QToolBar::event(QEvent *event) // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, - QApplication::mouseButtons(), QApplication::keyboardModifiers()); + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); #endif } else { diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index cf2d885b52..56dba1dd32 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -158,7 +158,7 @@ void QWidgetLineControl::copy(QClipboard::Mode mode) const { QString t = selectedText(); if (!t.isEmpty() && m_echoMode == QLineEdit::Normal) { - QApplication::clipboard()->setText(t, mode); + QGuiApplication::clipboard()->setText(t, mode); } } @@ -172,7 +172,7 @@ void QWidgetLineControl::copy(QClipboard::Mode mode) const */ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode) { - QString clip = QApplication::clipboard()->text(clipboardMode); + QString clip = QGuiApplication::clipboard()->text(clipboardMode); if (!clip.isEmpty() || hasSelectedText()) { separate(); //make it a separate undo/redo command insert(clip); @@ -1524,9 +1524,9 @@ void QWidgetLineControl::setBlinkingCursorEnabled(bool enable) m_blinkEnabled = enable; if (enable) - connect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); + connect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); else - disconnect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); + disconnect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); updateCursorBlinking(); } @@ -1680,7 +1680,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (hasAcceptableInput() || fixup()) { - QInputMethod *inputMethod = QApplication::inputMethod(); + QInputMethod *inputMethod = QGuiApplication::inputMethod(); inputMethod->commit(); QWidget *lineEdit = qobject_cast<QWidget *>(parent()); if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine)) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index cad3a64749..70e1c148a1 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -97,7 +97,7 @@ #include <qkeysequence.h> #define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \ - && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + && !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else @@ -648,7 +648,7 @@ void QWidgetTextControlPrivate::_q_updateCurrentCharFormatAndSelection() #ifndef QT_NO_CLIPBOARD void QWidgetTextControlPrivate::setClipboardSelection() { - QClipboard *clipboard = QApplication::clipboard(); + QClipboard *clipboard = QGuiApplication::clipboard(); if (!cursor.hasSelection() || !clipboard->supportsSelection()) return; Q_Q(QWidgetTextControl); @@ -719,9 +719,9 @@ void QWidgetTextControlPrivate::setCursorVisible(bool visible) updateCursorBlinking(); if (cursorVisible) - connect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); + connect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); else - disconnect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); + disconnect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); } void QWidgetTextControlPrivate::updateCursorBlinking() @@ -959,12 +959,12 @@ void QWidgetTextControl::copy() if (!d->cursor.hasSelection()) return; QMimeData *data = createMimeDataFromSelection(); - QApplication::clipboard()->setMimeData(data); + QGuiApplication::clipboard()->setMimeData(data); } void QWidgetTextControl::paste(QClipboard::Mode mode) { - const QMimeData *md = QApplication::clipboard()->mimeData(mode); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(mode); if (md) insertFromMimeData(md); } @@ -1787,9 +1787,9 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but selectionChanged(true); } else if (button == Qt::MidButton && (interactionFlags & Qt::TextEditable) - && QApplication::clipboard()->supportsSelection()) { + && QGuiApplication::clipboard()->supportsSelection()) { setCursorPosition(pos); - const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(QClipboard::Selection); if (md) q->insertFromMimeData(md); #endif @@ -2598,7 +2598,7 @@ bool QWidgetTextControl::canPaste() const #ifndef QT_NO_CLIPBOARD Q_D(const QWidgetTextControl); if (d->interactionFlags & Qt::TextEditable) { - const QMimeData *md = QApplication::clipboard()->mimeData(); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(); return md && canInsertFromMimeData(md); } #endif @@ -3175,7 +3175,7 @@ QString QWidgetTextControl::toHtml() const } #endif -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(textmarkdownwriter) QString QWidgetTextControl::toMarkdown(QTextDocument::MarkdownFeatures features) const { return document()->toMarkdown(features); @@ -3331,7 +3331,7 @@ void QWidgetTextControlPrivate::_q_copyLink() #ifndef QT_NO_CLIPBOARD QMimeData *md = new QMimeData; md->setText(linkToCopy); - QApplication::clipboard()->setMimeData(md); + QGuiApplication::clipboard()->setMimeData(md); #endif } |