From f8babd8b5c1ad3136d83e45b0304614620aff30e Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Tue, 2 Jan 2018 18:02:40 -0500 Subject: Added some specific data for desktop plugins into the JSON reader --- src-qt5/src-cpp/plugins-desktop.cpp | 32 ++++++++++++++++++++++++++++++-- src-qt5/src-cpp/plugins-desktop.h | 9 +++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src-qt5/src-cpp/plugins-desktop.cpp b/src-qt5/src-cpp/plugins-desktop.cpp index fdbd676d..edad2723 100644 --- a/src-qt5/src-cpp/plugins-desktop.cpp +++ b/src-qt5/src-cpp/plugins-desktop.cpp @@ -6,11 +6,15 @@ //=========================================== #include "plugins-desktop.h" +#include + // ============ // DT PLUGIN // ============ DTPlugin::DTPlugin(){ - + pluginIcon = QIcon(); + gridSize = QSize(1,1); + panelPossible = false; } DTPlugin::~DTPlugin(){ @@ -22,8 +26,32 @@ bool DTPlugin::isValid(){ bool ok = data.contains("name") && data.contains("qml") && data.contains("description"); ok &= containsDefault("name"); ok &= containsDefault("description"); + ok &= containsDefault("data"); if(ok) { - QJsonObject tmp = data.value("qml").toObject(); + QJsonObject tmp = data.value("data").toObject(); + + QString possibleS = tmp.value("panel_possible").toString(); + if(!possibleS.isEmpty() and (possibleS == "yes" or possibleS == "true")) + panelPossible = true; + + QString gridS = tmp.value("grid_size").toString(); + if(!gridS.isEmpty()) { + QStringList gridList = gridS.split("x"); + if(gridList.size() == 2) { + int width = gridList[0].toInt(); + int height = gridList[1].toInt(); + if(width != 0 and height != 0) + gridSize = QSize(width, height); + } + } + + QString iconS = tmp.value("plugin_icon").toString(); + if(!iconS.isEmpty()) { + pluginIcon = LXDG::findIcon(iconS,""); + } + + tmp = data.value("qml").toObject(); + QStringList mustexist; QString exec = tmp.value("exec").toString(); if(exec.isEmpty() || !exec.endsWith(".qml")){ return false; } diff --git a/src-qt5/src-cpp/plugins-desktop.h b/src-qt5/src-cpp/plugins-desktop.h index ed576db1..4d34f188 100644 --- a/src-qt5/src-cpp/plugins-desktop.h +++ b/src-qt5/src-cpp/plugins-desktop.h @@ -17,13 +17,22 @@ #include #include #include +#include class DTPlugin : public BasePlugin{ +private: + QSize gridSize; + bool panelPossible; + QIcon pluginIcon; public: DTPlugin(); ~DTPlugin(); virtual bool isValid() Q_DECL_OVERRIDE; + + QSize getSize { return gridSize; } + bool getPanelable { return panelPossible; } + QIcon getIcon { return pluginIcon; } }; #endif -- cgit