Keyboard shortcuts and available actions are now sorted alphabetically according to activated locale. (#110).

This commit is contained in:
Martin Rotter 2015-05-06 09:35:57 +02:00
parent 63711b5db2
commit f5675aeb38
3 changed files with 14 additions and 2 deletions

View file

@ -65,8 +65,9 @@ void DynamicShortcutsWidget::updateShortcuts() {
}
}
void DynamicShortcutsWidget::populate(const QList<QAction*> actions) {
void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
m_actionBindings.clear();
qSort(actions.begin(), actions.end(), DynamicShortcutsWidget::lessThan);
int row_id = 0;
@ -104,3 +105,7 @@ void DynamicShortcutsWidget::populate(const QList<QAction*> actions) {
m_layout->setRowStretch(row_id, 1);
m_layout->setColumnStretch(1, 1);
}
bool DynamicShortcutsWidget::lessThan(QAction *lhs, QAction *rhs) {
return QString::localeAwareCompare(lhs->text().replace("&", ""), rhs->text().replace("&", "")) < 0;
}

View file

@ -48,7 +48,10 @@ class DynamicShortcutsWidget : public QWidget {
// NOTE: This gets initial shortcut for each action from its properties, NOT from
// the application settings, so shortcuts from settings need to be
// assigned to actions before calling this method.
void populate(const QList<QAction*> actions);
void populate(QList<QAction*> actions);
private:
static bool lessThan(QAction *lhs, QAction *rhs);
private:
QGridLayout *m_layout;

View file

@ -95,6 +95,8 @@ void ToolBarEditor::loadFromToolBar(BaseToolBar *tool_bar) {
action_item->setToolTip(action->toolTip());
}
}
m_ui->m_listAvailableActions->sortItems(Qt::AscendingOrder);
}
updateActionsAvailability();
@ -210,6 +212,7 @@ void ToolBarEditor::deleteSelectedAction() {
m_ui->m_listAvailableActions->insertItem(
m_ui->m_listAvailableActions->currentRow() + 1,
m_ui->m_listActivatedActions->takeItem(m_ui->m_listActivatedActions->row(selected_item)));
m_ui->m_listAvailableActions->sortItems(Qt::AscendingOrder);
m_ui->m_listAvailableActions->setCurrentRow(m_ui->m_listAvailableActions->currentRow() + 1);
}
}
@ -227,5 +230,6 @@ void ToolBarEditor::deleteAllActions() {
}
}
m_ui->m_listAvailableActions->sortItems(Qt::AscendingOrder);
updateActionsAvailability();
}