diff --git a/containments/CMakeLists.txt b/containments/CMakeLists.txt index 94638a61..cb99c20e 100644 --- a/containments/CMakeLists.txt +++ b/containments/CMakeLists.txt @@ -2,3 +2,4 @@ plasma_install_package(panel org.kde.phone.panel) add_subdirectory(homescreen) +add_subdirectory(taskpanel) diff --git a/containments/taskpanel/CMakeLists.txt b/containments/taskpanel/CMakeLists.txt new file mode 100644 index 00000000..83cf80d5 --- /dev/null +++ b/containments/taskpanel/CMakeLists.txt @@ -0,0 +1,22 @@ +set(taskpanel_SRCS + taskpanel.cpp +) + +add_library(plasma_containment_phone_taskpanel MODULE ${taskpanel_SRCS}) + +kcoreaddons_desktop_to_json(plasma_containment_phone_taskpanel package/metadata.desktop) + +target_link_libraries(plasma_containment_phone_taskpanel + Qt5::Gui + Qt5::DBus + KF5::Plasma + Qt5::Qml + KF5::I18n + KF5::Service + ) + + +install(TARGETS plasma_containment_phone_taskpanel DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) + +plasma_install_package(package org.kde.phone.taskpanel) + diff --git a/containments/taskpanel/Messages.sh b/containments/taskpanel/Messages.sh new file mode 100755 index 00000000..9a0d8bd9 --- /dev/null +++ b/containments/taskpanel/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp +$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.phone.taskpanel.pot +rm -f rc.cpp diff --git a/containments/taskpanel/package/code/close.js b/containments/taskpanel/package/code/close.js new file mode 100644 index 00000000..56f0ef10 --- /dev/null +++ b/containments/taskpanel/package/code/close.js @@ -0,0 +1,2 @@ + +workspace.activeClient.closeWindow(); diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml new file mode 100644 index 00000000..9bb7e852 --- /dev/null +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -0,0 +1,38 @@ +/* + * Copyright 2015 Marco Martin + * + * 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 2.010-1301, USA. + */ + +import QtQuick 2.4 +import QtQuick.Layouts 1.1 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.kquickcontrolsaddons 2.0 + +Item { + width: 600 + height: 40 + + property Item toolBox + + PlasmaComponents.ToolButton { + anchors.right: parent.right + iconSource: "window-close" + onClicked: plasmoid.nativeInterface.executeScript("close"); + } +} \ No newline at end of file diff --git a/containments/taskpanel/package/metadata.desktop b/containments/taskpanel/package/metadata.desktop new file mode 100644 index 00000000..bc57d19a --- /dev/null +++ b/containments/taskpanel/package/metadata.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Encoding=UTF-8 +Keywords= +Name=Phone Task panel +Type=Service + +X-KDE-ServiceTypes=Plasma/Applet,Plasma/Containment +X-Plasma-API=declarativeappletscript +X-KDE-Library=plasma_containment_phone_taskpanel +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPLv2+ +X-KDE-PluginInfo-Name=org.kde.phone.taskpanel +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-Plasma-MainScript=ui/main.qml +X-Plasma-ContainmentType=Panel diff --git a/containments/taskpanel/taskpanel.cpp b/containments/taskpanel/taskpanel.cpp new file mode 100644 index 00000000..608baa07 --- /dev/null +++ b/containments/taskpanel/taskpanel.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2015 Marco Martin * + * * + * 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 "taskpanel.h" + +#include +#include +#include +#include + +#include + +static const QString s_kwinService = QStringLiteral("org.kde.KWin"); + +TaskPanel::TaskPanel(QObject *parent, const QVariantList &args) + : Plasma::Containment(parent, args) +{ + setHasConfigurationInterface(true); +} + +TaskPanel::~TaskPanel() +{ +} + +void TaskPanel::executeScript(const QString &script) +{ + //Plasma::Package p = + package().filePath("scripts", script + ".js"); + QDBusMessage message = QDBusMessage::createMethodCall(s_kwinService, "/Scripting", QString(), "loadScript"); + QList arguments; + arguments << QVariant("/opt/kde5qt5/share/plasma/plasmoids/org.kde.phone.taskpanel/code/close.js"); + message.setArguments(arguments); + QDBusMessage reply = QDBusConnection::sessionBus().call(message); + if (reply.type() == QDBusMessage::ErrorMessage) { + qWarning() << reply.errorMessage(); + } else { + const int id = reply.arguments().first().toInt(); + QDBusConnection::sessionBus().connect(s_kwinService, "/" + QString::number(id), QString(), "print", this, SLOT(print(QString))); + QDBusConnection::sessionBus().connect(s_kwinService, "/" + QString::number(id), QString(), "printError", this, SLOT(print(QString))); + message = QDBusMessage::createMethodCall(s_kwinService, "/" + QString::number(id), QString(), "run"); + reply = QDBusConnection::sessionBus().call(message); + if (reply.type() == QDBusMessage::ErrorMessage) { + qWarning() << reply.errorMessage(); + } + } +} + +K_EXPORT_PLASMA_APPLET_WITH_JSON(taskpanel, TaskPanel, "metadata.json") + +#include "taskpanel.moc" diff --git a/containments/taskpanel/taskpanel.h b/containments/taskpanel/taskpanel.h new file mode 100644 index 00000000..259b1bf8 --- /dev/null +++ b/containments/taskpanel/taskpanel.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2015 Marco Martin * + * + * * + * 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 TASKPANEL_H +#define TASKPANEL_H + + +#include + +class TaskPanel : public Plasma::Containment +{ + Q_OBJECT + +public: + TaskPanel( QObject *parent, const QVariantList &args ); + ~TaskPanel(); + + Q_INVOKABLE void executeScript(const QString &script); + +private: + +}; + +#endif diff --git a/shell/contents/layout.js b/shell/contents/layout.js index ea26268f..b7ee4134 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -20,3 +20,8 @@ var panel = new Panel("org.kde.phone.panel"); panel.addWidget("org.kde.plasma.networkmanagement"); panel.addWidget("org.kde.plasma.battery"); panel.height = 60; + +var bottomPanel = new Panel("org.kde.phone.taskpanel"); +bottomPanel.location = "bottom"; +bottomPanel.height = 80; +