Add template for Plasma QML Applet with QML extension
Summary: Should help people to kick-off plasmoids which also use custom QML classes. Test Plan: Created new plasmoid from template using kdevelop. Reviewers: #plasma, mart Reviewed By: mart Subscribers: plasma-devel, #frameworks Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D5914
This commit is contained in:
parent
f38c9760d4
commit
4d5793c28a
@ -1,5 +1,6 @@
|
||||
set(apptemplate_DIRS
|
||||
qml-plasmoid
|
||||
qml-plasmoid-with-qml-extension
|
||||
cpp-plasmoid
|
||||
plasma-wallpaper
|
||||
)
|
||||
|
27
templates/qml-plasmoid-with-qml-extension/CMakeLists.txt
Normal file
27
templates/qml-plasmoid-with-qml-extension/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
project(plasma-%{APPNAMELC})
|
||||
|
||||
find_package(ECM 1.4.0 REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
find_package(KF5 REQUIRED COMPONENTS
|
||||
Plasma
|
||||
I18n
|
||||
)
|
||||
|
||||
find_package(Qt5 CONFIG REQUIRED COMPONENTS
|
||||
Qml
|
||||
Gui
|
||||
Core
|
||||
)
|
||||
|
||||
# plasmoid
|
||||
plasma_install_package(package org.kde.%{APPNAMELC})
|
||||
|
||||
# qml extension plugin
|
||||
add_subdirectory(plugin)
|
2
templates/qml-plasmoid-with-qml-extension/Messages.sh
Normal file
2
templates/qml-plasmoid-with-qml-extension/Messages.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#! /usr/bin/env bash
|
||||
$XGETTEXT `find . -name \*.qml` -o $podir/plasma_applet_%{APPNAMELC}.pot
|
29
templates/qml-plasmoid-with-qml-extension/README
Normal file
29
templates/qml-plasmoid-with-qml-extension/README
Normal file
@ -0,0 +1,29 @@
|
||||
Plasma Applet Template
|
||||
----------------------
|
||||
|
||||
-- Build instructions --
|
||||
|
||||
cd /where/your/applet/is/generated
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=MYPREFIX ..
|
||||
make
|
||||
make install
|
||||
|
||||
(MYPREFIX is where you install your Plasma setup, replace it accordingly)
|
||||
|
||||
Restart plasma to load the applet
|
||||
(in a terminal type:
|
||||
kquitapp plasmashell
|
||||
and then
|
||||
plasmashell)
|
||||
|
||||
or view it with
|
||||
plasmoidviewer -a YourAppletName
|
||||
|
||||
-- Tutorials and resources --
|
||||
The explanation of the QML part of the template
|
||||
https://techbase.kde.org/Development/Tutorials/Plasma5/QML2/GettingStarted
|
||||
|
||||
Plasma QML API explained
|
||||
https://techbase.kde.org/Development/Tutorials/Plasma2/QML2/API
|
@ -0,0 +1,36 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
|
||||
* *
|
||||
* 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 . *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
import org.kde.plasma.private.%{APPNAMELC} 1.0
|
||||
|
||||
Item {
|
||||
Plasmoid.fullRepresentation: ColumnLayout {
|
||||
anchors.fill: parent
|
||||
PlasmaComponents.Label {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
text: HelloWorld.text
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
[Desktop Entry]
|
||||
Name=%{APPNAME}
|
||||
Comment=what your app does in a few words
|
||||
|
||||
Icon=applications-system
|
||||
Type=Service
|
||||
ServiceTypes=Plasma/Applet
|
||||
|
||||
X-KDE-PluginInfo-Author=%{AUTHOR}
|
||||
X-KDE-PluginInfo-Email=%{EMAIL}
|
||||
X-KDE-PluginInfo-Name=%{APPNAMELC}
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://plasma.kde.org/
|
||||
X-KDE-PluginInfo-Category=Utilities
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-PluginInfo-Name=org.kde.%{APPNAMELC}
|
||||
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
X-Plasma-Requires-FileDialog=Unused
|
||||
X-Plasma-Requires-LaunchApp=Unused
|
||||
X-Plasma-DefaultSize=200,300
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
|
||||
* 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 "%{APPNAMELC}plugin.h"
|
||||
|
||||
#include <QJSEngine>
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
|
||||
static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
|
||||
QJSValue helloWorld = scriptEngine->newObject();
|
||||
helloWorld.setProperty("text", QStringLiteral("Hello world!"));
|
||||
return helloWorld;
|
||||
}
|
||||
|
||||
|
||||
void %{APPNAME}Plugin::registerTypes(const char* uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.%{APPNAMELC}"));
|
||||
|
||||
qmlRegisterSingletonType(uri, 1, 0, "HelloWorld", singletonTypeExampleProvider);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef %{APPNAMEUC}PLUGIN_H
|
||||
#define %{APPNAMEUC}PLUGIN_H
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
class %{APPNAME}Plugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
||||
public:
|
||||
void registerTypes(const char *uri) override;
|
||||
};
|
||||
|
||||
#endif // %{APPNAMEUC}PLUGIN_H
|
@ -0,0 +1,12 @@
|
||||
set(%{APPNAMELC}plugin_SRCS
|
||||
%{APPNAMELC}plugin.cpp
|
||||
)
|
||||
|
||||
add_library(%{APPNAMELC}plugin SHARED ${%{APPNAMELC}plugin_SRCS})
|
||||
|
||||
target_link_libraries(%{APPNAMELC}plugin
|
||||
Qt5::Gui
|
||||
Qt5::Qml
|
||||
)
|
||||
install(TARGETS %{APPNAMELC}plugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/%{APPNAMELC})
|
||||
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/%{APPNAMELC})
|
2
templates/qml-plasmoid-with-qml-extension/plugin/qmldir
Normal file
2
templates/qml-plasmoid-with-qml-extension/plugin/qmldir
Normal file
@ -0,0 +1,2 @@
|
||||
module org.kde.plasma.private.%{APPNAMELC}
|
||||
plugin %{APPNAMELC}plugin
|
@ -0,0 +1,4 @@
|
||||
[General]
|
||||
Name=Plasma QML Applet with QML extension
|
||||
Comment=A template for a Plasma applet which uses custom API provided by an own QML extension plugin
|
||||
Category=Plasma/Plasmoid
|
Loading…
x
Reference in New Issue
Block a user