mirror-chatterino2/src/widgets/AccountSwitchPopup.cpp

63 lines
1.6 KiB
C++
Raw Normal View History

#include "widgets/AccountSwitchPopup.hpp"
#include "widgets/AccountSwitchWidget.hpp"
2018-06-26 15:11:45 +02:00
#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);
2018-07-06 19:23:47 +02:00
this->ui_.accountSwitchWidget = new AccountSwitchWidget(this);
QVBoxLayout *vbox = new QVBoxLayout(this);
2018-07-06 19:23:47 +02:00
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);
});
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);
}
void AccountSwitchPopup::refresh()
{
2018-07-06 19:23:47 +02:00
this->ui_.accountSwitchWidget->refresh();
}
void AccountSwitchPopup::focusOutEvent(QFocusEvent *)
{
this->hide();
}
void AccountSwitchPopup::paintEvent(QPaintEvent *)
{
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);
}
} // namespace chatterino