Add --pin, --upload, --accept-on-select to CLI (#1970)

* Add --pin option

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add --upload option

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add --accept-on-select option

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix failing build on MacOS

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Clean up option variable names in main

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Remove missing --path error

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add tests for action options

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix file extension config option

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix --print-geometry bug

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Replace Qt::endl with "\n"

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix copy/upload task clipboard conflict

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix endless loop when using --raw and --delay

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix bug in upload handling

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Show dialog after upload if --clipboard is set

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix failing build on Mac and Win

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
Haris Gušić
2021-10-20 18:48:54 +02:00
committed by GitHub
parent 94ed574f35
commit 988dcab9de
30 changed files with 409 additions and 208 deletions

View File

@@ -166,36 +166,49 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
#endif
}
QRect ScreenGrabber::screenGeometry(int screenNumber)
{
QPixmap p;
QRect geometry;
bool isVirtual = QApplication::desktop()->isVirtualDesktop();
if (isVirtual || m_info.waylandDetected()) {
QPoint topLeft(0, 0);
#ifdef Q_OS_WIN
for (QScreen* const screen : QGuiApplication::screens()) {
QPoint topLeftScreen = screen->geometry().topLeft();
if (topLeft.x() > topLeftScreen.x() ||
topLeft.y() > topLeftScreen.y()) {
topLeft = topLeftScreen;
}
}
#endif
geometry = QApplication::desktop()->screenGeometry(screenNumber);
geometry.moveTo(geometry.topLeft() - topLeft);
} else {
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
geometry = currentScreen->geometry();
}
return geometry;
}
QPixmap ScreenGrabber::grabScreen(int screenNumber, bool& ok)
{
QPixmap p;
bool isVirtual = QApplication::desktop()->isVirtualDesktop();
QRect geometry = screenGeometry(screenNumber);
if (isVirtual || m_info.waylandDetected()) {
p = grabEntireDesktop(ok);
if (ok) {
QPoint topLeft(0, 0);
#ifdef Q_OS_WIN
for (QScreen* const screen : QGuiApplication::screens()) {
QPoint topLeftScreen = screen->geometry().topLeft();
if (topLeft.x() > topLeftScreen.x() ||
topLeft.y() > topLeftScreen.y()) {
topLeft = topLeftScreen;
}
}
#endif
QRect geometry =
QApplication::desktop()->screenGeometry(screenNumber);
geometry.moveTo(geometry.topLeft() - topLeft);
p = p.copy(geometry);
return p.copy(geometry);
}
} else {
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
p = currentScreen->grabWindow(screenNumber,
currentScreen->geometry().x(),
currentScreen->geometry().y(),
currentScreen->geometry().width(),
currentScreen->geometry().height());
ok = true;
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
return currentScreen->grabWindow(screenNumber,
geometry.x(),
geometry.y(),
geometry.width(),
geometry.height());
}
return p;
}