citra-emu
/
citra
Archived
1
0
Fork 0

Merge pull request #3979 from zhaowenlan1779/filter-untranslated

game_list: move SearchField to game_list_p.h and fix untranslated text
This commit is contained in:
Weiyi Wang 2018-07-26 12:26:39 +03:00 committed by GitHub
commit 7568020ea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 39 deletions

View File

@ -31,10 +31,10 @@
#include "core/hle/service/fs/archive.h" #include "core/hle/service/fs/archive.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
GameList::SearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {} GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {}
// EventFilter in order to process systemkeys while editing the searchfield // EventFilter in order to process systemkeys while editing the searchfield
bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) { bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
// If it isn't a KeyRelease event then continue with standard event processing // If it isn't a KeyRelease event then continue with standard event processing
if (event->type() != QEvent::KeyRelease) if (event->type() != QEvent::KeyRelease)
return QObject::eventFilter(obj, event); return QObject::eventFilter(obj, event);
@ -82,7 +82,7 @@ bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* e
return QObject::eventFilter(obj, event); return QObject::eventFilter(obj, event);
} }
void GameList::SearchField::setFilterResult(int visible, int total) { void GameListSearchField::setFilterResult(int visible, int total) {
this->visible = visible; this->visible = visible;
this->total = total; this->total = total;
@ -116,17 +116,17 @@ QString GameList::getLastFilterResultItem() {
return file_path; return file_path;
} }
void GameList::SearchField::clear() { void GameListSearchField::clear() {
edit_filter->setText(""); edit_filter->setText("");
} }
void GameList::SearchField::setFocus() { void GameListSearchField::setFocus() {
if (edit_filter->isVisible()) { if (edit_filter->isVisible()) {
edit_filter->setFocus(); edit_filter->setFocus();
} }
} }
GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} { GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
KeyReleaseEater* keyReleaseEater = new KeyReleaseEater(parent); KeyReleaseEater* keyReleaseEater = new KeyReleaseEater(parent);
layout_filter = new QHBoxLayout; layout_filter = new QHBoxLayout;
layout_filter->setMargin(8); layout_filter->setMargin(8);
@ -271,7 +271,7 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
this->main_window = parent; this->main_window = parent;
layout = new QVBoxLayout; layout = new QVBoxLayout;
tree_view = new QTreeView; tree_view = new QTreeView;
search_field = new SearchField(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);

View File

@ -12,6 +12,7 @@
class GameListWorker; class GameListWorker;
class GameListDir; class GameListDir;
class GameListSearchField;
class GMainWindow; class GMainWindow;
class QFileSystemWatcher; class QFileSystemWatcher;
class QHBoxLayout; class QHBoxLayout;
@ -41,37 +42,6 @@ public:
COLUMN_COUNT, // Number of columns COLUMN_COUNT, // Number of columns
}; };
class SearchField : public QWidget {
public:
explicit SearchField(GameList* parent = nullptr);
void setFilterResult(int visible, int total);
void clear();
void setFocus();
int visible;
int total;
private:
class KeyReleaseEater : public QObject {
public:
explicit KeyReleaseEater(GameList* gamelist);
private:
GameList* gamelist = nullptr;
QString edit_filter_text_old;
protected:
bool eventFilter(QObject* obj, QEvent* event) override;
};
QHBoxLayout* layout_filter = nullptr;
QTreeView* tree_view = nullptr;
QLabel* label_filter = nullptr;
QLineEdit* edit_filter = nullptr;
QLabel* label_filter_result = nullptr;
QToolButton* button_filter_close = nullptr;
};
explicit GameList(GMainWindow* parent = nullptr); explicit GameList(GMainWindow* parent = nullptr);
~GameList() override; ~GameList() override;
@ -121,7 +91,7 @@ private:
void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected);
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
SearchField* search_field; GameListSearchField* search_field;
GMainWindow* main_window = nullptr; GMainWindow* main_window = nullptr;
QVBoxLayout* layout = nullptr; QVBoxLayout* layout = nullptr;
QTreeView* tree_view = nullptr; QTreeView* tree_view = nullptr;
@ -129,6 +99,8 @@ private:
GameListWorker* current_worker = nullptr; GameListWorker* current_worker = nullptr;
QFileSystemWatcher* watcher = nullptr; QFileSystemWatcher* watcher = nullptr;
std::unordered_map<std::string, std::pair<QString, QString>> compatibility_list; std::unordered_map<std::string, std::pair<QString, QString>> compatibility_list;
friend class GameListSearchField;
}; };
Q_DECLARE_METATYPE(GameListOpenTarget); Q_DECLARE_METATYPE(GameListOpenTarget);

View File

@ -15,6 +15,7 @@
#include <QRunnable> #include <QRunnable>
#include <QStandardItem> #include <QStandardItem>
#include <QString> #include <QString>
#include <QWidget>
#include "citra_qt/ui_settings.h" #include "citra_qt/ui_settings.h"
#include "citra_qt/util/util.h" #include "citra_qt/util/util.h"
#include "common/file_util.h" #include "common/file_util.h"
@ -408,3 +409,45 @@ private:
void AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion, void AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion,
GameListDir* parent_dir); GameListDir* parent_dir);
}; };
class GameList;
class QHBoxLayout;
class QTreeView;
class QLabel;
class QLineEdit;
class QToolButton;
class GameListSearchField : public QWidget {
Q_OBJECT
public:
explicit GameListSearchField(GameList* parent = nullptr);
void setFilterResult(int visible, int total);
void clear();
void setFocus();
int visible;
int total;
private:
class KeyReleaseEater : public QObject {
public:
explicit KeyReleaseEater(GameList* gamelist);
private:
GameList* gamelist = nullptr;
QString edit_filter_text_old;
protected:
// EventFilter in order to process systemkeys while editing the searchfield
bool eventFilter(QObject* obj, QEvent* event) override;
};
QHBoxLayout* layout_filter = nullptr;
QTreeView* tree_view = nullptr;
QLabel* label_filter = nullptr;
QLineEdit* edit_filter = nullptr;
QLabel* label_filter_result = nullptr;
QToolButton* button_filter_close = nullptr;
};