9
9
10
10
#include " abstractlogger.h"
11
11
#include " src/cli/commandlineparser.h"
12
+ #include " src/config/cacheutils.h"
12
13
#include " src/config/styleoverride.h"
13
14
#include " src/core/capturerequest.h"
14
15
#include " src/core/flameshot.h"
23
24
#include < QSharedMemory>
24
25
#include < QTimer>
25
26
#include < QTranslator>
26
-
27
27
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
28
28
#include " abstractlogger.h"
29
29
#include " src/core/flameshotdbusadapter.h"
@@ -176,6 +176,11 @@ int main(int argc, char* argv[])
176
176
CommandOption delayOption ({ " d" , " delay" },
177
177
QObject::tr (" Delay time in milliseconds" ),
178
178
QStringLiteral (" milliseconds" ));
179
+
180
+ CommandOption useLastRegionOption (
181
+ " last-region" ,
182
+ QObject::tr (" Repeat screenshot with previously selected region" ));
183
+
179
184
CommandOption regionOption (" region" ,
180
185
QObject::tr (" Screenshot region to select" ),
181
186
QStringLiteral (" WxH+X+Y or string" ));
@@ -272,6 +277,7 @@ int main(int argc, char* argv[])
272
277
mainColorOption.addChecker (colorChecker, colorErr);
273
278
delayOption.addChecker (numericChecker, delayErr);
274
279
regionOption.addChecker (regionChecker, regionErr);
280
+ useLastRegionOption.addChecker (booleanChecker, booleanErr);
275
281
pathOption.addChecker (pathChecker, pathErr);
276
282
trayOption.addChecker (booleanChecker, booleanErr);
277
283
autostartOption.addChecker (booleanChecker, booleanErr);
@@ -290,6 +296,7 @@ int main(int argc, char* argv[])
290
296
clipboardOption,
291
297
delayOption,
292
298
regionOption,
299
+ useLastRegionOption,
293
300
rawImageOption,
294
301
selectionOption,
295
302
uploadOption,
@@ -359,6 +366,7 @@ int main(int argc, char* argv[])
359
366
}
360
367
int delay = parser.value (delayOption).toInt ();
361
368
QString region = parser.value (regionOption);
369
+ bool useLastRegion = parser.isSet (useLastRegionOption);
362
370
bool clipboard = parser.isSet (clipboardOption);
363
371
bool raw = parser.isSet (rawImageOption);
364
372
bool printGeometry = parser.isSet (selectionOption);
@@ -367,7 +375,10 @@ int main(int argc, char* argv[])
367
375
bool acceptOnSelect = parser.isSet (acceptOnSelectOption);
368
376
CaptureRequest req (CaptureRequest::GRAPHICAL_MODE, delay, path);
369
377
if (!region.isEmpty ()) {
370
- req.setInitialSelection (Region ().value (region).toRect ());
378
+ auto selectionRegion = Region ().value (region).toRect ();
379
+ req.setInitialSelection (selectionRegion);
380
+ } else if (useLastRegion) {
381
+ req.setInitialSelection (getLastRegion ());
371
382
}
372
383
if (clipboard) {
373
384
req.addTask (CaptureRequest::COPY);
@@ -394,7 +405,6 @@ int main(int argc, char* argv[])
394
405
req.addSaveTask ();
395
406
}
396
407
}
397
-
398
408
requestCaptureAndWait (req);
399
409
} else if (parser.isSet (fullArgument)) { // FULL
400
410
// Recreate the application as a QApplication
0 commit comments