diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/doc/snippets/qsplashscreen/main.cpp | 7 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemdelegate.cpp | 42 | ||||
-rw-r--r-- | src/widgets/itemviews/qdirmodel.cpp | 4 | ||||
-rw-r--r-- | src/widgets/itemviews/qdirmodel.h | 11 | ||||
-rw-r--r-- | src/widgets/itemviews/qtablewidget.cpp | 6 | ||||
-rw-r--r-- | src/widgets/itemviews/qtablewidget.h | 5 | ||||
-rw-r--r-- | src/widgets/util/qcompleter.cpp | 10 | ||||
-rw-r--r-- | src/widgets/util/qsystemtrayicon.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets.pro | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmenubar.cpp | 13 | ||||
-rw-r--r-- | src/widgets/widgets/qsplashscreen.cpp | 38 | ||||
-rw-r--r-- | src/widgets/widgets/qsplashscreen.h | 4 |
12 files changed, 97 insertions, 47 deletions
diff --git a/src/widgets/doc/snippets/qsplashscreen/main.cpp b/src/widgets/doc/snippets/qsplashscreen/main.cpp index 843932ca83..2512035879 100644 --- a/src/widgets/doc/snippets/qsplashscreen/main.cpp +++ b/src/widgets/doc/snippets/qsplashscreen/main.cpp @@ -71,3 +71,10 @@ int main(int argc, char *argv[]) return app.exec(); } //! [1] + +//! [2] +QScreen *screen = QGuiApplication::screens().at(1); +QPixmap pixmap(":/splash.png"); +QSplashScreen splash(screen, pixmap); +splash.show(); +//! [2] diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 31dde8832b..eecc18e5c7 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -387,44 +387,46 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, const QStyleOptionViewItem &option, const QModelIndex &index) { - Q_D(QAbstractItemDelegate); - Q_UNUSED(d); - Q_UNUSED(index); - Q_UNUSED(option); - if (!event || !view) return false; + Q_D(QAbstractItemDelegate); switch (event->type()) { #ifndef QT_NO_TOOLTIP case QEvent::ToolTip: { QHelpEvent *he = static_cast<QHelpEvent*>(event); const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp - const QString tooltip = d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision); - if (!tooltip.isEmpty()) { - QToolTip::showText(he->globalPos(), tooltip, view); - return true; + const QString tooltip = index.isValid() ? + d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) : + QString(); + QRect rect; + if (index.isValid()) { + const QRect r = view->visualRect(index); + rect = QRect(view->mapToGlobal(r.topLeft()), r.size()); + } + QToolTip::showText(he->globalPos(), tooltip, view, rect); + event->setAccepted(!tooltip.isEmpty()); + break; } - break;} #endif #if QT_CONFIG(whatsthis) - case QEvent::QueryWhatsThis: { - if (index.data(Qt::WhatsThisRole).isValid()) - return true; - break; } + case QEvent::QueryWhatsThis: + event->setAccepted(index.data(Qt::WhatsThisRole).isValid()); + break; case QEvent::WhatsThis: { QHelpEvent *he = static_cast<QHelpEvent*>(event); const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp - const QString whatsthis = d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision); - if (!whatsthis.isEmpty()) { - QWhatsThis::showText(he->globalPos(), whatsthis, view); - return true; + const QString whatsthis = index.isValid() ? + d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision) : + QString(); + QWhatsThis::showText(he->globalPos(), whatsthis, view); + event->setAccepted(!whatsthis.isEmpty()); + break; } - break ; } #endif default: break; } - return false; + return event->isAccepted(); } /*! diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 13a1bbd8eb..ba7ee15314 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -39,6 +39,8 @@ #include "qdirmodel.h" +#if QT_DEPRECATED_SINCE(5, 15) + #include <qfile.h> #include <qfilesystemmodel.h> #include <qurl.h> @@ -1372,3 +1374,5 @@ QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info) QT_END_NAMESPACE #include "moc_qdirmodel.cpp" + +#endif // QT_DEPRECATED_SINCE(5, 15) diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h index ab91bbd763..665a622dbe 100644 --- a/src/widgets/itemviews/qdirmodel.h +++ b/src/widgets/itemviews/qdirmodel.h @@ -45,6 +45,8 @@ #include <QtCore/qdir.h> #include <QtWidgets/qfileiconprovider.h> +#if QT_DEPRECATED_SINCE(5, 15) + QT_REQUIRE_CONFIG(dirmodel); QT_BEGIN_NAMESPACE @@ -65,9 +67,10 @@ public: FileNameRole }; - QDirModel(const QStringList &nameFilters, QDir::Filters filters, - QDir::SortFlags sort, QObject *parent = nullptr); - explicit QDirModel(QObject *parent = nullptr); + QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") QDirModel(const QStringList &nameFilters, + QDir::Filters filters, QDir::SortFlags sort, + QObject *parent = nullptr); + QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") explicit QDirModel(QObject *parent = nullptr); ~QDirModel(); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; @@ -144,4 +147,6 @@ private: QT_END_NAMESPACE +#endif // QT_DEPRECATED_SINCE(5, 15) + #endif // QDIRMODEL_H diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index a25a582881..b1dbafa997 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -923,10 +923,8 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bo Constructs a the table selection range by copying the given \a other table selection range. */ -QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) - : top(other.top), left(other.left), bottom(other.bottom), right(other.right) -{ -} +QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) = default; +QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &other) = default; /*! Destroys the table selection range. diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index d93032f3f0..0d93a0a075 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -49,14 +49,17 @@ QT_REQUIRE_CONFIG(tablewidget); QT_BEGIN_NAMESPACE +// ### Qt6 unexport the class, remove the user-defined special 3 and make it a literal type. class Q_WIDGETS_EXPORT QTableWidgetSelectionRange { public: QTableWidgetSelectionRange(); QTableWidgetSelectionRange(int top, int left, int bottom, int right); - QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); ~QTableWidgetSelectionRange(); + QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); + QTableWidgetSelectionRange &operator=(const QTableWidgetSelectionRange &other); + inline int topRow() const { return top; } inline int bottomRow() const { return bottom; } inline int leftColumn() const { return left; } diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 7b69eff30c..3c0271e7c2 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -473,7 +473,7 @@ QMatchData QCompletionEngine::filterHistory() if (curParts.count() <= 1 || c->proxy->showAll || !source) return QMatchData(); -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) const bool isDirModel = (qobject_cast<QDirModel *>(source) != nullptr); #else const bool isDirModel = false; @@ -903,7 +903,7 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) QModelIndex si = proxy->mapToSource(index); si = si.sibling(si.row(), column); // for clicked() completion = q->pathFromIndex(si); -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) // add a trailing separator in inline if (mode == QCompleter::InlineCompletion) { if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir()) @@ -1125,7 +1125,7 @@ void QCompleter::setModel(QAbstractItemModel *model) setPopup(d->popup); // set the model and make new connections if (oldModel && oldModel->QObject::parent() == this) delete oldModel; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) if (qobject_cast<QDirModel *>(model)) { #if defined(Q_OS_WIN) setCaseSensitivity(Qt::CaseInsensitive); @@ -1846,7 +1846,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const return QString(); bool isDirModel = false; bool isFsModel = false; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != nullptr; #endif #if QT_CONFIG(filesystemmodel) @@ -1895,7 +1895,7 @@ QStringList QCompleter::splitPath(const QString& path) const { bool isDirModel = false; bool isFsModel = false; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) Q_D(const QCompleter); isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != nullptr; #endif diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index fd18888870..ae81cc5661 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -367,8 +367,6 @@ bool QSystemTrayIcon::event(QEvent *e) This signal is emitted when the message displayed using showMessage() was clicked by the user. - Currently this signal is not sent on \macos. - \note We follow Microsoft Windows behavior, so the signal is also emitted when the user clicks on a tray icon with a balloon message displayed. diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index 6f807e1696..2aa56ded93 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -9,6 +9,8 @@ msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x65000000 TRACEPOINT_PROVIDER = $$PWD/qtwidgets.tracepoints CONFIG += qt_tracepoints +CONFIG += metatypes install_metatypes + QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf #platforms diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 3d31a3b73a..69b1c5896f 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -324,15 +324,10 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1))); QSize popup_size = activeMenu->sizeHint(); //we put the popup menu on the screen containing the bottom-center of the action rect - QScreen *popupScreen = q->window()->windowHandle()->screen(); - QPoint bottomMiddlePos = pos + QPoint(adjustedActionRect.width() / 2, 0); - const auto &siblings = popupScreen->virtualSiblings(); - for (QScreen *sibling : siblings) { - if (sibling->geometry().contains(bottomMiddlePos)) { - popupScreen = sibling; - break; - } - } + QScreen *menubarScreen = q->window()->windowHandle()->screen(); + QScreen *popupScreen = menubarScreen->virtualSiblingAt(pos + QPoint(adjustedActionRect.width() / 2, 0)); + if (!popupScreen) + popupScreen = menubarScreen; QRect screenRect = popupScreen->geometry(); pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); const bool fitUp = (pos.y() - popup_size.height() >= screenRect.top()); diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index e39ef6d1cd..b7c3426e08 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -123,6 +123,11 @@ public: wish to do your own drawing you can get a pointer to the pixmap used in the splash screen with pixmap(). Alternatively, you can subclass QSplashScreen and reimplement drawContents(). + + In case of having multiple screens, it is also possible to show the + splash screen on a different screen than the primary one. For example: + + \snippet qsplashscreen/main.cpp 2 */ /*! @@ -139,6 +144,23 @@ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) /*! \overload + \since 5.15 + + This function allows you to specify the screen for your splashscreen. The + typical use for this constructor is if you have multiple screens and + prefer to have the splash screen on a different screen than your primary + one. In that case pass the proper \a screen. +*/ +QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowFlags f) + : QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f) +{ + d_func()->setPixmap(pixmap, screen); +} + +#if QT_DEPRECATED_SINCE(5, 15) +/*! + \overload + \obsolete This function allows you to specify a parent for your splashscreen. The typical use for this constructor is if you have a multiple screens and @@ -152,6 +174,7 @@ QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowF // is still 0 here due to QWidget's special handling. d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(parent)); } +#endif /*! Destructor. @@ -286,26 +309,35 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap) } // In setPixmap(), resize and try to position on a screen according to: -// 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on +// 1) If the screen for the given widget is available, use that +// 2) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on // QSplashScreen(QWidget *, QPixmap). -// 2) If a widget with associated QWindow is found, use that -// 3) When nothing can be found, try to center it over the cursor +// 3) If a widget with associated QWindow is found, use that +// 4) When nothing can be found, try to center it over the cursor +#if QT_DEPRECATED_SINCE(5, 15) static inline int screenNumberOf(const QDesktopScreenWidget *dsw) { auto desktopWidgetPrivate = static_cast<QDesktopWidgetPrivate *>(qt_widget_private(QApplication::desktop())); return desktopWidgetPrivate->screens.indexOf(const_cast<QDesktopScreenWidget *>(dsw)); } +#endif const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w) { + if (w && w->screen()) + return w->screen(); + for (const QWidget *p = w; p !=nullptr ; p = p->parentWidget()) { +#if QT_DEPRECATED_SINCE(5, 15) if (auto dsw = qobject_cast<const QDesktopScreenWidget *>(p)) return QGuiApplication::screens().value(screenNumberOf(dsw)); +#endif if (QWindow *window = p->windowHandle()) return window->screen(); } + #if QT_CONFIG(cursor) // Note: We could rely on QPlatformWindow::initialGeometry() to center it // over the cursor, but not all platforms (namely Android) use that. diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index 8bdf4e7749..1877493fcf 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -55,7 +55,11 @@ class Q_WIDGETS_EXPORT QSplashScreen : public QWidget Q_OBJECT public: explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); + QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use the constructor taking a QScreen *") QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); +#endif virtual ~QSplashScreen(); void setPixmap(const QPixmap &pixmap); |