Skip to content

Commit

Permalink
Add first run and settings migration screen (#5838)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Dec 12, 2017
1 parent a15b54d commit 3046979
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -42,6 +42,7 @@ SET(QGIS_APP_SRCS
qgsdiagramproperties.cpp
qgsdisplayangle.cpp
qgsfieldcalculator.cpp
qgsfirstrundialog.cpp
qgssourcefieldsproperties.cpp
qgsattributesformproperties.cpp
qgsidentifyresultsdialog.cpp
Expand Down Expand Up @@ -263,6 +264,7 @@ SET (QGIS_APP_MOC_HDRS
qgsdxfexportdialog.h
qgsfeatureaction.h
qgsfieldcalculator.h
qgsfirstrundialog.h
qgssourcefieldsproperties.h
qgsattributesformproperties.h
qgsformannotationdialog.h
Expand Down
23 changes: 21 additions & 2 deletions src/app/main.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}
}
}

Expand Down
33 changes: 33 additions & 0 deletions 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() );
}
38 changes: 38 additions & 0 deletions 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
199 changes: 199 additions & 0 deletions 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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://changelog.qgis.org/en/qgis/version/3.0.0/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#2a76c6;&quot;&gt;Check out &lt;/span&gt;&lt;/a&gt;the change log for all the new stuff.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;You are running a dev version. We would love your feedback and testing.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>

0 comments on commit 3046979

Please sign in to comment.