mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
implement tag number support to widget
bump api ver to 2
This commit is contained in:
parent
7f4dfe1060
commit
88c3e780cf
@ -40,6 +40,7 @@
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "graphicalitem.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
AWKeys::AWKeys(QObject *parent)
|
||||
@ -290,16 +291,16 @@ QStringList AWKeys::dictKeys()
|
||||
allKeys.append(QString("ps"));
|
||||
// package manager
|
||||
for (int i=extUpgrade.count()-1; i>=0; i--)
|
||||
allKeys.append(QString("pkgcount%1").arg(i));
|
||||
allKeys.append(extUpgrade[i]->tag());
|
||||
// quotes
|
||||
for (int i=extQuotes.count()-1; i>=0; i--) {
|
||||
allKeys.append(QString("ask%1").arg(i));
|
||||
allKeys.append(QString("bid%1").arg(i));
|
||||
allKeys.append(QString("price%1").arg(i));
|
||||
allKeys.append(extQuotes[i]->tag(QString("ask")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("bid")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("price")));
|
||||
}
|
||||
// custom
|
||||
for (int i=extScripts.count()-1; i>=0; i--)
|
||||
allKeys.append(QString("custom%1").arg(i));
|
||||
allKeys.append(extScripts[i]->tag());
|
||||
// desktop
|
||||
allKeys.append(QString("desktop"));
|
||||
allKeys.append(QString("ndesktop"));
|
||||
@ -958,17 +959,13 @@ void AWKeys::copyBar(const QString original)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList tagList;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
tagList.append(graphicalItems[i]->name());
|
||||
int number = 0;
|
||||
while (true) {
|
||||
bool exit = true;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
if (graphicalItems[i]->name() == QString("bar%1").arg(number)) {
|
||||
number++;
|
||||
exit = false;
|
||||
break;
|
||||
}
|
||||
if (exit) break;
|
||||
}
|
||||
while (tagList.contains(QString("bar%1").arg(number)))
|
||||
number++;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/desktops"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
@ -995,6 +992,7 @@ void AWKeys::copyBar(const QString original)
|
||||
break;
|
||||
}
|
||||
GraphicalItem *item = new GraphicalItem(0, name, dirs, debug);
|
||||
item->setApiVersion(AWGIAPI);
|
||||
item->setName(QString("bar%1").arg(number));
|
||||
if (originalItem != -1) {
|
||||
item->setComment(graphicalItems[originalItem]->comment());
|
||||
@ -1026,6 +1024,13 @@ void AWKeys::copyQuotes(const QString original)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<int> tagList;
|
||||
for (int i=0; i<extQuotes.count(); i++)
|
||||
tagList.append(extQuotes[i]->number());
|
||||
int number = 0;
|
||||
while (tagList.contains(number))
|
||||
number++;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/quotes"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
@ -1045,6 +1050,8 @@ void AWKeys::copyQuotes(const QString original)
|
||||
break;
|
||||
}
|
||||
ExtQuotes *quotes = new ExtQuotes(0, name, dirs, debug);
|
||||
quotes->setApiVersion(AWEQAPI);
|
||||
quotes->setNumber(number);
|
||||
if (originalItem != -1) {
|
||||
quotes->setActive(extQuotes[originalItem]->isActive());
|
||||
quotes->setComment(extQuotes[originalItem]->comment());
|
||||
@ -1074,6 +1081,13 @@ void AWKeys::copyScript(const QString original)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<int> tagList;
|
||||
for (int i=0; i<extScripts.count(); i++)
|
||||
tagList.append(extScripts[i]->number());
|
||||
int number = 0;
|
||||
while (tagList.contains(number))
|
||||
number++;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/scripts"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
@ -1093,6 +1107,8 @@ void AWKeys::copyScript(const QString original)
|
||||
break;
|
||||
}
|
||||
ExtScript *script = new ExtScript(0, name, dirs, debug);
|
||||
script->setApiVersion(AWESAPI);
|
||||
script->setNumber(number);
|
||||
if (originalItem != -1) {
|
||||
script->setActive(extScripts[originalItem]->isActive());
|
||||
script->setComment(extScripts[originalItem]->comment());
|
||||
@ -1124,6 +1140,13 @@ void AWKeys::copyUpgrade(const QString original)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<int> tagList;
|
||||
for (int i=0; i<extUpgrade.count(); i++)
|
||||
tagList.append(extUpgrade[i]->number());
|
||||
int number = 0;
|
||||
while (tagList.contains(number))
|
||||
number++;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/upgrade"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
@ -1143,6 +1166,8 @@ void AWKeys::copyUpgrade(const QString original)
|
||||
break;
|
||||
}
|
||||
ExtUpgrade *upgrade = new ExtUpgrade(0, name, dirs, debug);
|
||||
upgrade->setApiVersion(AWEUAPI);
|
||||
upgrade->setNumber(number);
|
||||
if (originalItem != -1) {
|
||||
upgrade->setActive(extUpgrade[originalItem]->isActive());
|
||||
upgrade->setComment(extUpgrade[originalItem]->comment());
|
||||
|
@ -1,25 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
# name should be barN and uniq
|
||||
Name=bar100500
|
||||
Comment=Template for the AW bars
|
||||
# value to show. Supported types are
|
||||
# cpu, cpu[0-9], mem, swap, bat
|
||||
X-AW-Value=cpu
|
||||
# active color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
# inactive color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
# bar type. Supported types are
|
||||
# Horizontal, Vertical, Circle
|
||||
X-AW-Type=Horizontal
|
||||
# direction. LeftToRight or RightToLeft
|
||||
X-AW-Direction=LeftToRight
|
||||
# height in pixels
|
||||
X-AW-Height=25
|
||||
# width in pixels
|
||||
X-AW-Width=100
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
@ -26,6 +26,7 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
@ -105,6 +106,23 @@ QString ExtQuotes::name()
|
||||
}
|
||||
|
||||
|
||||
int ExtQuotes::number()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::tag(const QString _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Tag type" << _type;
|
||||
|
||||
return QString("%1%2").arg(_type).arg(m_number);
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::ticker()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -158,6 +176,21 @@ void ExtQuotes::setName(const QString _name)
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::setNumber(int _number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << _number;
|
||||
if (_number == -1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number is empty, generate new one";
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_number = qrand() % 1000;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Generated number is" << _number;
|
||||
}
|
||||
|
||||
m_number = _number;
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::setTicker(const QString _ticker)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -178,12 +211,19 @@ void ExtQuotes::readConfiguration()
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWEQAPI).toInt());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt());
|
||||
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
// update for current API
|
||||
if ((m_apiVersion > 0) && (m_apiVersion < AWEQAPI)) {
|
||||
setApiVersion(AWEQAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +254,7 @@ int ExtQuotes::showConfiguration()
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->label_numberValue->setText(QString("%1").arg(m_number));
|
||||
ui->lineEdit_ticker->setText(m_ticker);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
@ -225,6 +266,7 @@ int ExtQuotes::showConfiguration()
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setNumber(ui->label_numberValue->text().toInt());
|
||||
setApiVersion(AWEQAPI);
|
||||
setTicker(ui->lineEdit_ticker->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
@ -265,6 +307,7 @@ void ExtQuotes::writeConfiguration()
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
@ -38,6 +38,7 @@ class ExtQuotes : public QDialog
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
Q_PROPERTY(QString ticker READ ticker WRITE setTicker)
|
||||
|
||||
public:
|
||||
@ -51,6 +52,8 @@ public:
|
||||
int interval();
|
||||
bool isActive();
|
||||
QString name();
|
||||
int number();
|
||||
QString tag(const QString _type = QString("price"));
|
||||
QString ticker();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
@ -58,6 +61,7 @@ public:
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setInterval(const int _interval = 0);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNumber(int _number = -1);
|
||||
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
||||
|
||||
public slots:
|
||||
@ -82,6 +86,7 @@ private:
|
||||
QString m_comment = QString("empty");
|
||||
int m_interval = 60;
|
||||
QString m_name = QString("none");
|
||||
int m_number = -1;
|
||||
QString m_ticker = QString("EURUSD=X");
|
||||
// values
|
||||
int times = 0;
|
||||
|
@ -60,6 +60,27 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_number">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_number">
|
||||
<property name="text">
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numberValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
@ -98,6 +99,14 @@ QString ExtScript::name()
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::number()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::prefix()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -135,6 +144,14 @@ QString ExtScript::strRedirect()
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::tag()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QString("custom%1").arg(m_number);
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -215,6 +232,21 @@ void ExtScript::setName(const QString _name)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setNumber(int _number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << _number;
|
||||
if (_number == -1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number is empty, generate new one";
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_number = qrand() % 1000;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Generated number is" << _number;
|
||||
}
|
||||
|
||||
m_number = _number;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setPrefix(const QString _prefix)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -258,18 +290,26 @@ void ExtScript::readConfiguration()
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
|
||||
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
// api == 2
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
if (!m_output)
|
||||
setRedirect(stdout2stderr);
|
||||
|
||||
// update for current API
|
||||
if ((m_apiVersion > 0) && (m_apiVersion < AWESAPI)) {
|
||||
setApiVersion(AWESAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -321,6 +361,7 @@ int ExtScript::showConfiguration()
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->label_numberValue->setText(QString("%1").arg(m_number));
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
ui->lineEdit_prefix->setText(m_prefix);
|
||||
if (m_active)
|
||||
@ -338,6 +379,7 @@ int ExtScript::showConfiguration()
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setNumber(ui->label_numberValue->text().toInt());
|
||||
setApiVersion(AWESAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setPrefix(ui->lineEdit_prefix->text());
|
||||
@ -384,6 +426,7 @@ void ExtScript::writeConfiguration()
|
||||
settings.setValue(QString("X-AW-Output"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
@ -32,6 +32,7 @@ class ExtScript : public QDialog
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
||||
@ -55,9 +56,11 @@ public:
|
||||
QString fileName();
|
||||
int interval();
|
||||
QString name();
|
||||
int number();
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
QString strRedirect();
|
||||
QString tag();
|
||||
bool hasOutput();
|
||||
bool isActive();
|
||||
// set methods
|
||||
@ -68,6 +71,7 @@ public:
|
||||
void setHasOutput(const bool _state = true);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNumber(int _number = -1);
|
||||
void setPrefix(const QString _prefix = QString(""));
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
@ -91,6 +95,7 @@ private:
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
int m_interval = 1;
|
||||
QString m_name = QString("none");
|
||||
int m_number = -1;
|
||||
bool m_output = true;
|
||||
QString m_prefix = QString("");
|
||||
Redirect m_redirect = nothing;
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
<height>304</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -60,6 +60,27 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_number">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_number">
|
||||
<property name="text">
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numberValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<item>
|
||||
|
@ -707,7 +707,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
}
|
||||
} else if (source == QString("custom")) {
|
||||
for (int i=0; i<externalScripts.count(); i++)
|
||||
setData(source, QString("custom%1").arg(i), externalScripts[i]->run());
|
||||
setData(source, externalScripts[i]->tag(), externalScripts[i]->run());
|
||||
} else if (source == QString("desktop")) {
|
||||
QMap<QString, QVariant> desktop = getCurrentDesktop();
|
||||
for (int i=0; i<desktop.keys().count(); i++)
|
||||
@ -728,7 +728,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
setData(source, QString("value"), getNetworkDevice());
|
||||
} else if (source == QString("pkg")) {
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, QString("pkgcount%1").arg(i), externalUpgrade[i]->run());
|
||||
setData(source, externalUpgrade[i]->tag(), externalUpgrade[i]->run());
|
||||
} else if (source == QString("player")) {
|
||||
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
@ -743,9 +743,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("quotes")) {
|
||||
for (int i=0; i<externalQuotes.count(); i++) {
|
||||
QMap<QString, float> data = externalQuotes[i]->run();
|
||||
setData(source, QString("ask%1").arg(i), data[QString("ask")]);
|
||||
setData(source, QString("bid%1").arg(i), data[QString("bid")]);
|
||||
setData(source, QString("price%1").arg(i), data[QString("price")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("ask")), data[QString("ask")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("bid")), data[QString("bid")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("price")), data[QString("price")]);
|
||||
}
|
||||
} else if (source == QString("update")) {
|
||||
setData(source, QString("value"), true);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
@ -106,6 +107,22 @@ int ExtUpgrade::null()
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::number()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::tag()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QString("pkgcount%1").arg(m_number);
|
||||
}
|
||||
|
||||
|
||||
bool ExtUpgrade::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -178,6 +195,21 @@ void ExtUpgrade::setNull(const int _null)
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setNumber(int _number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << _number;
|
||||
if (_number == -1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number is empty, generate new one";
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_number = qrand() % 1000;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Generated number is" << _number;
|
||||
}
|
||||
|
||||
m_number = _number;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -189,13 +221,21 @@ void ExtUpgrade::readConfiguration()
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWEUAPI).toInt());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
// api == 2
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
// update for current API
|
||||
if ((m_apiVersion > 0) && (m_apiVersion < AWEUAPI)) {
|
||||
setApiVersion(AWEUAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -228,6 +268,7 @@ int ExtUpgrade::showConfiguration()
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->label_numberValue->setText(QString("%1").arg(m_number));
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
@ -240,6 +281,7 @@ int ExtUpgrade::showConfiguration()
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setNumber(ui->label_numberValue->text().toInt());
|
||||
setApiVersion(AWEUAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
@ -282,6 +324,7 @@ void ExtUpgrade::writeConfiguration()
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Null"), m_null);
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
@ -33,6 +33,7 @@ class ExtUpgrade : public QDialog
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(int null READ null WRITE setNull)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
|
||||
@ -48,6 +49,8 @@ public:
|
||||
int interval();
|
||||
QString name();
|
||||
int null();
|
||||
int number();
|
||||
QString tag();
|
||||
bool isActive();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
@ -56,6 +59,7 @@ public:
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNull(const int _null = 0);
|
||||
void setNumber(int _number = -1);
|
||||
void setInterval(const int _interval = 0);
|
||||
|
||||
public slots:
|
||||
@ -77,6 +81,7 @@ private:
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QString m_name = QString("none");
|
||||
int m_null = 0;
|
||||
int m_number = -1;
|
||||
int m_interval = 3600;
|
||||
int times = 0;
|
||||
int value = 0;
|
||||
|
@ -60,6 +60,27 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_number">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_number">
|
||||
<property name="text">
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_numberValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<item>
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=AAPL.NASDAQ
|
||||
Comment=Apple Inc
|
||||
X-AW-Ticker=AAPL
|
||||
X-AW-Ticker="AAPL"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=0
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=EUR/RUB
|
||||
Comment=EUR/RUB
|
||||
X-AW-Ticker=EURRUB=X
|
||||
X-AW-Ticker="EURRUB=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=1
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=EUR/USD
|
||||
Comment=EUR/USD
|
||||
X-AW-Ticker=EURUSD=X
|
||||
X-AW-Ticker="EURUSD=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=2
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=GOOG.NASDAQ
|
||||
Comment=Google Inc
|
||||
X-AW-Ticker=GOOG
|
||||
X-AW-Ticker="GOOG"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=3
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=MSFT.NASDAQ
|
||||
Comment=Microsoft Corp
|
||||
X-AW-Ticker=MSFT
|
||||
X-AW-Ticker="MSFT"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=4
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=RTS
|
||||
Comment=RTS Index
|
||||
X-AW-Ticker=RTS.RS
|
||||
X-AW-Ticker="RTS.RS"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=5
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=S&P
|
||||
Comment=S&P 500 Index
|
||||
X-AW-Ticker=^GSPC
|
||||
X-AW-Ticker="^GSPC"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=6
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=USD/RUB
|
||||
Comment=USD/RUB
|
||||
X-AW-Ticker=USDRUB=X
|
||||
X-AW-Ticker="USDRUB=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=8
|
||||
|
@ -2,7 +2,8 @@
|
||||
Encoding=UTF-8
|
||||
Name=VIX
|
||||
Comment=Volatility S&P 500
|
||||
X-AW-Ticker=^VIX
|
||||
X-AW-Ticker="^VIX"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=7
|
||||
|
@ -8,4 +8,5 @@ X-AW-Active=true
|
||||
X-AW-Output=true
|
||||
X-AW-Redirect=nothing
|
||||
X-AW-Interval=1
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=0
|
||||
|
@ -1,20 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=aw-script-template
|
||||
Comment=Template for external script
|
||||
# path to command
|
||||
Exec=/path/to/some/command
|
||||
# usually you need to leave this field blank
|
||||
# use this field to setup script language for example
|
||||
X-AW-Prefix=/prefix/to/command/if/required
|
||||
# is the script active. true or false
|
||||
X-AW-Active=false
|
||||
# is the script has output. true or false
|
||||
X-AW-Output=false
|
||||
# use redirect for the script
|
||||
# stderr2stdout, nothing, stdout2stderr
|
||||
X-AW-Redirect=nothing
|
||||
# update interval in default AW intervals
|
||||
X-AW-Interval=1
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
@ -6,4 +6,5 @@ Exec=pacman -Qu
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=0
|
||||
|
@ -6,4 +6,5 @@ Exec=apt-show-versions -u -b
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=1
|
||||
|
@ -6,4 +6,5 @@ Exec=yum list updates
|
||||
X-AW-Active=false
|
||||
X-AW-Null=3
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=2
|
||||
|
@ -6,4 +6,5 @@ Exec=urpmq --auto-select
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=3
|
||||
|
@ -6,4 +6,5 @@ Exec=aptitude search '~U'
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=4
|
||||
|
@ -14,9 +14,9 @@
|
||||
// extquotes api version
|
||||
#define AWEQAPI 1
|
||||
// extscript api version
|
||||
#define AWESAPI 1
|
||||
#define AWESAPI 2
|
||||
// extupgrade api version
|
||||
#define AWEUAPI 1
|
||||
#define AWEUAPI 2
|
||||
|
||||
// links
|
||||
#define HOMEPAGE "http://arcanis.name/projects/awesome-widgets/"
|
||||
|
Loading…
Reference in New Issue
Block a user