2017-12-19 02:16:01 +01:00
|
|
|
#include "widgets/accountswitchpopupwidget.hpp"
|
|
|
|
#include "debug/log.hpp"
|
|
|
|
#include "widgets/settingsdialog.hpp"
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
namespace widgets {
|
|
|
|
|
|
|
|
AccountSwitchPopupWidget::AccountSwitchPopupWidget(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2018-06-24 13:10:29 +02:00
|
|
|
this->setWindowFlag(Qt::FramelessWindowHint);
|
|
|
|
this->setWindowFlag(Qt::WindowStaysOnTopHint);
|
2017-12-19 02:16:01 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// vbox->setSizeConstraint(QLayout::SetMinimumSize);
|
|
|
|
|
|
|
|
auto hbox = new QHBoxLayout();
|
|
|
|
auto manageAccountsButton = new QPushButton(this);
|
|
|
|
manageAccountsButton->setText("Manage Accounts");
|
|
|
|
hbox->addWidget(manageAccountsButton);
|
|
|
|
vbox->addLayout(hbox);
|
|
|
|
|
|
|
|
connect(manageAccountsButton, &QPushButton::clicked, []() {
|
|
|
|
SettingsDialog::showDialog(SettingsDialog::PreferredTab::Accounts); //
|
|
|
|
});
|
|
|
|
|
|
|
|
this->setLayout(vbox);
|
2018-05-25 13:02:14 +02:00
|
|
|
|
|
|
|
// this->setStyleSheet("background: #333");
|
2017-12-19 02:16:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccountSwitchPopupWidget::refresh()
|
|
|
|
{
|
|
|
|
this->ui.accountSwitchWidget->refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccountSwitchPopupWidget::focusOutEvent(QFocusEvent *)
|
|
|
|
{
|
|
|
|
this->hide();
|
|
|
|
}
|
|
|
|
|
2018-05-25 13:02:14 +02:00
|
|
|
void AccountSwitchPopupWidget::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 widgets
|
|
|
|
} // namespace chatterino
|