mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
some code style improvements (#67)
This commit is contained in:
parent
827275da3f
commit
440d180c20
@ -73,8 +73,8 @@ bool AWActions::dropCache() const
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
QString fileName = QString("%1/awesomewidgets.ndx").
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
|
|
||||||
return QFile(fileName).remove();
|
return QFile(fileName).remove();
|
||||||
}
|
}
|
||||||
@ -116,33 +116,35 @@ QString AWActions::getAboutText(const QString type) const
|
|||||||
qCDebug(LOG_AW) << "Type" << type;
|
qCDebug(LOG_AW) << "Type" << type;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if (type == QString("header"))
|
if (type == QString("header")) {
|
||||||
text = QString(NAME);
|
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));
|
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
|
||||||
if (!QString(COMMIT_SHA).isEmpty()) text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
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");
|
text = i18n("A set of minimalistic plasmoid widgets");
|
||||||
else if (type == QString("links"))
|
} else if (type == QString("links")) {
|
||||||
text = i18n("Links:") + QString("<br>") +
|
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(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(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(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(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><br>").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages"))
|
||||||
QString("<a href=\"%1\">%2</a>").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages"));
|
+ QString("<a href=\"%1\">%2</a>").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages"));
|
||||||
else if (type == QString("copy"))
|
} 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)) +
|
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").
|
||||||
i18n("This software is licensed under %1", QString(LICENSE)) + QString("</small>");
|
arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR))
|
||||||
else if (type == QString("translators"))
|
+ i18n("This software is licensed under %1", QString(LICENSE))
|
||||||
|
+ QString("</small>");
|
||||||
|
} else if (type == QString("translators")) {
|
||||||
text = i18n("Translators: %1", 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);
|
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<trdPartyList.count(); i++)
|
for (int i=0; i<trdPartyList.count(); i++)
|
||||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)").
|
||||||
.arg(trdPartyList.at(i).split(QChar(','))[0])
|
arg(trdPartyList.at(i).split(QChar(','))[0]).
|
||||||
.arg(trdPartyList.at(i).split(QChar(','))[1])
|
arg(trdPartyList.at(i).split(QChar(','))[1]).
|
||||||
.arg(trdPartyList.at(i).split(QChar(','))[2]);
|
arg(trdPartyList.at(i).split(QChar(','))[2]);
|
||||||
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +175,8 @@ QVariantMap AWActions::readDataEngineConfiguration() const
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
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;
|
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
QVariantMap configuration;
|
QVariantMap configuration;
|
||||||
@ -200,7 +203,8 @@ void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) co
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
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);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
|
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) << "Event" << eventId;
|
||||||
qCDebug(LOG_AW) << "Message" << message;
|
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"));
|
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;
|
qCDebug(LOG_AW) << "Version" << version;
|
||||||
|
|
||||||
QString text = i18n("You are using the actual version %1", 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);
|
QMessageBox::information(nullptr, i18n("No new version found"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,6 +268,9 @@ void AWActions::showUpdates(const QString version) const
|
|||||||
case QMessageBox::Ok:
|
case QMessageBox::Ok:
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||||
break;
|
break;
|
||||||
|
case QMessageBox::Cancel:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,8 +285,8 @@ void AWActions::versionReplyRecieved(QNetworkReply *reply, const bool showAnyway
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if ((reply->error() != QNetworkReply::NoError) ||
|
if ((reply->error() != QNetworkReply::NoError)
|
||||||
(error.error != QJsonParseError::NoError)) {
|
|| (error.error != QJsonParseError::NoError)) {
|
||||||
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||||
return;
|
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_major = QString(version).split(QChar('.')).at(0).toInt();
|
||||||
int new_minor = QString(version).split(QChar('.')).at(1).toInt();
|
int new_minor = QString(version).split(QChar('.')).at(1).toInt();
|
||||||
int new_patch = QString(version).split(QChar('.')).at(2).toInt();
|
int new_patch = QString(version).split(QChar('.')).at(2).toInt();
|
||||||
if ((old_major < new_major) ||
|
if ((old_major < new_major)
|
||||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
|| ((old_major == new_major) && (old_minor < new_minor))
|
||||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
|| ((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||||
return showUpdates(version);
|
return showUpdates(version);
|
||||||
else if (showAnyway)
|
else if (showAnyway)
|
||||||
return showInfo(version);
|
return showInfo(version);
|
||||||
|
@ -31,7 +31,6 @@ class AWActions : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit AWActions(QObject *parent = nullptr);
|
explicit AWActions(QObject *parent = nullptr);
|
||||||
virtual ~AWActions();
|
virtual ~AWActions();
|
||||||
|
|
||||||
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
||||||
Q_INVOKABLE bool dropCache() const;
|
Q_INVOKABLE bool dropCache() const;
|
||||||
Q_INVOKABLE bool isDebugEnabled() const;
|
Q_INVOKABLE bool isDebugEnabled() const;
|
||||||
|
@ -39,7 +39,6 @@ AWDataAggregator::AWDataAggregator(QObject *parent)
|
|||||||
qRegisterMetaType<QHash<QString, QString>>("QHash<QString, QString>");
|
qRegisterMetaType<QHash<QString, QString>>("QHash<QString, QString>");
|
||||||
|
|
||||||
initScene();
|
initScene();
|
||||||
|
|
||||||
connect(this, SIGNAL(updateData(const QHash<QString, QString>)),
|
connect(this, SIGNAL(updateData(const QHash<QString, QString>)),
|
||||||
this, SLOT(dataUpdate(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);
|
QBuffer buffer(&byteArray);
|
||||||
source.save(&buffer, "PNG");
|
source.save(&buffer, "PNG");
|
||||||
|
|
||||||
return byteArray.isEmpty() ? QString() :
|
return byteArray.isEmpty() ? QString()
|
||||||
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
: 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"));
|
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
||||||
|
|
||||||
// background
|
// background
|
||||||
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool()
|
||||||
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
? QBrush(QColor(configuration[QString("tooltipBackground")].toString()))
|
||||||
QBrush(Qt::NoBrush));
|
: QBrush(Qt::NoBrush));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +132,8 @@ QPixmap AWDataAggregator::tooltipImage()
|
|||||||
float normX = 100.0 / static_cast<float>(data[key].count());
|
float normX = 100.0 / static_cast<float>(data[key].count());
|
||||||
float normY = 100.0 / (1.5 * boundaries[key]);
|
float normY = 100.0 / (1.5 * boundaries[key]);
|
||||||
float shift = requiredKeys.indexOf(key) * 100.0;
|
float shift = requiredKeys.indexOf(key) * 100.0;
|
||||||
if (down) shift -= 100.0;
|
if (down)
|
||||||
|
shift -= 100.0;
|
||||||
// apply pen color
|
// apply pen color
|
||||||
if (key != QString("batTooltip"))
|
if (key != QString("batTooltip"))
|
||||||
pen.setColor(QColor(configuration[QString("%1Color").arg(key)].toString()));
|
pen.setColor(QColor(configuration[QString("%1Color").arg(key)].toString()));
|
||||||
@ -151,7 +152,8 @@ QPixmap AWDataAggregator::tooltipImage()
|
|||||||
}
|
}
|
||||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
||||||
}
|
}
|
||||||
if (key == QString("downTooltip")) down = true;
|
if (key == QString("downTooltip"))
|
||||||
|
down = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolTipView->grab();
|
return toolTipView->grab();
|
||||||
@ -219,17 +221,16 @@ QString AWDataAggregator::notificationText(const QString source, const float val
|
|||||||
qCDebug(LOG_AW) << "Value" << value;
|
qCDebug(LOG_AW) << "Value" << value;
|
||||||
|
|
||||||
QString output;
|
QString output;
|
||||||
if (source == QString("batTooltip")) {
|
if (source == QString("batTooltip"))
|
||||||
output = value > 0.0 ? i18n("AC online") : i18n("AC offline");
|
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");
|
output = i18n("High CPU load");
|
||||||
} else if (source == QString("memTooltip")) {
|
else if (source == QString("memTooltip"))
|
||||||
output = i18n("High memory usage");
|
output = i18n("High memory usage");
|
||||||
} else if (source == QString("swapTooltip")) {
|
else if (source == QString("swapTooltip"))
|
||||||
output = i18n("Swap is used");
|
output = i18n("Swap is used");
|
||||||
} else if (source == QString("gpu")) {
|
else if (source == QString("gpu"))
|
||||||
output = i18n("High GPU load");
|
output = i18n("High GPU load");
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -242,9 +243,8 @@ QString AWDataAggregator::notificationText(const QString source, const QString v
|
|||||||
qCDebug(LOG_AW) << "Value" << value;
|
qCDebug(LOG_AW) << "Value" << value;
|
||||||
|
|
||||||
QString output;
|
QString output;
|
||||||
if (source == QString("netdev")) {
|
if (source == QString("netdev"))
|
||||||
output = i18n("Network device has been changed to %1", value);
|
output = i18n("Network device has been changed to %1", value);
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -288,7 +288,8 @@ void AWDataAggregator::setData(const QString source, float value, const float ex
|
|||||||
data[source].append(0.0);
|
data[source].append(0.0);
|
||||||
else if (data[source].count() > configuration[QString("tooltipNumber")].toInt())
|
else if (data[source].count() > configuration[QString("tooltipNumber")].toInt())
|
||||||
data[source].removeFirst();
|
data[source].removeFirst();
|
||||||
if (isnan(value)) value = 0.0;
|
if (isnan(value))
|
||||||
|
value = 0.0;
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
checkValue(source, value, extremum);
|
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
|
// HACK "deep copy" of data to avoid plasma crash on Data object destruction
|
||||||
QString units = data[QString("units")].toString();
|
QString units = data[QString("units")].toString();
|
||||||
// HACK workaround for time values which are stored in the different path
|
// 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));
|
emit(updateData(sourceName, value, units));
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,8 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
|||||||
allKeys.append(QString("netdev"));
|
allKeys.append(QString("netdev"));
|
||||||
// battery
|
// battery
|
||||||
allKeys.append(QString("ac"));
|
allKeys.append(QString("ac"));
|
||||||
QStringList allBatteryDevices = QDir(QString("/sys/class/power_supply"))
|
QStringList allBatteryDevices = QDir(QString("/sys/class/power_supply")).
|
||||||
.entryList(QStringList() << QString("BAT*"),
|
entryList(QStringList() << QString("BAT*"),
|
||||||
QDir::Dirs | QDir::NoDotAndDotDot,
|
QDir::Dirs | QDir::NoDotAndDotDot,
|
||||||
QDir::Name);
|
QDir::Name);
|
||||||
for (int i=allBatteryDevices.count()-1; i>=0; i--)
|
for (int i=allBatteryDevices.count()-1; i>=0; i--)
|
||||||
@ -303,7 +303,8 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
|||||||
allKeys.append(graphicalItemsKeys.at(i));
|
allKeys.append(graphicalItemsKeys.at(i));
|
||||||
|
|
||||||
// sort if required
|
// sort if required
|
||||||
if (sorted) allKeys.sort();
|
if (sorted)
|
||||||
|
allKeys.sort();
|
||||||
|
|
||||||
return allKeys.filter(QRegExp(regexp));
|
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) << "Source" << sourceName;
|
||||||
qCDebug(LOG_AW) << "Data" << value << units;
|
qCDebug(LOG_AW) << "Data" << value << units;
|
||||||
|
|
||||||
if (lock) return;
|
if (lock)
|
||||||
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
return;
|
||||||
|
if (sourceName == QString("update"))
|
||||||
|
return emit(needToBeUpdated());
|
||||||
|
|
||||||
#ifdef BUILD_FUTURE
|
#ifdef BUILD_FUTURE
|
||||||
// run concurrent data update
|
// run concurrent data update
|
||||||
@ -425,8 +428,8 @@ void AWKeys::loadKeysFromCache()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
QString fileName = QString("%1/awesomewidgets.ndx").
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
qCInfo(LOG_AW) << "Cache file" << fileName;
|
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||||
QSettings cache(fileName, QSettings::IniFormat);
|
QSettings cache(fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
@ -483,7 +486,8 @@ void AWKeys::reinitKeys()
|
|||||||
qCInfo(LOG_AW) << "Found bar" << key;
|
qCInfo(LOG_AW) << "Found bar" << key;
|
||||||
selectedKeys.append(key);
|
selectedKeys.append(key);
|
||||||
}
|
}
|
||||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No bars found";
|
if (selectedKeys.isEmpty())
|
||||||
|
qCWarning(LOG_AW) << "No bars found";
|
||||||
return selectedKeys;
|
return selectedKeys;
|
||||||
}(m_pattern);
|
}(m_pattern);
|
||||||
|
|
||||||
@ -496,7 +500,8 @@ void AWKeys::reinitKeys()
|
|||||||
qCInfo(LOG_AW) << "Found key" << key;
|
qCInfo(LOG_AW) << "Found key" << key;
|
||||||
selectedKeys.append(key);
|
selectedKeys.append(key);
|
||||||
}
|
}
|
||||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No keys found";
|
if (selectedKeys.isEmpty())
|
||||||
|
qCWarning(LOG_AW) << "No keys found";
|
||||||
return selectedKeys;
|
return selectedKeys;
|
||||||
}(m_pattern);
|
}(m_pattern);
|
||||||
|
|
||||||
@ -518,7 +523,8 @@ void AWKeys::reinitKeys()
|
|||||||
qCInfo(LOG_AW) << "Found lambda" << lambda;
|
qCInfo(LOG_AW) << "Found lambda" << lambda;
|
||||||
selectedKeys.append(lambda);
|
selectedKeys.append(lambda);
|
||||||
}
|
}
|
||||||
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No lambdas found";
|
if (selectedKeys.isEmpty())
|
||||||
|
qCWarning(LOG_AW) << "No lambdas found";
|
||||||
return selectedKeys;
|
return selectedKeys;
|
||||||
}(m_pattern);
|
}(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 type" << type;
|
||||||
qCDebug(LOG_AW) << "Key" << key;
|
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;
|
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||||
QSettings cache(fileName, QSettings::IniFormat);
|
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]$")));
|
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||||
foreach(QString dev, devices) {
|
foreach(QString dev, devices) {
|
||||||
QString device = QString("/dev/%1").arg(dev);
|
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;
|
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
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();
|
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||||
foreach(QNetworkInterface interface, rawInterfaceList) {
|
foreach(QNetworkInterface interface, rawInterfaceList) {
|
||||||
QString device = interface.name();
|
QString device = interface.name();
|
||||||
if (cachedValues.contains(device)) continue;
|
if (cachedValues.contains(device))
|
||||||
|
continue;
|
||||||
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cachedValues.contains(key)) return;
|
if (cachedValues.contains(key))
|
||||||
|
return;
|
||||||
qCInfo(LOG_AW) << "Found new key" << key << "for type" << type;
|
qCInfo(LOG_AW) << "Found new key" << key << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
||||||
}
|
}
|
||||||
@ -598,22 +608,22 @@ void AWKeys::calculateValues()
|
|||||||
// hddtot*
|
// hddtot*
|
||||||
foreach(QString device, m_devices[QString("mount")]) {
|
foreach(QString device, m_devices[QString("mount")]) {
|
||||||
int index = m_devices[QString("mount")].indexOf(device);
|
int index = m_devices[QString("mount")].indexOf(device);
|
||||||
values[QString("hddtotmb%1").arg(index)] = QString("%1").arg(
|
values[QString("hddtotmb%1").arg(index)] = QString("%1").
|
||||||
values[QString("hddfreemb%1").arg(index)].toFloat() +
|
arg(values[QString("hddfreemb%1").arg(index)].toFloat()
|
||||||
values[QString("hddmb%1").arg(index)].toFloat(), 5, 'f', 0);
|
+ values[QString("hddmb%1").arg(index)].toFloat(), 5, 'f', 0);
|
||||||
values[QString("hddtotgb%1").arg(index)] = QString("%1").arg(
|
values[QString("hddtotgb%1").arg(index)] = QString("%1").
|
||||||
values[QString("hddfreegb%1").arg(index)].toFloat() +
|
arg(values[QString("hddfreegb%1").arg(index)].toFloat()
|
||||||
values[QString("hddgb%1").arg(index)].toFloat(), 5, 'f', 1);
|
+ values[QString("hddgb%1").arg(index)].toFloat(), 5, 'f', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// memtot*
|
// memtot*
|
||||||
values[QString("memtotmb")] = QString("%1").arg(
|
values[QString("memtotmb")] = QString("%1").
|
||||||
values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
arg(values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
||||||
values[QString("memtotgb")] = QString("%1").arg(
|
values[QString("memtotgb")] = QString("%1").
|
||||||
values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(), 5, 'f', 1);
|
arg(values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(), 5, 'f', 1);
|
||||||
// mem
|
// mem
|
||||||
values[QString("mem")] = QString("%1").arg(
|
values[QString("mem")] = QString("%1").
|
||||||
100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
arg(100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
||||||
5, 'f', 1);
|
5, 'f', 1);
|
||||||
|
|
||||||
// up, down, upkb, downkb, upunits, downunits
|
// up, down, upkb, downkb, upunits, downunits
|
||||||
@ -626,13 +636,13 @@ void AWKeys::calculateValues()
|
|||||||
values[QString("upunits")] = values[QString("upunits%1").arg(netIndex)];
|
values[QString("upunits")] = values[QString("upunits%1").arg(netIndex)];
|
||||||
|
|
||||||
// swaptot*
|
// swaptot*
|
||||||
values[QString("swaptotmb")] = QString("%1").arg(
|
values[QString("swaptotmb")] = QString("%1").
|
||||||
values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
arg(values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
||||||
values[QString("swaptotgb")] = QString("%1").arg(
|
values[QString("swaptotgb")] = QString("%1").
|
||||||
values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 5, 'f', 1);
|
arg(values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 5, 'f', 1);
|
||||||
// swap
|
// swap
|
||||||
values[QString("swap")] = QString("%1").arg(
|
values[QString("swap")] = QString("%1").
|
||||||
100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
arg(100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
||||||
5, 'f', 1);
|
5, 'f', 1);
|
||||||
|
|
||||||
// lambdas
|
// lambdas
|
||||||
@ -649,8 +659,9 @@ void AWKeys::calculateValues()
|
|||||||
qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt()
|
qCWarning(LOG_AW) << "Uncaught exception at line" << result.property("lineNumber").toInt()
|
||||||
<< ":" << result.toString();
|
<< ":" << result.toString();
|
||||||
return QString();
|
return QString();
|
||||||
} else
|
} else {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
}
|
||||||
}(key);
|
}(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,8 +680,8 @@ QString AWKeys::parsePattern(QString pattern) const
|
|||||||
// main keys
|
// main keys
|
||||||
foreach(QString key, m_foundKeys)
|
foreach(QString key, m_foundKeys)
|
||||||
pattern.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
pattern.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
||||||
if ((!key.startsWith(QString("custom"))) &&
|
if ((!key.startsWith(QString("custom")))
|
||||||
(!key.startsWith(QString("weather"))))
|
&& (!key.startsWith(QString("weather"))))
|
||||||
value.replace(QString(" "), QString(" "));
|
value.replace(QString(" "), QString(" "));
|
||||||
return value;
|
return value;
|
||||||
}(key, values[key]));
|
}(key, values[key]));
|
||||||
@ -690,7 +701,8 @@ QString AWKeys::parsePattern(QString pattern) const
|
|||||||
|
|
||||||
// prepare strings
|
// prepare strings
|
||||||
pattern.replace(QString("$\\$\\"), QString("$$"));
|
pattern.replace(QString("$\\$\\"), QString("$$"));
|
||||||
if (m_wrapNewLines) pattern.replace(QString("\n"), QString("<br>"));
|
if (m_wrapNewLines)
|
||||||
|
pattern.replace(QString("\n"), QString("<br>"));
|
||||||
|
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
@ -518,22 +518,22 @@ float AWKeysAggregator::temperature(const float temp) const
|
|||||||
qCDebug(LOG_AW) << "Temperature value" << temp;
|
qCDebug(LOG_AW) << "Temperature value" << temp;
|
||||||
|
|
||||||
float converted = temp;
|
float converted = temp;
|
||||||
if (m_tempUnits == QString("Celsius"))
|
if (m_tempUnits == QString("Celsius")) {
|
||||||
;
|
} else if (m_tempUnits == QString("Fahrenheit")) {
|
||||||
else if (m_tempUnits == QString("Fahrenheit"))
|
|
||||||
converted = temp * 9.0 / 5.0 + 32.0;
|
converted = temp * 9.0 / 5.0 + 32.0;
|
||||||
else if (m_tempUnits == QString("Kelvin"))
|
} else if (m_tempUnits == QString("Kelvin")) {
|
||||||
converted = temp + 273.15;
|
converted = temp + 273.15;
|
||||||
else if (m_tempUnits == QString("Reaumur"))
|
} else if (m_tempUnits == QString("Reaumur")) {
|
||||||
converted = temp * 0.8;
|
converted = temp * 0.8;
|
||||||
else if (m_tempUnits == QString("cm^-1"))
|
} else if (m_tempUnits == QString("cm^-1")) {
|
||||||
converted = (temp + 273.15) * 0.695;
|
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;
|
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;
|
converted = (temp + 273.15) * 1.98;
|
||||||
else
|
} else {
|
||||||
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
|
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
|
||||||
|
}
|
||||||
|
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,8 @@ void AbstractExtItem::setInterval(const int _interval)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_LIB) << "Interval" << _interval;
|
qCDebug(LOG_LIB) << "Interval" << _interval;
|
||||||
if (_interval <= 0) return;
|
if (_interval <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
m_interval = _interval;
|
m_interval = _interval;
|
||||||
}
|
}
|
||||||
@ -198,8 +199,10 @@ void AbstractExtItem::readConfiguration()
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||||
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
|
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName))
|
||||||
QSettings settings(QString("%1/%2").arg(m_dirs.at(i)).arg(m_fileName), QSettings::IniFormat);
|
continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(m_dirs.at(i)).arg(m_fileName),
|
||||||
|
QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setName(settings.value(QString("Name"), m_name).toString());
|
setName(settings.value(QString("Name"), m_name).toString());
|
||||||
@ -224,7 +227,8 @@ bool AbstractExtItem::tryDelete() const
|
|||||||
|
|
||||||
// check if exists
|
// check if exists
|
||||||
foreach(QString dir, m_dirs)
|
foreach(QString dir, m_dirs)
|
||||||
if (QFile::exists(QString("%1/%2").arg(dir).arg(m_fileName))) return false;
|
if (QFile::exists(QString("%1/%2").arg(dir).arg(m_fileName)))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,10 @@ QString AbstractExtItemAggregator::getName()
|
|||||||
QString name = QInputDialog::getText(this, i18n("Enter file name"),
|
QString name = QInputDialog::getText(this, i18n("Enter file name"),
|
||||||
i18n("File name"), QLineEdit::Normal,
|
i18n("File name"), QLineEdit::Normal,
|
||||||
QString(""), &ok);
|
QString(""), &ok);
|
||||||
if ((!ok) || (name.isEmpty())) return QString("");
|
if ((!ok) || (name.isEmpty()))
|
||||||
if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
|
return QString("");
|
||||||
|
if (!name.endsWith(QString(".desktop")))
|
||||||
|
name += QString(".desktop");
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,8 @@ public:
|
|||||||
|
|
||||||
T *found = nullptr;
|
T *found = nullptr;
|
||||||
foreach(T *item, m_items) {
|
foreach(T *item, m_items) {
|
||||||
if (item->tag() != _tag) continue;
|
if (item->tag() != _tag)
|
||||||
|
continue;
|
||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -93,7 +94,8 @@ public:
|
|||||||
|
|
||||||
T *found = nullptr;
|
T *found = nullptr;
|
||||||
foreach(T *item, m_items) {
|
foreach(T *item, m_items) {
|
||||||
if (item->number() != _number) continue;
|
if (item->number() != _number)
|
||||||
|
continue;
|
||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -108,11 +110,13 @@ public:
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QListWidgetItem *widgetItem = widgetDialog->currentItem();
|
QListWidgetItem *widgetItem = widgetDialog->currentItem();
|
||||||
if (widgetItem == nullptr) return nullptr;
|
if (widgetItem == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
T *found = nullptr;
|
T *found = nullptr;
|
||||||
foreach(T *item, m_items) {
|
foreach(T *item, m_items) {
|
||||||
if (item->fileName() != widgetItem->text()) continue;
|
if (item->fileName() != widgetItem->text())
|
||||||
|
continue;
|
||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -136,7 +140,8 @@ public:
|
|||||||
QList<int> tagList;
|
QList<int> tagList;
|
||||||
foreach(T *item, m_items) tagList.append(item->number());
|
foreach(T *item, m_items) tagList.append(item->number());
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while (tagList.contains(number)) number++;
|
while (tagList.contains(number))
|
||||||
|
number++;
|
||||||
|
|
||||||
return number;
|
return number;
|
||||||
};
|
};
|
||||||
@ -152,9 +157,9 @@ private:
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
// create directory at $HOME
|
// create directory at $HOME
|
||||||
QString localDir = QString("%1/awesomewidgets/%2")
|
QString localDir = QString("%1/awesomewidgets/%2").
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
|
arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).
|
||||||
.arg(m_type);
|
arg(m_type);
|
||||||
QDir localDirectory;
|
QDir localDirectory;
|
||||||
if (localDirectory.mkpath(localDir))
|
if (localDirectory.mkpath(localDir))
|
||||||
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
||||||
@ -167,8 +172,9 @@ private:
|
|||||||
foreach(QString dir, dirs) {
|
foreach(QString dir, dirs) {
|
||||||
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
|
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
|
||||||
foreach(QString file, files) {
|
foreach(QString file, files) {
|
||||||
if (!file.endsWith(QString(".desktop"))) continue;
|
if ((!file.endsWith(QString(".desktop")))
|
||||||
if (names.contains(file)) continue;
|
|| (names.contains(file)))
|
||||||
|
continue;
|
||||||
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
||||||
names.append(file);
|
names.append(file);
|
||||||
items.append(new T(this, file, dirs));
|
items.append(new T(this, file, dirs));
|
||||||
@ -190,8 +196,11 @@ private:
|
|||||||
m_activeItems.clear();
|
m_activeItems.clear();
|
||||||
|
|
||||||
m_items = getItems();
|
m_items = getItems();
|
||||||
foreach(T *item, m_items)
|
foreach(T *item, m_items) {
|
||||||
if (item->isActive()) m_activeItems.append(item);
|
if (!item->isActive())
|
||||||
|
continue;
|
||||||
|
m_activeItems.append(item);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void repaint()
|
void repaint()
|
||||||
@ -218,7 +227,8 @@ private:
|
|||||||
T *source = itemFromWidget();
|
T *source = itemFromWidget();
|
||||||
QString fileName = getName();
|
QString fileName = getName();
|
||||||
int number = uniqNumber();
|
int number = uniqNumber();
|
||||||
if ((source == nullptr) || (fileName.isEmpty())) {
|
if ((source == nullptr)
|
||||||
|
|| (fileName.isEmpty())) {
|
||||||
qCWarning(LOG_LIB) << "Nothing to copy";
|
qCWarning(LOG_LIB) << "Nothing to copy";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ ExtQuotes::~ExtQuotes()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||||
|
this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||||
|
|
||||||
delete manager;
|
delete manager;
|
||||||
delete ui;
|
delete ui;
|
||||||
@ -77,7 +78,8 @@ ExtQuotes *ExtQuotes::copy(const QString _fileName, const int _number)
|
|||||||
qCDebug(LOG_LIB) << "File" << _fileName;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), _fileName, directories());
|
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()),
|
||||||
|
_fileName, directories());
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
@ -121,8 +123,10 @@ void ExtQuotes::readConfiguration()
|
|||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName()))
|
||||||
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString());
|
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString());
|
||||||
@ -141,7 +145,8 @@ void ExtQuotes::readConfiguration()
|
|||||||
QVariantHash ExtQuotes::run()
|
QVariantHash ExtQuotes::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
if ((!isActive()) || (isRunning)) return values;
|
if ((!isActive()) || (isRunning))
|
||||||
|
return values;
|
||||||
|
|
||||||
if (times == 1) {
|
if (times == 1) {
|
||||||
qCInfo(LOG_LIB) << "Send request";
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
@ -151,7 +156,8 @@ QVariantHash ExtQuotes::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update value
|
// update value
|
||||||
if (times >= interval()) times = 0;
|
if (times >= interval())
|
||||||
|
times = 0;
|
||||||
times++;
|
times++;
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
@ -171,7 +177,8 @@ int ExtQuotes::showConfiguration(const QVariant args)
|
|||||||
ui->spinBox_interval->setValue(interval());
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return ret;
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
setName(ui->lineEdit_name->text());
|
setName(ui->lineEdit_name->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setNumber(ui->label_numberValue->text().toInt());
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
@ -190,7 +197,8 @@ void ExtQuotes::writeConfiguration() const
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
@ -210,8 +218,8 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if ((reply->error() != QNetworkReply::NoError) ||
|
if ((reply->error() != QNetworkReply::NoError)
|
||||||
(error.error != QJsonParseError::NoError)) {
|
|| (error.error != QJsonParseError::NoError)) {
|
||||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -221,23 +229,29 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
|||||||
|
|
||||||
// ask
|
// ask
|
||||||
value = jsonQuotes[QString("Ask")].toString().toDouble();
|
value = jsonQuotes[QString("Ask")].toString().toDouble();
|
||||||
values[tag(QString("askchg"))] = values[QString("ask")].toDouble() == 0.0 ? 0.0 :
|
values[tag(QString("askchg"))] = values[QString("ask")].toDouble() == 0.0
|
||||||
value - values[QString("ask")].toDouble();
|
? 0.0
|
||||||
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toDouble() / values[QString("ask")].toDouble();
|
: value - values[QString("ask")].toDouble();
|
||||||
|
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toDouble()
|
||||||
|
/ values[QString("ask")].toDouble();
|
||||||
values[tag(QString("ask"))] = value;
|
values[tag(QString("ask"))] = value;
|
||||||
|
|
||||||
// bid
|
// bid
|
||||||
value = jsonQuotes[QString("Bid")].toString().toDouble();
|
value = jsonQuotes[QString("Bid")].toString().toDouble();
|
||||||
values[tag(QString("bidchg"))] = values[QString("bid")].toDouble() == 0.0 ? 0.0 :
|
values[tag(QString("bidchg"))] = values[QString("bid")].toDouble() == 0.0
|
||||||
value - values[QString("bid")].toDouble();
|
? 0.0
|
||||||
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toDouble() / values[QString("bid")].toDouble();
|
: value - values[QString("bid")].toDouble();
|
||||||
|
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toDouble()
|
||||||
|
/ values[QString("bid")].toDouble();
|
||||||
values[tag(QString("bid"))] = value;
|
values[tag(QString("bid"))] = value;
|
||||||
|
|
||||||
// last trade
|
// last trade
|
||||||
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toDouble();
|
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toDouble();
|
||||||
values[tag(QString("pricechg"))] = values[QString("price")].toDouble() == 0.0 ? 0.0 :
|
values[tag(QString("pricechg"))] = values[QString("price")].toDouble() == 0.0
|
||||||
value - values[QString("price")].toDouble();
|
? 0.0
|
||||||
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toDouble() / values[QString("price")].toDouble();
|
: value - values[QString("price")].toDouble();
|
||||||
|
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toDouble()
|
||||||
|
/ values[QString("price")].toDouble();
|
||||||
values[tag(QString("price"))] = value;
|
values[tag(QString("price"))] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +263,10 @@ void ExtQuotes::translate()
|
|||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
ui->label_number->setText(i18n("Tag"));
|
ui->label_number->setText(i18n("Tag"));
|
||||||
ui->label->setText(i18n("<html><head/><body><p>Use YAHOO! finance ticker to get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\"><span style=\" text-decoration: underline; color:#0057ae;\">http://finance.yahoo.com/</span></a></p></body></html>"));
|
ui->label->setText(i18n("<html><head/><body><p>Use YAHOO! finance ticker to \
|
||||||
|
get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\">\
|
||||||
|
<span style=\" text-decoration: underline; color:#0057ae;\">http://finance.yahoo.com/\
|
||||||
|
</span></a></p></body></html>"));
|
||||||
ui->label_ticker->setText(i18n("Ticker"));
|
ui->label_ticker->setText(i18n("Ticker"));
|
||||||
ui->checkBox_active->setText(i18n("Active"));
|
ui->checkBox_active->setText(i18n("Active"));
|
||||||
ui->label_interval->setText(i18n("Interval"));
|
ui->label_interval->setText(i18n("Interval"));
|
||||||
|
@ -67,7 +67,8 @@ ExtScript *ExtScript::copy(const QString _fileName, const int _number)
|
|||||||
qCDebug(LOG_LIB) << "File" << _fileName;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), _fileName, directories());
|
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()),
|
||||||
|
_fileName, directories());
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
@ -228,7 +229,8 @@ void ExtScript::updateFilter(const QString _filter, const bool _add)
|
|||||||
qCDebug(LOG_LIB) << "Should be added" << _add;
|
qCDebug(LOG_LIB) << "Should be added" << _add;
|
||||||
|
|
||||||
if (_add) {
|
if (_add) {
|
||||||
if (m_filters.contains(_filter)) return;
|
if (m_filters.contains(_filter))
|
||||||
|
return;
|
||||||
m_filters.append(_filter);
|
m_filters.append(_filter);
|
||||||
} else {
|
} else {
|
||||||
m_filters.removeOne(_filter);
|
m_filters.removeOne(_filter);
|
||||||
@ -242,7 +244,8 @@ void ExtScript::readConfiguration()
|
|||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName()))
|
||||||
|
continue;
|
||||||
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
@ -250,8 +253,8 @@ void ExtScript::readConfiguration()
|
|||||||
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
||||||
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||||
// api == 3
|
// api == 3
|
||||||
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString()
|
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString().
|
||||||
.split(QChar(','), QString::SkipEmptyParts));
|
split(QChar(','), QString::SkipEmptyParts));
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,16 +297,19 @@ void ExtScript::readJsonFilters()
|
|||||||
QVariantHash ExtScript::run()
|
QVariantHash ExtScript::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
if (!isActive()) return value;
|
if (!isActive())
|
||||||
|
return value;
|
||||||
|
|
||||||
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
QStringList cmdList;
|
QStringList cmdList;
|
||||||
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
|
if (!m_prefix.isEmpty())
|
||||||
|
cmdList.append(m_prefix);
|
||||||
cmdList.append(m_executable);
|
cmdList.append(m_executable);
|
||||||
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
|
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
|
||||||
process->start(cmdList.join(QChar(' ')));
|
process->start(cmdList.join(QChar(' ')));
|
||||||
} else if (times >= interval())
|
} else if (times >= interval()) {
|
||||||
times = 0;
|
times = 0;
|
||||||
|
}
|
||||||
times++;
|
times++;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -324,12 +330,19 @@ int ExtScript::showConfiguration(const QVariant args)
|
|||||||
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||||
ui->spinBox_interval->setValue(interval());
|
ui->spinBox_interval->setValue(interval());
|
||||||
// filters
|
// filters
|
||||||
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
|
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color"))
|
||||||
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
|
? Qt::Checked
|
||||||
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
|
: Qt::Unchecked);
|
||||||
|
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline"))
|
||||||
|
? Qt::Checked
|
||||||
|
: Qt::Unchecked);
|
||||||
|
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space"))
|
||||||
|
? Qt::Checked
|
||||||
|
: Qt::Unchecked);
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return ret;
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
setName(ui->lineEdit_name->text());
|
setName(ui->lineEdit_name->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setNumber(ui->label_numberValue->text().toInt());
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
@ -354,7 +367,8 @@ void ExtScript::writeConfiguration() const
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
@ -64,7 +64,8 @@ ExtUpgrade *ExtUpgrade::copy(const QString _fileName, const int _number)
|
|||||||
qCDebug(LOG_LIB) << "File" << _fileName;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), _fileName, directories());
|
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()),
|
||||||
|
_fileName, directories());
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
@ -145,8 +146,10 @@ void ExtUpgrade::readConfiguration()
|
|||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName()))
|
||||||
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||||
@ -168,14 +171,16 @@ void ExtUpgrade::readConfiguration()
|
|||||||
QVariantHash ExtUpgrade::run()
|
QVariantHash ExtUpgrade::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
if (!isActive()) return value;
|
if (!isActive())
|
||||||
|
return value;
|
||||||
|
|
||||||
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
QString cmd = QString("sh -c \"%1\"").arg(m_executable);
|
QString cmd = QString("sh -c \"%1\"").arg(m_executable);
|
||||||
qCInfo(LOG_LIB) << "Run cmd" << cmd;
|
qCInfo(LOG_LIB) << "Run cmd" << cmd;
|
||||||
process->start(cmd);
|
process->start(cmd);
|
||||||
} else if (times >= interval())
|
} else if (times >= interval()) {
|
||||||
times = 0;
|
times = 0;
|
||||||
|
}
|
||||||
times++;
|
times++;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -197,7 +202,8 @@ int ExtUpgrade::showConfiguration(const QVariant args)
|
|||||||
ui->spinBox_interval->setValue(interval());
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return ret;
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
setName(ui->lineEdit_name->text());
|
setName(ui->lineEdit_name->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setNumber(ui->label_numberValue->text().toInt());
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
@ -218,7 +224,8 @@ void ExtUpgrade::writeConfiguration() const
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
@ -240,9 +247,9 @@ void ExtUpgrade::updateValue()
|
|||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||||
value[tag(QString("pkgcount"))] = [this](QString output) {
|
value[tag(QString("pkgcount"))] = [this](QString output) {
|
||||||
return m_filter.isEmpty() ?
|
return m_filter.isEmpty()
|
||||||
output.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null :
|
? output.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null
|
||||||
output.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
|
: output.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
|
||||||
}(qoutput);
|
}(qoutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
|
|||||||
qCDebug(LOG_LIB) << "File" << _fileName;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), _fileName, directories());
|
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()),
|
||||||
|
_fileName, directories());
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setCity(city());
|
item->setCity(city());
|
||||||
@ -184,8 +185,10 @@ void ExtWeather::readConfiguration()
|
|||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName()))
|
||||||
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setCity(settings.value(QString("X-AW-City"), m_city).toString());
|
setCity(settings.value(QString("X-AW-City"), m_city).toString());
|
||||||
@ -235,7 +238,8 @@ void ExtWeather::readJsonMap()
|
|||||||
QVariantHash ExtWeather::run()
|
QVariantHash ExtWeather::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
if ((!isActive()) || (isRunning)) return values;
|
if ((!isActive()) || (isRunning))
|
||||||
|
return values;
|
||||||
|
|
||||||
if (times == 1) {
|
if (times == 1) {
|
||||||
qCInfo(LOG_LIB) << "Send request";
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
@ -245,7 +249,8 @@ QVariantHash ExtWeather::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update value
|
// update value
|
||||||
if (times >= interval()) times = 0;
|
if (times >= interval())
|
||||||
|
times = 0;
|
||||||
times++;
|
times++;
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
@ -268,7 +273,8 @@ int ExtWeather::showConfiguration(const QVariant args)
|
|||||||
ui->spinBox_interval->setValue(interval());
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return ret;
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
setName(ui->lineEdit_name->text());
|
setName(ui->lineEdit_name->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setNumber(ui->label_numberValue->text().toInt());
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
@ -290,7 +296,8 @@ void ExtWeather::writeConfiguration() const
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
@ -314,8 +321,8 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if ((reply->error() != QNetworkReply::NoError) ||
|
if ((reply->error() != QNetworkReply::NoError)
|
||||||
(error.error != QJsonParseError::NoError)) {
|
|| (error.error != QJsonParseError::NoError)) {
|
||||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -328,13 +335,16 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariantHash data;
|
QVariantHash data;
|
||||||
if (m_ts == 0)
|
if (m_ts == 0) {
|
||||||
data = parseSingleJson(json);
|
data = parseSingleJson(json);
|
||||||
else {
|
} else {
|
||||||
QVariantList list = json[QString("list")].toList();
|
QVariantList list = json[QString("list")].toList();
|
||||||
data = parseSingleJson(list.count() <= m_ts ? list.at(m_ts-1).toMap() : list.last().toMap());
|
data = parseSingleJson(list.count() <= m_ts
|
||||||
|
? list.at(m_ts-1).toMap()
|
||||||
|
: list.last().toMap());
|
||||||
}
|
}
|
||||||
foreach(QString key, data.keys()) values[tag(key)] = data[key];
|
foreach(QString key, data.keys())
|
||||||
|
values[tag(key)] = data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number)
|
|||||||
qCDebug(LOG_LIB) << "File" << _fileName;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()), _fileName, directories());
|
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()),
|
||||||
|
_fileName, directories());
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setActiveColor(activeColor());
|
item->setActiveColor(activeColor());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
@ -124,7 +125,8 @@ QString GraphicalItem::image(const QVariant value)
|
|||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
QBuffer buffer(&byteArray);
|
QBuffer buffer(&byteArray);
|
||||||
pixmap.save(&buffer, "PNG");
|
pixmap.save(&buffer, "PNG");
|
||||||
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").
|
||||||
|
arg(QString(byteArray.toBase64()));
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -254,9 +256,10 @@ void GraphicalItem::setBar(const QString _bar)
|
|||||||
if (!_bar.contains(QRegExp(QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")))) {
|
if (!_bar.contains(QRegExp(QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")))) {
|
||||||
qCWarning(LOG_LIB) << "Unsupported bar type" << _bar;
|
qCWarning(LOG_LIB) << "Unsupported bar type" << _bar;
|
||||||
m_bar = QString("none");
|
m_bar = QString("none");
|
||||||
} else
|
} else {
|
||||||
m_bar = _bar;
|
m_bar = _bar;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setActiveColor(const QString _color)
|
void GraphicalItem::setActiveColor(const QString _color)
|
||||||
@ -327,7 +330,8 @@ void GraphicalItem::setHeight(const int _height)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_LIB) << "Height" << _height;
|
qCDebug(LOG_LIB) << "Height" << _height;
|
||||||
if (_height <= 0) return;
|
if (_height <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
m_height = _height;
|
m_height = _height;
|
||||||
}
|
}
|
||||||
@ -337,7 +341,8 @@ void GraphicalItem::setWidth(const int _width)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_LIB) << "Width" << _width;
|
qCDebug(LOG_LIB) << "Width" << _width;
|
||||||
if (_width <= 0) return;
|
if (_width <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
m_width = _width;
|
m_width = _width;
|
||||||
}
|
}
|
||||||
@ -349,8 +354,10 @@ void GraphicalItem::readConfiguration()
|
|||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName()))
|
||||||
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||||
@ -361,7 +368,8 @@ void GraphicalItem::readConfiguration()
|
|||||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||||
// api == 2
|
// api == 2
|
||||||
if (apiVersion() < 2) setNumber(bar().remove(QString("bar")).toInt());
|
if (apiVersion() < 2)
|
||||||
|
setNumber(bar().remove(QString("bar")).toInt());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,8 +410,8 @@ int GraphicalItem::showConfiguration(const QVariant args)
|
|||||||
ui->spinBox_width->setValue(m_width);
|
ui->spinBox_width->setValue(m_width);
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return ret;
|
if (ret != 1)
|
||||||
|
return ret;
|
||||||
setName(ui->label_nameValue->text());
|
setName(ui->label_nameValue->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setApiVersion(AWGIAPI);
|
setApiVersion(AWGIAPI);
|
||||||
@ -425,7 +433,8 @@ void GraphicalItem::writeConfiguration() const
|
|||||||
qCDebug(LOG_LIB);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()),
|
||||||
|
QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
@ -449,7 +458,8 @@ void GraphicalItem::changeColor()
|
|||||||
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
||||||
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
||||||
QColorDialog::ShowAlphaChannel);
|
QColorDialog::ShowAlphaChannel);
|
||||||
if (!newColor.isValid()) return;
|
if (!newColor.isValid())
|
||||||
|
return;
|
||||||
qCInfo(LOG_LIB) << "Selected color" << newColor;
|
qCInfo(LOG_LIB) << "Selected color" << newColor;
|
||||||
|
|
||||||
QStringList colorText;
|
QStringList colorText;
|
||||||
|
Loading…
Reference in New Issue
Block a user