mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
show settings and user button when it's not available in the window
frame
This commit is contained in:
parent
8b3fb691a7
commit
67e580059c
|
@ -251,8 +251,6 @@ void Notebook::scaleChangedEvent(float scale)
|
|||
{
|
||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
||||
|
||||
// this->settingsButton.setFixedSize(h, h);
|
||||
// this->userButton.setFixedSize(h, h);
|
||||
this->addButton.setFixedSize(h, h);
|
||||
|
||||
for (auto &i : this->items) {
|
||||
|
@ -297,6 +295,14 @@ void Notebook::performLayout(bool animated)
|
|||
// x += (int)(scale * 2);
|
||||
// }
|
||||
|
||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
||||
|
||||
for (auto *btn : this->customButtons) {
|
||||
btn->setFixedSize(h, h);
|
||||
btn->move(x, 0);
|
||||
x += h;
|
||||
}
|
||||
|
||||
int tabHeight = static_cast<int>(NOTEBOOK_TAB_HEIGHT * scale);
|
||||
bool first = true;
|
||||
|
||||
|
@ -361,6 +367,16 @@ NotebookButton *Notebook::getAddButton()
|
|||
return &this->addButton;
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::addCustomButton()
|
||||
{
|
||||
NotebookButton *btn = new NotebookButton(this);
|
||||
|
||||
this->customButtons.push_back(btn);
|
||||
|
||||
this->performLayout();
|
||||
return btn;
|
||||
}
|
||||
|
||||
NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
||||
{
|
||||
for (auto &it : this->items) {
|
||||
|
@ -372,11 +388,34 @@ NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SplitNotebook::SplitNotebook(QWidget *parent)
|
||||
SplitNotebook::SplitNotebook(Window *parent)
|
||||
: Notebook(parent)
|
||||
{
|
||||
this->connect(this->getAddButton(), &NotebookButton::clicked,
|
||||
[this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); });
|
||||
|
||||
bool customFrame = parent->hasCustomWindowFrame();
|
||||
|
||||
if (!customFrame) {
|
||||
auto *settingsBtn = this->addCustomButton();
|
||||
auto *userBtn = this->addCustomButton();
|
||||
|
||||
// app->settings->hidePreferencesButton.connectSimple(
|
||||
// [this](bool hide) { this->performLayout(); });
|
||||
// app->settings->hideUserButton.connectSimple([this](auto) { this->performLayout();
|
||||
// });
|
||||
|
||||
settingsBtn->icon = NotebookButton::IconSettings;
|
||||
userBtn->icon = NotebookButton::IconUser;
|
||||
|
||||
QObject::connect(settingsBtn, &NotebookButton::clicked,
|
||||
[this] { getApp()->windows->showSettingsDialog(); });
|
||||
|
||||
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
|
||||
getApp()->windows->showAccountSelectPopup(
|
||||
this->mapToGlobal(userBtn->rect().bottomRight()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SplitContainer *SplitNotebook::addPage(bool select)
|
||||
|
|
|
@ -53,6 +53,7 @@ protected:
|
|||
virtual void paintEvent(QPaintEvent *) override;
|
||||
|
||||
NotebookButton *getAddButton();
|
||||
NotebookButton *addCustomButton();
|
||||
|
||||
private:
|
||||
struct Item {
|
||||
|
@ -64,6 +65,7 @@ private:
|
|||
QWidget *selectedPage = nullptr;
|
||||
|
||||
NotebookButton addButton;
|
||||
std::vector<NotebookButton *> customButtons;
|
||||
|
||||
bool allowUserTabManagement = false;
|
||||
bool showAddButton = false;
|
||||
|
@ -75,7 +77,7 @@ private:
|
|||
class SplitNotebook : public Notebook
|
||||
{
|
||||
public:
|
||||
SplitNotebook(QWidget *parent);
|
||||
SplitNotebook(Window *parent);
|
||||
|
||||
SplitContainer *addPage(bool select = false);
|
||||
SplitContainer *getOrAddSelectedPage();
|
||||
|
|
Loading…
Reference in a new issue