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 =
|
||||
QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
Settings::Instance().AddPath(dir);
|
||||
}
|
||||
|
||||
void PathDialog::BrowseDefaultGame()
|
||||
|
@ -103,6 +94,13 @@ QGroupBox* PathDialog::MakeGameFolderBox()
|
|||
m_path_list = new QListWidget;
|
||||
m_path_list->insertItems(0, Settings::Instance().GetPaths());
|
||||
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);
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout;
|
||||
|
@ -168,9 +166,8 @@ QGridLayout* PathDialog::MakePathsLayout()
|
|||
|
||||
void PathDialog::RemovePath()
|
||||
{
|
||||
int row = m_path_list->currentRow();
|
||||
if (row < 0)
|
||||
auto item = m_path_list->currentItem();
|
||||
if (!item)
|
||||
return;
|
||||
emit PathRemoved(m_path_list->takeItem(row)->text());
|
||||
Settings::Instance().RemovePath(row);
|
||||
Settings::Instance().RemovePath(item->text());
|
||||
}
|
||||
|
|
|
@ -23,10 +23,6 @@ public slots:
|
|||
void BrowseApploader();
|
||||
void BrowseWiiNAND();
|
||||
|
||||
signals:
|
||||
void PathAdded(QString path);
|
||||
void PathRemoved(QString path);
|
||||
|
||||
private:
|
||||
QGroupBox* MakeGameFolderBox();
|
||||
QGridLayout* MakePathsLayout();
|
||||
|
|
|
@ -42,8 +42,8 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent)
|
|||
|
||||
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(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded);
|
||||
connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ private slots:
|
|||
|
||||
signals:
|
||||
void GameSelected();
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
|
||||
private:
|
||||
void MakeTableView();
|
||||
|
|
|
@ -40,7 +40,6 @@ MainWindow::MainWindow() : QMainWindow(nullptr)
|
|||
CreateComponents();
|
||||
|
||||
ConnectGameList();
|
||||
ConnectPathsDialog();
|
||||
ConnectToolBar();
|
||||
ConnectRenderWidget();
|
||||
ConnectStack();
|
||||
|
@ -169,12 +168,6 @@ void MainWindow::ConnectStack()
|
|||
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()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
|
|
|
@ -63,7 +63,6 @@ private:
|
|||
void ConnectRenderWidget();
|
||||
void ConnectStack();
|
||||
void ConnectToolBar();
|
||||
void ConnectPathsDialog();
|
||||
|
||||
void InitControllers();
|
||||
void ShutdownControllers();
|
||||
|
|
|
@ -61,16 +61,32 @@ QStringList Settings::GetPaths() const
|
|||
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)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||
}
|
||||
|
||||
void Settings::RemovePath(int i)
|
||||
void Settings::RemovePath(const QString& path)
|
||||
{
|
||||
QStringList paths = GetPaths();
|
||||
int i = paths.indexOf(path);
|
||||
if (i < 0)
|
||||
return;
|
||||
|
||||
paths.removeAt(i);
|
||||
SetPaths(paths);
|
||||
emit PathRemoved(path);
|
||||
}
|
||||
|
||||
QString Settings::GetDefaultGame() const
|
||||
|
|
|
@ -35,8 +35,9 @@ public:
|
|||
|
||||
// GameList
|
||||
QStringList GetPaths() const;
|
||||
void AddPath(const QString& path);
|
||||
void SetPaths(const QStringList& paths);
|
||||
void RemovePath(int i);
|
||||
void RemovePath(const QString& path);
|
||||
QString GetDefaultGame() const;
|
||||
void SetDefaultGame(const QString& path);
|
||||
QString GetDVDRoot() const;
|
||||
|
@ -107,6 +108,10 @@ public:
|
|||
|
||||
void Save();
|
||||
|
||||
signals:
|
||||
void PathAdded(const QString&);
|
||||
void PathRemoved(const QString&);
|
||||
|
||||
private:
|
||||
Settings();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue