summaryrefslogtreecommitdiff
path: root/src/plugins/fakevim/fakevimplugin.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-04-29 18:01:21 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2015-05-15 14:40:45 +0000
commit25057a7acccc124795ee02e4b9bb037f2194eef0 (patch)
tree31c97908bb39ad7b48173c66fc261793dd63052f /src/plugins/fakevim/fakevimplugin.cpp
parent0bd0468263142e1b98ced08d93264f35e7e4ebc2 (diff)
downloadqt-creator-25057a7acccc124795ee02e4b9bb037f2194eef0.tar.gz
Improve keyboard shortcut settings
- change the line edit to accept actual text input in a form similar to QKeySequence::fromString (with special "native" form on OS X) - add a button that allows entering a key sequence by pressing keys, including support for e.g. escape key, which was broken before because it closed the dialog - add a warning label, that allows filtering the list for all potentially conflicting shortcuts Task-number: QTCREATORBUG-6 Change-Id: I94fc63525f653127e87f6ef2bffe72d8dcaa867d Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Diffstat (limited to 'src/plugins/fakevim/fakevimplugin.cpp')
-rw-r--r--src/plugins/fakevim/fakevimplugin.cpp81
1 files changed, 51 insertions, 30 deletions
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 902ffe83f0..c720324923 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -544,25 +544,14 @@ class FakeVimExCommandsWidget : public CommandMappings
Q_OBJECT
public:
- FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent = 0)
- : CommandMappings(parent), m_q(q)
- {
- setPageTitle(Tr::tr("Ex Command Mapping"));
- setTargetHeader(Tr::tr("Ex Trigger Expression"));
- setTargetLabelText(Tr::tr("Regular expression:"));
- setTargetEditTitle(Tr::tr("Ex Command"));
- targetEdit()->setPlaceholderText(QString());
- setImportExportEnabled(false);
- initialize();
- }
+ FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent = 0);
protected:
- void targetIdentifierChanged() override;
- void resetTargetIdentifier() override;
- void removeTargetIdentifier() override;
+ void commandChanged();
+ void resetToDefault();
void defaultAction() override;
- void commandChanged(QTreeWidgetItem *current) override;
+ void handleCurrentCommandChanged(QTreeWidgetItem *current);
private:
void initialize();
@@ -571,8 +560,41 @@ private:
ExCommandMap &defaultExCommandMap();
FakeVimPluginPrivate *m_q;
+ QGroupBox *m_commandBox;
+ Utils::FancyLineEdit *m_commandEdit;
};
+FakeVimExCommandsWidget::FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent)
+ : CommandMappings(parent), m_q(q)
+{
+ setPageTitle(Tr::tr("Ex Command Mapping"));
+ setTargetHeader(Tr::tr("Ex Trigger Expression"));
+ setImportExportEnabled(false);
+
+ connect(this, &FakeVimExCommandsWidget::currentCommandChanged,
+ this, &FakeVimExCommandsWidget::handleCurrentCommandChanged);
+
+ m_commandBox = new QGroupBox(Tr::tr("Ex Command"), this);
+ m_commandBox->setEnabled(false);
+ auto boxLayout = new QHBoxLayout(m_commandBox);
+ m_commandEdit = new Utils::FancyLineEdit(m_commandBox);
+ m_commandEdit->setFiltering(true);
+ m_commandEdit->setPlaceholderText(QString());
+ connect(m_commandEdit, &Utils::FancyLineEdit::textChanged,
+ this, &FakeVimExCommandsWidget::commandChanged);
+ auto resetButton = new QPushButton(Tr::tr("Reset"), m_commandBox);
+ resetButton->setToolTip(Tr::tr("Reset to default."));
+ connect(resetButton, &QPushButton::clicked,
+ this, &FakeVimExCommandsWidget::resetToDefault);
+ boxLayout->addWidget(new QLabel(Tr::tr("Regular expression:")));
+ boxLayout->addWidget(m_commandEdit);
+ boxLayout->addWidget(resetButton);
+
+ layout()->addWidget(m_commandBox);
+
+ initialize();
+}
+
class FakeVimExCommandsPage : public IOptionsPage
{
Q_OBJECT
@@ -647,24 +669,28 @@ void FakeVimExCommandsWidget::initialize()
setModified(item, true);
}
- commandChanged(0);
+ handleCurrentCommandChanged(0);
}
-void FakeVimExCommandsWidget::commandChanged(QTreeWidgetItem *current)
+void FakeVimExCommandsWidget::handleCurrentCommandChanged(QTreeWidgetItem *current)
{
- CommandMappings::commandChanged(current);
- if (current)
- targetEdit()->setText(current->text(2));
+ if (current) {
+ m_commandEdit->setText(current->text(2));
+ m_commandBox->setEnabled(true);
+ } else {
+ m_commandEdit->clear();
+ m_commandBox->setEnabled(false);
+ }
}
-void FakeVimExCommandsWidget::targetIdentifierChanged()
+void FakeVimExCommandsWidget::commandChanged()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (!current)
return;
const QString name = current->data(0, CommandRole).toString();
- const QString regex = targetEdit()->text();
+ const QString regex = m_commandEdit->text();
if (current->data(0, Qt::UserRole).isValid()) {
current->setText(2, regex);
@@ -674,7 +700,7 @@ void FakeVimExCommandsWidget::targetIdentifierChanged()
setModified(current, regex != defaultExCommandMap()[name].pattern());
}
-void FakeVimExCommandsWidget::resetTargetIdentifier()
+void FakeVimExCommandsWidget::resetToDefault()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (!current)
@@ -683,12 +709,7 @@ void FakeVimExCommandsWidget::resetTargetIdentifier()
QString regex;
if (defaultExCommandMap().contains(name))
regex = defaultExCommandMap()[name].pattern();
- targetEdit()->setText(regex);
-}
-
-void FakeVimExCommandsWidget::removeTargetIdentifier()
-{
- targetEdit()->clear();
+ m_commandEdit->setText(regex);
}
void FakeVimExCommandsWidget::defaultAction()
@@ -706,7 +727,7 @@ void FakeVimExCommandsWidget::defaultAction()
setModified(item, false);
item->setText(2, regex);
if (item == commandList()->currentItem())
- commandChanged(item);
+ currentCommandChanged(item);
}
}
}