remove settings and paths from Application

This commit is contained in:
fourtf 2018-08-12 12:56:28 +02:00
parent 1ec1ecd52b
commit f6414c9d7e
35 changed files with 125 additions and 152 deletions

View file

@ -38,9 +38,7 @@ Application *Application::instance = nullptr;
// to each other // to each other
Application::Application(Settings &_settings, Paths &_paths) Application::Application(Settings &_settings, Paths &_paths)
: settings(&_settings) : resources(&this->emplace<Resources2>())
, paths(&_paths)
, resources(&this->emplace<Resources2>())
, themes(&this->emplace<Theme>()) , themes(&this->emplace<Theme>())
, fonts(&this->emplace<Fonts>()) , fonts(&this->emplace<Fonts>())

View file

@ -46,8 +46,6 @@ public:
friend void test(); friend void test();
Settings *const settings{};
Paths *const paths{};
Resources2 *const resources; Resources2 *const resources;
Theme *const themes{}; Theme *const themes{};

View file

@ -107,7 +107,7 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
chatterino::Updates::getInstance().checkForUpdates(); chatterino::Updates::getInstance().checkForUpdates();
#ifdef C_USE_BREAKPAD #ifdef C_USE_BREAKPAD
QBreakpadInstance.setDumpPath(app->paths->settingsFolderPath + "/Crashes"); QBreakpadInstance.setDumpPath(getPaths()->settingsFolderPath + "/Crashes");
#endif #endif
// Running file // Running file

View file

@ -44,7 +44,7 @@ void NetworkData::writeToCache(const QByteArray &bytes)
if (this->useQuickLoadCache_) { if (this->useQuickLoadCache_) {
auto app = getApp(); auto app = getApp();
QFile cachedFile(app->paths->cacheDirectory + "/" + this->getHash()); QFile cachedFile(getPaths()->cacheDirectory + "/" + this->getHash());
if (cachedFile.open(QIODevice::WriteOnly)) { if (cachedFile.open(QIODevice::WriteOnly)) {
cachedFile.write(bytes); cachedFile.write(bytes);

View file

@ -147,7 +147,7 @@ Outcome NetworkRequest::tryLoadCachedFile()
{ {
auto app = getApp(); auto app = getApp();
QFile cachedFile(app->paths->cacheDirectory + "/" + this->data->getHash()); QFile cachedFile(getPaths()->cacheDirectory + "/" + this->data->getHash());
if (!cachedFile.exists()) { if (!cachedFile.exists()) {
// File didn't exist // File didn't exist

View file

@ -37,13 +37,13 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item,
void HighlightModel::afterInit() void HighlightModel::afterInit()
{ {
std::vector<QStandardItem *> row = this->createRow(); std::vector<QStandardItem *> row = this->createRow();
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), setBoolItem(row[0], getSettings()->enableHighlightsSelf.getValue(), true,
true, false); false);
row[0]->setData("Your username (automatic)", Qt::DisplayRole); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), setBoolItem(row[1], getSettings()->enableHighlightTaskbar.getValue(), true,
true, false); false);
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), setBoolItem(row[2], getSettings()->enableHighlightSound.getValue(), true,
true, false); false);
row[3]->setFlags(0); row[3]->setFlags(0);
this->insertCustomRow(row, 0); this->insertCustomRow(row, 0);
} }
@ -55,20 +55,17 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
switch (column) { switch (column) {
case 0: { case 0: {
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
getApp()->settings->enableHighlightsSelf.setValue( getSettings()->enableHighlightsSelf.setValue(value.toBool());
value.toBool());
} }
} break; } break;
case 1: { case 1: {
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
getApp()->settings->enableHighlightTaskbar.setValue( getSettings()->enableHighlightTaskbar.setValue(value.toBool());
value.toBool());
} }
} break; } break;
case 2: { case 2: {
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
getApp()->settings->enableHighlightSound.setValue( getSettings()->enableHighlightSound.setValue(value.toBool());
value.toBool());
} }
} break; } break;
case 3: { case 3: {

View file

@ -29,12 +29,12 @@ void TaggedUsersModel::afterInit()
{ {
// std::vector<QStandardItem *> row = this->createRow(); // std::vector<QStandardItem *> row = this->createRow();
// setBoolItem(row[0], // setBoolItem(row[0],
// getApp()->settings->enableHighlightsSelf.getValue(), true, false); // getSettings()->enableHighlightsSelf.getValue(), true, false);
// row[0]->setData("Your username (automatic)", Qt::DisplayRole); // row[0]->setData("Your username (automatic)", Qt::DisplayRole);
// setBoolItem(row[1], // setBoolItem(row[1],
// getApp()->settings->enableHighlightTaskbar.getValue(), true, false); // getSettings()->enableHighlightTaskbar.getValue(), true, false);
// setBoolItem(row[2], // setBoolItem(row[2],
// getApp()->settings->enableHighlightSound.getValue(), true, false); // getSettings()->enableHighlightSound.getValue(), true, false);
// row[3]->setFlags(0); this->insertCustomRow(row, 0); // row[3]->setFlags(0); this->insertCustomRow(row, 0);
} }
@ -45,17 +45,17 @@ void TaggedUsersModel::afterInit()
// switch (column) { // switch (column) {
// case 0: { // case 0: {
// if (role == Qt::CheckStateRole) { // if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightsSelf.setValue(value.toBool()); // getSettings()->enableHighlightsSelf.setValue(value.toBool());
// } // }
// } break; // } break;
// case 1: { // case 1: {
// if (role == Qt::CheckStateRole) { // if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightTaskbar.setValue(value.toBool()); // getSettings()->enableHighlightTaskbar.setValue(value.toBool());
// } // }
// } break; // } break;
// case 2: { // case 2: {
// if (role == Qt::CheckStateRole) { // if (role == Qt::CheckStateRole) {
// getApp()->settings->enableHighlightSound.setValue(value.toBool()); // getSettings()->enableHighlightSound.setValue(value.toBool());
// } // }
// } break; // } break;
// case 3: { // case 3: {

View file

@ -225,8 +225,8 @@ void TimestampElement::addToContainer(MessageLayoutContainer &container,
{ {
if (flags.hasAny(this->getFlags())) { if (flags.hasAny(this->getFlags())) {
auto app = getApp(); auto app = getApp();
if (app->settings->timestampFormat != this->format_) { if (getSettings()->timestampFormat != this->format_) {
this->format_ = app->settings->timestampFormat.getValue(); this->format_ = getSettings()->timestampFormat.getValue();
this->element_.reset(this->formatTime(this->time_)); this->element_.reset(this->formatTime(this->time_));
} }
@ -238,7 +238,7 @@ TextElement *TimestampElement::formatTime(const QTime &time)
{ {
static QLocale locale("en_US"); static QLocale locale("en_US");
QString format = locale.toString(time, getApp()->settings->timestampFormat); QString format = locale.toString(time, getSettings()->timestampFormat);
return new TextElement(format, MessageElementFlag::Timestamp, return new TextElement(format, MessageElementFlag::Timestamp,
MessageColor::System, FontStyle::ChatMedium); MessageColor::System, FontStyle::ChatMedium);

View file

@ -73,7 +73,7 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
// check if work mask changed // check if work mask changed
layoutRequired |= this->currentWordFlags_ != flags; layoutRequired |= this->currentWordFlags_ != flags;
this->currentWordFlags_ = flags; // app->settings->getWordTypeMask(); this->currentWordFlags_ = flags; // getSettings()->getWordTypeMask();
// check if layout was requested manually // check if layout was requested manually
layoutRequired |= this->flags.has(MessageLayoutFlag::RequiresLayout); layoutRequired |= this->flags.has(MessageLayoutFlag::RequiresLayout);
@ -177,7 +177,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
} }
// draw message seperation line // draw message seperation line
if (app->settings->separateMessages.getValue()) { if (getSettings()->separateMessages.getValue()) {
painter.fillRect(0, y, this->container_->getWidth(), 1, painter.fillRect(0, y, this->container_->getWidth(), 1,
app->themes->splits.messageSeperator); app->themes->splits.messageSeperator);
} }
@ -190,7 +190,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
: app->themes->tabs.selected.backgrounds.unfocused.color(); : app->themes->tabs.selected.backgrounds.unfocused.color();
QBrush brush(color, static_cast<Qt::BrushStyle>( QBrush brush(color, static_cast<Qt::BrushStyle>(
app->settings->lastMessagePattern.getValue())); getSettings()->lastMessagePattern.getValue()));
painter.fillRect(0, y + this->container_->getHeight() - 1, painter.fillRect(0, y + this->container_->getHeight() - 1,
pixmap->width(), 1, brush); pixmap->width(), 1, brush);
@ -214,7 +214,7 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
backgroundColor = app->themes->messages.backgrounds.highlighted; backgroundColor = app->themes->messages.backgrounds.highlighted;
} else if (this->message_->flags.has(MessageFlag::Subscription)) { } else if (this->message_->flags.has(MessageFlag::Subscription)) {
backgroundColor = app->themes->messages.backgrounds.subscription; backgroundColor = app->themes->messages.backgrounds.subscription;
} else if (app->settings->alternateMessageBackground.getValue() && } else if (getSettings()->alternateMessageBackground.getValue() &&
this->flags.has(MessageLayoutFlag::AlternateBackground)) { this->flags.has(MessageLayoutFlag::AlternateBackground)) {
backgroundColor = app->themes->messages.backgrounds.alternate; backgroundColor = app->themes->messages.backgrounds.alternate;
} else { } else {

View file

@ -14,7 +14,7 @@
#define COMPACT_EMOTES_OFFSET 6 #define COMPACT_EMOTES_OFFSET 6
#define MAX_UNCOLLAPSED_LINES \ #define MAX_UNCOLLAPSED_LINES \
(getApp()->settings->collpseMessagesMinLines.getValue()) (getSettings()->collpseMessagesMinLines.getValue())
namespace chatterino { namespace chatterino {
@ -235,7 +235,7 @@ void MessageLayoutContainer::end()
bool MessageLayoutContainer::canCollapse() bool MessageLayoutContainer::canCollapse()
{ {
return getApp()->settings->collpseMessagesMinLines.getValue() > 0 && return getSettings()->collpseMessagesMinLines.getValue() > 0 &&
this->flags_.has(MessageFlag::Collapsed); this->flags_.has(MessageFlag::Collapsed);
} }

View file

@ -217,7 +217,7 @@ void Emojis::loadEmojiSet()
{ {
auto app = getApp(); auto app = getApp();
app->settings->emojiSet.connect([=](const auto &emojiSet, auto) { getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
log("Using emoji set {}", emojiSet); log("Using emoji set {}", emojiSet);
this->emojis.each([=](const auto &name, this->emojis.each([=](const auto &name,
std::shared_ptr<EmojiData> &emoji) { std::shared_ptr<EmojiData> &emoji) {

View file

@ -231,7 +231,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
c->addMessage(_message); c->addMessage(_message);
if (app->settings->inlineWhispers) { if (getSettings()->inlineWhispers) {
app->twitch.server->forEachChannel([_message](ChannelPtr channel) { app->twitch.server->forEachChannel([_message](ChannelPtr channel) {
channel->addMessage(_message); // channel->addMessage(_message); //
}); });

View file

@ -63,7 +63,7 @@ bool TwitchMessageBuilder::isIgnored() const
} }
} }
if (app->settings->enableTwitchIgnoredUsers && if (getSettings()->enableTwitchIgnoredUsers &&
this->tags.contains("user-id")) { this->tags.contains("user-id")) {
auto sourceUserID = this->tags.value("user-id").toString(); auto sourceUserID = this->tags.value("user-id").toString();
@ -289,7 +289,7 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
} }
// if (!linkString.isEmpty()) { // if (!linkString.isEmpty()) {
// if (getApp()->settings->lowercaseLink) { // if (getSettings()->lowercaseLink) {
// QRegularExpression httpRegex("\\bhttps?://", // QRegularExpression httpRegex("\\bhttps?://",
// QRegularExpression::CaseInsensitiveOption); QRegularExpression // QRegularExpression::CaseInsensitiveOption); QRegularExpression
// ftpRegex("\\bftps?://", // ftpRegex("\\bftps?://",
@ -499,9 +499,9 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
// update the media player url if necessary // update the media player url if necessary
QUrl highlightSoundUrl; QUrl highlightSoundUrl;
if (app->settings->customHighlightSound) { if (getSettings()->customHighlightSound) {
highlightSoundUrl = highlightSoundUrl =
QUrl::fromLocalFile(app->settings->pathHighlightSound.getValue()); QUrl::fromLocalFile(getSettings()->pathHighlightSound.getValue());
} else { } else {
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav"); highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
} }
@ -519,10 +519,10 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
std::vector<HighlightPhrase> userHighlights = std::vector<HighlightPhrase> userHighlights =
app->highlights->highlightedUsers.getVector(); app->highlights->highlightedUsers.getVector();
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) { if (getSettings()->enableHighlightsSelf && currentUsername.size() > 0) {
HighlightPhrase selfHighlight( HighlightPhrase selfHighlight(
currentUsername, app->settings->enableHighlightTaskbar, currentUsername, getSettings()->enableHighlightTaskbar,
app->settings->enableHighlightSound, false); getSettings()->enableHighlightSound, false);
activeHighlights.emplace_back(std::move(selfHighlight)); activeHighlights.emplace_back(std::move(selfHighlight));
} }
@ -581,7 +581,7 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
if (!isPastMsg) { if (!isPastMsg) {
if (playSound && if (playSound &&
(!hasFocus || app->settings->highlightAlwaysPlaySound)) { (!hasFocus || getSettings()->highlightAlwaysPlaySound)) {
player->play(); player->play();
} }

View file

@ -105,13 +105,13 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
{FontStyle::ChatMedium, {1, false, QFont::Normal}}, {FontStyle::ChatMedium, {1, false, QFont::Normal}},
{FontStyle::ChatMediumBold, {FontStyle::ChatMediumBold,
{1, false, {1, false,
QFont::Weight(getApp()->settings->boldScale.getValue())}}, QFont::Weight(getSettings()->boldScale.getValue())}},
{FontStyle::ChatMediumItalic, {1, true, QFont::Normal}}, {FontStyle::ChatMediumItalic, {1, true, QFont::Normal}},
{FontStyle::ChatLarge, {1.2f, false, QFont::Normal}}, {FontStyle::ChatLarge, {1.2f, false, QFont::Normal}},
{FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}}, {FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}},
}; };
sizeScale[FontStyle::ChatMediumBold] = { sizeScale[FontStyle::ChatMediumBold] = {
1, false, QFont::Weight(getApp()->settings->boldScale.getValue())}; 1, false, QFont::Weight(getSettings()->boldScale.getValue())};
auto data = sizeScale[type]; auto data = sizeScale[type];
return FontData( return FontData(
QFont(QString::fromStdString(this->chatFontFamily.getValue()), QFont(QString::fromStdString(this->chatFontFamily.getValue()),

View file

@ -43,6 +43,6 @@ private:
boost::optional<bool> portable_; boost::optional<bool> portable_;
}; };
[[deprecated]] Paths *getPaths(); Paths *getPaths();
} // namespace chatterino } // namespace chatterino

View file

@ -406,7 +406,7 @@ void WindowManager::save()
document.setObject(obj); document.setObject(obj);
// save file // save file
QString settingsPath = app->paths->settingsDirectory + SETTINGS_FILENAME; QString settingsPath = getPaths()->settingsDirectory + SETTINGS_FILENAME;
QFile file(settingsPath); QFile file(settingsPath);
file.open(QIODevice::WriteOnly | QIODevice::Truncate); file.open(QIODevice::WriteOnly | QIODevice::Truncate);
@ -518,7 +518,7 @@ int WindowManager::clampUiScale(int scale)
float WindowManager::getUiScaleValue() float WindowManager::getUiScaleValue()
{ {
return getUiScaleValue(getApp()->settings->uiScale.getValue()); return getUiScaleValue(getSettings()->uiScale.getValue());
} }
float WindowManager::getUiScaleValue(int scale) float WindowManager::getUiScaleValue(int scale)

View file

@ -10,7 +10,7 @@ void GIFTimer::initialize()
{ {
this->timer.setInterval(30); this->timer.setInterval(30);
getApp()->settings->enableGifAnimations.connect([this](bool enabled, auto) { getSettings()->enableGifAnimations.connect([this](bool enabled, auto) {
if (enabled) { if (enabled) {
this->timer.start(); this->timer.start();
} else { } else {

View file

@ -30,11 +30,11 @@ LoggingChannel::LoggingChannel(const QString &_channelName)
auto app = getApp(); auto app = getApp();
app->settings->logPath.connect([this](const QString &logPath, auto) { getSettings()->logPath.connect([this](const QString &logPath, auto) {
auto app = getApp(); auto app = getApp();
if (logPath.isEmpty()) { if (logPath.isEmpty()) {
this->baseDirectory = app->paths->messageLogDirectory; this->baseDirectory = getPaths()->messageLogDirectory;
} else { } else {
this->baseDirectory = logPath; this->baseDirectory = logPath;
} }

View file

@ -37,8 +37,8 @@ QString getStreamlinkProgram()
{ {
auto app = getApp(); auto app = getApp();
if (app->settings->streamlinkUseCustomPath) { if (getSettings()->streamlinkUseCustomPath) {
return app->settings->streamlinkPath + "/" + getBinaryName(); return getSettings()->streamlinkPath + "/" + getBinaryName();
} else { } else {
return getBinaryName(); return getBinaryName();
} }
@ -62,7 +62,7 @@ void showStreamlinkNotFoundError()
static QErrorMessage *msg = new QErrorMessage; static QErrorMessage *msg = new QErrorMessage;
auto app = getApp(); auto app = getApp();
if (app->settings->streamlinkUseCustomPath) { if (getSettings()->streamlinkUseCustomPath) {
msg->showMessage( msg->showMessage(
"Unable to find Streamlink executable\nMake sure your custom path " "Unable to find Streamlink executable\nMake sure your custom path "
"is pointing " "is pointing "
@ -146,9 +146,9 @@ void openStreamlink(const QString &channelURL, const QString &quality,
QStringList arguments; QStringList arguments;
QString additionalOptions = app->settings->streamlinkOpts.getValue(); QString additionalOptions = getSettings()->streamlinkOpts.getValue();
if (!additionalOptions.isEmpty()) { if (!additionalOptions.isEmpty()) {
arguments << app->settings->streamlinkOpts; arguments << getSettings()->streamlinkOpts;
} }
arguments.append(extraArguments); arguments.append(extraArguments);
@ -173,7 +173,7 @@ void openStreamlinkForChannel(const QString &channel)
QString channelURL = "twitch.tv/" + channel; QString channelURL = "twitch.tv/" + channel;
QString preferredQuality = app->settings->preferredQuality; QString preferredQuality = getSettings()->preferredQuality;
preferredQuality = preferredQuality.toLower(); preferredQuality = preferredQuality.toLower();
if (preferredQuality == "choose") { if (preferredQuality == "choose") {

View file

@ -56,13 +56,13 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
this->init(); this->init();
this->connections_.managedConnect( this->connections_.managedConnect(
getApp()->settings->uiScale.getValueChangedSignal(), getSettings()->uiScale.getValueChangedSignal(),
[this](auto, auto) { postToThread([this] { this->updateScale(); }); }); [this](auto, auto) { postToThread([this] { this->updateScale(); }); });
this->updateScale(); this->updateScale();
createWindowShortcut(this, "CTRL+0", createWindowShortcut(this, "CTRL+0",
[] { getApp()->settings->uiScale.setValue(0); }); [] { getSettings()->uiScale.setValue(0); });
// QTimer::this->scaleChangedEvent(this->getScale()); // QTimer::this->scaleChangedEvent(this->getScale());
} }
@ -163,7 +163,7 @@ void BaseWindow::init()
// fourtf: don't ask me why we need to delay this // fourtf: don't ask me why we need to delay this
if (!(this->flags_ & Flags::TopMost)) { if (!(this->flags_ & Flags::TopMost)) {
QTimer::singleShot(1, this, [this] { QTimer::singleShot(1, this, [this] {
getApp()->settings->windowTopMost.connect( getSettings()->windowTopMost.connect(
[this](bool topMost, auto) { [this](bool topMost, auto) {
::SetWindowPos(HWND(this->winId()), ::SetWindowPos(HWND(this->winId()),
topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0,
@ -174,7 +174,7 @@ void BaseWindow::init()
}); });
} }
#else #else
// if (getApp()->settings->windowTopMost.getValue()) { // if (getSettings()->windowTopMost.getValue()) {
// this->setWindowFlag(Qt::WindowStaysOnTopHint); // this->setWindowFlag(Qt::WindowStaysOnTopHint);
// } // }
#endif #endif
@ -267,11 +267,11 @@ void BaseWindow::wheelEvent(QWheelEvent *event)
if (event->modifiers() & Qt::ControlModifier) { if (event->modifiers() & Qt::ControlModifier) {
if (event->delta() > 0) { if (event->delta() > 0) {
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getSettings()->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() + 1)); getSettings()->uiScale.getValue() + 1));
} else { } else {
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getSettings()->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1)); getSettings()->uiScale.getValue() - 1));
} }
} }
} }

View file

@ -434,9 +434,9 @@ void SplitNotebook::addCustomButtons()
auto settingsBtn = this->addCustomButton(); auto settingsBtn = this->addCustomButton();
settingsBtn->setVisible( settingsBtn->setVisible(
!getApp()->settings->hidePreferencesButton.getValue()); !getSettings()->hidePreferencesButton.getValue());
getApp()->settings->hidePreferencesButton.connect( getSettings()->hidePreferencesButton.connect(
[settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); }, [settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); },
this->connections_); this->connections_);
@ -447,8 +447,8 @@ void SplitNotebook::addCustomButtons()
// account // account
auto userBtn = this->addCustomButton(); auto userBtn = this->addCustomButton();
userBtn->setVisible(!getApp()->settings->hideUserButton.getValue()); userBtn->setVisible(!getSettings()->hideUserButton.getValue());
getApp()->settings->hideUserButton.connect( getSettings()->hideUserButton.connect(
[userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, [userBtn](bool hide, auto) { userBtn->setVisible(!hide); },
this->connections_); this->connections_);

View file

@ -105,8 +105,8 @@ bool Window::event(QEvent *event)
void Window::showEvent(QShowEvent *event) void Window::showEvent(QShowEvent *event)
{ {
// Startup notification // Startup notification
if (getApp()->settings->startUpNotification.getValue() < 1) { if (getSettings()->startUpNotification.getValue() < 1) {
getApp()->settings->startUpNotification = 1; getSettings()->startUpNotification = 1;
auto box = new QMessageBox( auto box = new QMessageBox(
QMessageBox::Information, "Chatterino 2 Beta", QMessageBox::Information, "Chatterino 2 Beta",
@ -118,8 +118,8 @@ void Window::showEvent(QShowEvent *event)
} }
// Show changelog // Show changelog
if (getApp()->settings->currentVersion.getValue() != "" && if (getSettings()->currentVersion.getValue() != "" &&
getApp()->settings->currentVersion.getValue() != CHATTERINO_VERSION) { getSettings()->currentVersion.getValue() != CHATTERINO_VERSION) {
auto box = new QMessageBox(QMessageBox::Information, auto box = new QMessageBox(QMessageBox::Information,
"Chatterino 2 Beta", "Show changelog?", "Chatterino 2 Beta", "Show changelog?",
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
@ -130,7 +130,7 @@ void Window::showEvent(QShowEvent *event)
} }
} }
getApp()->settings->currentVersion.setValue(CHATTERINO_VERSION); getSettings()->currentVersion.setValue(CHATTERINO_VERSION);
// -- // --
BaseWindow::showEvent(event); BaseWindow::showEvent(event);
@ -281,8 +281,8 @@ void Window::addShortcuts()
auto s = new QShortcut(QKeySequence::ZoomIn, this); auto s = new QShortcut(QKeySequence::ZoomIn, this);
s->setContext(Qt::WindowShortcut); s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] { QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getSettings()->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() + 1)); getSettings()->uiScale.getValue() + 1));
}); });
} }
@ -291,8 +291,8 @@ void Window::addShortcuts()
auto s = new QShortcut(QKeySequence::ZoomOut, this); auto s = new QShortcut(QKeySequence::ZoomOut, this);
s->setContext(Qt::WindowShortcut); s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] { QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getSettings()->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1)); getSettings()->uiScale.getValue() - 1));
}); });
} }

View file

@ -154,7 +154,7 @@ void SettingsDialog::showDialog(PreferredTab preferredTab)
void SettingsDialog::refresh() void SettingsDialog::refresh()
{ {
getApp()->settings->saveSnapshot(); getSettings()->saveSnapshot();
for (auto *tab : this->tabs_) { for (auto *tab : this->tabs_) {
tab->getSettingsPage()->onShow(); tab->getSettingsPage()->onShow();
@ -199,7 +199,7 @@ void SettingsDialog::onCancelClicked()
tab->getSettingsPage()->cancel(); tab->getSettingsPage()->cancel();
} }
getApp()->settings->restoreSnapshot(); getSettings()->restoreSnapshot();
this->close(); this->close();
} }

View file

@ -131,8 +131,7 @@ void ChannelView::initializeLayout()
QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] { QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] {
QTimer::singleShot(180, [=] { QTimer::singleShot(180, [=] {
this->scrollBar_->scrollToBottom( this->scrollBar_->scrollToBottom(
getApp() getSettings()->enableSmoothScrollingNewMessages.getValue());
->settings->enableSmoothScrollingNewMessages.getValue());
}); });
}); });
} }
@ -162,7 +161,7 @@ void ChannelView::initializeSignals()
this->update(); this->update();
})); }));
getApp()->settings->showLastMessageIndicator.connect( getSettings()->showLastMessageIndicator.connect(
[this](auto, auto) { this->update(); }, this->connections_); [this](auto, auto) { this->update(); }, this->connections_);
connections_.push_back( connections_.push_back(
@ -213,8 +212,6 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
{ {
// BenchmarkGuard benchmark("layout"); // BenchmarkGuard benchmark("layout");
auto app = getApp();
auto messagesSnapshot = this->getMessagesSnapshot(); auto messagesSnapshot = this->getMessagesSnapshot();
if (messagesSnapshot.getLength() == 0) { if (messagesSnapshot.getLength() == 0) {
@ -293,7 +290,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
if (!this->isPaused()) { if (!this->isPaused()) {
this->scrollBar_->scrollToBottom( this->scrollBar_->scrollToBottom(
// this->messageWasAdded && // this->messageWasAdded &&
app->settings->enableSmoothScrollingNewMessages.getValue()); getSettings()->enableSmoothScrollingNewMessages.getValue());
} }
this->messageWasAdded_ = false; this->messageWasAdded_ = false;
} }
@ -654,8 +651,6 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// such as the grey overlay when a message is disabled // such as the grey overlay when a message is disabled
void ChannelView::drawMessages(QPainter &painter) void ChannelView::drawMessages(QPainter &painter)
{ {
auto app = getApp();
auto messagesSnapshot = this->getMessagesSnapshot(); auto messagesSnapshot = this->getMessagesSnapshot();
size_t start = size_t(this->scrollBar_->getCurrentValue()); size_t start = size_t(this->scrollBar_->getCurrentValue());
@ -674,7 +669,7 @@ void ChannelView::drawMessages(QPainter &painter)
MessageLayout *layout = messagesSnapshot[i].get(); MessageLayout *layout = messagesSnapshot[i].get();
bool isLastMessage = false; bool isLastMessage = false;
if (app->settings->showLastMessageIndicator) { if (getSettings()->showLastMessageIndicator) {
isLastMessage = this->lastReadMessage_.get() == layout; isLastMessage = this->lastReadMessage_.get() == layout;
} }
@ -737,9 +732,7 @@ void ChannelView::wheelEvent(QWheelEvent *event)
} }
if (this->scrollBar_->isVisible()) { if (this->scrollBar_->isVisible()) {
auto app = getApp(); float mouseMultiplier = getSettings()->mouseScrollMultiplier;
float mouseMultiplier = app->settings->mouseScrollMultiplier;
qreal desired = this->scrollBar_->getDesiredValue(); qreal desired = this->scrollBar_->getDesiredValue();
qreal delta = event->delta() * qreal(1.5) * mouseMultiplier; qreal delta = event->delta() * qreal(1.5) * mouseMultiplier;
@ -824,9 +817,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
return; return;
} }
auto app = getApp(); if (getSettings()->pauseChatHover.getValue()) {
if (app->settings->pauseChatHover.getValue()) {
this->pause(CHAT_HOVER_PAUSE_DURATION); this->pause(CHAT_HOVER_PAUSE_DURATION);
} }
@ -891,8 +882,6 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
void ChannelView::mousePressEvent(QMouseEvent *event) void ChannelView::mousePressEvent(QMouseEvent *event)
{ {
auto app = getApp();
this->mouseDown.invoke(event); this->mouseDown.invoke(event);
std::shared_ptr<MessageLayout> layout; std::shared_ptr<MessageLayout> layout;
@ -929,7 +918,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
return; return;
} }
if (app->settings->linksDoubleClickOnly.getValue()) { if (getSettings()->linksDoubleClickOnly.getValue()) {
this->pause(200); this->pause(200);
} }
@ -1034,7 +1023,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
} }
auto &link = hoveredElement->getLink(); auto &link = hoveredElement->getLink();
if (!getApp()->settings->linksDoubleClickOnly) { if (!getSettings()->linksDoubleClickOnly) {
this->handleLinkClick(event, link, layout); this->handleLinkClick(event, link, layout);
this->linkClicked.invoke(link); this->linkClicked.invoke(link);
@ -1119,9 +1108,7 @@ void ChannelView::addContextMenuItems(
void ChannelView::mouseDoubleClickEvent(QMouseEvent *event) void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
{ {
auto app = getApp(); if (getSettings()->linksDoubleClickOnly) {
if (app->settings->linksDoubleClickOnly) {
std::shared_ptr<MessageLayout> layout; std::shared_ptr<MessageLayout> layout;
QPoint relativePos; QPoint relativePos;
int messageIndex; int messageIndex;

View file

@ -35,7 +35,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->positionChangedAnimation_.setEasingCurve( this->positionChangedAnimation_.setEasingCurve(
QEasingCurve(QEasingCurve::InCubic)); QEasingCurve(QEasingCurve::InCubic));
app->settings->showTabCloseButton.connect( getSettings()->showTabCloseButton.connect(
boost::bind(&NotebookTab::hideTabXChanged, this, _1), boost::bind(&NotebookTab::hideTabXChanged, this, _1),
this->managedConnections_); this->managedConnections_);
@ -286,7 +286,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
painter.setPen(colors.text); painter.setPen(colors.text);
// set area for text // set area for text
int rectW = (!app->settings->showTabCloseButton ? 0 : int(16 * scale)); int rectW = (!getSettings()->showTabCloseButton ? 0 : int(16 * scale));
QRect rect(0, 0, this->width() - rectW, height); QRect rect(0, 0, this->width() - rectW, height);
// draw text // draw text
@ -341,7 +341,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
bool NotebookTab::hasXButton() bool NotebookTab::hasXButton()
{ {
return getApp()->settings->showTabCloseButton && return getSettings()->showTabCloseButton &&
this->notebook_->getAllowUserTabManagement(); this->notebook_->getAllowUserTabManagement();
} }
@ -434,7 +434,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
{ {
auto app = getApp(); auto app = getApp();
if (app->settings->showTabCloseButton && if (getSettings()->showTabCloseButton &&
this->notebook_->getAllowUserTabManagement()) // this->notebook_->getAllowUserTabManagement()) //
{ {
bool overX = this->getXRect().contains(event->pos()); bool overX = this->getXRect().contains(event->pos());

View file

@ -47,7 +47,7 @@ CommandPage::CommandPage()
layout.append( layout.append(
this->createCheckBox("Also match the trigger at the end of the message", this->createCheckBox("Also match the trigger at the end of the message",
app->settings->allowCommandsAtEnd)); getSettings()->allowCommandsAtEnd));
QLabel *text = layout.emplace<QLabel>(TEXT).getElement(); QLabel *text = layout.emplace<QLabel>(TEXT).getElement();
text->setWordWrap(true); text->setWordWrap(true);

View file

@ -57,22 +57,22 @@ ExternalToolsPage::ExternalToolsPage()
auto customPathCb = auto customPathCb =
this->createCheckBox("Use custom path (Enable if using " this->createCheckBox("Use custom path (Enable if using "
"non-standard streamlink installation path)", "non-standard streamlink installation path)",
app->settings->streamlinkUseCustomPath); getSettings()->streamlinkUseCustomPath);
groupLayout->setWidget(2, QFormLayout::SpanningRole, customPathCb); groupLayout->setWidget(2, QFormLayout::SpanningRole, customPathCb);
auto customPath = this->createLineEdit(app->settings->streamlinkPath); auto customPath = this->createLineEdit(getSettings()->streamlinkPath);
customPath->setPlaceholderText( customPath->setPlaceholderText(
"Path to folder where Streamlink executable can be found"); "Path to folder where Streamlink executable can be found");
groupLayout->addRow("Custom streamlink path:", customPath); groupLayout->addRow("Custom streamlink path:", customPath);
groupLayout->addRow( groupLayout->addRow(
"Preferred quality:", "Preferred quality:",
this->createComboBox({STREAMLINK_QUALITY}, this->createComboBox({STREAMLINK_QUALITY},
app->settings->preferredQuality)); getSettings()->preferredQuality));
groupLayout->addRow( groupLayout->addRow(
"Additional options:", "Additional options:",
this->createLineEdit(app->settings->streamlinkOpts)); this->createLineEdit(getSettings()->streamlinkOpts));
app->settings->streamlinkUseCustomPath.connect( getSettings()->streamlinkUseCustomPath.connect(
[=](const auto &value, auto) { [=](const auto &value, auto) {
customPath->setEnabled(value); // customPath->setEnabled(value); //
}, },

View file

@ -20,7 +20,6 @@ namespace chatterino {
FeelPage::FeelPage() FeelPage::FeelPage()
: SettingsPage("Feel", ":/settings/behave.svg") : SettingsPage("Feel", ":/settings/behave.svg")
{ {
auto app = getApp();
LayoutCreator<FeelPage> layoutCreator(this); LayoutCreator<FeelPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>(); auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
@ -37,20 +36,20 @@ FeelPage::FeelPage()
form->addRow( form->addRow(
"", this->createCheckBox( "", this->createCheckBox(
"Show which users joined the channel (up to 1000 chatters)", "Show which users joined the channel (up to 1000 chatters)",
app->settings->showJoins)); getSettings()->showJoins));
form->addRow( form->addRow(
"", this->createCheckBox( "", this->createCheckBox(
"Show which users parted the channel (up to 1000 chatters)", "Show which users parted the channel (up to 1000 chatters)",
app->settings->showParts)); getSettings()->showParts));
form->addRow("Pause chat:", form->addRow("Pause chat:",
this->createCheckBox(PAUSE_HOVERING, this->createCheckBox(PAUSE_HOVERING,
app->settings->pauseChatHover)); getSettings()->pauseChatHover));
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider()); form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
form->addRow("Links:", form->addRow("Links:",
this->createCheckBox("Open links only on double click", this->createCheckBox("Open links only on double click",
app->settings->linksDoubleClickOnly)); getSettings()->linksDoubleClickOnly));
} }
layout->addSpacing(16); layout->addSpacing(16);
@ -61,11 +60,11 @@ FeelPage::FeelPage()
groupLayout->addRow( groupLayout->addRow(
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS, LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
this->createCheckBox( this->createCheckBox(
"", app->settings->onlyFetchChattersForSmallerStreamers)); "", getSettings()->onlyFetchChattersForSmallerStreamers));
groupLayout->addRow( groupLayout->addRow(
"What viewer count counts as a \"smaller streamer\"", "What viewer count counts as a \"smaller streamer\"",
this->createSpinBox(app->settings->smallStreamerLimit, 10, 50000)); this->createSpinBox(getSettings()->smallStreamerLimit, 10, 50000));
} }
{ {
@ -73,7 +72,7 @@ FeelPage::FeelPage()
auto groupLayout = group.setLayoutType<QVBoxLayout>(); auto groupLayout = group.setLayoutType<QVBoxLayout>();
groupLayout.append(this->createCheckBox("Show whispers inline", groupLayout.append(this->createCheckBox("Show whispers inline",
app->settings->inlineWhispers)); getSettings()->inlineWhispers));
} }
layout->addStretch(1); layout->addStretch(1);
@ -81,17 +80,16 @@ FeelPage::FeelPage()
QSlider *FeelPage::createMouseScrollSlider() QSlider *FeelPage::createMouseScrollSlider()
{ {
auto app = getApp();
auto slider = new QSlider(Qt::Horizontal); auto slider = new QSlider(Qt::Horizontal);
float currentValue = app->settings->mouseScrollMultiplier; float currentValue = getSettings()->mouseScrollMultiplier;
int sliderValue = int(((currentValue - 0.1f) / 2.f) * 99.f); int sliderValue = int(((currentValue - 0.1f) / 2.f) * 99.f);
slider->setValue(sliderValue); slider->setValue(sliderValue);
QObject::connect(slider, &QSlider::valueChanged, [=](int newValue) { QObject::connect(slider, &QSlider::valueChanged, [=](int newValue) {
float mul = static_cast<float>(newValue) / 99.f; float mul = static_cast<float>(newValue) / 99.f;
float newSliderValue = (mul * 2.1f) + 0.1f; float newSliderValue = (mul * 2.1f) + 0.1f;
app->settings->mouseScrollMultiplier = newSliderValue; getSettings()->mouseScrollMultiplier = newSliderValue;
}); });
return slider; return slider;

View file

@ -39,7 +39,7 @@ HighlightingPage::HighlightingPage()
{ {
// GENERAL // GENERAL
// layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, // layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS,
// app->settings->enableHighlights)); // getSettings()->enableHighlights));
// TABS // TABS
auto tabs = layout.emplace<QTabWidget>(); auto tabs = layout.emplace<QTabWidget>();
@ -135,7 +135,7 @@ HighlightingPage::HighlightingPage()
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin(); auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
{ {
customSound.append(this->createCheckBox( customSound.append(this->createCheckBox(
"Custom sound", app->settings->customHighlightSound)); "Custom sound", getSettings()->customHighlightSound));
auto selectFile = auto selectFile =
customSound.emplace<QPushButton>("Select custom sound file"); customSound.emplace<QPushButton>("Select custom sound file");
QObject::connect(selectFile.getElement(), &QPushButton::clicked, QObject::connect(selectFile.getElement(), &QPushButton::clicked,
@ -143,12 +143,12 @@ HighlightingPage::HighlightingPage()
auto fileName = QFileDialog::getOpenFileName( auto fileName = QFileDialog::getOpenFileName(
this, tr("Open Sound"), "", this, tr("Open Sound"), "",
tr("Audio Files (*.mp3 *.wav)")); tr("Audio Files (*.mp3 *.wav)"));
app->settings->pathHighlightSound = fileName; getSettings()->pathHighlightSound = fileName;
}); });
} }
layout.append(createCheckBox(ALWAYS_PLAY, layout.append(createCheckBox(ALWAYS_PLAY,
app->settings->highlightAlwaysPlaySound)); getSettings()->highlightAlwaysPlaySound));
} }
// ---- misc // ---- misc

View file

@ -71,7 +71,7 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
{ {
users.append( users.append(
page.createCheckBox("Enable twitch ignored users", page.createCheckBox("Enable twitch ignored users",
getApp()->settings->enableTwitchIgnoredUsers)); getSettings()->enableTwitchIgnoredUsers));
auto anyways = users.emplace<QHBoxLayout>().withoutMargin(); auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
{ {

View file

@ -33,7 +33,7 @@
// LayoutCreator<LogsPage> layoutCreator(this); // LayoutCreator<LogsPage> layoutCreator(this);
// auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin(); // auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
// auto logPath = app->paths->logsFolderPath; // auto logPath = getPaths()->logsFolderPath;
// auto created = layout.emplace<QLabel>(); // auto created = layout.emplace<QLabel>();
// created->setText("Logs are saved to " + CreateLink(logPath, true)); // created->setText("Logs are saved to " + CreateLink(logPath, true));
@ -43,7 +43,7 @@
// Qt::LinksAccessibleByKeyboard); // Qt::LinksAccessibleByKeyboard);
// created->setOpenExternalLinks(true); // created->setOpenExternalLinks(true);
// layout.append(this->createCheckBox("Enable logging", // layout.append(this->createCheckBox("Enable logging",
// app->settings->enableLogging)); // getSettings()->enableLogging));
// layout->addStretch(1); // layout->addStretch(1);
//} //}

View file

@ -208,13 +208,13 @@ void LookPage::addEmoteTab(LayoutCreator<QVBoxLayout> layout)
/* /*
emotes.append( emotes.append(
this->createCheckBox("Enable Twitch emotes", this->createCheckBox("Enable Twitch emotes",
app->settings->enableTwitchEmotes)); getSettings()->enableTwitchEmotes));
emotes.append(this->createCheckBox("Enable BetterTTV emotes for Twitch", emotes.append(this->createCheckBox("Enable BetterTTV emotes for Twitch",
app->settings->enableBttvEmotes)); getSettings()->enableBttvEmotes));
emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch", emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch",
app->settings->enableFfzEmotes)); getSettings()->enableFfzEmotes));
emotes.append(this->createCheckBox("Enable emojis", emotes.append(this->createCheckBox("Enable emojis",
app->settings->enableEmojis)); getSettings()->enableEmojis));
*/ */
layout.append( layout.append(
this->createCheckBox("Animations", getSettings()->enableGifAnimations)); this->createCheckBox("Animations", getSettings()->enableGifAnimations));
@ -285,7 +285,7 @@ void LookPage::addLastReadMessageIndicatorPatternSelector(
combo->addItems({"Dotted line", "Solid line"}); combo->addItems({"Dotted line", "Solid line"});
const auto currentIndex = []() -> int { const auto currentIndex = []() -> int {
switch (getApp()->settings->lastMessagePattern.getValue()) { switch (getSettings()->lastMessagePattern.getValue()) {
case Qt::SolidLine: case Qt::SolidLine:
return 1; return 1;
case Qt::VerPattern: case Qt::VerPattern:

View file

@ -69,12 +69,11 @@ QString formatSize(qint64 size)
QString fetchLogDirectorySize() QString fetchLogDirectorySize()
{ {
auto app = getApp();
QString logPathDirectory; QString logPathDirectory;
if (app->settings->logPath == "") { if (getSettings()->logPath == "") {
logPathDirectory = app->paths->messageLogDirectory; logPathDirectory = getPaths()->messageLogDirectory;
} else { } else {
logPathDirectory = app->settings->logPath; logPathDirectory = getSettings()->logPath;
} }
qint64 logsSize = dirSize(logPathDirectory); qint64 logsSize = dirSize(logPathDirectory);
QString logsSizeLabel = "Your logs currently take up "; QString logsSizeLabel = "Your logs currently take up ";
@ -101,12 +100,12 @@ ModerationPage::ModerationPage()
QtConcurrent::run([] { return fetchLogDirectorySize(); })); QtConcurrent::run([] { return fetchLogDirectorySize(); }));
// Logs (copied from LoggingMananger) // Logs (copied from LoggingMananger)
app->settings->logPath.connect( getSettings()->logPath.connect(
[app, logsPathLabel](const QString &logPath, auto) mutable { [app, logsPathLabel](const QString &logPath, auto) mutable {
QString pathOriginal; QString pathOriginal;
if (logPath == "") { if (logPath == "") {
pathOriginal = app->paths->messageLogDirectory; pathOriginal = getPaths()->messageLogDirectory;
} else { } else {
pathOriginal = logPath; pathOriginal = logPath;
} }
@ -136,7 +135,7 @@ ModerationPage::ModerationPage()
Qt::LinksAccessibleByKeyboard); Qt::LinksAccessibleByKeyboard);
logsPathLabel->setOpenExternalLinks(true); logsPathLabel->setOpenExternalLinks(true);
logs.append(this->createCheckBox("Enable logging", logs.append(this->createCheckBox("Enable logging",
app->settings->enableLogging)); getSettings()->enableLogging));
logs->addStretch(1); logs->addStretch(1);
auto selectDir = logs.emplace<QPushButton>("Set custom logpath"); auto selectDir = logs.emplace<QPushButton>("Set custom logpath");
@ -145,10 +144,9 @@ ModerationPage::ModerationPage()
QObject::connect( QObject::connect(
selectDir.getElement(), &QPushButton::clicked, this, selectDir.getElement(), &QPushButton::clicked, this,
[this, logsPathSizeLabel]() mutable { [this, logsPathSizeLabel]() mutable {
auto app = getApp();
auto dirName = QFileDialog::getExistingDirectory(this); auto dirName = QFileDialog::getExistingDirectory(this);
app->settings->logPath = dirName; getSettings()->logPath = dirName;
// Refresh: Show how big (size-wise) the logs are // Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText( logsPathSizeLabel->setText(
@ -159,8 +157,7 @@ ModerationPage::ModerationPage()
auto resetDir = logs.emplace<QPushButton>("Reset logpath"); auto resetDir = logs.emplace<QPushButton>("Reset logpath");
QObject::connect(resetDir.getElement(), &QPushButton::clicked, this, QObject::connect(resetDir.getElement(), &QPushButton::clicked, this,
[logsPathSizeLabel]() mutable { [logsPathSizeLabel]() mutable {
auto app = getApp(); getSettings()->logPath = "";
app->settings->logPath = "";
// Refresh: Show how big (size-wise) the logs are // Refresh: Show how big (size-wise) the logs are
logsPathSizeLabel->setText(QtConcurrent::run( logsPathSizeLabel->setText(QtConcurrent::run(
@ -183,7 +180,7 @@ ModerationPage::ModerationPage()
// form->addRow("Action on timed out messages // form->addRow("Action on timed out messages
// (unimplemented):", // (unimplemented):",
// this->createComboBox({"Disable", "Hide"}, // this->createComboBox({"Disable", "Hide"},
// app->settings->timeoutAction)); // getSettings()->timeoutAction));
// } // }
EditableModelView *view = EditableModelView *view =

View file

@ -13,8 +13,6 @@ namespace chatterino {
SpecialChannelsPage::SpecialChannelsPage() SpecialChannelsPage::SpecialChannelsPage()
: SettingsPage("Special channels", "") : SettingsPage("Special channels", "")
{ {
auto app = getApp();
LayoutCreator<SpecialChannelsPage> layoutCreator(this); LayoutCreator<SpecialChannelsPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>(); auto layout = layoutCreator.setLayoutType<QVBoxLayout>();

View file

@ -109,7 +109,7 @@ void SplitInput::initLayout()
}); });
// textEditLength visibility // textEditLength visibility
app->settings->showMessageLength.connect( getSettings()->showMessageLength.connect(
[this](const bool &value, auto) { [this](const bool &value, auto) {
this->ui_.textEditLength->setHidden(!value); this->ui_.textEditLength->setHidden(!value);
}, },