mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
enable Ctrl+J and Ctrl+K navigation in VDirectoryTree
This commit is contained in:
parent
6e0f1d38b4
commit
3ca968169f
@ -112,6 +112,10 @@ QComboBox#NotebookSelector {
|
||||
icon-size: 30px;
|
||||
}
|
||||
|
||||
QComboBox#NotebookSelector::focus {
|
||||
background-color: @focus-color;
|
||||
}
|
||||
|
||||
QComboBox#NotebookSelector::drop-down {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: top right;
|
||||
|
@ -74,6 +74,7 @@ void VDirectoryTree::initActions()
|
||||
|
||||
void VDirectoryTree::setNotebook(VNotebook *p_notebook)
|
||||
{
|
||||
setFocus();
|
||||
if (m_notebook == p_notebook) {
|
||||
return;
|
||||
}
|
||||
@ -512,12 +513,47 @@ void VDirectoryTree::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void VDirectoryTree::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Return) {
|
||||
int key = event->key();
|
||||
int modifiers = event->modifiers();
|
||||
|
||||
switch (key) {
|
||||
case Qt::Key_Return:
|
||||
{
|
||||
QTreeWidgetItem *item = currentItem();
|
||||
if (item) {
|
||||
item->setExpanded(!item->isExpanded());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::Key_J:
|
||||
{
|
||||
if (modifiers == Qt::ControlModifier) {
|
||||
event->accept();
|
||||
QKeyEvent *downEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down,
|
||||
Qt::NoModifier);
|
||||
QCoreApplication::postEvent(this, downEvent);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::Key_K:
|
||||
{
|
||||
if (modifiers == Qt::ControlModifier) {
|
||||
event->accept();
|
||||
QKeyEvent *upEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up,
|
||||
Qt::NoModifier);
|
||||
QCoreApplication::postEvent(this, upEvent);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QTreeWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user