mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-06-29 15:15:45 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
b431d2c6cf | |||
f96b3fcb07 | |||
f534a6854a | |||
b51c97abbb | |||
8dc3510a30 | |||
fce098cb5c | |||
5f4bf9ec29 |
13
CHANGELOG
13
CHANGELOG
@ -1,9 +1,20 @@
|
||||
Ver.2.3.0:
|
||||
+ implement fitlers support to ExtScripts (ApiVer = 3) (#53)
|
||||
+ implement ability to wrap `\n` as new lines (#53)
|
||||
+ implement key sorting in comboboxes
|
||||
+ implement (perc)(bid|ask|price)chg tag support (ApiVer = 2)
|
||||
+ implement timeouts to quotes (#54)
|
||||
- fix bug with invalid html parsing
|
||||
* move from XML to JSON in ExtQuotes (ApiVer = 2)
|
||||
* more pretty configuration UI
|
||||
* some part of refactoring
|
||||
|
||||
Ver.2.2.2:
|
||||
+ add quotes support (#46)
|
||||
+ add support of properties height and width (#47)
|
||||
+ add transtaltion support to the plugins (#50)
|
||||
+ add support of key caching
|
||||
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer=2)
|
||||
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer = 2)
|
||||
+ add reconnection to DataEngine (in some cases some values are not updated)
|
||||
+ add widgets width and height update
|
||||
- fix bug with Ext* items update (#49)
|
||||
|
11
CHANGELOG-RU
11
CHANGELOG-RU
@ -1,3 +1,14 @@
|
||||
Вер.2.3.0:
|
||||
+ добавлена поддержка фильтров в ExtScript (ApiVer = 3) (#53)
|
||||
+ добавлена возможность отображать `\n`, как перенос строки (#53)
|
||||
+ добавлена сортировка ключей в комбобоксах
|
||||
+ добавлена поддержка тегов (perc)(bid|ask|price)chg (ApiVer = 2)
|
||||
+ добавлены таймауты запросов котировок (#54)
|
||||
- исправлен баг с неправильным парсингом html
|
||||
* ExtQuotes теперь использует JSON вместо XML (ApiVer = 2)
|
||||
* более красивый UI настроек
|
||||
* некоторый рефакторинг
|
||||
|
||||
Вер.2.2.2:
|
||||
+ добавлена поддержка котировок (#46)
|
||||
+ добавлена поддержка свойств height и width (#47)
|
||||
|
@ -27,8 +27,7 @@ Instruction
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* kdebase-workspace (*if KDE4 is used*) **or** plasma-framework (*if KF5 is used*)
|
||||
* lm_sensors (*for definition temperature device*)
|
||||
* plasma-framework
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
@ -42,7 +41,7 @@ Make dependencies
|
||||
-----------------
|
||||
|
||||
* cmake
|
||||
* automoc4 (*if KDE4 is used*) or extra-cmake-modules (*if KF5 is used*)
|
||||
* extra-cmake-modules
|
||||
|
||||
Installation
|
||||
------------
|
||||
@ -72,4 +71,5 @@ Links
|
||||
* [Scripts and bars](http://arcanis.name/en/2014/12/19/aw-v21-bells-and-whistles/)
|
||||
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124)
|
||||
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-awesome-widgets/) package
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/) package
|
||||
* [OpenSuse](http://software.opensuse.org/package/awesome-widgets) package
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
pkgname=plasma5-applet-awesome-widgets
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.2.2
|
||||
pkgver=2.3.0
|
||||
pkgrel=1
|
||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
||||
arch=('i686' 'x86_64')
|
||||
@ -20,7 +20,7 @@ optdepends=("amarok: for music player monitor"
|
||||
makedepends=('cmake' 'extra-cmake-modules')
|
||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('73e176a124f8bfe43a0a112307624bfe')
|
||||
md5sums=('3c79159d6de7b737d386d8ab7eb1ccf0')
|
||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
|
@ -10,8 +10,8 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 2)
|
||||
set (PROJECT_VERSION_MINOR 2)
|
||||
set (PROJECT_VERSION_PATCH 2)
|
||||
set (PROJECT_VERSION_MINOR 3)
|
||||
set (PROJECT_VERSION_PATCH 0)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
|
@ -8,7 +8,7 @@ configure_file (metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.de
|
||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
|
||||
find_package (Qt5 REQUIRED COMPONENTS Core Network Qml Xml)
|
||||
find_package (Qt5 REQUIRED COMPONENTS Core Network Qml)
|
||||
find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma)
|
||||
|
||||
include (KDEInstallDirs)
|
||||
|
@ -23,6 +23,9 @@
|
||||
<entry name="notify" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="wrapNewLines" type="bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="background" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -48,6 +48,12 @@ Item {
|
||||
text: AWActions.getAboutText("header")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: AWActions.getAboutText("version")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
@ -62,9 +68,11 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
font.capitalization: Font.SmallCaps
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignBottom
|
||||
textFormat: Text.RichText
|
||||
text: AWActions.getAboutText("copy")
|
||||
}
|
||||
@ -83,8 +91,10 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
verticalAlignment: Text.AlignTop
|
||||
textFormat: Text.RichText
|
||||
text: AWActions.getAboutText("3rdparty")
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ Item {
|
||||
property alias cfg_height: widgetHeight.value
|
||||
property alias cfg_width: widgetWidth.value
|
||||
property alias cfg_notify: notify.checked
|
||||
property alias cfg_wrapNewLines: wrapNewLines.checked
|
||||
property alias cfg_background: background.checked
|
||||
property alias cfg_customTime: customTime.text
|
||||
property alias cfg_customUptime: customUptime.text
|
||||
@ -98,6 +99,20 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Label {
|
||||
height: parent.heigth
|
||||
width: parent.width * 2 / 5
|
||||
}
|
||||
QtControls.CheckBox {
|
||||
id: wrapNewLines
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Wrap new lines")
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
@ -273,7 +273,7 @@ Item {
|
||||
if (debug) console.log("[dataengine::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
|
@ -199,7 +199,10 @@ Item {
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
AWKeys.initTooltip(tooltipSettings)
|
||||
AWKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||
AWKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
|
||||
needUpdate()
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ Item {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 12
|
||||
text: i18n("Font")
|
||||
iconName: "font"
|
||||
|
||||
@ -98,6 +99,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
@ -111,6 +113,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
@ -123,6 +126,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
@ -135,6 +139,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
@ -147,6 +152,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
@ -160,6 +166,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
@ -172,6 +179,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
@ -184,6 +192,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
@ -196,6 +205,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
@ -310,7 +320,7 @@ Item {
|
||||
if (debug) console.log("[widget::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
tags.model = AWKeys.dictKeys()
|
||||
AWKeys.initKeys(plasmoid.configuration.text)
|
||||
tags.model = AWKeys.dictKeys(true)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
set (PLUGIN_NAME awplugin)
|
||||
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Xml_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS}
|
||||
${Qt5Qml_INCLUDE_DIRS}
|
||||
${Qt5Xml_INCLUDE_DIRS})
|
||||
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${Qt5Qml_LIBRARIES}
|
||||
${Qt5Xml_LIBRARIES})
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS})
|
||||
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Qml_LIBRARIES})
|
||||
set (Kf5_INCLUDE ${I18n_INCLUDE_DIR}
|
||||
${Notifications_INCLUDE_DIR})
|
||||
set (Kf5_LIBRARIES KF5::I18n
|
||||
|
@ -101,6 +101,8 @@ QString AWActions::getAboutText(const QString type)
|
||||
QString text;
|
||||
if (type == QString("header"))
|
||||
text = QString(NAME);
|
||||
else if (type == QString("version"))
|
||||
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||
else if (type == QString("description"))
|
||||
text = i18n("A set of minimalistic plasmoid widgets");
|
||||
else if (type == QString("links"))
|
||||
@ -130,11 +132,11 @@ QString AWActions::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
QVariantMap AWActions::getFont(const QVariantMap defaultFont)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
@ -148,14 +150,14 @@ QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> default
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
QVariantMap AWActions::readDataEngineConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
QMap<QString, QVariant> configuration;
|
||||
QVariantMap configuration;
|
||||
|
||||
settings.beginGroup(QString("Configuration"));
|
||||
configuration[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
||||
@ -172,7 +174,7 @@ QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
|
@ -40,10 +40,10 @@ public:
|
||||
Q_INVOKABLE void showReadme();
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString getAboutText(const QString type = QString("header"));
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont);
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
|
||||
|
@ -86,9 +86,7 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup)
|
||||
void AWKeys::initKeys(const QString currentPattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -100,7 +98,6 @@ void AWKeys::initKeys(const QString currentPattern,
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
foundKeys.clear();
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
|
||||
// init
|
||||
pattern = currentPattern;
|
||||
@ -113,12 +110,34 @@ void AWKeys::initKeys(const QString currentPattern,
|
||||
addKeyToCache(QString("Network"));
|
||||
loadKeysFromCache();
|
||||
reinitKeys();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
toolTip = new AWToolTip(this, tooltipParams);
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setPopupEnabled(const bool popup)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
enablePopup = popup;
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setWrapNewLines(const bool wrap)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
wrapNewLines = wrap;
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::isDebugEnabled()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -135,11 +154,12 @@ QString AWKeys::parsePattern()
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(foundKeys[i]), valueByKey(foundKeys[i]));
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
parsed.replace(QString("$%1").arg(foundKeys[i]), htmlValue(foundKeys[i]));
|
||||
for (int i=0; i<foundBars.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(foundBars[i]), getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
// wrap new lines if required
|
||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
@ -148,6 +168,7 @@ QString AWKeys::parsePattern()
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QString("");
|
||||
|
||||
if (keys.isEmpty()) return QString();
|
||||
|
||||
@ -163,6 +184,7 @@ QString AWKeys::toolTipImage()
|
||||
QSize AWKeys::toolTipSize()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QSize();
|
||||
|
||||
return toolTip->getSize();
|
||||
}
|
||||
@ -194,7 +216,7 @@ void AWKeys::addDevice(const QString source)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::dictKeys()
|
||||
QStringList AWKeys::dictKeys(const bool sorted)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -293,8 +315,14 @@ QStringList AWKeys::dictKeys()
|
||||
// quotes
|
||||
for (int i=extQuotes.count()-1; i>=0; i--) {
|
||||
allKeys.append(extQuotes[i]->tag(QString("ask")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("askchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percaskchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("bid")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("bidchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percbidchg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("price")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("pricechg")));
|
||||
allKeys.append(extQuotes[i]->tag(QString("percpricechg")));
|
||||
}
|
||||
// custom
|
||||
for (int i=extScripts.count()-1; i>=0; i--)
|
||||
@ -312,6 +340,9 @@ QStringList AWKeys::dictKeys()
|
||||
for (int i=graphicalItemsKeys.count()-1; i>=0; i--)
|
||||
allKeys.append(graphicalItemsKeys[i]);
|
||||
|
||||
// sort if required
|
||||
if (sorted) allKeys.sort();
|
||||
|
||||
return allKeys;
|
||||
}
|
||||
|
||||
@ -329,9 +360,8 @@ QStringList AWKeys::getHddDevices()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params)
|
||||
bool AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
@ -339,6 +369,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
if (sourceName == QString("update")) return true;
|
||||
|
||||
// checking
|
||||
if (toolTip == nullptr) return false;
|
||||
if (!checkKeys(data)) return false;
|
||||
if (keys.isEmpty()) return false;
|
||||
|
||||
@ -373,7 +404,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("ac")] = params[QString("acOffline")].toString();
|
||||
} else {
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
toolTip->setData(QString("batTooltip"), data[data.keys()[i]].toFloat(), data[QString("ac")].toBool());
|
||||
toolTip->setData(QString("batTooltip"), data[data.keys()[i]].toFloat(),
|
||||
data[QString("ac")].toBool());
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/TotalLoad")) {
|
||||
@ -531,7 +563,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("down%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
if (device == values[QString("netdev")]) {
|
||||
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
toolTip->setData(QString("downTooltip"), data[QString("value")].toFloat());
|
||||
}
|
||||
@ -545,7 +577,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == networkDevice()) {
|
||||
if (device == values[QString("netdev")]) {
|
||||
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
toolTip->setData(QString("upTooltip"), data[QString("value")].toFloat());
|
||||
}
|
||||
@ -646,8 +678,8 @@ void AWKeys::graphicalValueByKey()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool ok;
|
||||
QString tag = QInputDialog::getItem(0, i18n("Select tag"),
|
||||
i18n("Tag"), keys, 0, false, &ok);
|
||||
QString tag = QInputDialog::getItem(0, i18n("Select tag"), i18n("Tag"),
|
||||
dictKeys(true), 0, false, &ok);
|
||||
|
||||
if ((!ok) || (tag.isEmpty())) return;
|
||||
QString message = i18n("Tag: %1", tag);
|
||||
@ -684,11 +716,9 @@ QString AWKeys::infoByKey(QString key)
|
||||
if (extUpgrade[i]->tag() != key) continue;
|
||||
return extUpgrade[i]->executable();
|
||||
}
|
||||
else if ((key.startsWith(QString("ask"))) ||
|
||||
(key.startsWith(QString("bid"))) ||
|
||||
(key.startsWith(QString("price"))))
|
||||
else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))))
|
||||
for (int i=0; i<extQuotes.count(); i++) {
|
||||
if (extQuotes[i]->number() != key.remove(QRegExp(QString("^(ask|bid|price)"))).toInt()) continue;
|
||||
if (extQuotes[i]->number() != key.remove(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))).toInt()) continue;
|
||||
return extQuotes[i]->ticker();
|
||||
}
|
||||
else if (key.startsWith(QString("temp")))
|
||||
@ -1247,7 +1277,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
bool AWKeys::checkKeys(const QVariantMap data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||
@ -1256,22 +1286,15 @@ bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice()
|
||||
QString AWKeys::htmlValue(QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
|
||||
QString device = QString("lo");
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||
device = rawInterfaceList[i].name();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return device;
|
||||
QString value = values[key];
|
||||
if (!key.startsWith(QString("custom")))
|
||||
value.replace(QString(" "), QString(" "));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,20 +51,20 @@ public:
|
||||
AWKeys(QObject *parent = nullptr);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup = false);
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern);
|
||||
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
||||
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
|
||||
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false);
|
||||
Q_INVOKABLE QStringList getHddDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params);
|
||||
// values
|
||||
Q_INVOKABLE void graphicalValueByKey();
|
||||
Q_INVOKABLE QString infoByKey(QString key);
|
||||
@ -85,8 +85,8 @@ private slots:
|
||||
private:
|
||||
// methods
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
QString networkDevice();
|
||||
bool checkKeys(const QVariantMap data);
|
||||
QString htmlValue(QString key);
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units);
|
||||
// find methods
|
||||
@ -111,6 +111,7 @@ private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool wrapNewLines = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtQuotes *> extQuotes;
|
||||
QList<ExtScript *> extScripts;
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
QMap<QString, QVariant> settings)
|
||||
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
||||
: QObject(parent),
|
||||
configuration(settings)
|
||||
{
|
||||
|
@ -32,8 +32,7 @@ class AWToolTip : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AWToolTip(QObject *parent = nullptr,
|
||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||
AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
||||
~AWToolTip();
|
||||
|
||||
QSize getSize();
|
||||
@ -48,7 +47,7 @@ private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
int counts = 0;
|
||||
QMap<QString, QVariant> configuration;
|
||||
QVariantMap configuration;
|
||||
QMap<QString, float> boundaries;
|
||||
QMap<QString, QList<float>> data;
|
||||
QStringList requiredKeys;
|
||||
|
@ -48,6 +48,12 @@ Item {
|
||||
text: DPAdds.getAboutText("header")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: DPAdds.getAboutText("version")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
@ -62,9 +68,11 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
font.capitalization: Font.SmallCaps
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignBottom
|
||||
textFormat: Text.RichText
|
||||
text: DPAdds.getAboutText("copy")
|
||||
}
|
||||
@ -83,8 +91,10 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillHeight: true
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
verticalAlignment: Text.AlignTop
|
||||
textFormat: Text.RichText
|
||||
text: DPAdds.getAboutText("3rdparty")
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ Item {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 12
|
||||
text: i18n("Font")
|
||||
iconName: "font"
|
||||
|
||||
@ -70,6 +71,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
@ -83,6 +85,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
@ -95,6 +98,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
@ -107,6 +111,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
@ -119,6 +124,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
@ -132,6 +138,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
@ -144,6 +151,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
@ -156,6 +164,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
@ -168,6 +177,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
|
@ -189,7 +189,6 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop)
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
parsed.replace(QString("$%1").arg(keys[i]), valueByKey(keys[i], desktop));
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
|
||||
return parsed;
|
||||
@ -221,7 +220,7 @@ void DPAdds::setPanelsToControl(const QString newPanels)
|
||||
}
|
||||
|
||||
|
||||
void DPAdds::setToolTipData(const QMap<QString, QVariant> tooltipData)
|
||||
void DPAdds::setToolTipData(const QVariantMap tooltipData)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData;
|
||||
@ -240,9 +239,10 @@ QString DPAdds::valueByKey(const QString key, int desktop)
|
||||
|
||||
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
||||
if (key == QString("mark"))
|
||||
return QString("%1").arg(currentMark, mark.count(), QLatin1Char(' '));
|
||||
return QString("%1").arg(currentMark, mark.count(), QLatin1Char(' '))
|
||||
.replace(QString(" "), QString(" "));
|
||||
else if (key == QString("name"))
|
||||
return KWindowSystem::desktopName(desktop);
|
||||
return KWindowSystem::desktopName(desktop).replace(QString(" "), QString(" "));
|
||||
else if (key == QString("number"))
|
||||
return QString::number(desktop);
|
||||
else if (key == QString("total"))
|
||||
@ -310,6 +310,8 @@ QString DPAdds::getAboutText(const QString type)
|
||||
QString text;
|
||||
if (type == QString("header"))
|
||||
text = QString(NAME);
|
||||
else if (type == QString("version"))
|
||||
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||
else if (type == QString("description"))
|
||||
text = i18n("A set of minimalistic plasmoid widgets");
|
||||
else if (type == QString("links"))
|
||||
@ -339,11 +341,11 @@ QString DPAdds::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> DPAdds::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
QVariantMap DPAdds::getFont(const QVariantMap defaultFont)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
|
@ -55,12 +55,12 @@ public:
|
||||
// values
|
||||
Q_INVOKABLE void setMark(const QString newMark);
|
||||
Q_INVOKABLE void setPanelsToControl(const QString newPanels);
|
||||
Q_INVOKABLE void setToolTipData(const QMap<QString, QVariant> tooltipData);
|
||||
Q_INVOKABLE void setToolTipData(const QVariantMap tooltipData);
|
||||
Q_INVOKABLE QString valueByKey(const QString key, int desktop = -1);
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString editPanelsToContol(const QString current);
|
||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont);
|
||||
|
||||
signals:
|
||||
void desktopChanged();
|
||||
|
@ -4,7 +4,7 @@ set (PLUGIN_NAME ${SUBPROJECT})
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (Qt5 REQUIRED COMPONENTS DBus Network Widgets Xml)
|
||||
find_package (Qt5 REQUIRED COMPONENTS DBus Network Widgets)
|
||||
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
find_package (KF5 REQUIRED COMPONENTS Plasma Service WindowSystem)
|
||||
@ -14,9 +14,9 @@ include (KDECMakeSettings)
|
||||
include (KDECompilerSettings)
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}
|
||||
${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Xml_DEFINITIONS})
|
||||
${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS})
|
||||
${Qt5Network_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (KDE_INCLUDE ${Plasma_INCLUDE_DIR})
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
|
@ -20,11 +20,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
#include <QTime>
|
||||
|
||||
@ -45,8 +44,14 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName, const QStringLis
|
||||
ui->setupUi(this);
|
||||
|
||||
values[QString("ask")] = 0.0;
|
||||
values[QString("askchg")] = 0.0;
|
||||
values[QString("percaskchg")] = 0.0;
|
||||
values[QString("bid")] = 0.0;
|
||||
values[QString("bidchg")] = 0.0;
|
||||
values[QString("percbidchg")] = 0.0;
|
||||
values[QString("price")] = 0.0;
|
||||
values[QString("pricechg")] = 0.0;
|
||||
values[QString("percpricechg")] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +242,8 @@ QMap<QString, float> ExtQuotes::run()
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
|
||||
manager->get(QNetworkRequest(QUrl(url())));
|
||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||
new QReplyTimeout(reply, 1000);
|
||||
}
|
||||
|
||||
// update value
|
||||
@ -314,42 +320,37 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return code" << reply->error();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << reply->errorString();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Reply error message" << reply->errorString();
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
reply->deleteLater();
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
reply->deleteLater();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if ((reply->error() != QNetworkReply::NoError) ||
|
||||
(error.error != QJsonParseError::NoError)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDomDocument doc;
|
||||
if (!doc.setContent(reply)) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not parse answer to XML";
|
||||
return;
|
||||
}
|
||||
QDomNodeList fields;
|
||||
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
|
||||
jsonQuotes = jsonQuotes[QString("results")].toMap()[QString("quote")].toMap();
|
||||
float value;
|
||||
|
||||
// ask
|
||||
fields = doc.elementsByTagName(QString("Ask"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("ask")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found ask" << values[QString("ask")];
|
||||
}
|
||||
value = jsonQuotes[QString("Ask")].toString().toFloat();
|
||||
values[QString("askchg")] = values[QString("ask")] == 0 ? 0.0 : value - values[QString("ask")];
|
||||
values[QString("percaskchg")] = 100 * values[QString("askchg")] / values[QString("ask")];
|
||||
values[QString("ask")] = value;
|
||||
|
||||
// bid
|
||||
fields = doc.elementsByTagName(QString("Bid"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("bid")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found bid" << values[QString("bid")];
|
||||
}
|
||||
value = jsonQuotes[QString("Bid")].toString().toFloat();
|
||||
values[QString("bidchg")] = values[QString("bid")] == 0 ? 0.0 : value - values[QString("bid")];
|
||||
values[QString("percbidchg")] = 100 * values[QString("bidchg")] / values[QString("bid")];
|
||||
values[QString("bid")] = value;
|
||||
|
||||
// last trade
|
||||
fields = doc.elementsByTagName(QString("LastTradePriceOnly"));
|
||||
for (int i=0; i<fields.size(); i++) {
|
||||
values[QString("price")] = fields.item(i).toElement().text().toFloat();
|
||||
if (debug) qDebug() << PDEBUG << "Found last trade" << values[QString("price")];
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toFloat();
|
||||
values[QString("pricechg")] = values[QString("price")] == 0 ? 0.0 : value - values[QString("price")];
|
||||
values[QString("percpricechg")] = 100 * values[QString("pricechg")] / values[QString("price")];
|
||||
values[QString("price")] = value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,11 +20,29 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QNetworkReply>
|
||||
#include <QTimer>
|
||||
|
||||
#define YAHOO_URL "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol in (\"$TICKER\")&env=store://datatables.org/alltableswithkeys"
|
||||
#define YAHOO_URL "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol=\"$TICKER\"&env=store://datatables.org/alltableswithkeys&format=json"
|
||||
|
||||
|
||||
class QNetworkReply;
|
||||
class QReplyTimeout : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QReplyTimeout(QNetworkReply *reply, const int timeout) : QObject(reply)
|
||||
{
|
||||
QTimer::singleShot(timeout, this, SLOT(timeout()));
|
||||
}
|
||||
|
||||
public slots:
|
||||
void timeout()
|
||||
{
|
||||
QNetworkReply *reply = static_cast<QNetworkReply *>(parent());
|
||||
if (reply->isRunning()) reply->close();
|
||||
}
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class ExtQuotes;
|
||||
|
@ -20,7 +20,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
#include <QTime>
|
||||
|
||||
@ -38,6 +41,7 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringLis
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
readJsonFilters();
|
||||
// init process
|
||||
process = new QProcess(this);
|
||||
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
@ -89,6 +93,22 @@ QString ExtScript::fileName()
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtScript::filters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_filters;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::interval()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -97,6 +117,14 @@ int ExtScript::interval()
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -141,6 +169,7 @@ QString ExtScript::strRedirect()
|
||||
case stderr2stdout:
|
||||
value = QString("stderr2stdout");
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
value = QString("nothing");
|
||||
break;
|
||||
@ -158,22 +187,6 @@ QString ExtScript::tag()
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -210,12 +223,22 @@ void ExtScript::setExecutable(const QString _executable)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setHasOutput(const bool state)
|
||||
void ExtScript::setFilters(const QStringList _filters)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters;
|
||||
|
||||
m_output = state;
|
||||
for (int i=0; i<_filters.count(); i++)
|
||||
updateFilter(_filters[i]);
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setHasOutput(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_output = _state;
|
||||
}
|
||||
|
||||
|
||||
@ -285,6 +308,41 @@ void ExtScript::setStrRedirect(const QString _redirect)
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::applyFilters(QString _value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
|
||||
|
||||
for (int i=0; i<m_filters.count(); i++) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found filter" << m_filters[i];
|
||||
QVariantMap filter = jsonFilters[m_filters[i]].toMap();
|
||||
if (filter.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find filter in the json";
|
||||
continue;
|
||||
}
|
||||
for (int j=0; j<filter.keys().count(); j++)
|
||||
_value.replace(filter.keys()[j], filter[filter.keys()[j]].toString());
|
||||
}
|
||||
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::updateFilter(const QString _filter, const bool _add)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Should be added" << _add;
|
||||
|
||||
if (_add) {
|
||||
if (m_filters.contains(_filter)) return;
|
||||
m_filters.append(_filter);
|
||||
} else {
|
||||
m_filters.removeOne(_filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -305,6 +363,9 @@ void ExtScript::readConfiguration()
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
// api == 2
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
// api == 3
|
||||
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString()
|
||||
.split(QChar(','), QString::SkipEmptyParts));
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -319,6 +380,30 @@ void ExtScript::readConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readJsonFilters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile jsonFile(fileName);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
QString jsonText = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if (error.error != QJsonParseError::NoError)
|
||||
return;
|
||||
jsonFilters = jsonDoc.toVariant().toMap();
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << jsonFilters;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -351,6 +436,10 @@ int ExtScript::showConfiguration()
|
||||
ui->checkBox_output->setCheckState(m_output ? Qt::Checked : Qt::Unchecked);
|
||||
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||
ui->spinBox_interval->setValue(m_interval);
|
||||
// filters
|
||||
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
|
||||
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
@ -364,6 +453,10 @@ int ExtScript::showConfiguration()
|
||||
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
|
||||
setStrRedirect(ui->comboBox_redirect->currentText());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
// filters
|
||||
updateFilter(QString("color"), ui->checkBox_colorFilter->checkState() == Qt::Checked);
|
||||
updateFilter(QString("newline"), ui->checkBox_linesFilter->checkState() == Qt::Checked);
|
||||
updateFilter(QString("space"), ui->checkBox_spaceFilter->checkState() == Qt::Checked);
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
@ -404,6 +497,7 @@ void ExtScript::writeConfiguration()
|
||||
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(',')));
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
@ -433,4 +527,7 @@ void ExtScript::updateValue()
|
||||
value = qoutput;
|
||||
break;
|
||||
}
|
||||
|
||||
// filters
|
||||
value = applyFilters(value);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define EXTSCRIPT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
@ -29,15 +30,16 @@ namespace Ui {
|
||||
class ExtScript : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
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)
|
||||
Q_PROPERTY(QStringList filters READ filters WRITE setFilters)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
|
||||
|
||||
public:
|
||||
@ -55,20 +57,23 @@ public:
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
QStringList filters();
|
||||
bool hasOutput();
|
||||
int interval();
|
||||
bool isActive();
|
||||
QString name();
|
||||
int number();
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
// derivatives
|
||||
QString strRedirect();
|
||||
QString tag();
|
||||
bool hasOutput();
|
||||
bool isActive();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setFilters(const QStringList _filters = QStringList());
|
||||
void setHasOutput(const bool _state = true);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
@ -76,9 +81,13 @@ public:
|
||||
void setPrefix(const QString _prefix = QString(""));
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
// filters
|
||||
QString applyFilters(QString _value);
|
||||
void updateFilter(const QString _filter, const bool _add = true);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
void readJsonFilters();
|
||||
QString run();
|
||||
int showConfiguration();
|
||||
bool tryDelete();
|
||||
@ -98,13 +107,16 @@ private:
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QStringList m_filters = QStringList();
|
||||
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;
|
||||
// internal properties
|
||||
Q_PID childProcess = 0;
|
||||
QVariantMap jsonFilters = QVariantMap();
|
||||
int times = 0;
|
||||
QString value = QString();
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>304</height>
|
||||
<height>424</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -244,6 +244,105 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_filters">
|
||||
<property name="title">
|
||||
<string>Additional filters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_colorFilter">
|
||||
<item>
|
||||
<spacer name="spacer_colorFilter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_colorFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_linesFilter">
|
||||
<item>
|
||||
<spacer name="spacer_linesFilter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_linesFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap new lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_spaceFilter">
|
||||
<item>
|
||||
<spacer name="spacer_spaceFilter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_spaceFilter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wrap spaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -303,12 +303,12 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
QVariantMap ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ACPI path" << acpiPath;
|
||||
|
||||
QMap<QString, QVariant> battery;
|
||||
QVariantMap battery;
|
||||
battery[QString("ac")] = false;
|
||||
battery[QString("bat")] = 0;
|
||||
QFile acFile(acpiPath + QString("/AC/online"));
|
||||
@ -344,13 +344,13 @@ QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getCurrentDesktop()
|
||||
QVariantMap ExtendedSysMon::getCurrentDesktop()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
int number = KWindowSystem::currentDesktop();
|
||||
int total = KWindowSystem::numberOfDesktops();
|
||||
QMap<QString, QVariant> currentDesktop;
|
||||
QVariantMap currentDesktop;
|
||||
currentDesktop[QString("currentName")] = KWindowSystem::desktopName(number);
|
||||
currentDesktop[QString("currentNumber")] = number;
|
||||
QStringList list;
|
||||
@ -499,17 +499,15 @@ QString ExtendedSysMon::getNetworkDevice()
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress,
|
||||
const QString mpdPort,
|
||||
QString mpris)
|
||||
QVariantMap ExtendedSysMon::getPlayerInfo(const QString playerName, const QString mpdAddress,
|
||||
const QString mpdPort, QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "player" << playerName;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
@ -530,13 +528,12 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress,
|
||||
const QString mpdPort)
|
||||
QVariantMap ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress, const QString mpdPort)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
@ -572,12 +569,12 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddres
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
QVariantMap ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
QVariantMap info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = 0;
|
||||
@ -622,7 +619,7 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
QVariantMap ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -641,7 +638,7 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> psStats;
|
||||
QVariantMap psStats;
|
||||
psStats[QString("pscount")] = running.count();
|
||||
psStats[QString("ps")] = running.join(QString(","));
|
||||
psStats[QString("pstotal")] = directories.count();
|
||||
@ -665,7 +662,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
if (source == QString("battery")) {
|
||||
QMap<QString, QVariant> battery = getBattery(configuration[QString("ACPIPATH")]);
|
||||
QVariantMap battery = getBattery(configuration[QString("ACPIPATH")]);
|
||||
setData(source, QString("ac"), battery[QString("ac")].toBool());
|
||||
for (int i=0; i<battery.keys().count(); i++) {
|
||||
if (battery.keys()[i] == QString("ac")) continue;
|
||||
@ -675,7 +672,7 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<externalScripts.count(); i++)
|
||||
setData(source, externalScripts[i]->tag(), externalScripts[i]->run());
|
||||
} else if (source == QString("desktop")) {
|
||||
QMap<QString, QVariant> desktop = getCurrentDesktop();
|
||||
QVariantMap desktop = getCurrentDesktop();
|
||||
for (int i=0; i<desktop.keys().count(); i++)
|
||||
setData(source, desktop.keys()[i], desktop[desktop.keys()[i]]);
|
||||
} else if (source == QString("gpu")) {
|
||||
@ -697,22 +694,28 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, externalUpgrade[i]->tag(), externalUpgrade[i]->run());
|
||||
} else if (source == QString("player")) {
|
||||
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")],
|
||||
configuration[QString("MPRIS")]);
|
||||
QVariantMap player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")],
|
||||
configuration[QString("MPRIS")]);
|
||||
for (int i=0; i<player.keys().count(); i++)
|
||||
setData(source, player.keys()[i], player[player.keys()[i]]);
|
||||
} else if (source == QString("ps")) {
|
||||
QMap<QString, QVariant> ps = getPsStats();
|
||||
QVariantMap ps = getPsStats();
|
||||
for (int i=0; i<ps.keys().count(); i++)
|
||||
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
||||
} else if (source == QString("quotes")) {
|
||||
for (int i=0; i<externalQuotes.count(); i++) {
|
||||
QMap<QString, float> data = externalQuotes[i]->run();
|
||||
setData(source, externalQuotes[i]->tag(QString("ask")), data[QString("ask")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("askchg")), data[QString("askchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percaskchg")), data[QString("percaskchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("bid")), data[QString("bid")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("bidchg")), data[QString("bidchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percbidchg")), data[QString("percbidchg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("price")), data[QString("price")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("pricechg")), data[QString("pricechg")]);
|
||||
setData(source, externalQuotes[i]->tag(QString("percpricechg")), data[QString("percpricechg")]);
|
||||
}
|
||||
} else if (source == QString("update")) {
|
||||
setData(source, QString("value"), true);
|
||||
|
@ -33,20 +33,20 @@ public:
|
||||
explicit ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
~ExtendedSysMon();
|
||||
// update functions
|
||||
QMap<QString, QVariant> getBattery(const QString acpiPath);
|
||||
QMap<QString, QVariant> getCurrentDesktop();
|
||||
QVariantMap getBattery(const QString acpiPath);
|
||||
QVariantMap getCurrentDesktop();
|
||||
float getGpu(const QString device);
|
||||
float getGpuTemp(const QString device);
|
||||
float getHddTemp(const QString cmd, const QString device);
|
||||
QString getNetworkDevice();
|
||||
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString(),
|
||||
const QString mpris = QString());
|
||||
QMap<QString, QVariant> getPlayerMpdInfo(const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString());
|
||||
QMap<QString, QVariant> getPlayerMprisInfo(const QString mpris = QString());
|
||||
QMap<QString, QVariant> getPsStats();
|
||||
QVariantMap getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString(),
|
||||
const QString mpris = QString());
|
||||
QVariantMap getPlayerMpdInfo(const QString mpdAddress = QString(),
|
||||
const QString mpdPort = QString());
|
||||
QVariantMap getPlayerMprisInfo(const QString mpris = QString());
|
||||
QVariantMap getPsStats();
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &source);
|
||||
|
@ -4,6 +4,6 @@ Name=AAPL.NASDAQ
|
||||
Comment=Apple Inc
|
||||
X-AW-Ticker="AAPL"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=0
|
||||
|
@ -4,6 +4,6 @@ Name=EUR/RUB
|
||||
Comment=EUR/RUB
|
||||
X-AW-Ticker="EURRUB=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=1
|
||||
|
@ -4,6 +4,6 @@ Name=EUR/USD
|
||||
Comment=EUR/USD
|
||||
X-AW-Ticker="EURUSD=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=2
|
||||
|
@ -4,6 +4,6 @@ Name=GOOG.NASDAQ
|
||||
Comment=Google Inc
|
||||
X-AW-Ticker="GOOG"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=3
|
||||
|
@ -4,6 +4,6 @@ Name=MSFT.NASDAQ
|
||||
Comment=Microsoft Corp
|
||||
X-AW-Ticker="MSFT"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=4
|
||||
|
@ -4,6 +4,6 @@ Name=RTS
|
||||
Comment=RTS Index
|
||||
X-AW-Ticker="RTS.RS"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=5
|
||||
|
@ -4,6 +4,6 @@ Name=S&P
|
||||
Comment=S&P 500 Index
|
||||
X-AW-Ticker="^GSPC"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=6
|
||||
|
@ -4,6 +4,6 @@ Name=USD/RUB
|
||||
Comment=USD/RUB
|
||||
X-AW-Ticker="USDRUB=X"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=8
|
||||
|
@ -4,6 +4,6 @@ Name=VIX
|
||||
Comment=Volatility S&P 500
|
||||
X-AW-Ticker="^VIX"
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Interval=60
|
||||
X-AW-Number=7
|
||||
|
@ -0,0 +1,30 @@
|
||||
{
|
||||
"color": {
|
||||
"\u001b[0;30m": "<span style=\"color:'#000000';\">",
|
||||
"\u001b[1;30m": "<span style=\"color:'#808080';\">",
|
||||
"\u001b[0;31m": "<span style=\"color:'#800000';\">",
|
||||
"\u001b[1;31m": "<span style=\"color:'#ff0000';\">",
|
||||
"\u001b[0;32m": "<span style=\"color:'#008000';\">",
|
||||
"\u001b[1;32m": "<span style=\"color:'#00ff00';\">",
|
||||
"\u001b[0;33m": "<span style=\"color:'#808000';\">",
|
||||
"\u001b[1;33m": "<span style=\"color:'#ffff00';\">",
|
||||
"\u001b[0;34m": "<span style=\"color:'#000080';\">",
|
||||
"\u001b[1;34m": "<span style=\"color:'#0000ff';\">",
|
||||
"\u001b[0;35m": "<span style=\"color:'#800080';\">",
|
||||
"\u001b[1;35m": "<span style=\"color:'#ff00ff';\">",
|
||||
"\u001b[0;36m": "<span style=\"color:'#008080';\">",
|
||||
"\u001b[1;36m": "<span style=\"color:'#00ffff';\">",
|
||||
"\u001b[0;37m": "<span style=\"color:'#c0c0c0';\">",
|
||||
"\u001b[1;37m": "<span style=\"color:'#ffffff';\">",
|
||||
"\u001b[0m": "</span>"
|
||||
},
|
||||
"newline": {
|
||||
"\n": "<br>",
|
||||
"\n\r": "<br>",
|
||||
"\t": "	",
|
||||
"\v": ""
|
||||
},
|
||||
"space": {
|
||||
" ": " "
|
||||
}
|
||||
}
|
@ -8,5 +8,6 @@ X-AW-Active=true
|
||||
X-AW-Output=true
|
||||
X-AW-Redirect=nothing
|
||||
X-AW-Interval=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-ApiVersion=3
|
||||
X-AW-Number=0
|
||||
X-AW-Filters=
|
||||
|
@ -12,9 +12,9 @@
|
||||
// graphical items api version
|
||||
#define AWGIAPI 1
|
||||
// extquotes api version
|
||||
#define AWEQAPI 1
|
||||
#define AWEQAPI 2
|
||||
// extscript api version
|
||||
#define AWESAPI 2
|
||||
#define AWESAPI 3
|
||||
// extupgrade api version
|
||||
#define AWEUAPI 2
|
||||
|
||||
|
Reference in New Issue
Block a user