diff --git a/CHANGELOG.md b/CHANGELOG.md index add85f89..5a0fd211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Bugfix: Added `desktop-entry` hint to Linux notifications. (#6615) - Bugfix: Fixed CMD + DELETE behavior in the user notes editing dialog for macOS. (#6676) - Bugfix: Fixed a potential crash when closing Chatterino with a slow network connection. (#6645) +- Bugfix: Disable "Sort Tabs Alphabetically" action when notebook layout is locked. (#6710) - Dev: Update release documentation. (#6498) - Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493) - Dev: Remove unused QTextCodec includes. (#6487) diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index 0edcf6d9..f33084db 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -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 &cb) } } +void SplitNotebook::setLockNotebookLayout(bool value) +{ + Notebook::setLockNotebookLayout(value); + this->sortTabsAlphabeticallyAction_->setEnabled(!value); +} + } // namespace chatterino diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index 01e158ba..8f020641 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -115,15 +115,13 @@ public: void setTabLocation(NotebookTabLocation location); bool isNotebookLayoutLocked() const; - void setLockNotebookLayout(bool value); + virtual void setLockNotebookLayout(bool value); virtual void addNotebookActionsToMenu(QMenu *menu); // Update layout and tab visibility void refresh(); - void sortTabsAlphabetically(); - protected: bool getShowTabs() const; void setShowTabs(bool value); @@ -171,6 +169,8 @@ protected: void performLayout(bool animate = false); + void sortTabsAlphabetically(); + private: struct LayoutContext { int left = 0; @@ -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