From 36fcb5cb628f3778cfa53ba958efd155b25f0341 Mon Sep 17 00:00:00 2001 From: tux3 Date: Mon, 8 Jun 2015 20:08:24 +0200 Subject: [PATCH] Add final/override specifiers We get more compile time checking, and it's always good for performance to help the compiler --- src/chatlog/chatlog.h | 18 ++++---- src/chatlog/content/filetransferwidget.h | 2 +- src/chatlog/content/text.h | 32 +++++++-------- src/video/videosurface.h | 8 ++-- src/widget/androidgui.h | 2 +- src/widget/emoticonswidget.h | 6 +-- src/widget/form/chatform.h | 11 +++-- src/widget/form/genericchatform.h | 14 ++++--- src/widget/form/groupchatform.h | 9 ++-- src/widget/form/profileform.h | 3 +- src/widget/form/settings/advancedform.h | 6 +-- src/widget/form/settings/avform.h | 10 ++--- src/widget/form/settings/generalform.h | 4 +- src/widget/form/settings/genericsettings.h | 2 +- src/widget/form/settings/privacyform.h | 6 +-- .../form/settings/verticalonlyscroller.h | 4 +- src/widget/friendwidget.h | 20 ++++----- src/widget/genericchatroomwidget.h | 8 ++-- src/widget/groupwidget.cpp | 15 ------- src/widget/groupwidget.h | 22 +++++----- src/widget/maskablepixmapwidget.h | 6 +-- src/widget/tool/adjustingscrollarea.h | 7 ++-- src/widget/tool/callconfirmwidget.h | 6 +-- src/widget/tool/chattextedit.h | 6 ++- src/widget/tool/croppinglabel.h | 15 ++++--- .../tool/screengrabberchooserrectitem.h | 6 +-- src/widget/tool/screengrabberoverlayitem.h | 7 ++-- src/widget/tool/toolboxgraphicsitem.h | 8 ++-- src/widget/widget.h | 41 ++++++++++--------- 29 files changed, 146 insertions(+), 158 deletions(-) diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index 19b3d86a6..4712afa6b 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -84,15 +84,15 @@ protected: void scrollToBottom(); void startResizeWorker(); - virtual void mouseDoubleClickEvent(QMouseEvent* ev); - virtual void mousePressEvent(QMouseEvent* ev); - virtual void mouseReleaseEvent(QMouseEvent* ev); - virtual void mouseMoveEvent(QMouseEvent* ev); - virtual void scrollContentsBy(int dx, int dy); - virtual void resizeEvent(QResizeEvent* ev); - virtual void showEvent(QShowEvent*); - virtual void focusInEvent(QFocusEvent* ev); - virtual void focusOutEvent(QFocusEvent* ev); + virtual void mouseDoubleClickEvent(QMouseEvent* ev) final override; + virtual void mousePressEvent(QMouseEvent* ev) final override; + virtual void mouseReleaseEvent(QMouseEvent* ev) final override; + virtual void mouseMoveEvent(QMouseEvent* ev) final override; + virtual void scrollContentsBy(int dx, int dy) final override; + virtual void resizeEvent(QResizeEvent* ev) final override; + virtual void showEvent(QShowEvent*) final override; + virtual void focusInEvent(QFocusEvent* ev) final override; + virtual void focusOutEvent(QFocusEvent* ev) final override; void updateMultiSelectionRect(); void updateTypingNotification(); diff --git a/src/chatlog/content/filetransferwidget.h b/src/chatlog/content/filetransferwidget.h index c065afd9e..a21f9b429 100644 --- a/src/chatlog/content/filetransferwidget.h +++ b/src/chatlog/content/filetransferwidget.h @@ -65,7 +65,7 @@ protected: bool drawButtonAreaNeeded() const; - virtual void paintEvent(QPaintEvent*); + virtual void paintEvent(QPaintEvent*) final override; private slots: void on_topButton_clicked(); diff --git a/src/chatlog/content/text.h b/src/chatlog/content/text.h index 451fa84f7..f994c21e0 100644 --- a/src/chatlog/content/text.h +++ b/src/chatlog/content/text.h @@ -36,27 +36,27 @@ public: void setText(const QString& txt); - virtual void setWidth(qreal width) override; + virtual void setWidth(qreal width) final; - virtual void selectionMouseMove(QPointF scenePos) override; - virtual void selectionStarted(QPointF scenePos) override; - virtual void selectionCleared() override; - virtual void selectionDoubleClick(QPointF scenePos) override; - virtual void selectionFocusChanged(bool focusIn) override; - virtual bool isOverSelection(QPointF scenePos) const override; - virtual QString getSelectedText() const override; + virtual void selectionMouseMove(QPointF scenePos) final; + virtual void selectionStarted(QPointF scenePos) final; + virtual void selectionCleared() final; + virtual void selectionDoubleClick(QPointF scenePos) final; + virtual void selectionFocusChanged(bool focusIn) final; + virtual bool isOverSelection(QPointF scenePos) const final; + virtual QString getSelectedText() const final; - virtual QRectF boundingRect() const override; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + virtual QRectF boundingRect() const final; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) final; - virtual void visibilityChanged(bool keepInMemory) override; + virtual void visibilityChanged(bool keepInMemory) final; - virtual qreal getAscent() const override; - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override; + virtual qreal getAscent() const final; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) final override; + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) final override; + virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) final override; - virtual QString getText() const override; + virtual QString getText() const final; protected: // dynamic resource management diff --git a/src/video/videosurface.h b/src/video/videosurface.h index cbe288d80..2b8fe17e7 100644 --- a/src/video/videosurface.h +++ b/src/video/videosurface.h @@ -6,14 +6,14 @@ qTox is libre software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + (at your option) any later version. qTox is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU General Public License along with qTox. If not, see . */ @@ -40,7 +40,7 @@ protected: void subscribe(); void unsubscribe(); - virtual void paintEvent(QPaintEvent * event) override; + virtual void paintEvent(QPaintEvent * event) final override; private slots: void onNewFrameAvailable(std::shared_ptr newFrame); diff --git a/src/widget/androidgui.h b/src/widget/androidgui.h index 20efd04a7..526697a2c 100644 --- a/src/widget/androidgui.h +++ b/src/widget/androidgui.h @@ -57,7 +57,7 @@ signals: private: void reloadTheme(); - virtual void keyPressEvent(QKeyEvent* event) final; + virtual void keyPressEvent(QKeyEvent* event) final override; private slots: void onUsernameChanged(const QString& newUsername, const QString& oldUsername); diff --git a/src/widget/emoticonswidget.h b/src/widget/emoticonswidget.h index 476e1d069..c12df6fa5 100644 --- a/src/widget/emoticonswidget.h +++ b/src/widget/emoticonswidget.h @@ -39,9 +39,9 @@ private slots: void PageButtonsUpdate(); protected: - virtual void mouseReleaseEvent(QMouseEvent *ev); - virtual void mousePressEvent(QMouseEvent *ev); - virtual void wheelEvent(QWheelEvent * event) override; + virtual void mouseReleaseEvent(QMouseEvent *ev) final override; + virtual void mousePressEvent(QMouseEvent *ev) final override; + virtual void wheelEvent(QWheelEvent * event) final override; private: QStackedWidget stack; diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index 6a17578ad..2aaf72f04 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -50,7 +50,7 @@ public: void setFriendTyping(bool isTyping); OfflineMsgEngine* getOfflineMsgEngine(); - virtual void show(Ui::MainWindow &ui); + virtual void show(Ui::MainWindow &ui) final override; signals: void sendFile(uint32_t friendId, QString, QString, long long); @@ -108,11 +108,10 @@ protected: void showNetcam(); void hideNetcam(); // drag & drop - void dragEnterEvent(QDragEnterEvent* ev); - void dropEvent(QDropEvent* ev); - void registerReceipt(int receipt, int messageID, ChatMessage::Ptr msg); - virtual void hideEvent(QHideEvent* event); - virtual void showEvent(QShowEvent* event); + virtual void dragEnterEvent(QDragEnterEvent* ev) final override; + virtual void dropEvent(QDropEvent* ev) final override; + virtual void hideEvent(QHideEvent* event) final override; + virtual void showEvent(QShowEvent* event) final override; private: Friend* f; diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 015d83c0b..739fe3acd 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -52,7 +52,8 @@ public: GenericChatForm(QWidget *parent = 0); ~GenericChatForm(); - virtual void setName(const QString &newName); + void setName(const QString &newName); + virtual void show() final = delete; virtual void show(Ui::MainWindow &ui); ChatMessage::Ptr addMessage(const ToxId& author, const QString &message, bool isAction, const QDateTime &datetime, bool isSent); @@ -64,7 +65,6 @@ public: ChatLog* getChatLog() const; - bool eventFilter(QObject* object, QEvent* event); signals: void sendMessage(uint32_t, QString); void sendAction(uint32_t, QString); @@ -91,12 +91,14 @@ private: protected: QString resolveToxId(const ToxId &id); void insertChatMessage(ChatMessage::Ptr msg); - void hideEvent(QHideEvent* event); - void showEvent(QShowEvent *); - bool event(QEvent *); - void resizeEvent(QResizeEvent* event); void adjustFileMenuPosition(); + virtual void hideEvent(QHideEvent* event) override; + virtual void showEvent(QShowEvent *) override; + virtual bool event(QEvent *) final override; + virtual void resizeEvent(QResizeEvent* event) final override; + virtual bool eventFilter(QObject* object, QEvent* event) final override; +protected: QAction* saveChatAction, *clearAction; ToxId previousId; QDateTime prevMsgDateTime; diff --git a/src/widget/form/groupchatform.h b/src/widget/form/groupchatform.h index b4d014f65..f9ce608c9 100644 --- a/src/widget/form/groupchatform.h +++ b/src/widget/form/groupchatform.h @@ -39,9 +39,6 @@ public: void onUserListChanged(); void peerAudioPlaying(int peer); - void keyPressEvent(QKeyEvent* ev); - void keyReleaseEvent(QKeyEvent* ev); - signals: void groupTitleChanged(int groupnum, const QString& name); @@ -52,9 +49,11 @@ private slots: void onCallClicked(); protected: + virtual void keyPressEvent(QKeyEvent* ev) final override; + virtual void keyReleaseEvent(QKeyEvent* ev) final override; // drag & drop - void dragEnterEvent(QDragEnterEvent* ev); - void dropEvent(QDropEvent* ev); + virtual void dragEnterEvent(QDragEnterEvent* ev) final override; + virtual void dropEvent(QDropEvent* ev) final override; private: void retranslateUi(); diff --git a/src/widget/form/profileform.h b/src/widget/form/profileform.h index e4f604598..e79aeaf40 100644 --- a/src/widget/form/profileform.h +++ b/src/widget/form/profileform.h @@ -44,7 +44,7 @@ public: signals: void clicked(); protected: - void mouseReleaseEvent(QMouseEvent*) {emit clicked();} + virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();} }; class ProfileForm : public QWidget @@ -53,6 +53,7 @@ class ProfileForm : public QWidget public: ProfileForm(QWidget *parent = nullptr); ~ProfileForm(); + virtual void show() final = delete; void show(Ui::MainWindow &ui); signals: diff --git a/src/widget/form/settings/advancedform.h b/src/widget/form/settings/advancedform.h index 0c6a16500..a8f3c787e 100644 --- a/src/widget/form/settings/advancedform.h +++ b/src/widget/form/settings/advancedform.h @@ -28,13 +28,13 @@ namespace Ui { class AdvancedSettings; } -class AdvancedForm : public GenericForm +class AdvancedForm final : public GenericForm { Q_OBJECT public: AdvancedForm(); - virtual ~AdvancedForm(); - QString getFormName() final {return tr("Advanced");} + ~AdvancedForm(); + virtual QString getFormName() final override {return tr("Advanced");} protected: bool eventFilter(QObject *o, QEvent *e); diff --git a/src/widget/form/settings/avform.h b/src/widget/form/settings/avform.h index 64470c603..d6c8ae7c1 100644 --- a/src/widget/form/settings/avform.h +++ b/src/widget/form/settings/avform.h @@ -33,13 +33,13 @@ class AVSettings; class CameraSource; class VideoSurface; -class AVForm : public GenericForm +class AVForm final : public GenericForm { Q_OBJECT public: AVForm(); ~AVForm(); - QString getFormName() final {return tr("Audio/Video");} + virtual QString getFormName() final override {return tr("Audio/Video");} private: void getAudioInDevices(); @@ -65,11 +65,11 @@ private slots: void onVideoDevChanged(int index); void onResProbingFinished(QList res); - virtual void hideEvent(QHideEvent*); - virtual void showEvent(QShowEvent*); + virtual void hideEvent(QHideEvent*) final override; + virtual void showEvent(QShowEvent*) final override; protected: - bool eventFilter(QObject *o, QEvent *e); + virtual bool eventFilter(QObject *o, QEvent *e) final override; void updateVideoModes(int curIndex); private: diff --git a/src/widget/form/settings/generalform.h b/src/widget/form/settings/generalform.h index aa2dca802..de5381633 100644 --- a/src/widget/form/settings/generalform.h +++ b/src/widget/form/settings/generalform.h @@ -28,13 +28,13 @@ class GeneralSettings; class SettingsWidget; -class GeneralForm : public GenericForm +class GeneralForm final : public GenericForm { Q_OBJECT public: GeneralForm(SettingsWidget *parent); ~GeneralForm(); - QString getFormName() final {return tr("General");} + virtual QString getFormName() final override {return tr("General");} private slots: void onEnableIPv6Updated(); diff --git a/src/widget/form/settings/genericsettings.h b/src/widget/form/settings/genericsettings.h index 9ccd32c86..af8c9575b 100644 --- a/src/widget/form/settings/genericsettings.h +++ b/src/widget/form/settings/genericsettings.h @@ -25,7 +25,7 @@ class GenericForm : public QWidget Q_OBJECT public: GenericForm(const QPixmap &icon) : formIcon(icon) {;} - ~GenericForm() {;} + ~GenericForm() {} virtual QString getFormName() = 0; QPixmap getFormIcon() {return formIcon;} diff --git a/src/widget/form/settings/privacyform.h b/src/widget/form/settings/privacyform.h index 5e83a7aa6..aa1c266bc 100644 --- a/src/widget/form/settings/privacyform.h +++ b/src/widget/form/settings/privacyform.h @@ -26,13 +26,13 @@ namespace Ui { class PrivacySettings; } -class PrivacyForm : public GenericForm +class PrivacyForm final : public GenericForm { Q_OBJECT public: PrivacyForm(); ~PrivacyForm(); - QString getFormName() final {return tr("Privacy");} + virtual QString getFormName() final override {return tr("Privacy");} private slots: void onEnableLoggingUpdated(); @@ -40,7 +40,7 @@ private slots: void setNospam(); void generateRandomNospam(); void onNospamEdit(); - virtual void showEvent(QShowEvent*); + virtual void showEvent(QShowEvent*) final override; private: void retranslateUi(); diff --git a/src/widget/form/settings/verticalonlyscroller.h b/src/widget/form/settings/verticalonlyscroller.h index 44f2626d5..ae0f14758 100644 --- a/src/widget/form/settings/verticalonlyscroller.h +++ b/src/widget/form/settings/verticalonlyscroller.h @@ -32,8 +32,8 @@ public: explicit VerticalOnlyScroller(QWidget *parent = 0); protected: - void resizeEvent(QResizeEvent *event); - void showEvent(QShowEvent *event); + virtual void resizeEvent(QResizeEvent *event) final override; + virtual void showEvent(QShowEvent *event) final override; }; #endif // VERTICALONLYSCROLLER_H diff --git a/src/widget/friendwidget.h b/src/widget/friendwidget.h index 6f39d6f3e..381c25f97 100644 --- a/src/widget/friendwidget.h +++ b/src/widget/friendwidget.h @@ -25,18 +25,18 @@ class QPixmap; class MaskablePixmapWidget; -struct FriendWidget : public GenericChatroomWidget +struct FriendWidget final : public GenericChatroomWidget { Q_OBJECT public: FriendWidget(int FriendId, QString id); - void contextMenuEvent(QContextMenuEvent * event); - void setAsActiveChatroom(); - void setAsInactiveChatroom(); - void updateStatusLight(); - void setChatForm(Ui::MainWindow &); - void resetEventFlags(); - QString getStatusString(); + virtual void contextMenuEvent(QContextMenuEvent * event) override; + virtual void setAsActiveChatroom() override; + virtual void setAsInactiveChatroom() override; + virtual void updateStatusLight() override; + virtual void setChatForm(Ui::MainWindow &) override; + virtual void resetEventFlags() override; + virtual QString getStatusString() override; signals: void friendWidgetClicked(FriendWidget* widget); @@ -49,8 +49,8 @@ public slots: void setAlias(const QString& alias); protected: - void mousePressEvent(QMouseEvent* ev); - void mouseMoveEvent(QMouseEvent* ev); + virtual void mousePressEvent(QMouseEvent* ev) final override; + virtual void mouseMoveEvent(QMouseEvent* ev) final override; void setFriendAlias(); public: diff --git a/src/widget/genericchatroomwidget.h b/src/widget/genericchatroomwidget.h index 83ca617b7..89a3d975a 100644 --- a/src/widget/genericchatroomwidget.h +++ b/src/widget/genericchatroomwidget.h @@ -65,10 +65,10 @@ signals: void chatroomWidgetClicked(GenericChatroomWidget* widget); protected: - virtual void mousePressEvent(QMouseEvent* event); - virtual void mouseReleaseEvent (QMouseEvent* event); - virtual void enterEvent(QEvent* e); - virtual void leaveEvent(QEvent* e); + virtual void mousePressEvent(QMouseEvent* event) override; + virtual void mouseReleaseEvent (QMouseEvent* event) override; + virtual void enterEvent(QEvent* e) override; + virtual void leaveEvent(QEvent* e) override; protected: QColor lastColor; diff --git a/src/widget/groupwidget.cpp b/src/widget/groupwidget.cpp index 2f0991d99..8d46e84d5 100644 --- a/src/widget/groupwidget.cpp +++ b/src/widget/groupwidget.cpp @@ -162,21 +162,6 @@ void GroupWidget::dropEvent(QDropEvent *ev) } } -void GroupWidget::keyPressEvent(QKeyEvent* ev) -{ - Group* g = GroupList::findGroup(groupId); - if (g) - g->getChatForm()->keyPressEvent(ev); - -} - -void GroupWidget::keyReleaseEvent(QKeyEvent* ev) -{ - Group* g = GroupList::findGroup(groupId); - if (g) - g->getChatForm()->keyReleaseEvent(ev); -} - void GroupWidget::setName(const QString& name) { nameLabel->setText(name); diff --git a/src/widget/groupwidget.h b/src/widget/groupwidget.h index 3bf112305..73bb9287a 100644 --- a/src/widget/groupwidget.h +++ b/src/widget/groupwidget.h @@ -28,15 +28,15 @@ class GroupWidget : public GenericChatroomWidget Q_OBJECT public: GroupWidget(int GroupId, QString Name); - void onUserListChanged(); - void contextMenuEvent(QContextMenuEvent * event); - void setAsInactiveChatroom(); - void setAsActiveChatroom(); - void updateStatusLight(); - void setChatForm(Ui::MainWindow &); - void resetEventFlags(); + virtual void contextMenuEvent(QContextMenuEvent * event) final override; + virtual void setAsInactiveChatroom() final override; + virtual void setAsActiveChatroom() final override; + virtual void updateStatusLight() final override; + virtual void setChatForm(Ui::MainWindow &) final override; + virtual void resetEventFlags() final override; + virtual QString getStatusString() final override; void setName(const QString& name); - QString getStatusString(); + void onUserListChanged(); signals: void groupWidgetClicked(GroupWidget* widget); @@ -44,10 +44,8 @@ signals: protected: // drag & drop - void dragEnterEvent(QDragEnterEvent* ev); - void dropEvent(QDropEvent* ev); - void keyPressEvent(QKeyEvent* ev); - void keyReleaseEvent(QKeyEvent* ev); + virtual void dragEnterEvent(QDragEnterEvent* ev) final override; + virtual void dropEvent(QDropEvent* ev) final override; public: int groupId; diff --git a/src/widget/maskablepixmapwidget.h b/src/widget/maskablepixmapwidget.h index b583c85e2..590d8f976 100644 --- a/src/widget/maskablepixmapwidget.h +++ b/src/widget/maskablepixmapwidget.h @@ -22,7 +22,7 @@ #include -class MaskablePixmapWidget : public QWidget +class MaskablePixmapWidget final : public QWidget { Q_OBJECT public: @@ -39,8 +39,8 @@ signals: void clicked(); protected: - virtual void paintEvent(QPaintEvent *); - virtual void mousePressEvent(QMouseEvent *); + virtual void paintEvent(QPaintEvent *) final override; + virtual void mousePressEvent(QMouseEvent *) final override; private: QPixmap pixmap, mask, unscaled; // a lot of memory... diff --git a/src/widget/tool/adjustingscrollarea.h b/src/widget/tool/adjustingscrollarea.h index 3bc48bc9a..d3ef529b3 100644 --- a/src/widget/tool/adjustingscrollarea.h +++ b/src/widget/tool/adjustingscrollarea.h @@ -22,14 +22,15 @@ #include -class AdjustingScrollArea : public QScrollArea +class AdjustingScrollArea final : public QScrollArea { Q_OBJECT public: explicit AdjustingScrollArea(QWidget *parent = 0); - virtual void resizeEvent(QResizeEvent *ev) override; - virtual QSize sizeHint() const override; +protected: + virtual void resizeEvent(QResizeEvent *ev) final override; + virtual QSize sizeHint() const final override; }; #endif // ADJUSTINGSCROLLAREA_H diff --git a/src/widget/tool/callconfirmwidget.h b/src/widget/tool/callconfirmwidget.h index b443ce401..9b77febba 100644 --- a/src/widget/tool/callconfirmwidget.h +++ b/src/widget/tool/callconfirmwidget.h @@ -32,7 +32,7 @@ class QShowEvent; /// This is a widget with dialog buttons to accept/reject a call /// It tracks the position of another widget called the anchor /// and looks like a bubble at the bottom of that widget. -class CallConfirmWidget : public QWidget +class CallConfirmWidget final : public QWidget { Q_OBJECT public: @@ -43,8 +43,8 @@ signals: void rejected(); protected: - virtual void paintEvent(QPaintEvent* event) override; - virtual void showEvent(QShowEvent * event) override; + virtual void paintEvent(QPaintEvent* event) final override; + virtual void showEvent(QShowEvent * event) final override; protected slots: void reposition(); ///< Recalculate our positions to track the anchor diff --git a/src/widget/tool/chattextedit.h b/src/widget/tool/chattextedit.h index 6728ec716..54d28a490 100644 --- a/src/widget/tool/chattextedit.h +++ b/src/widget/tool/chattextedit.h @@ -22,13 +22,12 @@ #include -class ChatTextEdit : public QTextEdit +class ChatTextEdit final : public QTextEdit { Q_OBJECT public: explicit ChatTextEdit(QWidget *parent = 0); ~ChatTextEdit(); - virtual void keyPressEvent(QKeyEvent * event) override; void setLastMessage(QString lm); signals: @@ -36,6 +35,9 @@ signals: void tabPressed(); void keyPressed(); +protected: + virtual void keyPressEvent(QKeyEvent * event) final override; + private: void retranslateUi(); diff --git a/src/widget/tool/croppinglabel.h b/src/widget/tool/croppinglabel.h index 6c34360de..0de74d9d0 100644 --- a/src/widget/tool/croppinglabel.h +++ b/src/widget/tool/croppinglabel.h @@ -24,7 +24,7 @@ class QLineEdit; -class CroppingLabel : public QLabel +class CroppingLabel final : public QLabel { Q_OBJECT public: @@ -33,13 +33,7 @@ public: void setEditable(bool editable); void setEdlideMode(Qt::TextElideMode elide); - virtual void setText(const QString& text); - virtual void resizeEvent(QResizeEvent *ev); - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual bool eventFilter(QObject *obj, QEvent *e); - + void setText(const QString& text); QString fullText(); ///< Returns the un-cropped text signals: @@ -50,6 +44,11 @@ protected: void setElidedText(); void hideTextEdit(bool acceptText); void showTextEdit(); + virtual void resizeEvent(QResizeEvent *ev) final override; + virtual QSize sizeHint() const final override; + virtual QSize minimumSizeHint() const final override; + virtual void mouseReleaseEvent(QMouseEvent *e) final override; + virtual bool eventFilter(QObject *obj, QEvent *e) final override; private: QString origText; diff --git a/src/widget/tool/screengrabberchooserrectitem.h b/src/widget/tool/screengrabberchooserrectitem.h index fee4c86fd..8fc56717a 100644 --- a/src/widget/tool/screengrabberchooserrectitem.h +++ b/src/widget/tool/screengrabberchooserrectitem.h @@ -22,14 +22,14 @@ #include -class ScreenGrabberChooserRectItem : public QObject, public QGraphicsItemGroup +class ScreenGrabberChooserRectItem final : public QObject, public QGraphicsItemGroup { Q_OBJECT public: ScreenGrabberChooserRectItem(QGraphicsScene* scene); ~ScreenGrabberChooserRectItem(); - QRectF boundingRect() const; + virtual QRectF boundingRect() const final override; void beginResize(QPointF mousePos); QRect chosenRect() const; @@ -43,7 +43,7 @@ signals: void regionChosen(QRect rect); protected: - bool sceneEventFilter(QGraphicsItem* watched, QEvent* event); + virtual bool sceneEventFilter(QGraphicsItem* watched, QEvent* event) final override; private: diff --git a/src/widget/tool/screengrabberoverlayitem.h b/src/widget/tool/screengrabberoverlayitem.h index 4e7dae84c..c9e2e7716 100644 --- a/src/widget/tool/screengrabberoverlayitem.h +++ b/src/widget/tool/screengrabberoverlayitem.h @@ -24,7 +24,7 @@ class ScreenshotGrabber; -class ScreenGrabberOverlayItem : public QObject, public QGraphicsRectItem +class ScreenGrabberOverlayItem final : public QObject, public QGraphicsRectItem { Q_OBJECT public: @@ -33,10 +33,9 @@ public: void setChosenRect(QRect rect); - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); - protected: - void mousePressEvent(QGraphicsSceneMouseEvent* event); + virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) final override; + virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) final override; private: ScreenshotGrabber* screnshootGrabber; diff --git a/src/widget/tool/toolboxgraphicsitem.h b/src/widget/tool/toolboxgraphicsitem.h index 1dd78f818..7c7776855 100644 --- a/src/widget/tool/toolboxgraphicsitem.h +++ b/src/widget/tool/toolboxgraphicsitem.h @@ -24,7 +24,7 @@ #include #include -class ToolBoxGraphicsItem : public QObject, public QGraphicsItemGroup +class ToolBoxGraphicsItem final : public QObject, public QGraphicsItemGroup { Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) @@ -32,11 +32,11 @@ public: ToolBoxGraphicsItem(); ~ToolBoxGraphicsItem(); - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); + virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) final override; protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent* event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event) final override; + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) final override; private: diff --git a/src/widget/widget.h b/src/widget/widget.h index 9c93baa20..c85f06f8b 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -48,23 +48,12 @@ class ProfileForm; class SettingsWidget; class AddFriendForm; -class Widget : public QMainWindow +class Widget final : public QMainWindow { Q_OBJECT - -protected: - bool eventFilter(QObject *obj, QEvent *event); - public: - enum FilterCriteria - { - All=0, - Online, - Offline, - Friends, - Groups - }; explicit Widget(QWidget *parent = 0); + ~Widget(); void init(); void setCentralWidget(QWidget *widget, const QString &widgetName); QString getUsername(); @@ -75,11 +64,6 @@ public: bool getIsWindowMinimized(); void updateIcons(); void clearContactsList(); - ~Widget(); - - virtual void closeEvent(QCloseEvent *event); - virtual void changeEvent(QEvent *event); - virtual void resizeEvent(QResizeEvent *event); static void confirmExecutableOpen(const QFileInfo file); @@ -135,6 +119,13 @@ signals: void statusMessageChanged(const QString& statusMessage); void resized(); +protected: + virtual bool eventFilter(QObject *obj, QEvent *event) final override; + virtual bool event(QEvent * e) final override; + virtual void closeEvent(QCloseEvent *event) final override; + virtual void changeEvent(QEvent *event) final override; + virtual void resizeEvent(QResizeEvent *event) final override; + private slots: void onAddClicked(); void onGroupClicked(); @@ -168,9 +159,19 @@ private: SettingButton, None, }; + + enum FilterCriteria + { + All=0, + Online, + Offline, + Friends, + Groups + }; + +private: void setActiveToolMenuButton(ActiveToolMenuButton newActiveButton); void hideMainForms(); - virtual bool event(QEvent * e); Group *createGroup(int groupId); void removeFriend(Friend* f, bool fake = false); void removeGroup(Group* g, bool fake = false); @@ -178,6 +179,8 @@ private: void saveSplitterGeometry(); void cycleContacts(int offset); void retranslateUi(); + +private: SystemTrayIcon *icon; QMenu *trayMenu; QAction *statusOnline,