diff --git a/dbus/org.dharkael.Flameshot.xml b/dbus/org.dharkael.Flameshot.xml
new file mode 100644
index 00000000..d7cf8bff
--- /dev/null
+++ b/dbus/org.dharkael.Flameshot.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/flameshot.pro b/flameshot.pro
index b4bf964d..dd5f61f2 100644
--- a/flameshot.pro
+++ b/flameshot.pro
@@ -7,6 +7,7 @@
QT += core gui
QT += x11extras
+QT += dbus
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@@ -47,7 +48,8 @@ SOURCES += src/main.cpp\
src/capture/colorpicker.cpp \
src/config/buttonlistview.cpp \
src/config/uicoloreditor.cpp \
- src/config/geneneralconf.cpp
+ src/config/geneneralconf.cpp \
+ src/flameshotdbusadapter.cpp
HEADERS += \
src/nativeeventfilter.h \
@@ -62,7 +64,8 @@ HEADERS += \
src/capture/colorpicker.h \
src/config/buttonlistview.h \
src/config/uicoloreditor.h \
- src/config/geneneralconf.h
+ src/config/geneneralconf.h \
+ src/flameshotdbusadapter.h
RESOURCES += \
graphics.qrc
diff --git a/src/controller.cpp b/src/controller.cpp
index 799ca5a7..f6134958 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -44,7 +44,7 @@ Controller::Controller(QObject *parent) : QObject(parent),
m_nativeEventFilter = new NativeEventFilter(this);
qApp->installNativeEventFilter(m_nativeEventFilter);
- connect(m_nativeEventFilter, &NativeEventFilter::activated, this, &Controller::slotPrintHotkey);
+ connect(m_nativeEventFilter, &NativeEventFilter::activated, this, &Controller::createCapture);
QString StyleSheet = Button::getStyle();
qApp->setStyleSheet(StyleSheet);
@@ -114,7 +114,7 @@ void Controller::initDefaults() {
}
// creation of a new capture
-void Controller::slotPrintHotkey() {
+void Controller::createCapture() {
if (!m_captureWindow) {
m_captureWindow = new CaptureWidget();
connect(m_captureWindow, &CaptureWidget::newMessage,
diff --git a/src/controller.h b/src/controller.h
index 617e0676..ffa66e9d 100644
--- a/src/controller.h
+++ b/src/controller.h
@@ -34,10 +34,12 @@ class Controller : public QObject {
public:
explicit Controller(QObject *parent = 0);
-private slots:
- void slotPrintHotkey();
+public slots:
+ void createCapture();
void openConfigWindow();
void openInfoWindow();
+
+private slots:
void showMessage(QString);
void initDefaults();
diff --git a/src/flameshotdbusadapter.cpp b/src/flameshotdbusadapter.cpp
new file mode 100644
index 00000000..2ba87f32
--- /dev/null
+++ b/src/flameshotdbusadapter.cpp
@@ -0,0 +1,36 @@
+// Copyright 2017 Alejandro Sirgo Rica
+//
+// This file is part of Flameshot.
+//
+// Flameshot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Flameshot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Flameshot. If not, see .
+
+#include "flameshotdbusadapter.h"
+
+FlameshotDBusAdapter::FlameshotDBusAdapter(Controller *parent)
+ : QDBusAbstractAdaptor(parent)
+{
+
+}
+
+FlameshotDBusAdapter::~FlameshotDBusAdapter() {
+
+}
+
+Controller *FlameshotDBusAdapter::parent() const {
+ return static_cast(QObject::parent());
+}
+
+void FlameshotDBusAdapter::createCapture() {
+ parent()->createCapture();
+}
diff --git a/src/flameshotdbusadapter.h b/src/flameshotdbusadapter.h
new file mode 100644
index 00000000..2806030a
--- /dev/null
+++ b/src/flameshotdbusadapter.h
@@ -0,0 +1,44 @@
+// Copyright 2017 Alejandro Sirgo Rica
+//
+// This file is part of Flameshot.
+//
+// Flameshot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Flameshot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Flameshot. If not, see .
+
+#ifndef FLAMESHOTDBUSADAPTER_H
+#define FLAMESHOTDBUSADAPTER_H
+
+#include
+#include "src/controller.h"
+
+class FlameshotDBusAdapter : public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.dharkael.Flameshot")
+ Q_CLASSINFO("D-Bus Introspection", ""
+ "\n"
+ " \n"
+ " \n"
+ "\n"
+ ""
+ )
+public:
+ FlameshotDBusAdapter(Controller *parent = 0);
+ virtual ~FlameshotDBusAdapter();
+ inline Controller *parent() const;
+
+public slots:
+ Q_NOREPLY void createCapture();
+};
+
+#endif // FLAMESHOTDBUSADAPTER_H
diff --git a/src/main.cpp b/src/main.cpp
index 72ea1a5e..2575a9ad 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,8 +17,10 @@
#include "controller.h"
#include "singleapplication.h"
+#include "src/flameshotdbusadapter.h"
#include
#include
+#include
int main(int argc, char *argv[]) {
QTranslator translator;
@@ -27,11 +29,16 @@ int main(int argc, char *argv[]) {
SingleApplication app(argc, argv);
app.installTranslator(&translator);
+ app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
app.setApplicationName("flameshot");
app.setOrganizationName("Dharkael");
- Controller w;
+ Controller c;
+ new FlameshotDBusAdapter(&c);
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ dbus.registerObject("/", &c);
+ dbus.registerService("org.dharkael.Flameshot");
return app.exec();
}
diff --git a/tools/flameshot-cli/flameshot-cli.pro b/tools/flameshot-cli/flameshot-cli.pro
new file mode 100644
index 00000000..8c8d8b00
--- /dev/null
+++ b/tools/flameshot-cli/flameshot-cli.pro
@@ -0,0 +1,24 @@
+QT += core
+QT += dbus
+QT -= gui
+
+CONFIG += c++11
+
+TARGET = flameshot-cli
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+SOURCES += main.cpp
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
diff --git a/tools/flameshot-cli/main.cpp b/tools/flameshot-cli/main.cpp
new file mode 100644
index 00000000..0c812d1c
--- /dev/null
+++ b/tools/flameshot-cli/main.cpp
@@ -0,0 +1,22 @@
+#include
+#include
+#include
+//#include
+
+int main(int argc, char *argv[]) {
+ Q_UNUSED(argc);
+ Q_UNUSED(argv);
+ //QCoreApplication a(argc, argv);
+ //QCommandLineParser parser;
+ QDBusMessage m = QDBusMessage::createMethodCall("org.dharkael.Flameshot",
+ "/",
+ "",
+ "createCapture"
+ );
+
+ QDBusConnection::sessionBus().call(m);
+
+
+ //return a.exec();
+
+}