diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index ec8120ea0da..df6269f5084 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 46a016e85cb..86262e01b05 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 00000000000..d39e13774a0 --- /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 00000000000..57fd32c81a3 --- /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 <QWidget> +#include <QDialog> +#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 00000000000..8243f2669b7 --- /dev/null +++ b/src/ui/qgsfirstrundialog.ui @@ -0,0 +1,199 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>QgsFirstRunDialog</class> + <widget class="QDialog" name="QgsFirstRunDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>659</width> + <height>464</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="2" column="1"> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Let's get started!</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2"> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <item row="2" column="1" rowspan="2"> + <widget class="QLabel" name="mWelcomeLabel"> + <property name="font"> + <font> + <pointsize>23</pointsize> + </font> + </property> + <property name="text"> + <string>Welcome to QGIS 3</string> + </property> + </widget> + </item> + <item row="2" column="0" rowspan="3"> + <widget class="QLabel" name="label_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="../../images/images.qrc">:/images/icons/qgis-icon-60x60.png</pixmap> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="6" column="0" colspan="2"> + <widget class="QLabel" name="label_2"> + <property name="font"> + <font> + <pointsize>16</pointsize> + </font> + </property> + <property name="text"> + <string><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></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="mWelcomeDevLabel"> + <property name="text"> + <string><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></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="0"> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="1" column="0" colspan="2"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Ready to go?</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="mImportSettingsYes"> + <property name="text"> + <string>Import settings from QGIS 2.</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="mImportSettingsNo"> + <property name="text"> + <string>I want a clean start. Don't import my QGIS 2 settings.</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Settings will be imported into the default profile and you will only see this screen once.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources> + <include location="../../images/images.qrc"/> + </resources> + <connections> + <connection> + <sender>pushButton</sender> + <signal>clicked()</signal> + <receiver>QgsFirstRunDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>350</x> + <y>424</y> + </hint> + <hint type="destinationlabel"> + <x>188</x> + <y>453</y> + </hint> + </hints> + </connection> + </connections> +</ui>