From 5eb7349b571f4402ab412b43412828b5ef5e9ce3 Mon Sep 17 00:00:00 2001 From: confuseh Date: Wed, 18 Jan 2017 13:48:42 +0000 Subject: [PATCH] getting rid of tons of warnings --- chatterino.pro | 3 ++- chatwidgetheader.cpp | 11 +++++++---- chatwidgetheader.h | 3 ++- chatwidgetview.cpp | 3 ++- message.cpp | 4 ++-- notebookpage.cpp | 2 +- notebookpage.h | 6 +++--- scrollbar.h | 30 +++++++++++++++--------------- settingsdialogtab.h | 8 ++++---- signallabel.h | 23 +++++++++++++++++++++++ word.h | 40 ++++++++++++++++++++-------------------- wordpart.cpp | 4 ++-- wordpart.h | 30 +++++++++++++++--------------- 13 files changed, 98 insertions(+), 69 deletions(-) create mode 100644 signallabel.h diff --git a/chatterino.pro b/chatterino.pro index 846cc0a44..541644554 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -112,7 +112,8 @@ HEADERS += mainwindow.h \ chatwidgetheaderbutton.h \ chatwidgetheaderbuttonlabel.h \ channels.h \ - textinputdialog.h + textinputdialog.h \ + signallabel.h PRECOMPILED_HEADER = diff --git a/chatwidgetheader.cpp b/chatwidgetheader.cpp index 53975d296..de24152e4 100644 --- a/chatwidgetheader.cpp +++ b/chatwidgetheader.cpp @@ -60,10 +60,13 @@ ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent) // middle this->middleLabel.setAlignment(Qt::AlignCenter); - QObject::connect(&this->middleLabel, - SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this, - SLOT(mouseDoubleClickEvent)); - + /*QObject::connect(&this->middleLabel, + * SIGNAL(mouseDoubleClickEvent(QMouseEvent)), this, + * SLOT(mouseDoubleClickEvent)); + * mouseDoubleClickEvent is not a signal, its an event handler + */ + connect(&this->middleLabel, &SignalLabel::mouseDoubleClick, this, &ChatWidgetHeader::mouseDoubleClickEvent); + // right this->rightLabel.setMinimumWidth(height()); this->rightLabel.getLabel().setTextFormat(Qt::RichText); diff --git a/chatwidgetheader.h b/chatwidgetheader.h index d2181b526..2e7cd600a 100644 --- a/chatwidgetheader.h +++ b/chatwidgetheader.h @@ -2,6 +2,7 @@ #define CHATWIDGETHEADER_H #include "chatwidgetheaderbutton.h" +#include "signallabel.h" #include #include @@ -45,7 +46,7 @@ private: QHBoxLayout hbox; ChatWidgetHeaderButton leftLabel; - QLabel middleLabel; + SignalLabel middleLabel; ChatWidgetHeaderButton rightLabel; QMenu leftMenu; diff --git a/chatwidgetview.cpp b/chatwidgetview.cpp index 9fac5e945..657d20ebc 100644 --- a/chatwidgetview.cpp +++ b/chatwidgetview.cpp @@ -6,6 +6,7 @@ #include "word.h" #include "wordpart.h" +#include #include #include #include @@ -105,7 +106,7 @@ ChatWidgetView::paintEvent(QPaintEvent *) } int y = -(messages[start].get()->getHeight() * - (std::fmod(this->scrollbar.getValue(), 1))); + (fmod(this->scrollbar.getValue(), 1))); for (int i = start; i < messages.size(); ++i) { Message *message = messages[i].get(); diff --git a/message.cpp b/message.cpp index 22bb8f771..654aeddb3 100644 --- a/message.cpp +++ b/message.cpp @@ -464,7 +464,7 @@ Message::layout(int width, bool enableEmoteMargins) bool first = true; auto alignParts = [&lineStart, &lineHeight, &parts, this] { - for (int i = lineStart; i < parts->size(); i++) { + for (size_t i = lineStart; i < parts->size(); i++) { WordPart &wordPart2 = parts->at(i); wordPart2.setY(wordPart2.getY() + lineHeight); @@ -510,7 +510,7 @@ Message::layout(int width, bool enableEmoteMargins) charWidths.reserve(text.length()); for (int i = 0; i < text.length(); i++) { - charWidths.push_back(metrics.charWidth(text, i)); + charWidths.push_back(metrics.width(text, i)); } } diff --git a/notebookpage.cpp b/notebookpage.cpp index 6e6762277..52f0b6cf2 100644 --- a/notebookpage.cpp +++ b/notebookpage.cpp @@ -16,8 +16,8 @@ std::pair NotebookPage::dropPosition = std::pair(-1, -1); NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab) : QWidget(parent) , parentbox(this) - , preview(this) , chatWidgets() + , preview(this) { this->tab = tab; tab->page = this; diff --git a/notebookpage.h b/notebookpage.h index 68da3c914..61ae564a3 100644 --- a/notebookpage.h +++ b/notebookpage.h @@ -37,9 +37,9 @@ public: protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void mouseReleaseEvent(QMouseEvent *event); + void enterEvent(QEvent *) override; + void leaveEvent(QEvent *) override; + void mouseReleaseEvent(QMouseEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; diff --git a/scrollbar.h b/scrollbar.h index 3a9a88031..7071370a7 100644 --- a/scrollbar.h +++ b/scrollbar.h @@ -21,71 +21,71 @@ public: void setMaximum(qreal value) { - maximum = value; + this->maximum = value; - updateScroll(); + this->updateScroll(); } void setMinimum(qreal value) { - minimum = value; + this->minimum = value; - updateScroll(); + this->updateScroll(); } void setLargeChange(qreal value) { - largeChange = value; + this->largeChange = value; - updateScroll(); + this->updateScroll(); } void setSmallChange(qreal value) { - smallChange = value; + this->smallChange = value; - updateScroll(); + this->updateScroll(); } void setValue(qreal value) { - value = value; + this->value = value; - updateScroll(); + this->updateScroll(); } qreal getMaximum() const { - return maximum; + return this->maximum; } qreal getMinimum() const { - return minimum; + return this->minimum; } qreal getLargeChange() const { - return largeChange; + return this->largeChange; } qreal getSmallChange() const { - return smallChange; + return this->smallChange; } qreal getValue() const { - return value; + return this->value; } private: diff --git a/settingsdialogtab.h b/settingsdialogtab.h index 2ee589990..3e6f46bf5 100644 --- a/settingsdialogtab.h +++ b/settingsdialogtab.h @@ -18,23 +18,23 @@ public: void setSelected(bool selected) { - if (selected == selected) + if (this->selected == selected) return; - selected = selected; + this->selected = selected; emit selectedChanged(selected); } bool getSelected() const { - return selected; + return this->selected; } QWidget * getWidget() { - return widget; + return this->widget; } void diff --git a/signallabel.h b/signallabel.h new file mode 100644 index 000000000..5c8d43421 --- /dev/null +++ b/signallabel.h @@ -0,0 +1,23 @@ +#ifndef SIGNALLABEL_H +#define SIGNALLABEL_H + +#include +#include +#include + +class SignalLabel : public QLabel +{ + Q_OBJECT +public: + explicit SignalLabel(QWidget *parent = 0, Qt::WindowFlags f = 0) + : QLabel(parent, f) {} + virtual ~SignalLabel() = default; +signals: + void mouseDoubleClick(QMouseEvent *ev); +protected: + virtual void mouseDoubleClickEvent(QMouseEvent *ev) override { + emit this->mouseDoubleClick(ev); + } +}; + +#endif // SIGNALLABEL_H diff --git a/word.h b/word.h index 570aaa86d..eeab9b766 100644 --- a/word.h +++ b/word.h @@ -77,111 +77,111 @@ public: const QString & getText() const { - return text; + return this->text; } int getWidth() const { - return width; + return this->width; } int getHeight() const { - return height; + return this->height; } void setSize(int width, int height) { - width = width; - height = height; + this->width = width; + this->height = height; } bool isImage() const { - return _isImage; + return this->_isImage; } bool isText() const { - return !_isImage; + return !this->_isImage; } const QString & getCopyText() const { - return copyText; + return this->copyText; } bool hasTrailingSpace() const { - return _hasTrailingSpace; + return this->_hasTrailingSpace; } QFont & getFont() const { - return Fonts::getFont(font); + return Fonts::getFont(this->font); } QFontMetrics & getFontMetrics() const { - return Fonts::getFontMetrics(font); + return Fonts::getFontMetrics(this->font); } Type getType() const { - return type; + return this->type; } const QString & getTooltip() const { - return tooltip; + return this->tooltip; } const QColor & getColor() const { - return color; + return this->color; } const Link & getLink() const { - return link; + return this->link; } int getXOffset() const { - return xOffset; + return this->xOffset; } int getYOffset() const { - return yOffset; + return this->yOffset; } void setOffset(int xOffset, int yOffset) { - xOffset = std::max(0, xOffset); - yOffset = std::max(0, yOffset); + this->xOffset = std::max(0, xOffset); + this->yOffset = std::max(0, yOffset); } std::vector & getCharacterWidthCache() { - return characterWidthCache; + return this->characterWidthCache; } private: diff --git a/wordpart.cpp b/wordpart.cpp index f30ee22fc..f52f0f520 100644 --- a/wordpart.cpp +++ b/wordpart.cpp @@ -5,12 +5,12 @@ WordPart::WordPart(Word &word, int x, int y, const QString ©Text, bool allowTrailingSpace) : m_word(word) , copyText(copyText) + , text(word.isText() ? m_word.getText() : QString()) , x(x) , y(y) , width(word.getWidth()) , height(word.getHeight()) , _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace) - , text(word.isText() ? m_word.getText() : QString()) { } @@ -19,11 +19,11 @@ WordPart::WordPart(Word &word, int x, int y, int width, int height, bool allowTrailingSpace) : m_word(word) , copyText(copyText) + , text(customText) , x(x) , y(y) , width(width) , height(height) , _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace) - , text(customText) { } diff --git a/wordpart.h b/wordpart.h index 6a110156d..da0fa8abe 100644 --- a/wordpart.h +++ b/wordpart.h @@ -19,84 +19,84 @@ public: const Word & getWord() const { - return m_word; + return this->m_word; } int getWidth() const { - return width; + return this->width; } int getHeight() const { - return height; + return this->height; } int getX() const { - return x; + return this->x; } int getY() const { - return y; + return this->y; } void setPosition(int x, int y) { - x = x; - y = y; + this->x = x; + this->y = y; } void setY(int y) { - y = y; + this->y = y; } int getRight() const { - return x + width; + return this->x + this->width; } int getBottom() const { - return y + height; + return this->y + this->height; } QRect getRect() const { - return QRect(x, y, width, height); + return QRect(this->x, this->y, this->width, this->height); } const QString getCopyText() const { - return copyText; + return this->copyText; } int hasTrailingSpace() const { - return _trailingSpace; + return this->_trailingSpace; } const QString & getText() const { - return text; + return this->text; } private: - Word &m_word; + Word& m_word; QString copyText; QString text;