mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-08 21:17:53 +00:00
CResourceBrowser: Allow navigating directories with the Enter keys
Previously the resource browser required you to double click on everything in order to interact with it (going into directories, or launching handlers for particular files, etc). This is kinda stinky workflow-wise long-term when flipping between assets; so we can make the interface a little less mouse-centric by allowing the use of the enter keys to also perform the same behavior.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
@@ -518,6 +519,38 @@ bool CResourceBrowser::eventFilter(QObject *pWatched, QEvent *pEvent)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CResourceBrowser::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
// If we don't have focus for one reason or another, then
|
||||
// don't do anything. It's unintuitive to listen on key
|
||||
// inputs when a control isn't in focus.
|
||||
const auto* resource_view = mpUI->ResourceTableView;
|
||||
if (!resource_view->hasFocus())
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
// We only want to handle directory drilldown and returning if only one item is selected.
|
||||
const auto indexes = resource_view->selectionModel()->selectedIndexes();
|
||||
if (indexes.empty() || indexes.size() > 1)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto key = event->key();
|
||||
if (key == Qt::Key_Return || key == Qt::Key_Enter)
|
||||
{
|
||||
OnDoubleClickTable(indexes.front());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pass down for any alternative handling
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceBrowser::RefreshResources()
|
||||
{
|
||||
// Fill resource table
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
|
||||
// Interface
|
||||
bool eventFilter(QObject* pWatched, QEvent* pEvent) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
// Accessors
|
||||
CResourceStore* CurrentStore() const { return mpStore; }
|
||||
|
||||
Reference in New Issue
Block a user