mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
some code style improvements (#67)
This commit is contained in:
@ -73,8 +73,8 @@ bool AWActions::dropCache() const
|
||||
{
|
||||
qCDebug(LOG_AW);
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").
|
||||
arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
|
||||
return QFile(fileName).remove();
|
||||
}
|
||||
@ -116,33 +116,35 @@ QString AWActions::getAboutText(const QString type) const
|
||||
qCDebug(LOG_AW) << "Type" << type;
|
||||
|
||||
QString text;
|
||||
if (type == QString("header"))
|
||||
if (type == QString("header")) {
|
||||
text = QString(NAME);
|
||||
else if (type == QString("version")) {
|
||||
} else if (type == QString("version")) {
|
||||
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||
if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
||||
} else if (type == QString("description"))
|
||||
} else if (type == QString("description")) {
|
||||
text = i18n("A set of minimalistic plasmoid widgets");
|
||||
else if (type == QString("links"))
|
||||
text = i18n("Links:") + QString("<br>") +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(i18n("Repository")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages")) +
|
||||
QString("<a href=\"%1\">%2</a>").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages"));
|
||||
else if (type == QString("copy"))
|
||||
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
||||
i18n("This software is licensed under %1", QString(LICENSE)) + QString("</small>");
|
||||
else if (type == QString("translators"))
|
||||
} else if (type == QString("links")) {
|
||||
text = i18n("Links:") + QString("<br>")
|
||||
+ QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(i18n("Homepage"))
|
||||
+ QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(i18n("Repository"))
|
||||
+ QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker"))
|
||||
+ QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(i18n("Translation issue"))
|
||||
+ QString("<a href=\"%1\">%2</a><br>").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages"))
|
||||
+ QString("<a href=\"%1\">%2</a>").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages"));
|
||||
} else if (type == QString("copy")) {
|
||||
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").
|
||||
arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR))
|
||||
+ i18n("This software is licensed under %1", QString(LICENSE))
|
||||
+ QString("</small>");
|
||||
} else if (type == QString("translators")) {
|
||||
text = i18n("Translators: %1", QString(TRANSLATORS));
|
||||
else if (type == QString("3rdparty")) {
|
||||
} else if (type == QString("3rdparty")) {
|
||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<trdPartyList.count(); i++)
|
||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||
.arg(trdPartyList.at(i).split(QChar(','))[0])
|
||||
.arg(trdPartyList.at(i).split(QChar(','))[1])
|
||||
.arg(trdPartyList.at(i).split(QChar(','))[2]);
|
||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)").
|
||||
arg(trdPartyList.at(i).split(QChar(','))[0]).
|
||||
arg(trdPartyList.at(i).split(QChar(','))[1]).
|
||||
arg(trdPartyList.at(i).split(QChar(','))[2]);
|
||||
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||
}
|
||||
|
||||
@ -173,7 +175,8 @@ QVariantMap AWActions::readDataEngineConfiguration() const
|
||||
{
|
||||
qCDebug(LOG_AW);
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
|
||||
QString("plasma-dataengine-extsysmon.conf"));
|
||||
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
QVariantMap configuration;
|
||||
@ -200,7 +203,8 @@ void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) co
|
||||
{
|
||||
qCDebug(LOG_AW);
|
||||
|
||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)
|
||||
+ QString("/plasma-dataengine-extsysmon.conf");
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
|
||||
|
||||
@ -227,7 +231,9 @@ void AWActions::sendNotification(const QString eventId, const QString message)
|
||||
qCDebug(LOG_AW) << "Event" << eventId;
|
||||
qCDebug(LOG_AW) << "Message" << message;
|
||||
|
||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: %1").arg(eventId), message);
|
||||
KNotification *notification = KNotification::event(eventId,
|
||||
QString("Awesome Widget ::: %1").arg(eventId),
|
||||
message);
|
||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
||||
}
|
||||
|
||||
@ -238,7 +244,8 @@ void AWActions::showInfo(const QString version) const
|
||||
qCDebug(LOG_AW) << "Version" << version;
|
||||
|
||||
QString text = i18n("You are using the actual version %1", version);
|
||||
if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
||||
if (!QString(COMMIT_SHA).isEmpty())
|
||||
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
||||
QMessageBox::information(nullptr, i18n("No new version found"), text);
|
||||
}
|
||||
|
||||
@ -261,6 +268,9 @@ void AWActions::showUpdates(const QString version) const
|
||||
case QMessageBox::Ok:
|
||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,8 +285,8 @@ void AWActions::versionReplyRecieved(QNetworkReply *reply, const bool showAnyway
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
reply->deleteLater();
|
||||
if ((reply->error() != QNetworkReply::NoError) ||
|
||||
(error.error != QJsonParseError::NoError)) {
|
||||
if ((reply->error() != QNetworkReply::NoError)
|
||||
|| (error.error != QJsonParseError::NoError)) {
|
||||
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||
return;
|
||||
}
|
||||
@ -294,9 +304,9 @@ void AWActions::versionReplyRecieved(QNetworkReply *reply, const bool showAnyway
|
||||
int new_major = QString(version).split(QChar('.')).at(0).toInt();
|
||||
int new_minor = QString(version).split(QChar('.')).at(1).toInt();
|
||||
int new_patch = QString(version).split(QChar('.')).at(2).toInt();
|
||||
if ((old_major < new_major) ||
|
||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||
if ((old_major < new_major)
|
||||
|| ((old_major == new_major) && (old_minor < new_minor))
|
||||
|| ((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||
return showUpdates(version);
|
||||
else if (showAnyway)
|
||||
return showInfo(version);
|
||||
|
@ -31,7 +31,6 @@ class AWActions : public QObject
|
||||
public:
|
||||
explicit AWActions(QObject *parent = nullptr);
|
||||
virtual ~AWActions();
|
||||
|
||||
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
||||
Q_INVOKABLE bool dropCache() const;
|
||||
Q_INVOKABLE bool isDebugEnabled() const;
|
||||
|
@ -39,7 +39,6 @@ AWDataAggregator::AWDataAggregator(QObject *parent)
|
||||
qRegisterMetaType<QHash<QString, QString>>("QHash<QString, QString>");
|
||||
|
||||
initScene();
|
||||
|
||||
connect(this, SIGNAL(updateData(const QHash<QString, QString>)),
|
||||
this, SLOT(dataUpdate(const QHash<QString, QString>)));
|
||||
}
|
||||
@ -70,8 +69,9 @@ QString AWDataAggregator::htmlImage(const QPixmap source) const
|
||||
QBuffer buffer(&byteArray);
|
||||
source.save(&buffer, "PNG");
|
||||
|
||||
return byteArray.isEmpty() ? QString() :
|
||||
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
return byteArray.isEmpty() ? QString()
|
||||
: QString("<img src=\"data:image/png;base64,%1\"/>").
|
||||
arg(QString(byteArray.toBase64()));
|
||||
}
|
||||
|
||||
|
||||
@ -113,9 +113,9 @@ void AWDataAggregator::setParameters(QVariantMap settings)
|
||||
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
||||
|
||||
// background
|
||||
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
||||
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
||||
QBrush(Qt::NoBrush));
|
||||
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool()
|
||||
? QBrush(QColor(configuration[QString("tooltipBackground")].toString()))
|
||||
: QBrush(Qt::NoBrush));
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,8 @@ QPixmap AWDataAggregator::tooltipImage()
|
||||
float normX = 100.0 / static_cast<float>(data[key].count());
|
||||
float normY = 100.0 / (1.5 * boundaries[key]);
|
||||
float shift = requiredKeys.indexOf(key) * 100.0;
|
||||
if (down) shift -= 100.0;
|
||||
if (down)
|
||||
shift -= 100.0;
|
||||
// apply pen color
|
||||
if (key != QString("batTooltip"))
|
||||
pen.setColor(QColor(configuration[QString("%1Color").arg(key)].toString()));
|
||||
@ -151,7 +152,8 @@ QPixmap AWDataAggregator::tooltipImage()
|
||||
}
|
||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
||||
}
|
||||
if (key == QString("downTooltip")) down = true;
|
||||
if (key == QString("downTooltip"))
|
||||
down = true;
|
||||
}
|
||||
|
||||
return toolTipView->grab();
|
||||
@ -219,17 +221,16 @@ QString AWDataAggregator::notificationText(const QString source, const float val
|
||||
qCDebug(LOG_AW) << "Value" << value;
|
||||
|
||||
QString output;
|
||||
if (source == QString("batTooltip")) {
|
||||
if (source == QString("batTooltip"))
|
||||
output = value > 0.0 ? i18n("AC online") : i18n("AC offline");
|
||||
} else if (source == QString("cpuTooltip")) {
|
||||
else if (source == QString("cpuTooltip"))
|
||||
output = i18n("High CPU load");
|
||||
} else if (source == QString("memTooltip")) {
|
||||
else if (source == QString("memTooltip"))
|
||||
output = i18n("High memory usage");
|
||||
} else if (source == QString("swapTooltip")) {
|
||||
else if (source == QString("swapTooltip"))
|
||||
output = i18n("Swap is used");
|
||||
} else if (source == QString("gpu")) {
|
||||
else if (source == QString("gpu"))
|
||||
output = i18n("High GPU load");
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -242,9 +243,8 @@ QString AWDataAggregator::notificationText(const QString source, const QString v
|
||||
qCDebug(LOG_AW) << "Value" << value;
|
||||
|
||||
QString output;
|
||||
if (source == QString("netdev")) {
|
||||
if (source == QString("netdev"))
|
||||
output = i18n("Network device has been changed to %1", value);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -288,7 +288,8 @@ void AWDataAggregator::setData(const QString source, float value, const float ex
|
||||
data[source].append(0.0);
|
||||
else if (data[source].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
data[source].removeFirst();
|
||||
if (isnan(value)) value = 0.0;
|
||||
if (isnan(value))
|
||||
value = 0.0;
|
||||
|
||||
// notifications
|
||||
checkValue(source, value, extremum);
|
||||
|
@ -119,7 +119,8 @@ void AWDataEngineAggregator::dataUpdated(const QString sourceName, const Plasma:
|
||||
// HACK "deep copy" of data to avoid plasma crash on Data object destruction
|
||||
QString units = data[QString("units")].toString();
|
||||
// HACK workaround for time values which are stored in the different path
|
||||
QVariant value = sourceName == QString("Local") ? data[QString("DateTime")] : data[QString("value")];
|
||||
QVariant value = sourceName == QString("Local") ? data[QString("DateTime")]
|
||||
: data[QString("value")];
|
||||
|
||||
emit(updateData(sourceName, value, units));
|
||||
}
|
||||
|
@ -245,10 +245,10 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
allKeys.append(QString("netdev"));
|
||||
// battery
|
||||
allKeys.append(QString("ac"));
|
||||
QStringList allBatteryDevices = QDir(QString("/sys/class/power_supply"))
|
||||
.entryList(QStringList() << QString("BAT*"),
|
||||
QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDir::Name);
|
||||
QStringList allBatteryDevices = QDir(QString("/sys/class/power_supply")).
|
||||
entryList(QStringList() << QString("BAT*"),
|
||||
QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDir::Name);
|
||||
for (int i=allBatteryDevices.count()-1; i>=0; i--)
|
||||
allKeys.append(QString("bat%1").arg(i));
|
||||
allKeys.append(QString("bat"));
|
||||
@ -303,7 +303,8 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
allKeys.append(graphicalItemsKeys.at(i));
|
||||
|
||||
// sort if required
|
||||
if (sorted) allKeys.sort();
|
||||
if (sorted)
|
||||
allKeys.sort();
|
||||
|
||||
return allKeys.filter(QRegExp(regexp));
|
||||
}
|
||||
@ -409,8 +410,10 @@ void AWKeys::dataUpdated(const QString sourceName, const QVariant value, const Q
|
||||
qCDebug(LOG_AW) << "Source" << sourceName;
|
||||
qCDebug(LOG_AW) << "Data" << value << units;
|
||||
|
||||
if (lock) return;
|
||||
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
||||
if (lock)
|
||||
return;
|
||||
if (sourceName == QString("update"))
|
||||
return emit(needToBeUpdated());
|
||||
|
||||
#ifdef BUILD_FUTURE
|
||||
// run concurrent data update
|
||||
@ -425,8 +428,8 @@ void AWKeys::loadKeysFromCache()
|
||||
{
|
||||
qCDebug(LOG_AW);
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").
|
||||
arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
|
||||
@ -483,7 +486,8 @@ void AWKeys::reinitKeys()
|
||||
qCInfo(LOG_AW) << "Found bar" << key;
|
||||
selectedKeys.append(key);
|
||||
}
|
||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No bars found";
|
||||
if (selectedKeys.isEmpty())
|
||||
qCWarning(LOG_AW) << "No bars found";
|
||||
return selectedKeys;
|
||||
}(m_pattern);
|
||||
|
||||
@ -496,7 +500,8 @@ void AWKeys::reinitKeys()
|
||||
qCInfo(LOG_AW) << "Found key" << key;
|
||||
selectedKeys.append(key);
|
||||
}
|
||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No keys found";
|
||||
if (selectedKeys.isEmpty())
|
||||
qCWarning(LOG_AW) << "No keys found";
|
||||
return selectedKeys;
|
||||
}(m_pattern);
|
||||
|
||||
@ -518,7 +523,8 @@ void AWKeys::reinitKeys()
|
||||
qCInfo(LOG_AW) << "Found lambda" << lambda;
|
||||
selectedKeys.append(lambda);
|
||||
}
|
||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No lambdas found";
|
||||
if (selectedKeys.isEmpty())
|
||||
qCWarning(LOG_AW) << "No lambdas found";
|
||||
return selectedKeys;
|
||||
}(m_pattern);
|
||||
|
||||
@ -551,7 +557,8 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
qCDebug(LOG_AW) << "Key type" << type;
|
||||
qCDebug(LOG_AW) << "Key" << key;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").
|
||||
arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
|
||||
@ -565,7 +572,8 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||
foreach(QString dev, devices) {
|
||||
QString device = QString("/dev/%1").arg(dev);
|
||||
if (cachedValues.contains(device)) continue;
|
||||
if (cachedValues.contains(device))
|
||||
continue;
|
||||
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||
}
|
||||
@ -573,12 +581,14 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
foreach(QNetworkInterface interface, rawInterfaceList) {
|
||||
QString device = interface.name();
|
||||
if (cachedValues.contains(device)) continue;
|
||||
if (cachedValues.contains(device))
|
||||
continue;
|
||||
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||
}
|
||||
} else {
|
||||
if (cachedValues.contains(key)) return;
|
||||
if (cachedValues.contains(key))
|
||||
return;
|
||||
qCInfo(LOG_AW) << "Found new key" << key << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
||||
}
|
||||
@ -598,23 +608,23 @@ void AWKeys::calculateValues()
|
||||
// hddtot*
|
||||
foreach(QString device, m_devices[QString("mount")]) {
|
||||
int index = m_devices[QString("mount")].indexOf(device);
|
||||
values[QString("hddtotmb%1").arg(index)] = QString("%1").arg(
|
||||
values[QString("hddfreemb%1").arg(index)].toFloat() +
|
||||
values[QString("hddmb%1").arg(index)].toFloat(), 5, 'f', 0);
|
||||
values[QString("hddtotgb%1").arg(index)] = QString("%1").arg(
|
||||
values[QString("hddfreegb%1").arg(index)].toFloat() +
|
||||
values[QString("hddgb%1").arg(index)].toFloat(), 5, 'f', 1);
|
||||
values[QString("hddtotmb%1").arg(index)] = QString("%1").
|
||||
arg(values[QString("hddfreemb%1").arg(index)].toFloat()
|
||||
+ values[QString("hddmb%1").arg(index)].toFloat(), 5, 'f', 0);
|
||||
values[QString("hddtotgb%1").arg(index)] = QString("%1").
|
||||
arg(values[QString("hddfreegb%1").arg(index)].toFloat()
|
||||
+ values[QString("hddgb%1").arg(index)].toFloat(), 5, 'f', 1);
|
||||
}
|
||||
|
||||
// memtot*
|
||||
values[QString("memtotmb")] = QString("%1").arg(
|
||||
values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
||||
values[QString("memtotgb")] = QString("%1").arg(
|
||||
values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(), 5, 'f', 1);
|
||||
values[QString("memtotmb")] = QString("%1").
|
||||
arg(values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
||||
values[QString("memtotgb")] = QString("%1").
|
||||
arg(values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(), 5, 'f', 1);
|
||||
// mem
|
||||
values[QString("mem")] = QString("%1").arg(
|
||||
100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
values[QString("mem")] = QString("%1").
|
||||
arg(100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
|
||||
// up, down, upkb, downkb, upunits, downunits
|
||||
int netIndex = m_devices[QString("net")].indexOf(values[QString("netdev")]);
|
||||
@ -626,14 +636,14 @@ void AWKeys::calculateValues()
|
||||
values[QString("upunits")] = values[QString("upunits%1").arg(netIndex)];
|
||||
|
||||
// swaptot*
|
||||
values[QString("swaptotmb")] = QString("%1").arg(
|
||||
values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
||||
values[QString("swaptotgb")] = QString("%1").arg(
|
||||
values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 5, 'f', 1);
|
||||
values[QString("swaptotmb")] = QString("%1").
|
||||
arg(values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
||||
values[QString("swaptotgb")] = QString("%1").
|
||||
arg(values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 5, 'f', 1);
|
||||
// swap
|
||||
values[QString("swap")] = QString("%1").arg(
|
||||
100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
values[QString("swap")] = QString("%1").
|
||||
arg(100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
|
||||
// lambdas
|
||||
foreach(QString key, m_foundLambdas)
|
||||
@ -649,8 +659,9 @@ void AWKeys::calculateValues()
|
||||
qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt()
|
||||
<< ":" << result.toString();
|
||||
return QString();
|
||||
} else
|
||||
} else {
|
||||
return result.toString();
|
||||
}
|
||||
}(key);
|
||||
}
|
||||
|
||||
@ -669,8 +680,8 @@ QString AWKeys::parsePattern(QString pattern) const
|
||||
// main keys
|
||||
foreach(QString key, m_foundKeys)
|
||||
pattern.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
||||
if ((!key.startsWith(QString("custom"))) &&
|
||||
(!key.startsWith(QString("weather"))))
|
||||
if ((!key.startsWith(QString("custom")))
|
||||
&& (!key.startsWith(QString("weather"))))
|
||||
value.replace(QString(" "), QString(" "));
|
||||
return value;
|
||||
}(key, values[key]));
|
||||
@ -690,7 +701,8 @@ QString AWKeys::parsePattern(QString pattern) const
|
||||
|
||||
// prepare strings
|
||||
pattern.replace(QString("$\\$\\"), QString("$$"));
|
||||
if (m_wrapNewLines) pattern.replace(QString("\n"), QString("<br>"));
|
||||
if (m_wrapNewLines)
|
||||
pattern.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
@ -518,22 +518,22 @@ float AWKeysAggregator::temperature(const float temp) const
|
||||
qCDebug(LOG_AW) << "Temperature value" << temp;
|
||||
|
||||
float converted = temp;
|
||||
if (m_tempUnits == QString("Celsius"))
|
||||
;
|
||||
else if (m_tempUnits == QString("Fahrenheit"))
|
||||
if (m_tempUnits == QString("Celsius")) {
|
||||
} else if (m_tempUnits == QString("Fahrenheit")) {
|
||||
converted = temp * 9.0 / 5.0 + 32.0;
|
||||
else if (m_tempUnits == QString("Kelvin"))
|
||||
} else if (m_tempUnits == QString("Kelvin")) {
|
||||
converted = temp + 273.15;
|
||||
else if (m_tempUnits == QString("Reaumur"))
|
||||
} else if (m_tempUnits == QString("Reaumur")) {
|
||||
converted = temp * 0.8;
|
||||
else if (m_tempUnits == QString("cm^-1"))
|
||||
} else if (m_tempUnits == QString("cm^-1")) {
|
||||
converted = (temp + 273.15) * 0.695;
|
||||
else if (m_tempUnits == QString("kJ/mol"))
|
||||
} else if (m_tempUnits == QString("kJ/mol")) {
|
||||
converted = (temp + 273.15) * 8.31;
|
||||
else if (m_tempUnits == QString("kcal/mol"))
|
||||
} else if (m_tempUnits == QString("kcal/mol")) {
|
||||
converted = (temp + 273.15) * 1.98;
|
||||
else
|
||||
} else {
|
||||
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
|
||||
}
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
Reference in New Issue
Block a user