diff options
Diffstat (limited to 'src/widgets/widgets')
75 files changed, 1036 insertions, 666 deletions
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7fa50f4c0b..c80e2e9d5d 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -122,16 +122,16 @@ protected: virtual void checkStateSet(); virtual void nextCheckState(); - bool event(QEvent *e); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); - void changeEvent(QEvent *e); - void timerEvent(QTimerEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; protected: diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 4cafeafcec..bcf0bbe1fc 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -923,7 +923,7 @@ QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment) they should not call this function. By default all margins are zero. - + \sa viewportMargins() */ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom) { @@ -943,7 +943,7 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b area. By default all margins are zero. - + \sa viewportMargins() */ void QAbstractScrollArea::setViewportMargins(const QMargins &margins) { @@ -951,6 +951,19 @@ void QAbstractScrollArea::setViewportMargins(const QMargins &margins) margins.right(), margins.bottom()); } +/*! + \since 5.5 + Returns the margins around the scrolling area. + By default all the margins are zero. + + \sa setViewportMargins() +*/ +QMargins QAbstractScrollArea::viewportMargins() const +{ + Q_D(const QAbstractScrollArea); + return QMargins(d->left, d->top, d->right, d->bottom); +} + /*! \internal */ bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e) { diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index a3f6c3e2d4..6a9a86b07f 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -84,9 +84,9 @@ public: void setViewport(QWidget *widget); QSize maximumViewportSize() const; - QSize minimumSizeHint() const; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; virtual void setupViewport(QWidget *viewport); @@ -97,31 +97,32 @@ protected: QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0); void setViewportMargins(int left, int top, int right, int bottom); void setViewportMargins(const QMargins &margins); + QMargins viewportMargins() const; - bool eventFilter(QObject *, QEvent *); - bool event(QEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; virtual bool viewportEvent(QEvent *); - void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - void dragEnterEvent(QDragEnterEvent *); - void dragMoveEvent(QDragMoveEvent *); - void dragLeaveEvent(QDragLeaveEvent *); - void dropEvent(QDropEvent *); + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; virtual void scrollContentsBy(int dx, int dy); diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h index aaf93a3352..a70b4df5eb 100644 --- a/src/widgets/widgets/qabstractscrollarea_p.h +++ b/src/widgets/widgets/qabstractscrollarea_p.h @@ -114,7 +114,7 @@ class QAbstractScrollAreaFilter : public QObject public: QAbstractScrollAreaFilter(QAbstractScrollAreaPrivate *p) : d(p) { setObjectName(QLatin1String("qt_abstractscrollarea_filter")); } - bool eventFilter(QObject *o, QEvent *e) + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE { return (o == d->viewport ? d->viewportEvent(e) : false); } private: QAbstractScrollAreaPrivate *d; diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h index 99312a0ef7..3b107d5502 100644 --- a/src/widgets/widgets/qabstractslider.h +++ b/src/widgets/widgets/qabstractslider.h @@ -122,7 +122,7 @@ Q_SIGNALS: void actionTriggered(int action); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50); SliderAction repeatAction() const; @@ -135,12 +135,12 @@ protected: }; virtual void sliderChange(SliderChange change); - void keyPressEvent(QKeyEvent *ev); - void timerEvent(QTimerEvent *); + void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *e); + void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif - void changeEvent(QEvent *e); + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; protected: diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index fa3dbc1f32..0071143958 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -104,11 +104,11 @@ class QCalendarDayValidator : public QCalendarDateSectionValidator public: QCalendarDayValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int m_pos; int m_day; @@ -220,11 +220,11 @@ class QCalendarMonthValidator : public QCalendarDateSectionValidator public: QCalendarMonthValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int m_pos; int m_month; @@ -337,11 +337,11 @@ class QCalendarYearValidator : public QCalendarDateSectionValidator public: QCalendarYearValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int pow10(int n); int m_pos; @@ -683,8 +683,8 @@ public: QDate date() const; void setDate(const QDate &date); - bool eventFilter(QObject *o, QEvent *e); - void timerEvent(QTimerEvent *e); + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; signals: void dateChanged(const QDate &date); @@ -853,32 +853,32 @@ class QCalendarModel : public QAbstractTableModel public: QCalendarModel(QObject *parent = 0); - int rowCount(const QModelIndex &) const + int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE { return RowCount + m_firstRow; } - int columnCount(const QModelIndex &) const + int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE { return ColumnCount + m_firstColumn; } - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginInsertRows(parent, row, row + count - 1); endInsertRows(); return true; } - bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) + bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginInsertColumns(parent, column, column + count - 1); endInsertColumns(); return true; } - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginRemoveRows(parent, row, row + count - 1); endRemoveRows(); return true; } - bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) + bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginRemoveColumns(parent, column, column + count - 1); endRemoveColumns(); @@ -939,7 +939,7 @@ public: void internalUpdate() { updateGeometries(); } void setReadOnly(bool enable); - virtual void keyboardSearch(const QString & search) { Q_UNUSED(search) } + virtual void keyboardSearch(const QString & search) Q_DECL_OVERRIDE { Q_UNUSED(search) } signals: void showDate(const QDate &date); @@ -947,16 +947,16 @@ signals: void clicked(const QDate &date); void editingFinished(); protected: - QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); - void mouseDoubleClickEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *event); - bool event(QEvent *event); + void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; QDate handleMouseEvent(QMouseEvent *event); public: @@ -1555,7 +1555,7 @@ public: : QItemDelegate(parent), calendarWidgetPrivate(w) { } virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; private: @@ -1571,7 +1571,7 @@ public: : QToolButton(parent) { } protected: - void paintEvent(QPaintEvent *e) + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE { Q_UNUSED(e) @@ -1599,7 +1599,7 @@ class QPrevNextCalButton : public QToolButton public: QPrevNextCalButton(QWidget *parent) : QToolButton(parent) {} protected: - void paintEvent(QPaintEvent *) { + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE { QStylePainter painter(this); QStyleOptionToolButton opt; initStyleOption(&opt); diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h index e838098e53..f039fdf6c9 100644 --- a/src/widgets/widgets/qcalendarwidget.h +++ b/src/widgets/widgets/qcalendarwidget.h @@ -86,8 +86,8 @@ public: explicit QCalendarWidget(QWidget *parent = 0); ~QCalendarWidget(); - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const Q_DECL_OVERRIDE; + virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; QDate selectedDate() const; @@ -132,11 +132,11 @@ public: void setDateEditAcceptDelay(int delay); protected: - bool event(QEvent *event); - bool eventFilter(QObject *watched, QEvent *event); - void mousePressEvent(QMouseEvent *event); - void resizeEvent(QResizeEvent * event); - void keyPressEvent(QKeyEvent * event); + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; void updateCell(const QDate &date); diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h index fe954571aa..6586793db2 100644 --- a/src/widgets/widgets/qcheckbox.h +++ b/src/widgets/widgets/qcheckbox.h @@ -53,8 +53,8 @@ public: explicit QCheckBox(const QString &text, QWidget *parent=0); ~QCheckBox(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setTristate(bool y = true); bool isTristate() const; @@ -66,12 +66,12 @@ Q_SIGNALS: void stateChanged(int); protected: - bool event(QEvent *e); - bool hitButton(const QPoint &pos) const; - void checkStateSet(); - void nextCheckState(); - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE; + void checkStateSet() Q_DECL_OVERRIDE; + void nextCheckState() Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *option) const; diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 806653d2d8..7e399ec1f5 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -188,14 +188,14 @@ public: QAbstractItemView *view() const; void setView(QAbstractItemView *itemView); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; virtual void showPopup(); virtual void hidePopup(); - bool event(QEvent *event); - QVariant inputMethodQuery(Qt::InputMethodQuery) const; + bool event(QEvent *event) Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE; public Q_SLOTS: void clear(); @@ -215,22 +215,22 @@ Q_SIGNALS: void currentTextChanged(const QString &); protected: - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); - void changeEvent(QEvent *e); - void resizeEvent(QResizeEvent *e); - void paintEvent(QPaintEvent *e); - void showEvent(QShowEvent *e); - void hideEvent(QHideEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); + void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *e); + void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif - void contextMenuEvent(QContextMenuEvent *e); - void inputMethodEvent(QInputMethodEvent *); + void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionComboBox *option) const; diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h index bfef2e300d..582f666e83 100644 --- a/src/widgets/widgets/qcommandlinkbutton.h +++ b/src/widgets/widgets/qcommandlinkbutton.h @@ -58,11 +58,11 @@ public: void setDescription(const QString &description); protected: - QSize sizeHint() const; - int heightForWidth(int) const; - QSize minimumSizeHint() const; - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + QSize sizeHint() const Q_DECL_OVERRIDE; + int heightForWidth(int) const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QCommandLinkButton) diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp index 0dd6515f5b..a9de9a7154 100644 --- a/src/widgets/widgets/qdial.cpp +++ b/src/widgets/widgets/qdial.cpp @@ -75,7 +75,7 @@ public: int valueFromPoint(const QPoint &) const; double angle(const QPoint &, const QPoint &) const; void init(); - virtual int bound(int val) const; + virtual int bound(int val) const Q_DECL_OVERRIDE; }; void QDialPrivate::init() diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h index de233b09b7..acaf6c8c9e 100644 --- a/src/widgets/widgets/qdial.h +++ b/src/widgets/widgets/qdial.h @@ -66,23 +66,23 @@ public: qreal notchTarget() const; bool notchesVisible() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setNotchesVisible(bool visible); void setWrapping(bool on); protected: - bool event(QEvent *e); - void resizeEvent(QResizeEvent *re); - void paintEvent(QPaintEvent *pe); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *pe) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *me); - void mouseReleaseEvent(QMouseEvent *me); - void mouseMoveEvent(QMouseEvent *me); + void mousePressEvent(QMouseEvent *me) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *me) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *me) Q_DECL_OVERRIDE; - void sliderChange(SliderChange change); + void sliderChange(SliderChange change) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h index e20a166d29..7bf497e3e5 100644 --- a/src/widgets/widgets/qdialogbuttonbox.h +++ b/src/widgets/widgets/qdialogbuttonbox.h @@ -140,8 +140,8 @@ Q_SIGNALS: void rejected(); protected: - void changeEvent(QEvent *event); - bool event(QEvent *event); + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QDialogButtonBox) diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 93e6131ab9..121fb2da49 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -109,13 +109,13 @@ class QDockWidgetTitleButton : public QAbstractButton public: QDockWidgetTitleButton(QDockWidget *dockWidget); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; inline QSize minimumSizeHint() const { return sizeHint(); } - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - void paintEvent(QPaintEvent *event); + void enterEvent(QEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; }; diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index 70ee2a4dcb..fb5c2c375a 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -106,10 +106,10 @@ Q_SIGNALS: void dockLocationChanged(Qt::DockWidgetArea area); protected: - void changeEvent(QEvent *event); - void closeEvent(QCloseEvent *event); - void paintEvent(QPaintEvent *event); - bool event(QEvent *event); + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionDockWidget *option) const; private: diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 7d75b4859c..e8c4720a98 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -128,18 +128,18 @@ class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout public: QDockWidgetLayout(QWidget *parent = 0); ~QDockWidgetLayout(); - void addItem(QLayoutItem *item); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - QSize maximumSize() const; - QSize minimumSize() const; - QSize sizeHint() const; + QSize maximumSize() const Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; QSize sizeFromContent(const QSize &content, bool floating) const; - void setGeometry(const QRect &r); + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount }; QWidget *widgetForRole(Role r) const; @@ -170,9 +170,9 @@ class QDockWidgetItem : public QWidgetItem { public: QDockWidgetItem(QDockWidget *dockWidget); - QSize minimumSize() const; - QSize maximumSize() const; - QSize sizeHint() const; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize maximumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; private: inline QLayoutItem *dockWidgetChildItem() const; diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index 33fa772d83..79e9c0669a 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -64,10 +64,10 @@ public: void run(int time); protected: - void paintEvent(QPaintEvent* e); - void closeEvent(QCloseEvent*); + void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE; void alphaBlend(); - bool eventFilter(QObject *, QEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; protected slots: void render(); @@ -341,8 +341,8 @@ public: void run(int time); protected: - void paintEvent(QPaintEvent*); - void closeEvent(QCloseEvent*); + void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE; private slots: void scroll(); diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h index d84f286bb6..08eb2a570d 100644 --- a/src/widgets/widgets/qfocusframe.h +++ b/src/widgets/widgets/qfocusframe.h @@ -53,10 +53,10 @@ public: QWidget *widget() const; protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; - bool eventFilter(QObject *, QEvent *); - void paintEvent(QPaintEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOption *option) const; private: diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 4e3b57bd02..b040d9ba0d 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -188,10 +188,10 @@ public: // painting void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; QIcon truetype; QIcon bitmap; diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h index 95bedc7009..c2e5332c50 100644 --- a/src/widgets/widgets/qfontcombobox.h +++ b/src/widgets/widgets/qfontcombobox.h @@ -72,7 +72,7 @@ public: FontFilters fontFilters() const; QFont currentFont() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setCurrentFont(const QFont &f); @@ -81,7 +81,7 @@ Q_SIGNALS: void currentFontChanged(const QFont &f); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QFontComboBox) diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp index 57cd51396c..b914a80f1d 100644 --- a/src/widgets/widgets/qframe.cpp +++ b/src/widgets/widgets/qframe.cpp @@ -202,6 +202,49 @@ QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f) d->init(); } +/*! + \since 5.5 + + Initializes \a option with the values from this QFrame. This method is + useful for subclasses when they need a QStyleOptionFrame but don't want to + fill in all the information themselves. + + \sa QStyleOption::initFrom() +*/ +void QFrame::initStyleOption(QStyleOptionFrame *option) const +{ + if (!option) + return; + + Q_D(const QFrame); + option->initFrom(this); + + int frameShape = d->frameStyle & QFrame::Shape_Mask; + int frameShadow = d->frameStyle & QFrame::Shadow_Mask; + option->frameShape = Shape(int(option->frameShape) | frameShape); + option->rect = frameRect(); + switch (frameShape) { + case QFrame::Box: + case QFrame::HLine: + case QFrame::VLine: + case QFrame::StyledPanel: + case QFrame::Panel: + option->lineWidth = d->lineWidth; + option->midLineWidth = d->midLineWidth; + break; + default: + // most frame styles do not handle customized line and midline widths + // (see updateFrameWidth()). + option->lineWidth = d->frameWidth; + break; + } + + if (frameShadow == Sunken) + option->state |= QStyle::State_Sunken; + else if (frameShadow == Raised) + option->state |= QStyle::State_Raised; +} + /*! Destroys the frame. @@ -362,10 +405,7 @@ void QFramePrivate::updateStyledFrameWidths() { Q_Q(const QFrame); QStyleOptionFrame opt; - opt.initFrom(q); - opt.lineWidth = lineWidth; - opt.midLineWidth = midLineWidth; - opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); + q->initStyleOption(&opt); QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); leftFrameWidth = cr.left() - opt.rect.left(); @@ -472,34 +512,8 @@ void QFrame::paintEvent(QPaintEvent *) */ void QFrame::drawFrame(QPainter *p) { - Q_D(QFrame); QStyleOptionFrame opt; - opt.init(this); - int frameShape = d->frameStyle & QFrame::Shape_Mask; - int frameShadow = d->frameStyle & QFrame::Shadow_Mask; - opt.frameShape = Shape(int(opt.frameShape) | frameShape); - opt.rect = frameRect(); - switch (frameShape) { - case QFrame::Box: - case QFrame::HLine: - case QFrame::VLine: - case QFrame::StyledPanel: - case QFrame::Panel: - opt.lineWidth = d->lineWidth; - opt.midLineWidth = d->midLineWidth; - break; - default: - // most frame styles do not handle customized line and midline widths - // (see updateFrameWidth()). - opt.lineWidth = d->frameWidth; - break; - } - - if (frameShadow == Sunken) - opt.state |= QStyle::State_Sunken; - else if (frameShadow == Raised) - opt.state |= QStyle::State_Raised; - + initStyleOption(&opt); style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); } diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h index ff04d70afc..90e434722e 100644 --- a/src/widgets/widgets/qframe.h +++ b/src/widgets/widgets/qframe.h @@ -40,6 +40,7 @@ QT_BEGIN_NAMESPACE class QFramePrivate; +class QStyleOptionFrame; class Q_WIDGETS_EXPORT QFrame : public QWidget { @@ -62,7 +63,7 @@ public: int frameWidth() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; enum Shape { NoFrame = 0, // no frame @@ -99,14 +100,15 @@ public: void setFrameRect(const QRect &); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; void drawFrame(QPainter *); protected: QFrame(QFramePrivate &dd, QWidget* parent = 0, Qt::WindowFlags f = 0); + void initStyleOption(QStyleOptionFrame *option) const; private: Q_DISABLE_COPY(QFrame) diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h index ca5a95e79e..da0f4680d6 100644 --- a/src/widgets/widgets/qgroupbox.h +++ b/src/widgets/widgets/qgroupbox.h @@ -63,7 +63,7 @@ public: Qt::Alignment alignment() const; void setAlignment(int alignment); - QSize minimumSizeHint() const; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; bool isFlat() const; void setFlat(bool flat); @@ -79,15 +79,15 @@ Q_SIGNALS: void toggled(bool); protected: - bool event(QEvent *event); - void childEvent(QChildEvent *event); - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); - void focusInEvent(QFocusEvent *event); - void changeEvent(QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionGroupBox *option) const; diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index a1e9543187..be56d3bf0f 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -88,13 +88,13 @@ public: bool hasScaledContents() const; void setScaledContents(bool); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; #ifndef QT_NO_SHORTCUT void setBuddy(QWidget *); QWidget *buddy() const; #endif - int heightForWidth(int) const; + int heightForWidth(int) const Q_DECL_OVERRIDE; bool openExternalLinks() const; void setOpenExternalLinks(bool open); @@ -125,17 +125,17 @@ Q_SIGNALS: void linkHovered(const QString& link); protected: - bool event(QEvent *e); - void keyPressEvent(QKeyEvent *ev); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); - void mousePressEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); - void mouseReleaseEvent(QMouseEvent *ev); - void contextMenuEvent(QContextMenuEvent *ev); - void focusInEvent(QFocusEvent *ev); - void focusOutEvent(QFocusEvent *ev); - bool focusNextPrevChild(bool next); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h index 0c3a4d6cf5..6acba3f7c1 100644 --- a/src/widgets/widgets/qlcdnumber.h +++ b/src/widgets/widgets/qlcdnumber.h @@ -81,7 +81,7 @@ public: double value() const; int intValue() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void display(const QString &str); @@ -97,8 +97,8 @@ Q_SIGNALS: void overflow(); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; public: diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index bd8dd783ff..5a504a880c 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1405,7 +1405,7 @@ bool QLineEdit::event(QEvent * e) { Q_D(QLineEdit); if (e->type() == QEvent::Timer) { - // should be timerEvent, is here for binary compatibility + // ### Qt6: move to timerEvent, is here for binary compatibility int timerId = ((QTimerEvent*)e)->timerId(); if (false) { #ifndef QT_NO_DRAGANDDROP diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 3997ed16fd..f1c92b48c7 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -121,8 +121,8 @@ public: QCompleter *completer() const; #endif - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; int cursorPosition() const; void setCursorPosition(int); @@ -204,30 +204,30 @@ Q_SIGNALS: void selectionChanged(); protected: - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void keyPressEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); - void paintEvent(QPaintEvent *); + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_DRAGANDDROP - void dragEnterEvent(QDragEnterEvent *); - void dragMoveEvent(QDragMoveEvent *e); - void dragLeaveEvent(QDragLeaveEvent *e); - void dropEvent(QDropEvent *); + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; #endif - void changeEvent(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif - void inputMethodEvent(QInputMethodEvent *); + void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionFrame *option) const; public: - QVariant inputMethodQuery(Qt::InputMethodQuery) const; - bool event(QEvent *); + QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; protected: QRect cursorRect() const; diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 6426329de6..95fc7551fc 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -81,7 +81,7 @@ public: #endif protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private slots: void updateCursor(); diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 4478c47449..717bc32739 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -188,9 +188,9 @@ Q_SIGNALS: protected: #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *event); + void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; #endif - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; private: Q_DECLARE_PRIVATE(QMainWindow) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 827e2ed2ba..9e8e0aee27 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1243,7 +1243,7 @@ class QMainWindowTabBar : public QTabBar public: QMainWindowTabBar(QWidget *parent); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; }; QMainWindowTabBar::QMainWindowTabBar(QWidget *parent) diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index d9e18b03f4..4e10aef891 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -151,7 +151,7 @@ public: void setDockOptions(QMainWindow::DockOptions opts); bool usesHIToolBar(QToolBar *toolbar) const; - void timerEvent(QTimerEvent *e); + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; // status bar @@ -249,17 +249,17 @@ public: // QLayout interface - void addItem(QLayoutItem *item); - void setGeometry(const QRect &r); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - QSize sizeHint() const; - QSize minimumSize() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; mutable QSize szHint; mutable QSize minSize; - void invalidate(); + void invalidate() Q_DECL_OVERRIDE; // animations diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 3553baf68a..e104a3511b 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -567,9 +567,9 @@ public: QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {} protected: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *event); + void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; #endif private: diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h index 18d559e21b..b824cfb4ae 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -82,8 +82,8 @@ public: QMdiArea(QWidget *parent = 0); ~QMdiArea(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; QMdiSubWindow *currentSubWindow() const; QMdiSubWindow *activeSubWindow() const; @@ -135,18 +135,18 @@ public Q_SLOTS: void activatePreviousSubWindow(); protected Q_SLOTS: - void setupViewport(QWidget *viewport); + void setupViewport(QWidget *viewport) Q_DECL_OVERRIDE; protected: - bool event(QEvent *event); - bool eventFilter(QObject *object, QEvent *event); - void paintEvent(QPaintEvent *paintEvent); - void childEvent(QChildEvent *childEvent); - void resizeEvent(QResizeEvent *resizeEvent); - void timerEvent(QTimerEvent *timerEvent); - void showEvent(QShowEvent *showEvent); - bool viewportEvent(QEvent *event); - void scrollContentsBy(int dx, int dy); + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE; + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QMdiArea) diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index ba531adaad..d1341d5837 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -81,7 +81,7 @@ class RegularTiler : public Rearranger // Rearranges widgets according to a regular tiling pattern // covering the entire domain. // Both positions and sizes may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; inline Type type() const { return Rearranger::RegularTiler; } }; @@ -90,7 +90,7 @@ class SimpleCascader : public Rearranger // Rearranges widgets according to a simple, regular cascading pattern. // Widgets are resized to minimumSize. // Both positions and sizes may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; inline Type type() const { return Rearranger::SimpleCascader; } }; @@ -99,7 +99,7 @@ class IconTiler : public Rearranger // Rearranges icons (assumed to be the same size) according to a regular // tiling pattern filling up the domain from the bottom. // Only positions may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; inline Type type() const { return Rearranger::IconTiler; } }; @@ -115,7 +115,7 @@ public: class MinOverlapPlacer : public Placer { - QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const; + QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const Q_DECL_OVERRIDE; static int accumulatedOverlap(const QRect &source, const QVector<QRect> &rects); static QRect findMinOverlapRect(const QVector<QRect> &source, const QVector<QRect> &rects); static QVector<QRect> getCandidatePlacements(const QSize &size, const QVector<QRect> &rects, const QRect &domain); @@ -199,7 +199,7 @@ public: bool lastWindowAboutToBeDestroyed() const; void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const; QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount); - void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp + void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) Q_DECL_OVERRIDE; // reimp QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder, int removed = -1, int fromIndex = -1) const; void highlightNextSubWindow(int increaseFactor); diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 2340c8fe4b..d656c0abb7 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -362,18 +362,18 @@ class ControlLabel : public QWidget public: ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; signals: void _q_clicked(); void _q_doubleClicked(); protected: - bool event(QEvent *event); - void paintEvent(QPaintEvent *paintEvent); - void mousePressEvent(QMouseEvent *mouseEvent); - void mouseDoubleClickEvent(QMouseEvent *mouseEvent); - void mouseReleaseEvent(QMouseEvent *mouseEvent); + bool event(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; private: QPixmap label; @@ -488,7 +488,7 @@ class ControllerWidget : public QWidget Q_OBJECT public: ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible); inline bool hasVisibleControls() const { @@ -503,12 +503,12 @@ signals: void _q_close(); protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void leaveEvent(QEvent *event); - bool event(QEvent *event); + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; private: QStyle::SubControl activeControl; diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index a94ecfb48e..6e4d0514ee 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -63,8 +63,8 @@ public: QMdiSubWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~QMdiSubWindow(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setWidget(QWidget *widget); QWidget *widget() const; @@ -101,28 +101,28 @@ public Q_SLOTS: void showShaded(); protected: - bool eventFilter(QObject *object, QEvent *event); - bool event(QEvent *event); - void showEvent(QShowEvent *showEvent); - void hideEvent(QHideEvent *hideEvent); - void changeEvent(QEvent *changeEvent); - void closeEvent(QCloseEvent *closeEvent); - void leaveEvent(QEvent *leaveEvent); - void resizeEvent(QResizeEvent *resizeEvent); - void timerEvent(QTimerEvent *timerEvent); - void moveEvent(QMoveEvent *moveEvent); - void paintEvent(QPaintEvent *paintEvent); - void mousePressEvent(QMouseEvent *mouseEvent); - void mouseDoubleClickEvent(QMouseEvent *mouseEvent); - void mouseReleaseEvent(QMouseEvent *mouseEvent); - void mouseMoveEvent(QMouseEvent *mouseEvent); - void keyPressEvent(QKeyEvent *keyEvent); + bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE; + void changeEvent(QEvent *changeEvent) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *closeEvent) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *leaveEvent) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *keyEvent) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *contextMenuEvent); + void contextMenuEvent(QContextMenuEvent *contextMenuEvent) Q_DECL_OVERRIDE; #endif - void focusInEvent(QFocusEvent *focusInEvent); - void focusOutEvent(QFocusEvent *focusOutEvent); - void childEvent(QChildEvent *childEvent); + void focusInEvent(QFocusEvent *focusInEvent) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *focusOutEvent) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QMdiSubWindow) diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 763f6ba039..f5cb94faea 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -260,7 +260,7 @@ public: void setFocusWidget(); bool restoreFocus(); void storeFocusWidget(); - void setWindowFlags(Qt::WindowFlags windowFlags); + void setWindowFlags(Qt::WindowFlags windowFlags) Q_DECL_OVERRIDE; void setVisible(WindowStateAction, bool visible = true); #ifndef QT_NO_ACTION void setEnabled(WindowStateAction, bool enable = true); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 5e5126e1e8..7e70be0aed 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -70,6 +70,22 @@ QT_BEGIN_NAMESPACE QMenu *QMenuPrivate::mouseDown = 0; +QPointer<QMenu> QMenuPrivate::previousMouseMenu(Q_NULLPTR); +static void handleEnterLeaveEvents(QPointer<QMenu> *previous_ptr, QMenu *next) +{ + QWidget *previous = previous_ptr->data(); + if (previous != next) { + if (previous) { + QEvent leaveEvent(QEvent::Leave); + QApplication::sendEvent(previous, &leaveEvent); + } + if (next) { + QEvent enterEvent(QEvent::Enter); + QApplication::sendEvent(next, &enterEvent); + } + } + *previous_ptr = next; +} /* QMenu code */ // internal class used for the torn off popup @@ -86,7 +102,7 @@ class QTornOffMenu : public QMenu causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action; causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack(); } - QList<QPointer<QWidget> > calcCausedStack() const { return causedStack; } + QList<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; } QPointer<QMenu> causedMenu; QList<QPointer<QWidget> > causedStack; }; @@ -119,7 +135,7 @@ public: } else if (act->type() == QEvent::ActionRemoved) removeAction(act->action()); } - void actionEvent(QActionEvent *e) + void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE { QMenu::actionEvent(e); setFixedSize(sizeHint()); @@ -148,6 +164,9 @@ void QMenuPrivate::init() } setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu()); + sloppyState.initialize(q); + delayState.initialize(q); + mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q); } void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) @@ -270,7 +289,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const maxIconWidth = 0; hasCheckableItems = false; ncols = 1; - sloppyAction = 0; for (int i = 0; i < actions.count(); ++i) { QAction *action = actions.at(i); @@ -482,21 +500,30 @@ void QMenuPrivate::hideMenu(QMenu *menu) aboutToHide = false; blocker.unblock(); #endif // QT_NO_EFFECTS + if (activeMenu == menu) + activeMenu = 0; + menu->d_func()->causedPopup.action = 0; + menu->d_func()->causedPopup.widget = 0; menu->close(); + if (previousMouseMenu.data() == menu) + handleEnterLeaveEvents(&previousMouseMenu, Q_NULLPTR); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) { Q_Q(QMenu); - if (action && action->isEnabled()) { - if (!delay) - q->internalDelayedPopup(); - else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible())) - menuDelayTimer.start(delay, q); - if (activateFirst && action->menu()) - action->menu()->d_func()->setFirstActionActive(); + if (action) { + if (action->isEnabled()) { + if (!delay) + q->internalDelayedPopup(); + else if (action->menu() && !action->menu()->isVisible()) + delayState.start(delay, action); + else if (!action->menu()) + delayState.stop(); + if (activateFirst && action->menu()) + action->menu()->d_func()->setFirstActionActive(); + } } else if (QMenu *menu = activeMenu) { //hide the current item - activeMenu = 0; hideMenu(menu); } } @@ -547,33 +574,32 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason { Q_Q(QMenu); tearoffHighlighted = 0; + + if (action + && (action->isSeparator() + || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)))) + action = Q_NULLPTR; + // Reselect the currently active action in case mouse moved over other menu items when // moving from sub menu action to sub menu (QTBUG-20094). - if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) { + if (reason != SelectedFromKeyboard) { if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) { if (causedPopup.action && menu->d_func()->activeMenu == q) menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); } - return; } if (currentAction) q->update(actionRect(currentAction)); - sloppyAction = 0; - if (!sloppyRegion.isEmpty()) - sloppyRegion = QRegion(); QMenu *hideActiveMenu = activeMenu; -#ifndef QT_NO_STATUSTIP QAction *previousAction = currentAction; -#endif currentAction = action; if (action) { if (!action->isSeparator()) { activateAction(action, QAction::Hover); if (popup != -1) { - hideActiveMenu = 0; //will be done "later" // if the menu is visible then activate the required action, // otherwise we just mark the action as currentAction // and activate it when the menu will be popuped. @@ -596,24 +622,122 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } } } - } else { //action is a separator - if (popup != -1) - hideActiveMenu = 0; //will be done "later" } #ifndef QT_NO_STATUSTIP } else if (previousAction) { previousAction->d_func()->showStatusText(topCausedWidget(), QString()); #endif } - if (hideActiveMenu) { - activeMenu = 0; + if (hideActiveMenu && previousAction != currentAction) { + if (popup == -1) { #ifndef QT_NO_EFFECTS - // kill any running effect - qFadeEffect(0); - qScrollEffect(0); + // kill any running effect + qFadeEffect(0); + qScrollEffect(0); #endif - hideMenu(hideActiveMenu); + hideMenu(hideActiveMenu); + } else if (!currentAction || !currentAction->menu()) { + sloppyState.startTimerIfNotRunning(); + } + } +} + +void QMenuSloppyState::reset() +{ + m_enabled = false; + m_first_mouse = true; + m_init_guard = false; + m_uni_dir_discarded_count = 0; + m_time.stop(); + m_reset_action = Q_NULLPTR; + m_origin_action = Q_NULLPTR; + m_action_rect = QRect(); + m_previous_point = QPointF(); + if (m_sub_menu) { + QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = Q_NULLPTR; + m_sub_menu = Q_NULLPTR; + } +} +void QMenuSloppyState::enter() +{ + QMenuPrivate *menuPriv = QMenuPrivate::get(m_menu); + + if (m_discard_state_when_entering_parent && m_sub_menu == menuPriv->activeMenu) { + menuPriv->hideMenu(m_sub_menu); + reset(); + } + if (m_parent) + m_parent->childEnter(); +} + +void QMenuSloppyState::childLeave() +{ + if (m_enabled && !QMenuPrivate::get(m_menu)->hasReceievedEnter) { + startTimer(); + if (m_parent) + m_parent->childLeave(); + } +} + +void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu) +{ + m_enabled = true; + m_init_guard = true; + m_time.stop(); + m_action_rect = actionRect; + m_sub_menu = subMenu; + QMenuPrivate::get(subMenu)->sloppyState.m_parent = this; + m_reset_action = resetAction; + m_origin_action = resetAction; +} + +bool QMenuSloppyState::hasParentActiveDelayTimer() const +{ + return m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive(); +} + +class ResetOnDestroy +{ +public: + ResetOnDestroy(QMenuSloppyState *sloppyState, bool *guard) + : toReset(sloppyState) + , guard(guard) + { + *guard = false; } + + ~ResetOnDestroy() + { + if (!*guard) + toReset->reset(); + } + + QMenuSloppyState *toReset; + bool *guard; +}; + +void QMenuSloppyState::timeout() +{ + QMenuPrivate *menu_priv = QMenuPrivate::get(m_menu); + if (menu_priv->currentAction == m_reset_action + && menu_priv->hasReceievedEnter + && (menu_priv->currentAction + && menu_priv->currentAction->menu() == menu_priv->activeMenu)) { + return; + } + + ResetOnDestroy resetState(this, &m_init_guard); + + if (hasParentActiveDelayTimer() || !m_menu || !m_menu->isVisible()) + return; + + if (m_sub_menu) + menu_priv->hideMenu(m_sub_menu); + + if (menu_priv->hasReceievedEnter) + menu_priv->setCurrentAction(m_reset_action,0); + else + menu_priv->setCurrentAction(Q_NULLPTR, 0); } //return the top causedPopup.widget that is not a QMenu @@ -964,8 +1088,10 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) tearoffHighlighted = 0; } - if (q->frameGeometry().contains(e->globalPos())) //otherwise if the event is in our rect we want it.. + if (q->frameGeometry().contains(e->globalPos())) { //otherwise if the event is in our rect we want it.. + handleEnterLeaveEvents(&previousMouseMenu, q); return false; + } for(QWidget *caused = causedPopup.widget; caused;) { bool passOnEvent = false; @@ -981,17 +1107,18 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) next_widget = m->d_func()->causedPopup.widget; } if (passOnEvent) { + handleEnterLeaveEvents(&previousMouseMenu,qobject_cast<QMenu *>(caused)); if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), e->button(), e->buttons(), e->modifiers()); QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source()); QApplication::sendEvent(caused, &new_e); return true; + } } - } - if (!next_widget) - break; caused = next_widget; + if (!caused) + handleEnterLeaveEvents(&previousMouseMenu, Q_NULLPTR); } return false; } @@ -2236,6 +2363,8 @@ void QMenu::hideEvent(QHideEvent *) #endif d->mouseDown = 0; d->hasHadMouse = false; + if (d->activeMenu) + d->hideMenu(d->activeMenu); d->causedPopup.widget = 0; d->causedPopup.action = 0; if (d->scroll) @@ -2402,7 +2531,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) #endif d->activateAction(action, QAction::Trigger); } - } else if (d->hasMouseMoved(e->globalPos())) { + } else if ((!action || action->isEnabled()) && d->hasMouseMoved(e->globalPos())) { d->hideUpToMenuBar(); } } @@ -2467,8 +2596,8 @@ QMenu::event(QEvent *e) } } break; case QEvent::ContextMenu: - if(d->menuDelayTimer.isActive()) { - d->menuDelayTimer.stop(); + if (d->delayState.timer.isActive()) { + d->delayState.stop(); internalDelayedPopup(); } break; @@ -2485,6 +2614,7 @@ QMenu::event(QEvent *e) case QEvent::Show: d->mouseDown = 0; d->updateActionRects(); + d->sloppyState.reset(); if (d->currentAction) d->popupAction(d->currentAction, 0, false); break; @@ -2892,34 +3022,34 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) Q_D(QMenu); if (!isVisible() || d->aboutToHide || d->mouseEventTaken(e)) return; + d->motions++; - if (d->motions == 0) // ignore first mouse move event (see enterEvent()) + if (d->motions == 0) return; + d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos()); QAction *action = d->actionAt(e->pos()); - if (!action || action->isSeparator()) { + if ((!action || action->isSeparator()) && !d->sloppyState.enabled()) { if (d->hasHadMouse - && d->sloppyDelayTimer == 0 // Keep things as they are while we're moving to the submenu - && (!d->currentAction || (action && action->isSeparator()) - || !(d->currentAction->menu() && d->currentAction->menu()->isVisible()))) - d->setCurrentAction(0); + || (!d->currentAction || !d->currentAction->menu() || !d->currentAction->menu()->isVisible())) { + d->setCurrentAction(action); + } return; - } else if(e->buttons()) { - d->mouseDown = this; } - if (d->sloppyRegion.contains(e->pos())) { - // If the timer is already running then don't start a new one unless the action is the same - if (d->sloppyAction != action && d->sloppyDelayTimer != 0) { - killTimer(d->sloppyDelayTimer); - d->sloppyDelayTimer = 0; - } - if (d->sloppyDelayTimer == 0) { - d->sloppyAction = action; - d->sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this) * 6); - } - } else if (action != d->currentAction) { - d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); + + if (e->buttons()) + d->mouseDown = this; + + if (d->activeMenu) + d->activeMenu->d_func()->setCurrentAction(0); + + QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction); + if (sloppyEventResult == QMenuSloppyState::EventShouldBePropogated) { + d->setCurrentAction(action, d->mousePopupDelay); + } else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) { + d->sloppyState.reset(); + d->hideMenu(d->activeMenu); } } @@ -2928,7 +3058,11 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) */ void QMenu::enterEvent(QEvent *) { - d_func()->motions = -1; // force us to ignore the generate mouse move in mouseMoveEvent() + Q_D(QMenu); + d->hasReceievedEnter = true; + d->sloppyState.enter(); + d->sloppyState.startTimer(); + d->motions = -1; // force us to ignore the generate mouse move in mouseMoveEvent() } /*! @@ -2937,9 +3071,8 @@ void QMenu::enterEvent(QEvent *) void QMenu::leaveEvent(QEvent *) { Q_D(QMenu); - d->sloppyAction = 0; - if (!d->sloppyRegion.isEmpty()) - d->sloppyRegion = QRegion(); + d->hasReceievedEnter = false; + d->sloppyState.leave(); if (!d->activeMenu && d->currentAction) setActiveAction(0); } @@ -2955,13 +3088,14 @@ QMenu::timerEvent(QTimerEvent *e) d->scrollMenu((QMenuPrivate::QMenuScroller::ScrollDirection)d->scroll->scrollDirection); if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone) d->scroll->scrollTimer.stop(); - } else if(d->menuDelayTimer.timerId() == e->timerId()) { - d->menuDelayTimer.stop(); + } else if (d->delayState.timer.timerId() == e->timerId()) { + if (d->currentAction && !d->currentAction->menu()) + return; + d->delayState.stop(); + d->sloppyState.stopTimer(); internalDelayedPopup(); - } else if (d->sloppyDelayTimer == e->timerId()) { - killTimer(d->sloppyDelayTimer); - d->sloppyDelayTimer = 0; - internalSetSloppyAction(); + } else if (d->sloppyState.isTimerId(e->timerId())) { + d->sloppyState.timeout(); } else if(d->searchBufferTimer.timerId() == e->timerId()) { d->searchBuffer.clear(); } @@ -3086,23 +3220,13 @@ void QMenu::actionEvent(QActionEvent *e) /*! \internal */ -void QMenu::internalSetSloppyAction() -{ - if (d_func()->sloppyAction) - d_func()->setCurrentAction(d_func()->sloppyAction, 0); -} - -/*! - \internal -*/ void QMenu::internalDelayedPopup() { Q_D(QMenu); - //hide the current item if (QMenu *menu = d->activeMenu) { - d->activeMenu = 0; - d->hideMenu(menu); + if (d->activeMenu->menuAction() != d->currentAction) + d->hideMenu(menu); } if (!d->currentAction || !d->currentAction->isEnabled() || !d->currentAction->menu() || @@ -3116,34 +3240,12 @@ void QMenu::internalDelayedPopup() int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); const QRect actionRect(d->actionRect(d->currentAction)); - const QSize menuSize(d->activeMenu->sizeHint()); const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); QPoint pos(rightPos); - //calc sloppy focus buffer - if (style()->styleHint(QStyle::SH_Menu_SloppySubMenus, 0, this)) { - QPoint cur = QCursor::pos(); - if (actionRect.contains(mapFromGlobal(cur))) { - QPoint pts[4]; - pts[0] = QPoint(cur.x(), cur.y() - 2); - pts[3] = QPoint(cur.x(), cur.y() + 2); - if (pos.x() >= cur.x()) { - pts[1] = QPoint(geometry().right(), pos.y()); - pts[2] = QPoint(geometry().right(), pos.y() + menuSize.height()); - } else { - pts[1] = QPoint(pos.x() + menuSize.width(), pos.y()); - pts[2] = QPoint(pos.x() + menuSize.width(), pos.y() + menuSize.height()); - } - QPolygon points(4); - for(int i = 0; i < 4; i++) - points.setPoint(i, mapFromGlobal(pts[i])); - d->sloppyRegion = QRegion(points); - } - } - - //do the popup d->activeMenu->popup(pos); + d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); } /*! diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 937f6e3316..8fd93a5a0f 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -117,7 +117,7 @@ public: static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0, QWidget *parent=0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; QRect actionGeometry(QAction *) const; QAction *actionAt(const QPoint &) const; @@ -157,22 +157,22 @@ Q_SIGNALS: protected: int columnCount() const; - void changeEvent(QEvent *); - void keyPressEvent(QKeyEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void hideEvent(QHideEvent *); - void paintEvent(QPaintEvent *); - void actionEvent(QActionEvent *); - void timerEvent(QTimerEvent *); - bool event(QEvent *); - bool focusNextPrevChild(bool next); + void enterEvent(QEvent *) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void actionEvent(QActionEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const; #ifdef Q_OS_WINCE @@ -180,7 +180,6 @@ protected: #endif private Q_SLOTS: - void internalSetSloppyAction(); void internalDelayedPopup(); private: diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 4a4518671c..64a728eaba 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -71,20 +71,230 @@ struct QWceMenuAction { }; #endif +template <typename T> +class QSetValueOnDestroy +{ +public: + QSetValueOnDestroy(T &toSet, T value) + : toSet(toSet) + , value(value) + { } + + ~QSetValueOnDestroy() { toSet = value; } +private: + T &toSet; + T value; +}; + +class QMenuSloppyState +{ + Q_DISABLE_COPY(QMenuSloppyState) +public: + QMenuSloppyState() + : m_menu(Q_NULLPTR) + , m_enabled(false) + , m_uni_directional(false) + , m_select_other_actions(false) + , m_first_mouse(true) + , m_init_guard(false) + , m_uni_dir_discarded_count(0) + , m_uni_dir_fail_at_count(0) + , m_timeout(0) + , m_reset_action(Q_NULLPTR) + , m_origin_action(Q_NULLPTR) + , m_parent(Q_NULLPTR) + { } + + ~QMenuSloppyState() { reset(); } + + void initialize(QMenu *menu) + { + m_menu = menu; + m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, 0, menu); + m_uni_dir_fail_at_count = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu); + m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, 0 , menu); + m_timeout = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout); + m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent); + m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); + reset(); + } + + void reset(); + bool enabled() const { return m_enabled; } + + void setResetAction(QAction *action) { m_reset_action = action; } + + enum MouseEventResult { + EventIsProcessed, + EventShouldBePropogated, + EventDiscardsSloppyState + }; + + void startTimer() + { + if (m_enabled) + m_time.start(m_timeout, m_menu); + } + + void startTimerIfNotRunning() + { + if (!m_time.isActive()) + startTimer(); + } + + void stopTimer() + { + m_time.stop(); + } + + void enter(); + + void childEnter() + { + stopTimer(); + if (m_parent) + m_parent->childEnter(); + } + + void leave() + { + if (m_dont_start_time_on_leave) + return; + if (m_parent) + m_parent->childLeave(); + startTimer(); + } + void childLeave(); + + static float slope(const QPointF &p1, const QPointF &p2) + { + const QPointF slope = p2 - p1; + if (slope.x()== 0) + return 9999; + return slope.y()/slope.x(); + } + + bool checkSlope(qreal oldS, qreal newS, bool wantSteeper) + { + if (wantSteeper) + return oldS <= newS; + return newS <= oldS; + } + + MouseEventResult processMouseEvent(const QPointF &mousePos, QAction *resetAction, QAction *currentAction) + { + if (m_parent) + m_parent->stopTimer(); + + if (!m_enabled) + return EventShouldBePropogated; + + if (!m_time.isActive()) + startTimer(); + + if (!m_sub_menu) { + reset(); + return EventShouldBePropogated; + } + + QSetValueOnDestroy<bool> setFirstMouse(m_first_mouse, false); + QSetValueOnDestroy<QPointF> setPreviousPoint(m_previous_point, mousePos); + + if (resetAction && resetAction->isSeparator()) + m_reset_action = Q_NULLPTR; + else { + m_reset_action = resetAction; + } + + if (m_action_rect.contains(mousePos)) { + startTimer(); + return currentAction == m_menu->menuAction() ? EventIsProcessed : EventShouldBePropogated; + } + + if (m_uni_directional && !m_first_mouse && resetAction != m_origin_action) { + bool left_to_right = m_menu->layoutDirection() == Qt::LeftToRight; + QRect sub_menu_rect = m_sub_menu->geometry(); + QPoint sub_menu_top = + left_to_right? sub_menu_rect.topLeft() : sub_menu_rect.topRight(); + QPoint sub_menu_bottom = + left_to_right? sub_menu_rect.bottomLeft() : sub_menu_rect.bottomRight(); + qreal prev_slope_top = slope(m_previous_point, sub_menu_top); + qreal prev_slope_bottom = slope(m_previous_point, sub_menu_bottom); + + qreal current_slope_top = slope(mousePos, sub_menu_top); + qreal current_slope_bottom = slope(mousePos, sub_menu_bottom); + + bool slopeTop = checkSlope(prev_slope_top, current_slope_top, sub_menu_top.y() < mousePos.y()); + bool slopeBottom = checkSlope(prev_slope_bottom, current_slope_bottom, sub_menu_bottom.y() > mousePos.y()); + bool rightDirection = false; + int mouseDir = m_previous_point.y() - mousePos.y(); + if (mouseDir >= 0) { + rightDirection = rightDirection || slopeTop; + } + if (mouseDir <= 0) { + rightDirection = rightDirection || slopeBottom; + } + + if (m_uni_dir_discarded_count >= m_uni_dir_fail_at_count && !rightDirection) { + m_uni_dir_discarded_count = 0; + return EventDiscardsSloppyState; + } + + if (!rightDirection) + m_uni_dir_discarded_count++; + else + m_uni_dir_discarded_count = 0; + + } + + return m_select_other_actions ? EventShouldBePropogated : EventIsProcessed; + } + + void setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu); + bool hasParentActiveDelayTimer() const; + void timeout(); + int timeForTimeout() const { return m_timeout; } + + bool isTimerId(int timerId) const { return m_time.timerId() == timerId; } + QMenu *subMenu() const { return m_sub_menu; } + +private: + QMenu *m_menu; + bool m_enabled; + bool m_uni_directional; + bool m_select_other_actions; + bool m_first_mouse; + bool m_init_guard; + bool m_discard_state_when_entering_parent; + bool m_dont_start_time_on_leave; + short m_uni_dir_discarded_count; + short m_uni_dir_fail_at_count; + short m_timeout; + QBasicTimer m_time; + QAction *m_reset_action; + QAction *m_origin_action; + QRectF m_action_rect; + QPointF m_previous_point; + QPointer<QMenu> m_sub_menu; + QMenuSloppyState *m_parent; +}; + class QMenuPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenu) public: QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0), collapsibleSeparators(true), toolTipsVisible(false), - activationRecursionGuard(false), hasHadMouse(0), aboutToHide(0), motions(0), + activationRecursionGuard(false), delayedPopupGuard(false), + hasReceievedEnter(false), + hasHadMouse(0), aboutToHide(0), motions(0), currentAction(0), #ifdef QT_KEYPAD_NAVIGATION selectAction(0), cancelAction(0), #endif scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), - hasCheckableItems(0), sloppyDelayTimer(0), sloppyAction(0), doChildEffects(false), platformMenu(0) + hasCheckableItems(0), doChildEffects(false), platformMenu(0) #if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) ,wce_menu(0) @@ -127,6 +337,8 @@ public: int getLastVisibleAction() const; bool activationRecursionGuard; + bool delayedPopupGuard; + bool hasReceievedEnter; //selection static QMenu *mouseDown; @@ -134,12 +346,39 @@ public: uint hasHadMouse : 1; uint aboutToHide : 1; int motions; + int mousePopupDelay; QAction *currentAction; #ifdef QT_KEYPAD_NAVIGATION QAction *selectAction; QAction *cancelAction; #endif - QBasicTimer menuDelayTimer; + struct DelayState { + DelayState() + : parent(0) + , action(0) + { } + void initialize(QMenu *parent) + { + this->parent = parent; + } + + void start(int timeout, QAction *toStartAction) + { + if (timer.isActive() && toStartAction == action) + return; + action = toStartAction; + timer.start(timeout,parent); + } + void stop() + { + action = 0; + timer.stop(); + } + + QMenu *parent; + QBasicTimer timer; + QAction *action; + } delayState; enum SelectionReason { SelectedFromKeyboard, SelectedFromElsewhere @@ -198,10 +437,7 @@ public: mutable bool hasCheckableItems; - //sloppy selection - int sloppyDelayTimer; - mutable QAction *sloppyAction; - QRegion sloppyRegion; + QMenuSloppyState sloppyState; //default action QPointer<QAction> defaultAction; @@ -257,6 +493,7 @@ public: QAction* wceCommands(uint command); #endif QPointer<QWidget> noReplayFor; + static QPointer<QMenu> previousMouseMenu; }; #endif // QT_NO_MENU diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 619cb64636..5f40e4b1d9 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -69,8 +69,8 @@ class QMenuBarExtension : public QToolButton public: explicit QMenuBarExtension(QWidget *parent); - QSize sizeHint() const; - void paintEvent(QPaintEvent *); + QSize sizeHint() const Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; }; QMenuBarExtension::QMenuBarExtension(QWidget *parent) diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 9f67aaa8da..c47da891c8 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -176,7 +176,7 @@ public: void print(QPagedPaintDevice *printer) const; int blockCount() const; - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; public Q_SLOTS: @@ -218,43 +218,43 @@ Q_SIGNALS: void modificationChanged(bool); protected: - virtual bool event(QEvent *e); - virtual void timerEvent(QTimerEvent *e); - virtual void keyPressEvent(QKeyEvent *e); - virtual void keyReleaseEvent(QKeyEvent *e); - virtual void resizeEvent(QResizeEvent *e); - virtual void paintEvent(QPaintEvent *e); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseMoveEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent *e); - virtual bool focusNextPrevChild(bool next); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dragLeaveEvent(QDragLeaveEvent *e); - virtual void dragMoveEvent(QDragMoveEvent *e); - virtual void dropEvent(QDropEvent *e); + virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; + virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; #endif - virtual void focusInEvent(QFocusEvent *e); - virtual void focusOutEvent(QFocusEvent *e); - virtual void showEvent(QShowEvent *); - virtual void changeEvent(QEvent *e); + virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *e); + virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif virtual QMimeData *createMimeDataFromSelection() const; virtual bool canInsertFromMimeData(const QMimeData *source) const; virtual void insertFromMimeData(const QMimeData *source); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent); - virtual void scrollContentsBy(int dx, int dy); + virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; virtual void doSetTextCursor(const QTextCursor &cursor); QTextBlock firstVisibleBlock() const; @@ -287,14 +287,14 @@ public: QPlainTextDocumentLayout(QTextDocument *document); ~QPlainTextDocumentLayout(); - void draw(QPainter *, const PaintContext &); - int hitTest(const QPointF &, Qt::HitTestAccuracy ) const; + void draw(QPainter *, const PaintContext &) Q_DECL_OVERRIDE; + int hitTest(const QPointF &, Qt::HitTestAccuracy ) const Q_DECL_OVERRIDE; - int pageCount() const; - QSizeF documentSize() const; + int pageCount() const Q_DECL_OVERRIDE; + QSizeF documentSize() const Q_DECL_OVERRIDE; - QRectF frameBoundingRect(QTextFrame *) const; - QRectF blockBoundingRect(const QTextBlock &block) const; + QRectF frameBoundingRect(QTextFrame *) const Q_DECL_OVERRIDE; + QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE; void ensureBlockLayout(const QTextBlock &block) const; @@ -304,7 +304,7 @@ public: void requestUpdate(); protected: - void documentChanged(int from, int /*charsRemoved*/, int charsAdded); + void documentChanged(int from, int /*charsRemoved*/, int charsAdded) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 6ab8b90a0d..1e74c7b895 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -72,18 +72,18 @@ public: QPlainTextEditControl(QPlainTextEdit *parent); - QMimeData *createMimeDataFromSelection() const; - bool canInsertFromMimeData(const QMimeData *source) const; - void insertFromMimeData(const QMimeData *source); - int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const; - QRectF blockBoundingRect(const QTextBlock &block) const; + QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE; + bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE; + void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE; + int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const Q_DECL_OVERRIDE; + QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE; inline QRectF cursorRect(const QTextCursor &cursor) const { QRectF r = QWidgetTextControl::cursorRect(cursor); r.setLeft(qMax(r.left(), (qreal) 0.)); return r; } inline QRectF cursorRect() { return cursorRect(textCursor()); } - void ensureCursorVisible() { + void ensureCursorVisible() Q_DECL_OVERRIDE { textEdit->ensureCursorVisible(); emit microFocusChanged(); } @@ -93,7 +93,7 @@ public: int topBlock; QTextBlock firstVisibleBlock() const; - QVariant loadResource(int type, const QUrl &name) { + QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE { return textEdit->loadResource(type, name); } diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 5501247973..751fcda871 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -132,7 +132,7 @@ void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const if (QStyleOptionProgressBarV2 *optionV2 = qstyleoption_cast<QStyleOptionProgressBarV2 *>(option)) { - optionV2->orientation = d->orientation; // ### Qt 5: use State_Horizontal instead + optionV2->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBarV2 optionV2->invertedAppearance = d->invertedAppearance; optionV2->bottomToTop = (d->textDirection == QProgressBar::BottomToTop); } diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h index 2cdcbccdb3..898656f8f4 100644 --- a/src/widgets/widgets/qprogressbar.h +++ b/src/widgets/widgets/qprogressbar.h @@ -77,8 +77,8 @@ public: Qt::Alignment alignment() const; void setAlignment(Qt::Alignment alignment); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; Qt::Orientation orientation() const; @@ -103,8 +103,8 @@ Q_SIGNALS: void valueChanged(int value); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionProgressBar *option) const; private: diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index ebf66f8ef8..5063651658 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -57,8 +57,8 @@ public: QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0); ~QPushButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; bool autoDefault() const; void setAutoDefault(bool); @@ -79,14 +79,14 @@ public Q_SLOTS: #endif protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; #ifdef Q_WS_MAC bool hitButton(const QPoint &pos) const; #endif // Q_WS_MAC - void paintEvent(QPaintEvent *); - void keyPressEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *option) const; QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0); diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h index 0bfb0de4e8..beda0e0d38 100644 --- a/src/widgets/widgets/qradiobutton.h +++ b/src/widgets/widgets/qradiobutton.h @@ -51,14 +51,14 @@ public: explicit QRadioButton(const QString &text, QWidget *parent=0); ~QRadioButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; protected: - bool event(QEvent *e); - bool hitButton(const QPoint &) const; - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + bool hitButton(const QPoint &) const Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *button) const; diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h index 7193f69f59..f46d6a8643 100644 --- a/src/widgets/widgets/qrubberband.h +++ b/src/widgets/widgets/qrubberband.h @@ -67,12 +67,12 @@ public: { resize(s.width(), s.height()); } protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionRubberBand *option) const; private: diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h index 568dbc6e4f..3ec9ca14a3 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -60,9 +60,9 @@ public: bool widgetResizable() const; void setWidgetResizable(bool resizable); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; - bool focusNextPrevChild(bool next); + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; Qt::Alignment alignment() const; void setAlignment(Qt::Alignment); @@ -72,10 +72,10 @@ public: protected: QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = 0); - bool event(QEvent *); - bool eventFilter(QObject *, QEvent *); - void resizeEvent(QResizeEvent *); - void scrollContentsBy(int dx, int dy); + bool event(QEvent *) Q_DECL_OVERRIDE; + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; QSize viewportSizeHint() const Q_DECL_OVERRIDE; diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h index 2b67f04850..992bd511c8 100644 --- a/src/widgets/widgets/qscrollbar.h +++ b/src/widgets/widgets/qscrollbar.h @@ -53,21 +53,21 @@ public: explicit QScrollBar(Qt::Orientation, QWidget *parent=0); ~QScrollBar(); - QSize sizeHint() const; - bool event(QEvent *event); + QSize sizeHint() const Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; protected: #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void hideEvent(QHideEvent*); - void sliderChange(SliderChange change); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent*) Q_DECL_OVERRIDE; + void sliderChange(SliderChange change) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h index 61b397e2bb..7885d0a2b7 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -48,19 +48,19 @@ public: explicit QSizeGrip(QWidget *parent); ~QSizeGrip(); - QSize sizeHint() const; - void setVisible(bool); + QSize sizeHint() const Q_DECL_OVERRIDE; + void setVisible(bool) Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *mouseEvent); - void moveEvent(QMoveEvent *moveEvent); - void showEvent(QShowEvent *showEvent); - void hideEvent(QHideEvent *hideEvent); - bool eventFilter(QObject *, QEvent *); - bool event(QEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE; + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; public: diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h index 6d7bf7eee8..66b23e6fa3 100644 --- a/src/widgets/widgets/qslider.h +++ b/src/widgets/widgets/qslider.h @@ -66,8 +66,8 @@ public: ~QSlider(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setTickPosition(TickPosition position); TickPosition tickPosition() const; @@ -75,13 +75,13 @@ public: void setTickInterval(int ti); int tickInterval() const; - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *ev); - void mousePressEvent(QMouseEvent *ev); - void mouseReleaseEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); + void paintEvent(QPaintEvent *ev) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index e8b22151fa..3fe1218b87 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -58,10 +58,10 @@ class QSpinBoxPrivate : public QAbstractSpinBoxPrivate Q_DECLARE_PUBLIC(QSpinBox) public: QSpinBoxPrivate(); - void emitSignals(EmitPolicy ep, const QVariant &); + void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE; - virtual QVariant valueFromText(const QString &n) const; - virtual QString textFromValue(const QVariant &n) const; + virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE; + virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; @@ -79,10 +79,10 @@ class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate Q_DECLARE_PUBLIC(QDoubleSpinBox) public: QDoubleSpinBoxPrivate(); - void emitSignals(EmitPolicy ep, const QVariant &); + void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE; - virtual QVariant valueFromText(const QString &n) const; - virtual QString textFromValue(const QVariant &n) const; + virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE; + virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; double round(double input) const; diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index bb8b359831..41db23a434 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -66,9 +66,9 @@ Q_SIGNALS: void messageChanged(const QString &message); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; virtual void drawContents(QPainter *painter); - void mousePressEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QSplashScreen) diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index f82c06c3bc..c08682eef2 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -77,8 +77,8 @@ public: bool opaqueResize() const; void refresh(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; QList<int> sizes() const; void setSizes(const QList<int> &list); @@ -104,12 +104,12 @@ Q_SIGNALS: protected: virtual QSplitterHandle *createHandle(); - void childEvent(QChildEvent *); + void childEvent(QChildEvent *) Q_DECL_OVERRIDE; - bool event(QEvent *); - void resizeEvent(QResizeEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; - void changeEvent(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; void moveSplitter(int pos, int index); void setRubberBand(int position); int closestLegalPosition(int, int); @@ -138,15 +138,15 @@ public: bool opaqueResize() const; QSplitter *splitter() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void resizeEvent(QResizeEvent *); - bool event(QEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; void moveSplitter(int p); int closestLegalPosition(int p); diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h index af048bc749..71191ba133 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -73,7 +73,7 @@ Q_SIGNALS: void widgetRemoved(int index); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QStackedWidget) diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index d24680ab2a..56d45b9001 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -73,14 +73,14 @@ Q_SIGNALS: void messageChanged(const QString &text); protected: - void showEvent(QShowEvent *); - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); - bool event(QEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QStatusBar) diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index bdc9dae07c..5cca289020 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -130,8 +130,8 @@ public: int currentIndex() const; int count() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setDrawBase(bool drawTheBase); bool drawBase() const; @@ -183,20 +183,20 @@ protected: virtual void tabRemoved(int index); virtual void tabLayoutChange(); - bool event(QEvent *); - void resizeEvent(QResizeEvent *); - void showEvent(QShowEvent *); - void hideEvent(QHideEvent *); - void paintEvent(QPaintEvent *); - void mousePressEvent (QMouseEvent *); - void mouseMoveEvent (QMouseEvent *); - void mouseReleaseEvent (QMouseEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent (QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent (QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent (QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *); - void changeEvent(QEvent *); - void timerEvent(QTimerEvent *event); + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionTab *option, int tabIndex) const; #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index b26ad20f1a..9393c94c9e 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -119,9 +119,9 @@ public: TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv) { setEasingCurve(QEasingCurve::InOutQuad); } - void updateCurrentValue(const QVariant ¤t); + void updateCurrentValue(const QVariant ¤t) Q_DECL_OVERRIDE; - void updateState(State, State newState); + void updateState(State, State newState) Q_DECL_OVERRIDE; private: //these are needed for the callbacks Tab *tab; @@ -250,12 +250,12 @@ class CloseButton : public QAbstractButton public: CloseButton(QWidget *parent = 0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; inline QSize minimumSizeHint() const { return sizeHint(); } - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - void paintEvent(QPaintEvent *event); + void enterEvent(QEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; }; diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index 5d9adc40e5..dc5c49c99c 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -113,10 +113,10 @@ public: TabShape tabShape() const; void setTabShape(TabShape s); - QSize sizeHint() const; - QSize minimumSizeHint() const; - int heightForWidth(int width) const; - bool hasHeightForWidth() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + int heightForWidth(int width) const Q_DECL_OVERRIDE; + bool hasHeightForWidth() const Q_DECL_OVERRIDE; void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner); QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const; @@ -154,13 +154,13 @@ protected: virtual void tabInserted(int index); virtual void tabRemoved(int index); - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); - void keyPressEvent(QKeyEvent *); - void paintEvent(QPaintEvent *); + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void setTabBar(QTabBar *); - void changeEvent(QEvent *); - bool event(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionTabWidgetFrame *option) const; diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 1ef2f92804..7a02401dd1 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -129,7 +129,7 @@ public: void setSource(const QUrl &url); // re-imlemented from QTextEditPrivate - virtual QUrl resolveUrl(const QUrl &url) const; + virtual QUrl resolveUrl(const QUrl &url) const Q_DECL_OVERRIDE; inline QUrl resolveUrl(const QString &url) const { return resolveUrl(QUrl(url)); } diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h index d08590cb27..de917d0bf3 100644 --- a/src/widgets/widgets/qtextbrowser.h +++ b/src/widgets/widgets/qtextbrowser.h @@ -65,7 +65,7 @@ public: QStringList searchPaths() const; void setSearchPaths(const QStringList &paths); - virtual QVariant loadResource(int type, const QUrl &name); + virtual QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE; bool isBackwardAvailable() const; bool isForwardAvailable() const; @@ -98,14 +98,14 @@ Q_SIGNALS: void anchorClicked(const QUrl &); protected: - bool event(QEvent *e); - virtual void keyPressEvent(QKeyEvent *ev); - virtual void mouseMoveEvent(QMouseEvent *ev); - virtual void mousePressEvent(QMouseEvent *ev); - virtual void mouseReleaseEvent(QMouseEvent *ev); - virtual void focusOutEvent(QFocusEvent *ev); - virtual bool focusNextPrevChild(bool next); - virtual void paintEvent(QPaintEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QTextBrowser) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 7ef864139f..a432a82ec0 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -77,19 +77,19 @@ class QTextEditControl : public QWidgetTextControl public: inline QTextEditControl(QObject *parent) : QWidgetTextControl(parent) {} - virtual QMimeData *createMimeDataFromSelection() const { + virtual QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) return QWidgetTextControl::createMimeDataFromSelection(); return ed->createMimeDataFromSelection(); } - virtual bool canInsertFromMimeData(const QMimeData *source) const { + virtual bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) return QWidgetTextControl::canInsertFromMimeData(source); return ed->canInsertFromMimeData(source); } - virtual void insertFromMimeData(const QMimeData *source) { + virtual void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) QWidgetTextControl::insertFromMimeData(source); diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index dc8deea8b6..4c5af67cca 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -203,7 +203,7 @@ public: void print(QPagedPaintDevice *printer) const; - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; public Q_SLOTS: @@ -257,43 +257,43 @@ Q_SIGNALS: void cursorPositionChanged(); protected: - virtual bool event(QEvent *e); - virtual void timerEvent(QTimerEvent *e); - virtual void keyPressEvent(QKeyEvent *e); - virtual void keyReleaseEvent(QKeyEvent *e); - virtual void resizeEvent(QResizeEvent *e); - virtual void paintEvent(QPaintEvent *e); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseMoveEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent *e); - virtual bool focusNextPrevChild(bool next); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dragLeaveEvent(QDragLeaveEvent *e); - virtual void dragMoveEvent(QDragMoveEvent *e); - virtual void dropEvent(QDropEvent *e); + virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; + virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; #endif - virtual void focusInEvent(QFocusEvent *e); - virtual void focusOutEvent(QFocusEvent *e); - virtual void showEvent(QShowEvent *); - virtual void changeEvent(QEvent *e); + virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *e); + virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif virtual QMimeData *createMimeDataFromSelection() const; virtual bool canInsertFromMimeData(const QMimeData *source) const; virtual void insertFromMimeData(const QMimeData *source); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; QTextEdit(QTextEditPrivate &dd, QWidget *parent); - virtual void scrollContentsBy(int dx, int dy); + virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; virtual void doSetTextCursor(const QTextCursor &cursor); void zoomInF(float range); diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 6bd1411592..68d4215a70 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -135,10 +135,10 @@ Q_SIGNALS: void visibilityChanged(bool visible); protected: - void actionEvent(QActionEvent *event); - void changeEvent(QEvent *event); - void paintEvent(QPaintEvent *event); - bool event(QEvent *event); + void actionEvent(QActionEvent *event) Q_DECL_OVERRIDE; + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionToolBar *option) const; diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h index 07e3301ed7..6625419d87 100644 --- a/src/widgets/widgets/qtoolbarextension_p.h +++ b/src/widgets/widgets/qtoolbarextension_p.h @@ -58,8 +58,8 @@ class Q_AUTOTEST_EXPORT QToolBarExtension : public QToolButton public: explicit QToolBarExtension(QWidget *parent); - void paintEvent(QPaintEvent *); - QSize sizeHint() const; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setOrientation(Qt::Orientation o); diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index 47857d6802..4cedd2b37a 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -61,7 +61,7 @@ class QToolBarItem : public QWidgetItem { public: QToolBarItem(QWidget *widget); - bool isEmpty() const; + bool isEmpty() const Q_DECL_OVERRIDE; QAction *action; bool customWidget; @@ -75,22 +75,22 @@ public: QToolBarLayout(QWidget *parent = 0); ~QToolBarLayout(); - void addItem(QLayoutItem *item); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - bool isEmpty() const; - void invalidate(); - Qt::Orientations expandingDirections() const; + bool isEmpty() const Q_DECL_OVERRIDE; + void invalidate() Q_DECL_OVERRIDE; + Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE; - void setGeometry(const QRect &r); - QSize minimumSize() const; - QSize sizeHint() const; + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; void insertAction(int index, QAction *action); int indexOf(QAction *action) const; - int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); } + int indexOf(QWidget *widget) const Q_DECL_OVERRIDE { return QLayout::indexOf(widget); } bool layoutActions(const QSize &size); QSize expandedSize(const QSize &size) const; diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h index 3ac46db482..b3f862cefa 100644 --- a/src/widgets/widgets/qtoolbarseparator_p.h +++ b/src/widgets/widgets/qtoolbarseparator_p.h @@ -64,9 +64,9 @@ public: Qt::Orientation orientation() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOption *option) const; public Q_SLOTS: diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index 518b975b51..83a158e59e 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -65,12 +65,12 @@ public: inline void setSelected(bool b) { selected = b; update(); } inline void setIndex(int newIndex) { indexInPage = newIndex; } - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; protected: void initStyleOption(QStyleOptionToolBox *opt) const; - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: bool selected; diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h index 1ea276e8ab..40bbce7d44 100644 --- a/src/widgets/widgets/qtoolbox.h +++ b/src/widgets/widgets/qtoolbox.h @@ -89,11 +89,11 @@ Q_SIGNALS: void currentChanged(int index); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; virtual void itemInserted(int index); virtual void itemRemoved(int index); - void showEvent(QShowEvent *e); - void changeEvent(QEvent *); + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 922ea09abd..5301a8b22b 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -66,8 +66,8 @@ public: explicit QToolButton(QWidget * parent=0); ~QToolButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; Qt::ToolButtonStyle toolButtonStyle() const; @@ -98,19 +98,19 @@ Q_SIGNALS: void triggered(QAction *); protected: - bool event(QEvent *e); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void paintEvent(QPaintEvent *); - void actionEvent(QActionEvent *); - - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void timerEvent(QTimerEvent *); - void changeEvent(QEvent *); - - bool hitButton(const QPoint &pos) const; - void nextCheckState(); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void actionEvent(QActionEvent *) Q_DECL_OVERRIDE; + + void enterEvent(QEvent *) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + + bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE; + void nextCheckState() Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionToolButton *option) const; private: diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index f21d88177c..78edefe0f3 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -532,7 +532,7 @@ Q_SIGNALS: void editFocusChange(bool); #endif protected: - virtual void timerEvent(QTimerEvent *event); + virtual void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; private Q_SLOTS: void _q_clipboardChanged(); diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 5b165aa7be..5c9bb50bd4 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -88,7 +88,7 @@ Q_SIGNALS: void activate(); protected: - bool eventFilter(QObject *o, QEvent *e); + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *e); void keyPressEvent(QKeyEvent *e); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 8c48533a03..eabaa160a0 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1312,8 +1312,10 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) else if (e == QKeySequence::Delete) { QTextCursor localCursor = cursor; localCursor.deleteChar(); - } - else if (e == QKeySequence::DeleteEndOfWord) { + } else if (e == QKeySequence::Backspace) { + QTextCursor localCursor = cursor; + localCursor.deletePreviousChar(); + }else if (e == QKeySequence::DeleteEndOfWord) { if (!cursor.hasSelection()) cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); cursor.removeSelectedText(); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 949201e8a8..79f4e404a2 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -242,9 +242,9 @@ public: bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor); protected: - virtual void timerEvent(QTimerEvent *e); + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; - virtual bool event(QEvent *e); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QWidgetTextControl) @@ -280,9 +280,9 @@ class QTextEditMimeData : public QMimeData public: inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {} - virtual QStringList formats() const; + virtual QStringList formats() const Q_DECL_OVERRIDE; protected: - virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const; + virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE; private: void setup() const; |