Initial support of templates and so on (#71)

* Initial syntax is the following:

    * $template{{ some JS code here }} - simple template based on JS
      code inside. It works the same as lambda functions, but calculates
      only once.
    * aw_count(regex) - keys count found for given regex
    * aw_keys(regex, [separator]) - keys found for given regex and
      joined by using given separator
    * aw_names(regex, [separator]) - key names found for given regex and
      joined by using given separator (the same as previous but w\o $)

  The template and function syntax may be changed before release.

* replace `foreach` to `for (auto foo : bar)` and update CONTRIBUTING.md
  accordingly
This commit is contained in:
2016-01-30 00:07:47 +07:00
parent fba58c27e8
commit 1c78e0d779
23 changed files with 224 additions and 106 deletions

View File

@ -42,7 +42,7 @@ DPAdds::DPAdds(QObject *parent)
{
qSetMessagePattern(LOG_FORMAT);
qCDebug(LOG_DP) << __PRETTY_FUNCTION__;
foreach (const QString metadata, getBuildData())
for (auto metadata : getBuildData())
qCDebug(LOG_DP) << metadata;
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this,
@ -137,7 +137,7 @@ QString DPAdds::toolTipImage(const int desktop) const
QPen pen = QPen();
pen.setWidthF(2.0 * info.desktop.width() / 400.0);
pen.setColor(QColor(m_tooltipColor));
foreach (WindowData data, info.windowsData) {
for (auto data : info.windowsData) {
QRect rect = data.rect;
toolTipScene->addLine(rect.left() + margin, rect.bottom() + margin,
rect.left() + margin, rect.top() + margin,
@ -196,7 +196,7 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop) const
QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\"));
foreach (QString key, dictKeys())
for (auto key : dictKeys())
parsed.replace(QString("$%1").arg(key), valueByKey(key, desktop));
parsed.replace(QString("$\\$\\"), QString("$$"));
@ -363,7 +363,7 @@ DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) const
DesktopWindowsInfo info;
info.desktop = KWindowSystem::workArea(desktop);
foreach (WId id, KWindowSystem::windows()) {
for (auto id : KWindowSystem::windows()) {
KWindowInfo winInfo = KWindowInfo(
id, NET::Property::WMDesktop | NET::Property::WMGeometry
| NET::Property::WMState | NET::Property::WMWindowType