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();
|
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 chatterino
|
||||||
|
|
||||||
namespace fmt {
|
namespace fmt {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ExternalToolsPage.hpp"
|
#include "ExternalToolsPage.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -9,14 +10,6 @@
|
||||||
"Choose", "Source", "High", "Medium", "Low", "Audio only"
|
"Choose", "Source", "High", "Medium", "Low", "Audio only"
|
||||||
|
|
||||||
namespace chatterino {
|
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()
|
ExternalToolsPage::ExternalToolsPage()
|
||||||
: SettingsPage("External tools", "")
|
: SettingsPage("External tools", "")
|
||||||
|
@ -39,8 +32,8 @@ ExternalToolsPage::ExternalToolsPage()
|
||||||
description->setStyleSheet("color: #bbb");
|
description->setStyleSheet("color: #bbb");
|
||||||
|
|
||||||
auto links = new QLabel(
|
auto links = new QLabel(
|
||||||
createLink("https://streamlink.github.io/", "Website") + " " +
|
createNamedLink("https://streamlink.github.io/", "Website") + " " +
|
||||||
createLink(
|
createNamedLink(
|
||||||
"https://github.com/streamlink/streamlink/releases/latest",
|
"https://github.com/streamlink/streamlink/releases/latest",
|
||||||
"Download"));
|
"Download"));
|
||||||
links->setTextFormat(Qt::RichText);
|
links->setTextFormat(Qt::RichText);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
|
|
||||||
|
@ -25,18 +26,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
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 dirSize(QString dirPath)
|
||||||
{
|
{
|
||||||
qint64 size = 0;
|
qint64 size = 0;
|
||||||
|
@ -110,20 +99,10 @@ ModerationPage::ModerationPage()
|
||||||
pathOriginal = logPath;
|
pathOriginal = logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString pathShortened;
|
QString pathShortened =
|
||||||
|
"Logs saved at <a href=\"file:///" + pathOriginal +
|
||||||
if (pathOriginal.size() > 50) {
|
|
||||||
pathShortened = pathOriginal;
|
|
||||||
pathShortened.resize(50);
|
|
||||||
pathShortened += "...";
|
|
||||||
} else {
|
|
||||||
pathShortened = pathOriginal;
|
|
||||||
}
|
|
||||||
|
|
||||||
pathShortened = "Logs saved at <a href=\"file:///" +
|
|
||||||
pathOriginal +
|
|
||||||
"\"><span style=\"color: white;\">" +
|
"\"><span style=\"color: white;\">" +
|
||||||
pathShortened + "</span></a>";
|
shortenString(pathOriginal, 50) + "</span></a>";
|
||||||
|
|
||||||
logsPathLabel->setText(pathShortened);
|
logsPathLabel->setText(pathShortened);
|
||||||
logsPathLabel->setToolTip(pathOriginal);
|
logsPathLabel->setToolTip(pathOriginal);
|
||||||
|
|
Loading…
Reference in a new issue