mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-14 22:35:49 +00:00
add support of smartctl (TODO remove qdbus calls)
end work on awesome-widget (prerelease state)
This commit is contained in:
@ -79,14 +79,9 @@ void AWActions::runCmd(const QString cmd)
|
||||
}
|
||||
|
||||
|
||||
void AWActions::sendNotification(const QString eventId, const QString message)
|
||||
void AWActions::sendEmail()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||
|
||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
||||
}
|
||||
|
||||
|
||||
@ -199,6 +194,13 @@ void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> confi
|
||||
}
|
||||
|
||||
|
||||
void AWActions::sendNotification(const QString eventId, const QString message)
|
||||
{
|
||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
||||
}
|
||||
|
||||
|
||||
void AWActions::showUpdates(QString version)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
Q_INVOKABLE void checkUpdates();
|
||||
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
||||
Q_INVOKABLE void sendNotification(const QString eventId, const QString message);
|
||||
Q_INVOKABLE void sendEmail();
|
||||
Q_INVOKABLE void showReadme();
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||
@ -45,6 +45,9 @@ public:
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
||||
|
||||
private slots:
|
||||
void showUpdates(QString version);
|
||||
void versionReplyRecieved(QNetworkReply *reply);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
// #include <QBuffer>
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@ -80,15 +80,6 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||
|
||||
return (data.count() != 0);
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> tooltipParams)
|
||||
{
|
||||
@ -101,7 +92,7 @@ void AWKeys::initKeys(const QString pattern,
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
foundKeys.clear();
|
||||
toolTip = nullptr;
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
|
||||
// init
|
||||
extScripts = getExtScripts();
|
||||
@ -130,6 +121,7 @@ QString AWKeys::parsePattern(const QString pattern)
|
||||
if (!ready) return pattern;
|
||||
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
parsed.replace(QString("$") + foundKeys[i], valueByKey(foundKeys[i]));
|
||||
@ -141,17 +133,26 @@ QString AWKeys::parsePattern(const QString pattern)
|
||||
}
|
||||
|
||||
|
||||
QPixmap AWKeys::toolTipImage()
|
||||
QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!ready) return QPixmap();
|
||||
if (!ready) return QString();
|
||||
|
||||
return toolTip->image();
|
||||
// QByteArray byteArray;
|
||||
// QBuffer buffer(&byteArray);
|
||||
// tooltip.save(&buffer, "PNG");
|
||||
// return QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
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;
|
||||
|
||||
return toolTip->getSize();
|
||||
}
|
||||
|
||||
|
||||
@ -672,6 +673,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 true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -954,6 +958,15 @@ void AWKeys::copyUpgrade(const QString original)
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||
|
||||
return (data.count() != 0);
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QVariant>
|
||||
|
||||
@ -50,12 +49,12 @@ public:
|
||||
AWKeys(QObject *parent = 0);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE bool checkKeys(const QMap<QString, QVariant> data);
|
||||
Q_INVOKABLE void initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> tooltipParams);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE QPixmap toolTipImage();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
Q_INVOKABLE bool addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
@ -82,6 +81,7 @@ private slots:
|
||||
|
||||
private:
|
||||
// methods
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units = QString("Celsius"));
|
||||
|
@ -56,6 +56,8 @@ AWToolTip::AWToolTip(QObject *parent,
|
||||
boundaries[QString("downTooltip")] = 1.0;
|
||||
boundaries[QString("upTooltip")] = 1.0;
|
||||
boundaries[QString("batTooltip")] = 100.0;
|
||||
size.setHeight(105.0);
|
||||
size.setWidth(100.0 * counts);
|
||||
|
||||
if (configuration[QString("cpuTooltip")].toBool()) requiredKeys.append(QString("cpuTooltip"));
|
||||
if (configuration[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpuclTooltip"));
|
||||
@ -76,17 +78,25 @@ AWToolTip::~AWToolTip()
|
||||
}
|
||||
|
||||
|
||||
QSize AWToolTip::getSize()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
QPixmap AWToolTip::image()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
toolTipView->resize(100.0 * counts, 105.0);
|
||||
toolTipView->resize(size);
|
||||
// create image
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
// background
|
||||
if (configuration[QString("useTooltipBackground")].toBool())
|
||||
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")].toString()));
|
||||
toolTipScene->setBackgroundBrush(QBrush(QColor(configuration[QString("tooltipBackground")].toString())));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
bool down = false;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||
~AWToolTip();
|
||||
|
||||
QSize getSize();
|
||||
QPixmap image();
|
||||
void setData(const QString source, float value,
|
||||
const bool ac = true);
|
||||
@ -51,6 +52,7 @@ private:
|
||||
QMap<QString, float> boundaries;
|
||||
QMap<QString, QList<float>> data;
|
||||
QStringList requiredKeys;
|
||||
QSize size;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user