mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Qt: Implement search
This commit is contained in:
parent
ad8c31699f
commit
3292abb41d
@ -26,6 +26,7 @@ set(SRCS
|
|||||||
MenuBar.cpp
|
MenuBar.cpp
|
||||||
RenderWidget.cpp
|
RenderWidget.cpp
|
||||||
Resources.cpp
|
Resources.cpp
|
||||||
|
SearchBar.cpp
|
||||||
Settings.cpp
|
Settings.cpp
|
||||||
ToolBar.cpp
|
ToolBar.cpp
|
||||||
Translation.cpp
|
Translation.cpp
|
||||||
|
@ -122,6 +122,7 @@
|
|||||||
<QtMoc Include="QtUtils\WrapInScrollArea.h" />
|
<QtMoc Include="QtUtils\WrapInScrollArea.h" />
|
||||||
<QtMoc Include="QtUtils\AspectRatioWidget.h" />
|
<QtMoc Include="QtUtils\AspectRatioWidget.h" />
|
||||||
<QtMoc Include="RenderWidget.h" />
|
<QtMoc Include="RenderWidget.h" />
|
||||||
|
<QtMoc Include="SearchBar.h" />
|
||||||
<QtMoc Include="Settings.h" />
|
<QtMoc Include="Settings.h" />
|
||||||
<QtMoc Include="Settings\AdvancedPane.h" />
|
<QtMoc Include="Settings\AdvancedPane.h" />
|
||||||
<QtMoc Include="Settings\GeneralPane.h" />
|
<QtMoc Include="Settings\GeneralPane.h" />
|
||||||
@ -188,6 +189,7 @@
|
|||||||
<ClCompile Include="$(QtMocOutPrefix)DoubleClickEventFilter.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)DoubleClickEventFilter.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)RegisterWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)RegisterWidget.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)RenderWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)RenderWidget.cpp" />
|
||||||
|
<ClCompile Include="$(QtMocOutPrefix)SearchBar.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)Settings.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)Settings.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)SettingsWindow.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)SettingsWindow.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)SoftwareRendererWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)SoftwareRendererWidget.cpp" />
|
||||||
@ -280,6 +282,7 @@
|
|||||||
<ClCompile Include="QtUtils\AspectRatioWidget.cpp" />
|
<ClCompile Include="QtUtils\AspectRatioWidget.cpp" />
|
||||||
<ClCompile Include="RenderWidget.cpp" />
|
<ClCompile Include="RenderWidget.cpp" />
|
||||||
<ClCompile Include="Resources.cpp" />
|
<ClCompile Include="Resources.cpp" />
|
||||||
|
<ClCompile Include="SearchBar.cpp" />
|
||||||
<ClCompile Include="Settings.cpp" />
|
<ClCompile Include="Settings.cpp" />
|
||||||
<ClCompile Include="Settings\AdvancedPane.cpp" />
|
<ClCompile Include="Settings\AdvancedPane.cpp" />
|
||||||
<ClCompile Include="Settings\AudioPane.cpp" />
|
<ClCompile Include="Settings\AudioPane.cpp" />
|
||||||
|
@ -521,3 +521,11 @@ void GameList::OnHeaderViewChanged()
|
|||||||
QSettings().setValue(QStringLiteral("tableheader/state"),
|
QSettings().setValue(QStringLiteral("tableheader/state"),
|
||||||
m_list->horizontalHeader()->saveState());
|
m_list->horizontalHeader()->saveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameList::SetSearchTerm(const QString& term)
|
||||||
|
{
|
||||||
|
m_model->SetSearchTerm(term);
|
||||||
|
|
||||||
|
m_list_proxy->invalidate();
|
||||||
|
m_grid_proxy->invalidate();
|
||||||
|
}
|
||||||
|
@ -27,9 +27,10 @@ public:
|
|||||||
void SetListView() { SetPreferredView(true); }
|
void SetListView() { SetPreferredView(true); }
|
||||||
void SetGridView() { SetPreferredView(false); }
|
void SetGridView() { SetPreferredView(false); }
|
||||||
void SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); }
|
void SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); }
|
||||||
|
void SetSearchTerm(const QString& term);
|
||||||
|
|
||||||
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
||||||
void OnGameListVisibilityChanged();
|
void OnGameListVisibilityChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameSelected();
|
void GameSelected();
|
||||||
void NetPlayHost(const QString& game_id);
|
void NetPlayHost(const QString& game_id);
|
||||||
|
@ -150,6 +150,10 @@ bool GameListModel::ShouldDisplayGameListItem(int index) const
|
|||||||
{
|
{
|
||||||
const UICommon::GameFile& game = *m_games[index];
|
const UICommon::GameFile& game = *m_games[index];
|
||||||
|
|
||||||
|
if (!m_term.isEmpty() &&
|
||||||
|
!QString::fromStdString(game.GetName()).contains(m_term, Qt::CaseInsensitive))
|
||||||
|
return false;
|
||||||
|
|
||||||
const bool show_platform = [&game] {
|
const bool show_platform = [&game] {
|
||||||
switch (game.GetPlatform())
|
switch (game.GetPlatform())
|
||||||
{
|
{
|
||||||
@ -244,3 +248,8 @@ int GameListModel::FindGame(const std::string& path) const
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameListModel::SetSearchTerm(const QString& term)
|
||||||
|
{
|
||||||
|
m_term = term;
|
||||||
|
}
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
return QString::fromStdString(m_games[index]->GetUniqueIdentifier());
|
return QString::fromStdString(m_games[index]->GetUniqueIdentifier());
|
||||||
}
|
}
|
||||||
bool ShouldDisplayGameListItem(int index) const;
|
bool ShouldDisplayGameListItem(int index) const;
|
||||||
|
void SetSearchTerm(const QString& term);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COL_PLATFORM = 0,
|
COL_PLATFORM = 0,
|
||||||
@ -60,4 +62,5 @@ private:
|
|||||||
|
|
||||||
GameTracker m_tracker;
|
GameTracker m_tracker;
|
||||||
QList<std::shared_ptr<const UICommon::GameFile>> m_games;
|
QList<std::shared_ptr<const UICommon::GameFile>> m_games;
|
||||||
|
QString m_term;
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -65,6 +66,7 @@
|
|||||||
#include "DolphinQt2/QtUtils/RunOnObject.h"
|
#include "DolphinQt2/QtUtils/RunOnObject.h"
|
||||||
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
#include "DolphinQt2/QtUtils/WindowActivationEventFilter.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
|
#include "DolphinQt2/SearchBar.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
#include "DolphinQt2/TAS/GCTASInputWindow.h"
|
#include "DolphinQt2/TAS/GCTASInputWindow.h"
|
||||||
#include "DolphinQt2/TAS/WiiTASInputWindow.h"
|
#include "DolphinQt2/TAS/WiiTASInputWindow.h"
|
||||||
@ -164,6 +166,7 @@ void MainWindow::CreateComponents()
|
|||||||
{
|
{
|
||||||
m_menu_bar = new MenuBar(this);
|
m_menu_bar = new MenuBar(this);
|
||||||
m_tool_bar = new ToolBar(this);
|
m_tool_bar = new ToolBar(this);
|
||||||
|
m_search_bar = new SearchBar(this);
|
||||||
m_game_list = new GameList(this);
|
m_game_list = new GameList(this);
|
||||||
m_render_widget = new RenderWidget;
|
m_render_widget = new RenderWidget;
|
||||||
m_stack = new QStackedWidget(this);
|
m_stack = new QStackedWidget(this);
|
||||||
@ -275,6 +278,8 @@ void MainWindow::ConnectMenuBar()
|
|||||||
// View
|
// View
|
||||||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||||
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
|
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
|
||||||
|
connect(m_menu_bar, &MenuBar::ToggleSearch, m_search_bar, &SearchBar::Toggle);
|
||||||
|
|
||||||
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
|
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
|
||||||
&GameList::OnColumnVisibilityToggled);
|
&GameList::OnColumnVisibilityToggled);
|
||||||
|
|
||||||
@ -372,7 +377,16 @@ void MainWindow::ConnectRenderWidget()
|
|||||||
|
|
||||||
void MainWindow::ConnectStack()
|
void MainWindow::ConnectStack()
|
||||||
{
|
{
|
||||||
m_stack->addWidget(m_game_list);
|
auto* widget = new QWidget;
|
||||||
|
auto* layout = new QVBoxLayout;
|
||||||
|
widget->setLayout(layout);
|
||||||
|
|
||||||
|
layout->addWidget(m_game_list);
|
||||||
|
layout->addWidget(m_search_bar);
|
||||||
|
|
||||||
|
connect(m_search_bar, &SearchBar::Search, m_game_list, &GameList::SetSearchTerm);
|
||||||
|
|
||||||
|
m_stack->addWidget(widget);
|
||||||
|
|
||||||
setCentralWidget(m_stack);
|
setCentralWidget(m_stack);
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ class NetPlayClient;
|
|||||||
class NetPlayDialog;
|
class NetPlayDialog;
|
||||||
class NetPlayServer;
|
class NetPlayServer;
|
||||||
class NetPlaySetupDialog;
|
class NetPlaySetupDialog;
|
||||||
|
class SearchBar;
|
||||||
class SettingsWindow;
|
class SettingsWindow;
|
||||||
class ControllersWindow;
|
class ControllersWindow;
|
||||||
class DragEnterEvent;
|
class DragEnterEvent;
|
||||||
@ -137,6 +138,7 @@ private:
|
|||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
ToolBar* m_tool_bar;
|
ToolBar* m_tool_bar;
|
||||||
MenuBar* m_menu_bar;
|
MenuBar* m_menu_bar;
|
||||||
|
SearchBar* m_search_bar;
|
||||||
GameList* m_game_list;
|
GameList* m_game_list;
|
||||||
RenderWidget* m_render_widget;
|
RenderWidget* m_render_widget;
|
||||||
bool m_rendering_to_main;
|
bool m_rendering_to_main;
|
||||||
|
@ -357,6 +357,10 @@ void MenuBar::AddViewMenu()
|
|||||||
view_menu->addSeparator();
|
view_menu->addSeparator();
|
||||||
AddShowPlatformsMenu(view_menu);
|
AddShowPlatformsMenu(view_menu);
|
||||||
AddShowRegionsMenu(view_menu);
|
AddShowRegionsMenu(view_menu);
|
||||||
|
|
||||||
|
view_menu->addSeparator();
|
||||||
|
AddAction(view_menu, tr("Search"), this, &MenuBar::ToggleSearch,
|
||||||
|
QKeySequence(QStringLiteral("Ctrl+F")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddOptionsMenu()
|
void MenuBar::AddOptionsMenu()
|
||||||
|
@ -82,6 +82,7 @@ signals:
|
|||||||
// View
|
// View
|
||||||
void ShowList();
|
void ShowList();
|
||||||
void ShowGrid();
|
void ShowGrid();
|
||||||
|
void ToggleSearch();
|
||||||
void ColumnVisibilityToggled(const QString& row, bool visible);
|
void ColumnVisibilityToggled(const QString& row, bool visible);
|
||||||
void GameListPlatformVisibilityToggled(const QString& row, bool visible);
|
void GameListPlatformVisibilityToggled(const QString& row, bool visible);
|
||||||
void GameListRegionVisibilityToggled(const QString& row, bool visible);
|
void GameListRegionVisibilityToggled(const QString& row, bool visible);
|
||||||
|
54
Source/Core/DolphinQt2/SearchBar.cpp
Normal file
54
Source/Core/DolphinQt2/SearchBar.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// Copyright 2018 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DolphinQt2/SearchBar.h"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
SearchBar::SearchBar(QWidget* parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
CreateWidgets();
|
||||||
|
ConnectWidgets();
|
||||||
|
|
||||||
|
setFixedHeight(32);
|
||||||
|
|
||||||
|
setHidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchBar::CreateWidgets()
|
||||||
|
{
|
||||||
|
m_search_edit = new QLineEdit;
|
||||||
|
m_close_button = new QPushButton(tr("Close"));
|
||||||
|
|
||||||
|
m_search_edit->setPlaceholderText(tr("Type your search term here"));
|
||||||
|
|
||||||
|
auto* layout = new QHBoxLayout;
|
||||||
|
|
||||||
|
layout->addWidget(m_search_edit);
|
||||||
|
layout->addWidget(m_close_button);
|
||||||
|
layout->setMargin(0);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchBar::Toggle()
|
||||||
|
{
|
||||||
|
m_search_edit->clear();
|
||||||
|
|
||||||
|
setHidden(isVisible());
|
||||||
|
|
||||||
|
if (isVisible())
|
||||||
|
m_search_edit->setFocus();
|
||||||
|
else
|
||||||
|
m_search_edit->clearFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchBar::ConnectWidgets()
|
||||||
|
{
|
||||||
|
connect(m_search_edit, &QLineEdit::textChanged, this, &SearchBar::Search);
|
||||||
|
connect(m_close_button, &QPushButton::pressed, this, &SearchBar::Toggle);
|
||||||
|
}
|
31
Source/Core/DolphinQt2/SearchBar.h
Normal file
31
Source/Core/DolphinQt2/SearchBar.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2018 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
class QLineEdit;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
class SearchBar : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SearchBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
void Toggle();
|
||||||
|
signals:
|
||||||
|
void Search(const QString& serach);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateWidgets();
|
||||||
|
void ConnectWidgets();
|
||||||
|
|
||||||
|
QLineEdit* m_search_edit;
|
||||||
|
QCheckBox* m_wii_check;
|
||||||
|
QCheckBox* m_gc_check;
|
||||||
|
QPushButton* m_close_button;
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user