Move some helper functions to Helpers.hpp
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user