From 49227fac43e2d1f8155e6f0ff8f6fd83674af131 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Sat, 26 May 2018 18:38:06 +0200 Subject: [PATCH] Solve cppcheck warnings --- src/cli/commandlineparser.h | 2 +- src/config/buttonlistview.h | 2 +- src/config/geneneralconf.h | 2 +- src/core/flameshotdbusadapter.h | 2 +- src/main.cpp | 4 ++-- src/third-party/Qt-Color-Widgets/src/color_wheel.cpp | 2 +- src/tools/text/textconfig.cpp | 2 ++ src/tools/text/texttool.cpp | 2 +- src/widgets/capture/buttonhandler.cpp | 3 +-- src/widgets/capture/buttonhandler.h | 2 +- src/widgets/capture/capturebutton.cpp | 4 ---- src/widgets/capture/capturebutton.h | 1 - src/widgets/capture/capturewidget.cpp | 8 -------- src/widgets/capture/capturewidget.h | 4 ---- src/widgets/capture/notifierbox.cpp | 1 + 15 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/cli/commandlineparser.h b/src/cli/commandlineparser.h index c8c080af..dbd8d251 100644 --- a/src/cli/commandlineparser.h +++ b/src/cli/commandlineparser.h @@ -55,7 +55,7 @@ private: QString m_generalErrorMessage; struct Node { - Node(const CommandArgument &arg) : argument(arg) {} + explicit Node(const CommandArgument &arg) : argument(arg) {} Node() {} bool operator==(const Node &n) const { return argument == n.argument && diff --git a/src/config/buttonlistview.h b/src/config/buttonlistview.h index ec7eb044..2bc88713 100644 --- a/src/config/buttonlistview.h +++ b/src/config/buttonlistview.h @@ -22,7 +22,7 @@ class ButtonListView : public QListWidget { public: - ButtonListView(QWidget *parent= nullptr); + explicit ButtonListView(QWidget *parent= nullptr); public slots: void selectAll(); diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index 856d5d5d..a2192e90 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -26,7 +26,7 @@ class QPushButton; class GeneneralConf : public QWidget { Q_OBJECT public: - GeneneralConf(QWidget *parent = nullptr); + explicit GeneneralConf(QWidget *parent = nullptr); public slots: void updateComponents(); diff --git a/src/core/flameshotdbusadapter.h b/src/core/flameshotdbusadapter.h index 6fbd2228..d2c2074b 100644 --- a/src/core/flameshotdbusadapter.h +++ b/src/core/flameshotdbusadapter.h @@ -25,7 +25,7 @@ class FlameshotDBusAdapter : public QDBusAbstractAdaptor { Q_CLASSINFO("D-Bus Interface", "org.dharkael.Flameshot") public: - FlameshotDBusAdapter(QObject *parent = nullptr); + explicit FlameshotDBusAdapter(QObject *parent = nullptr); virtual ~FlameshotDBusAdapter(); signals: diff --git a/src/main.cpp b/src/main.cpp index cf07d070..cfe07587 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,9 +48,9 @@ int main(int argc, char *argv[]) { QTranslator translator; QStringList trPaths = PathInfo::translationsPaths(); - bool match = false; + for (const QString &path: trPaths) { - match = translator.load(QLocale::system().language(), + bool match = translator.load(QLocale::system().language(), "Internationalization", "_", path); if (match) { diff --git a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp index d86c571b..335b29ce 100644 --- a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp +++ b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp @@ -59,7 +59,7 @@ public: QColor (*rainbow_from_hue)(qreal); int max_size = 128; - Private(ColorWheel *widget) + explicit Private(ColorWheel *widget) : w(widget), hue(0), sat(0), val(0), wheel_width(20), mouse_status(Nothing), display_flags(FLAGS_DEFAULT), diff --git a/src/tools/text/textconfig.cpp b/src/tools/text/textconfig.cpp index 078124e1..4821a52d 100644 --- a/src/tools/text/textconfig.cpp +++ b/src/tools/text/textconfig.cpp @@ -36,6 +36,8 @@ TextConfig::TextConfig(QWidget *parent) : QWidget(parent) { int index = fontsCB->findData(QFont().family()); if ( index != -1 ) { fontsCB->setCurrentIndex(index); + } else { + } QColor bgColor(palette().background().color()); diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index e5066abc..ae8135a6 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -22,7 +22,7 @@ #define BASE_POINT_SIZE 8 -TextTool::TextTool(QObject *parent) : CaptureTool(parent) { +TextTool::TextTool(QObject *parent) : CaptureTool(parent), m_size(1) { } bool TextTool::isValid() const { diff --git a/src/widgets/capture/buttonhandler.cpp b/src/widgets/capture/buttonhandler.cpp index 10a1694f..4c7b38ec 100644 --- a/src/widgets/capture/buttonhandler.cpp +++ b/src/widgets/capture/buttonhandler.cpp @@ -289,9 +289,8 @@ void ButtonHandler::positionButtonsInside(int index) { QPoint center = QPoint(mainArea.center().x(), mainArea.bottom() - m_buttonExtendedSize); - int addCounter; while (m_vectorButtons.size() > index) { - addCounter = buttonsPerRow; + int addCounter = buttonsPerRow; addCounter = qBound(0, addCounter, m_vectorButtons.size() - index); QVector positions = horizontalPoints(center, addCounter, true); moveButtonsToPoints(positions, index); diff --git a/src/widgets/capture/buttonhandler.h b/src/widgets/capture/buttonhandler.h index 48d8fe59..1db88127 100644 --- a/src/widgets/capture/buttonhandler.h +++ b/src/widgets/capture/buttonhandler.h @@ -30,7 +30,7 @@ class ButtonHandler : public QObject { Q_OBJECT public: ButtonHandler(const QVector&, QObject *parent = nullptr); - ButtonHandler(QObject *parent = nullptr); + explicit ButtonHandler(QObject *parent = nullptr); void hideSectionUnderMouse(const QPoint &p); diff --git a/src/widgets/capture/capturebutton.cpp b/src/widgets/capture/capturebutton.cpp index fed3d50f..6d2af48d 100644 --- a/src/widgets/capture/capturebutton.cpp +++ b/src/widgets/capture/capturebutton.cpp @@ -134,10 +134,6 @@ void CaptureButton::animatedShow() { } } -CaptureButton::ButtonType CaptureButton::buttonType() const { - return m_buttonType; -} - CaptureTool *CaptureButton::tool() const { return m_tool; } diff --git a/src/widgets/capture/capturebutton.h b/src/widgets/capture/capturebutton.h index fdeaa08d..a3a23968 100644 --- a/src/widgets/capture/capturebutton.h +++ b/src/widgets/capture/capturebutton.h @@ -65,7 +65,6 @@ public: QString description() const; QIcon icon() const; QString styleSheet() const; - ButtonType buttonType() const; CaptureTool* tool() const; void setColor(const QColor &c); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 49958802..37393cc1 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -563,10 +563,6 @@ void CaptureWidget::initSelection() { m_selection->setGeometry(QRect()); } -void CaptureWidget::initWidget() { - -} - void CaptureWidget::setState(CaptureButton *b) { if (!b) { return; @@ -826,10 +822,6 @@ void CaptureWidget::childLeave() { update(); } -int CaptureWidget::handleSize() { - return (QApplication::fontMetrics().height() * 0.7); -} - void CaptureWidget::copyScreenshot() { m_captureDone = true; ScreenshotSaver().saveToClipboard(pixmap()); diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h index 3e558250..06cc735e 100644 --- a/src/widgets/capture/capturewidget.h +++ b/src/widgets/capture/capturewidget.h @@ -123,16 +123,12 @@ private: void initContext(const QString &savePath, bool fullscreen); void initPanel(); void initSelection(); - void initWidget(); void initShortcuts(); void updateSizeIndicator(); void updateCursor(); void pushToolToStack(); void makeChild(QWidget *w); - // size of the handlers at the corners of the selection - int handleSize(); - QRect extendedSelection() const; QUndoStack m_undoStack; diff --git a/src/widgets/capture/notifierbox.cpp b/src/widgets/capture/notifierbox.cpp index b018449d..a060267c 100644 --- a/src/widgets/capture/notifierbox.cpp +++ b/src/widgets/capture/notifierbox.cpp @@ -62,5 +62,6 @@ void NotifierBox::showMessage(const QString &msg) { } void NotifierBox::showColor(const QColor &color) { + Q_UNUSED(color); m_message = ""; }