diff --git a/docs/futureFeatures.md b/docs/futureFeatures.md deleted file mode 100644 index 3aad3ae4..00000000 --- a/docs/futureFeatures.md +++ /dev/null @@ -1,9 +0,0 @@ -This will gather some possible features to implement in Flameshot. - -These are just conceptual and they may not be implemented implemented in a short period of time. - -- Add Text Button: this could be very handy but requires a huge refactor of the source code. - -- Mouse Visibility Button: if you look at the source code you'll find a lot of references about this. In fact it is almost implemente but it is disabled because the most important part (the code that fetches the mouse icon) is plataform specific and it requieres some of my time to end the implementation. - -- Wayland support diff --git a/src/capture/buttonhandler.cpp b/src/capture/buttonhandler.cpp index 999cd6b8..c598d2e3 100644 --- a/src/capture/buttonhandler.cpp +++ b/src/capture/buttonhandler.cpp @@ -29,7 +29,7 @@ ButtonHandler::ButtonHandler(const QVector &v, QObject *parent) QObject(parent) { if (!v.isEmpty()) { - m_buttonBaseSize = v[0]->getButtonBaseSize(); + m_buttonBaseSize = v[0]->buttonBaseSize(); m_distance = m_buttonBaseSize + SEPARATION; m_vectorButtons = v; } @@ -166,8 +166,8 @@ void ButtonHandler::updatePosition(const QRect &selection, } } - QVector positions = getHPoints(center, addCounter, true); - for (QPoint p: positions) { + QVector positions = horizontalPoints(center, addCounter, true); + for (const QPoint &p: positions) { m_vectorButtons[elemIndicator]->move(p); ++elemIndicator; } @@ -181,8 +181,8 @@ void ButtonHandler::updatePosition(const QRect &selection, QPoint center = QPoint(baseArea.right() + SEPARATION, baseArea.center().y()); - QVector positions = getVPoints(center, addCounter, false); - for (QPoint p: positions) { + QVector positions = verticalPoints(center, addCounter, false); + for (const QPoint &p: positions) { m_vectorButtons[elemIndicator]->move(p); ++elemIndicator; } @@ -210,8 +210,8 @@ void ButtonHandler::updatePosition(const QRect &selection, center.setX(center.x() - (baseWidth+SEPARATION)/2); } } - QVector positions = getHPoints(center, addCounter, false); - for (QPoint p: positions) { + QVector positions = horizontalPoints(center, addCounter, false); + for (const QPoint &p: positions) { m_vectorButtons[elemIndicator]->move(p); ++elemIndicator; } @@ -228,8 +228,8 @@ void ButtonHandler::updatePosition(const QRect &selection, } QPoint center = QPoint(baseArea.left() - (SEPARATION + baseWidth), baseArea.center().y()); - QVector positions = getVPoints(center, addCounter, true); - for (QPoint p: positions) { + QVector positions = verticalPoints(center, addCounter, true); + for (const QPoint &p: positions) { m_vectorButtons[elemIndicator]->move(p); ++elemIndicator; } @@ -263,7 +263,7 @@ void ButtonHandler::updatePosition(const QRect &selection, // getHPoints is an auxiliar method for the button position computation. // starts from a known center and keeps adding elements horizontally // and returns the computed positions. -QVector ButtonHandler::getHPoints( +QVector ButtonHandler::horizontalPoints( const QPoint ¢er, const int elements, const bool leftToRight) const { QVector res; @@ -289,7 +289,7 @@ QVector ButtonHandler::getHPoints( // getHPoints is an auxiliar method for the button position computation. // starts from a known center and keeps adding elements vertically // and returns the computed positions. -QVector ButtonHandler::getVPoints( +QVector ButtonHandler::verticalPoints( const QPoint ¢er, const int elements,const bool upToDown) const { QVector res; @@ -328,7 +328,7 @@ void ButtonHandler::setButtons(const QVector v) { for (CaptureButton *b: m_vectorButtons) delete(b); m_vectorButtons = v; if (!v.isEmpty()) { - m_buttonBaseSize = v[0]->getButtonBaseSize(); + m_buttonBaseSize = v[0]->buttonBaseSize(); m_distance = m_buttonBaseSize + SEPARATION; } } diff --git a/src/capture/buttonhandler.h b/src/capture/buttonhandler.h index 6b17690f..2441233e 100644 --- a/src/capture/buttonhandler.h +++ b/src/capture/buttonhandler.h @@ -43,9 +43,9 @@ public: bool contains(const QPoint &p) const; private: - QVector getHPoints(const QPoint ¢er, const int elements, + QVector horizontalPoints(const QPoint ¢er, const int elements, const bool leftToRight) const; - QVector getVPoints(const QPoint ¢er, const int elements, + QVector verticalPoints(const QPoint ¢er, const int elements, const bool upToDown) const; QVector m_vectorButtons; @@ -54,6 +54,7 @@ private: QRegion m_region; void addToRegion(const QVector &points); + }; #endif // BUTTONHANDLER_H diff --git a/src/capture/capturebutton.cpp b/src/capture/capturebutton.cpp index 7e468f86..9978ca25 100644 --- a/src/capture/capturebutton.cpp +++ b/src/capture/capturebutton.cpp @@ -28,33 +28,24 @@ // multiple functionality. namespace { - const int BUTTON_SIZE = 30; - inline qreal getColorLuma(const QColor &c) { - return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF(); - } - - inline int constrain(const int x, const int min, const int max) { - if (x > max) { - return max; - } else if (x < min) { - return min; - } else { - return x; - } - } - - QColor getContrastColor(const QColor &c) { - bool isWhite = CaptureButton::iconIsWhiteByColor(c); - int change = isWhite ? 30 : -45; - - return QColor(constrain(c.red() + change, 0, 255), - constrain(c.green() + change, 0, 255), - constrain(c.blue() + change, 0, 255)); - } +const int BUTTON_SIZE = 30; +inline qreal getColorLuma(const QColor &c) { + return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF(); } +QColor getContrastColor(const QColor &c) { + bool isWhite = CaptureButton::iconIsWhiteByColor(c); + int change = isWhite ? 30 : -45; + + return QColor(qBound(0, c.red() + change, 255), + qBound(0, c.green() + change, 255), + qBound(0, c.blue() + change, 255)); +} + +} // unnamed namespace + CaptureButton::CaptureButton(const ButtonType t, QWidget *parent) : QPushButton(parent), m_buttonType(t), m_pressed(false) { @@ -63,7 +54,7 @@ CaptureButton::CaptureButton(const ButtonType t, QWidget *parent) : QPushButton( QFont f = this->font(); setFont(QFont(f.family(), 7, QFont::Bold)); } else { - setIcon(getIcon()); + setIcon(icon()); } } @@ -75,7 +66,7 @@ void CaptureButton::initButton() { resize(BUTTON_SIZE, BUTTON_SIZE); setMask(QRegion(QRect(-1,-1,BUTTON_SIZE+2, BUTTON_SIZE+2), QRegion::Ellipse)); - setToolTip(m_tool->getDescription()); + setToolTip(m_tool->description()); emergeAnimation = new QPropertyAnimation(this, "size", this); emergeAnimation->setEasingCurve(QEasingCurve::InOutQuad); @@ -88,8 +79,8 @@ QVector CaptureButton::getIterableButtonTypes() { return iterableButtonTypes; } -QString CaptureButton::getGlobalStyleSheet() { - QColor mainColor = ConfigHandler().getUIMainColor(); +QString CaptureButton::globalStyleSheet() { + QColor mainColor = ConfigHandler().uiMainColorValue(); QString baseSheet = "CaptureButton { border-radius: %3;" "background-color: %1; color: %4 }" "CaptureButton:hover { background-color: %2; }" @@ -105,7 +96,7 @@ QString CaptureButton::getGlobalStyleSheet() { .arg(BUTTON_SIZE/2).arg(color); } -QString CaptureButton::getStyleSheet() const { +QString CaptureButton::styleSheet() const { QString baseSheet = "CaptureButton { border-radius: %3;" "background-color: %1; color: %4 }" "CaptureButton:hover { background-color: %2; }" @@ -121,10 +112,10 @@ QString CaptureButton::getStyleSheet() const { } // get icon returns the icon for the type of button -QIcon CaptureButton::getIcon() const { +QIcon CaptureButton::icon() const { QString color(iconIsWhiteByColor(m_mainColor) ? "White" : "Black"); QString iconPath = QString(":/img/buttonIcons%1/%2") - .arg(color).arg(m_tool->getIconName()); + .arg(color).arg(m_tool->iconName()); return QIcon(iconPath); } @@ -159,22 +150,22 @@ void CaptureButton::animatedShow() { emergeAnimation->start(); } -CaptureButton::ButtonType CaptureButton::getButtonType() const { +CaptureButton::ButtonType CaptureButton::buttonType() const { return m_buttonType; } -CaptureTool *CaptureButton::getTool() const { +CaptureTool *CaptureButton::tool() const { return m_tool; } void CaptureButton::setColor(const QColor &c) { m_mainColor = c; - setStyleSheet(getStyleSheet()); - setIcon(getIcon()); + setStyleSheet(styleSheet()); + setIcon(icon()); } // getButtonBaseSize returns the base size of the buttons -size_t CaptureButton::getButtonBaseSize() { +size_t CaptureButton::buttonBaseSize() { return BUTTON_SIZE; } @@ -186,7 +177,7 @@ bool CaptureButton::iconIsWhiteByColor(const QColor &c) { return isWhite; } -QColor CaptureButton::m_mainColor = ConfigHandler().getUIMainColor(); +QColor CaptureButton::m_mainColor = ConfigHandler().uiMainColorValue(); QVector CaptureButton::iterableButtonTypes = { CaptureButton::TYPE_PENCIL, diff --git a/src/capture/capturebutton.h b/src/capture/capturebutton.h index 3f61e011..c501783f 100644 --- a/src/capture/capturebutton.h +++ b/src/capture/capturebutton.h @@ -53,17 +53,17 @@ public: CaptureButton() = delete; explicit CaptureButton(const ButtonType, QWidget *parent = nullptr); - static size_t getButtonBaseSize(); + static size_t buttonBaseSize(); static bool iconIsWhiteByColor(const QColor &); - static QString getGlobalStyleSheet(); + static QString globalStyleSheet(); static QVector getIterableButtonTypes(); - QString getName() const; - QString getDescription() const; - QIcon getIcon() const; - QString getStyleSheet() const; - ButtonType getButtonType() const; - CaptureTool* getTool() const; + QString name() const; + QString description() const; + QIcon icon() const; + QString styleSheet() const; + ButtonType buttonType() const; + CaptureTool* tool() const; void setColor(const QColor &c); void animatedShow(); @@ -92,6 +92,7 @@ private: static QColor m_mainColor; void initButton(); + }; #endif // BUTTON_H diff --git a/src/capture/capturemodification.cpp b/src/capture/capturemodification.cpp index 48f0815d..d0df78e8 100644 --- a/src/capture/capturemodification.cpp +++ b/src/capture/capturemodification.cpp @@ -40,25 +40,25 @@ CaptureModification::CaptureModification( } } -CaptureButton::ButtonType CaptureModification::getType() const { +CaptureButton::ButtonType CaptureModification::buttonType() const { return m_type; } -QColor CaptureModification::getColor() const { +QColor CaptureModification::color() const { return m_color; } -QVector CaptureModification::getPoints() const { +QVector CaptureModification::points() const { return m_coords; } -CaptureTool* CaptureModification::getTool() const{ +CaptureTool* CaptureModification::tool() const{ return m_tool; } // addPoint adds a point to the vector of points void CaptureModification::addPoint(const QPoint p) { - if(m_tool->getToolType() == CaptureTool::TYPE_LINE_DRAWER) { + if (m_tool->toolType() == CaptureTool::TYPE_LINE_DRAWER) { m_coords[1] = p; } else { m_coords.append(p); diff --git a/src/capture/capturemodification.h b/src/capture/capturemodification.h index 6444ee94..5f7f3e92 100644 --- a/src/capture/capturemodification.h +++ b/src/capture/capturemodification.h @@ -35,10 +35,10 @@ public: const QColor &, QObject *parent = nullptr ); - QColor getColor() const; - QVector getPoints() const; - CaptureTool* getTool() const; - CaptureButton::ButtonType getType() const; + QColor color() const; + QVector points() const; + CaptureTool* tool() const; + CaptureButton::ButtonType buttonType() const; void addPoint(const QPoint); protected: @@ -47,8 +47,6 @@ protected: QVector m_coords; CaptureTool *m_tool; -private: - }; #endif // CAPTURECHANGE_H diff --git a/src/capture/capturewidget.cpp b/src/capture/capturewidget.cpp index 77b697a0..3bd5cda6 100644 --- a/src/capture/capturewidget.cpp +++ b/src/capture/capturewidget.cpp @@ -45,9 +45,12 @@ // are of selection with its respective buttons. namespace { - // size of the handlers at the corners of the selection - const int HANDLE_SIZE = 9; -} + +// size of the handlers at the corners of the selection +const int HANDLE_SIZE = 9; + +} // unnamed namespace + // enableSaveWIndow CaptureWidget::CaptureWidget(const QString &forcedSavePath, QWidget *parent) : QWidget(parent), m_mouseOverHandle(0), m_mouseIsClicked(false), @@ -55,7 +58,7 @@ CaptureWidget::CaptureWidget(const QString &forcedSavePath, QWidget *parent) : m_onButton(false), m_forcedSavePath(forcedSavePath), m_state(CaptureButton::TYPE_MOVESELECTION) { - m_showInitialMsg = ConfigHandler().getShowHelp(); + m_showInitialMsg = ConfigHandler().showHelpValue(); setAttribute(Qt::WA_DeleteOnClose); // create selection handlers @@ -102,13 +105,13 @@ CaptureWidget::~CaptureWidget() { // selection in the capture void CaptureWidget::updateButtons() { ConfigHandler config; - m_uiColor = config.getUIMainColor(); - m_contrastUiColor = config.getUIContrastColor(); + m_uiColor = config.uiMainColorValue(); + m_contrastUiColor = config.uiContrastColorValue(); auto buttons = config.getButtons(); QVector vectorButtons; - for (auto t: buttons) { + for (const CaptureButton::ButtonType &t: buttons) { CaptureButton *b = new CaptureButton(t, this); if (t == CaptureButton::TYPE_SELECTIONINDICATOR) { m_sizeIndButton = b; @@ -118,7 +121,7 @@ void CaptureWidget::updateButtons() { connect(b, &CaptureButton::hovered, this, &CaptureWidget::enterButton); connect(b, &CaptureButton::mouseExited, this, &CaptureWidget::leaveButton); connect(b, &CaptureButton::pressedButton, this, &CaptureWidget::setState); - connect(b->getTool(), &CaptureTool::requestAction, + connect(b->tool(), &CaptureTool::requestAction, this, &CaptureWidget::handleButtonSignal); vectorButtons << b; } @@ -136,7 +139,7 @@ void CaptureWidget::paintEvent(QPaintEvent *) { painter.drawPixmap(0, 0, m_screenshot->paintTemporalModification( m_modifications.last())); } else { - painter.drawPixmap(0, 0, m_screenshot->getScreenshot()); + painter.drawPixmap(0, 0, m_screenshot->screenshot()); } QColor overlayColor(0, 0, 0, 160); @@ -149,8 +152,7 @@ void CaptureWidget::paintEvent(QPaintEvent *) { painter.drawRect(-1, -1, rect().width() + 1, rect().height() + 1); painter.setClipRect(rect()); - if(m_showInitialMsg) { - + if (m_showInitialMsg) { QRect helpRect = QGuiApplication::primaryScreen()->geometry(); QString helpTxt = tr("Select an area with the mouse, or press Esc to exit." @@ -206,7 +208,7 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) { m_mouseIsClicked = true; if (m_state != CaptureButton::TYPE_MOVESELECTION) { auto mod = new CaptureModification(m_state, e->pos(), - m_colorPicker->getDrawColor(), + m_colorPicker->drawColor(), this); m_modifications.append(mod); return; @@ -242,14 +244,14 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { QPoint p = initialRect.topLeft() + (e->pos() - m_dragStartPoint); m_dragStartPoint += e->pos() - m_dragStartPoint; m_selection.moveTo(p); - if(!r.contains(QPoint(r.center().x(), m_selection.top()))) { + if (!r.contains(QPoint(r.center().x(), m_selection.top()))) { m_selection.setTop(r.top()); - } if(!r.contains(QPoint(m_selection.left(), r.center().y()))) { + } if (!r.contains(QPoint(m_selection.left(), r.center().y()))) { m_selection.setLeft(r.left()); } - if(!r.contains(QPoint(m_selection.right(), r.center().y()))) { + if (!r.contains(QPoint(m_selection.right(), r.center().y()))) { m_selection.setRight(r.right()); - } if(!r.contains(QPoint(r.center().x(), m_selection.bottom()))) { + } if (!r.contains(QPoint(r.center().x(), m_selection.bottom()))) { m_selection.setBottom(r.bottom()); } } else { @@ -307,7 +309,7 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) { return; } bool found = false; - for (QRect *r: m_Handles) { + for (QRect *const r: m_Handles) { if (r->contains(e->pos())) { m_mouseOverHandle = r; found = true; @@ -370,28 +372,28 @@ QString CaptureWidget::saveScreenshot(bool toClipboard) { SystemNotification notify; if (toClipboard) { if (m_selection.isNull()) { // copy full screen when no selection - QApplication::clipboard()->setPixmap(m_screenshot->getScreenshot()); + QApplication::clipboard()->setPixmap(m_screenshot->screenshot()); } else { - QApplication::clipboard()->setPixmap(m_screenshot->getScreenshot() - .copy(getExtendedSelection())); + QApplication::clipboard()->setPixmap(m_screenshot->screenshot() + .copy(extendedSelection())); } } bool ok = false; - if(m_forcedSavePath.isEmpty()) { - if(isVisible()) { + if (m_forcedSavePath.isEmpty()) { + if (isVisible()) { hide(); } - savePath = m_screenshot->graphicalSave(ok, getExtendedSelection(), this); + savePath = m_screenshot->graphicalSave(ok, extendedSelection(), this); } else { ConfigHandler config; config.setSavePath(m_forcedSavePath); - savePath = m_screenshot->fileSave(ok, getExtendedSelection()); - if(!ok || config.getSavePath() != m_forcedSavePath) { + savePath = m_screenshot->fileSave(ok, extendedSelection()); + if(!ok || config.savePathValue() != m_forcedSavePath) { saveMessage = tr("Error trying to save in ") + savePath; notify.sendMessage(saveMessage); } } - if(ok) { + if (ok) { saveMessage = tr("Capture saved in ") + savePath; notify.sendMessage(saveMessage); } @@ -401,10 +403,10 @@ QString CaptureWidget::saveScreenshot(bool toClipboard) { void CaptureWidget::copyScreenshot() { if (m_selection.isNull()) { // copy full screen when no selection - QApplication::clipboard()->setPixmap(m_screenshot->getScreenshot()); + QApplication::clipboard()->setPixmap(m_screenshot->screenshot()); } else { - QApplication::clipboard()->setPixmap(m_screenshot->getScreenshot() - .copy(getExtendedSelection())); + QApplication::clipboard()->setPixmap(m_screenshot->screenshot() + .copy(extendedSelection())); } close(); } @@ -444,7 +446,7 @@ void CaptureWidget::uploadScreenshot() { if (m_selection.isNull()) { m_screenshot->uploadToImgur(am); } else { - m_screenshot->uploadToImgur(am, getExtendedSelection()); + m_screenshot->uploadToImgur(am, extendedSelection()); } hide(); SystemNotification().sendMessage(tr("Uploading image...")); @@ -463,9 +465,9 @@ bool CaptureWidget::undo() { } void CaptureWidget::setState(CaptureButton *b) { - CaptureButton::ButtonType t = b->getButtonType(); - if(b->getTool()->isSelectable()) { - if(t != m_state) { + CaptureButton::ButtonType t = b->buttonType(); + if (b->tool()->isSelectable()) { + if (t != m_state) { m_state = t; if (m_lastPressedButton) { m_lastPressedButton->setColor(m_uiColor); @@ -638,9 +640,10 @@ QRegion CaptureWidget::handleMask() const { return mask; } -QRect CaptureWidget::getExtendedSelection() const { - if(m_selection.isNull()) return QRect(); - auto devicePixelRatio = m_screenshot->getScreenshot().devicePixelRatio(); +QRect CaptureWidget::extendedSelection() const { + if (m_selection.isNull()) + return QRect(); + auto devicePixelRatio = m_screenshot->screenshot().devicePixelRatio(); return QRect(m_selection.left() * devicePixelRatio, m_selection.top() * devicePixelRatio, diff --git a/src/capture/capturewidget.h b/src/capture/capturewidget.h index 45e2522b..31a0c38f 100644 --- a/src/capture/capturewidget.h +++ b/src/capture/capturewidget.h @@ -45,7 +45,7 @@ class CaptureWidget : public QWidget { friend class CaptureButton; public: - explicit CaptureWidget(const QString &forcedSavePath = "", + explicit CaptureWidget(const QString &forcedSavePath = QString(), QWidget *parent = nullptr); ~CaptureWidget(); @@ -112,7 +112,7 @@ private: void updateSizeIndicator(); void updateCursor(); - QRect getExtendedSelection() const; + QRect extendedSelection() const; QVector m_modifications; QPointer m_sizeIndButton; QPointer m_lastPressedButton; @@ -123,6 +123,7 @@ private: QColor m_uiColor; QColor m_contrastUiColor; ColorPicker *m_colorPicker; + }; #endif // CAPTUREWIDGET_H diff --git a/src/capture/colorpicker.cpp b/src/capture/colorpicker.cpp index 2877f2b5..ce065ab4 100644 --- a/src/capture/colorpicker.cpp +++ b/src/capture/colorpicker.cpp @@ -27,8 +27,8 @@ ColorPicker::ColorPicker(QWidget *parent) : QWidget(parent), setMouseTracking(true); // save the color values in member variables for faster access ConfigHandler config; - m_uiColor = config.getUIMainColor(); - m_drawColor = config.getDrawColor(); + m_uiColor = config.uiMainColorValue(); + m_drawColor = config.drawColorValue(); // extraSize represents the extra space needed for the highlight of the // selected color. const int extraSize = 6; @@ -54,7 +54,7 @@ ColorPicker::~ColorPicker() { ConfigHandler().setDrawColor(m_drawColor); } -QColor ColorPicker::getDrawColor() { +QColor ColorPicker::drawColor() { return m_drawColor; } @@ -74,7 +74,7 @@ void ColorPicker::paintEvent(QPaintEvent *) { QVector rects = handleMask(); painter.setPen(QColor(Qt::black)); - for(int i = 0; i < rects.size(); ++i) { + for (int i = 0; i < rects.size(); ++i) { // draw the highlight when we have to draw the selected color if (m_drawColor == QColor(colorList.at(i))) { QColor c = QColor(m_uiColor); @@ -95,7 +95,7 @@ void ColorPicker::paintEvent(QPaintEvent *) { } void ColorPicker::mouseMoveEvent(QMouseEvent *e) { - for(int i = 0; i < colorList.size(); ++i) { + for (int i = 0; i < colorList.size(); ++i) { if (m_colorAreaList.at(i).contains(e->pos())) { m_drawColor = colorList.at(i); update(); @@ -106,7 +106,7 @@ void ColorPicker::mouseMoveEvent(QMouseEvent *e) { QVector ColorPicker::handleMask() const { QVector areas; - for(QRect rect: m_colorAreaList) { + for (const QRect &rect: m_colorAreaList) { areas.append(rect); } diff --git a/src/capture/colorpicker.h b/src/capture/colorpicker.h index 0bd877f0..66bea1cb 100644 --- a/src/capture/colorpicker.h +++ b/src/capture/colorpicker.h @@ -27,7 +27,7 @@ public: explicit ColorPicker(QWidget *parent = nullptr); ~ColorPicker(); - QColor getDrawColor(); + QColor drawColor(); void show(); void hide(); @@ -38,16 +38,13 @@ protected: QVector handleMask() const; -signals: - -public slots: - private: const int m_colorAreaSize; QVector m_colorAreaList; static QVector colorList; QColor m_uiColor, m_drawColor; + }; #endif // COLORPICKER_H diff --git a/src/capture/screengrabber.cpp b/src/capture/screengrabber.cpp index 236f99d2..cd8c6d30 100644 --- a/src/capture/screengrabber.cpp +++ b/src/capture/screengrabber.cpp @@ -28,7 +28,7 @@ ScreenGrabber::ScreenGrabber(QObject *parent) : QObject(parent) { QPixmap ScreenGrabber::grabEntireDesktop() { QRect geometry; - for (QScreen *screen : QGuiApplication::screens()) { + for (QScreen *const screen : QGuiApplication::screens()) { geometry = geometry.united(screen->geometry()); } diff --git a/src/capture/screengrabber.h b/src/capture/screengrabber.h index 41140001..fa2491f7 100644 --- a/src/capture/screengrabber.h +++ b/src/capture/screengrabber.h @@ -27,9 +27,6 @@ public: explicit ScreenGrabber(QObject *parent = nullptr); QPixmap grabEntireDesktop(); -signals: - -public slots: }; #endif // SCREENGRABBER_H diff --git a/src/capture/screenshot.cpp b/src/capture/screenshot.cpp index a9e47ea7..f02c4c46 100644 --- a/src/capture/screenshot.cpp +++ b/src/capture/screenshot.cpp @@ -48,12 +48,12 @@ void Screenshot::setScreenshot(const QPixmap &p) { } // getScreenshot returns the screenshot with no modifications -QPixmap Screenshot::getBaseScreenshot() const { +QPixmap Screenshot::baseScreenshot() const { return m_baseScreenshot; } // getScreenshot returns the screenshot with all the modifications -QPixmap Screenshot::getScreenshot() const { +QPixmap Screenshot::screenshot() const { return m_modifiedScreenshot; } @@ -64,7 +64,7 @@ QString Screenshot::graphicalSave(bool &ok, QWidget *parent) const { ok = false; // user quits the dialog case - QString savePath = FileNameHandler().getAbsoluteSavePath(); + QString savePath = FileNameHandler().absoluteSavePath(); // setup window QFileDialog fileDialog(parent, QObject::tr("Save As"), savePath); fileDialog.setAcceptMode(QFileDialog::AcceptSave); @@ -80,7 +80,7 @@ QString Screenshot::graphicalSave(bool &ok, QString fileName; do { - if (fileDialog.exec() != QDialog::Accepted) { return ""; } + if (fileDialog.exec() != QDialog::Accepted) { return QString(); } fileName = fileDialog.selectedFiles().first(); QString pathNoFile = fileName.left(fileName.lastIndexOf("/")); @@ -107,7 +107,7 @@ QString Screenshot::graphicalSave(bool &ok, } QString Screenshot::fileSave(bool &ok, const QRect &selection) const { - QString savePath = FileNameHandler().getAbsoluteSavePath(); + QString savePath = FileNameHandler().absoluteSavePath(); QPixmap pixToSave; if (selection.isEmpty()) { pixToSave = m_modifiedScreenshot; @@ -134,7 +134,7 @@ QPixmap Screenshot::paintTemporalModification( { QPixmap tempPix = m_modifiedScreenshot; QPainter painter(&tempPix); - if (modification->getType() != CaptureButton::TYPE_PENCIL) { + if (modification->buttonType() != CaptureButton::TYPE_PENCIL) { painter.setRenderHint(QPainter::Antialiasing); } paintInPainter(painter, modification); @@ -147,7 +147,7 @@ QPixmap Screenshot::paintBaseModifications( const QVector &m) { m_modifiedScreenshot = m_baseScreenshot; - for (const CaptureModification *modification: m) { + for (const CaptureModification *const modification: m) { paintModification(modification); } return m_modifiedScreenshot; @@ -158,16 +158,16 @@ QPixmap Screenshot::paintBaseModifications( void Screenshot::paintInPainter(QPainter &painter, const CaptureModification *modification) { - const QVector &points = modification->getPoints(); - QColor color = modification->getColor(); - modification->getTool()->processImage(painter, points, color); + const QVector &points = modification->points(); + QColor color = modification->color(); + modification->tool()->processImage(painter, points, color); } void Screenshot::uploadToImgur(QNetworkAccessManager *accessManager, const QRect &selection) { QString title ="flameshot_screenshot"; - QString description = FileNameHandler().getParsedPattern(); + QString description = FileNameHandler().parsedPattern(); QPixmap pixToSave; if (selection.isEmpty()) { pixToSave = m_modifiedScreenshot; diff --git a/src/capture/screenshot.h b/src/capture/screenshot.h index 559ac81c..3cdf0984 100644 --- a/src/capture/screenshot.h +++ b/src/capture/screenshot.h @@ -34,8 +34,8 @@ public: ~Screenshot(); void setScreenshot(const QPixmap &); - QPixmap getBaseScreenshot() const; - QPixmap getScreenshot() const; + QPixmap baseScreenshot() const; + QPixmap screenshot() const; QString graphicalSave(bool &ok, const QRect &selection = QRect(), @@ -53,6 +53,7 @@ private: QPointer m_accessManager; void paintInPainter(QPainter &, const CaptureModification *); + }; #endif // SCREENSHOT_H diff --git a/src/capture/tools/arrowtool.cpp b/src/capture/tools/arrowtool.cpp index 1d2ae662..493da1c7 100644 --- a/src/capture/tools/arrowtool.cpp +++ b/src/capture/tools/arrowtool.cpp @@ -19,65 +19,70 @@ #include namespace { - const int ArrowWidth = 10; - const int ArrowHeight = 18; - QPainterPath getArrowHead(QPoint p1, QPoint p2) { - QLineF body(p1, p2); - int originalLength = body.length(); - body.setLength(ArrowWidth); - // move across the line up to the head - //QPointF =; - QLineF temp(QPoint(0,0), p2-p1); - temp.setLength(originalLength-ArrowHeight); - QPointF bottonTranslation(temp.p2()); +const int ArrowWidth = 10; +const int ArrowHeight = 18; - // generates the transformation to center of the arrowhead - body.setAngle(body.angle()+90); - QPointF temp2 = p1-body.p2(); - QPointF centerTranslation((temp2.x()/2), (temp2.y()/2)); +QPainterPath getArrowHead(QPoint p1, QPoint p2) { + QLineF body(p1, p2); + int originalLength = body.length(); + body.setLength(ArrowWidth); + // move across the line up to the head + //QPointF =; + QLineF temp(QPoint(0,0), p2-p1); + temp.setLength(originalLength-ArrowHeight); + QPointF bottonTranslation(temp.p2()); - body.translate(bottonTranslation); - body.translate(centerTranslation); + // generates the transformation to center of the arrowhead + body.setAngle(body.angle()+90); + QPointF temp2 = p1-body.p2(); + QPointF centerTranslation((temp2.x()/2), (temp2.y()/2)); - QPainterPath path; - path.moveTo(p2); - path.lineTo(body.p1()); - path.lineTo(body.p2()); - path.lineTo(p2); - return path; - } - - // gets a shorter line to prevent overlap in the point of the arrow - QLine getShorterLine(QPoint p1, QPoint p2) { - QLineF l(p1, p2); - l.setLength(l.length()-ArrowHeight); - return l.toLine(); - } + body.translate(bottonTranslation); + body.translate(centerTranslation); + QPainterPath path; + path.moveTo(p2); + path.lineTo(body.p1()); + path.lineTo(body.p2()); + path.lineTo(p2); + return path; } +// gets a shorter line to prevent overlap in the point of the arrow +QLine getShorterLine(QPoint p1, QPoint p2) { + QLineF l(p1, p2); + l.setLength(l.length()-ArrowHeight); + return l.toLine(); +} + +} // unnamed namespace + ArrowTool::ArrowTool(QObject *parent) : CaptureTool(parent) { } -bool ArrowTool::isSelectable() { +int ArrowTool::id() const { + return 0; +} + +bool ArrowTool::isSelectable() const { return true; } -QString ArrowTool::getIconName() { +QString ArrowTool::iconName() const { return "arrow-bottom-left.png"; } -QString ArrowTool::getName() { +QString ArrowTool::name() const { return tr("Arrow"); } -QString ArrowTool::getDescription() { +QString ArrowTool::description() const { return tr("Sets the Arrow as the paint tool"); } -CaptureTool::ToolWorkType ArrowTool::getToolType() { +CaptureTool::ToolWorkType ArrowTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/arrowtool.h b/src/capture/tools/arrowtool.h index 0e7c2f65..1d440013 100644 --- a/src/capture/tools/arrowtool.h +++ b/src/capture/tools/arrowtool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,20 @@ class ArrowTool : public CaptureTool public: explicit ArrowTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; - void onPressed(); + void onPressed() override; }; diff --git a/src/capture/tools/capturetool.h b/src/capture/tools/capturetool.h index 667455c6..6a1b9a4a 100644 --- a/src/capture/tools/capturetool.h +++ b/src/capture/tools/capturetool.h @@ -49,12 +49,13 @@ public: explicit CaptureTool(QObject *parent = nullptr); - virtual bool isSelectable() = 0; - virtual ToolWorkType getToolType() = 0; + virtual int id() const = 0; + virtual bool isSelectable() const = 0; + virtual ToolWorkType toolType() const = 0; - virtual QString getIconName() = 0; - virtual QString getName() = 0; - virtual QString getDescription() = 0; + virtual QString iconName() const = 0; + virtual QString name() const = 0; + virtual QString description() const = 0; virtual void processImage( QPainter &painter, diff --git a/src/capture/tools/circletool.cpp b/src/capture/tools/circletool.cpp index e374235e..9d25eb9e 100644 --- a/src/capture/tools/circletool.cpp +++ b/src/capture/tools/circletool.cpp @@ -22,23 +22,27 @@ CircleTool::CircleTool(QObject *parent) : CaptureTool(parent) { } -bool CircleTool::isSelectable() { +int CircleTool::id() const { + return 0; +} + +bool CircleTool::isSelectable() const { return true; } -QString CircleTool::getIconName() { +QString CircleTool::iconName() const { return "circle-outline.png"; } -QString CircleTool::getName() { +QString CircleTool::name() const { return tr("Circle"); } -QString CircleTool::getDescription() { +QString CircleTool::description() const { return tr("Sets the Circle as the paint tool"); } -CaptureTool::ToolWorkType CircleTool::getToolType() { +CaptureTool::ToolWorkType CircleTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/circletool.h b/src/capture/tools/circletool.h index 983b7181..426cc1af 100644 --- a/src/capture/tools/circletool.h +++ b/src/capture/tools/circletool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class CircleTool : public CaptureTool public: explicit CircleTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // CIRCLETOOL_H diff --git a/src/capture/tools/copytool.cpp b/src/capture/tools/copytool.cpp index e80f12b3..8dd51559 100644 --- a/src/capture/tools/copytool.cpp +++ b/src/capture/tools/copytool.cpp @@ -22,23 +22,27 @@ CopyTool::CopyTool(QObject *parent) : CaptureTool(parent) { } -bool CopyTool::isSelectable() { +int CopyTool::id() const { + return 0; +} + +bool CopyTool::isSelectable() const { return false; } -QString CopyTool::getIconName() { +QString CopyTool::iconName() const { return "content-copy.png"; } -QString CopyTool::getName() { +QString CopyTool::name() const { return tr("Copy"); } -QString CopyTool::getDescription() { +QString CopyTool::description() const { return tr("Copies the selecion into the clipboard"); } -CaptureTool::ToolWorkType CopyTool::getToolType() { +CaptureTool::ToolWorkType CopyTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/copytool.h b/src/capture/tools/copytool.h index 8f6e4b78..12138f6c 100644 --- a/src/capture/tools/copytool.h +++ b/src/capture/tools/copytool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class CopyTool : public CaptureTool public: explicit CopyTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // COPYTOOL_H diff --git a/src/capture/tools/exittool.cpp b/src/capture/tools/exittool.cpp index caf96866..ca1f08d7 100644 --- a/src/capture/tools/exittool.cpp +++ b/src/capture/tools/exittool.cpp @@ -22,23 +22,27 @@ ExitTool::ExitTool(QObject *parent) : CaptureTool(parent) { } -bool ExitTool::isSelectable() { +int ExitTool::id() const { + return 0; +} + +bool ExitTool::isSelectable() const { return false; } -QString ExitTool::getIconName() { +QString ExitTool::iconName() const { return "close.png"; } -QString ExitTool::getName() { +QString ExitTool::name() const { return tr("Exit"); } -QString ExitTool::getDescription() { +QString ExitTool::description() const { return tr("Leave the capture screen"); } -CaptureTool::ToolWorkType ExitTool::getToolType() { +CaptureTool::ToolWorkType ExitTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/exittool.h b/src/capture/tools/exittool.h index 1d583f8a..981f327a 100644 --- a/src/capture/tools/exittool.h +++ b/src/capture/tools/exittool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class ExitTool : public CaptureTool public: explicit ExitTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // EXITTOOL_H diff --git a/src/capture/tools/imguruploadertool.cpp b/src/capture/tools/imguruploadertool.cpp index 8a14f8fe..09a73c1a 100644 --- a/src/capture/tools/imguruploadertool.cpp +++ b/src/capture/tools/imguruploadertool.cpp @@ -22,23 +22,27 @@ ImgurUploaderTool::ImgurUploaderTool(QObject *parent) : CaptureTool(parent) { } -bool ImgurUploaderTool::isSelectable() { +int ImgurUploaderTool::id() const { + return 0; +} + +bool ImgurUploaderTool::isSelectable() const { return false; } -QString ImgurUploaderTool::getIconName() { +QString ImgurUploaderTool::iconName() const { return "cloud-upload.png"; } -QString ImgurUploaderTool::getName() { +QString ImgurUploaderTool::name() const { return tr("Image Uploader"); } -QString ImgurUploaderTool::getDescription() { +QString ImgurUploaderTool::description() const { return tr("Uploads the selection to Imgur"); } -CaptureTool::ToolWorkType ImgurUploaderTool::getToolType() { +CaptureTool::ToolWorkType ImgurUploaderTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/imguruploadertool.h b/src/capture/tools/imguruploadertool.h index 59633787..137364a3 100644 --- a/src/capture/tools/imguruploadertool.h +++ b/src/capture/tools/imguruploadertool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class ImgurUploaderTool : public CaptureTool public: explicit ImgurUploaderTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // IMGURUPLOADERTOOL_H diff --git a/src/capture/tools/linetool.cpp b/src/capture/tools/linetool.cpp index 2b47bed3..2824abc7 100644 --- a/src/capture/tools/linetool.cpp +++ b/src/capture/tools/linetool.cpp @@ -24,23 +24,27 @@ LineTool::LineTool(QObject *parent) : CaptureTool(parent) { } -bool LineTool::isSelectable() { +int LineTool::id() const { + return 0; +} + +bool LineTool::isSelectable() const { return true; } -QString LineTool::getIconName() { +QString LineTool::iconName() const { return "line.png"; } -QString LineTool::getName() { +QString LineTool::name() const { return tr("Line"); } -QString LineTool::getDescription() { +QString LineTool::description() const { return tr("Sets the Line as the paint tool"); } -CaptureTool::ToolWorkType LineTool::getToolType() { +CaptureTool::ToolWorkType LineTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/linetool.h b/src/capture/tools/linetool.h index 32a31570..008697b9 100644 --- a/src/capture/tools/linetool.h +++ b/src/capture/tools/linetool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,23 +26,24 @@ class LineTool : public CaptureTool public: explicit LineTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; - void onPressed(); + void onPressed() override; private: inline bool needsAdjustment(const QPoint &p0, const QPoint &p1) const; + }; #endif // LINETOOL_H diff --git a/src/capture/tools/markertool.cpp b/src/capture/tools/markertool.cpp index 4cf7cbed..c899d09e 100644 --- a/src/capture/tools/markertool.cpp +++ b/src/capture/tools/markertool.cpp @@ -24,23 +24,27 @@ MarkerTool::MarkerTool(QObject *parent) : CaptureTool(parent) { } -bool MarkerTool::isSelectable() { +int MarkerTool::id() const { + return 0; +} + +bool MarkerTool::isSelectable() const { return true; } -QString MarkerTool::getIconName() { +QString MarkerTool::iconName() const { return "marker.png"; } -QString MarkerTool::getName() { +QString MarkerTool::name() const { return tr("Marker"); } -QString MarkerTool::getDescription() { +QString MarkerTool::description() const { return tr("Sets the Marker as the paint tool"); } -CaptureTool::ToolWorkType MarkerTool::getToolType() { +CaptureTool::ToolWorkType MarkerTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/markertool.h b/src/capture/tools/markertool.h index f560d1a7..06962f4a 100644 --- a/src/capture/tools/markertool.h +++ b/src/capture/tools/markertool.h @@ -26,23 +26,24 @@ class MarkerTool : public CaptureTool public: explicit MarkerTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; - void onPressed(); + void onPressed() override; private: inline bool needsAdjustment(const QPoint &p0, const QPoint &p1) const; + }; #endif // MARKERTOOL_H diff --git a/src/capture/tools/movetool.cpp b/src/capture/tools/movetool.cpp index 41c1ab06..76eef841 100644 --- a/src/capture/tools/movetool.cpp +++ b/src/capture/tools/movetool.cpp @@ -22,23 +22,27 @@ MoveTool::MoveTool(QObject *parent) : CaptureTool(parent) { } -bool MoveTool::isSelectable() { +int MoveTool::id() const { + return 0; +} + +bool MoveTool::isSelectable() const { return false; } -QString MoveTool::getIconName() { +QString MoveTool::iconName() const { return "cursor-move.png"; } -QString MoveTool::getName() { +QString MoveTool::name() const { return tr("Move"); } -QString MoveTool::getDescription() { +QString MoveTool::description() const { return tr("Move the selection area"); } -CaptureTool::ToolWorkType MoveTool::getToolType() { +CaptureTool::ToolWorkType MoveTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/movetool.h b/src/capture/tools/movetool.h index b0a48d2d..e9841911 100644 --- a/src/capture/tools/movetool.h +++ b/src/capture/tools/movetool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class MoveTool : public CaptureTool public: explicit MoveTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // MOVETOOL_H diff --git a/src/capture/tools/penciltool.cpp b/src/capture/tools/penciltool.cpp index 8377d043..14c84803 100644 --- a/src/capture/tools/penciltool.cpp +++ b/src/capture/tools/penciltool.cpp @@ -22,23 +22,27 @@ PencilTool::PencilTool(QObject *parent) : CaptureTool(parent) { } -bool PencilTool::isSelectable() { +int PencilTool::id() const { + return 0; +} + +bool PencilTool::isSelectable() const { return true; } -QString PencilTool::getIconName() { +QString PencilTool::iconName() const { return "pencil.png"; } -QString PencilTool::getName() { +QString PencilTool::name() const { return tr("Pencil"); } -QString PencilTool::getDescription() { +QString PencilTool::description() const { return tr("Sets the Pencil as the paint tool"); } -CaptureTool::ToolWorkType PencilTool::getToolType() { +CaptureTool::ToolWorkType PencilTool::toolType() const { return TYPE_PATH_DRAWER; } diff --git a/src/capture/tools/penciltool.h b/src/capture/tools/penciltool.h index bde8b2e4..271d5973 100644 --- a/src/capture/tools/penciltool.h +++ b/src/capture/tools/penciltool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const override any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class PencilTool : public CaptureTool public: explicit PencilTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // PENCILTOOL_H diff --git a/src/capture/tools/rectangletool.cpp b/src/capture/tools/rectangletool.cpp index a9c18760..42d97d36 100644 --- a/src/capture/tools/rectangletool.cpp +++ b/src/capture/tools/rectangletool.cpp @@ -22,23 +22,27 @@ RectangleTool::RectangleTool(QObject *parent) : CaptureTool(parent) { } -bool RectangleTool::isSelectable() { +int RectangleTool::id() const { + return 0; +} + +bool RectangleTool::isSelectable() const { return true; } -QString RectangleTool::getIconName() { +QString RectangleTool::iconName() const { return "square.png"; } -QString RectangleTool::getName() { +QString RectangleTool::name() const { return tr("Rectangle"); } -QString RectangleTool::getDescription() { +QString RectangleTool::description() const { return tr("Sets the Rectangle as the paint tool"); } -CaptureTool::ToolWorkType RectangleTool::getToolType() { +CaptureTool::ToolWorkType RectangleTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/rectangletool.h b/src/capture/tools/rectangletool.h index c36ec043..b569d7cf 100644 --- a/src/capture/tools/rectangletool.h +++ b/src/capture/tools/rectangletool.h @@ -5,7 +5,7 @@ // Flameshot is free 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) const any later version. // // Flameshot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,20 +26,21 @@ class RectangleTool : public CaptureTool public: explicit RectangleTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // RECTANGLELTOOL_H diff --git a/src/capture/tools/savetool.cpp b/src/capture/tools/savetool.cpp index ee661508..79ff5f07 100644 --- a/src/capture/tools/savetool.cpp +++ b/src/capture/tools/savetool.cpp @@ -22,23 +22,27 @@ SaveTool::SaveTool(QObject *parent) : CaptureTool(parent) { } -bool SaveTool::isSelectable() { +int SaveTool::id() const { + return 0; +} + +bool SaveTool::isSelectable() const { return false; } -QString SaveTool::getIconName() { +QString SaveTool::iconName() const { return "content-save.png"; } -QString SaveTool::getName() { +QString SaveTool::name() const { return tr("Save"); } -QString SaveTool::getDescription() { +QString SaveTool::description() const { return tr("Save the capture"); } -CaptureTool::ToolWorkType SaveTool::getToolType() { +CaptureTool::ToolWorkType SaveTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/savetool.h b/src/capture/tools/savetool.h index 7c6d4b29..c6f9f150 100644 --- a/src/capture/tools/savetool.h +++ b/src/capture/tools/savetool.h @@ -26,20 +26,21 @@ class SaveTool : public CaptureTool public: explicit SaveTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // SAVETOOL_H diff --git a/src/capture/tools/selectiontool.cpp b/src/capture/tools/selectiontool.cpp index 9ad66acb..e169beb2 100644 --- a/src/capture/tools/selectiontool.cpp +++ b/src/capture/tools/selectiontool.cpp @@ -22,23 +22,27 @@ SelectionTool::SelectionTool(QObject *parent) : CaptureTool(parent) { } -bool SelectionTool::isSelectable() { +int SelectionTool::id() const { + return 0; +} + +bool SelectionTool::isSelectable() const { return true; } -QString SelectionTool::getIconName() { +QString SelectionTool::iconName() const { return "square-outline.png"; } -QString SelectionTool::getName() { +QString SelectionTool::name() const { return tr("Rectangular Selection"); } -QString SelectionTool::getDescription() { +QString SelectionTool::description() const { return tr("Sets the Selection as the paint tool"); } -CaptureTool::ToolWorkType SelectionTool::getToolType() { +CaptureTool::ToolWorkType SelectionTool::toolType() const { return TYPE_LINE_DRAWER; } diff --git a/src/capture/tools/selectiontool.h b/src/capture/tools/selectiontool.h index c8317c3c..1a3ab5c2 100644 --- a/src/capture/tools/selectiontool.h +++ b/src/capture/tools/selectiontool.h @@ -26,20 +26,21 @@ class SelectionTool : public CaptureTool public: explicit SelectionTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // SELECTIONTOOL_H diff --git a/src/capture/tools/sizeindicatortool.cpp b/src/capture/tools/sizeindicatortool.cpp index 38faff8b..631fd2ef 100644 --- a/src/capture/tools/sizeindicatortool.cpp +++ b/src/capture/tools/sizeindicatortool.cpp @@ -22,23 +22,27 @@ SizeIndicatorTool::SizeIndicatorTool(QObject *parent) : CaptureTool(parent) { } -bool SizeIndicatorTool::isSelectable() { +int SizeIndicatorTool::id() const { + return 0; +} + +bool SizeIndicatorTool::isSelectable() const { return false; } -QString SizeIndicatorTool::getIconName() { - return ""; +QString SizeIndicatorTool::iconName() const { + return QString(); } -QString SizeIndicatorTool::getName() { +QString SizeIndicatorTool::name() const { return tr("Selection Size Indicator"); } -QString SizeIndicatorTool::getDescription() { +QString SizeIndicatorTool::description() const { return tr("Shows the dimensions of the selection (X Y)"); } -CaptureTool::ToolWorkType SizeIndicatorTool::getToolType() { +CaptureTool::ToolWorkType SizeIndicatorTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/sizeindicatortool.h b/src/capture/tools/sizeindicatortool.h index 24316f5a..2f6be085 100644 --- a/src/capture/tools/sizeindicatortool.h +++ b/src/capture/tools/sizeindicatortool.h @@ -26,20 +26,21 @@ class SizeIndicatorTool : public CaptureTool public: explicit SizeIndicatorTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // SIZEINDICATORTOOL_H diff --git a/src/capture/tools/toolfactory.h b/src/capture/tools/toolfactory.h index b29d2a47..50dd0268 100644 --- a/src/capture/tools/toolfactory.h +++ b/src/capture/tools/toolfactory.h @@ -41,8 +41,7 @@ public: CaptureTool* CreateTool( CaptureButton::ButtonType t, QObject *parent = nullptr); -private: - //void registerTool(); + }; #endif // TOOLFACTORY_H diff --git a/src/capture/tools/undotool.cpp b/src/capture/tools/undotool.cpp index 553dfb71..c19e70df 100644 --- a/src/capture/tools/undotool.cpp +++ b/src/capture/tools/undotool.cpp @@ -22,23 +22,27 @@ UndoTool::UndoTool(QObject *parent) : CaptureTool(parent) { } -bool UndoTool::isSelectable() { +int UndoTool::id() const { + return 0; +} + +bool UndoTool::isSelectable() const { return false; } -QString UndoTool::getIconName() { +QString UndoTool::iconName() const { return "undo-variant.png"; } -QString UndoTool::getName() { +QString UndoTool::name() const { return tr("Undo"); } -QString UndoTool::getDescription() { +QString UndoTool::description() const { return tr("Undo the last modification"); } -CaptureTool::ToolWorkType UndoTool::getToolType() { +CaptureTool::ToolWorkType UndoTool::toolType() const { return TYPE_WORKER; } diff --git a/src/capture/tools/undotool.h b/src/capture/tools/undotool.h index 0efd81b0..b531310a 100644 --- a/src/capture/tools/undotool.h +++ b/src/capture/tools/undotool.h @@ -26,20 +26,21 @@ class UndoTool : public CaptureTool public: explicit UndoTool(QObject *parent = nullptr); - int getID(); - bool isSelectable(); - ToolWorkType getToolType(); + int id() const override; + bool isSelectable() const override; + ToolWorkType toolType() const override; - QString getIconName(); - QString getName(); - QString getDescription(); + QString iconName() const override; + QString name() const override; + QString description() const override; void processImage( QPainter &painter, const QVector &points, - const QColor &color); + const QColor &color) override; + + void onPressed() override; - void onPressed(); }; #endif // UNDOTOOL_H diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 4acfb9e2..662dd6a8 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -37,7 +37,7 @@ auto helpOption = CommandOption({"h", "help"}, inline QStringList addDashToOptionNames(const QStringList &names) { QStringList dashedNames; - for (QString name: names) { + for (const QString &name: names) { // prepend "-" to single character options, and "--" to the others QString dashedName = (name.length() == 1) ? QString("-%1").arg(name) : @@ -56,7 +56,7 @@ QString optionsToString(const QList &options, for (auto const &option: options) { QStringList dashedOptions = addDashToOptionNames(option.names()); QString joinedDashedOptions = dashedOptions.join(", "); - if(!option.valueName().isEmpty()) { + if (!option.valueName().isEmpty()) { joinedDashedOptions += QString(" <%1>") .arg(option.valueName()); } @@ -79,7 +79,7 @@ QString optionsToString(const QList &options, .arg(dashedOptionList.at(i).leftJustified(size, ' ')) .arg(options.at(i).description()); } - if(!arguments.isEmpty()) { + if (!arguments.isEmpty()) { result += "\n"; } } @@ -94,7 +94,7 @@ QString optionsToString(const QList &options, return result; } -} // namespace +} // unnamed namespace bool CommandLineParser::processArgs(const QStringList &args, QStringList::const_iterator &actualIt, @@ -134,7 +134,7 @@ bool CommandLineParser::processOptions(const QStringList &args, bool isDoubleDashed = arg.startsWith("--"); ok = isDoubleDashed ? arg.length() > 3 : arg.length() == 2; - if(!ok) { + if (!ok) { out << QString("the option %1 has a wrong format.").arg(arg); return ok; } diff --git a/src/config/buttonlistview.cpp b/src/config/buttonlistview.cpp index d69055aa..f5c418e0 100644 --- a/src/config/buttonlistview.cpp +++ b/src/config/buttonlistview.cpp @@ -35,11 +35,11 @@ void ButtonListView::initButtonList() { ToolFactory factory; auto listTypes = CaptureButton::getIterableButtonTypes(); - for (CaptureButton::ButtonType t: listTypes) { + for (const CaptureButton::ButtonType t: listTypes) { CaptureTool *tool = factory.CreateTool(t); // add element to the local map - m_buttonTypeByName.insert(tool->getName(), t); + m_buttonTypeByName.insert(tool->name(), t); // init the menu option QListWidgetItem *m_buttonItem = new QListWidgetItem(this); @@ -48,7 +48,7 @@ void ButtonListView::initButtonList() { QColor bgColor = this->palette().color(QWidget::backgroundRole()); QString color = bgColor.valueF() < 0.6 ? "White" : "Black"; QString iconPath = QString(":/img/buttonIcons%1/%2") - .arg(color).arg(tool->getIconName()); + .arg(color).arg(tool->iconName()); if (t == CaptureButton::TYPE_SELECTIONINDICATOR) { iconPath = QString(":/img/buttonIcons%1/size_indicator.png") .arg(color); @@ -59,8 +59,8 @@ void ButtonListView::initButtonList() { QColor foregroundColor = this->palette().color(QWidget::foregroundRole()); m_buttonItem->setForeground(foregroundColor); - m_buttonItem->setText(tool->getName()); - m_buttonItem->setToolTip(tool->getDescription()); + m_buttonItem->setText(tool->name()); + m_buttonItem->setToolTip(tool->description()); tool->deleteLater(); } } @@ -75,7 +75,6 @@ void ButtonListView::updateActiveButtons(QListWidgetItem *item) { } else { m_listButtons.removeOne(buttonIndex); } - qDebug("updateActiveButtons"); QSettings().setValue("buttons", QVariant::fromValue(m_listButtons)); } diff --git a/src/config/buttonlistview.h b/src/config/buttonlistview.h index bb6915cb..e9586164 100644 --- a/src/config/buttonlistview.h +++ b/src/config/buttonlistview.h @@ -40,6 +40,7 @@ private: QMap m_buttonTypeByName; void updateActiveButtons(QListWidgetItem *); + }; #endif // BUTTONLISTVIEW_H diff --git a/src/config/clickablelabel.h b/src/config/clickablelabel.h index d23b6f8c..5cfe60e6 100644 --- a/src/config/clickablelabel.h +++ b/src/config/clickablelabel.h @@ -32,6 +32,7 @@ signals: private: void mousePressEvent (QMouseEvent *); + }; #endif // CLICKABLELABEL_H diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index ffefd5ec..d95541e6 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -28,7 +28,6 @@ #include #include #include -#include // ConfigWindow contains the menus where you can configure the application @@ -47,7 +46,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) { } }; m_configWatcher = new QFileSystemWatcher(this); - m_configWatcher->addPath(ConfigHandler().getConfigFilePath()); + m_configWatcher->addPath(ConfigHandler().configFilePath()); connect(m_configWatcher, &QFileSystemWatcher::fileChanged, this, changedSlot); diff --git a/src/config/filenameeditor.cpp b/src/config/filenameeditor.cpp index 41511bda..d2380be4 100644 --- a/src/config/filenameeditor.cpp +++ b/src/config/filenameeditor.cpp @@ -86,7 +86,7 @@ void FileNameEditor::initWidgets() { // clear m_clearButton = new QPushButton(tr("Clear"), this); connect(m_clearButton, &QPushButton::clicked, this, - [this](){ m_nameEditor->setText(""); + [this](){ m_nameEditor->setText(QString()); }); m_clearButton->setToolTip(tr("Deletes the name"));} @@ -101,7 +101,7 @@ void FileNameEditor::showParsedPattern(const QString &p) { } void FileNameEditor::resetName() { - m_nameEditor->setText(ConfigHandler().getFilenamePattern()); + m_nameEditor->setText(ConfigHandler().filenamePatternValue()); } void FileNameEditor::addToNameEditor(QString s) { @@ -110,6 +110,6 @@ void FileNameEditor::addToNameEditor(QString s) { } void FileNameEditor::updateComponents() { - m_nameEditor->setText(ConfigHandler().getFilenamePattern()); - m_outputLabel->setText(m_nameHandler->getParsedPattern()); + m_nameEditor->setText(ConfigHandler().filenamePatternValue()); + m_outputLabel->setText(m_nameHandler->parsedPattern()); } diff --git a/src/config/filenameeditor.h b/src/config/filenameeditor.h index f7da683a..3a4374e1 100644 --- a/src/config/filenameeditor.h +++ b/src/config/filenameeditor.h @@ -54,6 +54,7 @@ private slots: void savePattern(); void showParsedPattern(const QString &); void resetName(); + }; #endif // FILENAMEEDITOR_H diff --git a/src/config/geneneralconf.cpp b/src/config/geneneralconf.cpp index 39f53517..783a3fb3 100644 --- a/src/config/geneneralconf.cpp +++ b/src/config/geneneralconf.cpp @@ -32,9 +32,9 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QGroupBox(parent) { void GeneneralConf::updateComponents() { ConfigHandler config; - m_helpMessage->setChecked(config.getShowHelp()); - m_showTray->setChecked(!config.getDisabledTrayIcon()); - m_sysNotifications->setChecked(config.getDesktopNotification()); + m_helpMessage->setChecked(config.showHelpValue()); + m_showTray->setChecked(!config.disabledTrayIconValue()); + m_sysNotifications->setChecked(config.desktopNotificationValue()); } void GeneneralConf::showHelpChanged(bool checked) { @@ -47,7 +47,7 @@ void GeneneralConf::showDesktopNotificationChanged(bool checked) { void GeneneralConf::showTrayIconChanged(bool checked) { auto controller = Controller::getInstance(); - if(checked) { + if (checked) { controller->enableTrayIcon(); } else { controller->disableTrayIcon(); @@ -57,7 +57,7 @@ void GeneneralConf::showTrayIconChanged(bool checked) { void GeneneralConf::initShowHelp() { m_helpMessage = new QCheckBox(tr("Show help message"), this); ConfigHandler config; - bool checked = config.getShowHelp(); + bool checked = config.showHelpValue(); m_helpMessage->setChecked(checked); m_helpMessage->setToolTip(tr("Show the help message at the beginning " "in the capture mode.")); @@ -71,7 +71,7 @@ void GeneneralConf::initShowDesktopNotification() { m_sysNotifications = new QCheckBox(tr("Show desktop notifications"), this); ConfigHandler config; - bool checked = config.getDesktopNotification(); + bool checked = config.desktopNotificationValue(); m_sysNotifications->setChecked(checked); m_sysNotifications->setToolTip(tr("Show desktop notifications")); m_layout->addWidget(m_sysNotifications); @@ -83,7 +83,7 @@ void GeneneralConf::initShowDesktopNotification() { void GeneneralConf::initShowTrayIcon() { m_showTray = new QCheckBox(tr("Show tray icon"), this); ConfigHandler config; - bool checked = !config.getDisabledTrayIcon(); + bool checked = !config.disabledTrayIconValue(); m_showTray->setChecked(checked); m_showTray->setToolTip(tr("Show the systemtray icon")); m_layout->addWidget(m_showTray); diff --git a/src/config/geneneralconf.h b/src/config/geneneralconf.h index 5e3aa96a..6aa5c2b9 100644 --- a/src/config/geneneralconf.h +++ b/src/config/geneneralconf.h @@ -45,6 +45,7 @@ private: void initShowHelp(); void initShowDesktopNotification(); void initShowTrayIcon(); + }; #endif // GENENERALCONF_H diff --git a/src/config/strftimechooserwidget.cpp b/src/config/strftimechooserwidget.cpp index c6669112..c862024f 100644 --- a/src/config/strftimechooserwidget.cpp +++ b/src/config/strftimechooserwidget.cpp @@ -25,8 +25,8 @@ StrftimeChooserWidget::StrftimeChooserWidget(QWidget *parent) : QWidget(parent) auto k = m_buttonData.keys(); int middle = k.length()/2; // add the buttons in 2 columns (they need to be even) - for(int i = 0; i < 2; i++) { - for(int j = 0; j < middle; j++) { + for (int i = 0; i < 2; i++) { + for (int j = 0; j < middle; j++) { QString key = k.last(); k.pop_back(); QString variable = m_buttonData.value(key); diff --git a/src/config/strftimechooserwidget.h b/src/config/strftimechooserwidget.h index 63d03207..9695dc94 100644 --- a/src/config/strftimechooserwidget.h +++ b/src/config/strftimechooserwidget.h @@ -31,6 +31,7 @@ signals: private: static QMap m_buttonData; + }; #endif // STRFTIMECHOOSERWIDGET_H diff --git a/src/config/uicoloreditor.cpp b/src/config/uicoloreditor.cpp index 69416490..cd761c05 100644 --- a/src/config/uicoloreditor.cpp +++ b/src/config/uicoloreditor.cpp @@ -42,8 +42,8 @@ UIcolorEditor::UIcolorEditor(QWidget *parent) : QGroupBox(parent) { void UIcolorEditor::updateComponents() { ConfigHandler config; - m_uiColor = config.getUIMainColor(); - m_contrastColor = config.getUIContrastColor(); + m_uiColor = config.uiMainColorValue(); + m_contrastColor = config.uiContrastColorValue(); if (m_lastButtonPressed == m_buttonMainColor) { m_colorWheel->setColor(m_uiColor); } else { @@ -91,7 +91,7 @@ void UIcolorEditor::initColorWheel() { void UIcolorEditor::initButtons() { const int extraSize = 10; - int frameSize = CaptureButton::getButtonBaseSize() + extraSize; + int frameSize = CaptureButton::buttonBaseSize() + extraSize; m_vLayout->addWidget(new QLabel(tr("Select a Button to modify it"), this)); @@ -154,6 +154,6 @@ void UIcolorEditor::changeLastButton(CaptureButton *b) { m_labelContrast->setStyleSheet(styleSheet()); m_labelMain->setStyleSheet(offStyle); } - b->setIcon(b->getIcon()); + b->setIcon(b->icon()); } } diff --git a/src/config/uicoloreditor.h b/src/config/uicoloreditor.h index 4a15de42..3a7c342b 100644 --- a/src/config/uicoloreditor.h +++ b/src/config/uicoloreditor.h @@ -56,6 +56,7 @@ private: void initColorWheel(); void initButtons(); + }; #endif // UICOLORPICKER_H diff --git a/src/core/controller.cpp b/src/core/controller.cpp index e2c4dc1e..6df7ddd2 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -35,13 +35,13 @@ Controller::Controller() : m_captureWindow(nullptr) qApp->setQuitOnLastWindowClosed(false); // init tray icon - if(!ConfigHandler().getDisabledTrayIcon()) { + if (!ConfigHandler().disabledTrayIconValue()) { enableTrayIcon(); } initDefaults(); - QString StyleSheet = CaptureButton::getGlobalStyleSheet(); + QString StyleSheet = CaptureButton::globalStyleSheet(); qApp->setStyleSheet(StyleSheet); } @@ -96,7 +96,7 @@ void Controller::openInfoWindow() { } void Controller::enableTrayIcon() { - if(m_trayIcon) { + if (m_trayIcon) { return; } ConfigHandler().setDisabledTrayIcon(false); @@ -138,7 +138,7 @@ void Controller::disableTrayIcon() { } void Controller::updateConfigComponents() { - if(m_configWindow) { + if (m_configWindow) { m_configWindow->updateComponents(); } } diff --git a/src/core/controller.h b/src/core/controller.h index dec8e862..83086d30 100644 --- a/src/core/controller.h +++ b/src/core/controller.h @@ -36,9 +36,9 @@ public: void operator =(const Controller&) = delete; public slots: - QString saveScreenshot(const QString &path = "", + QString saveScreenshot(const QString &path = QString(), bool const toClipboard = false); - void createVisualCapture(const QString &forcedSavePath = ""); + void createVisualCapture(const QString &forcedSavePath = QString()); void openConfigWindow(); void openInfoWindow(); @@ -54,12 +54,14 @@ private slots: private: Controller(); - QPointer createCaptureWidget(const QString &forcedSavePath = ""); + QPointer createCaptureWidget( + const QString &forcedSavePath = QString()); QPointer m_captureWindow; QPointer m_infoWindow; QPointer m_configWindow; QPointer m_trayIcon; + }; #endif // CONTROLLER_H diff --git a/src/infowindow.cpp b/src/infowindow.cpp index 847f38a7..b01af737 100644 --- a/src/infowindow.cpp +++ b/src/infowindow.cpp @@ -58,7 +58,6 @@ QVector InfoWindow::m_description = { QT_TR_NOOP("Show color picker") }; -#include void InfoWindow::initInfoTable() { QTableWidget *table = new QTableWidget(this); table->setToolTip(tr("Available shorcuts in the screen capture mode.")); diff --git a/src/infowindow.h b/src/infowindow.h index b88f64b9..ee14d547 100644 --- a/src/infowindow.h +++ b/src/infowindow.h @@ -37,6 +37,7 @@ private: static QVector m_keys; static QVector m_description; + }; #endif // INFOWINDOW_H diff --git a/src/main.cpp b/src/main.cpp index 4192626a..1bab3e2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { FileNameHandler fh; qInfo().noquote() << QString("The new pattern is '%1'\n" "Parsed pattern example: %2").arg(newFilename) - .arg(fh.getParsedPattern()); + .arg(fh.parsedPattern()); } if (tray) { QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot", diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 2b541725..ff3ad7fd 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -34,11 +34,10 @@ QList ConfigHandler::getButtons() { void ConfigHandler::setButtons(const QList &buttons) { QList l = fromButtonToInt(buttons); normalizeButtons(l); - qDebug("setButtons"); m_settings->setValue("buttons", QVariant::fromValue(l)); } -QString ConfigHandler::getSavePath() { +QString ConfigHandler::savePathValue() { return m_settings->value("savePath").toString(); } @@ -46,7 +45,7 @@ void ConfigHandler::setSavePath(const QString &savePath) { m_settings->setValue("savePath", savePath); } -QColor ConfigHandler::getUIMainColor() { +QColor ConfigHandler::uiMainColorValue() { return m_settings->value("uiColor").value(); } @@ -54,7 +53,7 @@ void ConfigHandler::setUIMainColor(const QColor &c) { m_settings->setValue("uiColor", c); } -QColor ConfigHandler::getUIContrastColor() { +QColor ConfigHandler::uiContrastColorValue() { return m_settings->value("contastUiColor").value(); } @@ -62,7 +61,7 @@ void ConfigHandler::setUIContrastColor(const QColor &c) { m_settings->setValue("contastUiColor", c); } -QColor ConfigHandler::getDrawColor() { +QColor ConfigHandler::drawColorValue() { return m_settings->value("drawColor").value(); } @@ -70,7 +69,7 @@ void ConfigHandler::setDrawColor(const QColor &c) { m_settings->setValue("drawColor", c); } -bool ConfigHandler::getShowHelp() { +bool ConfigHandler::showHelpValue() { return m_settings->value("showHelp").toBool(); } @@ -78,7 +77,7 @@ void ConfigHandler::setShowHelp(const bool showHelp) { m_settings->setValue("showHelp", showHelp); } -bool ConfigHandler::getDesktopNotification() { +bool ConfigHandler::desktopNotificationValue() { return m_settings->value("showDesktopNotification").toBool(); } @@ -86,7 +85,7 @@ void ConfigHandler::setDesktopNotification(const bool showDesktopNotification) { m_settings->setValue("showDesktopNotification", showDesktopNotification); } -QString ConfigHandler::getFilenamePattern() { +QString ConfigHandler::filenamePatternValue() { return m_settings->value("filenamePattern").toString(); } @@ -94,7 +93,7 @@ void ConfigHandler::setFilenamePattern(const QString &pattern) { return m_settings->setValue("filenamePattern", pattern); } -bool ConfigHandler::getDisabledTrayIcon() { +bool ConfigHandler::disabledTrayIconValue() { return m_settings->value("disabledTrayIcon").toBool(); } @@ -126,13 +125,13 @@ void ConfigHandler::setDefaults() { void ConfigHandler::setAllTheButtons() { QList buttons; auto listTypes = CaptureButton::getIterableButtonTypes(); - for (CaptureButton::ButtonType t: listTypes) { + for (const CaptureButton::ButtonType t: listTypes) { buttons << static_cast(t); } m_settings->setValue("buttons", QVariant::fromValue(buttons)); } -QString ConfigHandler::getConfigFilePath() const { +QString ConfigHandler::configFilePath() const { return m_settings->fileName(); } @@ -156,7 +155,7 @@ QList ConfigHandler::fromIntToButton( const QList &l) { QList buttons; - for(auto i: l) + for (auto const i: l) buttons << static_cast(i); return buttons; } @@ -165,7 +164,7 @@ QList ConfigHandler::fromButtonToInt( const QList &l) { QList buttons; - for(auto i: l) + for (auto const i: l) buttons << static_cast(i); return buttons; } diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index f977fe2f..1161cc76 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -33,28 +33,28 @@ public: QList getButtons(); void setButtons(const QList &); - QString getSavePath(); + QString savePathValue(); void setSavePath(const QString &); - QColor getUIMainColor(); + QColor uiMainColorValue(); void setUIMainColor(const QColor &); - QColor getUIContrastColor(); + QColor uiContrastColorValue(); void setUIContrastColor(const QColor &); - QColor getDrawColor(); + QColor drawColorValue(); void setDrawColor(const QColor &); - bool getShowHelp(); + bool showHelpValue(); void setShowHelp(const bool); - bool getDesktopNotification(); + bool desktopNotificationValue(); void setDesktopNotification(const bool); - QString getFilenamePattern(); + QString filenamePatternValue(); void setFilenamePattern(const QString &); - bool getDisabledTrayIcon(); + bool disabledTrayIconValue(); void setDisabledTrayIcon(const bool); bool initiatedIsSet(); @@ -64,7 +64,7 @@ public: void setAllTheButtons(); - QString getConfigFilePath() const; + QString configFilePath() const; private: QSettings *m_settings; diff --git a/src/utils/filenamehandler.cpp b/src/utils/filenamehandler.cpp index 29041f39..22e46d09 100644 --- a/src/utils/filenamehandler.cpp +++ b/src/utils/filenamehandler.cpp @@ -26,8 +26,8 @@ FileNameHandler::FileNameHandler(QObject *parent) : QObject(parent) { std::locale::global(std::locale(std::locale("").name())); } -QString FileNameHandler::getParsedPattern() { - return parseFilename(ConfigHandler().getFilenamePattern()); +QString FileNameHandler::parsedPattern() { + return parseFilename(ConfigHandler().filenamePatternValue()); } QString FileNameHandler::parseFilename(const QString &name) { @@ -51,21 +51,21 @@ void FileNameHandler::savePattern(const QString &pattern) { ConfigHandler().setFilenamePattern(pattern); } -QString FileNameHandler::getAbsoluteSavePath() { +QString FileNameHandler::absoluteSavePath() { ConfigHandler config; - QString savePath = config.getSavePath(); + QString savePath = config.savePathValue(); bool changed = false; if (savePath.isEmpty() || !QDir(savePath).exists() || !QFileInfo(savePath).isWritable()) { changed = true; savePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); } - if(changed) { + if (changed) { config.setSavePath(savePath); } // first add slash if needed QString tempName = savePath.endsWith("/") ? "" : "/"; // add the parsed pattern in a correct format for the filesystem - tempName += FileNameHandler().getParsedPattern().replace("/", "⁄"); + tempName += FileNameHandler().parsedPattern().replace("/", "⁄"); // find unused name adding _n where n is a number QFileInfo checkFile(savePath + tempName + ".png"); if (checkFile.exists()) { diff --git a/src/utils/filenamehandler.h b/src/utils/filenamehandler.h index 2b3f19ae..7e8d5f29 100644 --- a/src/utils/filenamehandler.h +++ b/src/utils/filenamehandler.h @@ -27,19 +27,20 @@ class FileNameHandler : public QObject public: explicit FileNameHandler(QObject *parent = nullptr); - QString getParsedPattern(); + QString parsedPattern(); QString parseFilename(const QString &name); static const int MAX_CHARACTERS = 70; public slots: void savePattern(const QString &pattern); - QString getAbsoluteSavePath(); + QString absoluteSavePath(); private: //using charArr = char[MAX_CHARACTERS]; inline QString charArrToQString(const char *c); inline char * QStringTocharArr(const QString &s); + }; #endif // FILENAMEHANDLER_H diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 3c0b049a..40725cff 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -18,7 +18,7 @@ void SystemNotification::sendMessage( const QString &title, const int timeout) { - if(!ConfigHandler().getDesktopNotification()) { + if(!ConfigHandler().desktopNotificationValue()) { return; } diff --git a/src/utils/systemnotification.h b/src/utils/systemnotification.h index 54320c6f..9efa30e6 100644 --- a/src/utils/systemnotification.h +++ b/src/utils/systemnotification.h @@ -15,12 +15,9 @@ public: const QString &title = "Flameshot Info", const int timeout = 5000); -signals: - -public slots: - private: QDBusInterface *m_interface; + }; #endif // SYSTEMNOTIFICATION_H