mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
improve update events
This commit is contained in:
parent
c7d998eb12
commit
1110929b14
@ -1,6 +1,9 @@
|
||||
ver.2.3.4:
|
||||
Ver.2.3.4:
|
||||
+ add support of load average (la1, la5, la15 tags)
|
||||
- fix bug with invalid network data calculation
|
||||
* update pattern parsing to recent plasma changes
|
||||
* improve work with data updating (#57)
|
||||
* move plugin part back to private
|
||||
* cast plugin as type, not signleton (#57)
|
||||
|
||||
Ver.2.3.3:
|
||||
* change text rendering from Qt to native
|
||||
|
@ -1,3 +1,10 @@
|
||||
Вер.2.3.4:
|
||||
+ добавлена поддержа LA (теги la1, la5, la15)
|
||||
- исправлен баг с неправильным расчетам скорости сети
|
||||
* улучшена работа с обновлениями виджета (#57)
|
||||
* плагин опять стал приватным
|
||||
* исправлен каст плагина с синглтона (#57)
|
||||
|
||||
Вер.2.3.3:
|
||||
* изменен рендеринг с Qt на нативный
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
pkgname=plasma5-applet-awesome-widgets
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.3.3
|
||||
pkgver=2.3.4
|
||||
pkgrel=1
|
||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
||||
arch=('i686' 'x86_64')
|
||||
@ -17,7 +17,7 @@ optdepends=("catalyst: for GPU 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=('a40592d66d9b5149fc7d470dc3e355cb')
|
||||
md5sums=('74e5b45df042e81c20f5e8bf421451f8')
|
||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
|
@ -66,7 +66,8 @@ Item {
|
||||
}
|
||||
|
||||
signal dropSource(string sourceName)
|
||||
signal needUpdate
|
||||
signal needTextUpdate(string newText)
|
||||
signal needToolTipUpdate(string newText)
|
||||
signal sizeUpdate
|
||||
|
||||
|
||||
@ -91,7 +92,7 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
// FIXME: ugly workaround to make some sources working
|
||||
systemmonitorDE.interval = plasmoid.configuration.interval
|
||||
// systemmonitorDE.interval = plasmoid.configuration.interval
|
||||
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
@ -112,7 +113,7 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
// FIXME: ugly workaround to make some sources working
|
||||
extsysmonDE.interval = plasmoid.configuration.interval
|
||||
// extsysmonDE.interval = plasmoid.configuration.interval
|
||||
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
@ -175,7 +176,8 @@ Item {
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
// connect data
|
||||
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||
awKeys.needToBeUpdated.connect(needUpdate)
|
||||
awKeys.needTextToBeUpdated.connect(needTextUpdate)
|
||||
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
|
||||
}
|
||||
|
||||
onDropSource: {
|
||||
@ -185,15 +187,19 @@ Item {
|
||||
systemmonitorDE.disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = awKeys.parsePattern()
|
||||
tooltip.text = awKeys.toolTipImage()
|
||||
onNeedTextUpdate: {
|
||||
if (debug) console.log("[main::onNeedTextUpdate]")
|
||||
|
||||
text.text = newText
|
||||
sizeUpdate()
|
||||
}
|
||||
|
||||
onNeedToolTipUpdate: {
|
||||
if (debug) console.log("[main::onNeedToolTipUpdate]")
|
||||
|
||||
tooltip.text = newText
|
||||
}
|
||||
|
||||
onSizeUpdate: {
|
||||
if (debug) console.log("[main::onSizeUpdate]")
|
||||
|
||||
@ -223,7 +229,7 @@ Item {
|
||||
awKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
|
||||
needUpdate()
|
||||
needTextUpdate(plasmoid.configuration.text)
|
||||
}
|
||||
|
||||
function action_checkUpdates() {
|
||||
|
@ -215,7 +215,8 @@ void AWActions::showUpdates(QString version)
|
||||
text += i18n("New version : %1", version) + QString("\n\n");
|
||||
text += i18n("Click \"Ok\" to download");
|
||||
|
||||
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||
int select = QMessageBox::information(nullptr, i18n("There are updates"), text,
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
switch (select) {
|
||||
case QMessageBox::Ok:
|
||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||
|
@ -51,6 +51,9 @@ AWKeys::AWKeys(QObject *parent)
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
// backend
|
||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
||||
|
||||
// init dialog
|
||||
dialog = new QDialog(nullptr);
|
||||
widgetDialog = new QListWidget(dialog);
|
||||
@ -73,11 +76,6 @@ AWKeys::~AWKeys()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete toolTip;
|
||||
delete createButton;
|
||||
delete copyButton;
|
||||
delete deleteButton;
|
||||
delete dialogButtons;
|
||||
delete widgetDialog;
|
||||
delete dialog;
|
||||
|
||||
graphicalItems.clear();
|
||||
@ -165,22 +163,6 @@ QString AWKeys::parsePattern()
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QString("");
|
||||
|
||||
if (keys.isEmpty()) return QString();
|
||||
|
||||
QPixmap tooltip = toolTip->image();
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
tooltip.save(&buffer, "PNG");
|
||||
|
||||
return QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
}
|
||||
|
||||
|
||||
QSize AWKeys::toolTipSize()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -327,6 +309,10 @@ QStringList AWKeys::dictKeys(const bool sorted)
|
||||
allKeys.append(QString("desktop"));
|
||||
allKeys.append(QString("ndesktop"));
|
||||
allKeys.append(QString("tdesktops"));
|
||||
// load average
|
||||
allKeys.append(QString("la15"));
|
||||
allKeys.append(QString("la5"));
|
||||
allKeys.append(QString("la1"));
|
||||
// bars
|
||||
QStringList graphicalItemsKeys;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
@ -362,13 +348,10 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
|
||||
if (sourceName == QString("update")) {
|
||||
emit(needToBeUpdated());
|
||||
return;
|
||||
}
|
||||
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
||||
|
||||
// checking
|
||||
if (!checkKeys(data)) return;
|
||||
// if (!checkKeys(data)) return;
|
||||
if (keys.isEmpty()) return;
|
||||
|
||||
// regular expressions
|
||||
@ -517,6 +500,11 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
temperature(data[data.keys()[i]].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName.startsWith(QString("cpu/system/loadavg"))) {
|
||||
// load average
|
||||
QString time = sourceName;
|
||||
time.remove(QString("cpu/system/loadavg"));
|
||||
values[QString("la%1").arg(time)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 2);
|
||||
} else if (sourceName == QString("mem/physical/application")) {
|
||||
// app memory
|
||||
values[QString("memmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
@ -639,8 +627,8 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
for (int i=0; i<tempDevices.count(); i++)
|
||||
if (sourceName == tempDevices[i]) {
|
||||
float temp = data[QString("units")].toString() == QString("°C") ?
|
||||
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString())
|
||||
: data[QString("value")].toFloat();
|
||||
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()) :
|
||||
data[QString("value")].toFloat();
|
||||
values[QString("temp%1").arg(i)] = QString("%1").arg(temp, 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
@ -797,6 +785,15 @@ void AWKeys::editItem(const QString type)
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::dataUpdate()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
emit(needTextToBeUpdated(parsePattern()));
|
||||
emit(needToolTipToBeUpdated(toolTipImage()));
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::loadKeysFromCache()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -1325,6 +1322,22 @@ float AWKeys::temperature(const float temp, const QString units)
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QString("");
|
||||
|
||||
if (keys.isEmpty()) return QString();
|
||||
|
||||
QPixmap tooltip = toolTip->image();
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
tooltip.save(&buffer, "PNG");
|
||||
|
||||
return QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -57,7 +57,6 @@ public:
|
||||
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);
|
||||
@ -74,9 +73,12 @@ public:
|
||||
|
||||
signals:
|
||||
void dropSourceFromDataengine(const QString source);
|
||||
void needTextToBeUpdated(const QString newText);
|
||||
void needToolTipToBeUpdated(const QString newText);
|
||||
void needToBeUpdated();
|
||||
|
||||
private slots:
|
||||
void dataUpdate();
|
||||
void loadKeysFromCache();
|
||||
void reinitKeys();
|
||||
// editor
|
||||
@ -93,11 +95,11 @@ private:
|
||||
QString htmlValue(QString key);
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units);
|
||||
QString toolTipImage();
|
||||
// find methods
|
||||
QStringList findGraphicalItems();
|
||||
QStringList findKeys();
|
||||
// get methods
|
||||
// get methods
|
||||
QList<ExtQuotes *> getExtQuotes();
|
||||
QList<ExtScript *> getExtScripts();
|
||||
QList<ExtUpgrade *> getExtUpgrade();
|
||||
|
@ -33,7 +33,7 @@ AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
toolTipScene = new QGraphicsScene();
|
||||
toolTipScene = new QGraphicsScene(nullptr);
|
||||
toolTipView = new QGraphicsView(toolTipScene);
|
||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||
@ -72,7 +72,6 @@ AWToolTip::~AWToolTip()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete toolTipView;
|
||||
delete toolTipScene;
|
||||
}
|
||||
|
||||
@ -94,10 +93,9 @@ QPixmap AWToolTip::image()
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
// background
|
||||
if (configuration[QString("useTooltipBackground")].toBool())
|
||||
toolTipScene->setBackgroundBrush(QBrush(QColor(configuration[QString("tooltipBackground")].toString())));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
||||
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
||||
QBrush(Qt::NoBrush));
|
||||
bool down = false;
|
||||
for (int i=0; i<requiredKeys.count(); i++) {
|
||||
float normX = 100.0 / static_cast<float>(data[requiredKeys[i]].count());
|
||||
|
@ -52,7 +52,8 @@ public:
|
||||
};
|
||||
|
||||
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString fileName();
|
||||
QString image(const float value);
|
||||
|
@ -151,12 +151,12 @@ void ExtQuotes::setApiVersion(const int _apiVersion)
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::setActive(const bool state)
|
||||
void ExtQuotes::setActive(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_active = state;
|
||||
m_active = _state;
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,12 +196,12 @@ void ExtScript::setApiVersion(const int _apiVersion)
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setActive(const bool state)
|
||||
void ExtScript::setActive(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_active = state;
|
||||
m_active = _state;
|
||||
}
|
||||
|
||||
|
||||
@ -519,7 +519,7 @@ void ExtScript::updateValue()
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||
break;
|
||||
case stderr2stdout:
|
||||
value = QString("%1\t%2").arg(qdebug).arg(qoutput);
|
||||
value = QString("%1\n%2").arg(qdebug).arg(qoutput);
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
|
@ -333,14 +333,14 @@ QVariantMap ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
(fullLevelFile.open(QIODevice::ReadOnly))) {
|
||||
float batCurrent = QString(currentLevelFile.readLine()).trimmed().toFloat();
|
||||
float batFull = QString(fullLevelFile.readLine()).trimmed().toFloat();
|
||||
battery[QString("bat%1").arg(i)] = 100 * batCurrent / batFull;
|
||||
battery[QString("bat%1").arg(i)] = static_cast<int>(100 * batCurrent / batFull);
|
||||
currentLevel += batCurrent;
|
||||
fullLevel += batFull;
|
||||
}
|
||||
currentLevelFile.close();
|
||||
fullLevelFile.close();
|
||||
}
|
||||
battery[QString("bat")] = 100 * currentLevel / fullLevel;
|
||||
battery[QString("bat")] = static_cast<int>(100 * currentLevel / fullLevel);
|
||||
|
||||
return battery;
|
||||
}
|
||||
|
@ -146,12 +146,12 @@ void ExtUpgrade::setApiVersion(const int _apiVersion)
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setActive(const bool state)
|
||||
void ExtUpgrade::setActive(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_active = state;
|
||||
m_active = _state;
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ int ExtUpgrade::run()
|
||||
if (!m_active) return value;
|
||||
|
||||
if ((times == 1) && (process->state() == QProcess::NotRunning))
|
||||
process->start(QString("bash -c \"%1\"").arg(m_executable));
|
||||
process->start(QString("sh -c \"%1\"").arg(m_executable));
|
||||
else if (times >= m_interval)
|
||||
times = 0;
|
||||
times++;
|
||||
|
Loading…
Reference in New Issue
Block a user