Support adding multiple shortcuts to the same action

In the settings UI. Moves the "Reset" button for individual
actions up to under the list, next to the "Reset All" button.

Users can add a new "row" for another shortcut for the same action,
as long as there are no shortcut inputs empty.
There is no way to directly remove an input row - to remove a shortcut,
just clear the input (like it was the case with just single shortcuts).
This gets cleaned up when you select an item again.

Fixes: QTCREATORBUG-72
Change-Id: Id0402d00ebeb41f5b0c612d9d03f884b78485fbc
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2020-03-31 09:54:35 +02:00
parent 897abf24e2
commit 41a122641c
4 changed files with 238 additions and 147 deletions

View File

@@ -74,11 +74,16 @@ public:
defaultButton = new QPushButton(CommandMappings::tr("Reset All"), groupBox);
defaultButton->setToolTip(CommandMappings::tr("Reset all to default."));
resetButton = new QPushButton(CommandMappings::tr("Reset"), groupBox);
resetButton->setToolTip(CommandMappings::tr("Reset to default."));
resetButton->setVisible(false);
importButton = new QPushButton(CommandMappings::tr("Import..."), groupBox);
exportButton = new QPushButton(CommandMappings::tr("Export..."), groupBox);
auto hboxLayout1 = new QHBoxLayout();
hboxLayout1->addWidget(defaultButton);
hboxLayout1->addWidget(resetButton);
hboxLayout1->addStretch();
hboxLayout1->addWidget(importButton);
hboxLayout1->addWidget(exportButton);
@@ -100,6 +105,7 @@ public:
q, &CommandMappings::importAction);
q->connect(defaultButton, &QPushButton::clicked,
q, &CommandMappings::defaultAction);
q->connect(resetButton, &QPushButton::clicked, q, &CommandMappings::resetRequested);
commandList->sortByColumn(0, Qt::AscendingOrder);
@@ -117,6 +123,7 @@ public:
FancyLineEdit *filterEdit;
QTreeWidget *commandList;
QPushButton *defaultButton;
QPushButton *resetButton;
QPushButton *importButton;
QPushButton *exportButton;
};
@@ -145,6 +152,11 @@ void CommandMappings::setImportExportEnabled(bool enabled)
d->exportButton->setVisible(enabled);
}
void CommandMappings::setResetVisible(bool visible)
{
d->resetButton->setVisible(visible);
}
QTreeWidget *CommandMappings::commandList() const
{
return d->commandList;