diff options
Diffstat (limited to 'src/widgets')
67 files changed, 508 insertions, 420 deletions
diff --git a/src/widgets/configure.json b/src/widgets/configure.json index b241fcdf11..8acbffef6a 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -44,31 +44,31 @@ }, "style-fusion": { "label": "Fusion", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-mac": { "label": "macOS", "condition": "config.osx", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-windows": { "label": "Windows", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-windowsxp": { "label": "WindowsXP", "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-windowsvista": { "label": "WindowsVista", "condition": "features.style-windowsxp", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-android": { "label": "Android", "autoDetect": "config.android", - "output": [ "styles" ] + "output": [ "privateFeature", "styles" ] }, "style-stylesheet": { "label": "QStyleSheetStyle", @@ -86,6 +86,7 @@ "label": "QFileSystemModel", "purpose": "Provides a data model for the local filesystem.", "section": "File I/O", + "condition": "features.itemmodel", "output": [ "publicFeature", "feature" ] }, "itemviews": { diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h index 265790b0e5..d88ff4a841 100644 --- a/src/widgets/dialogs/qdialog.h +++ b/src/widgets/dialogs/qdialog.h @@ -65,7 +65,7 @@ public: int result() const; - void setVisible(bool visible); + void setVisible(bool visible) override; void setOrientation(Qt::Orientation orientation); Qt::Orientation orientation() const; @@ -73,8 +73,8 @@ public: void setExtension(QWidget* extension); QWidget* extension() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; void setSizeGripEnabled(bool); bool isSizeGripEnabled() const; @@ -99,14 +99,14 @@ public Q_SLOTS: protected: QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); - void keyPressEvent(QKeyEvent *); - void closeEvent(QCloseEvent *); - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); + void keyPressEvent(QKeyEvent *) override; + void closeEvent(QCloseEvent *) override; + void showEvent(QShowEvent *) override; + void resizeEvent(QResizeEvent *) override; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) override; #endif - bool eventFilter(QObject *, QEvent *); + bool eventFilter(QObject *, QEvent *) override; void adjustPosition(QWidget*); private: Q_DECLARE_PRIVATE(QDialog) diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index bcad069b50..9153d7ea41 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qwizard.h" +#include <QtWidgets/private/qtwidgetsglobal_p.h> #ifndef QT_NO_WIZARD @@ -61,7 +62,7 @@ #include <QtCore/QMetaMethod> #include <QtGui/QGuiApplication> #include <qpa/qplatformnativeinterface.h> -#elif !defined(QT_NO_STYLE_WINDOWSVISTA) +#elif QT_CONFIG(style_windowsvista) #include "qwizard_win_p.h" #include "qtimer.h" #endif @@ -295,7 +296,7 @@ public: protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) private: bool vistaDisabled() const; #endif @@ -342,7 +343,7 @@ QWizardHeader::QWizardHeader(QWidget *parent) layout->addWidget(logoLabel, 1, 5, 5, 1); } -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) bool QWizardHeader::vistaDisabled() const { bool styleDisabled = false; @@ -362,7 +363,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title, Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat) { bool modern = ((info.wizStyle == QWizard::ModernStyle) -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) || ((info.wizStyle == QWizard::AeroStyle && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) #endif @@ -525,7 +526,7 @@ void QWizardPagePrivate::_q_updateCachedCompleteState() class QWizardAntiFlickerWidget : public QWidget { public: -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) QWizardPrivate *wizardPrivate; QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *wizardPrivate) : QWidget(wizard) @@ -572,7 +573,7 @@ public: , titleLabel(0) , subTitleLabel(0) , bottomRuler(0) -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) , vistaHelper(0) , vistaInitPending(false) , vistaState(QVistaHelper::Dirty) @@ -586,7 +587,7 @@ public: { std::fill(btns, btns + QWizard::NButtons, static_cast<QAbstractButton *>(0)); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) vistaInitPending = true; @@ -611,7 +612,7 @@ public: void setButtonLayout(const QWizard::WizardButton *array, int size); bool buttonLayoutContains(QWizard::WizardButton which); void updatePixmap(QWizard::WizardPixmap which); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) bool vistaDisabled() const; bool isVistaThemeEnabled(QVistaHelper::VistaState state) const; bool handleAeroStyleChange(); @@ -677,7 +678,7 @@ public: QHBoxLayout *buttonLayout; QGridLayout *mainLayout; -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) QVistaHelper *vistaHelper; bool vistaInitPending; QVistaHelper::VistaState vistaState; @@ -692,7 +693,7 @@ public: static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate) { -#if defined(QT_NO_STYLE_WINDOWSVISTA) +#if !QT_CONFIG(style_windowsvista) Q_UNUSED(wizardPrivate); #endif const bool macStyle = (wstyle == QWizard::MacStyle); @@ -730,7 +731,7 @@ void QWizardPrivate::init() opts = QWizard::HelpButtonOnRight; } -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) vistaHelper = new QVistaHelper(q); #endif @@ -959,7 +960,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() info.wizStyle = wizStyle; if (info.wizStyle == QWizard::AeroStyle -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) && (QVistaHelper::vistaState() == QVistaHelper::Classic || vistaDisabled()) #endif ) @@ -1337,7 +1338,7 @@ void QWizardPrivate::updateMinMaxSizes(const QWizardLayoutInfo &info) Q_Q(QWizard); int extraHeight = 0; -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (isVistaThemeEnabled()) extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset(); #endif @@ -1560,7 +1561,7 @@ void QWizardPrivate::updatePixmap(QWizard::WizardPixmap which) } } -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) bool QWizardPrivate::vistaDisabled() const { Q_Q(const QWizard); @@ -1642,7 +1643,7 @@ bool QWizardPrivate::handleAeroStyleChange() bool QWizardPrivate::isVistaThemeEnabled() const { -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) return isVistaThemeEnabled(QVistaHelper::VistaAero) || isVistaThemeEnabled(QVistaHelper::VistaBasic); #else @@ -1720,7 +1721,7 @@ void QWizardPrivate::_q_updateButtonStates() if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish)) finishPush->setDefault(!canContinue && useDefault); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (isVistaThemeEnabled()) { vistaHelper->backButton()->setEnabled(btn.back->isEnabled()); vistaHelper->backButton()->setVisible(backButtonVisible); @@ -1788,7 +1789,7 @@ QPixmap QWizardPrivate::findDefaultBackgroundPixmap() #endif -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *) { if (wizardPrivate->isVistaThemeEnabled()) { @@ -2556,7 +2557,7 @@ void QWizard::setWizardStyle(WizardStyle style) const bool styleChange = style != d->wizStyle; -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) const bool aeroStyleChange = d->vistaInitPending || d->vistaStateChanged || (styleChange && (style == AeroStyle || d->wizStyle == AeroStyle)); d->vistaStateChanged = false; @@ -2564,14 +2565,14 @@ void QWizard::setWizardStyle(WizardStyle style) #endif if (styleChange -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) || aeroStyleChange #endif ) { d->disableUpdates(); d->wizStyle = style; d->updateButtonTexts(); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (aeroStyleChange) { //Send a resizeevent since the antiflicker widget probably needs a new size //because of the backbutton in the window title @@ -2582,7 +2583,7 @@ void QWizard::setWizardStyle(WizardStyle style) d->updateLayout(); updateGeometry(); d->enableUpdates(); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) // Delay initialization when activating Aero style fails due to missing native window. if (aeroStyleChange && !d->handleAeroStyleChange() && d->wizStyle == AeroStyle) d->vistaInitPending = true; @@ -2816,7 +2817,7 @@ void QWizard::setButton(WizardButton which, QAbstractButton *button) QAbstractButton *QWizard::button(WizardButton which) const { Q_D(const QWizard); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (d->wizStyle == AeroStyle && which == BackButton) return d->vistaHelper->backButton(); #endif @@ -3176,7 +3177,7 @@ bool QWizard::event(QEvent *event) d->setStyle(style()); d->updateLayout(); } -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) else if (event->type() == QEvent::Show && d->vistaInitPending) { d->vistaInitPending = false; // Do not force AeroStyle when in Classic theme. @@ -3211,7 +3212,7 @@ void QWizard::resizeEvent(QResizeEvent *event) { Q_D(QWizard); int heightOffset = 0; -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (d->isVistaThemeEnabled()) { heightOffset = d->vistaHelper->topOffset(); if (d->isVistaThemeEnabled(QVistaHelper::VistaAero)) @@ -3219,7 +3220,7 @@ void QWizard::resizeEvent(QResizeEvent *event) } #endif d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset); -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) if (d->isVistaThemeEnabled()) d->vistaHelper->resizeEvent(event); #endif @@ -3240,7 +3241,7 @@ void QWizard::paintEvent(QPaintEvent * event) QPainter painter(this); painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap); } -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) else if (d->isVistaThemeEnabled()) { if (d->isVistaThemeEnabled(QVistaHelper::VistaBasic)) { QPainter painter(this); @@ -3260,7 +3261,7 @@ void QWizard::paintEvent(QPaintEvent * event) */ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *result) { -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) Q_D(QWizard); if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") { MSG *windowsMessage = static_cast<MSG *>(message); diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 9d8e7c4b66..80e37dab25 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -38,7 +38,10 @@ ****************************************************************************/ #ifndef QT_NO_WIZARD -#ifndef QT_NO_STYLE_WINDOWSVISTA + +#include <QtWidgets/private/qtwidgetsglobal_p.h> + +#if QT_CONFIG(style_windowsvista) #include "qwizard_win_p.h" #include <private/qapplication_p.h> @@ -722,6 +725,6 @@ int QVistaHelper::topOffset() QT_END_NAMESPACE -#endif // QT_NO_STYLE_WINDOWSVISTA +#endif // style_windowsvista #endif // QT_NO_WIZARD diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index 288e7adaf5..bbba53b879 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -54,7 +54,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #ifndef QT_NO_WIZARD -#ifndef QT_NO_STYLE_WINDOWSVISTA +#if QT_CONFIG(style_windowsvista) #include <qobject.h> #include <qwidget.h> @@ -156,6 +156,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_STYLE_WINDOWSVISTA +#endif // style_windowsvista #endif // QT_NO_WIZARD #endif // QWIZARD_WIN_P_H diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp index 284a4ce404..7d003e4886 100644 --- a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp +++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp @@ -62,7 +62,7 @@ lineEdit->setCompleter(completer); //! [1] QCompleter *completer = new QCompleter(this); -completer->setModel(new QDirModel(completer)); +completer->setModel(new QFileSystemModel(completer)); lineEdit->setCompleter(completer); //! [1] diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index e727d7fe56..84819e8c1a 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -2070,9 +2070,22 @@ Normally, the begin and end functions are capable of informing other components about changes to the model's underlying structure. For more complex changes to the - model's structure, perhaps involving internal reorganization or sorting of data, - it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} - signal to cause any attached views to be updated. + model's structure, perhaps involving internal reorganization, sorting of data or + any other structural change, it is necessary to perform the following sequence: + + \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal + \li Update internal data which represents the structure of the model. + \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()} + \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal. + + This sequence can be used for any structural update in lieu of the more + high-level and convenient protected methods. For example, if a model of + two million rows needs to have all odd numbered rows removed, that + is 1 million discountiguous ranges of 1 element each. It would be + possible to use beginRemoveRows and endRemoveRows 1 million times, but + that would obviously be inefficient. Instead, this can be signalled as a + single layout change which updates all necessary persistent indexes at + once. \section3 Lazy population of model data diff --git a/src/widgets/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h index 0797ba7066..4624772993 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget_p.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h @@ -80,7 +80,7 @@ public: void embedSubWindow(QWidget *); void unembedSubWindow(QWidget *); - bool isProxyWidget() const; + bool isProxyWidget() const override; QPointer<QWidget> widget; QPointer<QWidget> lastWidgetUnderMouse; diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 46d2a4c1aa..660620a5d9 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -52,7 +52,7 @@ #include <QtWidgets/qstyleoption.h> #include <QtWidgets/QStyleOptionTitleBar> #include <QtWidgets/QGraphicsSceneMouseEvent> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac) # include <private/qmacstyle_mac_p.h> #endif diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index f8ada6df08..d21ae573cd 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -93,12 +93,12 @@ class QEmptyModel : public QAbstractItemModel { public: explicit QEmptyModel(QObject *parent = 0) : QAbstractItemModel(parent) {} - QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); } - QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } - int rowCount(const QModelIndex &) const { return 0; } - int columnCount(const QModelIndex &) const { return 0; } - bool hasChildren(const QModelIndex &) const { return false; } - QVariant data(const QModelIndex &, int) const { return QVariant(); } + QModelIndex index(int, int, const QModelIndex &) const override { return QModelIndex(); } + QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } + int rowCount(const QModelIndex &) const override { return 0; } + int columnCount(const QModelIndex &) const override { return 0; } + bool hasChildren(const QModelIndex &) const override { return false; } + QVariant data(const QModelIndex &, int) const override { return QVariant(); } }; class Q_AUTOTEST_EXPORT QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate @@ -323,7 +323,7 @@ public: } // reimplemented from QAbstractScrollAreaPrivate - virtual QPoint contentsOffset() const { + QPoint contentsOffset() const override { Q_Q(const QAbstractItemView); return QPoint(q->horizontalOffset(), q->verticalOffset()); } diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 837383f016..1310a060ea 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3857,6 +3857,20 @@ bool QHeaderViewPrivate::read(QDataStream &in) if (sectionItemsLengthTotal != lengthIn) return false; + const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root)); + if (newSectionItems.count() < currentCount) { + // we have sections not in the saved state, give them default settings + for (int i = newSectionItems.count(); i < currentCount; ++i) { + visualIndicesIn.append(i); + logicalIndicesIn.append(i); + } + const int insertCount = currentCount - newSectionItems.count(); + const int insertLength = defaultSectionSizeIn * insertCount; + lengthIn += insertLength; + SectionItem section(defaultSectionSizeIn, globalResizeMode); + newSectionItems.insert(newSectionItems.count(), insertCount, section); // append + } + orientation = static_cast<Qt::Orientation>(orient); sortIndicatorOrder = static_cast<Qt::SortOrder>(order); sortIndicatorSection = sortIndicatorSectionIn; diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index 0356d79ff7..6affe7af95 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -117,7 +117,7 @@ public: void resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode = false); void _q_sectionsRemoved(const QModelIndex &,int,int); void _q_layoutAboutToBeChanged(); - void _q_layoutChanged(); + void _q_layoutChanged() override; bool isSectionSelected(int section) const; bool isFirstVisibleSection(int section) const; diff --git a/src/widgets/itemviews/qitemeditorfactory.h b/src/widgets/itemviews/qitemeditorfactory.h index 785d4d84ea..dea9bce794 100644 --- a/src/widgets/itemviews/qitemeditorfactory.h +++ b/src/widgets/itemviews/qitemeditorfactory.h @@ -81,8 +81,8 @@ public: inline QStandardItemEditorCreator() : propertyName(T::staticMetaObject.userProperty().name()) {} - inline QWidget *createWidget(QWidget *parent) const { return new T(parent); } - inline QByteArray valuePropertyName() const { return propertyName; } + inline QWidget *createWidget(QWidget *parent) const override { return new T(parent); } + inline QByteArray valuePropertyName() const override { return propertyName; } private: QByteArray propertyName; diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 42cb6b4eef..47effcdfd9 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -69,28 +69,28 @@ class QListViewItem friend class QListModeViewBase; friend class QIconModeViewBase; public: - inline QListViewItem() + Q_DECL_CONSTEXPR QListViewItem() : x(-1), y(-1), w(0), h(0), indexHint(-1), visited(0xffff) {} - inline QListViewItem(QRect r, int i) + Q_DECL_CONSTEXPR QListViewItem(QRect r, int i) : x(r.x()), y(r.y()), w(qMin(r.width(), SHRT_MAX)), h(qMin(r.height(), SHRT_MAX)), indexHint(i), visited(0xffff) {} - inline bool operator==(const QListViewItem &other) const { + Q_DECL_CONSTEXPR bool operator==(const QListViewItem &other) const { return (x == other.x && y == other.y && w == other.w && h == other.h && indexHint == other.indexHint); } - inline bool operator!=(const QListViewItem &other) const + Q_DECL_CONSTEXPR bool operator!=(const QListViewItem &other) const { return !(*this == other); } - inline bool isValid() const + Q_DECL_CONSTEXPR bool isValid() const { return rect().isValid() && (indexHint > -1); } - inline void invalidate() + Q_DECL_RELAXED_CONSTEXPR void invalidate() { x = -1; y = -1; w = 0; h = 0; } - inline void resize(const QSize &size) + Q_DECL_RELAXED_CONSTEXPR void resize(QSize size) { w = qMin(size.width(), SHRT_MAX); h = qMin(size.height(), SHRT_MAX); } - inline void move(const QPoint &position) + Q_DECL_RELAXED_CONSTEXPR void move(QPoint position) { x = position.x(); y = position.y(); } - inline int width() const { return w; } - inline int height() const { return h; } + Q_DECL_CONSTEXPR int width() const { return w; } + Q_DECL_CONSTEXPR int height() const { return h; } private: - inline QRect rect() const + Q_DECL_CONSTEXPR QRect rect() const { return QRect(x, y, w, h); } int x, y; short w, h; @@ -209,24 +209,24 @@ public: int batchSavedPosition; //reimplementations - int itemIndex(const QListViewItem &item) const { return item.indexHint; } - QListViewItem indexToListViewItem(const QModelIndex &index) const; - bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max); - void clear(); - void setRowCount(int rowCount) { flowPositions.resize(rowCount); } - QVector<QModelIndex> intersectingSet(const QRect &area) const; - void dataChanged(const QModelIndex &, const QModelIndex &); + int itemIndex(const QListViewItem &item) const override { return item.indexHint; } + QListViewItem indexToListViewItem(const QModelIndex &index) const override; + bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max) override; + void clear() override; + void setRowCount(int rowCount) override { flowPositions.resize(rowCount); } + QVector<QModelIndex> intersectingSet(const QRect &area) const override; + void dataChanged(const QModelIndex &, const QModelIndex &) override; int horizontalScrollToValue(int index, QListView::ScrollHint hint, - bool leftOf, bool rightOf,const QRect &area, const QRect &rect) const; + bool leftOf, bool rightOf,const QRect &area, const QRect &rect) const override; int verticalScrollToValue(int index, QListView::ScrollHint hint, - bool above, bool below, const QRect &area, const QRect &rect) const; - void scrollContentsBy(int dx, int dy, bool scrollElasticBand); - QRect mapToViewport(const QRect &rect) const; - int horizontalOffset() const; - int verticalOffset() const; - void updateHorizontalScrollBar(const QSize &step); - void updateVerticalScrollBar(const QSize &step); + bool above, bool below, const QRect &area, const QRect &rect) const override; + void scrollContentsBy(int dx, int dy, bool scrollElasticBand) override; + QRect mapToViewport(const QRect &rect) const override; + int horizontalOffset() const override; + int verticalOffset() const override; + void updateHorizontalScrollBar(const QSize &step) override; + void updateVerticalScrollBar(const QSize &step) override; #ifndef QT_NO_DRAGANDDROP // The next two methods are to be used on LefToRight flow only. @@ -261,24 +261,24 @@ public: QVector<QModelIndex> *interSectingVector; //used from within intersectingSet //reimplementations - int itemIndex(const QListViewItem &item) const; - QListViewItem indexToListViewItem(const QModelIndex &index) const; - bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max); - void clear(); - void setRowCount(int rowCount); - QVector<QModelIndex> intersectingSet(const QRect &area) const; - - void scrollContentsBy(int dx, int dy, bool scrollElasticBand); - void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); - void appendHiddenRow(int row); - void removeHiddenRow(int row); - void setPositionForIndex(const QPoint &position, const QModelIndex &index); + int itemIndex(const QListViewItem &item) const override; + QListViewItem indexToListViewItem(const QModelIndex &index) const override; + bool doBatchedItemLayout(const QListViewLayoutInfo &info, int max) override; + void clear() override; + void setRowCount(int rowCount) override; + QVector<QModelIndex> intersectingSet(const QRect &area) const override; + + void scrollContentsBy(int dx, int dy, bool scrollElasticBand) override; + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) override; + void appendHiddenRow(int row) override; + void removeHiddenRow(int row) override; + void setPositionForIndex(const QPoint &position, const QModelIndex &index) override; #ifndef QT_NO_DRAGANDDROP - bool filterDragMoveEvent(QDragMoveEvent *); - bool filterDragLeaveEvent(QDragLeaveEvent *); - bool filterDropEvent(QDropEvent *e); - bool filterStartDrag(Qt::DropActions); + bool filterDragMoveEvent(QDragMoveEvent *) override; + bool filterDragLeaveEvent(QDragLeaveEvent *) override; + bool filterDropEvent(QDropEvent *e) override; + bool filterStartDrag(Qt::DropActions) override; #endif private: @@ -349,18 +349,18 @@ public: QModelIndex closestIndex(const QRect &target, const QVector<QModelIndex> &candidates) const; QSize itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const; - bool selectionAllowed(const QModelIndex &index) const + bool selectionAllowed(const QModelIndex &index) const override { if (viewMode == QListView::ListMode && !showElasticBand) return index.isValid(); return true; } int horizontalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const; int verticalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const; QItemSelection selection(const QRect &rect) const; - void selectAll(QItemSelectionModel::SelectionFlags command); + void selectAll(QItemSelectionModel::SelectionFlags command) override; #ifndef QT_NO_DRAGANDDROP - virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; - bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); + QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const override; + bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index) override; #endif inline void setGridSize(const QSize &size) { grid = size; } @@ -383,7 +383,7 @@ public: void scrollElasticBandBy(int dx, int dy); - QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; + QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const override; void emitIndexesMoved(const QModelIndexList &indexes) { emit q_func()->indexesMoved(indexes); } diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h index eaddfc6e6e..0594fd511e 100644 --- a/src/widgets/itemviews/qlistwidget_p.h +++ b/src/widgets/itemviews/qlistwidget_p.h @@ -93,22 +93,22 @@ public: QListWidgetItem *take(int row); void move(int srcRow, int dstRow); - int rowCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; QModelIndex index(QListWidgetItem *item) const; - QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; - QMap<int, QVariant> itemData(const QModelIndex &index) const; + QMap<int, QVariant> itemData(const QModelIndex &index) const override; - bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()); - bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()); + bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override; + bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override; - Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; - void sort(int column, Qt::SortOrder order); + void sort(int column, Qt::SortOrder order) override; void ensureSorted(int column, Qt::SortOrder order, int start, int end); static bool itemLessThan(const QPair<QListWidgetItem*,int> &left, const QPair<QListWidgetItem*,int> &right); @@ -122,12 +122,12 @@ public: void itemChanged(QListWidgetItem *item); // dnd - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; + QStringList mimeTypes() const override; + QMimeData *mimeData(const QModelIndexList &indexes) const override; #ifndef QT_NO_DRAGANDDROP bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - Qt::DropActions supportedDropActions() const; + int row, int column, const QModelIndex &parent) override; + Qt::DropActions supportedDropActions() const override; #endif QMimeData *internalMimeData() const; diff --git a/src/widgets/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h index 313577befe..2db7337cd6 100644 --- a/src/widgets/itemviews/qtablewidget_p.h +++ b/src/widgets/itemviews/qtablewidget_p.h @@ -99,11 +99,11 @@ public: QTableModel(int rows, int columns, QTableWidget *parent); ~QTableModel(); - bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()); - bool insertColumns(int column, int count = 1, const QModelIndex &parent = QModelIndex()); + bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override; + bool insertColumns(int column, int count = 1, const QModelIndex &parent = QModelIndex()) override; - bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()); - bool removeColumns(int column, int count = 1, const QModelIndex &parent = QModelIndex()); + bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex()) override; + bool removeColumns(int column, int count = 1, const QModelIndex &parent = QModelIndex()) override; void setItem(int row, int column, QTableWidgetItem *item); QTableWidgetItem *takeItem(int row, int column); @@ -118,7 +118,7 @@ public: QTableWidgetItem *horizontalHeaderItem(int section); QTableWidgetItem *verticalHeaderItem(int section); - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override { return QAbstractTableModel::index(row, column, parent); } QModelIndex index(const QTableWidgetItem *item) const; @@ -126,21 +126,21 @@ public: void setRowCount(int rows); void setColumnCount(int columns); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); - bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override; - QMap<int, QVariant> itemData(const QModelIndex &index) const; + QMap<int, QVariant> itemData(const QModelIndex &index) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role); + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) override; - Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; - void sort(int column, Qt::SortOrder order); + void sort(int column, Qt::SortOrder order) override; static bool itemLessThan(const QPair<QTableWidgetItem*,int> &left, const QPair<QTableWidgetItem*,int> &right); static bool itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, @@ -167,11 +167,11 @@ public: void setItemPrototype(const QTableWidgetItem *item); // dnd - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; + QStringList mimeTypes() const override; + QMimeData *mimeData(const QModelIndexList &indexes) const override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - Qt::DropActions supportedDropActions() const; + int row, int column, const QModelIndex &parent) override; + Qt::DropActions supportedDropActions() const override; QMimeData *internalMimeData() const; diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 2d1d1f43d0..9583dd9657 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2194,7 +2194,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie return QModelIndex(); } int vi = -1; -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac) // Selection behavior is slightly different on the Mac. if (d->selectionMode == QAbstractItemView::ExtendedSelection && d->selectionModel diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index 56f3340966..63af41292b 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -102,8 +102,8 @@ public: return logicalIndex == logicalIndexForTree(); } - QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; - void adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const; + QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const override; + void adjustViewOptionsForIndex(QStyleOptionViewItem *option, const QModelIndex ¤t) const override; #ifndef QT_NO_ANIMATION struct AnimatedOperation : public QVariantAnimation @@ -115,8 +115,8 @@ public: AnimatedOperation() : item(0) { setEasingCurve(QEasingCurve::InOutQuad); } int top() const { return startValue().toInt(); } QRect rect() const { QRect rect = viewport->rect(); rect.moveTop(top()); return rect; } - void updateCurrentValue(const QVariant &) { viewport->update(rect()); } - void updateState(State state, State) { if (state == Stopped) before = after = QPixmap(); } + void updateCurrentValue(const QVariant &) override { viewport->update(rect()); } + void updateState(State state, State) override { if (state == Stopped) before = after = QPixmap(); } } animatedOperation; void prepareAnimatedOperation(int item, QVariantAnimation::Direction d); void beginAnimatedOperation(); @@ -128,11 +128,11 @@ public: void expand(int item, bool emitSignal); void collapse(int item, bool emitSignal); - void _q_columnsAboutToBeRemoved(const QModelIndex &, int, int); - void _q_columnsRemoved(const QModelIndex &, int, int); + void _q_columnsAboutToBeRemoved(const QModelIndex &, int, int) override; + void _q_columnsRemoved(const QModelIndex &, int, int) override; void _q_modelAboutToBeReset(); void _q_sortIndicatorChanged(int column, Qt::SortOrder order); - void _q_modelDestroyed(); + void _q_modelDestroyed() override; void layout(int item, bool recusiveExpanding = false, bool afterIsUninitialized = false); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 358838b4e9..128b5dc2b8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3305,7 +3305,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); bool eventAccepted; - while (w) { + do { we.spont = spontaneous && w == receiver; we.ignore(); res = d->notify_helper(w, &we); @@ -3323,7 +3323,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) we.p += w->pos(); w = w->parentWidget(); - } + } while (w); wheel->setAccepted(eventAccepted); } else if (!spontaneous) { // wheel_widget may forward the wheel event to a delegate widget, diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 3bef773187..73c75bbc14 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -164,6 +164,7 @@ public: #endif static bool inPopupMode(); + bool popupActive() Q_DECL_OVERRIDE { return inPopupMode(); } void closePopup(QWidget *popup); void openPopup(QWidget *popup); static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index 6f701b9f82..059ff2d470 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -101,14 +101,14 @@ public: void changeSize(int w, int h, QSizePolicy::Policy hData = QSizePolicy::Minimum, QSizePolicy::Policy vData = QSizePolicy::Minimum); - QSize sizeHint() const; - QSize minimumSize() const; - QSize maximumSize() const; - Qt::Orientations expandingDirections() const; - bool isEmpty() const; - void setGeometry(const QRect&); - QRect geometry() const; - QSpacerItem *spacerItem(); + QSize sizeHint() const override; + QSize minimumSize() const override; + QSize maximumSize() const override; + Qt::Orientations expandingDirections() const override; + bool isEmpty() const override; + void setGeometry(const QRect&) override; + QRect geometry() const override; + QSpacerItem *spacerItem() override; QSizePolicy sizePolicy() const { return sizeP; } private: @@ -126,18 +126,18 @@ public: explicit QWidgetItem(QWidget *w) : wid(w) { } ~QWidgetItem(); - QSize sizeHint() const; - QSize minimumSize() const; - QSize maximumSize() const; - Qt::Orientations expandingDirections() const; - bool isEmpty() const; - void setGeometry(const QRect&); - QRect geometry() const; - virtual QWidget *widget(); - - bool hasHeightForWidth() const; - int heightForWidth(int) const; - QSizePolicy::ControlTypes controlTypes() const; + QSize sizeHint() const override; + QSize minimumSize() const override; + QSize maximumSize() const override; + Qt::Orientations expandingDirections() const override; + bool isEmpty() const override; + void setGeometry(const QRect&) override; + QRect geometry() const override; + QWidget *widget() override; + + bool hasHeightForWidth() const override; + int heightForWidth(int) const override; + QSizePolicy::ControlTypes controlTypes() const override; protected: QWidget *wid; }; @@ -148,10 +148,10 @@ public: explicit QWidgetItemV2(QWidget *widget); ~QWidgetItemV2(); - QSize sizeHint() const; - QSize minimumSize() const; - QSize maximumSize() const; - int heightForWidth(int width) const; + QSize sizeHint() const override; + QSize minimumSize() const override; + QSize maximumSize() const override; + int heightForWidth(int width) const override; private: enum { Dirty = -123, HfwCacheMaxSize = 3 }; diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp index 743166549b..110153d0f6 100644 --- a/src/widgets/styles/qandroidstyle.cpp +++ b/src/widgets/styles/qandroidstyle.cpp @@ -39,7 +39,7 @@ #include "qandroidstyle_p.h" -#if !defined(QT_NO_STYLE_ANDROID) || defined(QT_PLUGIN) +#if QT_CONFIG(style_android) || defined(QT_PLUGIN) #include <QFile> #include <QFont> @@ -1606,15 +1606,14 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o if (!m_progressDrawable) return; - if (const QStyleOptionProgressBar *progressBarOption = - qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { + if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) { if (m_progressDrawable->type() == QAndroidStyle::Layer) { - const double fraction = progressBarOption->progress / double(progressBarOption->maximum - progressBarOption->minimum); + const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum); QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId); if (clipDrawable->type() == QAndroidStyle::Clip) - static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, progressBarOption->orientation); + static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, pb->orientation); else - static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, progressBarOption->orientation); + static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation); } m_progressDrawable->draw(p, option); } @@ -1807,4 +1806,4 @@ QRect QAndroidStyle::AndroidSpinnerControl::subControlRect(const QStyleOptionCom QT_END_NAMESPACE -#endif // !defined(QT_NO_STYLE_ANDROID) || defined(QT_PLUGIN) +#endif // QT_CONFIG(style_android) || defined(QT_PLUGIN) diff --git a/src/widgets/styles/qandroidstyle_p.h b/src/widgets/styles/qandroidstyle_p.h index 4649d90852..caff0afada 100644 --- a/src/widgets/styles/qandroidstyle_p.h +++ b/src/widgets/styles/qandroidstyle_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_ANDROID) +#if QT_CONFIG(style_android) class Q_WIDGETS_EXPORT QAndroidStyle : public QFusionStyle { @@ -388,7 +388,7 @@ private: AndroidCompoundButtonControl *checkBoxControl; }; -#endif // QT_NO_STYLE_ANDROID +#endif // style_android QT_END_NAMESPACE diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 3473ec7fb0..c2b4ef382b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -40,7 +40,7 @@ #include "qfusionstyle_p.h" #include "qfusionstyle_p_p.h" -#if !defined(QT_NO_STYLE_FUSION) || defined(QT_PLUGIN) +#if QT_CONFIG(style_fusion) || defined(QT_PLUGIN) #include "qcommonstyle_p.h" #include <qcombobox.h> #include <qpushbutton.h> @@ -1352,10 +1352,11 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } int maxWidth = rect.width(); - int minWidth = 0; - qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); - int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); + const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(progress) - bar->minimum; + const auto progressBarWidth = progressSteps * maxWidth / totalSteps; + int width = indeterminate ? maxWidth : progressBarWidth; bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; if (inverted) @@ -1450,8 +1451,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio inverted = bar->invertedAppearance; if (vertical) rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / - qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum); + const auto progressSteps = qint64(bar->progress) - bar->minimum; + const auto progressIndicatorPos = progressSteps * rect.width() / totalSteps; if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); if (vertical) @@ -3746,4 +3748,4 @@ QT_END_NAMESPACE #include "moc_qfusionstyle_p.cpp" -#endif // QT_NO_STYLE_FUSION || QT_PLUGIN +#endif // style_fusion|| QT_PLUGIN diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h index 126fb96e78..aac27e51ab 100644 --- a/src/widgets/styles/qfusionstyle_p.h +++ b/src/widgets/styles/qfusionstyle_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_FUSION) +#if QT_CONFIG(style_fusion) class QFusionStylePrivate; class QFusionStyle : public QCommonStyle @@ -110,7 +110,7 @@ protected: }; -#endif // QT_NO_STYLE_FUSION +#endif // style_fusion QT_END_NAMESPACE diff --git a/src/widgets/styles/qfusionstyle_p_p.h b/src/widgets/styles/qfusionstyle_p_p.h index 8d1d27d244..169fd9a407 100644 --- a/src/widgets/styles/qfusionstyle_p_p.h +++ b/src/widgets/styles/qfusionstyle_p_p.h @@ -57,7 +57,7 @@ #include <qpa/qplatformtheme.h> #include "private/qguiapplication_p.h" -#ifndef QT_NO_STYLE_FUSION +#if QT_CONFIG(style_fusion) QT_BEGIN_NAMESPACE @@ -147,6 +147,6 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STYLE_FUSION +#endif // style_fusion #endif //QFUSIONSTYLE_P_P_H diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h index 459784c538..3642424a14 100644 --- a/src/widgets/styles/qmacstyle_mac_p.h +++ b/src/widgets/styles/qmacstyle_mac_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) class QPalette; diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index e973a96a91..ce37065fb6 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -819,11 +819,14 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter); } else { - if (pbar->progress == 0) + if (pbar->progress == pbar->minimum) return; - const int maximum = pbar->maximum; - const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum; - const int progress = pbar->progress*ratio; + const auto totalSteps = qint64(pbar->maximum) - pbar->minimum; + const auto progressSteps = qint64(pbar->progress) - pbar->minimum; + const auto availablePixels = vertical ? option->rect.height() : option->rect.width(); + const auto pixelsPerStep = double(availablePixels) / totalSteps; + + const auto progress = static_cast<int>(progressSteps * pixelsPerStep); // width in pixels QRect optRect = option->rect; if (vertical) { diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index 09cccff4e8..8dc603f8e6 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -44,20 +44,20 @@ #include "qapplication.h" #include "qwindowsstyle_p.h" -#ifndef QT_NO_STYLE_FUSION +#if QT_CONFIG(style_fusion) #include "qfusionstyle_p.h" -#ifndef QT_NO_STYLE_ANDROID +#if QT_CONFIG(style_android) #include "qandroidstyle_p.h" #endif #endif -#ifndef QT_NO_STYLE_WINDOWSXP +#if QT_CONFIG(style_windowsxp) #include "qwindowsxpstyle_p.h" #endif -#ifndef QT_NO_STYLE_WINDOWSVISTA +#if QT_CONFIG(style_windowsvista) #include "qwindowsvistastyle_p.h" #endif -#if !defined(QT_NO_STYLE_MAC) && defined(Q_OS_MAC) +#if QT_CONFIG(style_mac) # include "qmacstyle_mac_p.h" #endif @@ -103,32 +103,32 @@ QStyle *QStyleFactory::create(const QString& key) { QStyle *ret = 0; QString style = key.toLower(); -#ifndef QT_NO_STYLE_WINDOWS +#if QT_CONFIG(style_windows) if (style == QLatin1String("windows")) ret = new QWindowsStyle; else #endif -#ifndef QT_NO_STYLE_WINDOWSXP +#if QT_CONFIG(style_windowsxp) if (style == QLatin1String("windowsxp")) ret = new QWindowsXPStyle; else #endif -#ifndef QT_NO_STYLE_WINDOWSVISTA +#if QT_CONFIG(style_windowsvista) if (style == QLatin1String("windowsvista")) ret = new QWindowsVistaStyle; else #endif -#ifndef QT_NO_STYLE_FUSION +#if QT_CONFIG(style_fusion) if (style == QLatin1String("fusion")) ret = new QFusionStyle; else #endif -#ifndef QT_NO_STYLE_ANDROID +#if QT_CONFIG(style_android) if (style == QLatin1String("android")) ret = new QAndroidStyle; else #endif -#ifndef QT_NO_STYLE_MAC +#if QT_CONFIG(style_mac) if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # if 0 // Used to be included in Qt4 for Q_WS_MAC @@ -160,29 +160,29 @@ QStringList QStyleFactory::keys() const PluginKeyMap::const_iterator cend = keyMap.constEnd(); for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it) list.append(it.value()); -#ifndef QT_NO_STYLE_WINDOWS +#if QT_CONFIG(style_windows) if (!list.contains(QLatin1String("Windows"))) list << QLatin1String("Windows"); #endif -#ifndef QT_NO_STYLE_WINDOWSXP +#if QT_CONFIG(style_windowsxp) if (!list.contains(QLatin1String("WindowsXP")) && (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) list << QLatin1String("WindowsXP"); #endif -#ifndef QT_NO_STYLE_WINDOWSVISTA +#if QT_CONFIG(style_windowsvista) if (!list.contains(QLatin1String("WindowsVista")) && (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) list << QLatin1String("WindowsVista"); #endif -#ifndef QT_NO_STYLE_ANDROID +#if QT_CONFIG(style_android) if (!list.contains(QLatin1String("Android"))) list << QLatin1String("Android"); #endif -#ifndef QT_NO_STYLE_FUSION +#if QT_CONFIG(style_fusion) if (!list.contains(QLatin1String("Fusion"))) list << QLatin1String("Fusion"); #endif -#ifndef QT_NO_STYLE_MAC +#if QT_CONFIG(style_mac) QString mstyle = QLatin1String("Macintosh"); # if 0 // Used to be included in Qt4 for Q_WS_MAC mstyle += QLatin1String(" (aqua)"); diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 83739655af..c12b3285f1 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -37,9 +37,10 @@ ** ****************************************************************************/ +#include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qstyleoption.h" #include "qapplication.h" -#ifdef Q_OS_MAC +#if QT_CONFIG(style_mac) # include "qmacstyle_mac_p.h" #endif #include <qdebug.h> @@ -204,7 +205,7 @@ void QStyleOption::init(const QWidget *widget) if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget)) state &= ~QStyle::State_Enabled; #endif -#if defined(Q_OS_OSX) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) switch (QMacStyle::widgetSizePolicy(widget)) { case QMacStyle::SizeSmall: state |= QStyle::State_Small; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8e77ae0e44..68ee8c22d3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3903,8 +3903,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (inverted) reverse = !reverse; const bool indeterminate = pb->minimum == pb->maximum; - qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum); - int fillWidth = int(rect.width() * fillRatio); + const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (maximum - minimum); + const auto fillWidth = static_cast<int>(rect.width() * fillRatio); int chunkWidth = fillWidth; if (subRule.hasContentsSize()) { QSize sz = subRule.size(); @@ -5542,9 +5542,9 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp } else { sliderlen = maxlen; } - + const int sliderPosition = sb->orientation == Qt::Horizontal && sb->direction == Qt::RightToLeft ? sb->maximum - sb->sliderPosition + sb->minimum : sb->sliderPosition; int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top()) - + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition, + + sliderPositionFromValue(sb->minimum, sb->maximum, sliderPosition, maxlen - sliderlen, sb->upsideDown); QRect sr = (sb->orientation == Qt::Horizontal) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index e3bf28608c..a8ee881a30 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -40,7 +40,7 @@ #include "qwindowsstyle_p.h" #include "qwindowsstyle_p_p.h" -#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN) +#if QT_CONFIG(style_windows) || defined(QT_PLUGIN) #include "qapplication.h" #include "qbitmap.h" @@ -2407,4 +2407,4 @@ QT_END_NAMESPACE #include "moc_qwindowsstyle_p.cpp" -#endif // QT_NO_STYLE_WINDOWS +#endif // style_windows diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index 5d68bfeba0..a1d65610ff 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_WINDOWS) +#if QT_CONFIG(style_windows) class QWindowsStylePrivate; @@ -106,7 +106,7 @@ private: Q_DECLARE_PRIVATE(QWindowsStyle) }; -#endif // QT_NO_STYLE_WINDOWS +#endif // style_windows QT_END_NAMESPACE diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index 0c23f4b4a8..5023fd1042 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -55,7 +55,7 @@ #include "qwindowsstyle_p.h" #include "qcommonstyle_p.h" -#ifndef QT_NO_STYLE_WINDOWS +#if QT_CONFIG(style_windows) #include <qlist.h> QT_BEGIN_NAMESPACE @@ -103,7 +103,7 @@ private: QT_END_NAMESPACE -#endif // QT_NO_STYLE_WINDOWS +#endif // style_windows #endif //QWINDOWSSTYLE_P_P_H ; diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index bf5aad0187..7f52d3d2f3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -46,7 +46,7 @@ #include <private/qapplication_p.h> #include <qpa/qplatformnativeinterface.h> -#if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN) +#if QT_CONFIG(style_windowsvista) || defined(QT_PLUGIN) QT_BEGIN_NAMESPACE @@ -1871,8 +1871,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(windowsItemHMargin * 5 + 1, 5); - return sz; - break; + return sz; #endif case CT_ItemViewItem: sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h index 0289f404dd..8fbd1dc380 100644 --- a/src/widgets/styles/qwindowsvistastyle_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) class QWindowsVistaStylePrivate; class QWindowsVistaStyle : public QWindowsXPStyle @@ -103,7 +103,7 @@ private: Q_DECLARE_PRIVATE(QWindowsVistaStyle) friend class QStyleFactory; }; -#endif //QT_NO_STYLE_WINDOWSVISTA +#endif // style_windowsvista QT_END_NAMESPACE diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 4ca47fec2c..18b6f9c3f7 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -54,7 +54,7 @@ #include <QtWidgets/private/qtwidgetsglobal_p.h> #include "qwindowsvistastyle_p.h" -#if !defined(QT_NO_STYLE_WINDOWSVISTA) +#if QT_CONFIG(style_windowsvista) #include <private/qwindowsxpstyle_p_p.h> #include <private/qstyleanimation_p.h> #include <private/qpaintengine_raster_p.h> @@ -177,6 +177,6 @@ public: QT_END_NAMESPACE -#endif // QT_NO_STYLE_WINDOWSVISTA +#endif // style_windowsvista #endif // QWINDOWSVISTASTYLE_P_P_H diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 4ce359a7c4..f999d823e0 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -39,7 +39,7 @@ #include "qwindowsxpstyle_p.h" #include "qwindowsxpstyle_p_p.h" -#if !defined(QT_NO_STYLE_WINDOWSXP) || defined(QT_PLUGIN) +#if QT_CONFIG(style_windowsxp) || defined(QT_PLUGIN) #include <private/qobject_p.h> #include <private/qpaintengine_raster_p.h> diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h index 088178cb5a..62e3af927c 100644 --- a/src/widgets/styles/qwindowsxpstyle_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QT_NO_STYLE_WINDOWSXP) +#if QT_CONFIG(style_windowsxp) class QWindowsXPStylePrivate; class QWindowsXPStyle : public QWindowsStyle @@ -102,7 +102,7 @@ private: friend class QStyleFactory; }; -#endif // QT_NO_STYLE_WINDOWSXP +#endif // style_windowsxp QT_END_NAMESPACE diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index d6702c8803..fb5210cb07 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -94,7 +94,7 @@ QT_BEGIN_NAMESPACE // Uncomment define below to build debug assisting code, and output // #define DEBUG_XP_STYLE -#if !defined(QT_NO_STYLE_WINDOWSXP) +#if QT_CONFIG(style_windowsxp) // Declarations ----------------------------------------------------------------------------------- class XPThemeData @@ -338,7 +338,7 @@ inline QMarginsF XPThemeData::themeMargins(const QWidget *w, QPainter *p, int th return theme.margins(propId); } -#endif // QT_NO_STYLE_WINDOWS +#endif // style_windows QT_END_NAMESPACE diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index 69e13fb6ec..481123f0d4 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -37,51 +37,35 @@ RESOURCES += styles/qstyle.qrc include($$OUT_PWD/qtwidgets-config.pri) -contains( styles, mac ) { +qtConfig(style-mac) { HEADERS += \ styles/qmacstyle_mac_p.h \ styles/qmacstyle_mac_p_p.h OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm LIBS_PRIVATE += -framework Carbon -} else { - DEFINES += QT_NO_STYLE_MAC } -contains( styles, windowsvista ) { - HEADERS += styles/qwindowsvistastyle_p.h - HEADERS += styles/qwindowsvistastyle_p_p.h +qtConfig(style-windowsvista) { + HEADERS += styles/qwindowsvistastyle_p.h styles/qwindowsvistastyle_p_p.h SOURCES += styles/qwindowsvistastyle.cpp -} else { - DEFINES += QT_NO_STYLE_WINDOWSVISTA } -contains( styles, windowsxp ) { - HEADERS += styles/qwindowsxpstyle_p.h - HEADERS += styles/qwindowsxpstyle_p_p.h +qtConfig(style-windowsxp) { + HEADERS += styles/qwindowsxpstyle_p.h styles/qwindowsxpstyle_p_p.h SOURCES += styles/qwindowsxpstyle.cpp -} else { - DEFINES += QT_NO_STYLE_WINDOWSXP } -contains( styles, windows ) { - HEADERS += styles/qwindowsstyle_p.h - HEADERS += styles/qwindowsstyle_p_p.h +qtConfig(style-windows) { + HEADERS += styles/qwindowsstyle_p.h styles/qwindowsstyle_p_p.h SOURCES += styles/qwindowsstyle.cpp -} else { - DEFINES += QT_NO_STYLE_WINDOWS } -contains( styles, fusion ) { - HEADERS += styles/qfusionstyle_p.h - HEADERS += styles/qfusionstyle_p_p.h - SOURCES += styles/qfusionstyle.cpp -} else { - DEFINES += QT_NO_STYLE_FUSION +qtConfig(style-fusion) { + HEADERS += styles/qfusionstyle_p.h styles/qfusionstyle_p_p.h + SOURCES += styles/qfusionstyle.cpp } -contains( styles, android ) { +qtConfig(style-android) { HEADERS += styles/qandroidstyle_p.h SOURCES += styles/qandroidstyle.cpp -} else { - DEFINES += QT_NO_STYLE_ANDROID } diff --git a/src/widgets/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h index fa70806ef7..74a0f2a0f3 100644 --- a/src/widgets/util/qflickgesture_p.h +++ b/src/widgets/util/qflickgesture_p.h @@ -97,9 +97,9 @@ class QFlickGestureRecognizer : public QGestureRecognizer public: QFlickGestureRecognizer(Qt::MouseButton button); - QGesture *create(QObject *target); - QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); - void reset(QGesture *state); + QGesture *create(QObject *target) override; + QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override; + void reset(QGesture *state) override; private: Qt::MouseButton button; // NoButton == Touch diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 224ffeb6e2..630524aadb 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -436,7 +436,10 @@ bool QBalloonTip::isBalloonVisible() QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, const QString& message, QSystemTrayIcon *ti) - : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1) + : QWidget(0, Qt::ToolTip), + trayIcon(ti), + timerId(-1), + showArrow(true) { setAttribute(Qt::WA_DeleteOnClose); QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close())); diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 59d517e77b..033d4e9e05 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -654,10 +654,12 @@ void QUndoStack::setClean() This method resets the clean index to -1. This is typically called in the following cases, when a document has been: + \list \li created basing on some template and has not been saved, so no filename has been associated with the document yet. \li restored from a backup file. \li changed outside of the editor and the user did not reload it. + \endlist \sa isClean(), setClean(), cleanIndex() */ diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index d93489e663..ac46894a27 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -117,12 +117,12 @@ public: void setGroupSeparatorShown(bool shown); bool isGroupSeparatorShown() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; void interpretText(); - bool event(QEvent *event); + bool event(QEvent *event) override; - QVariant inputMethodQuery(Qt::InputMethodQuery) const; + QVariant inputMethodQuery(Qt::InputMethodQuery) const override; virtual QValidator::State validate(QString &input, int &pos) const; virtual void fixup(QString &input) const; @@ -134,24 +134,24 @@ public Q_SLOTS: void selectAll(); virtual void clear(); protected: - void resizeEvent(QResizeEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) override; #endif - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); - void contextMenuEvent(QContextMenuEvent *event); - void changeEvent(QEvent *event); - void closeEvent(QCloseEvent *event); - void hideEvent(QHideEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void timerEvent(QTimerEvent *event); - void paintEvent(QPaintEvent *event); - void showEvent(QShowEvent *event); + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void contextMenuEvent(QContextMenuEvent *event) override; + void changeEvent(QEvent *event) override; + void closeEvent(QCloseEvent *event) override; + void hideEvent(QHideEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void timerEvent(QTimerEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void showEvent(QShowEvent *event) override; void initStyleOption(QStyleOptionSpinBox *option) const; QLineEdit *lineEdit() const; diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index 47ca10a183..5ec59d899b 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -156,8 +156,8 @@ class QSpinBoxValidator : public QValidator { public: QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr); - QValidator::State validate(QString &input, int &) const; - void fixup(QString &) const; + QValidator::State validate(QString &input, int &) const override; + void fixup(QString &) const override; private: QAbstractSpinBox *qptr; QAbstractSpinBoxPrivate *dptr; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 4358e568bf..4519265fb8 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -66,7 +66,7 @@ #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <qdebug.h> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && QT_CONFIG(style_mac) #include <private/qcore_mac_p.h> #include <private/qmacstyle_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> @@ -1841,7 +1841,7 @@ QLineEdit *QComboBox::lineEdit() const Sets the \a validator to use instead of the current validator. - \note The validator is removed when the editable property becomes \c false. + \note The validator is removed when the \l editable property becomes \c false. */ void QComboBox::setValidator(const QValidator *v) @@ -1876,7 +1876,7 @@ const QValidator *QComboBox::validator() const By default, for an editable combo box, a QCompleter that performs case insensitive inline completion is automatically created. - \note The completer is removed when the \a editable property becomes \c false. + \note The completer is removed when the \l editable property becomes \c false. */ void QComboBox::setCompleter(QCompleter *c) { diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 7ca077abf9..6c36359f81 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -86,13 +86,13 @@ public: QComboBoxListView(QComboBox *cmb = 0) : combo(cmb) {} protected: - void resizeEvent(QResizeEvent *event) + void resizeEvent(QResizeEvent *event) override { resizeContents(viewport()->width(), contentsSize().height()); QListView::resizeEvent(event); } - QStyleOptionViewItem viewOptions() const + QStyleOptionViewItem viewOptions() const override { QStyleOptionViewItem option = QListView::viewOptions(); option.showDecorationSelected = true; @@ -101,7 +101,7 @@ protected: return option; } - void paintEvent(QPaintEvent *e) + void paintEvent(QPaintEvent *e) override { if (combo) { QStyleOptionComboBox opt; @@ -142,7 +142,7 @@ public: setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setAttribute(Qt::WA_NoMousePropagation); } - QSize sizeHint() const { + QSize sizeHint() const override { return QSize(20, style()->pixelMetric(QStyle::PM_MenuScrollerHeight)); } @@ -156,14 +156,14 @@ protected: fast = false; } - void enterEvent(QEvent *) { + void enterEvent(QEvent *) override { startTimer(); } - void leaveEvent(QEvent *) { + void leaveEvent(QEvent *) override { stopTimer(); } - void timerEvent(QTimerEvent *e) { + void timerEvent(QTimerEvent *e) override { if (e->timerId() == timer.timerId()) { emit doScroll(sliderAction); if (fast) { @@ -172,11 +172,11 @@ protected: } } } - void hideEvent(QHideEvent *) { + void hideEvent(QHideEvent *) override { stopTimer(); } - void mouseMoveEvent(QMouseEvent *e) + void mouseMoveEvent(QMouseEvent *e) override { // Enable fast scrolling if the cursor is directly above or below the popup. const int mouseX = e->pos().x(); @@ -188,7 +188,7 @@ protected: fast = horizontallyInside && verticallyOutside; } - void paintEvent(QPaintEvent *) { + void paintEvent(QPaintEvent *) override { QPainter p(this); QStyleOptionMenuItem menuOpt; menuOpt.init(this); @@ -235,15 +235,15 @@ public Q_SLOTS: void viewDestroyed(); protected: - void changeEvent(QEvent *e); - bool eventFilter(QObject *o, QEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void showEvent(QShowEvent *e); - void hideEvent(QHideEvent *e); - void timerEvent(QTimerEvent *timerEvent); - void leaveEvent(QEvent *e); - void resizeEvent(QResizeEvent *e); + void changeEvent(QEvent *e) override; + bool eventFilter(QObject *o, QEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *e) override; + void showEvent(QShowEvent *e) override; + void hideEvent(QHideEvent *e) override; + void timerEvent(QTimerEvent *timerEvent) override; + void leaveEvent(QEvent *e) override; + void resizeEvent(QResizeEvent *e) override; QStyleOptionComboBox comboStyleOption() const; Q_SIGNALS: @@ -270,13 +270,13 @@ public: protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const { + const QModelIndex &index) const override { QStyleOptionMenuItem opt = getStyleOption(option, index); painter->fillRect(option.rect, opt.palette.background()); mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo); } QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const { + const QModelIndex &index) const override { QStyleOptionMenuItem opt = getStyleOption(option, index); return mCombo->style()->sizeFromContents( QStyle::CT_MenuItem, &opt, option.rect.size(), mCombo); @@ -309,7 +309,7 @@ public: protected: void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const { + const QModelIndex &index) const override { if (isSeparator(index)) { QRect rect = option.rect; if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(option.widget)) @@ -323,7 +323,7 @@ protected: } QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const { + const QModelIndex &index) const override { if (isSeparator(index)) { int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, mCombo); return QSize(pm, pm); diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index c261ce369b..5c9f4e0f9d 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -159,12 +159,12 @@ public: Qt::TimeSpec timeSpec() const; void setTimeSpec(Qt::TimeSpec spec); - QSize sizeHint() const; + QSize sizeHint() const override; - virtual void clear(); - virtual void stepBy(int steps); + void clear() override; + void stepBy(int steps) override; - bool event(QEvent *event); + bool event(QEvent *event) override; Q_SIGNALS: void dateTimeChanged(const QDateTime &dateTime); void timeChanged(const QTime &time); @@ -176,20 +176,20 @@ public Q_SLOTS: void setTime(const QTime &time); protected: - virtual void keyPressEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event) override; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) override; #endif - virtual void focusInEvent(QFocusEvent *event); - virtual bool focusNextPrevChild(bool next); - virtual QValidator::State validate(QString &input, int &pos) const; - virtual void fixup(QString &input) const; + void focusInEvent(QFocusEvent *event) override; + bool focusNextPrevChild(bool next) override; + QValidator::State validate(QString &input, int &pos) const override; + void fixup(QString &input) const override; virtual QDateTime dateTimeFromText(const QString &text) const; virtual QString textFromDateTime(const QDateTime &dt) const; - virtual StepEnabled stepEnabled() const; - virtual void mousePressEvent(QMouseEvent *event); - virtual void paintEvent(QPaintEvent *event); + StepEnabled stepEnabled() const override; + void mousePressEvent(QMouseEvent *event) override; + void paintEvent(QPaintEvent *event) override; void initStyleOption(QStyleOptionSpinBox *option) const; QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = Q_NULLPTR); diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 6889bda041..730aa0f0b2 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -167,10 +167,10 @@ private Q_SLOTS: void dateSelectionChanged(); protected: - void hideEvent(QHideEvent *); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *); - bool event(QEvent *e); + void hideEvent(QHideEvent *) override; + void mousePressEvent(QMouseEvent *e) override; + void mouseReleaseEvent(QMouseEvent *) override; + bool event(QEvent *e) override; private: QCalendarWidget *verifyCalendarInstance(); diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 63f8172bf6..ad19e5d5f9 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -266,6 +266,16 @@ bool QDockAreaLayoutInfo::isEmpty() const return next(-1) == -1; } +bool QDockAreaLayoutInfo::onlyHasPlaceholders() const +{ + for (const QDockAreaLayoutItem &item : item_list) { + if (!item.placeHolderItem) + return false; + } + + return true; +} + QSize QDockAreaLayoutInfo::minimumSize() const { if (isEmpty()) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index f22a3d2de2..21787283f4 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -167,6 +167,7 @@ public: void clear(); bool isEmpty() const; + bool onlyHasPlaceholders() const; bool hasFixedSize() const; QList<int> findSeparator(const QPoint &pos) const; int next(int idx) const; diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 1df7259aba..53cb21186f 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -219,8 +219,10 @@ QDockWidgetLayout::~QDockWidgetLayout() bool QDockWidgetLayout::nativeWindowDeco() const { bool floating = parentWidget()->isWindow(); - if (!floating && qobject_cast<QDockWidgetGroupWindow*>(parentWidget()->parentWidget())) - return wmSupportsNativeWindowDeco(); + if (!floating) { + if (auto groupWindow = qobject_cast<const QDockWidgetGroupWindow*>(parentWidget()->parentWidget())) + return groupWindow->hasNativeDecos(); + } return nativeWindowDeco(floating); } @@ -797,8 +799,10 @@ void QDockWidgetPrivate::endDrag(bool abort) if (abort || !mwLayout->plug(state->widgetItem)) { if (hasFeature(this, QDockWidget::DockWidgetFloatable)) { // This QDockWidget will now stay in the floating state. - if (state->ownWidgetItem) + if (state->ownWidgetItem) { delete state->widgetItem; + state->widgetItem = nullptr; + } mwLayout->restore(); QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); if (!dwLayout->nativeWindowDeco()) { diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index 84389f16df..a8faffd6be 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -54,11 +54,11 @@ public: QMacNativeWidget(NSView *parentView = Q_NULLPTR); ~QMacNativeWidget(); - QSize sizeHint() const; + QSize sizeHint() const override; NSView *nativeView() const; protected: - bool event(QEvent *ev); + bool event(QEvent *ev) override; }; QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 8df197e05c..14d7f3d835 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -183,7 +183,7 @@ class QDockWidgetGroupLayout : public QLayout { QDockAreaLayoutInfo info; QWidgetResizeHandler *resizer; public: - QDockWidgetGroupLayout(QWidget* parent) : QLayout(parent) { + QDockWidgetGroupLayout(QDockWidgetGroupWindow* parent) : QLayout(parent) { setSizeConstraint(QLayout::SetMinAndMaxSize); resizer = new QWidgetResizeHandler(parent); resizer->setMovingEnabled(false); @@ -221,7 +221,7 @@ public: } void setGeometry(const QRect&r) Q_DECL_OVERRIDE { - static_cast<QDockWidgetGroupWindow *>(parent())->destroyOrHideIfEmpty(); + groupWindow()->destroyOrHideIfEmpty(); QDockAreaLayoutInfo *li = layoutInfo(); if (li->isEmpty()) return; @@ -239,7 +239,7 @@ public: bool nativeWindowDeco() const { - return QDockWidgetLayout::wmSupportsNativeWindowDeco(); + return groupWindow()->hasNativeDecos(); } int frameWidth() const @@ -247,6 +247,11 @@ public: return nativeWindowDeco() ? 0 : parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget()); } + + QDockWidgetGroupWindow *groupWindow() const + { + return static_cast<QDockWidgetGroupWindow *>(parent()); + } }; bool QDockWidgetGroupWindow::event(QEvent *e) @@ -390,16 +395,49 @@ void QDockWidgetGroupWindow::adjustFlags() flags.setFlag(Qt::WindowCloseButtonHint, top->features() & QDockWidget::DockWidgetClosable); flags &= ~Qt::FramelessWindowHint; } else { + flags &= ~(Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint); flags |= Qt::FramelessWindowHint; } + if (oldFlags != flags) { setWindowFlags(flags); + const bool gainedNativeDecos = (oldFlags & Qt::FramelessWindowHint) && !(flags & Qt::FramelessWindowHint); + const bool lostNativeDecos = !(oldFlags & Qt::FramelessWindowHint) && (flags & Qt::FramelessWindowHint); + + // Adjust the geometry after gaining/losing decos, so that the client area appears always + // at the same place when tabbing + if (lostNativeDecos) { + QRect newGeometry = geometry(); + newGeometry.setTop(frameGeometry().top()); + const int bottomFrame = geometry().top() - frameGeometry().top(); + m_removedFrameSize = QSize((frameSize() - size()).width(), bottomFrame); + setGeometry(newGeometry); + } else if (gainedNativeDecos && m_removedFrameSize.isValid()) { + QRect r = geometry(); + r.adjust(-m_removedFrameSize.width() / 2, 0, + -m_removedFrameSize.width() / 2, -m_removedFrameSize.height()); + setGeometry(r); + m_removedFrameSize = QSize(); + } + show(); // setWindowFlags hides the window } setWindowTitle(top->windowTitle()); setWindowIcon(top->windowIcon()); } + +bool QDockWidgetGroupWindow::hasNativeDecos() const +{ + if (!QDockWidgetLayout::wmSupportsNativeWindowDeco()) + return false; + + if (QDockWidget *dw = topDockWidget()) + return dw->titleBarWidget() == nullptr; + + return true; +} + #endif /****************************************************************************** @@ -992,12 +1030,19 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, Qt::Horizontal, QTabBar::RoundedSouth, mainWindow); QRect geometry; stream >> geometry; - if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false)) + QDockAreaLayoutInfo *info = floatingTab->layoutInfo(); + if (!info->restoreState(stream, dockWidgets, false)) return false; geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab); floatingTab->move(geometry.topLeft()); floatingTab->resize(geometry.size()); - floatingTab->show(); + + // Don't show an empty QDockWidgetGroupWindow if no dock widget is available yet. + // reparentWidgets() would be triggered by show(), so do it explicitly here. + if (info->onlyHasPlaceholders()) + info->reparentWidgets(floatingTab); + else + floatingTab->show(); } break; #endif // QT_NO_TABBAR @@ -1704,6 +1749,9 @@ void QMainWindowLayout::tabChanged() if (activated) emit static_cast<QMainWindow *>(parentWidget())->tabifiedDockWidgetActivated(activated); + if (auto dwgw = qobject_cast<QDockWidgetGroupWindow*>(tb->parentWidget())) + dwgw->adjustFlags(); + if (QWidget *w = centralWidget()) w->raise(); } diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 6e8b965431..40336caeba 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -83,9 +83,14 @@ public: QDockWidget *topDockWidget() const; void destroyOrHideIfEmpty(); void adjustFlags(); + bool hasNativeDecos() const; + protected: bool event(QEvent *) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; + +private: + QSize m_removedFrameSize; }; // This item will be used in the layout for the gap item. We cannot use QWidgetItem directly diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 183f1c2848..9b39743281 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -160,7 +160,7 @@ #include <QApplication> #include <QStyle> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_STYLE_MAC) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac) #include <private/qmacstyle_mac_p.h> #endif #include <QChildEvent> diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 2fff2fc729..a627c86871 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -158,7 +158,7 @@ #include <QMainWindow> #include <QScrollBar> #include <QDebug> -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) #include <private/qmacstyle_mac_p.h> #endif #include <QMdiArea> @@ -295,7 +295,7 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti Q_ASSERT(helpEvent->type() == QEvent::ToolTip); Q_ASSERT(widget); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) // Native Mac windows don't show tool tip. if (qobject_cast<QMacStyle *>(widget->style())) return; @@ -1076,7 +1076,7 @@ void QMdiSubWindowPrivate::updateCursor() { #ifndef QT_NO_CURSOR Q_Q(QMdiSubWindow); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(q->style())) return; #endif @@ -1504,7 +1504,7 @@ void QMdiSubWindowPrivate::processClickedSubControl() q->showNormal(); break; case QStyle::SC_TitleBarMinButton: -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(q->style())) { if (q->isMinimized()) q->showNormal(); @@ -1521,7 +1521,7 @@ void QMdiSubWindowPrivate::processClickedSubControl() q->showNormal(); break; case QStyle::SC_TitleBarMaxButton: -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(q->style())) { if (q->isMaximized()) q->showNormal(); @@ -1568,7 +1568,7 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const } QRegion region; -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(q->style())) return region; #endif @@ -1775,7 +1775,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const if (isChildOfTabbedQMdiArea(q)) return false; -#if defined(Q_OS_DARWIN) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) Q_UNUSED(isChildOfQMdiSubWindow); return true; #else @@ -2191,7 +2191,7 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) return; newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); bool putSizeGripInLayout = layout ? true : false; -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(q->style())) putSizeGripInLayout = false; #endif @@ -2843,7 +2843,7 @@ bool QMdiSubWindow::event(QEvent *event) d->isMaximizeMode = false; d->isWidgetHiddenByUs = false; if (!parent()) { -#if !defined(QT_NO_SIZEGRIP) && defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(style())) delete d->sizeGrip; #endif @@ -2938,7 +2938,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) return; } -#if !defined(QT_NO_SIZEGRIP) && defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(style()) && !d->sizeGrip && !(windowFlags() & Qt::FramelessWindowHint)) { d->setSizeGrip(new QSizeGrip(this)); @@ -3333,7 +3333,7 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, d->hoveredSubControl, this); } -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) if (qobject_cast<QMacStyle *>(style()) && !hoverRegion.isEmpty()) hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options)); #endif @@ -3543,7 +3543,7 @@ QSize QMdiSubWindow::minimumSizeHint() const int sizeGripHeight = 0; if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this))) sizeGripHeight = d->sizeGrip->height(); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) +#if QT_CONFIG(style_mac) else if (parent() && qobject_cast<QMacStyle *>(style()) && !d->sizeGrip) sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); #endif diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 650d3b0bfb..33fa73eb0d 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -80,7 +80,7 @@ public: mdiChild = child; } - void *qt_metacast(const char *classname) + void *qt_metacast(const char *classname) override { if (classname && strcmp(classname, "ControlElement") == 0) return this; diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 36a8a96b79..2917083415 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1507,7 +1507,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) When inserting action items you usually specify a receiver and a slot. The receiver will be notifed whenever the item is \l{QAction::triggered()}{triggered()}. In addition, QMenu provides - two signals, activated() and highlighted(), which signal the + two signals, triggered() and hovered(), which signal the QAction that was triggered from the menu. You clear a menu with clear() and remove individual action items diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index ec15155710..7ad205b77a 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -86,9 +86,9 @@ public: void setDefaultUp(bool); bool isDefaultUp() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; - int heightForWidth(int) const; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; + int heightForWidth(int) const override; QRect actionGeometry(QAction *) const; QAction *actionAt(const QPoint &) const; @@ -104,27 +104,27 @@ public: void setNativeMenuBar(bool nativeMenuBar); QPlatformMenuBar *platformMenuBar(); public Q_SLOTS: - virtual void setVisible(bool visible); + void setVisible(bool visible) override; Q_SIGNALS: void triggered(QAction *action); void hovered(QAction *action); protected: - void changeEvent(QEvent *); - void keyPressEvent(QKeyEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void leaveEvent(QEvent *); - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); - void actionEvent(QActionEvent *); - void focusOutEvent(QFocusEvent *); - void focusInEvent(QFocusEvent *); - void timerEvent(QTimerEvent *); - bool eventFilter(QObject *, QEvent *); - bool event(QEvent *); + void changeEvent(QEvent *) override; + void keyPressEvent(QKeyEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; + void leaveEvent(QEvent *) override; + void paintEvent(QPaintEvent *) override; + void resizeEvent(QResizeEvent *) override; + void actionEvent(QActionEvent *) override; + void focusOutEvent(QFocusEvent *) override; + void focusInEvent(QFocusEvent *) override; + void timerEvent(QTimerEvent *) override; + bool eventFilter(QObject *, QEvent *) override; + bool event(QEvent *) override; void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const; private: diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 10f005e6d3..64f19047b6 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -144,16 +144,17 @@ bool QProgressBarPrivate::repaintRequired() const if (value == lastPaintedValue) return false; - int valueDifference = qAbs(value - lastPaintedValue); - + const auto valueDifference = qAbs(qint64(value) - lastPaintedValue); // Check if the text needs to be repainted if (value == minimum || value == maximum) return true; + + const auto totalSteps = qint64(maximum) - minimum; if (textVisible) { if ((format.contains(QLatin1String("%v")))) return true; if ((format.contains(QLatin1String("%p")) - && valueDifference >= qAbs((maximum - minimum) / 100))) + && valueDifference >= qAbs(totalSteps / 100))) return true; } @@ -166,7 +167,7 @@ bool QProgressBarPrivate::repaintRequired() const // (valueDifference / (maximum - minimum) > cw / groove.width()) // transformed to avoid integer division. int grooveBlock = (q->orientation() == Qt::Horizontal) ? groove.width() : groove.height(); - return (valueDifference * grooveBlock > cw * (maximum - minimum)); + return valueDifference * grooveBlock > cw * totalSteps; } /*! @@ -260,9 +261,10 @@ QProgressBar::~QProgressBar() void QProgressBar::reset() { Q_D(QProgressBar); - d->value = d->minimum - 1; if (d->minimum == INT_MIN) d->value = INT_MIN; + else + d->value = d->minimum - 1; repaint(); } @@ -358,7 +360,7 @@ void QProgressBar::setRange(int minimum, int maximum) d->minimum = minimum; d->maximum = qMax(minimum, maximum); - if (d->value < (d->minimum - 1) || d->value > d->maximum) + if (d->value < qint64(d->minimum) - 1 || d->value > d->maximum) reset(); else update(); @@ -479,11 +481,11 @@ QString QProgressBar::text() const // progress bar has one step and that we are on that step. Return // 100% here in order to avoid division by zero further down. if (totalSteps == 0) { - result.replace(QLatin1String("%p"), locale.toString(int(100))); + result.replace(QLatin1String("%p"), locale.toString(100)); return result; } - int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps; + const auto progress = static_cast<int>((qint64(d->value) - d->minimum) * 100.0 / totalSteps); result.replace(QLatin1String("%p"), locale.toString(progress)); return result; } diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index 2e77f0be7a..2eb12fd90d 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -91,11 +91,11 @@ public: void setDisplayIntegerBase(int base); protected: - bool event(QEvent *event); - virtual QValidator::State validate(QString &input, int &pos) const; + bool event(QEvent *event) override; + QValidator::State validate(QString &input, int &pos) const override; virtual int valueFromText(const QString &text) const; virtual QString textFromValue(int val) const; - virtual void fixup(QString &str) const; + void fixup(QString &str) const override; public Q_SLOTS: @@ -151,10 +151,10 @@ public: int decimals() const; void setDecimals(int prec); - virtual QValidator::State validate(QString &input, int &pos) const; + QValidator::State validate(QString &input, int &pos) const override; virtual double valueFromText(const QString &text) const; virtual QString textFromValue(double val) const; - virtual void fixup(QString &str) const; + void fixup(QString &str) const override; public Q_SLOTS: void setValue(double val); diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 9b65dc43d1..a862274a3d 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1924,19 +1924,15 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) unknown = false; } - // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards - if (unknown && !isReadOnly() - && event->modifiers() != Qt::ControlModifier - && event->modifiers() != (Qt::ControlModifier | Qt::ShiftModifier)) { - QString t = event->text(); - if (!t.isEmpty() && t.at(0).isPrint()) { - insert(t); + if (unknown + && !isReadOnly() + && isAcceptableInput(event)) { + insert(event->text()); #ifndef QT_NO_COMPLETER - complete(event->key()); + complete(event->key()); #endif - event->accept(); - return; - } + event->accept(); + return; } if (unknown) diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index d4a4534fb5..b9340c0aff 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -64,6 +64,7 @@ #include "QtCore/qpoint.h" #include "QtWidgets/qcompleter.h" #include "QtCore/qthread.h" +#include "QtGui/private/qinputcontrol_p.h" #include "qplatformdefs.h" @@ -76,13 +77,14 @@ QT_BEGIN_NAMESPACE -class Q_WIDGETS_EXPORT QWidgetLineControl : public QObject +class Q_WIDGETS_EXPORT QWidgetLineControl : public QInputControl { Q_OBJECT public: QWidgetLineControl(const QString &txt = QString()) - : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto), + : QInputControl(LineEdit) + , m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto), m_hideCursor(false), m_separator(0), m_readOnly(0), m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0), m_validInput(1), m_blinkStatus(0), m_blinkEnabled(false), m_blinkTimer(0), m_deleteAllTimer(0), diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 47806a194e..f5672bd87a 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -848,21 +848,21 @@ void QWidgetTextControl::redo() } QWidgetTextControl::QWidgetTextControl(QObject *parent) - : QObject(*new QWidgetTextControlPrivate, parent) + : QInputControl(QInputControl::TextEdit, *new QWidgetTextControlPrivate, parent) { Q_D(QWidgetTextControl); d->init(); } QWidgetTextControl::QWidgetTextControl(const QString &text, QObject *parent) - : QObject(*new QWidgetTextControlPrivate, parent) + : QInputControl(QInputControl::TextEdit, *new QWidgetTextControlPrivate, parent) { Q_D(QWidgetTextControl); d->init(Qt::RichText, text); } QWidgetTextControl::QWidgetTextControl(QTextDocument *doc, QObject *parent) - : QObject(*new QWidgetTextControlPrivate, parent) + : QInputControl(QInputControl::TextEdit, *new QWidgetTextControlPrivate, parent) { Q_D(QWidgetTextControl); d->init(Qt::RichText, QString(), doc); @@ -1361,14 +1361,7 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) process: { - // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards - if (e->modifiers() == Qt::ControlModifier - || e->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) { - e->ignore(); - return; - } - QString text = e->text(); - if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) { + if (q->isAcceptableInput(e)) { if (overwriteMode // no need to call deleteChar() if we have a selection, insertText // does it already @@ -1376,7 +1369,7 @@ process: && !cursor.atBlockEnd()) cursor.deleteChar(); - cursor.insertText(text); + cursor.insertText(e->text()); selectionChanged(); } else { e->ignore(); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index b45f4fff74..f540a3c9ad 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -63,6 +63,7 @@ #include <QtGui/qtextdocumentfragment.h> #include <QtGui/qclipboard.h> #include <QtCore/qmimedata.h> +#include <QtGui/private/qinputcontrol_p.h> QT_BEGIN_NAMESPACE @@ -75,7 +76,7 @@ class QAbstractScrollArea; class QEvent; class QTimerEvent; -class Q_WIDGETS_EXPORT QWidgetTextControl : public QObject +class Q_WIDGETS_EXPORT QWidgetTextControl : public QInputControl { Q_OBJECT Q_DECLARE_PRIVATE(QWidgetTextControl) |