Merge pull request #3424 from spxtr/DQt2
DQt2: Add a message if the game list is empty
This commit is contained in:
commit
3f5f52342a
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
#include "DolphinQt2/GameList/TableProxyModel.h"
|
||||
|
@ -18,15 +19,20 @@ GameList::GameList(QWidget* parent): QStackedWidget(parent)
|
|||
|
||||
MakeTableView();
|
||||
MakeListView();
|
||||
MakeEmptyView();
|
||||
|
||||
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(this, &GameList::DirectoryAdded, m_model, &GameListModel::DirectoryAdded);
|
||||
connect(this, &GameList::DirectoryRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||
|
||||
addWidget(m_table);
|
||||
addWidget(m_list);
|
||||
setCurrentWidget(m_table);
|
||||
addWidget(m_empty);
|
||||
m_prefer_table = Settings().GetPreferredView();
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
void GameList::MakeTableView()
|
||||
|
@ -63,6 +69,14 @@ void GameList::MakeTableView()
|
|||
header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::Fixed);
|
||||
}
|
||||
|
||||
void GameList::MakeEmptyView()
|
||||
{
|
||||
m_empty = new QLabel(this);
|
||||
m_empty->setText(tr("Dolphin did not find any game files.\n"
|
||||
"Open the Paths dialog to add game folders."));
|
||||
m_empty->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
void GameList::MakeListView()
|
||||
{
|
||||
m_list = new QListView(this);
|
||||
|
@ -94,3 +108,25 @@ QString GameList::GetSelectedGame() const
|
|||
}
|
||||
return QStringLiteral();
|
||||
}
|
||||
|
||||
void GameList::SetPreferredView(bool table)
|
||||
{
|
||||
m_prefer_table = table;
|
||||
Settings().SetPreferredView(table);
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
void GameList::ConsiderViewChange()
|
||||
{
|
||||
if (m_model->rowCount(QModelIndex()) > 0)
|
||||
{
|
||||
if (m_prefer_table)
|
||||
setCurrentWidget(m_table);
|
||||
else
|
||||
setCurrentWidget(m_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentWidget(m_empty);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStackedWidget>
|
||||
|
@ -22,18 +23,22 @@ public:
|
|||
QString GetSelectedGame() const;
|
||||
|
||||
public slots:
|
||||
void SetTableView() { setCurrentWidget(m_table); }
|
||||
void SetListView() { setCurrentWidget(m_list); }
|
||||
void SetTableView() { SetPreferredView(true); }
|
||||
void SetListView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||
|
||||
signals:
|
||||
void GameSelected();
|
||||
void DirectoryAdded(QString dir);
|
||||
void DirectoryRemoved(QString dir);
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
|
||||
private:
|
||||
void MakeTableView();
|
||||
void MakeListView();
|
||||
void MakeEmptyView();
|
||||
// We only have two views, just use a bool to distinguish.
|
||||
void SetPreferredView(bool table);
|
||||
void ConsiderViewChange();
|
||||
|
||||
GameListModel* m_model;
|
||||
QSortFilterProxyModel* m_table_proxy;
|
||||
|
@ -41,4 +46,6 @@ private:
|
|||
|
||||
QListView* m_list;
|
||||
QTableView* m_table;
|
||||
QLabel* m_empty;
|
||||
bool m_prefer_table;
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
|||
endInsertRows();
|
||||
}
|
||||
|
||||
void GameListModel::RemoveGame(QString path)
|
||||
void GameListModel::RemoveGame(const QString& path)
|
||||
{
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
|
|
|
@ -42,11 +42,11 @@ public:
|
|||
|
||||
public slots:
|
||||
void UpdateGame(QSharedPointer<GameFile> game);
|
||||
void RemoveGame(QString path);
|
||||
void RemoveGame(const QString& path);
|
||||
|
||||
signals:
|
||||
void DirectoryAdded(QString dir);
|
||||
void DirectoryRemoved(QString dir);
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
|
||||
private:
|
||||
// Index in m_games, or -1 if it isn't found
|
||||
|
|
|
@ -45,7 +45,7 @@ GameTracker::~GameTracker()
|
|||
m_loader_thread.wait();
|
||||
}
|
||||
|
||||
void GameTracker::AddDirectory(QString dir)
|
||||
void GameTracker::AddDirectory(const QString& dir)
|
||||
{
|
||||
if (!QFileInfo(dir).exists())
|
||||
return;
|
||||
|
@ -53,7 +53,7 @@ void GameTracker::AddDirectory(QString dir)
|
|||
UpdateDirectory(dir);
|
||||
}
|
||||
|
||||
void GameTracker::RemoveDirectory(QString dir)
|
||||
void GameTracker::RemoveDirectory(const QString& dir)
|
||||
{
|
||||
removePath(dir);
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
|
|
|
@ -30,14 +30,14 @@ public:
|
|||
~GameTracker();
|
||||
|
||||
public slots:
|
||||
void AddDirectory(QString dir);
|
||||
void RemoveDirectory(QString dir);
|
||||
void AddDirectory(const QString& dir);
|
||||
void RemoveDirectory(const QString& dir);
|
||||
|
||||
signals:
|
||||
void GameLoaded(QSharedPointer<GameFile> game);
|
||||
void GameRemoved(QString path);
|
||||
void GameRemoved(const QString& path);
|
||||
|
||||
void PathChanged(QString path);
|
||||
void PathChanged(const QString& path);
|
||||
|
||||
private:
|
||||
void UpdateDirectory(const QString& dir);
|
||||
|
@ -54,7 +54,7 @@ class GameLoader final : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void LoadGame(QString path)
|
||||
void LoadGame(const QString& path)
|
||||
{
|
||||
GameFile* game = new GameFile(path);
|
||||
if (game->IsValid())
|
||||
|
|
|
@ -30,7 +30,7 @@ public slots:
|
|||
void SetRenderFullscreen(bool fullscreen);
|
||||
|
||||
signals:
|
||||
void RequestTitle(QString title);
|
||||
void RequestTitle(const QString& title);
|
||||
void RequestStop();
|
||||
void RequestRenderSize(int w, int h);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QActionGroup>
|
||||
|
||||
#include "DolphinQt2/MenuBar.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
MenuBar::MenuBar(QWidget* parent)
|
||||
: QMenuBar(parent)
|
||||
|
@ -46,8 +47,9 @@ void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
|||
list_group->addAction(table_view);
|
||||
list_group->addAction(list_view);
|
||||
|
||||
// TODO load this from settings
|
||||
table_view->setChecked(true);
|
||||
bool prefer_table = Settings().GetPreferredView();
|
||||
table_view->setChecked(prefer_table);
|
||||
list_view->setChecked(!prefer_table);
|
||||
|
||||
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
|
||||
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
||||
|
|
|
@ -105,6 +105,16 @@ DiscIO::IVolume::ELanguage Settings::GetGCSystemLanguage() const
|
|||
return SConfig::GetInstance().GetCurrentLanguage(false);
|
||||
}
|
||||
|
||||
bool Settings::GetPreferredView() const
|
||||
{
|
||||
return value(QStringLiteral("PreferredView"), true).toBool();
|
||||
}
|
||||
|
||||
void Settings::SetPreferredView(bool table)
|
||||
{
|
||||
setValue(QStringLiteral("PreferredView"), table);
|
||||
}
|
||||
|
||||
bool Settings::GetConfirmStop() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
void SetWiiNAND(const QString& path);
|
||||
DiscIO::IVolume::ELanguage GetWiiSystemLanguage() const;
|
||||
DiscIO::IVolume::ELanguage GetGCSystemLanguage() const;
|
||||
bool GetPreferredView() const;
|
||||
void SetPreferredView(bool table);
|
||||
|
||||
// Emulation
|
||||
bool GetConfirmStop() const;
|
||||
|
|
Loading…
Reference in New Issue