2019-09-01 14:13:44 +02:00
|
|
|
#include "widgets/AccountSwitchPopup.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "debug/Log.hpp"
|
2018-06-26 15:11:45 +02:00
|
|
|
#include "widgets/dialogs/SettingsDialog.hpp"
|
2017-12-19 02:16:01 +01:00
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLayout>
|
2018-01-17 02:22:57 +01:00
|
|
|
#include <QPainter>
|
2017-12-19 02:16:01 +01:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2019-09-01 14:13:44 +02:00
|
|
|
AccountSwitchPopup::AccountSwitchPopup(QWidget *parent)
|
2019-09-08 12:43:12 +02:00
|
|
|
: BaseWindow(parent,
|
|
|
|
BaseWindow::Flags(BaseWindow::TopMost | BaseWindow::Frameless))
|
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
|
|
|
|
|
|
|
// vbox->setSizeConstraint(QLayout::SetMinimumSize);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
connect(manageAccountsButton, &QPushButton::clicked, []() {
|
2018-10-21 15:32:28 +02:00
|
|
|
SettingsDialog::showDialog(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);
|
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
|