Remove dbus from Windows build
This commit is contained in:
@@ -7,8 +7,11 @@
|
||||
VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
|
||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
QT += core gui
|
||||
QT += dbus
|
||||
QT += core gui
|
||||
|
||||
unix:!macx {
|
||||
QT += dbus
|
||||
}
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
@@ -74,7 +77,6 @@ SOURCES += src/main.cpp \
|
||||
src/config/buttonlistview.cpp \
|
||||
src/config/uicoloreditor.cpp \
|
||||
src/config/geneneralconf.cpp \
|
||||
src/core/flameshotdbusadapter.cpp \
|
||||
src/core/controller.cpp \
|
||||
src/config/clickablelabel.cpp \
|
||||
src/config/filenameeditor.cpp \
|
||||
@@ -112,7 +114,6 @@ SOURCES += src/main.cpp \
|
||||
src/core/resourceexporter.cpp \
|
||||
src/capture/widget/notifierbox.cpp \
|
||||
src/utils/desktopinfo.cpp \
|
||||
src/utils/dbusutils.cpp \
|
||||
src/capture/workers/launcher/applauncherwidget.cpp \
|
||||
src/capture/tools/applauncher.cpp \
|
||||
src/utils/desktopfileparse.cpp \
|
||||
@@ -120,8 +121,7 @@ SOURCES += src/main.cpp \
|
||||
src/capture/tools/blurtool.cpp \
|
||||
src/capture/workers/launcher/terminallauncher.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/capture/widget/buttonhandler.h \
|
||||
HEADERS += src/capture/widget/buttonhandler.h \
|
||||
src/infowindow.h \
|
||||
src/config/configwindow.h \
|
||||
src/capture/screenshot.h \
|
||||
@@ -131,7 +131,6 @@ HEADERS += \
|
||||
src/config/buttonlistview.h \
|
||||
src/config/uicoloreditor.h \
|
||||
src/config/geneneralconf.h \
|
||||
src/core/flameshotdbusadapter.h \
|
||||
src/config/clickablelabel.h \
|
||||
src/config/filenameeditor.h \
|
||||
src/utils/filenamehandler.h \
|
||||
@@ -169,7 +168,6 @@ HEADERS += \
|
||||
src/core/resourceexporter.h \
|
||||
src/capture/widget/notifierbox.h \
|
||||
src/utils/desktopinfo.h \
|
||||
src/utils/dbusutils.h \
|
||||
src/capture/workers/launcher/applauncherwidget.h \
|
||||
src/capture/tools/applauncher.h \
|
||||
src/utils/desktopfileparse.h \
|
||||
@@ -177,11 +175,19 @@ HEADERS += \
|
||||
src/capture/tools/blurtool.h \
|
||||
src/capture/workers/launcher/terminallauncher.h
|
||||
|
||||
unix:!macx {
|
||||
SOURCES += src/core/flameshotdbusadapter.cpp \
|
||||
src/utils/dbusutils.cpp
|
||||
|
||||
HEADERS += src/core/flameshotdbusadapter.h \
|
||||
src/utils/dbusutils.h
|
||||
}
|
||||
|
||||
RESOURCES += \
|
||||
graphics.qrc
|
||||
|
||||
# installs
|
||||
unix: {
|
||||
unix:!macx {
|
||||
packaging {
|
||||
USRPATH = /usr
|
||||
} else {
|
||||
|
||||
@@ -42,8 +42,10 @@ GeneneralConf::GeneneralConf(QWidget *parent) : QGroupBox(parent) {
|
||||
void GeneneralConf::updateComponents() {
|
||||
ConfigHandler config;
|
||||
m_helpMessage->setChecked(config.showHelpValue());
|
||||
m_showTray->setChecked(!config.disabledTrayIconValue());
|
||||
m_sysNotifications->setChecked(config.desktopNotificationValue());
|
||||
#ifdef Q_OS_LINUX
|
||||
m_showTray->setChecked(!config.disabledTrayIconValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GeneneralConf::showHelpChanged(bool checked) {
|
||||
@@ -127,6 +129,7 @@ void GeneneralConf::initShowDesktopNotification() {
|
||||
}
|
||||
|
||||
void GeneneralConf::initShowTrayIcon() {
|
||||
#ifdef Q_OS_LINUX
|
||||
m_showTray = new QCheckBox(tr("Show tray icon"), this);
|
||||
ConfigHandler config;
|
||||
bool checked = !config.disabledTrayIconValue();
|
||||
@@ -136,6 +139,7 @@ void GeneneralConf::initShowTrayIcon() {
|
||||
|
||||
connect(m_showTray, &QCheckBox::clicked, this,
|
||||
&GeneneralConf::showTrayIconChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GeneneralConf::initConfingButtons() {
|
||||
|
||||
@@ -35,9 +35,13 @@ Controller::Controller() : m_captureWindow(nullptr)
|
||||
qApp->setQuitOnLastWindowClosed(false);
|
||||
|
||||
// init tray icon
|
||||
#ifdef Q_OS_LINUX
|
||||
if (!ConfigHandler().disabledTrayIconValue()) {
|
||||
enableTrayIcon();
|
||||
}
|
||||
#else
|
||||
enableTrayIcon();
|
||||
#endif
|
||||
|
||||
initDefaults();
|
||||
|
||||
@@ -123,10 +127,22 @@ void Controller::enableTrayIcon() {
|
||||
}
|
||||
|
||||
void Controller::disableTrayIcon() {
|
||||
#ifdef Q_OS_LINUX
|
||||
if (m_trayIcon) {
|
||||
m_trayIcon->deleteLater();
|
||||
}
|
||||
ConfigHandler().setDisabledTrayIcon(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Controller::sendTrayNotification(
|
||||
const QString &text,
|
||||
const QString &title,
|
||||
const int timeout)
|
||||
{
|
||||
if (m_trayIcon) {
|
||||
m_trayIcon->showMessage(title, text, QSystemTrayIcon::Information, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::updateConfigComponents() {
|
||||
|
||||
@@ -49,6 +49,9 @@ public slots:
|
||||
|
||||
void enableTrayIcon();
|
||||
void disableTrayIcon();
|
||||
void sendTrayNotification(const QString &text,
|
||||
const QString &title = "Flameshot Info",
|
||||
const int timeout = 5000);
|
||||
|
||||
void updateConfigComponents();
|
||||
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -17,20 +17,23 @@
|
||||
|
||||
#include "src/core/controller.h"
|
||||
#include "singleapplication.h"
|
||||
#include "src/core/flameshotdbusadapter.h"
|
||||
#include "src/utils/filenamehandler.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/cli/commandlineparser.h"
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include "src/utils/dbusutils.h"
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QTextStream>
|
||||
#include <QTimer>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "src/core/flameshotdbusadapter.h"
|
||||
#include "src/utils/dbusutils.h"
|
||||
#include <QDBusConnection>
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// required for the button serialization
|
||||
qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
|
||||
@@ -48,6 +51,7 @@ int main(int argc, char *argv[]) {
|
||||
app.setApplicationName("flameshot");
|
||||
app.setOrganizationName("Dharkael");
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
auto c = Controller::getInstance();
|
||||
new FlameshotDBusAdapter(c);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
@@ -57,9 +61,14 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
dbus.registerObject("/", c);
|
||||
dbus.registerService("org.dharkael.Flameshot");
|
||||
#else
|
||||
// Create inicial static instance
|
||||
Controller::getInstance();
|
||||
#endif
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
/*--------------|
|
||||
* CLI parsing |
|
||||
* ------------*/
|
||||
@@ -316,5 +325,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
finish:
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,15 +22,19 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#endif
|
||||
|
||||
ScreenGrabber::ScreenGrabber(QObject *parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
|
||||
QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
|
||||
ok = true; // revisit later
|
||||
ok = true;
|
||||
#ifdef Q_OS_LINUX
|
||||
if(m_info.waylandDectected()) {
|
||||
QPixmap res;
|
||||
// handle screenshot based on DE
|
||||
@@ -62,6 +66,8 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool &ok) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
QRect geometry;
|
||||
for (QScreen *const screen : QGuiApplication::screens()) {
|
||||
geometry = geometry.united(screen->geometry());
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#include "systemnotification.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QApplication>
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusInterface>
|
||||
#include <QApplication>
|
||||
#else
|
||||
#endif
|
||||
#include "src/core/controller.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
SystemNotification::SystemNotification(QObject *parent) : QObject(parent) {
|
||||
m_interface = new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"),
|
||||
QStringLiteral("/org/freedesktop/Notifications"),
|
||||
@@ -12,6 +18,11 @@ SystemNotification::SystemNotification(QObject *parent) : QObject(parent) {
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
}
|
||||
#else
|
||||
SystemNotification::SystemNotification(QObject *parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void SystemNotification::sendMessage(
|
||||
const QString &text,
|
||||
@@ -22,6 +33,7 @@ void SystemNotification::sendMessage(
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QList<QVariant> args;
|
||||
args << (qAppName()) //appname
|
||||
<< static_cast<unsigned int>(0) //id
|
||||
@@ -32,4 +44,8 @@ void SystemNotification::sendMessage(
|
||||
<< QVariantMap() //hints
|
||||
<< timeout; //timeout
|
||||
m_interface->callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||
#else
|
||||
#endif
|
||||
auto c = Controller::getInstance();
|
||||
c->sendTrayNotification(title, text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user