When installing from CD, have the user select a drive/directory instead of making them find pak0.pk3 on the CD.

This commit is contained in:
Jonathan Young 2014-05-15 17:06:20 +10:00
parent 0837c47531
commit 64a060fcf6
3 changed files with 57 additions and 55 deletions

View file

@ -19,6 +19,14 @@ InstallWizard_Setup::InstallWizard_Setup(QWidget *parent, Settings *settings) :
ui->rbInstall->setChecked(true); ui->rbInstall->setChecked(true);
ui->stackPages->setCurrentIndex(Page_Install); ui->stackPages->setCurrentIndex(Page_Install);
#endif #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() InstallWizard_Setup::~InstallWizard_Setup()
@ -50,9 +58,11 @@ bool InstallWizard_Setup::validatePage()
{ {
if (ui->stackPages->currentIndex() == Page_Install) 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; return false;
} }
@ -60,7 +70,7 @@ bool InstallWizard_Setup::validatePage()
((InstallWizard *)wizard())->setIsQuake3PatchRequired(true); ((InstallWizard *)wizard())->setIsQuake3PatchRequired(true);
// Copy page will copy baseq3/pak0.pk3. // 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); registerField("quake3Path", ui->txtInstallDest);
} }
else if (ui->stackPages->currentIndex() == Page_InstallSteam) else if (ui->stackPages->currentIndex() == Page_InstallSteam)
@ -138,7 +148,7 @@ bool InstallWizard_Setup::isComplete() const
{ {
if (ui->stackPages->currentIndex() == Page_Install) 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) 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() 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()) if (!location.isEmpty())
{ {
ui->txtInstallSource->setText(location); ui->cbInstallSource->setCurrentText(location);
} }
} }
void InstallWizard_Setup::on_btnInstallBrowseDest_clicked() 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()) 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(); emit completeChanged();
} }

View file

@ -36,7 +36,7 @@ private slots:
void on_btnInstallBrowseDest_clicked(); 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); void on_txtInstallDest_textChanged(const QString &arg1);

View file

@ -99,52 +99,44 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="pageInstallFromCd"> <widget class="QWidget" name="pageInstallFromCd">
<layout class="QFormLayout" name="formLayout_2"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0">
<layout class="QFormLayout" name="formLayout"> <widget class="QLabel" name="label">
<item row="0" column="0"> <property name="text">
<widget class="QLabel" name="label"> <string>CD-ROM Drive:</string>
<property name="text"> </property>
<string>Source (pak0.pk3):</string> </widget>
</property> </item>
</widget> <item row="0" column="1">
</item> <widget class="QComboBox" name="cbInstallSource">
<item row="0" column="1"> <property name="editable">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <bool>true</bool>
<item> </property>
<widget class="QLineEdit" name="txtInstallSource"/> </widget>
</item> </item>
<item> <item row="0" column="2">
<widget class="QPushButton" name="btnInstallBrowseSource"> <widget class="QPushButton" name="btnInstallBrowseSource">
<property name="text"> <property name="text">
<string>Browse...</string> <string>Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="0">
</item> <widget class="QLabel" name="label_2">
<item row="1" column="0"> <property name="text">
<widget class="QLabel" name="label_2"> <string>Destination:</string>
<property name="text"> </property>
<string>Destination:</string> </widget>
</property> </item>
</widget> <item row="1" column="1">
</item> <widget class="QLineEdit" name="txtInstallDest"/>
<item row="1" column="1"> </item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <item row="1" column="2">
<item> <widget class="QPushButton" name="btnInstallBrowseDest">
<widget class="QLineEdit" name="txtInstallDest"/> <property name="text">
</item> <string>Browse...</string>
<item> </property>
<widget class="QPushButton" name="btnInstallBrowseDest"> </widget>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>