diff --git a/CMakeLists.txt b/CMakeLists.txt index 99405d4..93009ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,65 +1,70 @@ project(plasma-phone-components) # minimal requirements cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) set (QT_MIN_VERSION "5.2.0") set(KF5_MIN_VERSION "5.0.0") set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(ECM 0.0.9 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_SOURCE_DIR}/cmake) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(GenerateExportHeader) include(FeatureSummary) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick Test) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n KIO People) find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons Notifications) find_package(TelepathyQt5 REQUIRED) find_package(KF5Wayland CONFIG) set_package_properties(KF5Wayland PROPERTIES TYPE REQUIRED PURPOSE "Required for interacting with the compositor") +# torch +find_package(GStreamer 1.1.90 REQUIRED) +find_package(GLIB2 REQUIRED) +find_package(GObject REQUIRED) + include(CheckIncludeFiles) plasma_install_package(look-and-feel org.kde.plasma.phone look-and-feel) plasma_install_package(shell org.kde.plasma.phone shells) install(DIRECTORY wallpaper/ DESTINATION "${WALLPAPER_INSTALL_DIR}/org.kde.plasma.phone.lockers") #kpackage_install_package(phonebook org.kde.phone.phonebook genericqml) #install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.phonebook.desktop) install( DIRECTORY kwinmultitasking/ DESTINATION ${DATA_INSTALL_DIR}/kwin/scripts/org.kde.phone.multitasking ) install( FILES kwinmultitasking/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-org.kde.phone.multitasking.desktop ) install( DIRECTORY qtvirtualkeyboardplugin/ DESTINATION ${KDE_INSTALL_QMLDIR}/QtQuick/VirtualKeyboard/Styles/Plasma ) configure_file(plasma-mobile.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/plasma-mobile.desktop) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plasma-mobile.desktop DESTINATION ${KDE_INSTALL_DATADIR}/wayland-sessions ) add_subdirectory(bin) #add_subdirectory(services) add_subdirectory(applets) add_subdirectory(containments) add_subdirectory(components) add_subdirectory(dialer) add_subdirectory(sounds) #add_subdirectory(touchscreentest) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake new file mode 100644 index 0000000..ebd1c55 --- /dev/null +++ b/cmake/FindGLIB2.cmake @@ -0,0 +1,48 @@ +# - Try to find the GLIB2 libraries +# Once done this will define +# +# GLIB2_FOUND - system has glib2 +# GLIB2_INCLUDE_DIR - the glib2 include directory +# GLIB2_LIBRARIES - glib2 library + +# Copyright (c) 2008 Laurent Montel, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + # Already in cache, be silent + set(GLIB2_FIND_QUIETLY TRUE) +endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + +if (NOT WIN32) + find_package(PkgConfig REQUIRED) + pkg_check_modules(PKG_GLIB REQUIRED glib-2.0) +endif(NOT WIN32) + +find_path(GLIB2_MAIN_INCLUDE_DIR glib.h + PATH_SUFFIXES glib-2.0 + PATHS ${PKG_GLIB_INCLUDE_DIRS} ) + +# search the glibconfig.h include dir under the same root where the library is found +find_library(GLIB2_LIBRARIES + NAMES glib-2.0 + PATHS ${PKG_GLIB_LIBRARY_DIRS} ) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h + PATH_SUFFIXES glib-2.0/include ../lib/glib-2.0/include + PATHS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_LIBRARIES} ${CMAKE_SYSTEM_LIBRARY_PATH}) + +set(GLIB2_INCLUDE_DIR ${GLIB2_MAIN_INCLUDE_DIR}) + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) + set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} ${GLIB2_INTERNAL_INCLUDE_DIR}) +endif(GLIB2_INTERNAL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) + +mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) diff --git a/cmake/FindGObject.cmake b/cmake/FindGObject.cmake new file mode 100644 index 0000000..af0c9f7 --- /dev/null +++ b/cmake/FindGObject.cmake @@ -0,0 +1,52 @@ +# - Try to find GObject +# Once done this will define +# +# GOBJECT_FOUND - system has GObject +# GOBJECT_INCLUDE_DIR - the GObject include directory +# GOBJECT_LIBRARIES - the libraries needed to use GObject +# GOBJECT_DEFINITIONS - Compiler switches required for using GObject + +# Copyright (c) 2011, Raphael Kubo da Costa +# Copyright (c) 2006, Tim Beaulen +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +FIND_PACKAGE(PkgConfig) +PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0) +SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER}) + +FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h + HINTS + ${PC_GOBJECT_INCLUDEDIR} + ${PC_GOBJECT_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0/gobject/ + ) + +FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GLibs NAMES glib-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) + +SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} ) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GOBJECT DEFAULT_MSG GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR) + +MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs) diff --git a/cmake/FindGStreamer.cmake b/cmake/FindGStreamer.cmake new file mode 100644 index 0000000..83397fd --- /dev/null +++ b/cmake/FindGStreamer.cmake @@ -0,0 +1,72 @@ +# - Try to find GStreamer +# Once done this will define +# +# GSTREAMER_FOUND - system has GStreamer +# GSTREAMER_INCLUDE_DIR - the GStreamer include directory +# GSTREAMER_LIBRARY - the main GStreamer library +# GSTREAMER_PLUGIN_DIR - the GStreamer plugin directory +# +# And for all the plugin libraries specified in the COMPONENTS +# of find_package, this module will define: +# +# GSTREAMER__LIBRARY_FOUND - system has +# GSTREAMER__LIBRARY - the library +# GSTREAMER__INCLUDE_DIR - the include directory +# +# Copyright(c) 2010, Collabora Ltd. +# @author George Kiagiadakis +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# TODO: Other versions --> GSTREAMER_X_Y_FOUND(Example: GSTREAMER_0_8_FOUND and GSTREAMER_0_10_FOUND etc) + +if(GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY) + # in cache already + set(GStreamer_FIND_QUIETLY TRUE) +else() + set(GStreamer_FIND_QUIETLY FALSE) +endif() + +set(GSTREAMER_API_VERSION 1.0) +if(NOT WIN32) + FIND_PACKAGE(PkgConfig REQUIRED) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + # don't make this check required - otherwise you can't use macro_optional_find_package on this one + PKG_CHECK_MODULES(PKG_GSTREAMER gstreamer-${GSTREAMER_API_VERSION}) + set(GSTREAMER_VERSION ${PKG_GSTREAMER_VERSION}) + set(GSTREAMER_DEFINITIONS ${PKG_GSTREAMER_CFLAGS}) +endif() + +message(STATUS "Found GStreamer package: ${PKG_GSTREAMER_VERSION}") + +set(GSTREAMER_INCLUDE_DIR ${PKG_GSTREAMER_INCLUDE_DIRS}) + +find_library(GSTREAMER_LIBRARIES NAMES gstreamer-${GSTREAMER_API_VERSION} + PATHS + ${PKG_GSTREAMER_LIBRARY_DIRS} + ) + +find_library(GSTREAMER_BASE_LIBRARY NAMES gstbase-${GSTREAMER_API_VERSION} + PATHS + ${PKG_GSTREAMER_LIBRARY_DIRS} + ) + +find_library(GSTREAMER_VIDEO_LIBRARY NAMES gstvideo-${GSTREAMER_API_VERSION} + PATHS + ${PKG_GSTREAMER_LIBRARY_DIRS} + ) + +if(NOT GSTREAMER_INCLUDE_DIR) + message(STATUS "GStreamer: WARNING: include dir not found") +endif() + +if(NOT GSTREAMER_LIBRARIES) + message(STATUS "GStreamer: WARNING: library not found") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GStreamer DEFAULT_MSG GSTREAMER_LIBRARIES GSTREAMER_INCLUDE_DIR GSTREAMER_BASE_LIBRARY) + +mark_as_advanced(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY) diff --git a/containments/panel/CMakeLists.txt b/containments/panel/CMakeLists.txt index c6a5a2e..e324030 100644 --- a/containments/panel/CMakeLists.txt +++ b/containments/panel/CMakeLists.txt @@ -1,19 +1,21 @@ set(phonepanel_SRCS phonepanel.cpp ) add_library(plasma_applet_phonepanel MODULE ${phonepanel_SRCS}) kcoreaddons_desktop_to_json(plasma_applet_phonepanel package/metadata.desktop) target_link_libraries(plasma_applet_phonepanel Qt5::Gui KF5::Plasma - KF5::I18n) + KF5::I18n + ${GSTREAMER_LIBRARIES} ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES}) +target_include_directories(plasma_applet_phonepanel PRIVATE "${GSTREAMER_INCLUDE_DIR}") install(TARGETS plasma_applet_phonepanel DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) #install(FILES plasma-phonepanel-default.desktop DESTINATION ${SERVICES_INSTALL_DIR}) plasma_install_package(package org.kde.phone.panel) diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml index d9cd6b9..f4fb50b 100644 --- a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml @@ -1,152 +1,158 @@ /* * 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 Library 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. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents Item { id: root function toggleAirplane() { print("toggle airplane mode") } + function toggleTorch() { + plasmoid.nativeInterface.toggleTorch() + } + function addPlasmoid(applet, id) { settingsModel.append({"icon": applet.icon, "text": applet.title, "plasmoidId": id, "enabled": false, "applet": applet, - "settingsCommand": ""}) + "settingsCommand": "", + "toggleFunction": ""}); } signal plasmoidTriggered(var applet, var id) Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2 property int screenBrightness property bool disableBrightnessUpdate: true readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 onScreenBrightnessChanged: { if(!disableBrightnessUpdate) { var service = pmSource.serviceForSource("PowerDevil"); var operation = service.operationDescription("setBrightness"); operation.brightness = screenBrightness; operation.silent = true service.startOperationCall(operation); } } PlasmaCore.DataSource { id: pmSource engine: "powermanagement" connectedSources: ["PowerDevil"] onSourceAdded: { if (source === "PowerDevil") { disconnectSource(source); connectSource(source); } } onDataChanged: { root.screenBrightness = pmSource.data["PowerDevil"]["Screen Brightness"]; } } //HACK: make the list know about the applet delegate which is a qtobject QtObject { id: nullApplet } Component.onCompleted: { //NOTE: add all in javascript as the static decl of listelements can't have scripts settingsModel.append({ "text": i18n("Settings"), "icon": "configure", "enabled": false, "settingsCommand": "plasma-settings", "toggleFunction": "", "delegate": "", "plasmoidId": -1, "enabled": false, "applet": null }); settingsModel.append({ "text": i18n("Flashlight"), "icon": "package_games_puzzle", "enabled": false, "settingsCommand": "", + "toggleFunction": "toggleTorch", "plasmoidId": -1, "applet": null }); settingsModel.append({ "text": i18n("Location"), "icon": "find-location-symbolic", "enabled": false, "settingsCommand": "", "plasmoidId": -1, "applet": null }); brightnessSlider.valueChanged.connect(function() { root.screenBrightness = brightnessSlider.value; }); disableBrightnessUpdate = false; } ListModel { id: settingsModel } Flow { id: flow anchors { fill: parent margins: units.largeSpacing } spacing: units.largeSpacing Repeater { model: settingsModel delegate: Loader { width: item ? item.implicitWidth : 0 height: item ? item.implicitHeight : 0 source: Qt.resolvedUrl((model.delegate ? model.delegate : "Delegate") + ".qml") } } move: Transition { NumberAnimation { duration: units.shortDuration easing.type: Easing.InOutQuad properties: "x,y" } } BrightnessItem { id: brightnessSlider width: flow.width icon: "video-display-brightness" label: i18n("Display Brightness") value: root.screenBrightness maximumValue: root.maximumScreenBrightness Connections { target: root onScreenBrightnessChanged: brightnessSlider.value = root.screenBrightness } } } } diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp index 9ba98d8..1a9c0e0 100644 --- a/containments/panel/phonepanel.cpp +++ b/containments/panel/phonepanel.cpp @@ -1,43 +1,77 @@ /*************************************************************************** * Copyright (C) 2015 Marco Martin * + * Copyright (C) 2018 Bhushan Shah * * * * This program 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 2 of the License, 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 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 "phonepanel.h" #include #include PhonePanel::PhonePanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { //setHasConfigurationInterface(true); } PhonePanel::~PhonePanel() { } void PhonePanel::executeCommand(const QString &command) { qWarning()<<"Executing"< * * * * * This program 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 2 of the License, 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 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 . * ***************************************************************************/ #ifndef PHONEPANEL_H #define PHONEPANEL_H #include +#include + class PhonePanel : public Plasma::Containment { Q_OBJECT public: PhonePanel( QObject *parent, const QVariantList &args ); ~PhonePanel(); public Q_SLOTS: void executeCommand(const QString &command); + void toggleTorch(); private: - + GstElement* m_pipeline; + GstElement* m_sink; + GstElement* m_source; + bool m_running = false; }; #endif