new settings page

This commit is contained in:
fourtf
2018-10-31 19:45:51 +01:00
parent a0b6e4bb76
commit 3c3be99177
23 changed files with 651 additions and 101 deletions
+33
View File
@@ -0,0 +1,33 @@
#include "FuzzyConvert.hpp"
#include <QRegularExpression>
namespace chatterino {
int fuzzyToInt(const QString &str, int default_)
{
static auto intFinder = QRegularExpression("[0-9]+");
auto match = intFinder.match(str);
if (match.hasMatch())
{
return match.captured().toInt();
}
return default_;
}
float fuzzyToFloat(const QString &str, float default_)
{
static auto floatFinder = QRegularExpression("[0-9]+(\\.[0-9]+)?");
auto match = floatFinder.match(str);
if (match.hasMatch())
{
return match.captured().toFloat();
}
return default_;
}
} // namespace chatterino
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#include <QString>
namespace chatterino {
int fuzzyToInt(const QString &str, int default_);
float fuzzyToFloat(const QString &str, float default_);
} // namespace chatterino
+10 -25
View File
@@ -19,43 +19,28 @@ static QString CreateUUID()
static QString createLink(const QString &url, bool file = false)
{
if (file)
{
return QString("<a href=\"file:///" + url +
"\"><span style=\"color: white;\">" + url +
"</span></a>");
}
return QString("<a href=\"" + url + "\"><span style=\"color: white;\">" +
url + "</span></a>");
return QString("<a href=\"") + (file ? "file:///" : "") + url + "\">" +
url + "</a>";
}
static QString createNamedLink(const QString &url, const QString &name,
bool file = false)
{
if (file)
{
return QString("<a href=\"file:///" + url +
"\"><span style=\"color: white;\">" + name +
"</span></a>");
}
return QString("<a href=\"" + url + "\"><span style=\"color: white;\">" +
name + "</span></a>");
return QString("<a href=\"") + (file ? "file:///" : "") + url + "\">" +
name + "</a>";
}
static QString shortenString(const QString &str, unsigned maxWidth = 50)
{
if (str.size() <= maxWidth)
auto shortened = QString(str);
if (str.size() > int(maxWidth))
{
return str;
shortened.resize(int(maxWidth));
shortened += "...";
}
QString shortenedStr = str;
shortenedStr.resize(47);
shortenedStr += "...";
return shortenedStr;
return shortened;
}
} // namespace chatterino
+7
View File
@@ -93,6 +93,13 @@ public:
return *this;
}
LayoutCreator<T> withoutSpacing()
{
this->item_->setSpacing(0);
return *this;
}
template <typename Q = T,
typename std::enable_if<std::is_base_of<QWidget, Q>::value,
int>::type = 0>