mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
some fixes
This commit is contained in:
parent
27fd4e8f1e
commit
86d4bd76ea
@ -70,7 +70,6 @@ Item {
|
||||
text: i18n("ACPI path")
|
||||
}
|
||||
QtControls.TextField {
|
||||
height: parent.height
|
||||
width: parent.width * 3 / 5
|
||||
text: cfg_dataengine["ACPIPATH"]
|
||||
}
|
||||
@ -154,9 +153,8 @@ Item {
|
||||
text: i18n("hddtemp cmd")
|
||||
}
|
||||
QtControls.TextField {
|
||||
height: parent.height
|
||||
width: parent.width * 3 / 5
|
||||
text: cfg_dataengine["HDDTEMP"]
|
||||
text: cfg_dataengine["HDDTEMPCMD"]
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +169,6 @@ Item {
|
||||
text: i18n("MPD address")
|
||||
}
|
||||
QtControls.TextField {
|
||||
height: parent.height
|
||||
width: parent.width * 3 / 5
|
||||
text: cfg_dataengine["MPDADDRESS"]
|
||||
}
|
||||
|
@ -62,14 +62,12 @@ Item {
|
||||
|
||||
// init
|
||||
Plasmoid.icon: "utilities-system-monitor"
|
||||
Plasmoid.backgroundHints: "DefaultBackground"
|
||||
Plasmoid.toolTipMainText: "Awesome Widget"
|
||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||
Plasmoid.associatedApplication: "ksysguard"
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: systemmonitorDE
|
||||
engine: "systemmonitor"
|
||||
connectedSources: []
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
@ -81,8 +79,7 @@ Item {
|
||||
onSourceAdded: {
|
||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
||||
|
||||
systemmonitorDE.connectSource(source)
|
||||
AWKeys.addDevice(source)
|
||||
if (AWKeys.addDevice(source)) systemmonitorDE.connectSource(source)
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,9 +93,7 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
// update
|
||||
if (sourceName == "update") needUpdate()
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) needUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +125,13 @@ Item {
|
||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||
textFormat: Text.RichText
|
||||
text: plasmoid.configuration.text
|
||||
|
||||
PlasmaCore.ToolTipArea {
|
||||
id: tooltip
|
||||
height: 100
|
||||
width: 500
|
||||
mainText: "Awesome Widget"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,6 +150,8 @@ Item {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||
// FIXME change to pixmap/image/etc
|
||||
tooltip.mainText = AWKeys.toolTipImage()
|
||||
// update geometry
|
||||
text.update()
|
||||
height = text.contentHeight
|
||||
|
@ -59,6 +59,7 @@ Item {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.WordWrap
|
||||
text: i18n("CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make needed checkbox fully checked.")
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ Item {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.WordWrap
|
||||
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@ -140,15 +141,21 @@ QString AWKeys::parsePattern(const QString pattern)
|
||||
}
|
||||
|
||||
|
||||
QPixmap AWKeys::toolTipImage()
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolTip->image();
|
||||
if (!ready) 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()));
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::addDevice(const QString source)
|
||||
bool AWKeys::addDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
@ -170,6 +177,40 @@ void AWKeys::addDevice(const QString source)
|
||||
mountDevices.append(device);
|
||||
} else if (tempRegexp.indexIn(source) > -1)
|
||||
tempDevices.append(source);
|
||||
|
||||
// check sources to be connected
|
||||
if ((source.endsWith(QString("/TotalLoad"))) ||
|
||||
(source.endsWith(QString("/clock"))) ||
|
||||
(source.endsWith(QString("/AverageClock"))) ||
|
||||
(source.endsWith(QString("/Rate/rblk"))) ||
|
||||
(source.endsWith(QString("/Rate/wblk"))) ||
|
||||
(source.endsWith(QString("/filllevel"))) ||
|
||||
(source.endsWith(QString("/freespace"))) ||
|
||||
(source.endsWith(QString("/usedspace"))) ||
|
||||
(source.endsWith(QString("/receiver/data"))) ||
|
||||
(source.endsWith(QString("/receiver/data"))) ||
|
||||
(source.endsWith(QString("/transmitter/data"))) ||
|
||||
(source.startsWith(QString("lmsensors/"))) ||
|
||||
(source.startsWith(QString("mem/physical/"))) ||
|
||||
(source.startsWith(QString("mem/swap/"))) ||
|
||||
(source == QString("system/uptime")) ||
|
||||
(source == QString("Local")) ||
|
||||
(source == QString("battery")) ||
|
||||
(source == QString("custom")) ||
|
||||
(source == QString("desktop")) ||
|
||||
(source == QString("netdev")) ||
|
||||
(source == QString("gpu")) ||
|
||||
(source == QString("gputemp")) ||
|
||||
(source == QString("hddtemp")) ||
|
||||
(source == QString("pkg")) ||
|
||||
(source == QString("player")) ||
|
||||
(source == QString("ps")) ||
|
||||
(source == QString("update")))
|
||||
return true;
|
||||
else {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source << "not found";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -279,8 +320,12 @@ QStringList AWKeys::dictKeys()
|
||||
allKeys.append(QString("ndesktop"));
|
||||
allKeys.append(QString("tdesktops"));
|
||||
// bars
|
||||
QStringList graphicalItemsKeys;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
allKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
graphicalItemsKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
graphicalItemsKeys.sort();
|
||||
for (int i=graphicalItemsKeys.count()-1; i>=0; i--)
|
||||
allKeys.append(graphicalItemsKeys[i]);
|
||||
|
||||
return allKeys;
|
||||
}
|
||||
@ -366,6 +411,8 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
|
||||
if (sourceName == QString("update")) return true;
|
||||
|
||||
// checking
|
||||
if (!checkKeys(data)) return false;
|
||||
if (!ready) return false;
|
||||
@ -625,12 +672,9 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours));
|
||||
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
||||
} else {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source not found";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -984,11 +1028,13 @@ QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||
QStringList AWKeys::findKeys(const QString pattern)
|
||||
{
|
||||
QStringList selectedKeys;
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
for (int i=0; i<keys.count(); i++) {
|
||||
if (keys[i].startsWith(QString("bar"))) continue;
|
||||
if (pattern.contains(QString("$") + keys[i])) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||
selectedKeys.append(keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
@ -55,9 +55,10 @@ public:
|
||||
const QMap<QString, QVariant> tooltipParams);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE QPixmap toolTipImage();
|
||||
// Q_INVOKABLE QPixmap toolTipImage();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
// keys
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE bool addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList getDiskDevices();
|
||||
Q_INVOKABLE QStringList getFanDevices();
|
||||
|
@ -26,7 +26,7 @@
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
QMap<QString, QVariant> settings)
|
||||
: QObject(parent),
|
||||
m_settings(settings)
|
||||
configuration(settings)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
@ -41,12 +41,12 @@ AWToolTip::AWToolTip(QObject *parent,
|
||||
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
m_counts += m_settings[QString("cpuTooltip")].toInt();
|
||||
m_counts += m_settings[QString("cpuclTooltip")].toInt();
|
||||
m_counts += m_settings[QString("memTooltip")].toInt();
|
||||
m_counts += m_settings[QString("swapTooltip")].toInt();
|
||||
m_counts += m_settings[QString("downTooltip")].toInt();
|
||||
m_counts += m_settings[QString("batteryTooltip")].toInt();
|
||||
counts += configuration[QString("cpuTooltip")].toInt();
|
||||
counts += configuration[QString("cpuclTooltip")].toInt();
|
||||
counts += configuration[QString("memTooltip")].toInt();
|
||||
counts += configuration[QString("swapTooltip")].toInt();
|
||||
counts += configuration[QString("downTooltip")].toInt();
|
||||
counts += configuration[QString("batteryTooltip")].toInt();
|
||||
|
||||
boundaries[QString("cpu")] = 100.0;
|
||||
boundaries[QString("cpucl")] = 4000.0;
|
||||
@ -56,13 +56,13 @@ AWToolTip::AWToolTip(QObject *parent,
|
||||
boundaries[QString("up")] = 1.0;
|
||||
boundaries[QString("bat")] = 100.0;
|
||||
|
||||
if (m_settings[QString("cpuTooltip")].toBool()) requiredKeys.append(QString("cpu"));
|
||||
if (m_settings[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpucl"));
|
||||
if (m_settings[QString("memTooltip")].toBool()) requiredKeys.append(QString("mem"));
|
||||
if (m_settings[QString("swapTooltip")].toBool()) requiredKeys.append(QString("swap"));
|
||||
if (m_settings[QString("downTooltip")].toBool()) requiredKeys.append(QString("down"));
|
||||
if (m_settings[QString("upTooltip")].toBool()) requiredKeys.append(QString("up"));
|
||||
if (m_settings[QString("batTooltip")].toBool()) requiredKeys.append(QString("bat"));
|
||||
if (configuration[QString("cpuTooltip")].toBool()) requiredKeys.append(QString("cpu"));
|
||||
if (configuration[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpucl"));
|
||||
if (configuration[QString("memTooltip")].toBool()) requiredKeys.append(QString("mem"));
|
||||
if (configuration[QString("swapTooltip")].toBool()) requiredKeys.append(QString("swap"));
|
||||
if (configuration[QString("downTooltip")].toBool()) requiredKeys.append(QString("down"));
|
||||
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("up"));
|
||||
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("bat"));
|
||||
}
|
||||
|
||||
|
||||
@ -79,13 +79,13 @@ QPixmap AWToolTip::image()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
toolTipView->resize(100.0 * m_counts, 105.0);
|
||||
toolTipView->resize(100.0 * counts, 105.0);
|
||||
// create image
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
// background
|
||||
if (m_settings[QString("useTooltipBackground")].toBool())
|
||||
toolTipScene->setBackgroundBrush(QColor(m_settings[QString("tooltipBackground")].toString()));
|
||||
if (configuration[QString("useTooltipBackground")].toBool())
|
||||
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")].toString()));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
bool down = false;
|
||||
@ -97,7 +97,7 @@ QPixmap AWToolTip::image()
|
||||
isBattery = true;
|
||||
else
|
||||
isBattery = false;
|
||||
if (!isBattery) pen.setColor(QColor(m_settings[requiredKeys[i] + QString("Color")].toString()));
|
||||
if (!isBattery) pen.setColor(QColor(configuration[requiredKeys[i] + QString("Color")].toString()));
|
||||
float shift = i * 100.0;
|
||||
if (down) shift -= 100.0;
|
||||
for (int j=0; j<data[requiredKeys[i]].count()-1; j++) {
|
||||
@ -107,9 +107,9 @@ QPixmap AWToolTip::image()
|
||||
float y2 = - fabs(data[requiredKeys[i]][j+1]) * normY + 5.0;
|
||||
if (isBattery) {
|
||||
if (data[requiredKeys[i]][j+1] > 0)
|
||||
pen.setColor(QColor(m_settings[QString("batteryColor")].toString()));
|
||||
pen.setColor(QColor(configuration[QString("batteryColor")].toString()));
|
||||
else
|
||||
pen.setColor(QColor(m_settings[QString("batteryInColor")].toString()));
|
||||
pen.setColor(QColor(configuration[QString("batteryInColor")].toString()));
|
||||
}
|
||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
||||
}
|
||||
@ -126,7 +126,7 @@ void AWToolTip::setData (const QString source, const float value, const bool ac)
|
||||
|
||||
if (data[source].count() == 0)
|
||||
data[source].append(0.0);
|
||||
else if (data[source].count() > m_settings[QString("tooltipNumber")].toInt())
|
||||
else if (data[source].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
data[source].takeFirst();
|
||||
|
||||
if (ac)
|
||||
|
@ -33,7 +33,7 @@ class AWToolTip : public QObject
|
||||
|
||||
public:
|
||||
AWToolTip(QObject *parent = 0,
|
||||
QMap<QString, QVariant> m_settings = QMap<QString, QVariant>());
|
||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||
~AWToolTip();
|
||||
|
||||
QPixmap image();
|
||||
@ -46,8 +46,8 @@ private:
|
||||
QGraphicsView *toolTipView = nullptr;
|
||||
// variables
|
||||
bool debug = false;
|
||||
int m_counts = 0;
|
||||
QMap<QString, QVariant> m_settings;
|
||||
int counts = 0;
|
||||
QMap<QString, QVariant> configuration;
|
||||
QMap<QString, float> boundaries;
|
||||
QMap<QString, QList<float>> data;
|
||||
QStringList requiredKeys;
|
||||
|
Loading…
Reference in New Issue
Block a user