mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
1043f9f803
* refactor: remove unnecessary includes in headers * fix: formatting * chore: changelog * fix: scrollbar * fix: suggestions and old appbase remains * fix: suggestion * fix: missing Qt forward declarations * fix: another qt include * fix: includes for precompiled-headers=off * Add missing `<memory>` includes * Add missing `#pragma once` * Fix tests Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
#include "widgets/AccountSwitchPopup.hpp"
|
|
|
|
#include "widgets/AccountSwitchWidget.hpp"
|
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
|
|
|
#include <QLayout>
|
|
#include <QPainter>
|
|
#include <QPushButton>
|
|
|
|
namespace chatterino {
|
|
|
|
AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
|
: BaseWindow({BaseWindow::TopMost, BaseWindow::Frameless,
|
|
BaseWindow::DisableLayoutSave},
|
|
parent)
|
|
{
|
|
#ifdef Q_OS_LINUX
|
|
this->setWindowFlag(Qt::Popup);
|
|
#endif
|
|
|
|
this->setContentsMargins(0, 0, 0, 0);
|
|
|
|
this->ui_.accountSwitchWidget = new AccountSwitchWidget(this);
|
|
QVBoxLayout *vbox = new QVBoxLayout(this);
|
|
this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus);
|
|
vbox->addWidget(this->ui_.accountSwitchWidget);
|
|
|
|
auto hbox = new QHBoxLayout();
|
|
auto manageAccountsButton = new QPushButton(this);
|
|
manageAccountsButton->setText("Manage Accounts");
|
|
manageAccountsButton->setFocusPolicy(Qt::NoFocus);
|
|
hbox->addWidget(manageAccountsButton);
|
|
vbox->addLayout(hbox);
|
|
|
|
connect(manageAccountsButton, &QPushButton::clicked, [this]() {
|
|
SettingsDialog::showDialog(this, SettingsDialogPreference::Accounts);
|
|
});
|
|
|
|
this->getLayoutContainer()->setLayout(vbox);
|
|
|
|
this->setScaleIndependantSize(200, 200);
|
|
}
|
|
|
|
void AccountSwitchPopup::refresh()
|
|
{
|
|
this->ui_.accountSwitchWidget->refresh();
|
|
}
|
|
|
|
void AccountSwitchPopup::focusOutEvent(QFocusEvent *)
|
|
{
|
|
this->hide();
|
|
}
|
|
|
|
void AccountSwitchPopup::paintEvent(QPaintEvent *)
|
|
{
|
|
QPainter painter(this);
|
|
|
|
painter.setPen(QColor("#999"));
|
|
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
|
|
}
|
|
|
|
} // namespace chatterino
|