mirror-chatterino2/src/widgets/AccountSwitchPopup.cpp

61 lines
1.5 KiB
C++
Raw Normal View History

#include "widgets/AccountSwitchPopup.hpp"
2018-06-26 15:11:45 +02:00
#include "widgets/dialogs/SettingsDialog.hpp"
#include <QHBoxLayout>
#include <QLayout>
#include <QPainter>
#include <QPushButton>
#include <QVBoxLayout>
namespace chatterino {
AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
2019-09-08 21:45:46 +02:00
: BaseWindow({BaseWindow::TopMost, BaseWindow::Frameless}, 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, []() {
SettingsDialog::showDialog(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