mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Update Group in Preview Widget when focused
* Fixes #3129 * Also fix out of bounds access when no entries are present in EntryView and up/down arrow pressed
This commit is contained in:
parent
91283e7c76
commit
96b0ea45dd
@ -787,6 +787,9 @@ void DatabaseWidget::switchToMainView(bool previousDialogAccepted)
|
||||
}
|
||||
|
||||
m_newParent = nullptr;
|
||||
} else {
|
||||
// Workaround: ensure entries are focused so search doesn't reset
|
||||
m_entryView->setFocus();
|
||||
}
|
||||
|
||||
setCurrentWidget(m_mainWidget);
|
||||
|
@ -139,17 +139,18 @@ void EntryView::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
|
||||
int last = m_model->rowCount() - 1;
|
||||
if (last > 0) {
|
||||
if (event->key() == Qt::Key_Up && currentIndex().row() == 0) {
|
||||
QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(last, 0));
|
||||
setCurrentEntry(m_model->entryFromIndex(index));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Up && currentIndex().row() == 0) {
|
||||
QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(last, 0));
|
||||
setCurrentEntry(m_model->entryFromIndex(index));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Down && currentIndex().row() == last) {
|
||||
QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(0, 0));
|
||||
setCurrentEntry(m_model->entryFromIndex(index));
|
||||
return;
|
||||
if (event->key() == Qt::Key_Down && currentIndex().row() == last) {
|
||||
QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(0, 0));
|
||||
setCurrentEntry(m_model->entryFromIndex(index));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QTreeView::keyPressEvent(event);
|
||||
|
@ -72,6 +72,12 @@ void GroupView::dragMoveEvent(QDragMoveEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
void GroupView::focusInEvent(QFocusEvent* event)
|
||||
{
|
||||
emitGroupChanged();
|
||||
QTreeView::focusInEvent(event);
|
||||
}
|
||||
|
||||
Group* GroupView::currentGroup()
|
||||
{
|
||||
if (currentIndex() == QModelIndex()) {
|
||||
|
@ -47,6 +47,7 @@ private slots:
|
||||
|
||||
protected:
|
||||
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||
void focusInEvent(QFocusEvent* event) override;
|
||||
|
||||
private:
|
||||
void recInitExpanded(Group* group);
|
||||
|
Loading…
Reference in New Issue
Block a user