feat: menu action to sort tabs alphabetically (#6551)
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- Minor: Added setting for character limit of deleted messages. (#6491)
|
- Minor: Added setting for character limit of deleted messages. (#6491)
|
||||||
- Minor: Added link support to plugin message API. (#6386, #6527)
|
- 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 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)
|
- 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: 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)
|
- Bugfix: Fixed some commands and filters not working as expected in seach popups. (#6539)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
@@ -1244,6 +1245,18 @@ bool Notebook::shouldShowTab(const NotebookTab *tab) const
|
|||||||
return true;
|
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)
|
SplitNotebook::SplitNotebook(Window *parent)
|
||||||
: Notebook(parent)
|
: Notebook(parent)
|
||||||
{
|
{
|
||||||
@@ -1305,6 +1318,13 @@ SplitNotebook::SplitNotebook(Window *parent)
|
|||||||
});
|
});
|
||||||
tabVisibilityActionGroup->addAction(this->hideAllTabsAction);
|
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())
|
switch (getSettings()->tabVisibility.getEnum())
|
||||||
{
|
{
|
||||||
case NotebookTabVisibility::AllTabs: {
|
case NotebookTabVisibility::AllTabs: {
|
||||||
@@ -1393,6 +1413,8 @@ void SplitNotebook::addNotebookActionsToMenu(QMenu *menu)
|
|||||||
{
|
{
|
||||||
Notebook::addNotebookActionsToMenu(menu);
|
Notebook::addNotebookActionsToMenu(menu);
|
||||||
|
|
||||||
|
menu->addAction(this->sortTabsAlphabeticallyAction_);
|
||||||
|
|
||||||
auto *submenu = menu->addMenu("Tab visibility");
|
auto *submenu = menu->addMenu("Tab visibility");
|
||||||
submenu->addAction(this->showAllTabsAction);
|
submenu->addAction(this->showAllTabsAction);
|
||||||
submenu->addAction(this->onlyShowLiveTabsAction);
|
submenu->addAction(this->onlyShowLiveTabsAction);
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ public:
|
|||||||
// Update layout and tab visibility
|
// Update layout and tab visibility
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
|
void sortTabsAlphabetically();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool getShowTabs() const;
|
bool getShowTabs() const;
|
||||||
void setShowTabs(bool value);
|
void setShowTabs(bool value);
|
||||||
@@ -264,6 +266,8 @@ protected:
|
|||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QAction *sortTabsAlphabeticallyAction_;
|
||||||
|
|
||||||
void addCustomButtons();
|
void addCustomButtons();
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder signalHolder_;
|
pajlada::Signals::SignalHolder signalHolder_;
|
||||||
|
|||||||
Reference in New Issue
Block a user