diff --git a/CMakeLists.txt b/CMakeLists.txt index aa8d86b2..71f6b94e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ include(FeatureSummary) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n) -find_package(KF5 REQUIRED COMPONENTS PlasmaQuick) +find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/dialer/CMakeLists.txt b/dialer/CMakeLists.txt index c2adad8f..9927f95e 100644 --- a/dialer/CMakeLists.txt +++ b/dialer/CMakeLists.txt @@ -1,3 +1,5 @@ kpackage_install_package(package org.kde.phone.dialer genericqml) install(FILES package/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.dialer.desktop) + +add_subdirectory(src) diff --git a/dialer/package/contents/ui/main.qml b/dialer/package/contents/ui/main.qml index fd17930b..d7f611e0 100644 --- a/dialer/package/contents/ui/main.qml +++ b/dialer/package/contents/ui/main.qml @@ -32,8 +32,7 @@ ApplicationWindow { //BEGIN PROPERTIES width: 600 height: 800 - visible: true - //color: Qt.rgba(0, 0, 0, 0.9) + property int status: voiceCallmanager.activeVoiceCall ? voiceCallmanager.activeVoiceCall.status : 0 //END PROPERTIES diff --git a/dialer/package/metadata.desktop b/dialer/package/metadata.desktop index cf835d33..54766985 100644 --- a/dialer/package/metadata.desktop +++ b/dialer/package/metadata.desktop @@ -14,7 +14,7 @@ X-KDE-PluginInfo-Name=org.kde.phone.dialer X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= X-KDE-ServiceTypes=KPackage/Generic -Exec=kpackagelauncherqml -a org.kde.phone.dialer +Exec=plasmaphonedialer X-Plasma-MainScript=ui/main.qml X-Plasma-RemoteLocation= diff --git a/dialer/src/CMakeLists.txt b/dialer/src/CMakeLists.txt new file mode 100644 index 00000000..f430c3f6 --- /dev/null +++ b/dialer/src/CMakeLists.txt @@ -0,0 +1,23 @@ + + +set(plasmaphonedialer_SRCS + main.cpp +) + +add_executable(plasmaphonedialer ${plasmaphonedialer_SRCS}) +target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") + +#find_package(ActiveApp REQUIRED) + +target_link_libraries(plasmaphonedialer + Qt5::Gui + Qt5::Quick + Qt5::Widgets + KF5::Declarative + KF5::I18n + KF5::Package + KF5::QuickAddons + KF5::DBusAddons +) + +install(TARGETS plasmaphonedialer ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/dialer/src/main.cpp b/dialer/src/main.cpp new file mode 100644 index 00000000..8b7862ce --- /dev/null +++ b/dialer/src/main.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2015 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + QCommandLineParser parser; + QApplication app(argc, argv); + + app.setQuitOnLastWindowClosed(false); + KDBusService service(KDBusService::Unique); + + const QString description = i18n("Plasma Phone Dialer"); + const char version[] = PROJECT_VERSION; + + app.setApplicationVersion(version); + parser.addVersionOption(); + parser.addHelpOption(); + parser.setApplicationDescription(description); + + QCommandLineOption daemonOption("daemon", "Daemon mode. run without displaying anything."); + + parser.addOption(daemonOption); + + parser.process(app); + + const QString packagePath("org.kde.phone.dialer"); + + //usually we have an ApplicationWindow here, so we do not need to create a window by ourselves + KDeclarative::QmlObject *obj = new KDeclarative::QmlObject(); + obj->setTranslationDomain(packagePath); + obj->setInitializationDelayed(true); + obj->loadPackage(packagePath); + obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments()); + + obj->completeInitialization(); + + if (!obj->package().metadata().isValid()) { + return -1; + } + + KPluginMetaData data = obj->package().metadata(); + // About data + KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key()); + + for (auto author : data.authors()) { + aboutData.addAuthor(author.name(), author.task(), author.emailAddress(), author.webAddress(), author.ocsUsername()); + } + + //The root is not a window? + //have to use a normal QQuickWindow since the root item is already created + QWindow *window = qobject_cast(obj->rootObject()); + if (window) { + QObject::connect(&service, &KDBusService::activateRequested, [=](const QStringList &arguments, const QString &workingDirectory) { + Q_UNUSED(arguments) + Q_UNUSED(workingDirectory); + window->show(); + window->requestActivate(); + }); + if (!parser.isSet(daemonOption)) { + window->show(); + window->requestActivate(); + } + window->setTitle(obj->package().metadata().name()); + window->setIcon(QIcon::fromTheme(obj->package().metadata().iconName())); + } else { + qWarning() << "Error loading the ApplicationWindow"; + } + + return app.exec(); +} +