Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/wizard/style.qss6
-rw-r--r--src/common/utility.cpp23
-rw-r--r--src/common/utility.h5
-rw-r--r--src/gui/newwizard/setupwizardwindow.cpp10
4 files changed, 35 insertions, 9 deletions
diff --git a/resources/wizard/style.qss b/resources/wizard/style.qss
index a8d2cc5cb..ad705c517 100644
--- a/resources/wizard/style.qss
+++ b/resources/wizard/style.qss
@@ -8,7 +8,7 @@
the navigation/pagination part is located outside the content widget, so it won't be affected by this stylesheet
especially since we prefix all rules with #contentWidget
- note that @...@ are variables replaced by our own code when loading the stylesheet
+ note that @\{...\} are variables replaced by our own code when loading the stylesheet
they represent theme-specific colors
*/
@@ -18,7 +18,7 @@
*/
#contentWidget
{
- background-color: @WIZARD_BACKGROUND_COLOR@;
+ background-color: @{WIZARD_BACKGROUND_COLOR};
}
/* selectively set the font color for most labels and one group box title */
@@ -35,7 +35,7 @@
#contentWidget #passwordLabel,
#contentWidget #advancedConfigGroupBox::title
{
- color: @WIZARD_FONT_COLOR@;
+ color: @{WIZARD_FONT_COLOR};
}
/*
diff --git a/src/common/utility.cpp b/src/common/utility.cpp
index 0b9bb244a..444e31284 100644
--- a/src/common/utility.cpp
+++ b/src/common/utility.cpp
@@ -32,6 +32,7 @@
#include <QObject>
#include <QProcess>
#include <QRandomGenerator>
+#include <QRegularExpression>
#include <QSettings>
#include <QStandardPaths>
#include <QSysInfo>
@@ -606,4 +607,26 @@ QDebug &operator<<(QDebug &debug, nanoseconds in)
<< ms.count() << "ms)";
}
+QString Utility::renderTemplate(QString templ, const QMap<QString, QString> &values)
+{
+ static const QRegularExpression pattern(QStringLiteral("@{([^{}]+)}"));
+ const auto replace = [&templ, &values](QRegularExpressionMatchIterator it) {
+ while (it.hasNext()) {
+ const auto match = it.next();
+ Q_ASSERT(match.lastCapturedIndex() == 1);
+ Q_ASSERT(values.contains(match.captured(1)));
+ templ.replace(match.captured(0), values.value(match.captured(1)));
+ }
+ };
+
+ auto matches = pattern.globalMatch(templ);
+ do {
+ replace(matches);
+ // the placeholder can again contain a placeholder
+ matches = pattern.globalMatch(templ);
+ } while (matches.hasNext());
+
+ return templ;
+}
+
} // namespace OCC
diff --git a/src/common/utility.h b/src/common/utility.h
index ea715f5ef..753b674d6 100644
--- a/src/common/utility.h
+++ b/src/common/utility.h
@@ -358,6 +358,11 @@ OCSYNC_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcUtility)
Q_UNREACHABLE();
}
+ /**
+ * Replace all occurances of @{} values in template with the values from values
+ */
+ OCSYNC_EXPORT QString renderTemplate(QString templ, const QMap<QString, QString> &values);
+
#ifdef Q_OS_LINUX
OCSYNC_EXPORT QString appImageLocation();
OCSYNC_EXPORT bool runningInAppImage();
diff --git a/src/gui/newwizard/setupwizardwindow.cpp b/src/gui/newwizard/setupwizardwindow.cpp
index 68d4a941c..179665c26 100644
--- a/src/gui/newwizard/setupwizardwindow.cpp
+++ b/src/gui/newwizard/setupwizardwindow.cpp
@@ -17,12 +17,10 @@ using namespace OCC;
QString replaceCssColors(QString stylesheet)
{
- QString rv = stylesheet;
-
- rv = stylesheet.replace(QStringLiteral("@WIZARD_BACKGROUND_COLOR@"), Theme::instance()->wizardHeaderBackgroundColor().name());
- rv = stylesheet.replace(QStringLiteral("@WIZARD_FONT_COLOR@"), Theme::instance()->wizardHeaderTitleColor().name());
-
- return rv;
+ return Utility::renderTemplate(stylesheet, {
+ { QStringLiteral("WIZARD_BACKGROUND_COLOR"), Theme::instance()->wizardHeaderBackgroundColor().name() }, //
+ { QStringLiteral("WIZARD_FONT_COLOR"), Theme::instance()->wizardHeaderTitleColor().name() } //
+ });
}
}