diff options
| author | 2018-08-26 16:23:12 +0800 | |
|---|---|---|
| committer | 2018-10-06 15:43:49 +0200 | |
| commit | 690f326613998ea9cc0737c2bef99d1ba2cb911c (patch) | |
| tree | d17f178e7924e4ffb0d5b96e148490aa758289b6 /src/common/param_package.cpp | |
| parent | Merge pull request #1449 from lioncash/link (diff) | |
| download | yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.gz yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.xz yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.zip | |
citra_qt/configuration: misc input tab improvements
* Added a context menu on the buttons including Clear & Restore Default
* Allow clearing (unsetting) inputs. Added a Clear All button
* Allow restoring a single input to default (instead of all)
Diffstat (limited to 'src/common/param_package.cpp')
| -rw-r--r-- | src/common/param_package.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index 9526ca0c6..b916b4866 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -20,7 +20,15 @@ constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0"; | |||
| 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; | 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; |
| 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; | 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; |
| 22 | 22 | ||
| 23 | /// A placeholder for empty param packages to avoid empty strings | ||
| 24 | /// (they may be recognized as "not set" by some frontend libraries like qt) | ||
| 25 | constexpr char EMPTY_PLACEHOLDER[] = "[empty]"; | ||
| 26 | |||
| 23 | ParamPackage::ParamPackage(const std::string& serialized) { | 27 | ParamPackage::ParamPackage(const std::string& serialized) { |
| 28 | if (serialized == EMPTY_PLACEHOLDER) { | ||
| 29 | return; | ||
| 30 | } | ||
| 31 | |||
| 24 | std::vector<std::string> pairs; | 32 | std::vector<std::string> pairs; |
| 25 | Common::SplitString(serialized, PARAM_SEPARATOR, pairs); | 33 | Common::SplitString(serialized, PARAM_SEPARATOR, pairs); |
| 26 | 34 | ||
| @@ -46,7 +54,7 @@ ParamPackage::ParamPackage(std::initializer_list<DataType::value_type> list) : d | |||
| 46 | 54 | ||
| 47 | std::string ParamPackage::Serialize() const { | 55 | std::string ParamPackage::Serialize() const { |
| 48 | if (data.empty()) | 56 | if (data.empty()) |
| 49 | return ""; | 57 | return EMPTY_PLACEHOLDER; |
| 50 | 58 | ||
| 51 | std::string result; | 59 | std::string result; |
| 52 | 60 | ||
| @@ -120,4 +128,12 @@ bool ParamPackage::Has(const std::string& key) const { | |||
| 120 | return data.find(key) != data.end(); | 128 | return data.find(key) != data.end(); |
| 121 | } | 129 | } |
| 122 | 130 | ||
| 131 | void ParamPackage::Erase(const std::string& key) { | ||
| 132 | data.erase(key); | ||
| 133 | } | ||
| 134 | |||
| 135 | void ParamPackage::Clear() { | ||
| 136 | data.clear(); | ||
| 137 | } | ||
| 138 | |||
| 123 | } // namespace Common | 139 | } // namespace Common |