mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Move some helper functions to Helpers.hpp
This commit is contained in:
parent
8bcc9c487b
commit
3fc91bded5
3 changed files with 45 additions and 36 deletions
|
@ -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 {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ExternalToolsPage.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
|
||||
#include <QGroupBox>
|
||||
|
@ -9,14 +10,6 @@
|
|||
"Choose", "Source", "High", "Medium", "Low", "Audio only"
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
QString createLink(const QString &url, const QString &name)
|
||||
{
|
||||
return QString("<a href=\"" + url +
|
||||
"\"><span style=\"color: white;\">" + name +
|
||||
"</span></a>");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ExternalToolsPage::ExternalToolsPage()
|
||||
: SettingsPage("External tools", "")
|
||||
|
@ -39,8 +32,8 @@ ExternalToolsPage::ExternalToolsPage()
|
|||
description->setStyleSheet("color: #bbb");
|
||||
|
||||
auto links = new QLabel(
|
||||
createLink("https://streamlink.github.io/", "Website") + " " +
|
||||
createLink(
|
||||
createNamedLink("https://streamlink.github.io/", "Website") + " " +
|
||||
createNamedLink(
|
||||
"https://github.com/streamlink/streamlink/releases/latest",
|
||||
"Download"));
|
||||
links->setTextFormat(Qt::RichText);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
||||
#include "singletons/Logging.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "widgets/helper/EditableModelView.hpp"
|
||||
|
||||
|
@ -25,18 +26,6 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
inline 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>");
|
||||
}
|
||||
|
||||
qint64 dirSize(QString dirPath)
|
||||
{
|
||||
qint64 size = 0;
|
||||
|
@ -110,20 +99,10 @@ ModerationPage::ModerationPage()
|
|||
pathOriginal = logPath;
|
||||
}
|
||||
|
||||
QString pathShortened;
|
||||
|
||||
if (pathOriginal.size() > 50) {
|
||||
pathShortened = pathOriginal;
|
||||
pathShortened.resize(50);
|
||||
pathShortened += "...";
|
||||
} else {
|
||||
pathShortened = pathOriginal;
|
||||
}
|
||||
|
||||
pathShortened = "Logs saved at <a href=\"file:///" +
|
||||
pathOriginal +
|
||||
QString pathShortened =
|
||||
"Logs saved at <a href=\"file:///" + pathOriginal +
|
||||
"\"><span style=\"color: white;\">" +
|
||||
pathShortened + "</span></a>";
|
||||
shortenString(pathOriginal, 50) + "</span></a>";
|
||||
|
||||
logsPathLabel->setText(pathShortened);
|
||||
logsPathLabel->setToolTip(pathOriginal);
|
||||
|
|
Loading…
Reference in a new issue