Mercurial > minori
comparison src/core/strings.cc @ 101:c537996cf67b
*: multitude of config changes
1. theme is now configurable from the settings menu
(but you have to restart for it to apply)
2. config is now stored in an INI file, with no method of
conversion from json (this repo is private-ish anyway)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 03 Nov 2023 14:06:02 -0400 |
parents | f5940a575d83 |
children | b315f3759c56 |
comparison
equal
deleted
inserted
replaced
100:f5940a575d83 | 101:c537996cf67b |
---|---|
1 /** | 1 /** |
2 * strings.cpp: Useful functions for manipulating strings | 2 * strings.cpp: Useful functions for manipulating strings |
3 **/ | 3 **/ |
4 #include "core/strings.h" | 4 #include "core/strings.h" |
5 #include <QByteArray> | 5 #include <QByteArray> |
6 #include <QDebug> | |
6 #include <QString> | 7 #include <QString> |
7 #include <QLocale> | 8 #include <QLocale> |
8 #include <algorithm> | 9 #include <algorithm> |
9 #include <cctype> | 10 #include <cctype> |
10 #include <codecvt> | 11 #include <codecvt> |
131 | 132 |
132 QString ToQString(const std::wstring& wstring) { | 133 QString ToQString(const std::wstring& wstring) { |
133 return QString::fromWCharArray(wstring.c_str(), wstring.length()); | 134 return QString::fromWCharArray(wstring.c_str(), wstring.length()); |
134 } | 135 } |
135 | 136 |
137 int ToInt(const std::string& str, int def) { | |
138 int tmp = 0; | |
139 try { | |
140 tmp = std::stoi(str); | |
141 } catch (std::invalid_argument const& ex) { | |
142 qDebug() << "Failed to parse int from std::string: no number found in " << ToQString(str) << " defaulting to " << def; | |
143 tmp = def; | |
144 } | |
145 return tmp; | |
146 } | |
147 | |
136 } // namespace Strings | 148 } // namespace Strings |