fix: disable sortTabsAlphabetically when notebook layout locked (#6704)
This commit is contained in:
@@ -1247,6 +1247,8 @@ bool Notebook::shouldShowTab(const NotebookTab *tab) const
|
|||||||
|
|
||||||
void Notebook::sortTabsAlphabetically()
|
void Notebook::sortTabsAlphabetically()
|
||||||
{
|
{
|
||||||
|
assert(!this->isNotebookLayoutLocked() &&
|
||||||
|
"sortTabsAlphabetically called while notebook layout is locked");
|
||||||
std::ranges::sort(this->items_, [](const Item &a, const Item &b) {
|
std::ranges::sort(this->items_, [](const Item &a, const Item &b) {
|
||||||
const QString &lhs = a.tab->getTitle();
|
const QString &lhs = a.tab->getTitle();
|
||||||
const QString &rhs = b.tab->getTitle();
|
const QString &rhs = b.tab->getTitle();
|
||||||
@@ -1320,6 +1322,10 @@ SplitNotebook::SplitNotebook(Window *parent)
|
|||||||
|
|
||||||
this->sortTabsAlphabeticallyAction_ =
|
this->sortTabsAlphabeticallyAction_ =
|
||||||
new QAction("Sort Tabs Alphabetically", this);
|
new QAction("Sort Tabs Alphabetically", this);
|
||||||
|
if (this->isNotebookLayoutLocked())
|
||||||
|
{
|
||||||
|
this->sortTabsAlphabeticallyAction_->setEnabled(false);
|
||||||
|
}
|
||||||
QObject::connect(this->sortTabsAlphabeticallyAction_, &QAction::triggered,
|
QObject::connect(this->sortTabsAlphabeticallyAction_, &QAction::triggered,
|
||||||
[this] {
|
[this] {
|
||||||
this->sortTabsAlphabetically();
|
this->sortTabsAlphabetically();
|
||||||
@@ -1632,4 +1638,10 @@ void SplitNotebook::forEachSplit(const std::function<void(Split *)> &cb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitNotebook::setLockNotebookLayout(bool value)
|
||||||
|
{
|
||||||
|
this->Notebook::setLockNotebookLayout(value);
|
||||||
|
this->sortTabsAlphabeticallyAction_->setEnabled(!value);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
void setTabLocation(NotebookTabLocation location);
|
void setTabLocation(NotebookTabLocation location);
|
||||||
|
|
||||||
bool isNotebookLayoutLocked() const;
|
bool isNotebookLayoutLocked() const;
|
||||||
void setLockNotebookLayout(bool value);
|
virtual void setLockNotebookLayout(bool value);
|
||||||
|
|
||||||
virtual void addNotebookActionsToMenu(QMenu *menu);
|
virtual void addNotebookActionsToMenu(QMenu *menu);
|
||||||
|
|
||||||
@@ -275,6 +275,8 @@ private:
|
|||||||
// Main window on Windows has basically a duplicate of this in Window
|
// Main window on Windows has basically a duplicate of this in Window
|
||||||
PixmapButton *streamerModeIcon_{};
|
PixmapButton *streamerModeIcon_{};
|
||||||
void updateStreamerModeIcon();
|
void updateStreamerModeIcon();
|
||||||
|
|
||||||
|
void setLockNotebookLayout(bool value) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
Reference in New Issue
Block a user