mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
Merge 196db24a36 into 4867bb2e2b
This commit is contained in:
commit
38e138c72f
3 changed files with 48 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
@ -44,6 +45,36 @@
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
#include "qcursor.h"
|
#include "qcursor.h"
|
||||||
|
|
||||||
|
// On Mac OS X, the Return key does not trigger the activation signal for some reason. Fix it.
|
||||||
|
|
||||||
|
void GameListTreeView::keyPressEvent(QKeyEvent* event) {
|
||||||
|
if (event->key() == Qt::Key_Return) {
|
||||||
|
const QModelIndex idx = currentIndex();
|
||||||
|
if (idx.isValid()) {
|
||||||
|
emit activated(idx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QTreeView::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if focus goes into the game list and nothing is already selected, select the first actual game
|
||||||
|
void GameListTreeView::focusInEvent(QFocusEvent* event) {
|
||||||
|
if (!currentIndex().isValid()) {
|
||||||
|
for (int i = 0; i < model()->rowCount(); i++) {
|
||||||
|
const QModelIndex folder = model()->index(i, 0);
|
||||||
|
if (model()->rowCount(folder) > 0) {
|
||||||
|
const QModelIndex first = model()->index(0, 0, folder);
|
||||||
|
setCurrentIndex(first);
|
||||||
|
selectionModel()->select(first,
|
||||||
|
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QTreeView::focusInEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist, QObject* parent)
|
GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist, QObject* parent)
|
||||||
: QObject(parent), gamelist{gamelist} {}
|
: QObject(parent), gamelist{gamelist} {}
|
||||||
|
|
||||||
|
|
@ -88,6 +119,13 @@ bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* eve
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// up, down, tab
|
||||||
|
// If the up arrow, down arrow, or tab key is pressed, this should move focus to the
|
||||||
|
// treeview
|
||||||
|
case Qt::Key_Up:
|
||||||
|
case Qt::Key_Down: {
|
||||||
|
gamelist->tree_view->setFocus();
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
@ -355,7 +393,7 @@ GameList::GameList(PlayTime::PlayTimeManager& play_time_manager_, GMainWindow* p
|
||||||
|
|
||||||
this->main_window = parent;
|
this->main_window = parent;
|
||||||
layout = new QVBoxLayout;
|
layout = new QVBoxLayout;
|
||||||
tree_view = new QTreeView;
|
tree_view = new GameListTreeView;
|
||||||
search_field = new GameListSearchField(this);
|
search_field = new GameListSearchField(this);
|
||||||
item_model = new QStandardItemModel(tree_view);
|
item_model = new QStandardItemModel(tree_view);
|
||||||
tree_view->setModel(item_model);
|
tree_view->setModel(item_model);
|
||||||
|
|
@ -371,7 +409,6 @@ GameList::GameList(PlayTime::PlayTimeManager& play_time_manager_, GMainWindow* p
|
||||||
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
|
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
|
||||||
tree_view->setItemDelegateForColumn(0, new CartridgeIconDelegate(tree_view));
|
tree_view->setItemDelegateForColumn(0, new CartridgeIconDelegate(tree_view));
|
||||||
tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
UpdateColumnVisibility();
|
UpdateColumnVisibility();
|
||||||
|
|
||||||
item_model->insertColumns(0, COLUMN_COUNT);
|
item_model->insertColumns(0, COLUMN_COUNT);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ enum class MediaType : u32;
|
||||||
class GameListWorker;
|
class GameListWorker;
|
||||||
class GameListDir;
|
class GameListDir;
|
||||||
class GameListSearchField;
|
class GameListSearchField;
|
||||||
|
class GameListTreeView;
|
||||||
class GMainWindow;
|
class GMainWindow;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
|
@ -140,7 +141,7 @@ private:
|
||||||
GameListSearchField* search_field;
|
GameListSearchField* search_field;
|
||||||
GMainWindow* main_window = nullptr;
|
GMainWindow* main_window = nullptr;
|
||||||
QVBoxLayout* layout = nullptr;
|
QVBoxLayout* layout = nullptr;
|
||||||
QTreeView* tree_view = nullptr;
|
GameListTreeView* tree_view = nullptr;
|
||||||
QStandardItemModel* item_model = nullptr;
|
QStandardItemModel* item_model = nullptr;
|
||||||
GameListWorker* current_worker = nullptr;
|
GameListWorker* current_worker = nullptr;
|
||||||
QFileSystemWatcher* watcher = nullptr;
|
QFileSystemWatcher* watcher = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTreeView>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "citra_qt/uisettings.h"
|
#include "citra_qt/uisettings.h"
|
||||||
#include "citra_qt/util/util.h"
|
#include "citra_qt/util/util.h"
|
||||||
|
|
@ -529,3 +530,9 @@ private:
|
||||||
QLabel* label_filter_result = nullptr;
|
QLabel* label_filter_result = nullptr;
|
||||||
QToolButton* button_filter_close = nullptr;
|
QToolButton* button_filter_close = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GameListTreeView : public QTreeView {
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
void focusInEvent(QFocusEvent* event) override;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue