From 3046979a5f2af59d743c79a6ebb85ac406ffb45b Mon Sep 17 00:00:00 2001 From: Nathan Woodrow Date: Tue, 12 Dec 2017 20:39:15 +1000 Subject: [PATCH] Add first run and settings migration screen (#5838) --- src/app/CMakeLists.txt | 2 + src/app/main.cpp | 23 +++- src/app/qgsfirstrundialog.cpp | 33 ++++++ src/app/qgsfirstrundialog.h | 38 +++++++ src/ui/qgsfirstrundialog.ui | 199 ++++++++++++++++++++++++++++++++++ 5 files changed, 293 insertions(+), 2 deletions(-) create mode 100644 src/app/qgsfirstrundialog.cpp create mode 100644 src/app/qgsfirstrundialog.h create mode 100644 src/ui/qgsfirstrundialog.ui diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index ec8120ea0da5..df6269f5084c 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -42,6 +42,7 @@ SET(QGIS_APP_SRCS qgsdiagramproperties.cpp qgsdisplayangle.cpp qgsfieldcalculator.cpp + qgsfirstrundialog.cpp qgssourcefieldsproperties.cpp qgsattributesformproperties.cpp qgsidentifyresultsdialog.cpp @@ -263,6 +264,7 @@ SET (QGIS_APP_MOC_HDRS qgsdxfexportdialog.h qgsfeatureaction.h qgsfieldcalculator.h + qgsfirstrundialog.h qgssourcefieldsproperties.h qgsattributesformproperties.h qgsformannotationdialog.h diff --git a/src/app/main.cpp b/src/app/main.cpp index 46a016e85cba..86262e01b054 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -100,6 +100,7 @@ typedef SInt32 SRefCon; #include "qgscrashhandler.h" #include "qgsziputils.h" #include "qgsversionmigration.h" +#include "qgsfirstrundialog.h" #include "qgsuserprofilemanager.h" #include "qgsuserprofile.h" @@ -862,11 +863,29 @@ int main( int argc, char *argv[] ) // Settings migration is only supported on the default profile for now. if ( profileName == "default" ) { + // 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. + + int firstRunVersion = settings.value( QStringLiteral( "migration/firstRunVersionFlag" ), 0 ).toInt(); + bool showWelcome = ( firstRunVersion == 0 || Qgis::QGIS_VERSION_INT > firstRunVersion ); + std::unique_ptr< QgsVersionMigration > migration( QgsVersionMigration::canMigrate( 20000, Qgis::QGIS_VERSION_INT ) ); if ( migration && ( mySettingsMigrationForce || migration->requiresMigration() ) ) { - QgsDebugMsg( "RUNNING MIGRATION" ); - migration->runMigration(); + bool runMigration = true; + if ( !mySettingsMigrationForce && showWelcome ) + { + QgsFirstRunDialog dlg; + dlg.exec(); + runMigration = dlg.migrateSettings(); + settings.setValue( QStringLiteral( "migration/firstRunVersionFlag" ), Qgis::QGIS_VERSION_INT ); + } + + if ( runMigration ) + { + QgsDebugMsg( "RUNNING MIGRATION" ); + migration->runMigration(); + } } } diff --git a/src/app/qgsfirstrundialog.cpp b/src/app/qgsfirstrundialog.cpp new file mode 100644 index 000000000000..d39e13774a08 --- /dev/null +++ b/src/app/qgsfirstrundialog.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** + qgsfirstrundialog.cpp - qgsfirstrundialog + + --------------------- + begin : 11.12.2017 + copyright : (C) 2017 by Nathan Woodrow + email : woodrow.nathan@gmail.com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "qgsfirstrundialog.h" +#include "qgis.h" + +QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) : QDialog( parent ) +{ + setupUi( this ); + mWelcomeDevLabel->hide(); + mWelcomeLabel->setText( tr( "Welcome to QGIS %1" ).arg( Qgis::QGIS_VERSION ) ); + if ( Qgis::QGIS_VERSION.endsWith( QLatin1String( "Master" ) ) ) + { + mWelcomeDevLabel->show(); + } +} + +bool QgsFirstRunDialog::migrateSettings() +{ + return ( mImportSettingsYes->isChecked() ); +} diff --git a/src/app/qgsfirstrundialog.h b/src/app/qgsfirstrundialog.h new file mode 100644 index 000000000000..57fd32c81a35 --- /dev/null +++ b/src/app/qgsfirstrundialog.h @@ -0,0 +1,38 @@ +/*************************************************************************** + qgsfirstrundialog.h - qgsfirstrundialog + + --------------------- + begin : 11.12.2017 + copyright : (C) 2017 by Nathan Woodrow + email : woodrow.nathan@gmail.com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef QGSFIRSTRUNDIALOG_H +#define QGSFIRSTRUNDIALOG_H + +#include +#include +#include "qgis_app.h" + +#include "ui_qgsfirstrundialog.h" + +class APP_EXPORT QgsFirstRunDialog : public QDialog, private Ui::QgsFirstRunDialog +{ + Q_OBJECT + public: + QgsFirstRunDialog( QWidget *parent = 0 ); + + bool migrateSettings(); + + signals: + + public slots: +}; + +#endif // QGSFIRSTRUNDIALOG_H diff --git a/src/ui/qgsfirstrundialog.ui b/src/ui/qgsfirstrundialog.ui new file mode 100644 index 000000000000..8243f2669b7d --- /dev/null +++ b/src/ui/qgsfirstrundialog.ui @@ -0,0 +1,199 @@ + + + QgsFirstRunDialog + + + + 0 + 0 + 659 + 464 + + + + Dialog + + + + + + Let's get started! + + + + + + + 0 + + + 0 + + + + + + 23 + + + + Welcome to QGIS 3 + + + + + + + + 0 + 0 + + + + + + + :/images/icons/qgis-icon-60x60.png + + + false + + + + + + + + 16 + + + + <html><head/><body><p><a href="http://changelog.qgis.org/en/qgis/version/3.0.0/"><span style=" text-decoration: underline; color:#2a76c6;">Check out </span></a>the change log for all the new stuff.</p></body></html> + + + true + + + true + + + + + + + <html><head/><body><p><span style=" font-style:italic;">You are running a dev version. We would love your feedback and testing.</span></p></body></html> + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 40 + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + Ready to go? + + + + + + + Import settings from QGIS 2. + + + true + + + + + + + I want a clean start. Don't import my QGIS 2 settings. + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Settings will be imported into the default profile and you will only see this screen once. + + + true + + + + + + + + + + + + + pushButton + clicked() + QgsFirstRunDialog + accept() + + + 350 + 424 + + + 188 + 453 + + + + +