first work on plasmoid

This commit is contained in:
arcan1s 2014-12-26 08:22:26 +03:00
parent 030dec5e14
commit a35e9b0164
7 changed files with 270 additions and 37 deletions

View File

@ -29,6 +29,7 @@ include_directories (${CMAKE_SOURCE_DIR}
set (PLUGIN_NAME ${SUBPROJECT}) set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
message (STATUS ${SUBPROJECT_DESKTOP_IN})
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${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) file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h) 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}) qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE}) add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} ${Qt5Network_LIBRARIES}) 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
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 ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR}) install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})

View File

@ -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" #include "netctl.moc"

View File

@ -2,40 +2,82 @@
set (SUBPROJECT plasma_applet_netctl) set (SUBPROJECT plasma_applet_netctl)
message (STATUS "Subproject ${SUBPROJECT}") message (STATUS "Subproject ${SUBPROJECT}")
# find resources # 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 include(KDEInstallDirs)
find_package (KDE4 REQUIRED) include(KDECMakeSettings)
include (KDE4Defaults) include(KDECompilerSettings)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) include(ECMPackageConfigHelpers)
include_directories (${CMAKE_SOURCE_DIR} include(ECMOptionalAddSubdirectory)
${CMAKE_BINARY_DIR} include(FeatureSummary)
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR})
add_subdirectory (po) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
DBus
Network
Quick
Widgets
)
# set sources find_package(KF5 REQUIRED
set (PLUGIN_NAME ${SUBPROJECT}) I18n WindowSystem Service Completion WidgetsAddons KIO CoreAddons Wallet ItemViews XmlGui
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) ConfigWidgets IconThemes Solid DBusAddons Notifications Plasma Declarative Init KDELibs4Support)
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 set(dir plasmoid)
qt4_add_resources (QRC_SOURCES ${RESOURCES}) set(component org.kde.netctl)
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI}) set(root ${ARGV2})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${QRC_SOURCES}) set(type ${ARGV3})
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) 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(FILES ${dir}/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-${type}-${component}.desktop)
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})

View File

@ -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
}
}
}

View File

@ -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
}
}
}

View File

@ -5,16 +5,18 @@ Comment=Plasmoid for netctl
Type=Service Type=Service
Icon=netctl-gui-widget Icon=netctl-gui-widget
X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet X-KDE-ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_netctl 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-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com 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-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-Category=Network
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3 X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-NotificationArea=true