diff --git a/sources/dataengine/CMakeLists.txt b/sources/dataengine/CMakeLists.txt index 2c1b074..24672bb 100644 --- a/sources/dataengine/CMakeLists.txt +++ b/sources/dataengine/CMakeLists.txt @@ -29,6 +29,7 @@ include_directories (${CMAKE_SOURCE_DIR} set (PLUGIN_NAME ${SUBPROJECT}) file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) +message (STATUS ${SUBPROJECT_DESKTOP_IN}) file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN}) file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp) set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h) @@ -41,8 +42,11 @@ configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJEC qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER}) add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE}) target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} ${Qt5Network_LIBRARIES}) +kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${SUBPROJECT_DESKTOP_IN}) +# kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${SUBPROJECT_DESKTOP}) # install -install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) +install (TARGETS ${PLUGIN_NAME} DESTINATION lib/qt/plugins/plasma/dataengine) +# install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/dataengine) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR}) install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR}) diff --git a/sources/dataengine/netctl.cpp b/sources/dataengine/netctl.cpp index 3f51029..bf8c4bf 100644 --- a/sources/dataengine/netctl.cpp +++ b/sources/dataengine/netctl.cpp @@ -387,6 +387,7 @@ bool Netctl::updateSourceEvent(const QString &source) } -K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl) +// K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl) +K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(netctl, Netctl, "plasma-dataengine-netctl.json") #include "netctl.moc" diff --git a/sources/dataengine/plasma-engine-netctl.desktop b/sources/dataengine/plasma-dataengine-netctl.desktop similarity index 100% rename from sources/dataengine/plasma-engine-netctl.desktop rename to sources/dataengine/plasma-dataengine-netctl.desktop diff --git a/sources/plasmoid/CMakeLists.txt b/sources/plasmoid/CMakeLists.txt index d795ae3..f05492e 100644 --- a/sources/plasmoid/CMakeLists.txt +++ b/sources/plasmoid/CMakeLists.txt @@ -2,40 +2,82 @@ set (SUBPROJECT plasma_applet_netctl) message (STATUS "Subproject ${SUBPROJECT}") # find resources -set (RESOURCES ${PROJECT_RESOURCE_DIR}/resources-plasmoid.qrc) +# set (RESOURCES ${PROJECT_RESOURCE_DIR}/resources-plasmoid.qrc) +# +# # find required libaries +# find_package (KDE4 REQUIRED) +# include (KDE4Defaults) +# +# add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) +# include_directories (${CMAKE_SOURCE_DIR} +# ${CMAKE_BINARY_DIR} +# ${KDE4_INCLUDES} +# ${CMAKE_CURRENT_BINARY_DIR} +# ${CMAKE_CURRENT_BINARY_DIR}/../ +# ${PROJECT_TRDPARTY_DIR}) +# +# # add_subdirectory (po) +# +# # set sources +# set (PLUGIN_NAME ${SUBPROJECT}) +# file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) +# file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN}) +# file (GLOB SUBPROJECT_NOTIFY *.notifyrc) +# file (GLOB SUBPROJECT_SOURCE *.cpp) +# file (GLOB_RECURSE SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui) +# +# # prepare +# configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP}) +# +# # make +# qt4_add_resources (QRC_SOURCES ${RESOURCES}) +# kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI}) +# kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${QRC_SOURCES}) +# target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) +# +# # install +# install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) +# install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR}) +# install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME}) +# plasma_install_package(plasmoid org.kde.netctl) +find_package(ECM 0.0.12 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -# find required libaries -find_package (KDE4 REQUIRED) -include (KDE4Defaults) +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings) -add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) -include_directories (${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - ${KDE4_INCLUDES} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/../ - ${PROJECT_TRDPARTY_DIR}) +include(ECMPackageConfigHelpers) +include(ECMOptionalAddSubdirectory) +include(FeatureSummary) -add_subdirectory (po) +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS + Core + DBus + Network + Quick + Widgets +) -# set sources -set (PLUGIN_NAME ${SUBPROJECT}) -file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) -file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN}) -file (GLOB SUBPROJECT_NOTIFY *.notifyrc) -file (GLOB SUBPROJECT_SOURCE *.cpp) -file (GLOB_RECURSE SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui) +find_package(KF5 REQUIRED + I18n WindowSystem Service Completion WidgetsAddons KIO CoreAddons Wallet ItemViews XmlGui + ConfigWidgets IconThemes Solid DBusAddons Notifications Plasma Declarative Init KDELibs4Support) -# prepare -configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP}) -# make -qt4_add_resources (QRC_SOURCES ${RESOURCES}) -kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI}) -kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${QRC_SOURCES}) -target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) +set(dir plasmoid) +set(component org.kde.netctl) +set(root ${ARGV2}) + set(type ${ARGV3}) + if(NOT root) + set(root plasmoids) + endif() + if(NOT type) + set(type applet) + endif() + install(DIRECTORY ${dir}/ DESTINATION ${PLASMA_DATA_INSTALL_DIR}/${root}/${component} + PATTERN CMakeLists.txt EXCLUDE + PATTERN README.txt EXCLUDE + PATTERN Messages.sh EXCLUDE + PATTERN dummydata EXCLUDE) -# install -install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) -install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR}) -install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME}) + install(FILES ${dir}/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-${type}-${component}.desktop) diff --git a/sources/plasmoid/plasmoid/contents/ui/main.qml b/sources/plasmoid/plasmoid/contents/ui/main.qml new file mode 100644 index 0000000..544b741 --- /dev/null +++ b/sources/plasmoid/plasmoid/contents/ui/main.qml @@ -0,0 +1,92 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui 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 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.2 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + + +Item { + id: main + + // variables + Text { + id: info + property string extip4: "127.0.0.1" + property string extip6: "::1" + property string intip4: "127.0.0.1" + property string intip6: "::1" + property var interfaces: ["lo"] + property var profiles: [] + property string status: "N\\A" + } + Text { + id: iconPath + property string active: "/usr/share/icons/hicolor/64x64/apps/netctl-idle.png" + property string inactive: "/usr/share/icons/hicolor/64x64/apps/netctl-offline.png" + } + property int interval: 1000 + property bool status: false + + PlasmaCore.DataSource { + id: mainData + engine: "netctl" + connectedSources: ["active", "current", "extip4", "extip6", "interfaces", "intip4", "intip6", "profiles", "status"] + interval: main.interval + + onNewData: { + if (data.isEmpty) return + if (sourceName == "active") { + if (data.value == "true") { + main.status = true + icon.source = iconPath.active + } else { + main.status = false + icon.source = iconPath.inactive + } + } else if (sourceName == "current") { + text.text = data.value + } else if (sourceName == "extip4") { + info.extip4 = data.value + } else if (sourceName == "extip6") { + info.extip6 = data.value + } else if (sourceName == "interfaces") { + info.interfaces = data.value + } else if (sourceName == "intip4") { + info.intip4 = data.value + } else if (sourceName == "intip6") { + info.intip6 = data.value + } else if (sourceName == "profiles") { + info.profiles = data.value + } else if (sourceName == "status") { + info.status = data.value + } + } + } + + Grid { + id: mainGrid + columns: 2 + + Image { + id: icon + } + Text { + id: text + } + } +} diff --git a/sources/plasmoid/plasmoid/contents/ui/main.qml.autosave b/sources/plasmoid/plasmoid/contents/ui/main.qml.autosave new file mode 100644 index 0000000..3a2c4c5 --- /dev/null +++ b/sources/plasmoid/plasmoid/contents/ui/main.qml.autosave @@ -0,0 +1,92 @@ +/*************************************************************************** + * This file is part of netctl-gui * + * * + * netctl-gui 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 3 of the * + * License, or (at your option) any later version. * + * * + * netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.2 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + + +Item { + id: main + + // variables + Text { + id: info + property string extip4: "127.0.0.1" + property string extip6: "::1" + property string intip4: "127.0.0.1" + property string intip6: "::1" + property var interfaces: ["lo"] + property var profiles: [] + property string status: "N\\A" + } + Text { + id: iconPath + property string active: "/usr/share/icons/hicolor/64x64/apps/netctl-idle.png" + property string inactive: "/usr/share/icons/hicolor/64x64/apps/netctl-offline.png" + } + property int interval: 1000 + property bool status: false + + PlasmaCore.DataSource { + id: mainData + engine: "" + connectedSources: ["active", "current", "extip4", "extip6", "interfaces", "intip4", "intip6", "profiles", "status"] + interval: main.interval + + onNewData: { + if (data.isEmpty) return + if (sourceName == "active") { + if (data.value == "true") { + main.status = true + icon.source = iconPath.active + } else { + main.status = false + icon.source = iconPath.inactive + } + } else if (sourceName == "current") { + text.text = data.value + } else if (sourceName == "extip4") { + info.extip4 = data.value + } else if (sourceName == "extip6") { + info.extip6 = data.value + } else if (sourceName == "interfaces") { + info.interfaces = data.value + } else if (sourceName == "intip4") { + info.intip4 = data.value + } else if (sourceName == "intip6") { + info.intip6 = data.value + } else if (sourceName == "profiles") { + info.profiles = data.value + } else if (sourceName == "status") { + info.status = data.value + } + } + } + + Grid { + id: mainGrid + columns: 2 + + Image { + id: icon + } + Text { + id: text + } + } +} diff --git a/sources/plasmoid/plasma-applet-netctl.desktop b/sources/plasmoid/plasmoid/metadata.desktop similarity index 64% rename from sources/plasmoid/plasma-applet-netctl.desktop rename to sources/plasmoid/plasmoid/metadata.desktop index ef2656a..11757e8 100644 --- a/sources/plasmoid/plasma-applet-netctl.desktop +++ b/sources/plasmoid/plasmoid/metadata.desktop @@ -5,16 +5,18 @@ Comment=Plasmoid for netctl Type=Service Icon=netctl-gui-widget -X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet -X-KDE-Library=plasma_applet_netctl +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-Plasma-MainScript=ui/main.qml +X-Plasma-NotificationArea=true +X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis X-KDE-PluginInfo-Email=esalexeev@gmail.com -X-KDE-PluginInfo-Name=netctl +X-KDE-PluginInfo-Name=org.kde.netctl X-KDE-PluginInfo-Version=@PROJECT_VERSION@ -X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid +X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui X-KDE-PluginInfo-Category=Network X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPLv3 X-KDE-PluginInfo-EnabledByDefault=true -X-Plasma-NotificationArea=true