changed to 80 max column

This commit is contained in:
fourtf
2018-08-06 21:17:03 +02:00
parent defa7e41fa
commit f71ff08e68
203 changed files with 3792 additions and 2405 deletions
+57 -43
View File
@@ -28,11 +28,13 @@ namespace chatterino {
inline QString CreateLink(const QString &url, bool file = false)
{
if (file) {
return QString("<a href=\"file:///" + url + "\"><span style=\"color: white;\">" + url +
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=\"" + url + "\"><span style=\"color: white;\">" +
url + "</span></a>");
}
qint64 dirSize(QString dirPath)
@@ -46,7 +48,8 @@ qint64 dirSize(QString dirPath)
size += fi.size();
}
// add size of child directories recursively
QDir::Filters dirFilters = QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden;
QDir::Filters dirFilters =
QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden;
for (QString childDirPath : dir.entryList(dirFilters))
size += dirSize(dirPath + QDir::separator() + childDirPath);
return size;
@@ -58,8 +61,7 @@ QString formatSize(qint64 size)
int i;
double outputSize = size;
for (i = 0; i < units.size() - 1; i++) {
if (outputSize < 1024)
break;
if (outputSize < 1024) break;
outputSize = outputSize / 1024;
}
return QString("%0 %1").arg(outputSize, 0, 'f', 2).arg(units[i]);
@@ -95,57 +97,63 @@ ModerationPage::ModerationPage()
// Show how big (size-wise) the logs are
auto logsPathSizeLabel = logs.emplace<QLabel>();
logsPathSizeLabel->setText(QtConcurrent::run([] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
// Logs (copied from LoggingMananger)
app->settings->logPath.connect([app, logsPathLabel](const QString &logPath, auto) mutable {
QString pathOriginal;
app->settings->logPath.connect(
[app, logsPathLabel](const QString &logPath, auto) mutable {
QString pathOriginal;
if (logPath == "") {
pathOriginal = app->paths->messageLogDirectory;
} else {
pathOriginal = logPath;
}
if (logPath == "") {
pathOriginal = app->paths->messageLogDirectory;
} else {
pathOriginal = logPath;
}
QString pathShortened;
QString pathShortened;
if (pathOriginal.size() > 50) {
pathShortened = pathOriginal;
pathShortened.resize(50);
pathShortened += "...";
} else {
pathShortened = 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;\">" + pathShortened + "</span></a>";
pathShortened = "Logs saved at <a href=\"file:///" +
pathOriginal +
"\"><span style=\"color: white;\">" +
pathShortened + "</span></a>";
logsPathLabel->setText(pathShortened);
logsPathLabel->setToolTip(pathOriginal);
});
logsPathLabel->setText(pathShortened);
logsPathLabel->setToolTip(pathOriginal);
});
logsPathLabel->setTextFormat(Qt::RichText);
logsPathLabel->setTextInteractionFlags(Qt::TextBrowserInteraction |
Qt::LinksAccessibleByKeyboard |
Qt::LinksAccessibleByKeyboard);
logsPathLabel->setOpenExternalLinks(true);
logs.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
logs.append(this->createCheckBox("Enable logging",
app->settings->enableLogging));
logs->addStretch(1);
auto selectDir = logs.emplace<QPushButton>("Set custom logpath");
// Setting custom logpath
QObject::connect(selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto app = getApp();
auto dirName = QFileDialog::getExistingDirectory(this);
QObject::connect(
selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable {
auto app = getApp();
auto dirName = QFileDialog::getExistingDirectory(this);
app->settings->logPath = dirName;
app->settings->logPath = dirName;
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
});
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
});
// Reset custom logpath
auto resetDir = logs.emplace<QPushButton>("Reset logpath");
@@ -155,8 +163,8 @@ ModerationPage::ModerationPage()
app->settings->logPath = "";
// Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(
QtConcurrent::run([] { return fetchLogDirectorySize(); }));
logsPathSizeLabel->setText(QtConcurrent::run(
[] { return fetchLogDirectorySize(); }));
});
// Logs end
@@ -172,21 +180,27 @@ ModerationPage::ModerationPage()
// auto form = modMode.emplace<QFormLayout>();
// {
// form->addRow("Action on timed out messages (unimplemented):",
// form->addRow("Action on timed out messages
// (unimplemented):",
// this->createComboBox({"Disable", "Hide"},
// app->settings->timeoutAction));
// }
EditableModelView *view =
modMode.emplace<EditableModelView>(app->moderationActions->createModel(nullptr))
modMode
.emplace<EditableModelView>(
app->moderationActions->createModel(nullptr))
.getElement();
view->setTitles({"Actions"});
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
view->getTableView()->horizontalHeader()->setSectionResizeMode(
QHeaderView::Fixed);
view->getTableView()->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::Stretch);
view->addButtonPressed.connect([] {
getApp()->moderationActions->items.appendItem(ModerationAction("/timeout {user} 300"));
getApp()->moderationActions->items.appendItem(
ModerationAction("/timeout {user} 300"));
});
/*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users");