mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-10 04:15:51 +00:00
* fix building
* add clang build * more correct method types
This commit is contained in:
@ -34,6 +34,7 @@ file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
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)
|
||||
@ -54,6 +55,7 @@ kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPRO
|
||||
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})
|
||||
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})
|
||||
|
@ -45,7 +45,7 @@ AbstractExtItem::~AbstractExtItem()
|
||||
}
|
||||
|
||||
|
||||
int AbstractExtItem::apiVersion()
|
||||
int AbstractExtItem::apiVersion() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -53,7 +53,7 @@ int AbstractExtItem::apiVersion()
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItem::comment()
|
||||
QString AbstractExtItem::comment() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -61,7 +61,7 @@ QString AbstractExtItem::comment()
|
||||
}
|
||||
|
||||
|
||||
QStringList AbstractExtItem::directories()
|
||||
QStringList AbstractExtItem::directories() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -69,7 +69,7 @@ QStringList AbstractExtItem::directories()
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItem::fileName()
|
||||
QString AbstractExtItem::fileName() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -77,7 +77,7 @@ QString AbstractExtItem::fileName()
|
||||
}
|
||||
|
||||
|
||||
int AbstractExtItem::interval()
|
||||
int AbstractExtItem::interval() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -85,7 +85,7 @@ int AbstractExtItem::interval()
|
||||
}
|
||||
|
||||
|
||||
bool AbstractExtItem::isActive()
|
||||
bool AbstractExtItem::isActive() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -93,7 +93,7 @@ bool AbstractExtItem::isActive()
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItem::name()
|
||||
QString AbstractExtItem::name() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -101,7 +101,7 @@ QString AbstractExtItem::name()
|
||||
}
|
||||
|
||||
|
||||
int AbstractExtItem::number()
|
||||
int AbstractExtItem::number() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -109,7 +109,7 @@ int AbstractExtItem::number()
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItem::tag(const QString _type)
|
||||
QString AbstractExtItem::tag(const QString _type) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Tag type" << _type;
|
||||
@ -145,6 +145,24 @@ void AbstractExtItem::setComment(const QString _comment)
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItem::setDirectories(QStringList _directories)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Directories" << _directories;
|
||||
|
||||
m_dirs = _directories;
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItem::setFileName(const QString _fileName)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filename" << _fileName;
|
||||
|
||||
m_fileName = _fileName;
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItem::setInterval(const int _interval)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -199,7 +217,7 @@ void AbstractExtItem::readConfiguration()
|
||||
}
|
||||
|
||||
|
||||
bool AbstractExtItem::tryDelete()
|
||||
bool AbstractExtItem::tryDelete() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -214,7 +232,7 @@ bool AbstractExtItem::tryDelete()
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItem::writeConfiguration()
|
||||
void AbstractExtItem::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
|
@ -28,7 +28,8 @@ class AbstractExtItem : public QDialog
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QStringList directories READ directories)
|
||||
Q_PROPERTY(QStringList directories READ directories WRITE setDirectories)
|
||||
Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
@ -40,19 +41,21 @@ public:
|
||||
const bool debugCmd = false);
|
||||
virtual ~AbstractExtItem();
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QStringList directories();
|
||||
QString fileName();
|
||||
int interval();
|
||||
bool isActive();
|
||||
QString name();
|
||||
int number();
|
||||
QString tag(const QString _type);
|
||||
int apiVersion() const;
|
||||
QString comment() const;
|
||||
QStringList directories() const;
|
||||
QString fileName() const;
|
||||
int interval() const;
|
||||
bool isActive() const;
|
||||
QString name() const;
|
||||
int number() const;
|
||||
QString tag(const QString _type) const;
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setDirectories(const QStringList _directories);
|
||||
void setFileName(const QString _fileName);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNumber(int _number = -1);
|
||||
@ -60,9 +63,9 @@ public:
|
||||
public slots:
|
||||
virtual void readConfiguration();
|
||||
virtual QVariantMap run() = 0;
|
||||
virtual int showConfiguration() = 0;
|
||||
bool tryDelete();
|
||||
virtual void writeConfiguration();
|
||||
virtual int showConfiguration(const QVariant args = QVariant()) = 0;
|
||||
bool tryDelete() const;
|
||||
virtual void writeConfiguration() const;
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
|
12
sources/extsysmon/desktops/aw-bat-bar.desktop
Normal file
12
sources/extsysmon/desktops/aw-bat-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar3
|
||||
Comment=Simple bat bar
|
||||
X-AW-Value=bat
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/extsysmon/desktops/aw-cpu-bar.desktop
Normal file
12
sources/extsysmon/desktops/aw-cpu-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar0
|
||||
Comment=Simple cpu bar
|
||||
X-AW-Value=cpu
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/extsysmon/desktops/aw-mem-bar.desktop
Normal file
12
sources/extsysmon/desktops/aw-mem-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar1
|
||||
Comment=Simple mem bar
|
||||
X-AW-Value=mem
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/extsysmon/desktops/aw-swap-bar.desktop
Normal file
12
sources/extsysmon/desktops/aw-swap-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar2
|
||||
Comment=Simple swap bar
|
||||
X-AW-Value=swap
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -68,7 +68,7 @@ ExtQuotes::~ExtQuotes()
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::ticker()
|
||||
QString ExtQuotes::ticker() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -88,6 +88,7 @@ void ExtQuotes::setTicker(const QString _ticker)
|
||||
void ExtQuotes::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=directories().count()-1; i>=0; i--) {
|
||||
if (!QDir(directories()[i]).entryList(QDir::Files).contains(fileName())) continue;
|
||||
@ -126,8 +127,9 @@ QVariantMap ExtQuotes::run()
|
||||
}
|
||||
|
||||
|
||||
int ExtQuotes::showConfiguration()
|
||||
int ExtQuotes::showConfiguration(const QVariant args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(name());
|
||||
@ -152,9 +154,10 @@ int ExtQuotes::showConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::writeConfiguration()
|
||||
void ExtQuotes::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories()[0]).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
@ -208,7 +211,7 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::url()
|
||||
QString ExtQuotes::url() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
|
@ -40,15 +40,15 @@ public:
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtQuotes();
|
||||
// get methods
|
||||
QString ticker();
|
||||
QString ticker() const;
|
||||
// set methods
|
||||
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QVariantMap run();
|
||||
int showConfiguration();
|
||||
void writeConfiguration();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void quotesReplyReceived(QNetworkReply *reply);
|
||||
@ -58,7 +58,7 @@ private:
|
||||
QNetworkAccessManager *manager;
|
||||
bool isRunning = false;
|
||||
Ui::ExtQuotes *ui;
|
||||
QString url();
|
||||
QString url() const;
|
||||
// properties
|
||||
QString m_ticker = QString("EURUSD=X");
|
||||
// values
|
||||
|
@ -41,7 +41,7 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
||||
readJsonFilters();
|
||||
ui->setupUi(this);
|
||||
|
||||
value[QString("value")] = QString();
|
||||
value[QString("value")] = QString("");
|
||||
|
||||
process = new QProcess(this);
|
||||
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
@ -59,7 +59,7 @@ ExtScript::~ExtScript()
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::executable()
|
||||
QString ExtScript::executable() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -67,7 +67,7 @@ QString ExtScript::executable()
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtScript::filters()
|
||||
QStringList ExtScript::filters() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -75,7 +75,7 @@ QStringList ExtScript::filters()
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
bool ExtScript::hasOutput() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -83,7 +83,7 @@ bool ExtScript::hasOutput()
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::prefix()
|
||||
QString ExtScript::prefix() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -91,7 +91,7 @@ QString ExtScript::prefix()
|
||||
}
|
||||
|
||||
|
||||
ExtScript::Redirect ExtScript::redirect()
|
||||
ExtScript::Redirect ExtScript::redirect() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -99,7 +99,7 @@ ExtScript::Redirect ExtScript::redirect()
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::strRedirect()
|
||||
QString ExtScript::strRedirect() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -181,7 +181,7 @@ void ExtScript::setStrRedirect(const QString _redirect)
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::applyFilters(QString _value)
|
||||
QString ExtScript::applyFilters(QString _value) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
|
||||
@ -219,6 +219,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add)
|
||||
void ExtScript::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=directories().count()-1; i>=0; i--) {
|
||||
if (!QDir(directories()[i]).entryList(QDir::Files).contains(fileName())) continue;
|
||||
@ -289,8 +290,9 @@ QVariantMap ExtScript::run()
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::showConfiguration()
|
||||
int ExtScript::showConfiguration(const QVariant args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(name());
|
||||
@ -329,9 +331,10 @@ int ExtScript::showConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::writeConfiguration()
|
||||
void ExtScript::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories()[0]).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
@ -48,13 +48,13 @@ public:
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtScript();
|
||||
// get methods
|
||||
QString executable();
|
||||
QStringList filters();
|
||||
bool hasOutput();
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
QString executable() const;
|
||||
QStringList filters() const;
|
||||
bool hasOutput() const;
|
||||
QString prefix() const;
|
||||
Redirect redirect() const;
|
||||
// derivatives
|
||||
QString strRedirect();
|
||||
QString strRedirect() const;
|
||||
// set methods
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setFilters(const QStringList _filters = QStringList());
|
||||
@ -63,15 +63,15 @@ public:
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
// filters
|
||||
QString applyFilters(QString _value);
|
||||
QString applyFilters(QString _value) const;
|
||||
void updateFilter(const QString _filter, const bool _add = true);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
void readJsonFilters();
|
||||
QVariantMap run();
|
||||
int showConfiguration();
|
||||
void writeConfiguration();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
@ -55,7 +55,7 @@ ExtUpgrade::~ExtUpgrade()
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::executable()
|
||||
QString ExtUpgrade::executable() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -63,7 +63,7 @@ QString ExtUpgrade::executable()
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::null()
|
||||
int ExtUpgrade::null() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -93,6 +93,7 @@ void ExtUpgrade::setNull(const int _null)
|
||||
void ExtUpgrade::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=directories().count()-1; i>=0; i--) {
|
||||
if (!QDir(directories()[i]).entryList(QDir::Files).contains(fileName())) continue;
|
||||
@ -127,8 +128,9 @@ QVariantMap ExtUpgrade::run()
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::showConfiguration()
|
||||
int ExtUpgrade::showConfiguration(const QVariant args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(name());
|
||||
@ -155,9 +157,10 @@ int ExtUpgrade::showConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::writeConfiguration()
|
||||
void ExtUpgrade::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories()[0]).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
@ -38,8 +38,8 @@ public:
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtUpgrade();
|
||||
// get methods
|
||||
QString executable();
|
||||
int null();
|
||||
QString executable() const;
|
||||
int null() const;
|
||||
// set methods
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setNull(const int _null = 0);
|
||||
@ -47,8 +47,8 @@ public:
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QVariantMap run();
|
||||
int showConfiguration();
|
||||
void writeConfiguration();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
@ -65,7 +65,7 @@ ExtWeather::~ExtWeather()
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::weatherFromInt(const int _id)
|
||||
QString ExtWeather::weatherFromInt(const int _id) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ID" << _id;
|
||||
@ -165,7 +165,7 @@ QString ExtWeather::weatherFromInt(const int _id)
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::city()
|
||||
QString ExtWeather::city() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -173,7 +173,7 @@ QString ExtWeather::city()
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::country()
|
||||
QString ExtWeather::country() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -181,7 +181,7 @@ QString ExtWeather::country()
|
||||
}
|
||||
|
||||
|
||||
int ExtWeather::ts()
|
||||
int ExtWeather::ts() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -219,6 +219,7 @@ void ExtWeather::setTs(const int _ts)
|
||||
void ExtWeather::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=directories().count()-1; i>=0; i--) {
|
||||
if (!QDir(directories()[i]).entryList(QDir::Files).contains(fileName())) continue;
|
||||
@ -259,8 +260,9 @@ QVariantMap ExtWeather::run()
|
||||
}
|
||||
|
||||
|
||||
int ExtWeather::showConfiguration()
|
||||
int ExtWeather::showConfiguration(const QVariant args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(name());
|
||||
@ -289,9 +291,10 @@ int ExtWeather::showConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::writeConfiguration()
|
||||
void ExtWeather::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories()[0]).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
@ -341,7 +344,7 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
||||
}
|
||||
|
||||
|
||||
QVariantMap ExtWeather::parseSingleJson(const QVariantMap json)
|
||||
QVariantMap ExtWeather::parseSingleJson(const QVariantMap json) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -367,7 +370,7 @@ QVariantMap ExtWeather::parseSingleJson(const QVariantMap json)
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::url(const bool isForecast)
|
||||
QString ExtWeather::url(const bool isForecast) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << "Is forecast" << isForecast;
|
||||
|
@ -42,11 +42,11 @@ public:
|
||||
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtWeather();
|
||||
QString weatherFromInt(const int _id);
|
||||
QString weatherFromInt(const int _id) const;
|
||||
// get methods
|
||||
QString city();
|
||||
QString country();
|
||||
int ts();
|
||||
QString city() const;
|
||||
QString country() const;
|
||||
int ts() const;
|
||||
// set methods
|
||||
void setCity(const QString _city = QString("London"));
|
||||
void setCountry(const QString _country = QString("uk"));
|
||||
@ -55,8 +55,8 @@ public:
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QVariantMap run();
|
||||
int showConfiguration();
|
||||
void writeConfiguration();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void weatherReplyReceived(QNetworkReply *reply);
|
||||
@ -66,8 +66,8 @@ private:
|
||||
QNetworkAccessManager *manager;
|
||||
bool isRunning = false;
|
||||
Ui::ExtWeather *ui;
|
||||
QVariantMap parseSingleJson(const QVariantMap json);
|
||||
QString url(const bool isForecast = false);
|
||||
QVariantMap parseSingleJson(const QVariantMap json) const;
|
||||
QString url(const bool isForecast = false) const;
|
||||
// properties
|
||||
QString m_city = QString("London");
|
||||
QString m_country = QString("uk");
|
||||
|
454
sources/extsysmon/graphicalitem.cpp
Normal file
454
sources/extsysmon/graphicalitem.cpp
Normal file
@ -0,0 +1,454 @@
|
||||
/***************************************************************************
|
||||
* 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 "graphicalitem.h"
|
||||
#include "ui_graphicalitem.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QColorDialog>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QSettings>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, desktopName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::GraphicalItem)
|
||||
{
|
||||
readConfiguration();
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::~GraphicalItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::image(const float value) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
||||
if (m_bar == QString("none")) return QString("");
|
||||
|
||||
QColor active = stringToColor(m_activeColor);
|
||||
QColor inactive = stringToColor(m_inactiveColor);
|
||||
float percent = value / 100.0;
|
||||
int scale[2] = {1, 1};
|
||||
QPen pen = QPen();
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
QGraphicsView *view = new QGraphicsView(scene);
|
||||
view->setStyleSheet(QString("background: transparent"));
|
||||
view->setContentsMargins(0, 0, 0, 0);
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->resize(m_width + 5.0, m_height + 5.0);
|
||||
|
||||
// paint
|
||||
switch (m_type) {
|
||||
case Vertical:
|
||||
pen.setWidth(m_width);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
|
||||
(1.0 - percent) * m_height - 0.5 * m_width, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(0.5 * m_width, (1.0 - percent) * m_height + 0.5 * m_width,
|
||||
0.5 * m_width, m_height + 0.5 * m_width, pen);
|
||||
// scale
|
||||
scale[1] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
case Circle:
|
||||
QGraphicsEllipseItem *circle;
|
||||
pen.setWidth(1.0);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(inactive, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- (1.0 - percent) * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0 - percent * 360.0 * 16.0);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(active, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- percent * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
default:
|
||||
pen.setWidth(m_height);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(percent * m_width + 0.5 * m_height, 0.5 * m_height,
|
||||
m_width + 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(-0.5 * m_height, 0.5 * m_height,
|
||||
percent * m_width - 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// convert
|
||||
QPixmap pixmap = view->grab().transformed(QTransform().scale(scale[0], scale[1]));
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap.save(&buffer, "PNG");
|
||||
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
delete view;
|
||||
delete scene;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::bar() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_bar;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::activeColor() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_activeColor;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::inactiveColor() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_inactiveColor;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Type GraphicalItem::type() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strType() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (m_type) {
|
||||
case Vertical:
|
||||
value = QString("Vertical");
|
||||
break;
|
||||
case Circle:
|
||||
value = QString("Circle");
|
||||
break;
|
||||
default:
|
||||
value = QString("Horizontal");
|
||||
break;
|
||||
}\
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Direction GraphicalItem::direction() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strDirection() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (m_direction) {
|
||||
case RightToLeft:
|
||||
value = QString("RightToLeft");
|
||||
break;
|
||||
default:
|
||||
value = QString("LeftToRight");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::height() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::width() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setBar(const QString _bar)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
|
||||
|
||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
||||
(!_bar.contains(QRegExp(QString("mem")))) &&
|
||||
(!_bar.contains(QRegExp(QString("swap")))) &&
|
||||
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("bat.*")))))
|
||||
m_bar = QString("none");
|
||||
else
|
||||
m_bar = _bar;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setActiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_activeColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setInactiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_inactiveColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setType(const Type _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrType(const QString _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
if (_type == QString("Vertical"))
|
||||
setType(Vertical);
|
||||
else if (_type == QString("Circle"))
|
||||
setType(Circle);
|
||||
else
|
||||
setType(Horizontal);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setDirection(const Direction _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
m_direction = _direction;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrDirection(const QString _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
if (_direction == QString("RightToLeft"))
|
||||
setDirection(RightToLeft);
|
||||
else
|
||||
setDirection(LeftToRight);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setHeight(const int _height)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
|
||||
if (_height <= 0) return;
|
||||
|
||||
m_height = _height;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setWidth(const int _width)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
|
||||
if (_width <= 0) return;
|
||||
|
||||
m_width = _width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=directories().count()-1; i>=0; i--) {
|
||||
if (!QDir(directories()[i]).entryList(QDir::Files).contains(fileName())) continue;
|
||||
QSettings settings(QString("%1/%2").arg(directories()[i]).arg(fileName()), QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||
setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
|
||||
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariantMap GraphicalItem::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// required by abstract class
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::showConfiguration(const QVariant args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
QStringList tags = args.toStringList();
|
||||
|
||||
ui->label_nameValue->setText(name());
|
||||
ui->lineEdit_comment->setText(comment());
|
||||
ui->comboBox_value->addItems(tags);
|
||||
ui->comboBox_value->addItem(m_bar);
|
||||
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
||||
ui->pushButton_activeColor->setText(m_activeColor);
|
||||
ui->pushButton_inactiveColor->setText(m_inactiveColor);
|
||||
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type));
|
||||
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction));
|
||||
ui->spinBox_height->setValue(m_height);
|
||||
ui->spinBox_width->setValue(m_width);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
|
||||
setName(ui->label_nameValue->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWGIAPI);
|
||||
setBar(ui->comboBox_value->currentText());
|
||||
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
||||
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
||||
setStrType(ui->comboBox_type->currentText());
|
||||
setStrDirection(ui->comboBox_direction->currentText());
|
||||
setHeight(ui->spinBox_height->value());
|
||||
setWidth(ui->spinBox_width->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories()[0]).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||
settings.setValue(QString("X-AW-Type"), strType());
|
||||
settings.setValue(QString("X-AW-Direction"), strDirection());
|
||||
settings.setValue(QString("X-AW-Height"), m_height);
|
||||
settings.setValue(QString("X-AW-Width"), m_width);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::changeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QColor color = stringToColor((dynamic_cast<QPushButton *>(sender()))->text());
|
||||
QColor newColor = QColorDialog::getColor(color, 0, tr("Select color"),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
if (!newColor.isValid()) return;
|
||||
|
||||
QStringList colorText;
|
||||
colorText.append(QString("%1").arg(newColor.red()));
|
||||
colorText.append(QString("%1").arg(newColor.green()));
|
||||
colorText.append(QString("%1").arg(newColor.blue()));
|
||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
QColor GraphicalItem::stringToColor(const QString _color) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
QColor qcolor;
|
||||
QStringList listColor = _color.split(QChar(','));
|
||||
while (listColor.count() < 4)
|
||||
listColor.append(QString("0"));
|
||||
qcolor.setRed(listColor[0].toInt());
|
||||
qcolor.setGreen(listColor[1].toInt());
|
||||
qcolor.setBlue(listColor[2].toInt());
|
||||
qcolor.setAlpha(listColor[3].toInt());
|
||||
|
||||
return qcolor;
|
||||
}
|
107
sources/extsysmon/graphicalitem.h
Normal file
107
sources/extsysmon/graphicalitem.h
Normal file
@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* 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 GRAPHICALITEM_H
|
||||
#define GRAPHICALITEM_H
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GraphicalItem;
|
||||
}
|
||||
|
||||
class GraphicalItem : public AbstractExtItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||
Q_PROPERTY(Type type READ type WRITE setType)
|
||||
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
||||
Q_PROPERTY(int height READ height WRITE setHeight)
|
||||
Q_PROPERTY(int width READ width WRITE setWidth)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
LeftToRight = 0,
|
||||
RightToLeft
|
||||
};
|
||||
enum Type {
|
||||
Horizontal = 0,
|
||||
Vertical,
|
||||
Circle
|
||||
};
|
||||
|
||||
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString image(const float value) const;
|
||||
// get methods
|
||||
QString bar() const;
|
||||
QString activeColor() const;
|
||||
QString inactiveColor() const;
|
||||
Type type() const;
|
||||
QString strType() const;
|
||||
Direction direction() const;
|
||||
QString strDirection() const;
|
||||
int height() const;
|
||||
int width() const;
|
||||
// set methods
|
||||
void setBar(const QString _bar = QString("cpu"));
|
||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||
void setType(const Type _type = Horizontal);
|
||||
void setStrType(const QString _type = QString("Horizontal"));
|
||||
void setDirection(const Direction _direction = LeftToRight);
|
||||
void setStrDirection(const QString _direction = QString("LeftToRight"));
|
||||
void setHeight(const int _height = 100);
|
||||
void setWidth(const int _width = 100);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QVariantMap run();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void changeColor();
|
||||
|
||||
private:
|
||||
QColor stringToColor(const QString _color) const;
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::GraphicalItem *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
QString m_name = QString("none");
|
||||
QString m_comment = QString("empty");
|
||||
QString m_bar = QString("cpu");
|
||||
QString m_activeColor = QString("0,0,0,130");
|
||||
QString m_inactiveColor = QString("255,255,255,130");
|
||||
Type m_type = Horizontal;
|
||||
Direction m_direction = LeftToRight;
|
||||
int m_height = 100;
|
||||
int m_width = 100;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GRAPHICALITEM_H */
|
293
sources/extsysmon/graphicalitem.ui
Normal file
293
sources/extsysmon/graphicalitem.ui
Normal file
@ -0,0 +1,293 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GraphicalItem</class>
|
||||
<widget class="QDialog" name="GraphicalItem">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_nameValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_comment">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_comment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_value">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_value">
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_value">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_activeColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_activeColor">
|
||||
<property name="text">
|
||||
<string>Active color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_activeColor">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_inactiveColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_inactiveColor">
|
||||
<property name="text">
|
||||
<string>Inactive color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_inactiveColor">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_type">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_type">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_direction">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_direction">
|
||||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_direction">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">LeftToRight</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">RightToLeft</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_height">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_height">
|
||||
<property name="text">
|
||||
<string>Height</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_height">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_width">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_width">
|
||||
<property name="text">
|
||||
<string>Width</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_width">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
11
sources/extsysmon/weather/london.desktop
Normal file
11
sources/extsysmon/weather/london.desktop
Normal file
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Comment=London current weather
|
||||
Encoding=UTF-8
|
||||
Name=London current
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-City=London
|
||||
X-AW-Country=uk
|
||||
X-AW-Interval=3600
|
||||
X-AW-Number=0
|
||||
X-AW-TS=0
|
Reference in New Issue
Block a user