Commit 87b7f268 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Don't use DBus on Android

parent 31f39755
Pipeline #90586 passed with stage
in 33 seconds
......@@ -35,9 +35,13 @@ ecm_setup_version(${PROJECT_VERSION}
)
################# Find dependencies #################
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg Sql DBus)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Qml QuickControls2 Svg Sql)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2 I18n CoreAddons)
if(NOT ANDROID)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus)
endif()
################# build and install #################
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_USE_QSTRINGBUILDER)
......
......@@ -6,7 +6,6 @@ add_executable(kontrast
target_link_libraries(kontrast
Qt5::Core
Qt5::DBus
Qt5::Gui
Qt5::Qml
Qt5::Quick
......@@ -16,4 +15,8 @@ target_link_libraries(kontrast
KF5::I18n
KF5::CoreAddons)
if(TARGET Qt5::DBus)
target_link_libraries(kontrast Qt5::DBus)
endif()
install(TARGETS kontrast ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
......@@ -6,6 +6,11 @@
#include "kontrast.h"
#include <QDebug>
#include <QRandomGenerator>
#include <QtMath>
#ifdef QT_DBUS_LIB
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusMetaType>
......@@ -13,9 +18,6 @@
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QDebug>
#include <QRandomGenerator>
#include <QtMath>
QDBusArgument &operator<<(QDBusArgument &arg, const Kontrast::ColorRGB &color)
{
......@@ -37,6 +39,7 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, Kontrast::ColorRGB &co
return arg;
}
#endif
Kontrast::Kontrast(KAboutData about, QObject *parent)
: QObject(parent)
......@@ -44,7 +47,9 @@ Kontrast::Kontrast(KAboutData about, QObject *parent)
{
setObjectName(QStringLiteral("Kontrast"));
#ifdef QT_DBUS_LIB
qDBusRegisterMetaType<ColorRGB>();
#endif
}
QColor Kontrast::textColor() const
......@@ -240,6 +245,7 @@ QColor Kontrast::pixelAt(const QImage &image, int x, int y) const
void Kontrast::grabColor()
{
#ifdef QT_DBUS_LIB
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
QLatin1String("/org/freedesktop/portal/desktop"),
QLatin1String("org.freedesktop.portal.Screenshot"),
......@@ -261,6 +267,7 @@ void Kontrast::grabColor()
SLOT(gotColorResponse(uint, QVariantMap)));
}
});
#endif
}
QColor Kontrast::grabbedColor() const
......@@ -270,6 +277,7 @@ QColor Kontrast::grabbedColor() const
void Kontrast::gotColorResponse(uint response, const QVariantMap &results)
{
#ifdef QT_DBUS_LIB
if (!response) {
if (results.contains(QLatin1String("color"))) {
auto color = qdbus_cast<ColorRGB>(results.value(QLatin1String("color")));
......@@ -279,4 +287,8 @@ void Kontrast::gotColorResponse(uint response, const QVariantMap &results)
} else {
qWarning() << "Failed to take screenshot";
}
#else
Q_UNUSED(response);
Q_UNUSED(results);
#endif
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment