mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2026-10-13 18:32:15 +00:00
create a static library for backend items
move backend items to template-based mechanism
This commit is contained in:
1 parent
3b6df44489
commit
c61a5ac092
47 files changed
+608
-171
No files matched your search
@@ -45,7 +45,9 @@ endif ()
|
|||||||
|
|
||||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||||
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||||
|
set (PROJECT_LIBRARY awesomewidgets)
|
||||||
|
|
||||||
|
add_subdirectory (awesomewidgets)
|
||||||
add_subdirectory (extsysmon)
|
add_subdirectory (extsysmon)
|
||||||
add_subdirectory (awesome-widget)
|
add_subdirectory (awesome-widget)
|
||||||
add_subdirectory (desktop-panel)
|
add_subdirectory (desktop-panel)
|
||||||
|
|||||||
@@ -13,27 +13,19 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/
|
||||||
${PROJECT_TRDPARTY_DIR}
|
${PROJECT_TRDPARTY_DIR}
|
||||||
../../extsysmon
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../../extsysmon
|
|
||||||
${Qt_INCLUDE}
|
${Qt_INCLUDE}
|
||||||
${Kf5_INCLUDE})
|
${Kf5_INCLUDE})
|
||||||
|
|
||||||
# task source is required by extscripts
|
# task source is required by extscripts
|
||||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp)
|
||||||
${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp
|
|
||||||
../../extsysmon/abstractextitem.cpp
|
|
||||||
../../extsysmon/extquotes.cpp
|
|
||||||
../../extsysmon/extscript.cpp
|
|
||||||
../../extsysmon/extupgrade.cpp
|
|
||||||
../../extsysmon/extweather.cpp
|
|
||||||
../../extsysmon/graphicalitem.cpp)
|
|
||||||
file (GLOB SUBPROJECT_UI *.ui)
|
file (GLOB SUBPROJECT_UI *.ui)
|
||||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
|
|
||||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
|
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
target_link_libraries (${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||||
|
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# set project name
|
||||||
|
set (SUBPROJECT ${PROJECT_LIBRARY})
|
||||||
|
message (STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
||||||
|
|
||||||
|
# find required libaries
|
||||||
|
find_package (Qt5 REQUIRED COMPONENTS Core Network Widgets)
|
||||||
|
|
||||||
|
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}
|
||||||
|
${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
|
||||||
|
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}
|
||||||
|
${Qt5Network_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${PROJECT_TRDPARTY_DIR}
|
||||||
|
${Qt_INCLUDE})
|
||||||
|
|
||||||
|
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp)
|
||||||
|
file (GLOB SUBPROJECT_HEADER *.h ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.h)
|
||||||
|
file (GLOB SUBPROJECT_UI *.ui)
|
||||||
|
set (SUBPROJECT_GRAPHITEMS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||||
|
set (SUBPROJECT_QUOTES ${CMAKE_CURRENT_SOURCE_DIR}/quotes)
|
||||||
|
set (SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
|
||||||
|
set (SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
|
||||||
|
set (SUBPROJECT_WEATHER ${CMAKE_CURRENT_SOURCE_DIR}/weather)
|
||||||
|
|
||||||
|
# make
|
||||||
|
qt5_wrap_cpp (SUBPROJECT_MOC_SOURCE ${SUBPROJECT_HEADER})
|
||||||
|
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
|
add_library (${SUBPROJECT} STATIC ${SUBPROJECT_SOURCE} ${SUBPROJECT_MOC_SOURCE}
|
||||||
|
${SUBPROJECT_HEADER} ${SUBPROJECT_UI_HEADER})
|
||||||
|
target_link_libraries (${SUBPROJECT} ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||||
|
|
||||||
|
# install
|
||||||
|
install (DIRECTORY ${SUBPROJECT_GRAPHITEMS} DESTINATION share/${PROJECT_NAME})
|
||||||
|
install (DIRECTORY ${SUBPROJECT_QUOTES} DESTINATION share/${PROJECT_NAME})
|
||||||
|
install (DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION share/${PROJECT_NAME})
|
||||||
|
install (DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION share/${PROJECT_NAME})
|
||||||
|
install (DIRECTORY ${SUBPROJECT_WEATHER} DESTINATION share/${PROJECT_NAME})
|
||||||
@@ -45,6 +45,18 @@ AbstractExtItem::~AbstractExtItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T *AbstractExtItem::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
Q_UNUSED(fileName)
|
||||||
|
Q_UNUSED(number)
|
||||||
|
|
||||||
|
// an analog of pure virtual method
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AbstractExtItem::apiVersion() const
|
int AbstractExtItem::apiVersion() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -34,12 +34,14 @@ class AbstractExtItem : public QDialog
|
|||||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||||
|
Q_PROPERTY(QString uniq READ uniq)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
virtual ~AbstractExtItem();
|
virtual ~AbstractExtItem();
|
||||||
|
template <class T> T *copy(const QString fileName, const int number);
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion() const;
|
int apiVersion() const;
|
||||||
QString comment() const;
|
QString comment() const;
|
||||||
@@ -50,6 +52,7 @@ public:
|
|||||||
QString name() const;
|
QString name() const;
|
||||||
int number() const;
|
int number() const;
|
||||||
QString tag(const QString _type) const;
|
QString tag(const QString _type) const;
|
||||||
|
virtual QString uniq() const = 0;
|
||||||
// set methods
|
// set methods
|
||||||
void setApiVersion(const int _apiVersion = 0);
|
void setApiVersion(const int _apiVersion = 0);
|
||||||
void setActive(const bool _state = true);
|
void setActive(const bool _state = true);
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "abstractextitemaggregator.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool debugCmd)
|
||||||
|
: QWidget(parent),
|
||||||
|
debug(debugCmd)
|
||||||
|
{
|
||||||
|
dialog = new QDialog(this);
|
||||||
|
widgetDialog = new QListWidget(dialog);
|
||||||
|
dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
|
||||||
|
Qt::Vertical, dialog);
|
||||||
|
copyButton = dialogButtons->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
|
||||||
|
createButton = dialogButtons->addButton(tr("Create"), QDialogButtonBox::ActionRole);
|
||||||
|
deleteButton = dialogButtons->addButton(tr("Remove"), QDialogButtonBox::ActionRole);
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||||
|
layout->addWidget(widgetDialog);
|
||||||
|
layout->addWidget(dialogButtons);
|
||||||
|
dialog->setLayout(layout);
|
||||||
|
|
||||||
|
connect(dialogButtons, SIGNAL(clicked(QAbstractButton *)),
|
||||||
|
this, SLOT(editItemButtonPressed(QAbstractButton *)));
|
||||||
|
connect(dialogButtons, SIGNAL(rejected()), dialog, SLOT(reject()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItemAggregator::~AbstractExtItemAggregator()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
if (static_cast<QPushButton *>(button) == copyButton)
|
||||||
|
return copyItem();
|
||||||
|
else if (static_cast<QPushButton *>(button) == createButton)
|
||||||
|
return createItem();
|
||||||
|
else if (dynamic_cast<QPushButton *>(button) == deleteButton)
|
||||||
|
return deleteItem();
|
||||||
|
else if (dialogButtons->buttonRole(button) == QDialogButtonBox::AcceptRole)
|
||||||
|
return editItem();
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ABSTRACTEXTITEMAGGREGATOR_H
|
||||||
|
#define ABSTRACTEXTITEMAGGREGATOR_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractExtItemAggregator : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AbstractExtItemAggregator(QWidget *parent = nullptr, const bool debugCmd = false);
|
||||||
|
virtual ~AbstractExtItemAggregator();
|
||||||
|
// ui
|
||||||
|
QDialog *dialog = nullptr;
|
||||||
|
QListWidget *widgetDialog = nullptr;
|
||||||
|
QDialogButtonBox *dialogButtons = nullptr;
|
||||||
|
QPushButton *copyButton = nullptr;
|
||||||
|
QPushButton *createButton = nullptr;
|
||||||
|
QPushButton *deleteButton = nullptr;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void editItemButtonPressed(QAbstractButton *button);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool debug;
|
||||||
|
// methods
|
||||||
|
virtual void copyItem() = 0;
|
||||||
|
virtual void createItem() = 0;
|
||||||
|
virtual void deleteItem() = 0;
|
||||||
|
virtual void editItem() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,234 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef EXTITEMAGGREGATOR_H
|
||||||
|
#define EXTITEMAGGREGATOR_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
#include "abstractextitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
template <class T> class ExtItemAggregator : public AbstractExtItemAggregator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ExtItemAggregator(QWidget *parent, const QString type,
|
||||||
|
const bool debugCmd = false)
|
||||||
|
: AbstractExtItemAggregator(parent, debugCmd),
|
||||||
|
debug(debugCmd),
|
||||||
|
m_type(type)
|
||||||
|
{
|
||||||
|
initItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
~ExtItemAggregator()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
m_items.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getName() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
QString name = QInputDialog::getText(nullptr, tr("Enter file name"),
|
||||||
|
tr("File name"), QLineEdit::Normal,
|
||||||
|
QString(""), &ok);
|
||||||
|
if ((!ok) || (name.isEmpty())) return QString("");
|
||||||
|
if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
|
||||||
|
|
||||||
|
return name;
|
||||||
|
};
|
||||||
|
|
||||||
|
void editItems()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
int ret = dialog->exec();
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Dialog returns" << ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initItems()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
m_items.clear();
|
||||||
|
m_items = getItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
T *itemFromWidget() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QListWidgetItem *item = widgetDialog->currentItem();
|
||||||
|
if (item == nullptr) return nullptr;
|
||||||
|
|
||||||
|
int originalItem = -1;
|
||||||
|
for (int i=0; i<m_items.count(); i++) {
|
||||||
|
if (m_items[i]->fileName() != item->text()) continue;
|
||||||
|
originalItem = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return originalItem == -1 ? nullptr : m_items[originalItem];
|
||||||
|
};
|
||||||
|
|
||||||
|
QList<T *> items() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_items;
|
||||||
|
};
|
||||||
|
|
||||||
|
int uniqNumber() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QList<int> tagList;
|
||||||
|
for (int i=0; i<m_items.count(); i++)
|
||||||
|
tagList.append(m_items[i]->number());
|
||||||
|
int number = 0;
|
||||||
|
while (tagList.contains(number))
|
||||||
|
number++;
|
||||||
|
|
||||||
|
return number;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool debug;
|
||||||
|
QList<T *> m_items;
|
||||||
|
QString m_type;
|
||||||
|
// init method
|
||||||
|
QList<T *> getItems()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
// create directory at $HOME
|
||||||
|
QString localDir = QString("%1/awesomewidgets/%2")
|
||||||
|
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
|
||||||
|
.arg(m_type);
|
||||||
|
QDir localDirectory;
|
||||||
|
if (localDirectory.mkpath(localDir))
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||||
|
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
QStringList names;
|
||||||
|
QList<T *> items;
|
||||||
|
for (int i=0; i<dirs.count(); i++) {
|
||||||
|
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||||
|
for (int j=0; j<files.count(); j++) {
|
||||||
|
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||||
|
if (names.contains(files[j])) continue;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||||
|
names.append(files[j]);
|
||||||
|
items.append(new T(this, files[j], dirs, debug));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
|
void repaint()
|
||||||
|
{
|
||||||
|
widgetDialog->clear();
|
||||||
|
for (int i=0; i<m_items.count(); i++) {
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(m_items[i]->fileName(), widgetDialog);
|
||||||
|
QStringList tooltip;
|
||||||
|
tooltip.append(tr("Name: %1").arg(m_items[i]->name()));
|
||||||
|
tooltip.append(tr("Comment: %1").arg(m_items[i]->comment()));
|
||||||
|
tooltip.append(tr("Identity: %1").arg(m_items[i]->uniq()));
|
||||||
|
item->setToolTip(tooltip.join(QChar('\n')));
|
||||||
|
widgetDialog->addItem(item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// methods
|
||||||
|
void copyItem()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
QString fileName = getName();
|
||||||
|
int number = uniqNumber();
|
||||||
|
if ((source == nullptr) || (fileName.isEmpty())) return;
|
||||||
|
|
||||||
|
T *newItem = source->copy(fileName, number);
|
||||||
|
if (newItem->showConfiguration() == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void createItem()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString fileName = getName();
|
||||||
|
int number = uniqNumber();
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
if (fileName.isEmpty()) return;
|
||||||
|
|
||||||
|
T *newItem = new T(this, fileName, dirs, debug);
|
||||||
|
newItem->setNumber(number);
|
||||||
|
if (newItem->showConfiguration() == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void deleteItem()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
if (source == nullptr) return;
|
||||||
|
|
||||||
|
if (source->tryDelete()) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void editItem()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
if (source == nullptr) return;
|
||||||
|
|
||||||
|
if (source->showConfiguration() == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXTITEMAGGREGATOR_H */
|
||||||
@@ -68,6 +68,24 @@ ExtQuotes::~ExtQuotes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), fileName,
|
||||||
|
directories(), debug);
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(number);
|
||||||
|
item->setTicker(ticker());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtQuotes::ticker() const
|
QString ExtQuotes::ticker() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -76,6 +94,14 @@ QString ExtQuotes::ticker() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtQuotes::uniq() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_ticker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtQuotes::setTicker(const QString _ticker)
|
void ExtQuotes::setTicker(const QString _ticker)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -40,8 +40,10 @@ public:
|
|||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
~ExtQuotes();
|
~ExtQuotes();
|
||||||
|
ExtQuotes *copy(const QString fileName, const int number);
|
||||||
// get methods
|
// get methods
|
||||||
QString ticker() const;
|
QString ticker() const;
|
||||||
|
QString uniq() const;
|
||||||
// set methods
|
// set methods
|
||||||
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
||||||
|
|
||||||
File renamed without changes.
@@ -59,6 +59,27 @@ ExtScript::~ExtScript()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtScript *ExtScript::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), fileName,
|
||||||
|
directories(), debug);
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setExecutable(executable());
|
||||||
|
item->setHasOutput(hasOutput());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(number);
|
||||||
|
item->setPrefix(prefix());
|
||||||
|
item->setRedirect(redirect());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::executable() const
|
QString ExtScript::executable() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -99,6 +120,14 @@ ExtScript::Redirect ExtScript::redirect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::uniq() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::strRedirect() const
|
QString ExtScript::strRedirect() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -48,12 +48,14 @@ public:
|
|||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
~ExtScript();
|
~ExtScript();
|
||||||
|
ExtScript *copy(const QString fileName, const int number);
|
||||||
// get methods
|
// get methods
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
QStringList filters() const;
|
QStringList filters() const;
|
||||||
bool hasOutput() const;
|
bool hasOutput() const;
|
||||||
QString prefix() const;
|
QString prefix() const;
|
||||||
Redirect redirect() const;
|
Redirect redirect() const;
|
||||||
|
QString uniq() const;
|
||||||
// derivatives
|
// derivatives
|
||||||
QString strRedirect() const;
|
QString strRedirect() const;
|
||||||
// set methods
|
// set methods
|
||||||
File renamed without changes.
@@ -55,6 +55,25 @@ ExtUpgrade::~ExtUpgrade()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), fileName,
|
||||||
|
directories(), debug);
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setExecutable(executable());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(number);
|
||||||
|
item->setNull(null());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtUpgrade::executable() const
|
QString ExtUpgrade::executable() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -71,6 +90,14 @@ int ExtUpgrade::null() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtUpgrade::uniq() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtUpgrade::setExecutable(const QString _executable)
|
void ExtUpgrade::setExecutable(const QString _executable)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -38,9 +38,11 @@ public:
|
|||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
~ExtUpgrade();
|
~ExtUpgrade();
|
||||||
|
ExtUpgrade *copy(const QString fileName, const int number);
|
||||||
// get methods
|
// get methods
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
int null() const;
|
int null() const;
|
||||||
|
QString uniq() const;
|
||||||
// set methods
|
// set methods
|
||||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||||
void setNull(const int _null = 0);
|
void setNull(const int _null = 0);
|
||||||
File renamed without changes.
@@ -65,6 +65,26 @@ ExtWeather::~ExtWeather()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtWeather *ExtWeather::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), fileName,
|
||||||
|
directories(), debug);
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setCity(city());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setCountry(country());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(number);
|
||||||
|
item->setTs(ts());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtWeather::weatherFromInt(const int _id) const
|
QString ExtWeather::weatherFromInt(const int _id) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -189,6 +209,14 @@ int ExtWeather::ts() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::uniq() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtWeather::setCity(const QString _city)
|
void ExtWeather::setCity(const QString _city)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -43,11 +43,13 @@ public:
|
|||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
~ExtWeather();
|
~ExtWeather();
|
||||||
|
ExtWeather *copy(const QString fileName, const int number);
|
||||||
QString weatherFromInt(const int _id) const;
|
QString weatherFromInt(const int _id) const;
|
||||||
// get methods
|
// get methods
|
||||||
QString city() const;
|
QString city() const;
|
||||||
QString country() const;
|
QString country() const;
|
||||||
int ts() const;
|
int ts() const;
|
||||||
|
QString uniq() const;
|
||||||
// set methods
|
// set methods
|
||||||
void setCity(const QString _city = QString("London"));
|
void setCity(const QString _city = QString("London"));
|
||||||
void setCountry(const QString _country = QString("uk"));
|
void setCountry(const QString _country = QString("uk"));
|
||||||
File renamed without changes.
@@ -54,6 +54,30 @@ GraphicalItem::~GraphicalItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()),
|
||||||
|
fileName, directories(), debug);
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setActiveColor(activeColor());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setBar(bar());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setDirection(direction());
|
||||||
|
item->setHeight(height());
|
||||||
|
item->setInactiveColor(inactiveColor());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(QString("bar%1").arg(number));
|
||||||
|
item->setNumber(number);
|
||||||
|
item->setType(type());
|
||||||
|
item->setWidth(width());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::image(const float value) const
|
QString GraphicalItem::image(const float value) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -229,6 +253,14 @@ int GraphicalItem::width() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString GraphicalItem::uniq() const
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setBar(const QString _bar)
|
void GraphicalItem::setBar(const QString _bar)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList(),
|
||||||
const bool debugCmd = false);
|
const bool debugCmd = false);
|
||||||
~GraphicalItem();
|
~GraphicalItem();
|
||||||
|
GraphicalItem *copy(const QString fileName, const int number);
|
||||||
QString image(const float value) const;
|
QString image(const float value) const;
|
||||||
// get methods
|
// get methods
|
||||||
QString bar() const;
|
QString bar() const;
|
||||||
@@ -64,6 +65,7 @@ public:
|
|||||||
QString strDirection() const;
|
QString strDirection() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
int width() const;
|
int width() const;
|
||||||
|
QString uniq() const;
|
||||||
// set methods
|
// set methods
|
||||||
void setBar(const QString _bar = QString("cpu"));
|
void setBar(const QString _bar = QString("cpu"));
|
||||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
|||||||
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
||||||
|
|
||||||
# find required libaries
|
# find required libaries
|
||||||
find_package (Qt5 REQUIRED COMPONENTS DBus Network Widgets)
|
find_package (Qt5 REQUIRED COMPONENTS DBus Network)
|
||||||
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||||
find_package (KF5 REQUIRED COMPONENTS Plasma Service WindowSystem)
|
find_package (KF5 REQUIRED COMPONENTS Plasma Service WindowSystem)
|
||||||
@@ -15,31 +15,25 @@ include (KDECMakeSettings)
|
|||||||
include (KDECompilerSettings)
|
include (KDECompilerSettings)
|
||||||
|
|
||||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}
|
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}
|
||||||
${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
|
${Qt5Network_DEFINITIONS})
|
||||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}
|
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}
|
||||||
${Qt5Network_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
${Qt5Network_INCLUDE_DIRS})
|
||||||
set (KDE_INCLUDE ${Plasma_INCLUDE_DIR})
|
set (KDE_INCLUDE ${Plasma_INCLUDE_DIR})
|
||||||
|
|
||||||
include_directories (${CMAKE_SOURCE_DIR}
|
include_directories (${CMAKE_SOURCE_DIR}
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/
|
||||||
${PROJECT_TRDPARTY_DIR}
|
${PROJECT_TRDPARTY_DIR}
|
||||||
${Qt_INCLUDE}
|
${Qt_INCLUDE}
|
||||||
${KDE_INCLUDE})
|
${KDE_INCLUDE})
|
||||||
|
|
||||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||||
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)
|
||||||
${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp)
|
|
||||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||||
file (GLOB SUBPROJECT_UI *.ui)
|
|
||||||
file (GLOB SUBPROJECT_CONF *.conf)
|
file (GLOB SUBPROJECT_CONF *.conf)
|
||||||
set (SUBPROJECT_GRAPHITEMS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
|
||||||
set (SUBPROJECT_QUOTES ${CMAKE_CURRENT_SOURCE_DIR}/quotes)
|
|
||||||
set (SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
|
|
||||||
set (SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
|
|
||||||
set (SUBPROJECT_WEATHER ${CMAKE_CURRENT_SOURCE_DIR}/weather)
|
|
||||||
|
|
||||||
# prepare
|
# prepare
|
||||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||||
@@ -48,16 +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})
|
||||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${TASK_MOC_SOURCE})
|
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${TASK_MOC_SOURCE})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} KF5::WindowSystem
|
target_link_libraries (${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Plasma_LIBRARIES} KF5::WindowSystem
|
||||||
${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES})
|
${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||||
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||||
|
|
||||||
# install
|
# install
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/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})
|
||||||
install (DIRECTORY ${SUBPROJECT_GRAPHITEMS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
install (DIRECTORY ${SUBPROJECT_QUOTES} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
install (DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
install (DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
install (DIRECTORY ${SUBPROJECT_WEATHER} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
+23
-134
@@ -57,10 +57,11 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
|||||||
|
|
||||||
setMinimumPollingInterval(333);
|
setMinimumPollingInterval(333);
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
initQuotes();
|
|
||||||
initScripts();
|
externalQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"), debug);
|
||||||
initUpgrade();
|
externalScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"), debug);
|
||||||
initWeather();
|
externalUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"), debug);
|
||||||
|
externalWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"), debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,10 +69,10 @@ ExtendedSysMon::~ExtendedSysMon()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
externalQuotes.clear();
|
delete externalQuotes;
|
||||||
externalScripts.clear();
|
delete externalScripts;
|
||||||
externalUpgrade.clear();
|
delete externalUpgrade;
|
||||||
externalWeather.clear();
|
delete externalWeather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,122 +129,6 @@ QString ExtendedSysMon::getAutoMpris() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::initQuotes()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
// create directory at $HOME and create dirs list
|
|
||||||
QString localDir = QString("%1/awesomewidgets/quotes")
|
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
|
||||||
QDir localDirectory;
|
|
||||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
|
||||||
|
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
|
||||||
QString("awesomewidgets/quotes"),
|
|
||||||
QStandardPaths::LocateDirectory);
|
|
||||||
|
|
||||||
QStringList names;
|
|
||||||
for (int i=0; i<dirs.count(); i++) {
|
|
||||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
|
||||||
for (int j=0; j<files.count(); j++) {
|
|
||||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
|
||||||
if (names.contains(files[j])) continue;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
|
||||||
names.append(files[j]);
|
|
||||||
externalQuotes.append(new ExtQuotes(nullptr, files[j], dirs, debug));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::initScripts()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
// create directory at $HOME and create dirs list
|
|
||||||
QString localDir = QString("%1/awesomewidgets/scripts")
|
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
|
||||||
QDir localDirectory;
|
|
||||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
|
||||||
|
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
|
||||||
QString("awesomewidgets/scripts"),
|
|
||||||
QStandardPaths::LocateDirectory);
|
|
||||||
|
|
||||||
QStringList names;
|
|
||||||
for (int i=0; i<dirs.count(); i++) {
|
|
||||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
|
||||||
for (int j=0; j<files.count(); j++) {
|
|
||||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
|
||||||
if (names.contains(files[j])) continue;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
|
||||||
names.append(files[j]);
|
|
||||||
externalScripts.append(new ExtScript(nullptr, files[j], dirs, debug));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::initUpgrade()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
// create directory at $HOME and create dirs list
|
|
||||||
QString localDir = QString("%1/awesomewidgets/upgrade")
|
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
|
||||||
QDir localDirectory;
|
|
||||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
|
||||||
|
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
|
||||||
QString("awesomewidgets/upgrade"),
|
|
||||||
QStandardPaths::LocateDirectory);
|
|
||||||
|
|
||||||
QStringList names;
|
|
||||||
for (int i=0; i<dirs.count(); i++) {
|
|
||||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
|
||||||
for (int j=0; j<files.count(); j++) {
|
|
||||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
|
||||||
if (names.contains(files[j])) continue;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
|
||||||
names.append(files[j]);
|
|
||||||
externalUpgrade.append(new ExtUpgrade(nullptr, files[j], dirs, debug));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::initWeather()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
// create directory at $HOME and create dirs list
|
|
||||||
QString localDir = QString("%1/awesomewidgets/weather")
|
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
|
||||||
QDir localDirectory;
|
|
||||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
|
||||||
|
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
|
||||||
QString("awesomewidgets/weather"),
|
|
||||||
QStandardPaths::LocateDirectory);
|
|
||||||
|
|
||||||
QStringList names;
|
|
||||||
for (int i=0; i<dirs.count(); i++) {
|
|
||||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
|
||||||
for (int j=0; j<files.count(); j++) {
|
|
||||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
|
||||||
if (names.contains(files[j])) continue;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
|
||||||
names.append(files[j]);
|
|
||||||
externalWeather.append(new ExtWeather(nullptr, files[j], dirs, debug));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList ExtendedSysMon::sources() const
|
QStringList ExtendedSysMon::sources() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@@ -701,8 +586,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
for (int i=0; i<battery.keys().count(); i++)
|
for (int i=0; i<battery.keys().count(); i++)
|
||||||
setData(source, battery.keys()[i], battery[battery.keys()[i]]);
|
setData(source, battery.keys()[i], battery[battery.keys()[i]]);
|
||||||
} else if (source == QString("custom")) {
|
} else if (source == QString("custom")) {
|
||||||
for (int i=0; i<externalScripts.count(); i++)
|
for (int i=0; i<externalScripts->items().count(); i++)
|
||||||
setData(source, externalScripts[i]->tag(QString("custom")), externalScripts[i]->run()[QString("value")]);
|
setData(source, externalScripts->items()[i]->tag(QString("custom")),
|
||||||
|
externalScripts->items()[i]->run()[QString("value")]);
|
||||||
} else if (source == QString("desktop")) {
|
} else if (source == QString("desktop")) {
|
||||||
QVariantMap desktop = getCurrentDesktop();
|
QVariantMap desktop = getCurrentDesktop();
|
||||||
for (int i=0; i<desktop.keys().count(); i++)
|
for (int i=0; i<desktop.keys().count(); i++)
|
||||||
@@ -721,8 +607,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
} else if (source == QString("netdev")) {
|
} else if (source == QString("netdev")) {
|
||||||
setData(source, QString("value"), getNetworkDevice());
|
setData(source, QString("value"), getNetworkDevice());
|
||||||
} else if (source == QString("pkg")) {
|
} else if (source == QString("pkg")) {
|
||||||
for (int i=0; i<externalUpgrade.count(); i++)
|
for (int i=0; i<externalUpgrade->items().count(); i++)
|
||||||
setData(source, externalUpgrade[i]->tag(QString("pkgcount")), externalUpgrade[i]->run()[QString("value")]);
|
setData(source, externalUpgrade->items()[i]->tag(QString("pkgcount")),
|
||||||
|
externalUpgrade->items()[i]->run()[QString("value")]);
|
||||||
} else if (source == QString("player")) {
|
} else if (source == QString("player")) {
|
||||||
QVariantMap player = getPlayerInfo(configuration[QString("PLAYER")],
|
QVariantMap player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||||
configuration[QString("MPDADDRESS")],
|
configuration[QString("MPDADDRESS")],
|
||||||
@@ -735,18 +622,20 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
for (int i=0; i<ps.keys().count(); i++)
|
for (int i=0; i<ps.keys().count(); i++)
|
||||||
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
||||||
} else if (source == QString("quotes")) {
|
} else if (source == QString("quotes")) {
|
||||||
for (int i=0; i<externalQuotes.count(); i++) {
|
for (int i=0; i<externalQuotes->items().count(); i++) {
|
||||||
QVariantMap data = externalQuotes[i]->run();
|
QVariantMap data = externalQuotes->items()[i]->run();
|
||||||
for (int j=0; j<data.keys().count(); j++)
|
for (int j=0; j<data.keys().count(); j++)
|
||||||
setData(source, externalQuotes[i]->tag(data.keys()[j]), data[data.keys()[j]]);
|
setData(source, externalQuotes->items()[i]->tag(data.keys()[j]),
|
||||||
|
data[data.keys()[j]]);
|
||||||
}
|
}
|
||||||
} else if (source == QString("update")) {
|
} else if (source == QString("update")) {
|
||||||
setData(source, QString("value"), true);
|
setData(source, QString("value"), true);
|
||||||
} else if (source == QString("weather")) {
|
} else if (source == QString("weather")) {
|
||||||
for (int i=0; i<externalWeather.count(); i++) {
|
for (int i=0; i<externalWeather->items().count(); i++) {
|
||||||
QVariantMap data = externalWeather[i]->run();
|
QVariantMap data = externalWeather->items()[i]->run();
|
||||||
for (int j=0; j<data.keys().count(); j++)
|
for (int j=0; j<data.keys().count(); j++)
|
||||||
setData(source, externalWeather[i]->tag(data.keys()[j]), data[data.keys()[j]]);
|
setData(source, externalWeather->items()[i]->tag(data.keys()[j]),
|
||||||
|
data[data.keys()[j]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include <Plasma/DataEngine>
|
#include <Plasma/DataEngine>
|
||||||
|
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
class ExtQuotes;
|
class ExtQuotes;
|
||||||
class ExtScript;
|
class ExtScript;
|
||||||
@@ -57,19 +59,15 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
QList<ExtQuotes *> externalQuotes;
|
ExtItemAggregator<ExtQuotes> *externalQuotes;
|
||||||
QList<ExtScript *> externalScripts;
|
ExtItemAggregator<ExtScript> *externalScripts;
|
||||||
QList<ExtUpgrade *> externalUpgrade;
|
ExtItemAggregator<ExtUpgrade> *externalUpgrade;
|
||||||
QList<ExtWeather *> externalWeather;
|
ExtItemAggregator<ExtWeather> *externalWeather;
|
||||||
bool debug;
|
bool debug;
|
||||||
// reread configuration
|
// reread configuration
|
||||||
QStringList getAllHdd() const;
|
QStringList getAllHdd() const;
|
||||||
QString getAutoGpu() const;
|
QString getAutoGpu() const;
|
||||||
QString getAutoMpris() const;
|
QString getAutoMpris() const;
|
||||||
void initQuotes();
|
|
||||||
void initScripts();
|
|
||||||
void initUpgrade();
|
|
||||||
void initWeather();
|
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
QMap<QString, QString> updateConfiguration(QMap<QString, QString> rawConfig) const;
|
QMap<QString, QString> updateConfiguration(QMap<QString, QString> rawConfig) const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user