From 221ad0bbe8e724c48520f1a9ba4a75b9daef928a Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Sat, 6 Apr 2019 17:27:18 -0400 Subject: [PATCH] Turn template into dataengine project. --- CMakeLists.txt | 8 +-- README | 5 ++ src/CMakeLists.txt | 19 +++--- src/main.cpp | 62 ------------------- src/org.example.simplecastengine.appdata.xml | 23 ------- src/org.example.simplecastengine.desktop | 9 --- ...plasma_dataengine_simplecastengine.desktop | 17 +++++ ...astenginewindow.h => simplecastengine.cpp} | 55 +++++++--------- ...astenginewindow.cpp => simplecastengine.h} | 28 +++++---- src/simplecastengine.ui | 28 --------- 10 files changed, 72 insertions(+), 182 deletions(-) delete mode 100644 src/main.cpp delete mode 100644 src/org.example.simplecastengine.appdata.xml delete mode 100644 src/org.example.simplecastengine.desktop create mode 100644 src/plasma_dataengine_simplecastengine.desktop rename src/{simplecastenginewindow.h => simplecastengine.cpp} (50%) rename src/{simplecastenginewindow.cpp => simplecastengine.h} (65%) delete mode 100644 src/simplecastengine.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index ba7eeac..aba6555 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,20 +11,18 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) -include(ECMInstallIcons) include(FeatureSummary) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core) find_package(KF5 ${KF_MIN_VERSION} REQUIRED COMPONENTS CoreAddons + Service + Plasma I18n ) add_subdirectory(src) -add_subdirectory(icons) -# Make it possible to use the po files fetched by the fetch-translations step -ki18n_install(po) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/README b/README index 21a8f91..26821f5 100644 --- a/README +++ b/README @@ -15,3 +15,8 @@ where $KDEDIRS points to your KDE installation prefix. Note: you can use another build path. Then cd in your build dir and: export KDE_SRC=path_to_your_src cmake $KDE_SRC -DCMAKE_INSTALL_PREFIX=$KDEDIRS -DCMAKE_BUILD_TYPE=Debug + +Requires: +* KDNSSD +* youtube-dl +* QtMultimedia diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e62d32a..093ef41 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,18 +1,17 @@ set( simplecastengine_SRCS - main.cpp - simplecastenginewindow.cpp + simplecastengine.cpp ) -ki18n_wrap_ui(simplecastengine_SRCS simplecastengine.ui) +add_library( plasma_dataengine_simplecastengine ${simplecastengine_SRCS} ) -add_executable( simplecastengine ${simplecastengine_SRCS} ) +kcoreaddons_desktop_to_json(plasma_dataengine_simplecastengine plasma_dataengine_simplecastengine.desktop) -target_link_libraries( simplecastengine - KF5::CoreAddons +target_link_libraries( plasma_dataengine_simplecastengine + Qt5::Core + KF5::Plasma + KF5::Service KF5::I18n - Qt5::Widgets ) -install( TARGETS simplecastengine ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) -install( PROGRAMS org.example.simplecastengine.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) -install( FILES org.example.simplecastengine.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) +install(TARGETS plasma_dataengine_simplecastengine DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/dataengine) +install( PROGRAMS org.eyecreate.simplecastengine.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 8fa82b7..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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, see . -*/ - -// application header -#include "simplecastenginewindow.h" - -// KF headers -#include -#include - -// Qt headers -#include -#include - -int main(int argc, char **argv) -{ - QApplication application(argc, argv); - - KLocalizedString::setApplicationDomain("simplecastengine"); - - KAboutData aboutData( QStringLiteral("simplecastengine"), - i18n("SimpleCastEngine"), - QStringLiteral("%{VERSION}"), - i18n("A Simple Application written with KDE Frameworks"), - KAboutLicense::GPL, - i18n("Copyright %{CURRENT_YEAR}, %{AUTHOR} <%{EMAIL}>")); - - aboutData.addAuthor(i18n("%{AUTHOR}"),i18n("Author"), QStringLiteral("%{EMAIL}")); - aboutData.setOrganizationDomain("example.org"); - aboutData.setDesktopFileName(QStringLiteral("org.example.simplecastengine")); - - KAboutData::setApplicationData(aboutData); - application.setWindowIcon(QIcon::fromTheme(QStringLiteral("simplecastengine"))); - - QCommandLineParser parser; - aboutData.setupCommandLine(&parser); - - parser.process(application); - aboutData.processCommandLine(&parser); - - SimpleCastEngineWindow *mainWindow = new SimpleCastEngineWindow; - mainWindow->show(); - - return application.exec(); -} diff --git a/src/org.example.simplecastengine.appdata.xml b/src/org.example.simplecastengine.appdata.xml deleted file mode 100644 index f226d00..0000000 --- a/src/org.example.simplecastengine.appdata.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - org.example.simplecastengine.desktop - CC0-1.0 - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-metadata_license - SimpleCastEngine - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-summary - -

https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-description

-
- https://www.example.org - https://bugs.example.org - https://www.example.org/community/donations - - - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-screenshots - - - - simplecastengine - - KDE -
diff --git a/src/org.example.simplecastengine.desktop b/src/org.example.simplecastengine.desktop deleted file mode 100644 index ebf1671..0000000 --- a/src/org.example.simplecastengine.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application - -Name=SimpleCastEngine -GenericName=A Simple KDE Application -Icon=simplecastengine - -Exec=simplecastengine -StartupWMClass=simplecastengine diff --git a/src/plasma_dataengine_simplecastengine.desktop b/src/plasma_dataengine_simplecastengine.desktop new file mode 100644 index 0000000..947f8b6 --- /dev/null +++ b/src/plasma_dataengine_simplecastengine.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Name=Simple Cast Engine +Comment=Data Engine that handles listing, queueing, and playing media URLs from other devices. +Type=Service + +X-KDE-ServiceTypes=Plasma/DataEngine +X-KDE-Library=plasma_dataengine_simplecast +X-Plasma-EngineName=simplecast +X-KDE-PluginInfo-Author=Kevin Whitaker +X-KDE-PluginInfo-Email=eyecreate@eyecreate.org +X-KDE-PluginInfo-Name=simplecast +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Category=Examples +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true diff --git a/src/simplecastenginewindow.h b/src/simplecastengine.cpp similarity index 50% rename from src/simplecastenginewindow.h rename to src/simplecastengine.cpp index 246e610..4b604d6 100644 --- a/src/simplecastenginewindow.h +++ b/src/simplecastengine.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + Copyright (C) 2019 by Kevin Whitaker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -18,40 +18,27 @@ along with this program. If not, see . */ -#ifndef SIMPLECASTENGINEWINDOW_H -#define SIMPLECASTENGINEWINDOW_H +#include "simplecastengine.h" +SimpleCastEngine::SimpleCastEngine(QObject *parent, const QVariantList &args) + : Plasma::DataEngine(parent,args) +{ + Q_UNUSED(args) + setMinimumPollingInterval(333); +} -#include "ui_simplecastengine.h" - -#include +bool SimpleCastEngine::sourceRequestEvent(const QString& source) +{ + return updateSourceEvent(source);//TODO +} -/** - * This class serves as the main window for SimpleCastEngine. It handles the - * menus, toolbars and status bars. - * - * @short Main window class - * @author %{AUTHOR} <%{EMAIL}> - * @version %{VERSION} - */ -class SimpleCastEngineWindow : public QMainWindow +bool SimpleCastEngine::updateSourceEvent(const QString& source) { - Q_OBJECT -public: - /** - * Default Constructor - */ - SimpleCastEngineWindow(); - - /** - * Default Destructor - */ - ~SimpleCastEngineWindow() override; - -private: - // this is the name of the root widget inside our Ui file - // you can rename it in designer and then change it here - Ui::mainWidget m_ui; -}; - -#endif // SIMPLECASTENGINEWINDOW_H + return true;//TODO +} + + + +K_EXPORT_PLASMA_DATAENGINE(simplecast, SimpleCastEngine) + +#include "simplecastengine.moc" diff --git a/src/simplecastenginewindow.cpp b/src/simplecastengine.h similarity index 65% rename from src/simplecastenginewindow.cpp rename to src/simplecastengine.h index 68ef726..6457368 100644 --- a/src/simplecastenginewindow.cpp +++ b/src/simplecastengine.h @@ -1,5 +1,5 @@ /* - Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> + Copyright (C) 2019 by Kevin Whitaker This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -18,16 +18,22 @@ along with this program. If not, see . */ -#include "simplecastenginewindow.h" +#ifndef SIMPLECASTENGINE_H +#define SIMPLECASTENGINE_H -SimpleCastEngineWindow::SimpleCastEngineWindow() - : QMainWindow() -{ - QWidget *widget = new QWidget(this); - setCentralWidget(widget); - m_ui.setupUi(widget); -} -SimpleCastEngineWindow::~SimpleCastEngineWindow() +#include + +class SimpleCastEngine : public Plasma::DataEngine { -} + Q_OBJECT +public: + SimpleCastEngine(QObject *parent, const QVariantList &args); + +protected: + bool sourceRequestEvent(const QString &source); + bool updateSourceEvent(const QString &source); + +}; + +#endif // SIMPLECASTENGINE_H diff --git a/src/simplecastengine.ui b/src/simplecastengine.ui deleted file mode 100644 index c133702..0000000 --- a/src/simplecastengine.ui +++ /dev/null @@ -1,28 +0,0 @@ - - - mainWidget - - - - 0 - 0 - 400 - 300 - - - - - - - Hello world! - - - Qt::AlignCenter - - - - - - - - -- GitLab