Skip to content

Commit 424bd1a

Browse files
committed
update keymap page and menu & toolbar page
1 parent 431aa40 commit 424bd1a

File tree

4 files changed

+385
-12
lines changed

4 files changed

+385
-12
lines changed

src/plugins/coreplugin/internal/coreplugin.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "appearancepage.h"
3535
#include "actionlayoutspage.h"
3636
#include "keymappage.h"
37+
#include "menutoolbarpage.h"
3738

3839
extern const Core::ActionExtension *ckGetStaticActionExtension_core_actions();
3940

@@ -121,11 +122,14 @@ namespace Core::Internal {
121122
auto appearance = new AppearancePage();
122123
environmentTop->addPage(appearance);
123124

124-
auto actionLayouts = new ActionLayoutsPage();
125-
environmentTop->addPage(actionLayouts);
125+
// auto actionLayouts = new ActionLayoutsPage();
126+
// environmentTop->addPage(actionLayouts);
126127

127128
auto keymap = new KeymapPage();
128129
environmentTop->addPage(keymap);
130+
131+
auto menuToolbar = new MenuToolbarPage();
132+
environmentTop->addPage(menuToolbar);
129133
}
130134
}
131135

src/plugins/coreplugin/internal/settings/keymappage.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ namespace Core::Internal {
6868
actionsFilterLayout->addWidget(findShortcutButton);
6969
actionsLayout->addLayout(actionsFilterLayout);
7070
auto actionsTreeWidget = new QTreeWidget;
71-
actionsTreeWidget->setHeaderLabels({tr("Name"), tr("ID"), tr("Shortcut")});
71+
actionsTreeWidget->setHeaderLabels({tr("Name"), tr("Shortcut")});
72+
actionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
7273
actionsLayout->addWidget(actionsTreeWidget);
7374
actionsGroupBox->setLayout(actionsLayout);
7475
mainLayout->addWidget(actionsGroupBox);
@@ -109,7 +110,6 @@ namespace Core::Internal {
109110
actionsTreeWidget->resizeColumnToContents(0);
110111
actionsTreeWidget->resizeColumnToContents(1);
111112
actionsTreeWidget->collapseAll();
112-
actionsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
113113

114114
connect(m_presetComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=](int index) {
115115
m_shortcutInfo.clear();
@@ -259,6 +259,7 @@ namespace Core::Internal {
259259
private:
260260
enum ItemDataRole {
261261
ShortcutRole = Qt::UserRole,
262+
IDRole,
262263
};
263264

264265
QComboBox *m_presetComboBox;
@@ -273,7 +274,8 @@ namespace Core::Internal {
273274
auto domain = ICore::instance()->actionManager()->domain();
274275
item->setText(0, ActionObjectInfo::translatedCategory(catalog.name()));
275276
item->setIcon(0, domain->objectIcon(qIDec->theme(), catalog.id()));
276-
item->setText(1, catalog.id());
277+
item->setData(0, IDRole, catalog.id());
278+
item->setTextAlignment(1, Qt::AlignRight);
277279
for (const auto &childCatalog : catalog.children()) {
278280
auto childItem = new QTreeWidgetItem;
279281
traverseCatalog(childItem, childCatalog);
@@ -285,7 +287,7 @@ namespace Core::Internal {
285287
auto actionMgr = ICore::instance()->actionManager();
286288
auto shortcutsFamily = m_presetComboBox->currentData().toBool() ? actionMgr->systemShortcutsFamily(m_presetComboBox->currentText()) : actionMgr->userShortcutsFamily(m_presetComboBox->currentText());
287289
auto domain = ICore::instance()->actionManager()->domain();
288-
auto id = item->text(1);
290+
auto id = item->data(0, IDRole).toString();
289291
for (int i = 0; i < item->childCount(); i++) {
290292
traverseShortcuts(item->child(i));
291293
}
@@ -297,7 +299,7 @@ namespace Core::Internal {
297299
shortcuts = modification.value(id);
298300
} else if (!m_presetComboBox->currentData().toBool() && m_userShortcutFamilyAddition.contains(m_presetComboBox->currentText())) {
299301
shortcuts = m_userShortcutFamilyAddition.value(m_presetComboBox->currentText()).value(id, domain->objectInfo(id).shortcuts());
300-
} else if (shortcutsFamily.value(item->text(1))) {
302+
} else if (shortcutsFamily.value(item->data(0, IDRole).toString())) {
301303
shortcuts = shortcutsFamily.value(id).value();
302304
} else {
303305
shortcuts = domain->objectInfo(id).shortcuts();
@@ -307,7 +309,7 @@ namespace Core::Internal {
307309
m_shortcutInfo.insert(keySeq.toString(), item);
308310
}
309311

310-
item->setText(2, shortcutTexts.join(' '));
312+
item->setText(1, shortcutTexts.join(' '));
311313
item->setData(0, ShortcutRole, QVariant::fromValue(shortcuts));
312314
}
313315

@@ -322,7 +324,7 @@ namespace Core::Internal {
322324
if (!text.isEmpty())
323325
item->setExpanded(true);
324326
return true;
325-
} else if (item->text(0).contains(text, Qt::CaseInsensitive) || item->text(1).contains(text, Qt::CaseInsensitive)) {
327+
} else if (item->text(0).contains(text, Qt::CaseInsensitive) || item->data(0, IDRole).toString().contains(text, Qt::CaseInsensitive)) {
326328
item->setHidden(false);
327329
return true;
328330
} else {
@@ -355,11 +357,11 @@ namespace Core::Internal {
355357
shortcutTexts.append("[" + shortcut.toString(QKeySequence::NativeText) + "]");
356358
}
357359
if (m_presetComboBox->currentData().toBool()) {
358-
m_systemShortcutFamilyModification[m_presetComboBox->currentText()].insert(item->text(1), shortcuts);
360+
m_systemShortcutFamilyModification[m_presetComboBox->currentText()].insert(item->data(0, IDRole).toString(), shortcuts);
359361
} else {
360-
m_userShortcutFamilyModification[m_presetComboBox->currentText()].insert(item->text(1), shortcuts);
362+
m_userShortcutFamilyModification[m_presetComboBox->currentText()].insert(item->data(0, IDRole).toString(), shortcuts);
361363
}
362-
item->setText(2, shortcutTexts.join(' '));
364+
item->setText(1, shortcutTexts.join(' '));
363365
}
364366

365367
void promptShortcut(QTreeWidgetItem *item) {

0 commit comments

Comments
 (0)