Skip to content

Commit bd3bbc4

Browse files
committed
Merge pull request #2790 from SebDieBln/ImproveVersionCheck
[Bugfix] Improve version check (refs #14022)
2 parents 3600046 + 8359bfe commit bd3bbc4

File tree

8 files changed

+44
-8
lines changed

8 files changed

+44
-8
lines changed

src/app/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void usage( std::string const & appName )
119119
<< "\t[--project projectfile]\tload the given QGIS project\n"
120120
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
121121
<< "\t[--nologo]\thide splash screen\n"
122+
<< "\t[--noversioncheck]\tdon't check for new version of QGIS at startup"
122123
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
123124
<< "\t[--nocustomization]\tdon't apply GUI customization\n"
124125
<< "\t[--customizationfile]\tuse the given ini file as GUI customization\n"
@@ -476,6 +477,7 @@ int main( int argc, char *argv[] )
476477
int mySnapshotHeight = 600;
477478

478479
bool myHideSplash = false;
480+
bool mySkipVersionCheck = false;
479481
#if defined(ANDROID)
480482
QgsDebugMsg( QString( "Android: Splash hidden" ) );
481483
myHideSplash = true;
@@ -543,6 +545,10 @@ int main( int argc, char *argv[] )
543545
{
544546
myHideSplash = true;
545547
}
548+
else if ( arg == "--noversioncheck" || arg == "-V" )
549+
{
550+
mySkipVersionCheck = true;
551+
}
546552
else if ( arg == "--noplugins" || arg == "-P" )
547553
{
548554
myRestorePlugins = false;
@@ -1032,7 +1038,7 @@ int main( int argc, char *argv[] )
10321038
// this should be done in QgsApplication::init() but it doesn't know the settings dir.
10331039
QgsApplication::setMaxThreads( QSettings().value( "/qgis/max_threads", -1 ).toInt() );
10341040

1035-
QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
1041+
QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins, mySkipVersionCheck ); // "QgisApp" used to find canonical instance
10361042
qgis->setObjectName( "QgisApp" );
10371043

10381044
myApp.connect(

src/app/qgisapp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static bool cmpByText_( QAction* a, QAction* b )
531531
QgisApp *QgisApp::smInstance = nullptr;
532532

533533
// constructor starts here
534-
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WindowFlags fl )
534+
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCheck, QWidget * parent, Qt::WindowFlags fl )
535535
: QMainWindow( parent, fl )
536536
, mNonEditMapTool( nullptr )
537537
, mScaleLabel( nullptr )
@@ -639,7 +639,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
639639
// what type of project to auto-open
640640
mProjOpen = settings.value( "/qgis/projOpenAtLaunch", 0 ).toInt();
641641

642-
mWelcomePage = new QgsWelcomePage;
642+
mWelcomePage = new QgsWelcomePage( skipVersionCheck );
643643

644644
mCentralContainer = new QStackedWidget;
645645
mCentralContainer->insertWidget( 0, mMapCanvas );

src/app/qgisapp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
134134
Q_OBJECT
135135
public:
136136
//! Constructor
137-
QgisApp( QSplashScreen *splash, bool restorePlugins = true, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
137+
QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipVersionCheck = false, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
138138
//! Constructor for unit tests
139139
QgisApp();
140140
//! Destructor

src/app/qgsoptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
590590
mLegendGroupsBoldChkBx->setChecked( mSettings->value( "/qgis/legendGroupsBold", false ).toBool() );
591591
cbxHideSplash->setChecked( mSettings->value( "/qgis/hideSplash", false ).toBool() );
592592
cbxShowTips->setChecked( mSettings->value( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), true ).toBool() );
593+
cbxCheckVersion->setChecked( mSettings->value( "/qgis/checkVersion", true ).toBool() );
593594
cbxAttributeTableDocked->setChecked( mSettings->value( "/qgis/dockAttributeTable", false ).toBool() );
594595
cbxSnappingOptionsDocked->setChecked( mSettings->value( "/qgis/dockSnapping", false ).toBool() );
595596
cbxAddPostgisDC->setChecked( mSettings->value( "/qgis/addPostgisDC", false ).toBool() );
@@ -1131,6 +1132,7 @@ void QgsOptions::saveOptions()
11311132
mSettings->setValue( "/qgis/legendGroupsBold", mLegendGroupsBoldChkBx->isChecked() );
11321133
mSettings->setValue( "/qgis/hideSplash", cbxHideSplash->isChecked() );
11331134
mSettings->setValue( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), cbxShowTips->isChecked() );
1135+
mSettings->setValue( "/qgis/checkVersion", cbxCheckVersion->isChecked() );
11341136
mSettings->setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
11351137
mSettings->setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->itemData( cmbAttrTableBehaviour->currentIndex() ) );
11361138
mSettings->setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );

src/app/qgsversioninfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void QgsVersionInfo::versionReplyFinished()
7878
mErrorString = tr( "Connection refused - server may be down" );
7979
break;
8080
case QNetworkReply::HostNotFoundError:
81-
mErrorString = tr( "The host name qgis.org could not be resolved. Check your DNS settings or contact your system administrator." );
81+
mErrorString = tr( "The host name %1 could not be resolved. Check your DNS settings or contact your system administrator." ).arg( reply->request().url().host() );
8282
break;
8383
case QNetworkReply::NoError:
8484
mErrorString = "";

src/app/qgswelcomepage.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
#include <QListView>
2525
#include <QSettings>
2626

27-
QgsWelcomePage::QgsWelcomePage( QWidget* parent )
27+
QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget* parent )
2828
: QWidget( parent )
2929
{
30+
QSettings settings;
31+
3032
QVBoxLayout* mainLayout = new QVBoxLayout;
3133
mainLayout->setMargin( 0 );
3234
setLayout( mainLayout );
@@ -58,7 +60,7 @@ QgsWelcomePage::QgsWelcomePage( QWidget* parent )
5860
mVersionInformation->setVisible( false );
5961

6062
mVersionInfo = new QgsVersionInfo();
61-
if ( !QgsApplication::isRunningFromBuildDir() )
63+
if ( !QgsApplication::isRunningFromBuildDir() && settings.value( "/qgis/checkVersion", true ).toBool() && !skipVersionCheck )
6264
{
6365
connect( mVersionInfo, SIGNAL( versionInfoAvailable() ), this, SLOT( versionInfoReceived() ) );
6466
mVersionInfo->checkVersion();

src/app/qgswelcomepage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsWelcomePage : public QWidget
2828
Q_OBJECT
2929

3030
public:
31-
explicit QgsWelcomePage( QWidget* parent = nullptr );
31+
explicit QgsWelcomePage( bool skipVersionCheck = false, QWidget* parent = nullptr );
3232

3333
~QgsWelcomePage();
3434

src/ui/qgsoptionsbase.ui

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,37 @@
619619
</item>
620620
<item>
621621
<widget class="QCheckBox" name="cbxShowTips">
622+
<property name="sizePolicy">
623+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
624+
<horstretch>0</horstretch>
625+
<verstretch>0</verstretch>
626+
</sizepolicy>
627+
</property>
622628
<property name="text">
623629
<string>Show tips at start up</string>
624630
</property>
625631
</widget>
626632
</item>
633+
<item>
634+
<widget class="Line" name="line_2">
635+
<property name="minimumSize">
636+
<size>
637+
<width>12</width>
638+
<height>0</height>
639+
</size>
640+
</property>
641+
<property name="orientation">
642+
<enum>Qt::Vertical</enum>
643+
</property>
644+
</widget>
645+
</item>
646+
<item>
647+
<widget class="QCheckBox" name="cbxCheckVersion">
648+
<property name="text">
649+
<string>Check QGIS version at startup</string>
650+
</property>
651+
</widget>
652+
</item>
627653
</layout>
628654
</item>
629655
<item>

0 commit comments

Comments
 (0)