mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 17:59:25 +00:00
Added a gui --selection option to print out the geometry of the selection.
Fixes #425.
This commit is contained in:
committed by
borgmanJeremy
parent
8b51af2010
commit
05c2bc6ae7
@@ -19,6 +19,7 @@
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QRect>
|
||||
#include <QTextStream>
|
||||
|
||||
DBusUtils::DBusUtils(QObject* parent)
|
||||
@@ -34,7 +35,26 @@ void DBusUtils::connectPrintCapture(QDBusConnection& session, uint id)
|
||||
QLatin1String(""),
|
||||
QStringLiteral("captureTaken"),
|
||||
this,
|
||||
SLOT(captureTaken(uint, QByteArray)));
|
||||
SLOT(captureTaken(uint, QByteArray, QRect)));
|
||||
// captureFailed
|
||||
session.connect(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("captureFailed"),
|
||||
this,
|
||||
SLOT(captureFailed(uint)));
|
||||
}
|
||||
|
||||
void DBusUtils::connectSelectionCapture(QDBusConnection& session, uint id)
|
||||
{
|
||||
m_id = id;
|
||||
// captureTaken
|
||||
session.connect(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("captureTaken"),
|
||||
this,
|
||||
SLOT(selectionTaken(uint, QByteArray, QRect)));
|
||||
// captureFailed
|
||||
session.connect(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
@@ -52,11 +72,12 @@ void DBusUtils::checkDBusConnection(const QDBusConnection& connection)
|
||||
}
|
||||
}
|
||||
|
||||
void DBusUtils::captureTaken(uint id, QByteArray rawImage)
|
||||
void DBusUtils::captureTaken(uint id, QByteArray rawImage, QRect selection)
|
||||
{
|
||||
if (m_id == id) {
|
||||
QFile file;
|
||||
file.open(stdout, QIODevice::WriteOnly);
|
||||
|
||||
file.write(rawImage);
|
||||
file.close();
|
||||
qApp->exit();
|
||||
@@ -70,3 +91,17 @@ void DBusUtils::captureFailed(uint id)
|
||||
qApp->exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void DBusUtils::selectionTaken(uint id, QByteArray rawImage, QRect selection)
|
||||
{
|
||||
if (m_id == id) {
|
||||
QFile file;
|
||||
file.open(stdout, QIODevice::WriteOnly);
|
||||
|
||||
QTextStream out(&file);
|
||||
out << selection.width() << " " << selection.height() << " "
|
||||
<< selection.x() << " " << selection.y();
|
||||
file.close();
|
||||
qApp->exit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user