2019-09-01 14:13:44 +02:00
|
|
|
#include "widgets/AccountSwitchPopup.hpp"
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
|
2023-09-15 18:44:36 +02:00
|
|
|
#include "common/Literals.hpp"
|
|
|
|
#include "singletons/Theme.hpp"
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "widgets/AccountSwitchWidget.hpp"
|
2018-06-26 15:11:45 +02:00
|
|
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
2017-12-19 02:16:01 +01:00
|
|
|
|
|
|
|
#include <QLayout>
|
2018-01-17 02:22:57 +01:00
|
|
|
#include <QPainter>
|
2017-12-19 02:16:01 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2023-09-15 18:44:36 +02:00
|
|
|
using namespace literals;
|
|
|
|
|
2019-09-01 14:13:44 +02:00
|
|
|
AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
2022-12-03 11:50:22 +01:00
|
|
|
: BaseWindow({BaseWindow::TopMost, BaseWindow::Frameless,
|
|
|
|
BaseWindow::DisableLayoutSave},
|
|
|
|
parent)
|
2017-12-19 02:16:01 +01:00
|
|
|
{
|
2019-03-27 19:15:37 +01:00
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
this->setWindowFlag(Qt::Popup);
|
|
|
|
#endif
|
2017-12-19 02:16:01 +01:00
|
|
|
|
|
|
|
this->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
2018-07-06 19:23:47 +02:00
|
|
|
this->ui_.accountSwitchWidget = new AccountSwitchWidget(this);
|
2017-12-19 02:16:01 +01:00
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(this);
|
2018-07-06 19:23:47 +02:00
|
|
|
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
|
|
|
vbox->addWidget(this->ui_.accountSwitchWidget);
|
2017-12-19 02:16:01 +01:00
|
|
|
|
|
|
|
auto hbox = new QHBoxLayout();
|
|
|
|
auto manageAccountsButton = new QPushButton(this);
|
|
|
|
manageAccountsButton->setText("Manage Accounts");
|
2019-08-17 01:35:24 +02:00
|
|
|
manageAccountsButton->setFocusPolicy(Qt::NoFocus);
|
2017-12-19 02:16:01 +01:00
|
|
|
hbox->addWidget(manageAccountsButton);
|
|
|
|
vbox->addLayout(hbox);
|
|
|
|
|
2020-10-31 16:42:48 +01:00
|
|
|
connect(manageAccountsButton, &QPushButton::clicked, [this]() {
|
2020-11-08 12:02:19 +01:00
|
|
|
SettingsDialog::showDialog(this, SettingsDialogPreference::Accounts);
|
2017-12-19 02:16:01 +01:00
|
|
|
});
|
|
|
|
|
2019-09-08 12:43:12 +02:00
|
|
|
this->getLayoutContainer()->setLayout(vbox);
|
2018-05-25 13:02:14 +02:00
|
|
|
|
2019-09-08 12:43:12 +02:00
|
|
|
this->setScaleIndependantSize(200, 200);
|
2023-09-15 18:44:36 +02:00
|
|
|
this->themeChangedEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccountSwitchPopup::themeChangedEvent()
|
|
|
|
{
|
|
|
|
BaseWindow::themeChangedEvent();
|
|
|
|
|
|
|
|
auto *t = getTheme();
|
|
|
|
auto color = [](const QColor &c) {
|
|
|
|
return c.name(QColor::HexArgb);
|
|
|
|
};
|
|
|
|
this->setStyleSheet(uR"(
|
|
|
|
QListView {
|
|
|
|
color: %1;
|
|
|
|
background: %2;
|
|
|
|
}
|
|
|
|
QListView::item:hover {
|
|
|
|
background: %3;
|
|
|
|
}
|
|
|
|
QListView::item:selected {
|
|
|
|
background: %4;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPushButton {
|
|
|
|
background: %5;
|
|
|
|
color: %1;
|
|
|
|
}
|
|
|
|
QPushButton:hover {
|
|
|
|
background: %3;
|
|
|
|
}
|
|
|
|
QPushButton:pressed {
|
|
|
|
background: %6;
|
|
|
|
}
|
|
|
|
|
|
|
|
chatterino--AccountSwitchPopup {
|
|
|
|
background: %7;
|
|
|
|
}
|
|
|
|
)"_s.arg(color(t->window.text), color(t->splits.header.background),
|
|
|
|
color(t->splits.header.focusedBackground), color(t->accent),
|
|
|
|
color(t->tabs.regular.backgrounds.regular),
|
|
|
|
color(t->tabs.selected.backgrounds.regular),
|
|
|
|
color(t->window.background)));
|
2017-12-19 02:16:01 +01:00
|
|
|
}
|
|
|
|
|
2019-09-01 14:13:44 +02:00
|
|
|
void AccountSwitchPopup::refresh()
|
2017-12-19 02:16:01 +01:00
|
|
|
{
|
2018-07-06 19:23:47 +02:00
|
|
|
this->ui_.accountSwitchWidget->refresh();
|
2017-12-19 02:16:01 +01:00
|
|
|
}
|
|
|
|
|
2019-09-01 14:13:44 +02:00
|
|
|
void AccountSwitchPopup::focusOutEvent(QFocusEvent *)
|
2017-12-19 02:16:01 +01:00
|
|
|
{
|
|
|
|
this->hide();
|
|
|
|
}
|
|
|
|
|
2019-09-01 14:13:44 +02:00
|
|
|
void AccountSwitchPopup::paintEvent(QPaintEvent *)
|
2018-01-17 02:22:57 +01:00
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
|
2018-05-25 13:02:14 +02:00
|
|
|
painter.setPen(QColor("#999"));
|
|
|
|
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
|
2018-01-17 02:22:57 +01:00
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2017-12-19 02:16:01 +01:00
|
|
|
} // namespace chatterino
|