@ -4,6 +4,7 @@
# include <QMessageBox>
# include <QMessageBox>
# include <QDebug>
# include <QDebug>
# include <QDir>
# include <QDir>
# include <QTimer>
# include <components/files/configurationmanager.hpp>
# include <components/files/configurationmanager.hpp>
@ -39,6 +40,7 @@ Launcher::SettingsPage::SettingsPage(Files::ConfigurationManager &cfg,
mWizardInvoker = new ProcessInvoker ( ) ;
mWizardInvoker = new ProcessInvoker ( ) ;
mImporterInvoker = new ProcessInvoker ( ) ;
mImporterInvoker = new ProcessInvoker ( ) ;
resetProgressBar ( ) ;
connect ( mWizardInvoker - > getProcess ( ) , SIGNAL ( started ( ) ) ,
connect ( mWizardInvoker - > getProcess ( ) , SIGNAL ( started ( ) ) ,
this , SLOT ( wizardStarted ( ) ) ) ;
this , SLOT ( wizardStarted ( ) ) ) ;
@ -141,8 +143,13 @@ void Launcher::SettingsPage::on_importerButton_clicked()
qDebug ( ) < < " arguments " < < arguments ;
qDebug ( ) < < " arguments " < < arguments ;
// start the progress bar as a "bouncing ball"
progressBar - > setMaximum ( 0 ) ;
progressBar - > setValue ( 0 ) ;
if ( ! mImporterInvoker - > startProcess ( QLatin1String ( " openmw-iniimporter " ) , arguments , false ) )
if ( ! mImporterInvoker - > startProcess ( QLatin1String ( " openmw-iniimporter " ) , arguments , false ) )
return ;
{
resetProgressBar ( ) ;
}
}
}
void Launcher : : SettingsPage : : on_browseButton_clicked ( )
void Launcher : : SettingsPage : : on_browseButton_clicked ( )
@ -197,38 +204,36 @@ void Launcher::SettingsPage::importerStarted()
void Launcher : : SettingsPage : : importerFinished ( int exitCode , QProcess : : ExitStatus exitStatus )
void Launcher : : SettingsPage : : importerFinished ( int exitCode , QProcess : : ExitStatus exitStatus )
{
{
if ( exitCode ! = 0 | | exitStatus = = QProcess : : CrashExit )
if ( exitCode ! = 0 | | exitStatus = = QProcess : : CrashExit )
return ;
// Importer may have changed settings, so refresh
mMain - > reloadSettings ( ) ;
// Import selected data files from openmw.cfg
if ( addonsCheckBox - > isChecked ( ) )
{
{
// Because we've reloaded settings, the current content list matches content in OpenMW.cfg
resetProgressBar ( ) ;
QString oldContentListName = mLauncherSettings . getCurrentContentListName ( ) ;
if ( mProfileDialog - > exec ( ) = = QDialog : : Accepted )
{
// remove the current content list to prevent duplication
//... except, not allowed to delete the Default content list
if ( oldContentListName . compare ( DataFilesPage : : mDefaultContentListName ) ! = 0 )
{
mLauncherSettings . removeContentList ( oldContentListName ) ;
}
const QString newContentListName ( mProfileDialog - > lineEdit ( ) - > text ( ) ) ;
QMessageBox msgBox ;
const QStringList files ( mGameSettings . getContentList ( ) ) ;
msgBox . setWindowTitle ( tr ( " Importer finished " ) ) ;
mLauncherSettings . setCurrentContentListName ( newContentListName ) ;
msgBox . setStandardButtons ( QMessageBox : : Ok ) ;
mLauncherSettings . setContentList ( newContentListName , files ) ;
msgBox . setIcon ( QMessageBox : : Warning ) ;
msgBox . setText ( tr ( " Failed to import settings from INI file. " ) ) ;
msgBox . exec ( ) ;
}
else
{
// indicate progress finished
progressBar - > setMaximum ( 1 ) ;
progressBar - > setValue ( 1 ) ;
// Make DataFiles Page load the new content list.
// Importer may have changed settings, so refresh
mMain - > reloadSettings ( ) ;
mMain - > reloadSettings ( ) ;
}
}
}
importerButton - > setEnabled ( true ) ;
importerButton - > setEnabled ( true ) ;
}
}
void Launcher : : SettingsPage : : resetProgressBar ( )
{
// set progress bar to 0 %
progressBar - > setMaximum ( 1 ) ;
progressBar - > setValue ( 0 ) ;
}
void Launcher : : SettingsPage : : updateOkButton ( const QString & text )
void Launcher : : SettingsPage : : updateOkButton ( const QString & text )
{
{
// We do this here because we need to access the profiles
// We do this here because we need to access the profiles