mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Add the ability to lock NotebookTab layout (#3627)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
8247ce72fb
commit
554313d645
|
@ -60,6 +60,7 @@
|
|||
- Minor: Make Tab Layout setting only accept predefined values (#3564)
|
||||
- Minor: Added librewolf, icecat, and waterfox incognito support. (#3588)
|
||||
- Minor: Updated to Emoji v14.0 (#3612)
|
||||
- Minor: Add support for locking tab arrangement (#3627)
|
||||
- Bugfix: Fix Split Input hotkeys not being available when input is hidden (#3362)
|
||||
- Bugfix: Fixed colored usernames sometimes not working. (#3170)
|
||||
- Bugfix: Restored ability to send duplicate `/me` messages. (#3166)
|
||||
|
|
|
@ -386,6 +386,7 @@ public:
|
|||
BoolSetting askOnImageUpload = {"/misc/askOnImageUpload", true};
|
||||
BoolSetting informOnTabVisibilityToggle = {"/misc/askOnTabVisibilityToggle",
|
||||
true};
|
||||
BoolSetting lockNotebookLayout = {"/misc/lockNotebookLayout", false};
|
||||
|
||||
/// Debug
|
||||
BoolSetting showUnhandledIrcMessages = {"/debug/showUnhandledIrcMessages",
|
||||
|
|
|
@ -34,12 +34,21 @@ Notebook::Notebook(QWidget *parent)
|
|||
|
||||
this->addButton_->setHidden(true);
|
||||
|
||||
this->menu_.addAction(
|
||||
"Toggle visibility of tabs",
|
||||
[this]() {
|
||||
this->setShowTabs(!this->getShowTabs());
|
||||
},
|
||||
QKeySequence("Ctrl+U"));
|
||||
this->lockNotebookLayoutAction_ = new QAction("Lock Tab Layout", this);
|
||||
|
||||
// Load lock notebook layout state from settings
|
||||
this->setLockNotebookLayout(getSettings()->lockNotebookLayout.getValue());
|
||||
|
||||
this->lockNotebookLayoutAction_->setCheckable(true);
|
||||
this->lockNotebookLayoutAction_->setChecked(this->lockNotebookLayout_);
|
||||
|
||||
// Update lockNotebookLayout_ value anytime the user changes the checkbox state
|
||||
QObject::connect(this->lockNotebookLayoutAction_, &QAction::triggered,
|
||||
[this](bool value) {
|
||||
this->setLockNotebookLayout(value);
|
||||
});
|
||||
|
||||
this->addNotebookActionsToMenu(&this->menu_);
|
||||
}
|
||||
|
||||
NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
|
||||
|
@ -316,6 +325,11 @@ QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth)
|
|||
|
||||
void Notebook::rearrangePage(QWidget *page, int index)
|
||||
{
|
||||
if (this->isNotebookLayoutLocked())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Queue up save because: Tab rearranged
|
||||
getApp()->windows->queueSave();
|
||||
|
||||
|
@ -673,6 +687,30 @@ void Notebook::paintEvent(QPaintEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
bool Notebook::isNotebookLayoutLocked() const
|
||||
{
|
||||
return this->lockNotebookLayout_;
|
||||
}
|
||||
|
||||
void Notebook::setLockNotebookLayout(bool value)
|
||||
{
|
||||
this->lockNotebookLayout_ = value;
|
||||
this->lockNotebookLayoutAction_->setChecked(value);
|
||||
getSettings()->lockNotebookLayout.setValue(value);
|
||||
}
|
||||
|
||||
void Notebook::addNotebookActionsToMenu(QMenu *menu)
|
||||
{
|
||||
menu->addAction(
|
||||
"Toggle visibility of tabs",
|
||||
[this]() {
|
||||
this->setShowTabs(!this->getShowTabs());
|
||||
},
|
||||
QKeySequence("Ctrl+U"));
|
||||
|
||||
menu->addAction(this->lockNotebookLayoutAction_);
|
||||
}
|
||||
|
||||
NotebookButton *Notebook::getAddButton()
|
||||
{
|
||||
return this->addButton_;
|
||||
|
|
|
@ -60,6 +60,11 @@ public:
|
|||
|
||||
void setTabDirection(NotebookTabDirection direction);
|
||||
|
||||
bool isNotebookLayoutLocked() const;
|
||||
void setLockNotebookLayout(bool value);
|
||||
|
||||
void addNotebookActionsToMenu(QMenu *menu);
|
||||
|
||||
protected:
|
||||
virtual void scaleChangedEvent(float scale_) override;
|
||||
virtual void resizeEvent(QResizeEvent *) override;
|
||||
|
@ -98,7 +103,9 @@ private:
|
|||
bool showTabs_ = true;
|
||||
bool showAddButton_ = false;
|
||||
int lineOffset_ = 20;
|
||||
bool lockNotebookLayout_ = false;
|
||||
NotebookTabDirection tabDirection_ = NotebookTabDirection::Horizontal;
|
||||
QAction *lockNotebookLayoutAction_;
|
||||
};
|
||||
|
||||
class SplitNotebook : public Notebook
|
||||
|
|
|
@ -89,12 +89,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||
|
||||
this->menu_.addSeparator();
|
||||
|
||||
this->menu_.addAction(
|
||||
"Toggle visibility of tabs",
|
||||
[this]() {
|
||||
this->notebook_->setShowTabs(!this->notebook_->getShowTabs());
|
||||
},
|
||||
QKeySequence("Ctrl+U"));
|
||||
this->notebook_->addNotebookActionsToMenu(&this->menu_);
|
||||
}
|
||||
|
||||
void NotebookTab::showRenameDialog()
|
||||
|
|
Loading…
Reference in a new issue