Flameshot: fix build, dbus autostart

This commit is contained in:
Gerasim Troeglazov
2020-08-21 23:31:13 +10:00
parent e22607a1e1
commit cf01971dbb
3 changed files with 175 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
resource app_flags B_SINGLE_LAUNCH;
resource app_flags B_MULTIPLE_LAUNCH;
resource app_version {
major = @MAJOR@,

View File

@@ -9,7 +9,7 @@ DESCRIPTION="Features
HOMEPAGE="https://github.com/lupoDharkael/flameshot/"
COPYRIGHT="2019 lupoDharkael"
LICENSE="GNU GPL v3"
REVISION="2"
REVISION="3"
SOURCE_URI="https://github.com/lupoDharkael/flameshot/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="61b3a1969d6e17d80d5d90a3fce53ca5ae78fa21f9a45e5a19b0b32ea815a589"
PATCHES="flameshot-$portVersion.patchset"
@@ -38,6 +38,7 @@ REQUIRES="
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libQt5Core$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix

View File

@@ -1,4 +1,4 @@
From 99407a848b8164d7400aa8ff297d8c7d4476b51e Mon Sep 17 00:00:00 2001
From 37c38cf8bb9b7ec66a4e7adf640b157992469b9b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 21 Aug 2019 21:38:36 +1000
Subject: Fix crush
@@ -19,5 +19,175 @@ index d31bcfd..ae1f03e 100644
QString FileNameHandler::parsedPattern() {
--
2.23.0
2.28.0
From af6feac4c9b47b4cd73a6307271ecf581c13b3ad Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 21 Aug 2020 21:37:07 +1000
Subject: Fix build for Qt 5.15
diff --git a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp
index 335b29c..a9a6fba 100644
--- a/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp
+++ b/src/third-party/Qt-Color-Widgets/src/color_wheel.cpp
@@ -24,6 +24,7 @@
#include <cmath>
#include <QMouseEvent>
#include <QPainter>
+#include <QPainterPath>
#include <QLineF>
#include <QDragEnterEvent>
#include <QMimeData>
--
2.28.0
From 41fc7ded2fbacbefdcb097ed0604f27ad113d944 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 21 Aug 2020 21:37:53 +1000
Subject: Fix build for Qt 5.15
diff --git a/src/tools/arrow/arrowtool.h b/src/tools/arrow/arrowtool.h
index abdbe33..1dd0471 100644
--- a/src/tools/arrow/arrowtool.h
+++ b/src/tools/arrow/arrowtool.h
@@ -19,6 +19,7 @@
#include "src/tools/abstracttwopointtool.h"
#include <QPainter>
+#include <QPainterPath>
class ArrowTool : public AbstractTwoPointTool {
Q_OBJECT
--
2.28.0
From f92403f65f9a4d6a39dc0075a7f9023b11c083e1 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 21 Aug 2020 21:38:13 +1000
Subject: Add support for autolaunch
diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp
index 6eef22a..9b91878 100644
--- a/src/utils/confighandler.cpp
+++ b/src/utils/confighandler.cpp
@@ -240,7 +240,10 @@ void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen) {
bool ConfigHandler::startupLaunchValue() {
bool res = false;
-#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
+#if defined(Q_OS_HAIKU)
+ QString path = QDir::homePath() + "/config/settings/boot/launch/Flameshot";
+ res = QFile(path).exists();
+#elif defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
QString path = QDir::homePath() + "/.config/autostart/Flameshot.desktop";
res = QFile(path).exists();
#elif defined(Q_OS_WIN)
@@ -254,7 +257,16 @@ bool ConfigHandler::startupLaunchValue() {
}
void ConfigHandler::setStartupLaunch(const bool start) {
-#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
+#if defined(Q_OS_HAIKU)
+ QString linkname = QDir::homePath() + "/config/settings/boot/launch/Flameshot";
+ QFile appFile(QCoreApplication::applicationFilePath());
+ QFile linkFile(linkname);
+ if (start) {
+ appFile.link(linkname);
+ } else {
+ linkFile.remove();
+ }
+#elif defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
QString path = QDir::homePath() + "/.config/autostart/Flameshot.desktop";
QFile file(path);
if (start) {
--
2.28.0
From fe04c9b90cc719990d8974b38c6bf6533d3d91d3 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 21 Aug 2020 21:41:02 +1000
Subject: DBus autostart
diff --git a/src/main.cpp b/src/main.cpp
index 83fa1c1..4bf0db9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,6 +28,7 @@
#include <QTextStream>
#include <QTimer>
#include <QDir>
+#include <QProcess>
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
#include "src/core/flameshotdbusadapter.h"
@@ -44,7 +45,28 @@ int main(int argc, char *argv[]) {
// no arguments, just launch Flameshot
if (argc == 1) {
SingleApplication app(argc, argv);
+#ifdef Q_OS_HAIKU
+ int status=0;
+ QProcess dbusProcess;
+ QString exec = "/bin/dbus-launch";
+ QStringList params;
+ dbusProcess.start(exec, params);
+ dbusProcess.waitForFinished();
+ QString output(dbusProcess.readAllStandardOutput());
+
+ QFile file ("/tmp/flameshot_session");
+ if (file.open(QFile::WriteOnly | QFile::Truncate)) {
+ QTextStream outstream(&file);
+ outstream << output;
+ file.close();
+ }
+
+ QStringList list = output.split("\n", QString::SkipEmptyParts);
+ foreach (const QString &str, list)
+ putenv(str.toLatin1().data());
+#endif
+
QTranslator translator;
QStringList trPaths = PathInfo::translationsPaths();
@@ -77,10 +99,30 @@ int main(int argc, char *argv[]) {
// Exporting captures must be connected after the dbus interface
// or the dbus signal gets blocked until we end the exports.
c->enableExports();
+#ifdef Q_OS_HAIKU
+ status = app.exec();
+ system("kill -3 $DBUS_SESSION_BUS_PID");
+ return status;
+#else
return app.exec();
+#endif
}
#ifndef Q_OS_WIN
+
+#ifdef Q_OS_HAIKU
+QFile inputFile("/tmp/flameshot_session");
+if (inputFile.open(QIODevice::ReadOnly))
+{
+ QTextStream in(&inputFile);
+ while (!in.atEnd())
+ {
+ QString line = in.readLine();
+ putenv(line.toLatin1().data());
+ }
+ inputFile.close();
+}
+#endif
/*--------------|
* CLI parsing |
* ------------*/
--
2.28.0