mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
ShortcutPrefs: clean-up
This commit is contained in:
parent
2b6d0ae3de
commit
b53d07897b
@ -2822,6 +2822,13 @@ void PrefShortcuts::updateShortcutsTW()
|
||||
}
|
||||
|
||||
|
||||
//static
|
||||
KeyMap::ItemType PrefShortcuts::itemType(QTreeWidgetItem & item)
|
||||
{
|
||||
return static_cast<KeyMap::ItemType>(item.data(0, Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
|
||||
void PrefShortcuts::setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag)
|
||||
{
|
||||
item->setData(0, Qt::UserRole, QVariant(tag));
|
||||
@ -2915,9 +2922,7 @@ void PrefShortcuts::on_shortcutsTW_itemSelectionChanged()
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
KeyMap::ItemType tag =
|
||||
static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt());
|
||||
if (tag == KeyMap::UserUnbind)
|
||||
if (itemType(*items[0]) == KeyMap::UserUnbind)
|
||||
removePB->setText(qt_("Res&tore"));
|
||||
else
|
||||
removePB->setText(qt_("Remo&ve"));
|
||||
@ -2955,10 +2960,8 @@ void PrefShortcuts::removeShortcut()
|
||||
string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
|
||||
string lfun = fromqstr(items[i]->text(0));
|
||||
FuncRequest func = lyxaction.lookupFunc(lfun);
|
||||
KeyMap::ItemType tag =
|
||||
static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt());
|
||||
|
||||
switch (tag) {
|
||||
switch (itemType(*items[i])) {
|
||||
case KeyMap::System: {
|
||||
// for system bind, we do not touch the item
|
||||
// but add an user unbind item
|
||||
@ -3010,10 +3013,8 @@ void PrefShortcuts::deactivateShortcuts(QList<QTreeWidgetItem*> const & items)
|
||||
string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
|
||||
string lfun = fromqstr(items[i]->text(0));
|
||||
FuncRequest func = lyxaction.lookupFunc(lfun);
|
||||
KeyMap::ItemType tag =
|
||||
static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt());
|
||||
|
||||
switch (tag) {
|
||||
switch (itemType(*items[i])) {
|
||||
case KeyMap::System:
|
||||
// for system bind, we do not touch the item
|
||||
// but add an user unbind item
|
||||
|
@ -456,24 +456,6 @@ public:
|
||||
void applyRC(LyXRC & rc) const;
|
||||
void updateRC(LyXRC const & rc);
|
||||
void updateShortcutsTW();
|
||||
void modifyShortcut();
|
||||
/// remove selected binding, restore default value
|
||||
void removeShortcut();
|
||||
/// remove bindings, do not restore default values
|
||||
void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
|
||||
/// check the new binding k->func, and remove existing bindings to k after
|
||||
/// asking the user. We exclude lfun_to_modify from this test: we assume
|
||||
/// that if the user clicked "modify" then they agreed to modify the
|
||||
/// binding. Returns false if the shortcut is invalid or the user cancels.
|
||||
bool validateNewShortcut(FuncRequest const & func,
|
||||
KeySequence const & k,
|
||||
QString const & lfun_to_modify);
|
||||
/// compute current active shortcut
|
||||
FuncRequest currentBinding(KeySequence const & k);
|
||||
///
|
||||
void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
|
||||
QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
|
||||
KeySequence const & shortcut, KeyMap::ItemType tag);
|
||||
|
||||
public Q_SLOTS:
|
||||
void selectBind();
|
||||
@ -491,6 +473,27 @@ public Q_SLOTS:
|
||||
void shortcutRemovePressed();
|
||||
|
||||
private:
|
||||
void modifyShortcut();
|
||||
/// remove selected binding, restore default value
|
||||
void removeShortcut();
|
||||
/// remove bindings, do not restore default values
|
||||
void deactivateShortcuts(QList<QTreeWidgetItem*> const & items);
|
||||
/// check the new binding k->func, and remove existing bindings to k after
|
||||
/// asking the user. We exclude lfun_to_modify from this test: we assume
|
||||
/// that if the user clicked "modify" then they agreed to modify the
|
||||
/// binding. Returns false if the shortcut is invalid or the user cancels.
|
||||
bool validateNewShortcut(FuncRequest const & func,
|
||||
KeySequence const & k,
|
||||
QString const & lfun_to_modify);
|
||||
/// compute current active shortcut
|
||||
FuncRequest currentBinding(KeySequence const & k);
|
||||
///
|
||||
void setItemType(QTreeWidgetItem * item, KeyMap::ItemType tag);
|
||||
///
|
||||
static KeyMap::ItemType itemType(QTreeWidgetItem & item);
|
||||
///
|
||||
QTreeWidgetItem * insertShortcutItem(FuncRequest const & lfun,
|
||||
KeySequence const & shortcut, KeyMap::ItemType tag);
|
||||
///
|
||||
GuiShortcutDialog * shortcut_;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user