Reduce dependence on D-Bus (#2003)
* Handle captures without sigslots Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Set {app,organization}Name and version consistently Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make 'full' dbus-free Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move CaptureRequest::exportCapture to Controller We need to wait until the upload widget (or similar widgets) have finished before exiting. This must be done using a signal. The problem is that CaptureRequest can't be guaranteed to survive until the widget has finished what it's doing. Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Use QApplication with the 'full' subcommand Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Do unto 'screen' as we did to 'full' Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add FlameshotDaemon singleton class Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Support clipboard hosting for both pixmaps and text * Fix upload handling Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Do not show tray icon if not daemon Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Clean up handling of pin task Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove annoying Qt warning messages The messages were caused by the color wheel. Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix small bug in Controller::exportCapture * Fix --raw output * Make 'gui' dbus-independent Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix accept on select bug Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix compile error on Windows Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make it work on Windows * Remove obsolete function in main.cpp Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make 'launcher' work without dbus Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * clang-format, sigh Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Enable CLI parsing on MacOS Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make 'config' work without dbus Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Small refactor of capture request handling Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove obsolete DBusUtils Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove unused D-Bus sigslots Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove D-Bus methods openConfig, autostartEnabled and trayIconEnabled Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove D-Bus method requestCapture Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Remove CaptureRequest id mechanism Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix 'launcher' crash Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Handle clipboard notifications properly Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add 'autoCloseIdleDaemon' option Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Document FlameshotDaemon class Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Make 'flameshot gui' run in single-application mode Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add `allowmultipleGuiInstances` config option Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix endless loop with multiple GUI instances Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Move upload confirmation dialog where it belongs Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Add the new config options to the GUI as well Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix failing build on Windows Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Handle persistence on MacOS Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * fixed notifications on macos * Fixed display on macos * Reformat tests/action_options.sh Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> * Fix infinite recursion in tests/action_options.sh Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com> Co-authored-by: Dearsh Oberoi <59907159+deo002@users.noreply.github.com> Co-authored-by: Jeremy Borgman <borgman.jeremy@pm.me>
This commit is contained in:
@@ -23,63 +23,8 @@ CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode,
|
||||
, m_delay(delay)
|
||||
, m_tasks(tasks)
|
||||
, m_data(data)
|
||||
, m_forcedID(false)
|
||||
, m_id(0)
|
||||
{}
|
||||
|
||||
void CaptureRequest::setStaticID(uint id)
|
||||
{
|
||||
m_forcedID = true;
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
uint CaptureRequest::id() const
|
||||
{
|
||||
if (m_forcedID) {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
uint id = 0;
|
||||
QVector<uint> v;
|
||||
v << qHash(m_mode) << qHash(m_delay * QDateTime::currentMSecsSinceEpoch())
|
||||
<< qHash(m_path) << qHash(m_tasks) << m_data.toInt();
|
||||
for (uint i : v) {
|
||||
id ^= i + 0x9e3779b9 + (id << 6) + (id >> 2);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
QByteArray CaptureRequest::serialize() const
|
||||
{
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
// Convert enums to integers
|
||||
qint32 tasks = m_tasks, mode = m_mode;
|
||||
stream << mode << m_delay << tasks << m_data << m_forcedID << m_id << m_path
|
||||
<< m_initialSelection;
|
||||
return data;
|
||||
}
|
||||
|
||||
CaptureRequest CaptureRequest::deserialize(const QByteArray& data)
|
||||
{
|
||||
QDataStream stream(data);
|
||||
CaptureRequest request;
|
||||
qint32 tasks, mode;
|
||||
stream >> mode;
|
||||
stream >> request.m_delay;
|
||||
stream >> tasks;
|
||||
stream >> request.m_data;
|
||||
stream >> request.m_forcedID;
|
||||
stream >> request.m_id;
|
||||
stream >> request.m_path;
|
||||
stream >> request.m_initialSelection;
|
||||
|
||||
// Convert integers to enums
|
||||
request.m_tasks = static_cast<ExportTask>(tasks);
|
||||
request.m_mode = static_cast<CaptureMode>(mode);
|
||||
return request;
|
||||
}
|
||||
|
||||
CaptureRequest::CaptureMode CaptureRequest::captureMode() const
|
||||
{
|
||||
return m_mode;
|
||||
@@ -118,7 +63,7 @@ void CaptureRequest::addTask(CaptureRequest::ExportTask task)
|
||||
m_tasks |= task;
|
||||
}
|
||||
|
||||
void CaptureRequest::removeTask(CaptureRequest::ExportTask task)
|
||||
void CaptureRequest::removeTask(ExportTask task)
|
||||
{
|
||||
((int&)m_tasks) &= ~task;
|
||||
}
|
||||
@@ -139,59 +84,3 @@ void CaptureRequest::setInitialSelection(const QRect& selection)
|
||||
{
|
||||
m_initialSelection = selection;
|
||||
}
|
||||
|
||||
void CaptureRequest::exportCapture(const QPixmap& capture)
|
||||
{
|
||||
if (m_tasks & SAVE) {
|
||||
if (m_path.isEmpty()) {
|
||||
ScreenshotSaver(m_id).saveToFilesystemGUI(capture);
|
||||
} else {
|
||||
ScreenshotSaver(m_id).saveToFilesystem(capture, m_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_tasks & COPY) {
|
||||
ScreenshotSaver().saveToClipboard(capture);
|
||||
}
|
||||
|
||||
if (m_tasks & PIN) {
|
||||
QWidget* widget = new PinWidget(capture, m_pinWindowGeometry);
|
||||
widget->show();
|
||||
widget->activateWindow();
|
||||
if (m_mode == SCREEN_MODE || m_mode == FULLSCREEN_MODE) {
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("Full screen screenshot pinned to screen"));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_tasks & UPLOAD) {
|
||||
if (!ConfigHandler().uploadWithoutConfirmation()) {
|
||||
ImgUploadDialog* dialog = new ImgUploadDialog();
|
||||
if (dialog->exec() == QDialog::Rejected) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ImgUploaderBase* widget = ImgUploaderManager().uploader(capture);
|
||||
widget->show();
|
||||
widget->activateWindow();
|
||||
// NOTE: lambda can't capture 'this' because it might be destroyed later
|
||||
ExportTask tasks = m_tasks;
|
||||
QObject::connect(
|
||||
widget, &ImgUploaderBase::uploadOk, [widget, tasks](const QUrl& url) {
|
||||
if (ConfigHandler().copyAndCloseAfterUpload()) {
|
||||
if (!(tasks & COPY)) {
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("URL copied to clipboard."));
|
||||
|
||||
QApplication::clipboard()->setText(url.toString());
|
||||
widget->close();
|
||||
} else {
|
||||
widget->showPostUploadDialog();
|
||||
}
|
||||
} else {
|
||||
widget->showPostUploadDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user