DolphinQt2: move path signals from PathDialog to Settings
This commit is contained in:
parent
548522877a
commit
47e8cb97b4
|
@ -37,16 +37,7 @@ void PathDialog::Browse()
|
||||||
QString dir =
|
QString dir =
|
||||||
QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath());
|
QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath());
|
||||||
if (!dir.isEmpty())
|
if (!dir.isEmpty())
|
||||||
{
|
Settings::Instance().AddPath(dir);
|
||||||
QStringList game_folders = Settings::Instance().GetPaths();
|
|
||||||
if (!game_folders.contains(dir))
|
|
||||||
{
|
|
||||||
game_folders << dir;
|
|
||||||
Settings::Instance().SetPaths(game_folders);
|
|
||||||
m_path_list->addItem(dir);
|
|
||||||
emit PathAdded(dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathDialog::BrowseDefaultGame()
|
void PathDialog::BrowseDefaultGame()
|
||||||
|
@ -103,6 +94,13 @@ QGroupBox* PathDialog::MakeGameFolderBox()
|
||||||
m_path_list = new QListWidget;
|
m_path_list = new QListWidget;
|
||||||
m_path_list->insertItems(0, Settings::Instance().GetPaths());
|
m_path_list->insertItems(0, Settings::Instance().GetPaths());
|
||||||
m_path_list->setSpacing(1);
|
m_path_list->setSpacing(1);
|
||||||
|
connect(&Settings::Instance(), &Settings::PathAdded,
|
||||||
|
[this](const QString& dir) { m_path_list->addItem(dir); });
|
||||||
|
connect(&Settings::Instance(), &Settings::PathRemoved, [this](const QString& dir) {
|
||||||
|
auto items = m_path_list->findItems(dir, Qt::MatchExactly);
|
||||||
|
for (auto& item : items)
|
||||||
|
delete item;
|
||||||
|
});
|
||||||
vlayout->addWidget(m_path_list);
|
vlayout->addWidget(m_path_list);
|
||||||
|
|
||||||
QHBoxLayout* hlayout = new QHBoxLayout;
|
QHBoxLayout* hlayout = new QHBoxLayout;
|
||||||
|
@ -168,9 +166,8 @@ QGridLayout* PathDialog::MakePathsLayout()
|
||||||
|
|
||||||
void PathDialog::RemovePath()
|
void PathDialog::RemovePath()
|
||||||
{
|
{
|
||||||
int row = m_path_list->currentRow();
|
auto item = m_path_list->currentItem();
|
||||||
if (row < 0)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
emit PathRemoved(m_path_list->takeItem(row)->text());
|
Settings::Instance().RemovePath(item->text());
|
||||||
Settings::Instance().RemovePath(row);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,6 @@ public slots:
|
||||||
void BrowseApploader();
|
void BrowseApploader();
|
||||||
void BrowseWiiNAND();
|
void BrowseWiiNAND();
|
||||||
|
|
||||||
signals:
|
|
||||||
void PathAdded(QString path);
|
|
||||||
void PathRemoved(QString path);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGroupBox* MakeGameFolderBox();
|
QGroupBox* MakeGameFolderBox();
|
||||||
QGridLayout* MakePathsLayout();
|
QGridLayout* MakePathsLayout();
|
||||||
|
|
|
@ -42,8 +42,8 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent)
|
||||||
|
|
||||||
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||||
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||||
connect(this, &GameList::DirectoryAdded, m_model, &GameListModel::DirectoryAdded);
|
connect(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded);
|
||||||
connect(this, &GameList::DirectoryRemoved, m_model, &GameListModel::DirectoryRemoved);
|
connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ private slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameSelected();
|
void GameSelected();
|
||||||
void DirectoryAdded(const QString& dir);
|
|
||||||
void DirectoryRemoved(const QString& dir);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeTableView();
|
void MakeTableView();
|
||||||
|
|
|
@ -40,7 +40,6 @@ MainWindow::MainWindow() : QMainWindow(nullptr)
|
||||||
CreateComponents();
|
CreateComponents();
|
||||||
|
|
||||||
ConnectGameList();
|
ConnectGameList();
|
||||||
ConnectPathsDialog();
|
|
||||||
ConnectToolBar();
|
ConnectToolBar();
|
||||||
ConnectRenderWidget();
|
ConnectRenderWidget();
|
||||||
ConnectStack();
|
ConnectStack();
|
||||||
|
@ -169,12 +168,6 @@ void MainWindow::ConnectStack()
|
||||||
setCentralWidget(m_stack);
|
setCentralWidget(m_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ConnectPathsDialog()
|
|
||||||
{
|
|
||||||
connect(m_paths_dialog, &PathDialog::PathAdded, m_game_list, &GameList::DirectoryAdded);
|
|
||||||
connect(m_paths_dialog, &PathDialog::PathRemoved, m_game_list, &GameList::DirectoryRemoved);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::Open()
|
void MainWindow::Open()
|
||||||
{
|
{
|
||||||
QString file = QFileDialog::getOpenFileName(
|
QString file = QFileDialog::getOpenFileName(
|
||||||
|
|
|
@ -63,7 +63,6 @@ private:
|
||||||
void ConnectRenderWidget();
|
void ConnectRenderWidget();
|
||||||
void ConnectStack();
|
void ConnectStack();
|
||||||
void ConnectToolBar();
|
void ConnectToolBar();
|
||||||
void ConnectPathsDialog();
|
|
||||||
|
|
||||||
void InitControllers();
|
void InitControllers();
|
||||||
void ShutdownControllers();
|
void ShutdownControllers();
|
||||||
|
|
|
@ -61,16 +61,32 @@ QStringList Settings::GetPaths() const
|
||||||
return value(QStringLiteral("GameList/Paths")).toStringList();
|
return value(QStringLiteral("GameList/Paths")).toStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::AddPath(const QString& path)
|
||||||
|
{
|
||||||
|
QStringList game_folders = Settings::Instance().GetPaths();
|
||||||
|
if (!game_folders.contains(path))
|
||||||
|
{
|
||||||
|
game_folders << path;
|
||||||
|
Settings::Instance().SetPaths(game_folders);
|
||||||
|
emit PathAdded(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::SetPaths(const QStringList& paths)
|
void Settings::SetPaths(const QStringList& paths)
|
||||||
{
|
{
|
||||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::RemovePath(int i)
|
void Settings::RemovePath(const QString& path)
|
||||||
{
|
{
|
||||||
QStringList paths = GetPaths();
|
QStringList paths = GetPaths();
|
||||||
|
int i = paths.indexOf(path);
|
||||||
|
if (i < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
paths.removeAt(i);
|
paths.removeAt(i);
|
||||||
SetPaths(paths);
|
SetPaths(paths);
|
||||||
|
emit PathRemoved(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::GetDefaultGame() const
|
QString Settings::GetDefaultGame() const
|
||||||
|
|
|
@ -35,8 +35,9 @@ public:
|
||||||
|
|
||||||
// GameList
|
// GameList
|
||||||
QStringList GetPaths() const;
|
QStringList GetPaths() const;
|
||||||
|
void AddPath(const QString& path);
|
||||||
void SetPaths(const QStringList& paths);
|
void SetPaths(const QStringList& paths);
|
||||||
void RemovePath(int i);
|
void RemovePath(const QString& path);
|
||||||
QString GetDefaultGame() const;
|
QString GetDefaultGame() const;
|
||||||
void SetDefaultGame(const QString& path);
|
void SetDefaultGame(const QString& path);
|
||||||
QString GetDVDRoot() const;
|
QString GetDVDRoot() const;
|
||||||
|
@ -107,6 +108,10 @@ public:
|
||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void PathAdded(const QString&);
|
||||||
|
void PathRemoved(const QString&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings();
|
Settings();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue