forked from flameshot-org/flameshot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to cache the last region (flameshot-org#2615)
* Added the ability to cache the last region * adding cli option * addressed typo comments and applied clang-format (cherry picked from commit 46801d9)
- Loading branch information
1 parent
b0bb2a5
commit 2a02b95
Showing
15 changed files
with
144 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
target_sources( | ||
flameshot | ||
PRIVATE buttonlistview.cpp | ||
cacheutils.cpp | ||
clickablelabel.cpp | ||
configwindow.cpp | ||
configresolver.cpp | ||
colorpickereditmode.cpp | ||
colorpickereditor.cpp | ||
configerrordetails.cpp | ||
configresolver.cpp | ||
configwindow.cpp | ||
extendedslider.cpp | ||
filenameeditor.cpp | ||
generalconf.cpp | ||
setshortcutwidget.cpp | ||
shortcutswidget.cpp | ||
strftimechooserwidget.cpp | ||
styleoverride.cpp | ||
uicoloreditor.cpp | ||
colorpickereditor.cpp | ||
visualseditor.cpp | ||
shortcutswidget.cpp | ||
setshortcutwidget.cpp | ||
colorpickereditmode.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// SPDX-FileCopyrightText: 2021 Jeremy Borgman | ||
|
||
#include "cacheutils.h" | ||
#include <QDataStream> | ||
#include <QDir> | ||
#include <QFile> | ||
#include <QRect> | ||
#include <QStandardPaths> | ||
#include <QString> | ||
|
||
QString getCachePath() | ||
{ | ||
auto cachePath = | ||
QStandardPaths::writableLocation(QStandardPaths::CacheLocation); | ||
if (!QDir(cachePath).exists()) { | ||
QDir().mkpath(cachePath); | ||
} | ||
return cachePath; | ||
} | ||
|
||
void setLastRegion(QRect const& newRegion) | ||
{ | ||
auto cachePath = getCachePath() + "/region.txt"; | ||
|
||
QFile file(cachePath); | ||
if (file.open(QIODevice::WriteOnly)) { | ||
QDataStream out(&file); | ||
out << newRegion; | ||
file.close(); | ||
} | ||
} | ||
|
||
QRect getLastRegion() | ||
{ | ||
auto cachePath = getCachePath() + "/region.txt"; | ||
QFile file(cachePath); | ||
|
||
QRect lastRegion; | ||
if (file.open(QIODevice::ReadOnly)) { | ||
QDataStream input(&file); | ||
input >> lastRegion; | ||
file.close(); | ||
} else { | ||
lastRegion = QRect(0, 0, 0, 0); | ||
} | ||
|
||
return lastRegion; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// SPDX-FileCopyrightText: 2021 Jeremy Borgman | ||
|
||
#ifndef FLAMESHOT_CACHEUTILS_H | ||
#define FLAMESHOT_CACHEUTILS_H | ||
|
||
class QString; | ||
class QRect; | ||
|
||
QString getCachePath(); | ||
QRect getLastRegion(); | ||
void setLastRegion(QRect const& newRegion); | ||
|
||
#endif // FLAMESHOT_CACHEUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.