game_install_dialog.cpp: Implementing multiple game paths (Create and Read)
This commit is contained in:
parent
159be2c7f4
commit
45d3340021
|
@ -17,7 +17,7 @@ endif()
|
|||
|
||||
project(shadPS4)
|
||||
|
||||
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
|
||||
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" ON)
|
||||
|
||||
# This function should be passed a list of all files in a target. It will automatically generate file groups
|
||||
# following the directory hierarchy, so that the layout of the files in IDEs matches the one in the filesystem.
|
||||
|
|
|
@ -20,7 +20,12 @@
|
|||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "clang_cl_x64_x64" ]
|
||||
"inheritEnvironments": [ "clang_cl_x64_x64" ],
|
||||
"environments": [
|
||||
{
|
||||
"PATH": "C:/Qt/6.7.2/msvc2019_64/bin;${env.PATH}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "x64-Clang-RelWithDebInfo",
|
||||
|
|
|
@ -13,11 +13,16 @@
|
|||
#include <QVBoxLayout>
|
||||
|
||||
#include "game_install_dialog.h"
|
||||
#include <QListWidget>
|
||||
|
||||
GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
||||
auto layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(SetupGamesDirectory());
|
||||
|
||||
layout->addWidget(GameDirectoryList());
|
||||
// call list dialog here later
|
||||
|
||||
layout->addStretch();
|
||||
layout->addWidget(SetupDialogActions());
|
||||
|
||||
|
@ -27,9 +32,55 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
|||
|
||||
GameInstallDialog::~GameInstallDialog() {}
|
||||
|
||||
QWidget* GameInstallDialog::GameDirectoryList() {
|
||||
auto group = new QGroupBox("Gamepaths");
|
||||
auto layout = new QHBoxLayout(group);
|
||||
|
||||
// Input.
|
||||
|
||||
/*
|
||||
newItem->setText(path);
|
||||
listWidget->insertItem(1, newItem);
|
||||
*/
|
||||
// Browse button.
|
||||
//auto browse = new QPushButton("Browse");
|
||||
|
||||
//connect(browse, &QPushButton::clicked, this, &GameInstallDialog::Browse);
|
||||
|
||||
QListWidget* listWidget = new QListWidget(this);
|
||||
QFile file("shadPS4-gamepaths.txt");
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd()) {
|
||||
QString path = in.readLine();
|
||||
if (!path.isEmpty() && path.endsWith(";")) {
|
||||
path.chop(1);
|
||||
listWidget->addItem(path);
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
layout->addWidget(listWidget);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
QWidget* GameInstallDialog::GameDirectoryListDialog() {
|
||||
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(actions, &QDialogButtonBox::accepted, this, &GameInstallDialog::Save);
|
||||
return actions;
|
||||
}
|
||||
|
||||
void GameInstallDialog::Browse() {
|
||||
auto path = QFileDialog::getExistingDirectory(this, "Directory to install games");
|
||||
|
||||
QFile file("shadPS4-gamepaths.txt");
|
||||
if (file.open(QIODevice::Append | QIODevice::Text)) {
|
||||
QTextStream out(&file);
|
||||
out << path << ";\n";
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
m_gamesDirectory->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ public:
|
|||
GameInstallDialog();
|
||||
~GameInstallDialog();
|
||||
|
||||
QWidget* GameDirectoryList();
|
||||
QWidget* GameDirectoryListDialog();
|
||||
|
||||
private slots:
|
||||
void Browse();
|
||||
|
||||
|
|
Loading…
Reference in New Issue