mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
add support of smartctl (TODO remove qdbus calls)
end work on awesome-widget (prerelease state)
This commit is contained in:
parent
eac1319889
commit
f01fd96cf6
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
import org.kde.plasma.plasmoid 2.0
|
import org.kde.plasma.plasmoid 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
@ -39,7 +40,7 @@ Item {
|
|||||||
property variant tooltipSettings: {
|
property variant tooltipSettings: {
|
||||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
||||||
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
|
"tooltipBackground": plasmoid.configuration.tooltipBackground,
|
||||||
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
||||||
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
||||||
"memTooltip": plasmoid.configuration.memTooltip,
|
"memTooltip": plasmoid.configuration.memTooltip,
|
||||||
@ -61,6 +62,14 @@ Item {
|
|||||||
|
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
|
||||||
|
Plasmoid.compactRepresentation: Plasmoid.fullRepresentation
|
||||||
|
|
||||||
|
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
||||||
|
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
||||||
|
Layout.minimumHeight: text.height
|
||||||
|
Layout.minimumWidth: text.width
|
||||||
|
|
||||||
Plasmoid.icon: "utilities-system-monitor"
|
Plasmoid.icon: "utilities-system-monitor"
|
||||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||||
Plasmoid.associatedApplication: "ksysguard"
|
Plasmoid.associatedApplication: "ksysguard"
|
||||||
@ -68,18 +77,19 @@ Item {
|
|||||||
PlasmaCore.DataSource {
|
PlasmaCore.DataSource {
|
||||||
id: systemmonitorDE
|
id: systemmonitorDE
|
||||||
engine: "systemmonitor"
|
engine: "systemmonitor"
|
||||||
|
connectedSources: systemmonitorDE.sources
|
||||||
interval: plasmoid.configuration.interval
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
if (AWKeys.setDataBySource(sourceName, data, settings)) disconnectSource(sourceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSourceAdded: {
|
onSourceAdded: {
|
||||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
||||||
|
|
||||||
if (AWKeys.addDevice(source)) systemmonitorDE.connectSource(source)
|
AWKeys.addDevice(source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,27 +120,35 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ui
|
// ui
|
||||||
Grid {
|
Grid {
|
||||||
id: mainGrid
|
|
||||||
columns: 1
|
columns: 1
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
|
height: contentHeight
|
||||||
|
width: contentWidth
|
||||||
|
textFormat: Text.RichText
|
||||||
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
|
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
color: plasmoid.configuration.fontColor
|
color: plasmoid.configuration.fontColor
|
||||||
font.family: plasmoid.configuration.fontFamily
|
font.family: plasmoid.configuration.fontFamily
|
||||||
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
||||||
font.pointSize: plasmoid.configuration.fontSize
|
font.pointSize: plasmoid.configuration.fontSize
|
||||||
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
|
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
|
||||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
|
||||||
textFormat: Text.RichText
|
|
||||||
text: plasmoid.configuration.text
|
text: plasmoid.configuration.text
|
||||||
|
|
||||||
PlasmaCore.ToolTipArea {
|
PlasmaCore.ToolTipArea {
|
||||||
|
id: rootTooltip
|
||||||
|
mainItem: Text {
|
||||||
id: tooltip
|
id: tooltip
|
||||||
height: 100
|
textFormat: Text.RichText
|
||||||
width: 500
|
}
|
||||||
mainText: "Awesome Widget"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,25 +156,32 @@ Item {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[main::onCompleted]")
|
if (debug) console.log("[main::onCompleted]")
|
||||||
|
|
||||||
// init submodule
|
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
|
||||||
// actions
|
// actions
|
||||||
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
||||||
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
||||||
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
||||||
|
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
||||||
|
// init submodule
|
||||||
|
Plasmoid.userConfiguringChanged(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||||
// FIXME change to pixmap/image/etc
|
tooltip.text = AWKeys.toolTipImage()
|
||||||
tooltip.image = AWKeys.toolTipImage()
|
|
||||||
// update geometry
|
// update geometry
|
||||||
text.update()
|
text.update()
|
||||||
height = text.contentHeight
|
height = text.height
|
||||||
width = text.contentWidth
|
width = text.width
|
||||||
update()
|
update()
|
||||||
|
rootTooltip.height = AWKeys.toolTipSize().height
|
||||||
|
rootTooltip.width = AWKeys.toolTipSize().width
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
|
// init submodule
|
||||||
|
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_checkUpdates() {
|
function action_checkUpdates() {
|
||||||
@ -171,6 +196,12 @@ Item {
|
|||||||
AWActions.showReadme()
|
AWActions.showReadme()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function action_report() {
|
||||||
|
if (debug) console.log("[main::action_report]")
|
||||||
|
|
||||||
|
AWActions.sendEmail()
|
||||||
|
}
|
||||||
|
|
||||||
function action_requestKey() {
|
function action_requestKey() {
|
||||||
if (debug) console.log("[main::action_requestKey]")
|
if (debug) console.log("[main::action_requestKey]")
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ Item {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
id: pageColumn
|
||||||
width: units.gridUnit * 50
|
width: units.gridUnit * 25
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
@ -78,6 +78,7 @@ Item {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
text: i18n("Font")
|
text: i18n("Font")
|
||||||
|
iconName: "font"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Font button")
|
if (debug) console.log("[widget::onClicked] : Font button")
|
||||||
@ -207,12 +208,17 @@ Item {
|
|||||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p")
|
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
id: tags
|
id: tags
|
||||||
model: AWKeys.dictKeys()
|
width: parent.width - addTagButton.width - showValueButton.width
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
id: addTagButton
|
||||||
text: i18n("Add")
|
text: i18n("Add")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -225,6 +231,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
id: showValueButton
|
||||||
text: i18n("Show value")
|
text: i18n("Show value")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
@ -293,5 +300,6 @@ Item {
|
|||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||||
|
tags.model = AWKeys.dictKeys()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
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)
|
void AWActions::showUpdates(QString version)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void checkUpdates();
|
Q_INVOKABLE void checkUpdates();
|
||||||
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
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();
|
Q_INVOKABLE void showReadme();
|
||||||
// configuration slots
|
// configuration slots
|
||||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||||
@ -45,6 +45,9 @@ public:
|
|||||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showUpdates(QString version);
|
void showUpdates(QString version);
|
||||||
void versionReplyRecieved(QNetworkReply *reply);
|
void versionReplyRecieved(QNetworkReply *reply);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
// #include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#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,
|
void AWKeys::initKeys(const QString pattern,
|
||||||
const QMap<QString, QVariant> tooltipParams)
|
const QMap<QString, QVariant> tooltipParams)
|
||||||
{
|
{
|
||||||
@ -101,7 +92,7 @@ void AWKeys::initKeys(const QString pattern,
|
|||||||
keys.clear();
|
keys.clear();
|
||||||
foundBars.clear();
|
foundBars.clear();
|
||||||
foundKeys.clear();
|
foundKeys.clear();
|
||||||
toolTip = nullptr;
|
if (toolTip != nullptr) delete toolTip;
|
||||||
|
|
||||||
// init
|
// init
|
||||||
extScripts = getExtScripts();
|
extScripts = getExtScripts();
|
||||||
@ -130,6 +121,7 @@ QString AWKeys::parsePattern(const QString pattern)
|
|||||||
if (!ready) return pattern;
|
if (!ready) return pattern;
|
||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = pattern;
|
||||||
|
parsed.replace(QString(" "), QString(" "));
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
for (int i=0; i<foundKeys.count(); i++)
|
for (int i=0; i<foundKeys.count(); i++)
|
||||||
parsed.replace(QString("$") + foundKeys[i], valueByKey(foundKeys[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(debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (!ready) return QPixmap();
|
if (!ready) return QString();
|
||||||
|
|
||||||
return toolTip->image();
|
QPixmap tooltip = toolTip->image();
|
||||||
// QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
// QBuffer buffer(&byteArray);
|
QBuffer buffer(&byteArray);
|
||||||
// tooltip.save(&buffer, "PNG");
|
tooltip.save(&buffer, "PNG");
|
||||||
// return QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
|
||||||
|
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("$h"), QString("%1").arg(hours));
|
||||||
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||||
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
||||||
|
} else {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Source not found";
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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()
|
QString AWKeys::networkDevice()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QPixmap>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -50,12 +49,12 @@ public:
|
|||||||
AWKeys(QObject *parent = 0);
|
AWKeys(QObject *parent = 0);
|
||||||
~AWKeys();
|
~AWKeys();
|
||||||
|
|
||||||
Q_INVOKABLE bool checkKeys(const QMap<QString, QVariant> data);
|
|
||||||
Q_INVOKABLE void initKeys(const QString pattern,
|
Q_INVOKABLE void initKeys(const QString pattern,
|
||||||
const QMap<QString, QVariant> tooltipParams);
|
const QMap<QString, QVariant> tooltipParams);
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||||
Q_INVOKABLE QPixmap toolTipImage();
|
Q_INVOKABLE QString toolTipImage();
|
||||||
|
Q_INVOKABLE QSize toolTipSize();
|
||||||
// keys
|
// keys
|
||||||
Q_INVOKABLE bool addDevice(const QString source);
|
Q_INVOKABLE bool addDevice(const QString source);
|
||||||
Q_INVOKABLE QStringList dictKeys();
|
Q_INVOKABLE QStringList dictKeys();
|
||||||
@ -82,6 +81,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// methods
|
// methods
|
||||||
|
bool checkKeys(const QMap<QString, QVariant> data);
|
||||||
QString networkDevice();
|
QString networkDevice();
|
||||||
int numberCpus();
|
int numberCpus();
|
||||||
float temperature(const float temp, const QString units = QString("Celsius"));
|
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("downTooltip")] = 1.0;
|
||||||
boundaries[QString("upTooltip")] = 1.0;
|
boundaries[QString("upTooltip")] = 1.0;
|
||||||
boundaries[QString("batTooltip")] = 100.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("cpuTooltip")].toBool()) requiredKeys.append(QString("cpuTooltip"));
|
||||||
if (configuration[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpuclTooltip"));
|
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()
|
QPixmap AWToolTip::image()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
toolTipView->resize(100.0 * counts, 105.0);
|
toolTipView->resize(size);
|
||||||
// create image
|
// create image
|
||||||
toolTipScene->clear();
|
toolTipScene->clear();
|
||||||
QPen pen = QPen();
|
QPen pen = QPen();
|
||||||
// background
|
// background
|
||||||
if (configuration[QString("useTooltipBackground")].toBool())
|
if (configuration[QString("useTooltipBackground")].toBool())
|
||||||
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")].toString()));
|
toolTipScene->setBackgroundBrush(QBrush(QColor(configuration[QString("tooltipBackground")].toString())));
|
||||||
else
|
else
|
||||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||||
bool down = false;
|
bool down = false;
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||||
~AWToolTip();
|
~AWToolTip();
|
||||||
|
|
||||||
|
QSize getSize();
|
||||||
QPixmap image();
|
QPixmap image();
|
||||||
void setData(const QString source, float value,
|
void setData(const QString source, float value,
|
||||||
const bool ac = true);
|
const bool ac = true);
|
||||||
@ -51,6 +52,7 @@ private:
|
|||||||
QMap<QString, float> boundaries;
|
QMap<QString, float> boundaries;
|
||||||
QMap<QString, QList<float>> data;
|
QMap<QString, QList<float>> data;
|
||||||
QStringList requiredKeys;
|
QStringList requiredKeys;
|
||||||
|
QSize size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,11 +449,23 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
|||||||
if (process.exitCode != 0)
|
if (process.exitCode != 0)
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
|
||||||
|
bool smartctl = cmd.contains(QString("smartctl"));
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Define smartctl" << smartctl;
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
if (smartctl) {
|
||||||
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
for (int i=0; i<qoutput.split(QChar(':'), QString::SkipEmptyParts).count(); i++) {
|
||||||
temp.remove(QChar(0260)).remove(QChar('C'));
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '))[0] != QString("194")) continue;
|
||||||
value = temp.toFloat();
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts).count() < 9) break;
|
||||||
|
value = qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts)[9].toFloat();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() < 3) {
|
||||||
|
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
||||||
|
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||||
|
value = temp.toFloat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
Loading…
Reference in New Issue
Block a user