Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
1f480e36
Commit
1f480e36
authored
Mar 14, 2021
by
Ahmad Samir
Committed by
Kurt Hindenburg
Mar 19, 2021
Browse files
Always sort the profiles by name in 'File -> New Tab'
With the Fallback profile always sorted at the top.
parent
bc41efd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/profile/ProfileList.cpp
View file @
1f480e36
...
...
@@ -17,6 +17,8 @@
// Konsole
#include "ProfileManager.h"
#include <algorithm>
using
Konsole
::
Profile
;
using
Konsole
::
ProfileList
;
...
...
@@ -88,7 +90,7 @@ void ProfileList::updateAction(QAction* action , Profile::Ptr profile)
action
->
setText
(
profile
->
name
());
action
->
setIcon
(
QIcon
::
fromTheme
(
profile
->
icon
()));
Q_EMIT
actionsChanged
(
_group
->
actions
());
Q_EMIT
actionsChanged
(
actions
());
}
void
ProfileList
::
shortcutChanged
(
const
Profile
::
Ptr
&
profile
,
const
QKeySequence
&
sequence
)
{
...
...
@@ -116,7 +118,7 @@ void ProfileList::syncWidgetActions(QWidget* widget, bool sync)
widget
->
removeAction
(
currentAction
);
}
widget
->
addActions
(
_group
->
actions
());
widget
->
addActions
(
actions
());
}
void
ProfileList
::
addShortcutAction
(
const
Profile
::
Ptr
&
profile
)
...
...
@@ -135,7 +137,7 @@ void ProfileList::addShortcutAction(const Profile::Ptr &profile)
for
(
QWidget
*
widget
:
qAsConst
(
_registeredWidgets
))
{
widget
->
addAction
(
action
);
}
Q_EMIT
actionsChanged
(
_group
->
actions
());
Q_EMIT
actionsChanged
(
actions
());
updateEmptyAction
();
}
...
...
@@ -149,7 +151,7 @@ void ProfileList::removeShortcutAction(const Profile::Ptr &profile)
for
(
QWidget
*
widget
:
qAsConst
(
_registeredWidgets
))
{
widget
->
removeAction
(
action
);
}
Q_EMIT
actionsChanged
(
_group
->
actions
());
Q_EMIT
actionsChanged
(
actions
());
}
updateEmptyAction
();
}
...
...
@@ -161,6 +163,20 @@ void ProfileList::triggered(QAction* action)
QList
<
QAction
*>
ProfileList
::
actions
()
{
return
_group
->
actions
();
}
auto
actionsList
=
_group
->
actions
();
std
::
sort
(
actionsList
.
begin
(),
actionsList
.
end
(),
[](
QAction
*
a
,
QAction
*
b
)
{
// Remove '&', which is added by KAcceleratorManager
const
QString
aName
=
a
->
text
().
remove
(
QLatin1Char
(
'&'
));
const
QString
bName
=
b
->
text
().
remove
(
QLatin1Char
(
'&'
));
if
(
aName
==
QLatin1String
(
"Default"
))
{
return
true
;
}
else
if
(
bName
==
QLatin1String
(
"Default"
))
{
return
false
;
}
return
QString
::
localeAwareCompare
(
aName
,
bName
)
<
0
;
});
return
actionsList
;
}
src/profile/ProfileList.h
View file @
1f480e36
...
...
@@ -48,9 +48,10 @@ public:
ProfileList
(
bool
addShortcuts
,
QObject
*
parent
);
/**
* Returns a list of actions representing profiles
* Returns a list of actions representing profiles, sorted by profile
* name.
*
* The user-data associated with each action is the corresponding profile
* The user-data associated with each action is the corresponding profile
.
*/
QList
<
QAction
*>
actions
();
...
...
Ahmad Samir
@ahmadsamir
mentioned in commit
cc7fc4f3
·
Mar 23, 2021
mentioned in commit
cc7fc4f3
mentioned in commit cc7fc4f3d299edd9773c063f034610e5e205dc9a
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment