mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
do not replace space to nbsp in some cases (#143)
This commit is contained in:
parent
0f19bce80d
commit
e525cb4742
@ -38,7 +38,7 @@ for more details. To avoid manual labor there is automatic cmake target named
|
|||||||
* `Q_PROPERTY` macro is allowed and recommended for QObject based classes.
|
* `Q_PROPERTY` macro is allowed and recommended for QObject based classes.
|
||||||
* Qt macros (e.g. `signals`, `slots`, `Q_OBJECT`, etc) are allowed. In other hand
|
* Qt macros (e.g. `signals`, `slots`, `Q_OBJECT`, etc) are allowed. In other hand
|
||||||
`Q_FOREACH` (`foreach`) is not allowed use `for (auto &foo : bar)` instead.
|
`Q_FOREACH` (`foreach`) is not allowed use `for (auto &foo : bar)` instead.
|
||||||
* Current project standard is **C++11**.
|
* Current project standard is **C++17**.
|
||||||
* Do not use C-like code:
|
* Do not use C-like code:
|
||||||
* C-like style iteration if possible. Use `for (auto &foo : bar)` and
|
* C-like style iteration if possible. Use `for (auto &foo : bar)` and
|
||||||
`std::for_each` instead if possible. It is also recommended to use iterators.
|
`std::for_each` instead if possible. It is also recommended to use iterators.
|
||||||
|
@ -39,6 +39,7 @@ Optional dependencies
|
|||||||
* hddtemp
|
* hddtemp
|
||||||
* smartmontools
|
* smartmontools
|
||||||
* music player (mpd or MPRIS supported)
|
* music player (mpd or MPRIS supported)
|
||||||
|
* wireless_tools
|
||||||
|
|
||||||
Make dependencies
|
Make dependencies
|
||||||
-----------------
|
-----------------
|
||||||
|
@ -58,6 +58,13 @@ QStringList AWAbstractPairHelper::values() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSet<QString> AWAbstractPairHelper::valuesSet() const
|
||||||
|
{
|
||||||
|
auto values = m_pairs.values();
|
||||||
|
return QSet(values.cbegin(), values.cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWAbstractPairHelper::initItems()
|
void AWAbstractPairHelper::initItems()
|
||||||
{
|
{
|
||||||
m_pairs.clear();
|
m_pairs.clear();
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
QHash<QString, QString> pairs() const;
|
QHash<QString, QString> pairs() const;
|
||||||
QStringList values() const;
|
QStringList values() const;
|
||||||
|
QSet<QString> valuesSet() const;
|
||||||
// read-write methods
|
// read-write methods
|
||||||
virtual void initItems();
|
virtual void initItems();
|
||||||
virtual bool writeItems(const QHash<QString, QString> &_configuration) const;
|
virtual bool writeItems(const QHash<QString, QString> &_configuration) const;
|
||||||
|
@ -46,13 +46,13 @@ QString AWCustomKeysHelper::source(const QString &_key) const
|
|||||||
|
|
||||||
QStringList AWCustomKeysHelper::sources() const
|
QStringList AWCustomKeysHelper::sources() const
|
||||||
{
|
{
|
||||||
return QSet<QString>::fromList(values()).toList();
|
return valuesSet().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWCustomKeysHelper::refinedSources() const
|
QStringList AWCustomKeysHelper::refinedSources() const
|
||||||
{
|
{
|
||||||
auto allSources = QSet<QString>::fromList(pairs().values());
|
auto allSources = valuesSet();
|
||||||
QSet<QString> output;
|
QSet<QString> output;
|
||||||
|
|
||||||
while (output != allSources) {
|
while (output != allSources) {
|
||||||
@ -62,7 +62,7 @@ QStringList AWCustomKeysHelper::refinedSources() const
|
|||||||
allSources = output;
|
allSources = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toList();
|
return output.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
<< _tooltip;
|
<< _tooltip;
|
||||||
|
|
||||||
// initial copy
|
// initial copy
|
||||||
QSet<QString> used = QSet<QString>::fromList(_keys);
|
QSet<QString> used(_keys.cbegin(), _keys.cend());
|
||||||
used.unite(QSet<QString>::fromList(_bars));
|
used.unite(QSet(_bars.cbegin(), _bars.cend()));
|
||||||
used.unite(QSet<QString>::fromList(_userKeys));
|
used.unite(QSet(_userKeys.cbegin(), _userKeys.cend()));
|
||||||
// insert keys from tooltip
|
// insert keys from tooltip
|
||||||
for (auto &key : _tooltip.keys()) {
|
for (auto &key : _tooltip.keys()) {
|
||||||
if ((key.endsWith("Tooltip")) && (_tooltip[key].toBool())) {
|
if ((key.endsWith("Tooltip")) && (_tooltip[key].toBool())) {
|
||||||
@ -155,7 +155,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
|
|||||||
if (used.isEmpty())
|
if (used.isEmpty())
|
||||||
used << "dummy";
|
used << "dummy";
|
||||||
|
|
||||||
return used.toList();
|
return used.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ QString AWKeys::valueByKey(const QString &_key) const
|
|||||||
|
|
||||||
QString trueKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key;
|
QString trueKey = _key.startsWith("bar") ? m_keyOperator->infoByKey(_key) : _key;
|
||||||
|
|
||||||
return m_aggregator->formatter(m_values[trueKey], trueKey);
|
return m_aggregator->formatter(m_values[trueKey], trueKey, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ QString AWKeys::parsePattern(QString _pattern) const
|
|||||||
|
|
||||||
// main keys
|
// main keys
|
||||||
for (auto &key : m_foundKeys)
|
for (auto &key : m_foundKeys)
|
||||||
_pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key));
|
_pattern.replace(QString("$%1").arg(key), m_aggregator->formatter(m_values[key], key, true));
|
||||||
|
|
||||||
// bars
|
// bars
|
||||||
for (auto &bar : m_foundBars) {
|
for (auto &bar : m_foundBars) {
|
||||||
|
@ -55,7 +55,7 @@ void AWKeysAggregator::initFormatters()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key) const
|
QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Data" << _data << "for key" << _key;
|
qCDebug(LOG_AW) << "Data" << _data << "for key" << _key;
|
||||||
|
|
||||||
@ -162,7 +162,8 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// replace spaces to non-breakable ones
|
// replace spaces to non-breakable ones
|
||||||
if (!_key.startsWith("custom") && (!_key.startsWith("weather")))
|
replaceSpace &= (!_key.startsWith("custom") && (!_key.startsWith("weather")));
|
||||||
|
if (replaceSpace)
|
||||||
output.replace(" ", " ");
|
output.replace(" ", " ");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
~AWKeysAggregator() override;
|
~AWKeysAggregator() override;
|
||||||
void initFormatters();
|
void initFormatters();
|
||||||
// get methods
|
// get methods
|
||||||
QString formatter(const QVariant &_data, const QString &_key) const;
|
QString formatter(const QVariant &_data, const QString &_key, bool replaceSpace) const;
|
||||||
QStringList keysFromSource(const QString &_source) const;
|
QStringList keysFromSource(const QString &_source) const;
|
||||||
// set methods
|
// set methods
|
||||||
void setAcOffline(const QString &_inactive);
|
void setAcOffline(const QString &_inactive);
|
||||||
|
@ -36,7 +36,7 @@ QString AWPatternFunctions::expandLambdas(QString _code, AWKeysAggregator *_aggr
|
|||||||
// parsed values
|
// parsed values
|
||||||
for (auto &lambdaKey : _usedKeys)
|
for (auto &lambdaKey : _usedKeys)
|
||||||
_code.replace(QString("$%1").arg(lambdaKey),
|
_code.replace(QString("$%1").arg(lambdaKey),
|
||||||
_aggregator->formatter(_metadata[lambdaKey], lambdaKey));
|
_aggregator->formatter(_metadata[lambdaKey], lambdaKey, false));
|
||||||
qCInfo(LOG_AW) << "Expression" << _code;
|
qCInfo(LOG_AW) << "Expression" << _code;
|
||||||
QJSValue result = engine.evaluate(_code);
|
QJSValue result = engine.evaluate(_code);
|
||||||
if (result.isError()) {
|
if (result.isError()) {
|
||||||
|
@ -17,7 +17,7 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# some flags
|
# some flags
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# verbose output for debug builds
|
# verbose output for debug builds
|
||||||
|
@ -51,7 +51,7 @@ void TestAWTelemetryHandler::test_get()
|
|||||||
QStringList output = plugin->get(telemetryGroup);
|
QStringList output = plugin->get(telemetryGroup);
|
||||||
|
|
||||||
QVERIFY(!output.isEmpty());
|
QVERIFY(!output.isEmpty());
|
||||||
QCOMPARE(QSet<QString>::fromList(output).count(), output.count());
|
QCOMPARE(QSet<QString>(output.cbegin(), output.cend()).count(), output.count());
|
||||||
QVERIFY(output.contains(telemetryData));
|
QVERIFY(output.contains(telemetryData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user