From 64a060fcf62b32e4a9739717b39616d826933a85 Mon Sep 17 00:00:00 2001 From: Jonathan Young Date: Thu, 15 May 2014 17:06:20 +1000 Subject: [PATCH] When installing from CD, have the user select a drive/directory instead of making them find pak0.pk3 on the CD. --- installwizard_setup.cpp | 26 +++++++++---- installwizard_setup.h | 2 +- installwizard_setup.ui | 84 +++++++++++++++++++---------------------- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/installwizard_setup.cpp b/installwizard_setup.cpp index 1e27c35..9dd3fb1 100644 --- a/installwizard_setup.cpp +++ b/installwizard_setup.cpp @@ -19,6 +19,14 @@ InstallWizard_Setup::InstallWizard_Setup(QWidget *parent, Settings *settings) : ui->rbInstall->setChecked(true); ui->stackPages->setCurrentIndex(Page_Install); #endif + + // Populate drives list. + QFileInfoList drives = QDir::drives(); + + for (int i = 0; i < drives.size(); i++) + { + ui->cbInstallSource->addItem(drives.at(i).absoluteFilePath()); + } } InstallWizard_Setup::~InstallWizard_Setup() @@ -50,9 +58,11 @@ bool InstallWizard_Setup::validatePage() { if (ui->stackPages->currentIndex() == Page_Install) { - if (!QFileInfo::exists(ui->txtInstallSource->text())) + QDir dir(ui->cbInstallSource->currentText()); + + if (!dir.exists()) { - QMessageBox::warning(wizard(), "Missing source", QString("Source file '%1' does not exist.").arg(ui->txtInstallSource->text())); + QMessageBox::warning(wizard(), "Missing source", "Source directory does not exist. Please select a valid directory."); return false; } @@ -60,7 +70,7 @@ bool InstallWizard_Setup::validatePage() ((InstallWizard *)wizard())->setIsQuake3PatchRequired(true); // Copy page will copy baseq3/pak0.pk3. - ((InstallWizard *)wizard())->addCopyFile(ui->txtInstallSource->text(), ui->txtInstallDest->text() + QString("/baseq3/pak0.pk3")); + ((InstallWizard *)wizard())->addCopyFile(ui->cbInstallSource->currentText() + QString("/QUAKE3/baseq3/pak0.pk3"), ui->txtInstallDest->text() + QString("/baseq3/pak0.pk3")); registerField("quake3Path", ui->txtInstallDest); } else if (ui->stackPages->currentIndex() == Page_InstallSteam) @@ -138,7 +148,7 @@ bool InstallWizard_Setup::isComplete() const { if (ui->stackPages->currentIndex() == Page_Install) { - return !ui->txtInstallSource->text().isEmpty() && !ui->txtInstallDest->text().isEmpty(); + return !ui->cbInstallSource->currentText().isEmpty() && !ui->txtInstallDest->text().isEmpty(); } else if (ui->stackPages->currentIndex() == Page_InstallSteam) { @@ -212,17 +222,17 @@ void InstallWizard_Setup::on_txtLocatePath_textChanged(const QString & /*arg1*/) void InstallWizard_Setup::on_btnInstallBrowseSource_clicked() { - const QString location = QFileDialog::getOpenFileName(wizard(), "Select pak0.pk3 location", QString(), "Quake III Arena Pak File (pak0.pk3)"); + const QString location = QFileDialog::getExistingDirectory(wizard(), "Select Quake III Arena CD-ROM directory", ui->cbInstallSource->currentText()); if (!location.isEmpty()) { - ui->txtInstallSource->setText(location); + ui->cbInstallSource->setCurrentText(location); } } void InstallWizard_Setup::on_btnInstallBrowseDest_clicked() { - const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Location"), ui->txtInstallDest->text()); + const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Install Directory"), ui->txtInstallDest->text()); if (!location.isEmpty()) { @@ -230,7 +240,7 @@ void InstallWizard_Setup::on_btnInstallBrowseDest_clicked() } } -void InstallWizard_Setup::on_txtInstallSource_textChanged(const QString & /*arg1*/) +void InstallWizard_Setup::on_cbInstallSource_currentTextChanged(const QString & /*arg1*/) { emit completeChanged(); } diff --git a/installwizard_setup.h b/installwizard_setup.h index 17ebc80..7fab609 100644 --- a/installwizard_setup.h +++ b/installwizard_setup.h @@ -36,7 +36,7 @@ private slots: void on_btnInstallBrowseDest_clicked(); - void on_txtInstallSource_textChanged(const QString &arg1); + void on_cbInstallSource_currentTextChanged(const QString &arg1); void on_txtInstallDest_textChanged(const QString &arg1); diff --git a/installwizard_setup.ui b/installwizard_setup.ui index d3ce71c..f544b12 100644 --- a/installwizard_setup.ui +++ b/installwizard_setup.ui @@ -99,52 +99,44 @@ - - - - - - - Source (pak0.pk3): - - - - - - - - - - - - Browse... - - - - - - - - - Destination: - - - - - - - - - - - - Browse... - - - - - - + + + + + CD-ROM Drive: + + + + + + + true + + + + + + + Browse... + + + + + + + Destination: + + + + + + + + + + Browse... + +