Keep file navigation focused and open entries with Enter
This commit is contained in:
1 parent
043257cabf
commit
93a6277ca4
2 files changed
+26
-1
No files matched your search
@@ -121,6 +121,7 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
||||
m_copyAction->setShortcut(QKeySequence::Copy); m_copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
m_entries->addAction(m_copyAction);
|
||||
connect(m_copyAction, &QAction::triggered, this, [this] { exportFile(true); });
|
||||
for (auto* button : findChildren<QPushButton*>()) button->setAutoDefault(false);
|
||||
auto dropTargets = findChildren<QWidget*>(); dropTargets.append(this);
|
||||
for (auto* target : dropTargets) { target->setAcceptDrops(true); target->installEventFilter(this); }
|
||||
m_dropHint = new QLabel(m_entries->viewport()); m_dropHint->setObjectName("memberFilesDropHint");
|
||||
@@ -130,6 +131,7 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: drop targets installed count=%d", int(dropTargets.size()));
|
||||
connect(reload, &QPushButton::clicked, this, [this]() { m_staleRetries = 0; refresh(); });
|
||||
connect(up, &QPushButton::clicked, this, [this]() {
|
||||
m_entries->setFocus();
|
||||
if (m_path.isEmpty()) { m_owners->setCurrentIndex(0); return; }
|
||||
int slash = m_path.lastIndexOf('/'); navigate(slash < 0 ? QString() : m_path.left(slash));
|
||||
});
|
||||
@@ -155,6 +157,15 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: Backspace key path=%s enabled=%d", qPrintable(m_path), up->isEnabled());
|
||||
up->click();
|
||||
});
|
||||
for (auto key : {Qt::Key_Return, Qt::Key_Enter}) {
|
||||
auto* enterShortcut = new QShortcut(QKeySequence(key), m_entries);
|
||||
enterShortcut->setContext(Qt::WidgetWithChildrenShortcut); enterShortcut->setAutoRepeat(false);
|
||||
connect(enterShortcut, &QShortcut::activated, this, [this] {
|
||||
auto* item = m_entries->currentItem();
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "file browser: Enter key path=%s selected=%d", qPrintable(selectedPath()), item != nullptr);
|
||||
if (item) enter(item);
|
||||
});
|
||||
}
|
||||
connect(m_cancel, &QPushButton::clicked, this, &MemberFileBrowser::cancel);
|
||||
m_entries->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_entries, &QWidget::customContextMenuRequested, this, [this](const QPoint& point) {
|
||||
@@ -169,7 +180,7 @@ MemberFileBrowser::MemberFileBrowser(DbManager* db, QWidget* parent) : QDialog(p
|
||||
if (copyPath(q.path, selectedPath()) && post(q)) m_actions.insert(q.request_id, MF_STAT);
|
||||
}
|
||||
});
|
||||
updateActions();
|
||||
updateActions(); m_entries->setFocus();
|
||||
}
|
||||
|
||||
MemberFileBrowser::~MemberFileBrowser() {
|
||||
|
||||
Reference in new issue
Block a user