fix: disable sortTabsAlphabetically when notebook layout locked (#6704)

This commit is contained in:
2026-01-05 04:17:21 +05:30
committed by ruiny
parent b7b592098f
commit e0730ed712
2 changed files with 15 additions and 1 deletions
+12
View File
@@ -1247,6 +1247,8 @@ bool Notebook::shouldShowTab(const NotebookTab *tab) const
void Notebook::sortTabsAlphabetically()
{
assert(!this->isNotebookLayoutLocked() &&
"sortTabsAlphabetically called while notebook layout is locked");
std::ranges::sort(this->items_, [](const Item &a, const Item &b) {
const QString &lhs = a.tab->getTitle();
const QString &rhs = b.tab->getTitle();
@@ -1320,6 +1322,10 @@ SplitNotebook::SplitNotebook(Window *parent)
this->sortTabsAlphabeticallyAction_ =
new QAction("Sort Tabs Alphabetically", this);
if (this->isNotebookLayoutLocked())
{
this->sortTabsAlphabeticallyAction_->setEnabled(false);
}
QObject::connect(this->sortTabsAlphabeticallyAction_, &QAction::triggered,
[this] {
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
+3 -1
View File
@@ -115,7 +115,7 @@ public:
void setTabLocation(NotebookTabLocation location);
bool isNotebookLayoutLocked() const;
void setLockNotebookLayout(bool value);
virtual void setLockNotebookLayout(bool value);
virtual void addNotebookActionsToMenu(QMenu *menu);
@@ -275,6 +275,8 @@ private:
// Main window on Windows has basically a duplicate of this in Window
PixmapButton *streamerModeIcon_{};
void updateStreamerModeIcon();
void setLockNotebookLayout(bool value) override;
};
} // namespace chatterino