mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
More work on the Shortcuts UI:
- add ability to remove a Key from the sequence - add ability to modify a sequence without retyping it from scratch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25783 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c3f185f254
commit
91baeb2c55
@ -190,4 +190,13 @@ void KeySequence::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KeySequence::removeKey()
|
||||||
|
{
|
||||||
|
if (deleted_)
|
||||||
|
return;
|
||||||
|
sequence.pop_back();
|
||||||
|
modifiers.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -91,6 +91,9 @@ public:
|
|||||||
/// clear in full
|
/// clear in full
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
/// remove last key in sequence
|
||||||
|
void removeKey();
|
||||||
|
|
||||||
bool deleted() const { return deleted_; }
|
bool deleted() const { return deleted_; }
|
||||||
|
|
||||||
/// length of sequence
|
/// length of sequence
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* \author Bo Peng
|
* \author Bo Peng
|
||||||
* \author Edwin Leuven
|
* \author Edwin Leuven
|
||||||
|
* \author Jürgen Spitzmüller
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
@ -84,6 +85,12 @@ KeySequence const ShortcutWidget::getKeySequence() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ShortcutWidget::setKeySequence(lyx::KeySequence const s)
|
||||||
|
{
|
||||||
|
keysequence_ = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShortcutWidget::keyPressEvent(QKeyEvent * e)
|
void ShortcutWidget::keyPressEvent(QKeyEvent * e)
|
||||||
{
|
{
|
||||||
int const keyQt = e->key();
|
int const keyQt = e->key();
|
||||||
@ -139,6 +146,13 @@ void ShortcutWidget::appendToSequence(QKeyEvent * e)
|
|||||||
keysequence_.addkey(sym, mod, lyx::NoModifier);
|
keysequence_.addkey(sym, mod, lyx::NoModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ShortcutWidget::removeFromSequence()
|
||||||
|
{
|
||||||
|
keysequence_.removeKey();
|
||||||
|
setText(toqstr(keysequence_.print(KeySequence::ForGui)));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* \author Bo Peng
|
* \author Bo Peng
|
||||||
* \author Edwin Leuven
|
* \author Edwin Leuven
|
||||||
|
* \author Jürgen Spitzmüller
|
||||||
*
|
*
|
||||||
* Full author contact details are available in file CREDITS.
|
* Full author contact details are available in file CREDITS.
|
||||||
*/
|
*/
|
||||||
@ -32,6 +33,8 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
bool eventFilter(QObject*, QEvent* e );
|
bool eventFilter(QObject*, QEvent* e );
|
||||||
lyx::KeySequence const getKeySequence() const;
|
lyx::KeySequence const getKeySequence() const;
|
||||||
|
void setKeySequence(lyx::KeySequence const s);
|
||||||
|
void removeFromSequence();
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
bool event(QEvent* e);
|
bool event(QEvent* e);
|
||||||
void keyPressEvent(QKeyEvent * e);
|
void keyPressEvent(QKeyEvent * e);
|
||||||
|
@ -2055,6 +2055,8 @@ PrefShortcuts::PrefShortcuts(GuiPreferences * form)
|
|||||||
shortcut_, SLOT(reject()));
|
shortcut_, SLOT(reject()));
|
||||||
connect(shortcut_->clearPB, SIGNAL(clicked()),
|
connect(shortcut_->clearPB, SIGNAL(clicked()),
|
||||||
this, SLOT(shortcut_clearPB_pressed()));
|
this, SLOT(shortcut_clearPB_pressed()));
|
||||||
|
connect(shortcut_->removePB, SIGNAL(clicked()),
|
||||||
|
this, SLOT(shortcut_removePB_pressed()));
|
||||||
connect(shortcut_->okPB, SIGNAL(clicked()),
|
connect(shortcut_->okPB, SIGNAL(clicked()),
|
||||||
this, SLOT(shortcut_okPB_pressed()));
|
this, SLOT(shortcut_okPB_pressed()));
|
||||||
connect(shortcut_->cancelPB, SIGNAL(clicked()),
|
connect(shortcut_->cancelPB, SIGNAL(clicked()),
|
||||||
@ -2268,6 +2270,9 @@ void PrefShortcuts::modifyShortcut()
|
|||||||
if (item->flags() & Qt::ItemIsSelectable) {
|
if (item->flags() & Qt::ItemIsSelectable) {
|
||||||
shortcut_->lfunLE->setText(item->text(0));
|
shortcut_->lfunLE->setText(item->text(0));
|
||||||
shortcut_->shortcutWG->setText(item->text(1));
|
shortcut_->shortcutWG->setText(item->text(1));
|
||||||
|
KeySequence seq;
|
||||||
|
seq.parse(fromqstr(item->data(1, Qt::UserRole).toString()));
|
||||||
|
shortcut_->shortcutWG->setKeySequence(seq);
|
||||||
shortcut_->shortcutWG->setFocus();
|
shortcut_->shortcutWG->setFocus();
|
||||||
shortcut_->exec();
|
shortcut_->exec();
|
||||||
}
|
}
|
||||||
@ -2430,6 +2435,12 @@ void PrefShortcuts::shortcut_clearPB_pressed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrefShortcuts::shortcut_removePB_pressed()
|
||||||
|
{
|
||||||
|
shortcut_->shortcutWG->removeFromSequence();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// PrefIdentity
|
// PrefIdentity
|
||||||
|
@ -452,6 +452,7 @@ public Q_SLOTS:
|
|||||||
void shortcut_okPB_pressed();
|
void shortcut_okPB_pressed();
|
||||||
void shortcut_cancelPB_pressed();
|
void shortcut_cancelPB_pressed();
|
||||||
void shortcut_clearPB_pressed();
|
void shortcut_clearPB_pressed();
|
||||||
|
void shortcut_removePB_pressed();
|
||||||
void on_shortcutsTW_itemDoubleClicked();
|
void on_shortcutsTW_itemDoubleClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>348</width>
|
<width>421</width>
|
||||||
<height>106</height>
|
<height>111</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
@ -22,60 +22,7 @@
|
|||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="1" >
|
<item row="2" column="0" colspan="4" >
|
||||||
<widget class="lyx::frontend::ShortcutWidget" name="shortcutWG" >
|
|
||||||
<property name="enabled" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip" >
|
|
||||||
<string>Type shortcut after clicking on this field. You can reset the content with the 'Clear' button</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" colspan="2" >
|
|
||||||
<widget class="QLineEdit" name="lfunLE" >
|
|
||||||
<property name="toolTip" >
|
|
||||||
<string>Enter LyX function or command sequence</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2" >
|
|
||||||
<widget class="QPushButton" name="clearPB" >
|
|
||||||
<property name="toolTip" >
|
|
||||||
<string>Clear current shortcut</string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>C&lear</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" >
|
|
||||||
<widget class="QLabel" name="lfunLBL" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Function:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy" >
|
|
||||||
<cstring>lfunLE</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<widget class="QLabel" name="shortcutLBL" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>&Shortcut:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy" >
|
|
||||||
<cstring>shortcutWG</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="3" >
|
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<property name="margin" >
|
<property name="margin" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -124,6 +71,69 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" colspan="3" >
|
||||||
|
<widget class="QLineEdit" name="lfunLE" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Enter LyX function or command sequence</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2" >
|
||||||
|
<widget class="QPushButton" name="removePB" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Remove last key from the shortcut sequence</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Delete Key</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3" >
|
||||||
|
<widget class="QPushButton" name="clearPB" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Clear current shortcut</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>C&lear</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QLabel" name="shortcutLBL" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Shortcut:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>shortcutWG</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="lfunLBL" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Function:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>lfunLE</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<widget class="lyx::frontend::ShortcutWidget" name="shortcutWG" >
|
||||||
|
<property name="enabled" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Type shortcut after clicking on this field. You can reset the content with the 'Clear' button</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
Loading…
Reference in New Issue
Block a user