Skip to content

Commit e6f747d

Browse files
committed
fix Enter to open on macOS
1 parent 919ac14 commit e6f747d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/docks/filesdock.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,31 @@ void FilesDock::updateViewMode()
10881088

10891089
void FilesDock::keyPressEvent(QKeyEvent *event)
10901090
{
1091+
LOG_DEBUG() << event;
1092+
#if defined(Q_OS_MAC)
1093+
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
1094+
if (!m_view->selectionModel()->selectedIndexes().isEmpty()) {
1095+
const auto index = m_view->selectionModel()->selectedIndexes().first();
1096+
if (index.isValid()) {
1097+
const auto sourceIndex = m_filesProxyModel->mapToSource(index);
1098+
const auto filePath = m_filesModel->filePath(sourceIndex);
1099+
if (m_filesModel->isDir(sourceIndex)) {
1100+
m_filesModel->setRootPath(filePath);
1101+
m_view->setRootIndex(index);
1102+
m_view->scrollToTop();
1103+
const auto dirsIndex = m_dirsModel.index(filePath);
1104+
ui->treeView->setExpanded(dirsIndex, true);
1105+
ui->treeView->scrollTo(dirsIndex);
1106+
ui->treeView->setCurrentIndex(dirsIndex);
1107+
return;
1108+
}
1109+
emit clipOpened(filePath);
1110+
}
1111+
}
1112+
event->accept();
1113+
return;
1114+
}
1115+
#endif
10911116
QDockWidget::keyPressEvent(event);
10921117
if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
10931118
event->accept();

0 commit comments

Comments
 (0)