Added the ability to cache the last region (#2615)

* Added the ability to cache the last region

* adding cli option

* addressed typo comments and applied clang-format
This commit is contained in:
borgmanJeremy
2022-06-01 09:18:54 -05:00
committed by GitHub
parent 2582f063cc
commit 46801d933a
15 changed files with 144 additions and 93 deletions

View File

@@ -3,7 +3,6 @@
#include "flameshot.h"
#include "flameshotdaemon.h"
#if defined(Q_OS_MACOS)
#include "external/QHotkey/QHotkey"
#endif
@@ -25,7 +24,6 @@
#include <QApplication>
#include <QBuffer>
#include <QDebug>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QFile>
#include <QMessageBox>
@@ -115,8 +113,6 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req)
}
m_captureWindow = new CaptureWidget(req);
// m_captureWindow = new CaptureWidget(req, false); //
// debug
#ifdef Q_OS_WIN
m_captureWindow->show();
@@ -138,20 +134,16 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req)
void Flameshot::screen(CaptureRequest req, const int screenNumber)
{
if (!resolveAnyConfigErrors())
if (!resolveAnyConfigErrors()) {
return;
}
bool ok = true;
QScreen* screen;
if (screenNumber < 0) {
QPoint globalCursorPos = QCursor::pos();
#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0)
screen = qApp->screenAt(globalCursorPos);
#else
screen =
qApp->screens()[qApp->desktop()->screenNumber(globalCursorPos)];
#endif
} else if (screenNumber >= qApp->screens().count()) {
AbstractLogger() << QObject::tr(
"Requested screen exceeds screen count");
@@ -184,8 +176,9 @@ void Flameshot::screen(CaptureRequest req, const int screenNumber)
void Flameshot::full(const CaptureRequest& req)
{
if (!resolveAnyConfigErrors())
if (!resolveAnyConfigErrors()) {
return;
}
bool ok = true;
QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
@@ -203,10 +196,11 @@ void Flameshot::full(const CaptureRequest& req)
void Flameshot::launcher()
{
if (!resolveAnyConfigErrors())
if (!resolveAnyConfigErrors()) {
return;
}
if (!m_launcherWindow) {
if (m_launcherWindow == nullptr) {
m_launcherWindow = new CaptureLauncher();
}
m_launcherWindow->show();
@@ -218,10 +212,11 @@ void Flameshot::launcher()
void Flameshot::config()
{
if (!resolveAnyConfigErrors())
if (!resolveAnyConfigErrors()) {
return;
}
if (!m_configWindow) {
if (m_configWindow == nullptr) {
m_configWindow = new ConfigWindow();
m_configWindow->show();
#if defined(Q_OS_MACOS)
@@ -233,7 +228,7 @@ void Flameshot::config()
void Flameshot::info()
{
if (!m_infoWindow) {
if (m_infoWindow == nullptr) {
m_infoWindow = new InfoWindow();
#if defined(Q_OS_MACOS)
m_infoWindow->activateWindow();