#include "widgets/dialogs/SettingsDialog.hpp" #include "Application.hpp" #include "singletons/Resources.hpp" #include "util/LayoutCreator.hpp" #include "widgets/helper/Button.hpp" #include "widgets/helper/SettingsDialogTab.hpp" #include "widgets/settingspages/AboutPage.hpp" #include "widgets/settingspages/AccountsPage.hpp" #include "widgets/settingspages/AdvancedPage.hpp" #include "widgets/settingspages/BrowserExtensionPage.hpp" #include "widgets/settingspages/CommandPage.hpp" #include "widgets/settingspages/EmotesPage.hpp" #include "widgets/settingspages/ExternalToolsPage.hpp" #include "widgets/settingspages/FeelPage.hpp" #include "widgets/settingspages/GeneralPage.hpp" #include "widgets/settingspages/HighlightingPage.hpp" #include "widgets/settingspages/IgnoresPage.hpp" #include "widgets/settingspages/KeyboardSettingsPage.hpp" #include "widgets/settingspages/LogsPage.hpp" #include "widgets/settingspages/LookPage.hpp" #include "widgets/settingspages/ModerationPage.hpp" #include "widgets/settingspages/NotificationPage.hpp" #include "widgets/settingspages/SpecialChannelsPage.hpp" #include #include namespace chatterino { SettingsDialog *SettingsDialog::handle = nullptr; SettingsDialog::SettingsDialog() : BaseWindow(nullptr, BaseWindow::DisableCustomScaling) { this->initUi(); this->addTabs(); this->scaleChangedEvent(this->scale()); this->overrideBackgroundColor_ = QColor("#111111"); this->themeChangedEvent(); this->resize(815, 600); } void SettingsDialog::initUi() { LayoutCreator layoutCreator(this); // tab pages auto outerBox = layoutCreator.setLayoutType(); outerBox->setSpacing(12); outerBox.emplace() .assign(&this->ui_.tabContainerContainer) .emplace() .withoutMargin() .assign(&this->ui_.tabContainer); this->ui_.tabContainerContainer->layout()->setContentsMargins(8, 8, 0, 39); // right side layout auto right = layoutCreator.emplace().withoutMargin().withoutSpacing(); { auto title = right.emplace(); auto header = LayoutCreator(title.getElement()) .setLayoutType(); auto edit = header.emplace().assign(&this->ui_.search); edit->setPlaceholderText("Find in settings..."); QTimer::singleShot(100, edit.getElement(), [edit = edit.getElement()]() { edit->setFocus(); }); QObject::connect( edit.getElement(), &QLineEdit::textChanged, this, [this](const QString &text) { // filter elements and hide pages for (auto &&page : this->pages_) { // filterElements returns true if anything on the page matches the search query page->tab()->setVisible(page->filterElements(text)); } // TODO: add originally selected page // find next visible page if (this->lastSelectedByUser_ && this->lastSelectedByUser_->isVisible()) { this->selectTab(this->lastSelectedByUser_, false); } else if (!this->selectedTab_->isVisible()) { for (auto &&tab : this->tabs_) { if (tab->isVisible()) { this->selectTab(tab, false); break; } } } // remove duplicate spaces bool shouldShowSpace = true; for (int i = 0; i < this->ui_.tabContainer->count(); i++) { auto item = this->ui_.tabContainer->itemAt(i); if (auto x = dynamic_cast(item); x) { x->changeSize( 10, shouldShowSpace ? int(16 * this->scale()) : 0); shouldShowSpace = false; } else if (item->widget()) { shouldShowSpace |= item->widget()->isVisible(); } } }); auto searchButton = header.emplace