fixed "hide settings" and "hide user" settings on linux/mac

This commit is contained in:
fourtf 2018-06-04 15:36:48 +02:00
parent 66dab0a6b7
commit bd5f9853f9
2 changed files with 29 additions and 32 deletions

View file

@ -311,32 +311,13 @@ void Notebook::performLayout(bool animated)
int x = xStart, y = 0; int x = xStart, y = 0;
float scale = this->getScale(); float scale = this->getScale();
// bool customFrame = this->parentWindow->hasCustomWindowFrame(); int h = int(NOTEBOOK_TAB_HEIGHT * this->getScale());
// 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();
for (auto *btn : this->customButtons) { for (auto *btn : this->customButtons) {
if (!btn->isVisible()) {
continue;
}
btn->setFixedSize(h, h); btn->setFixedSize(h, h);
btn->move(x, 0); btn->move(x, 0);
x += h; x += h;
@ -346,8 +327,6 @@ void Notebook::performLayout(bool animated)
bool first = true; bool first = true;
for (auto i = this->items.begin(); i != this->items.end(); i++) { for (auto i = this->items.begin(); i != this->items.end(); i++) {
// int yOffset = i->tab->isSelected() ? 0 : 1;
bool wrap = bool wrap =
!first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x + !first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x +
i->tab->width()) > width(); i->tab->width()) > width();
@ -430,6 +409,8 @@ NotebookTab *Notebook::getTabFromPage(QWidget *page)
SplitNotebook::SplitNotebook(Window *parent) SplitNotebook::SplitNotebook(Window *parent)
: Notebook(parent) : Notebook(parent)
{ {
auto app = getApp();
this->connect(this->getAddButton(), &NotebookButton::clicked, this->connect(this->getAddButton(), &NotebookButton::clicked,
[this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); }); [this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); });
@ -439,16 +420,28 @@ SplitNotebook::SplitNotebook(Window *parent)
auto *settingsBtn = this->addCustomButton(); auto *settingsBtn = this->addCustomButton();
auto *userBtn = this->addCustomButton(); auto *userBtn = this->addCustomButton();
// app->settings->hidePreferencesButton.connectSimple( settingsBtn->setVisible(!app->settings->hidePreferencesButton.getValue());
// [this](bool hide) { this->performLayout(); }); userBtn->setVisible(!app->settings->hideUserButton.getValue());
// app->settings->hideUserButton.connectSimple([this](auto) { this->performLayout();
// }); 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; settingsBtn->icon = NotebookButton::IconSettings;
userBtn->icon = NotebookButton::IconUser; userBtn->icon = NotebookButton::IconUser;
QObject::connect(settingsBtn, &NotebookButton::clicked, QObject::connect(settingsBtn, &NotebookButton::clicked,
[this] { getApp()->windows->showSettingsDialog(); }); [] { getApp()->windows->showSettingsDialog(); });
QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] { QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] {
getApp()->windows->showAccountSelectPopup( getApp()->windows->showAccountSelectPopup(

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "pajlada/signals/signal.hpp"
#include "widgets/basewidget.hpp" #include "widgets/basewidget.hpp"
#include "widgets/helper/notebookbutton.hpp" #include "widgets/helper/notebookbutton.hpp"
#include "widgets/helper/notebooktab.hpp" #include "widgets/helper/notebooktab.hpp"
@ -80,13 +81,16 @@ private:
NotebookTab *getTabFromPage(QWidget *page); NotebookTab *getTabFromPage(QWidget *page);
}; };
class SplitNotebook : public Notebook class SplitNotebook : public Notebook, pajlada::Signals::SignalHolder
{ {
public: public:
SplitNotebook(Window *parent); SplitNotebook(Window *parent);
SplitContainer *addPage(bool select = false); SplitContainer *addPage(bool select = false);
SplitContainer *getOrAddSelectedPage(); SplitContainer *getOrAddSelectedPage();
private:
std::vector<pajlada::Signals::ScopedConnection> uniqueConnections;
}; };
} // namespace widgets } // namespace widgets