general cleanup
-use of the override keyword -delete unused code -const correctness -more uniform code style -for each with const references when possible -getters no longer use the word 'get' -others
This commit is contained in:
@@ -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
|
||||
@@ -29,7 +29,7 @@ ButtonHandler::ButtonHandler(const QVector<CaptureButton*> &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<QPoint> positions = getHPoints(center, addCounter, true);
|
||||
for (QPoint p: positions) {
|
||||
QVector<QPoint> 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<QPoint> positions = getVPoints(center, addCounter, false);
|
||||
for (QPoint p: positions) {
|
||||
QVector<QPoint> 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<QPoint> positions = getHPoints(center, addCounter, false);
|
||||
for (QPoint p: positions) {
|
||||
QVector<QPoint> 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<QPoint> positions = getVPoints(center, addCounter, true);
|
||||
for (QPoint p: positions) {
|
||||
QVector<QPoint> 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<QPoint> ButtonHandler::getHPoints(
|
||||
QVector<QPoint> ButtonHandler::horizontalPoints(
|
||||
const QPoint ¢er, const int elements, const bool leftToRight) const
|
||||
{
|
||||
QVector<QPoint> res;
|
||||
@@ -289,7 +289,7 @@ QVector<QPoint> 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<QPoint> ButtonHandler::getVPoints(
|
||||
QVector<QPoint> ButtonHandler::verticalPoints(
|
||||
const QPoint ¢er, const int elements,const bool upToDown) const
|
||||
{
|
||||
QVector<QPoint> res;
|
||||
@@ -328,7 +328,7 @@ void ButtonHandler::setButtons(const QVector<CaptureButton *> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
bool contains(const QPoint &p) const;
|
||||
|
||||
private:
|
||||
QVector<QPoint> getHPoints(const QPoint ¢er, const int elements,
|
||||
QVector<QPoint> horizontalPoints(const QPoint ¢er, const int elements,
|
||||
const bool leftToRight) const;
|
||||
QVector<QPoint> getVPoints(const QPoint ¢er, const int elements,
|
||||
QVector<QPoint> verticalPoints(const QPoint ¢er, const int elements,
|
||||
const bool upToDown) const;
|
||||
QVector<CaptureButton*> m_vectorButtons;
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
|
||||
QRegion m_region;
|
||||
void addToRegion(const QVector<QPoint> &points);
|
||||
|
||||
};
|
||||
|
||||
#endif // BUTTONHANDLER_H
|
||||
|
||||
@@ -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::ButtonType> 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::ButtonType> CaptureButton::iterableButtonTypes = {
|
||||
CaptureButton::TYPE_PENCIL,
|
||||
|
||||
@@ -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<CaptureButton::ButtonType> 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
|
||||
|
||||
@@ -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<QPoint> CaptureModification::getPoints() const {
|
||||
QVector<QPoint> 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);
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
const QColor &,
|
||||
QObject *parent = nullptr
|
||||
);
|
||||
QColor getColor() const;
|
||||
QVector<QPoint> getPoints() const;
|
||||
CaptureTool* getTool() const;
|
||||
CaptureButton::ButtonType getType() const;
|
||||
QColor color() const;
|
||||
QVector<QPoint> points() const;
|
||||
CaptureTool* tool() const;
|
||||
CaptureButton::ButtonType buttonType() const;
|
||||
void addPoint(const QPoint);
|
||||
|
||||
protected:
|
||||
@@ -47,8 +47,6 @@ protected:
|
||||
QVector<QPoint> m_coords;
|
||||
CaptureTool *m_tool;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // CAPTURECHANGE_H
|
||||
|
||||
@@ -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<CaptureButton*> 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,
|
||||
|
||||
@@ -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<CaptureModification*> m_modifications;
|
||||
QPointer<CaptureButton> m_sizeIndButton;
|
||||
QPointer<CaptureButton> m_lastPressedButton;
|
||||
@@ -123,6 +123,7 @@ private:
|
||||
QColor m_uiColor;
|
||||
QColor m_contrastUiColor;
|
||||
ColorPicker *m_colorPicker;
|
||||
|
||||
};
|
||||
|
||||
#endif // CAPTUREWIDGET_H
|
||||
|
||||
@@ -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<QRect> 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<QRect> ColorPicker::handleMask() const {
|
||||
QVector<QRect> areas;
|
||||
for(QRect rect: m_colorAreaList) {
|
||||
for (const QRect &rect: m_colorAreaList) {
|
||||
areas.append(rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QRect> handleMask() const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
const int m_colorAreaSize;
|
||||
QVector<QRect> m_colorAreaList;
|
||||
static QVector<Qt::GlobalColor> colorList;
|
||||
|
||||
QColor m_uiColor, m_drawColor;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORPICKER_H
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@ public:
|
||||
explicit ScreenGrabber(QObject *parent = nullptr);
|
||||
QPixmap grabEntireDesktop();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // SCREENGRABBER_H
|
||||
|
||||
@@ -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<CaptureModification*> &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<QPoint> &points = modification->getPoints();
|
||||
QColor color = modification->getColor();
|
||||
modification->getTool()->processImage(painter, points, color);
|
||||
const QVector<QPoint> &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;
|
||||
|
||||
@@ -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<QNetworkAccessManager> m_accessManager;
|
||||
|
||||
void paintInPainter(QPainter &, const CaptureModification *);
|
||||
|
||||
};
|
||||
|
||||
#endif // SCREENSHOT_H
|
||||
|
||||
@@ -19,65 +19,70 @@
|
||||
#include <QPainter>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed();
|
||||
void onPressed() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // CIRCLETOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // COPYTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // EXITTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // IMGURUPLOADERTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // MOVETOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // PENCILTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // RECTANGLELTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // SAVETOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // SELECTIONTOOL_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // SIZEINDICATORTOOL_H
|
||||
|
||||
@@ -41,8 +41,7 @@ public:
|
||||
CaptureTool* CreateTool(
|
||||
CaptureButton::ButtonType t,
|
||||
QObject *parent = nullptr);
|
||||
private:
|
||||
//void registerTool();
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLFACTORY_H
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<QPoint> &points,
|
||||
const QColor &color);
|
||||
const QColor &color) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
void onPressed();
|
||||
};
|
||||
|
||||
#endif // UNDOTOOL_H
|
||||
|
||||
@@ -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<CommandOption> &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<CommandOption> &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<CommandOption> &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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ private:
|
||||
QMap<QString, CaptureButton::ButtonType> m_buttonTypeByName;
|
||||
|
||||
void updateActiveButtons(QListWidgetItem *);
|
||||
|
||||
};
|
||||
|
||||
#endif // BUTTONLISTVIEW_H
|
||||
|
||||
@@ -32,6 +32,7 @@ signals:
|
||||
|
||||
private:
|
||||
void mousePressEvent (QMouseEvent *);
|
||||
|
||||
};
|
||||
|
||||
#endif // CLICKABLELABEL_H
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <QLabel>
|
||||
#include <QKeyEvent>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QDebug>
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ private slots:
|
||||
void savePattern();
|
||||
void showParsedPattern(const QString &);
|
||||
void resetName();
|
||||
|
||||
};
|
||||
|
||||
#endif // FILENAMEEDITOR_H
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
void initShowHelp();
|
||||
void initShowDesktopNotification();
|
||||
void initShowTrayIcon();
|
||||
|
||||
};
|
||||
|
||||
#endif // GENENERALCONF_H
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -31,6 +31,7 @@ signals:
|
||||
|
||||
private:
|
||||
static QMap<QString, QString> m_buttonData;
|
||||
|
||||
};
|
||||
|
||||
#endif // STRFTIMECHOOSERWIDGET_H
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ private:
|
||||
|
||||
void initColorWheel();
|
||||
void initButtons();
|
||||
|
||||
};
|
||||
|
||||
#endif // UICOLORPICKER_H
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CaptureWidget> createCaptureWidget(const QString &forcedSavePath = "");
|
||||
QPointer<CaptureWidget> createCaptureWidget(
|
||||
const QString &forcedSavePath = QString());
|
||||
|
||||
QPointer<CaptureWidget> m_captureWindow;
|
||||
QPointer<InfoWindow> m_infoWindow;
|
||||
QPointer<ConfigWindow> m_configWindow;
|
||||
QPointer<QSystemTrayIcon> m_trayIcon;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
@@ -58,7 +58,6 @@ QVector<const char *> InfoWindow::m_description = {
|
||||
QT_TR_NOOP("Show color picker")
|
||||
};
|
||||
|
||||
#include <QDebug>
|
||||
void InfoWindow::initInfoTable() {
|
||||
QTableWidget *table = new QTableWidget(this);
|
||||
table->setToolTip(tr("Available shorcuts in the screen capture mode."));
|
||||
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
|
||||
static QVector<const char *> m_keys;
|
||||
static QVector<const char *> m_description;
|
||||
|
||||
};
|
||||
|
||||
#endif // INFOWINDOW_H
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -34,11 +34,10 @@ QList<CaptureButton::ButtonType> ConfigHandler::getButtons() {
|
||||
void ConfigHandler::setButtons(const QList<CaptureButton::ButtonType> &buttons) {
|
||||
QList<int> 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<QColor>();
|
||||
}
|
||||
|
||||
@@ -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<QColor>();
|
||||
}
|
||||
|
||||
@@ -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<QColor>();
|
||||
}
|
||||
|
||||
@@ -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<int> buttons;
|
||||
auto listTypes = CaptureButton::getIterableButtonTypes();
|
||||
for (CaptureButton::ButtonType t: listTypes) {
|
||||
for (const CaptureButton::ButtonType t: listTypes) {
|
||||
buttons << static_cast<int>(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<CaptureButton::ButtonType> ConfigHandler::fromIntToButton(
|
||||
const QList<int> &l)
|
||||
{
|
||||
QList<CaptureButton::ButtonType> buttons;
|
||||
for(auto i: l)
|
||||
for (auto const i: l)
|
||||
buttons << static_cast<CaptureButton::ButtonType>(i);
|
||||
return buttons;
|
||||
}
|
||||
@@ -165,7 +164,7 @@ QList<int> ConfigHandler::fromButtonToInt(
|
||||
const QList<CaptureButton::ButtonType> &l)
|
||||
{
|
||||
QList<int> buttons;
|
||||
for(auto i: l)
|
||||
for (auto const i: l)
|
||||
buttons << static_cast<int>(i);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -33,28 +33,28 @@ public:
|
||||
QList<CaptureButton::ButtonType> getButtons();
|
||||
void setButtons(const QList<CaptureButton::ButtonType> &);
|
||||
|
||||
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;
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,7 +18,7 @@ void SystemNotification::sendMessage(
|
||||
const QString &title,
|
||||
const int timeout)
|
||||
{
|
||||
if(!ConfigHandler().getDesktopNotification()) {
|
||||
if(!ConfigHandler().desktopNotificationValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,9 @@ public:
|
||||
const QString &title = "Flameshot Info",
|
||||
const int timeout = 5000);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QDBusInterface *m_interface;
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSTEMNOTIFICATION_H
|
||||
|
||||
Reference in New Issue
Block a user