feat: menu action to sort tabs alphabetically (#6551)

This commit is contained in:
teknsl
2025-10-25 18:13:12 +02:00
committed by GitHub
parent 7172503527
commit 1a6b4d6d36
3 changed files with 27 additions and 0 deletions
+1
View File
@@ -7,6 +7,7 @@
- Minor: Added setting for character limit of deleted messages. (#6491)
- Minor: Added link support to plugin message API. (#6386, #6527)
- Minor: Added a description for the logging option under moderation tab. (#6514)
- Minor: Added a menu action to sort tabs alphabetically. (#6551)
- Minor: Fixed "edit hotkey" dialog opening like a normal window. (#6540)
- Bugfix: Expose the "Extra extension IDs" setting on non-Windows systems too. (#6509)
- Bugfix: Fixed some commands and filters not working as expected in seach popups. (#6539)
+22
View File
@@ -32,6 +32,7 @@
#include <QUuid>
#include <QWidget>
#include <ranges>
#include <utility>
namespace chatterino {
@@ -1244,6 +1245,18 @@ bool Notebook::shouldShowTab(const NotebookTab *tab) const
return true;
}
void Notebook::sortTabsAlphabetically()
{
std::ranges::sort(this->items_, [](const Item &a, const Item &b) {
const QString &lhs = a.tab->getTitle();
const QString &rhs = b.tab->getTitle();
return lhs.compare(rhs, Qt::CaseInsensitive) < 0;
});
getApp()->getWindows()->queueSave();
this->performLayout(true);
}
SplitNotebook::SplitNotebook(Window *parent)
: Notebook(parent)
{
@@ -1305,6 +1318,13 @@ SplitNotebook::SplitNotebook(Window *parent)
});
tabVisibilityActionGroup->addAction(this->hideAllTabsAction);
this->sortTabsAlphabeticallyAction_ =
new QAction("Sort Tabs Alphabetically", this);
QObject::connect(this->sortTabsAlphabeticallyAction_, &QAction::triggered,
[this] {
this->sortTabsAlphabetically();
});
switch (getSettings()->tabVisibility.getEnum())
{
case NotebookTabVisibility::AllTabs: {
@@ -1393,6 +1413,8 @@ void SplitNotebook::addNotebookActionsToMenu(QMenu *menu)
{
Notebook::addNotebookActionsToMenu(menu);
menu->addAction(this->sortTabsAlphabeticallyAction_);
auto *submenu = menu->addMenu("Tab visibility");
submenu->addAction(this->showAllTabsAction);
submenu->addAction(this->onlyShowLiveTabsAction);
+4
View File
@@ -122,6 +122,8 @@ public:
// Update layout and tab visibility
void refresh();
void sortTabsAlphabetically();
protected:
bool getShowTabs() const;
void setShowTabs(bool value);
@@ -264,6 +266,8 @@ protected:
void showEvent(QShowEvent *event) override;
private:
QAction *sortTabsAlphabeticallyAction_;
void addCustomButtons();
pajlada::Signals::SignalHolder signalHolder_;