Skip to content

Commit 3046979

Browse files
authored
Add first run and settings migration screen (#5838)
1 parent a15b54d commit 3046979

File tree

5 files changed

+293
-2
lines changed

5 files changed

+293
-2
lines changed

src/app/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SET(QGIS_APP_SRCS
4242
qgsdiagramproperties.cpp
4343
qgsdisplayangle.cpp
4444
qgsfieldcalculator.cpp
45+
qgsfirstrundialog.cpp
4546
qgssourcefieldsproperties.cpp
4647
qgsattributesformproperties.cpp
4748
qgsidentifyresultsdialog.cpp
@@ -263,6 +264,7 @@ SET (QGIS_APP_MOC_HDRS
263264
qgsdxfexportdialog.h
264265
qgsfeatureaction.h
265266
qgsfieldcalculator.h
267+
qgsfirstrundialog.h
266268
qgssourcefieldsproperties.h
267269
qgsattributesformproperties.h
268270
qgsformannotationdialog.h

src/app/main.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef SInt32 SRefCon;
100100
#include "qgscrashhandler.h"
101101
#include "qgsziputils.h"
102102
#include "qgsversionmigration.h"
103+
#include "qgsfirstrundialog.h"
103104

104105
#include "qgsuserprofilemanager.h"
105106
#include "qgsuserprofile.h"
@@ -862,11 +863,29 @@ int main( int argc, char *argv[] )
862863
// Settings migration is only supported on the default profile for now.
863864
if ( profileName == "default" )
864865
{
866+
// Note: this flag is ka version number so that we can reset it once we change the version.
867+
// Note2: Is this a good idea can we do it better.
868+
869+
int firstRunVersion = settings.value( QStringLiteral( "migration/firstRunVersionFlag" ), 0 ).toInt();
870+
bool showWelcome = ( firstRunVersion == 0 || Qgis::QGIS_VERSION_INT > firstRunVersion );
871+
865872
std::unique_ptr< QgsVersionMigration > migration( QgsVersionMigration::canMigrate( 20000, Qgis::QGIS_VERSION_INT ) );
866873
if ( migration && ( mySettingsMigrationForce || migration->requiresMigration() ) )
867874
{
868-
QgsDebugMsg( "RUNNING MIGRATION" );
869-
migration->runMigration();
875+
bool runMigration = true;
876+
if ( !mySettingsMigrationForce && showWelcome )
877+
{
878+
QgsFirstRunDialog dlg;
879+
dlg.exec();
880+
runMigration = dlg.migrateSettings();
881+
settings.setValue( QStringLiteral( "migration/firstRunVersionFlag" ), Qgis::QGIS_VERSION_INT );
882+
}
883+
884+
if ( runMigration )
885+
{
886+
QgsDebugMsg( "RUNNING MIGRATION" );
887+
migration->runMigration();
888+
}
870889
}
871890
}
872891

src/app/qgsfirstrundialog.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/***************************************************************************
2+
qgsfirstrundialog.cpp - qgsfirstrundialog
3+
4+
---------------------
5+
begin : 11.12.2017
6+
copyright : (C) 2017 by Nathan Woodrow
7+
email : woodrow.nathan@gmail.com
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
#include "qgsfirstrundialog.h"
17+
#include "qgis.h"
18+
19+
QgsFirstRunDialog::QgsFirstRunDialog( QWidget *parent ) : QDialog( parent )
20+
{
21+
setupUi( this );
22+
mWelcomeDevLabel->hide();
23+
mWelcomeLabel->setText( tr( "Welcome to QGIS %1" ).arg( Qgis::QGIS_VERSION ) );
24+
if ( Qgis::QGIS_VERSION.endsWith( QLatin1String( "Master" ) ) )
25+
{
26+
mWelcomeDevLabel->show();
27+
}
28+
}
29+
30+
bool QgsFirstRunDialog::migrateSettings()
31+
{
32+
return ( mImportSettingsYes->isChecked() );
33+
}

src/app/qgsfirstrundialog.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/***************************************************************************
2+
qgsfirstrundialog.h - qgsfirstrundialog
3+
4+
---------------------
5+
begin : 11.12.2017
6+
copyright : (C) 2017 by Nathan Woodrow
7+
email : woodrow.nathan@gmail.com
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
#ifndef QGSFIRSTRUNDIALOG_H
17+
#define QGSFIRSTRUNDIALOG_H
18+
19+
#include <QWidget>
20+
#include <QDialog>
21+
#include "qgis_app.h"
22+
23+
#include "ui_qgsfirstrundialog.h"
24+
25+
class APP_EXPORT QgsFirstRunDialog : public QDialog, private Ui::QgsFirstRunDialog
26+
{
27+
Q_OBJECT
28+
public:
29+
QgsFirstRunDialog( QWidget *parent = 0 );
30+
31+
bool migrateSettings();
32+
33+
signals:
34+
35+
public slots:
36+
};
37+
38+
#endif // QGSFIRSTRUNDIALOG_H

src/ui/qgsfirstrundialog.ui

+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsFirstRunDialog</class>
4+
<widget class="QDialog" name="QgsFirstRunDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>659</width>
10+
<height>464</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Dialog</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout_2">
17+
<item row="2" column="1">
18+
<widget class="QPushButton" name="pushButton">
19+
<property name="text">
20+
<string>Let's get started!</string>
21+
</property>
22+
</widget>
23+
</item>
24+
<item row="0" column="0" colspan="2">
25+
<layout class="QGridLayout" name="gridLayout">
26+
<property name="leftMargin">
27+
<number>0</number>
28+
</property>
29+
<property name="rightMargin">
30+
<number>0</number>
31+
</property>
32+
<item row="2" column="1" rowspan="2">
33+
<widget class="QLabel" name="mWelcomeLabel">
34+
<property name="font">
35+
<font>
36+
<pointsize>23</pointsize>
37+
</font>
38+
</property>
39+
<property name="text">
40+
<string>Welcome to QGIS 3</string>
41+
</property>
42+
</widget>
43+
</item>
44+
<item row="2" column="0" rowspan="3">
45+
<widget class="QLabel" name="label_3">
46+
<property name="sizePolicy">
47+
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
48+
<horstretch>0</horstretch>
49+
<verstretch>0</verstretch>
50+
</sizepolicy>
51+
</property>
52+
<property name="text">
53+
<string/>
54+
</property>
55+
<property name="pixmap">
56+
<pixmap resource="../../images/images.qrc">:/images/icons/qgis-icon-60x60.png</pixmap>
57+
</property>
58+
<property name="scaledContents">
59+
<bool>false</bool>
60+
</property>
61+
</widget>
62+
</item>
63+
<item row="6" column="0" colspan="2">
64+
<widget class="QLabel" name="label_2">
65+
<property name="font">
66+
<font>
67+
<pointsize>16</pointsize>
68+
</font>
69+
</property>
70+
<property name="text">
71+
<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>
72+
</property>
73+
<property name="wordWrap">
74+
<bool>true</bool>
75+
</property>
76+
<property name="openExternalLinks">
77+
<bool>true</bool>
78+
</property>
79+
</widget>
80+
</item>
81+
<item row="4" column="1">
82+
<widget class="QLabel" name="mWelcomeDevLabel">
83+
<property name="text">
84+
<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>
85+
</property>
86+
<property name="wordWrap">
87+
<bool>true</bool>
88+
</property>
89+
</widget>
90+
</item>
91+
<item row="5" column="0">
92+
<spacer name="verticalSpacer_3">
93+
<property name="orientation">
94+
<enum>Qt::Vertical</enum>
95+
</property>
96+
<property name="sizeType">
97+
<enum>QSizePolicy::Preferred</enum>
98+
</property>
99+
<property name="sizeHint" stdset="0">
100+
<size>
101+
<width>20</width>
102+
<height>40</height>
103+
</size>
104+
</property>
105+
</spacer>
106+
</item>
107+
</layout>
108+
</item>
109+
<item row="1" column="0" colspan="2">
110+
<layout class="QVBoxLayout" name="verticalLayout">
111+
<item>
112+
<spacer name="verticalSpacer_2">
113+
<property name="orientation">
114+
<enum>Qt::Vertical</enum>
115+
</property>
116+
<property name="sizeType">
117+
<enum>QSizePolicy::Expanding</enum>
118+
</property>
119+
<property name="sizeHint" stdset="0">
120+
<size>
121+
<width>20</width>
122+
<height>40</height>
123+
</size>
124+
</property>
125+
</spacer>
126+
</item>
127+
<item>
128+
<widget class="QLabel" name="label">
129+
<property name="text">
130+
<string>Ready to go?</string>
131+
</property>
132+
</widget>
133+
</item>
134+
<item>
135+
<widget class="QRadioButton" name="mImportSettingsYes">
136+
<property name="text">
137+
<string>Import settings from QGIS 2.</string>
138+
</property>
139+
<property name="checked">
140+
<bool>true</bool>
141+
</property>
142+
</widget>
143+
</item>
144+
<item>
145+
<widget class="QRadioButton" name="mImportSettingsNo">
146+
<property name="text">
147+
<string>I want a clean start. Don't import my QGIS 2 settings.</string>
148+
</property>
149+
</widget>
150+
</item>
151+
<item>
152+
<spacer name="verticalSpacer">
153+
<property name="orientation">
154+
<enum>Qt::Vertical</enum>
155+
</property>
156+
<property name="sizeHint" stdset="0">
157+
<size>
158+
<width>20</width>
159+
<height>40</height>
160+
</size>
161+
</property>
162+
</spacer>
163+
</item>
164+
<item>
165+
<widget class="QLabel" name="label_4">
166+
<property name="text">
167+
<string>Settings will be imported into the default profile and you will only see this screen once.</string>
168+
</property>
169+
<property name="wordWrap">
170+
<bool>true</bool>
171+
</property>
172+
</widget>
173+
</item>
174+
</layout>
175+
</item>
176+
</layout>
177+
</widget>
178+
<resources>
179+
<include location="../../images/images.qrc"/>
180+
</resources>
181+
<connections>
182+
<connection>
183+
<sender>pushButton</sender>
184+
<signal>clicked()</signal>
185+
<receiver>QgsFirstRunDialog</receiver>
186+
<slot>accept()</slot>
187+
<hints>
188+
<hint type="sourcelabel">
189+
<x>350</x>
190+
<y>424</y>
191+
</hint>
192+
<hint type="destinationlabel">
193+
<x>188</x>
194+
<y>453</y>
195+
</hint>
196+
</hints>
197+
</connection>
198+
</connections>
199+
</ui>

0 commit comments

Comments
 (0)