From b9d287021a0f9245d16688703524078749c3979f Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Sun, 16 Jun 2024 21:22:58 +1000 Subject: [PATCH] Add quoteString to Contemporary QML attached property --- .../CoreStyles/contemporarystyle.cpp | 8 + .../CoreStyles/contemporarystyle.h | 3 + playground/translations/en_US.ts | 182 +++++++++--------- 3 files changed, 102 insertions(+), 91 deletions(-) diff --git a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.cpp b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.cpp index 65328bd..2cbfb8a 100644 --- a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.cpp +++ b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.cpp @@ -243,6 +243,14 @@ void ContemporaryStyle::setColorTheme(ColorTheme colorTheme) { emit colorThemeChanged(); } +QString ContemporaryStyle::quoteString(QString string) { + return QLocale().quoteString(string); +} + +QString ContemporaryStyle::quoteString(QString locale, QString string) { + return QLocale(locale).quoteString(string); +} + QColor ContemporaryStyle::readColor(const QJsonValue& jsonColor) { QJsonArray colorArray = jsonColor.toArray(); return {colorArray[0].toInt(), colorArray[1].toInt(), colorArray[2].toInt(), colorArray.size() == 4 ? colorArray[3].toInt() : 255}; diff --git a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.h b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.h index a26262a..b846903 100644 --- a/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.h +++ b/controls/com/vicr123/Contemporary/CoreStyles/contemporarystyle.h @@ -78,6 +78,9 @@ class ContemporaryStyle : public QObject { // ReSharper disable once CppRedundantQualifier Q_INVOKABLE void setColorTheme(ContemporaryStyle::ColorTheme colorTheme); + Q_INVOKABLE QString quoteString(QString string); + Q_INVOKABLE QString quoteString(QString locale, QString string); + signals: void accentChanged(); void backgroundChanged(); diff --git a/playground/translations/en_US.ts b/playground/translations/en_US.ts index 059b183..eaea9f8 100644 --- a/playground/translations/en_US.ts +++ b/playground/translations/en_US.ts @@ -5,97 +5,97 @@ Buttons - + Normal Buttons - + Default Button - + Disabled Button - + Checkable Button - + Flat Buttons - + Flat Default Button - + Flat Disabled Button - + Flat Checkable Button - + Popover - + Popover Contents - + This is the contents of the popover. - + Open Popover 2 - + Erase this disk? - + Erase all data from all disks? - + Erase - + Cancel @@ -106,9 +106,9 @@ - - - + + + Off @@ -116,9 +116,9 @@ - - - + + + On @@ -126,27 +126,27 @@ - - - + + + Disabled Off - + Radio Buttons - + Switches - + Checkboxes @@ -154,21 +154,21 @@ - - - + + + Disabled On - + Indeterminate - + Disabled Indeterminate @@ -177,19 +177,19 @@ ComboBoxPage - + Combo Boxes - + Editable Combo Boxes - + Flat Combo Boxes @@ -198,55 +198,55 @@ DialogBoxes - + Combo Boxes - + Click on a button to open a dialog box. - + Informational Dialog Box - + Oh no! Goblins! - + Shut down the nuclear reactor! - + Low Battery - + Message Box Title - + This is the main text of the message box. It conveys the primary information or message that needs to be communicated to the user. - + After battling through hordes of goblins, you finally stand before the throne of the Goblin King himself. The grotesque creature eyes you with contempt from his towering seat. "So, you're the meddlesome adventurer who's been causing trouble in my kingdom," he growls. "I'll give you one chance to save your miserable hide. Swear fealty to me, and I'll let you live as my servant. Refuse, and you'll spend the rest of your days in the darkest pit of my dungeons!" @@ -256,19 +256,19 @@ The Goblin King leans forward, his putrid breath washing over you as he awaits y - + Swear Fealty - + Danger! Extremely Hazardous Operation - + You are attempting to perform an extremely hazardous operation that could result in catastrophic consequences if not executed with extreme caution. This operation has the potential to cause: @@ -282,43 +282,43 @@ Only proceed if you are an expert user and fully understand the risks involved. - + This is the informative text displayed in grey below the main text. It provides additional context and warnings about the dangerous operation. Attempting this operation without proper expertise and precautions could lead to permanent and devastating damage to your systems and data. Proceed at your own risk. - + Warning! - + Your battery is low! - + Never tell me again - + You checked the box - + You didn't check the box - + Refuse @@ -327,91 +327,91 @@ Only proceed if you are an expert user and fully understand the risks involved. Main - + Contemporary Playground - + &File - + &Quit - - + + Follow System - + &Help - + &About - + Add Surface - + Theme - - + + Light - + &Theme - - + + Dark - + Components - + Patterns - + Extra Surface @@ -420,7 +420,7 @@ Only proceed if you are an expert user and fully understand the risks involved. Progress - + Progress Bars @@ -429,67 +429,67 @@ Only proceed if you are an expert user and fully understand the risks involved. Root - + Components - + Buttons - + Checkboxes and Radio Buttons - + Text Input - + Combo Box - + Progress - + Ranges - + Tumbler - + Scrollable - + Patterns - + Dialog Boxes @@ -498,33 +498,33 @@ Only proceed if you are an expert user and fully understand the risks involved. TextInput - + Text Fields - + Text Field - - + + Disabled - + Text Areas - + Text Area @@ -533,7 +533,7 @@ Only proceed if you are an expert user and fully understand the risks involved. TumblerPage - + Tumblers