diff --git a/engine/timetable/CMakeLists.txt b/engine/timetable/CMakeLists.txt index db8d8b8..913b27f 100644 --- a/engine/timetable/CMakeLists.txt +++ b/engine/timetable/CMakeLists.txt @@ -1,27 +1,26 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.publictransport.timetable\") plasma_install_package(plasmoid org.kde.plasma.publictransport.timetable) set ( timetable_SRCS plugin/timetableplugin.cpp plugin/timetablehelper.cpp + plugin/timetablebackend.cpp ) +install (FILES publictransport.knsrc DESTINATION ${CONFIG_INSTALL_DIR}) install (FILES plugin/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/publictransport/timetable) add_library (timetable SHARED ${timetable_SRCS}) -kcoreaddons_desktop_to_json(timetable plasmoid/metadata.desktop) - target_link_libraries (timetable Qt5::Core Qt5::Qml Qt5::Quick Qt5::Widgets KF5::Plasma KF5::NewStuff - KF5::CoreAddons KF5::KDELibs4Support ) -install (TARGETS timetable DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/publictransport/timetable) +install (TARGETS timetable DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/publictransport/timetable) \ No newline at end of file diff --git a/engine/timetable/plasmoid/contents/ui/CheckServiceproviders.qml b/engine/timetable/plasmoid/contents/ui/CheckServiceproviders.qml index 8d3bb2e..fb5db93 100644 --- a/engine/timetable/plasmoid/contents/ui/CheckServiceproviders.qml +++ b/engine/timetable/plasmoid/contents/ui/CheckServiceproviders.qml @@ -1,75 +1,77 @@ /*************************************************************************** * Copyright (C) 2016 by R. Harish Navnit * * * * 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.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.private.publictransport.timetable 0.1 as Timetable + Item { id: serviceproviderCheckRoot anchors.fill: parent + Timetable.TimetableBackend { + id: backend + } + PlasmaComponents.Label { id: errorLabel anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter } verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: i18n("Failed to locate any service providers" + "\nPlease download a service provider and try again") visible: false } PlasmaComponents.Button { id: downloadProvidersButton anchors { top: errorLabel.bottom topMargin: 2 horizontalCenter: parent.horizontalCenter } text: i18n("Download") visible: false - - // TODO: Integrate the applet code with the engine code - // Add a Q_INVOKABLE method to show service provider - // download dialog. - onClicked: plasmoid.nativeInterface.downloadNewProviders() + onClicked: backend.ghnsDialogRequested() } Loader { id: gtfsImportLoader anchors.fill: parent source: "GtfsService.qml" active: { var data = mainDataSource.data["ServiceProviders"] if (data == undefined) { // No service providers found // Prompt the user to download new service providers errorLabel.visible = true downloadProvidersButton.visible = true return false } return true } } } diff --git a/engine/timetable/plugin/timetablebackend.cpp b/engine/timetable/plugin/timetablebackend.cpp new file mode 100644 index 0000000..6bf31fa --- /dev/null +++ b/engine/timetable/plugin/timetablebackend.cpp @@ -0,0 +1,15 @@ +#include "timetablebackend.h" + +TimetableBackend::TimetableBackend(QObject *parent) + : QObject(parent), m_helper() +{ +} + +TimetableBackend::~TimetableBackend() +{ +} + +void TimetableBackend::ghnsDialogRequested() +{ + m_helper->showDialog(); +} \ No newline at end of file diff --git a/engine/timetable/plugin/timetablebackend.h b/engine/timetable/plugin/timetablebackend.h new file mode 100644 index 0000000..db109b7 --- /dev/null +++ b/engine/timetable/plugin/timetablebackend.h @@ -0,0 +1,23 @@ +#ifndef TIMETABLEBACKEND_H +#define TIMETABLEBACKEND_H + +#include "timetablehelper.h" + +#include + +class TimetableBackend : public QObject +{ + Q_OBJECT + +public: + TimetableBackend(QObject *parent=0); + ~TimetableBackend(); + +public slots: + Q_INVOKABLE void ghnsDialogRequested(); + +private: + TimetableHelper *m_helper; +}; + +#endif // TIMETABLEBACKEND_H \ No newline at end of file diff --git a/engine/timetable/plugin/timetablehelper.cpp b/engine/timetable/plugin/timetablehelper.cpp index b1afa4f..71cb944 100644 --- a/engine/timetable/plugin/timetablehelper.cpp +++ b/engine/timetable/plugin/timetablehelper.cpp @@ -1,32 +1,19 @@ #include "timetablehelper.h" #include TimetableHelper::TimetableHelper(QWidget* parent) : KDialog(parent) { } TimetableHelper::~TimetableHelper() { } -void TimetableHelper::displayDownloadDialog() +void TimetableHelper::showDialog() { KNS3::DownloadDialog *dialog = new KNS3::DownloadDialog("publictransport.knsrc", this); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); } - -TimetableExporter::TimetableExporter(QObject* parent, const QVariantList& data) -: Plasma::Applet(parent, data) -{ -} - -TimetableExporter::~TimetableExporter() -{ -} - -K_EXPORT_PLASMA_APPLET_WITH_JSON(timetableexporter, TimetableExporter, "metadata.json") - -#include "timetablehelper.moc" \ No newline at end of file diff --git a/engine/timetable/plugin/timetablehelper.h b/engine/timetable/plugin/timetablehelper.h index 22e8b78..96ea083 100644 --- a/engine/timetable/plugin/timetablehelper.h +++ b/engine/timetable/plugin/timetablehelper.h @@ -1,37 +1,25 @@ #ifndef TIMETABLEHELPER_H #define TIMETABLEHELPER_H #include #include #include #include /** * Class that aims to display the GHNS dialog * Enables the user to download new service providers */ class TimetableHelper : public KDialog { Q_OBJECT public: TimetableHelper(QWidget *parent=0); ~TimetableHelper(); - Q_INVOKABLE void displayDownloadDialog(); -}; - -/** - * Class to export the desktop file to json format - */ -class TimetableExporter : public Plasma::Applet -{ - Q_OBJECT - -public: - TimetableExporter(QObject *parent, const QVariantList &data); - ~TimetableExporter() override; + Q_INVOKABLE void showDialog(); }; #endif // TIMETABLEHELPER_H \ No newline at end of file diff --git a/engine/timetable/plugin/timetableplugin.cpp b/engine/timetable/plugin/timetableplugin.cpp index d55c926..08b96ad 100644 --- a/engine/timetable/plugin/timetableplugin.cpp +++ b/engine/timetable/plugin/timetableplugin.cpp @@ -1,10 +1,12 @@ #include "timetableplugin.h" #include "timetablehelper.h" +#include "timetablebackend.h" #include void TimetablePlugin::registerTypes(const char *uri) { Q_ASSERT( uri == QLatin1String("org.kde.plasma.private.publictransport.timetable") ); qmlRegisterType( uri, 0, 1, "TimetableHelper" ); + qmlRegisterType( uri, 0, 1, "TimetableBackend"); } diff --git a/engine/timetable/publictransport.knsrc b/engine/timetable/publictransport.knsrc new file mode 100644 index 0000000..3a6b28b --- /dev/null +++ b/engine/timetable/publictransport.knsrc @@ -0,0 +1,4 @@ +[KNewStuff3] +Categories=Plasma public transport timetable +TargetDir=plasma_engine_publictransport/serviceProviders +Uncompress=archive