Move some helper functions to Helpers.hpp

This commit is contained in:
Rasmus Karlsson
2018-08-19 16:18:07 +02:00
parent 8bcc9c487b
commit 3fc91bded5
3 changed files with 45 additions and 36 deletions
+37
View File
@@ -17,6 +17,43 @@ static QString CreateUUID()
return uuid.toString();
}
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>");
}
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>");
}
static QString shortenString(const QString &str, unsigned maxWidth = 50)
{
if (str.size() <= maxWidth) {
return str;
}
QString shortenedStr = str;
shortenedStr.resize(47);
shortenedStr += "...";
return shortenedStr;
}
} // namespace chatterino
namespace fmt {