Skip to content
Permalink
Browse files

Improved workflow of first run dialog based on feedback in #38616.

  • Loading branch information
timlinux authored and nyalldawson committed Dec 16, 2020
1 parent 8494c89 commit 8a7b918c3d7a4b35c2779c95f7ec55ac87755111
Showing with 25 additions and 30 deletions.
  1. +19 −20 src/app/main.cpp
  2. +0 −4 src/app/qgsfirstrundialog.cpp
  3. +0 −6 src/app/qgsfirstrundialog.h
  4. +6 −0 src/ui/qgsfirstrundialog.ui
@@ -1043,31 +1043,30 @@ int main( int argc, char *argv[] )
{
// Note: this flag is ka version number so that we can reset it once we change the version.
// Note2: Is this a good idea can we do it better.

QgsSettings migSettings;
int firstRunVersion = migSettings.value( QStringLiteral( "migration/firstRunVersionFlag" ), 0 ).toInt();
bool showWelcome = ( firstRunVersion == 0 || Qgis::versionInt() > firstRunVersion );

std::unique_ptr< QgsVersionMigration > migration( QgsVersionMigration::canMigrate( 20000, Qgis::versionInt() ) );
if ( migration && ( settingsMigrationForce || migration->requiresMigration() ) )
// Note3: Updated to only show if we have a migration from QGIS 2 - see https://github.com/qgis/QGIS/pull/38616
QString path = QSettings( "QGIS", "QGIS2" ).fileName() ;
if ( QFile::exists( path ) )
{
bool runMigration = true;
if ( !settingsMigrationForce && showWelcome )
QgsSettings migSettings;
int firstRunVersion = migSettings.value( QStringLiteral( "migration/firstRunVersionFlag" ), 0 ).toInt();
bool showWelcome = ( firstRunVersion == 0 || Qgis::versionInt() > firstRunVersion );
std::unique_ptr< QgsVersionMigration > migration( QgsVersionMigration::canMigrate( 20000, Qgis::versionInt() ) );
if ( migration && ( settingsMigrationForce || migration->requiresMigration() ) )
{
QgsFirstRunDialog dlg;
if ( ! QFile::exists( QSettings( "QGIS", "QGIS2" ).fileName() ) )
bool runMigration = true;
if ( !settingsMigrationForce && showWelcome )
{
dlg.hideMigration();
QgsFirstRunDialog dlg;
dlg.exec();
runMigration = dlg.migrateSettings();
migSettings.setValue( QStringLiteral( "migration/firstRunVersionFlag" ), Qgis::versionInt() );
}
dlg.exec();
runMigration = dlg.migrateSettings();
migSettings.setValue( QStringLiteral( "migration/firstRunVersionFlag" ), Qgis::versionInt() );
}

if ( runMigration )
{
QgsDebugMsg( QStringLiteral( "RUNNING MIGRATION" ) );
migration->runMigration();
if ( runMigration )
{
QgsDebugMsg( QStringLiteral( "RUNNING MIGRATION" ) );
migration->runMigration();
}
}
}
}
@@ -32,7 +32,3 @@ bool QgsFirstRunDialog::migrateSettings()
return ( mImportSettingsYes->isChecked() );
}

void QgsFirstRunDialog::hideMigration()
{
mMigrationWidget->hide();
}
@@ -30,12 +30,6 @@ class APP_EXPORT QgsFirstRunDialog : public QDialog, private Ui::QgsFirstRunDial

bool migrateSettings();

/**
* Hides the migration checkboxes
*/
void hideMigration();


signals:

public slots:
@@ -14,6 +14,9 @@
<string>Welcome to QGIS</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>50</number>
</property>
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
@@ -58,6 +61,9 @@
<item row="2" column="1">
<widget class="QWidget" name="mMigrationWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="mImportSettingsYes">
<property name="text">

0 comments on commit 8a7b918

Please sign in to comment.
You can’t perform that action at this time.