mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed "hide settings" and "hide user" settings on linux/mac
This commit is contained in:
parent
66dab0a6b7
commit
bd5f9853f9
2 changed files with 29 additions and 32 deletions
|
@ -311,32 +311,13 @@ void Notebook::performLayout(bool animated)
|
|||
int x = xStart, y = 0;
|
||||
float scale = this->getScale();
|
||||
|
||||
// bool customFrame = this->parentWindow->hasCustomWindowFrame();
|
||||
|
||||
// bool customFrame = false;
|
||||
|
||||
// if (!this->showButtons || app->settings->hidePreferencesButton || customFrame) {
|
||||
// this->settingsButton.hide();
|
||||
// } else {
|
||||
// this->settingsButton.show();
|
||||
// x += settingsButton.width();
|
||||
// }
|
||||
// if (!this->showButtons || app->settings->hideUserButton || customFrame) {
|
||||
// this->userButton.hide();
|
||||
// } else {
|
||||
// this->userButton.move(x, 0);
|
||||
// this->userButton.show();
|
||||
// x += userButton.width();
|
||||
// }
|
||||
|
||||
// if (customFrame || !this->showButtons ||
|
||||
// (app->settings->hideUserButton && app->settings->hidePreferencesButton)) {
|
||||
// x += (int)(scale * 2);
|
||||
// }
|
||||
|
||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
||||
int h = int(NOTEBOOK_TAB_HEIGHT * this->getScale());
|
||||
|
||||
for (auto *btn : this->customButtons) {
|
||||
if (!btn->isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
btn->setFixedSize(h, h);
|
||||
btn->move(x, 0);
|
||||
x += h;
|
||||
|
@ -346,8 +327,6 @@ void Notebook::performLayout(bool animated)
|
|||
bool first = true;
|
||||
|
||||
for (auto i = this->items.begin(); i != this->items.end(); i++) {
|
||||
// int yOffset = i->tab->isSelected() ? 0 : 1;
|
||||
|
||||
bool wrap =
|
||||
!first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x +
|
||||
i->tab->width()) > width();
|
||||
|
@ -430,6 +409,8 @@ NotebookTab *Notebook::getTabFromPage(QWidget *page)
|
|||
SplitNotebook::SplitNotebook(Window *parent)
|
||||
: Notebook(parent)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->connect(this->getAddButton(), &NotebookButton::clicked,
|
||||
[this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); });
|
||||
|
||||
|
@ -439,16 +420,28 @@ SplitNotebook::SplitNotebook(Window *parent)
|
|||
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->setVisible(!app->settings->hidePreferencesButton.getValue());
|
||||
userBtn->setVisible(!app->settings->hideUserButton.getValue());
|
||||
|
||||
app->settings->hidePreferencesButton.connect(
|
||||
[this, settingsBtn](bool hide, auto) {
|
||||
settingsBtn->setVisible(!hide);
|
||||
this->performLayout(true);
|
||||
},
|
||||
this->uniqueConnections);
|
||||
|
||||
app->settings->hideUserButton.connect(
|
||||
[this, userBtn](bool hide, auto) {
|
||||
userBtn->setVisible(!hide);
|
||||
this->performLayout(true);
|
||||
},
|
||||
this->uniqueConnections);
|
||||
|
||||
settingsBtn->icon = NotebookButton::IconSettings;
|
||||
userBtn->icon = NotebookButton::IconUser;
|
||||
|
||||
QObject::connect(settingsBtn, &NotebookButton::clicked,
|
||||
[this] { getApp()->windows->showSettingsDialog(); });
|
||||
[] { getApp()->windows->showSettingsDialog(); });
|
||||
|
||||
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
|
||||
getApp()->windows->showAccountSelectPopup(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "pajlada/signals/signal.hpp"
|
||||
#include "widgets/basewidget.hpp"
|
||||
#include "widgets/helper/notebookbutton.hpp"
|
||||
#include "widgets/helper/notebooktab.hpp"
|
||||
|
@ -80,13 +81,16 @@ private:
|
|||
NotebookTab *getTabFromPage(QWidget *page);
|
||||
};
|
||||
|
||||
class SplitNotebook : public Notebook
|
||||
class SplitNotebook : public Notebook, pajlada::Signals::SignalHolder
|
||||
{
|
||||
public:
|
||||
SplitNotebook(Window *parent);
|
||||
|
||||
SplitContainer *addPage(bool select = false);
|
||||
SplitContainer *getOrAddSelectedPage();
|
||||
|
||||
private:
|
||||
std::vector<pajlada::Signals::ScopedConnection> uniqueConnections;
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
|
|
Loading…
Reference in a new issue