Skip to content

Commit

Permalink
Merge pull request #2790 from SebDieBln/ImproveVersionCheck
Browse files Browse the repository at this point in the history
[Bugfix] Improve version check (refs #14022)
  • Loading branch information
jef-n committed Feb 15, 2016
2 parents 3600046 + 8359bfe commit bd3bbc4
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/app/main.cpp
Expand Up @@ -119,6 +119,7 @@ void usage( std::string const & appName )
<< "\t[--project projectfile]\tload the given QGIS project\n"
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
<< "\t[--nologo]\thide splash screen\n"
<< "\t[--noversioncheck]\tdon't check for new version of QGIS at startup"
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
<< "\t[--nocustomization]\tdon't apply GUI customization\n"
<< "\t[--customizationfile]\tuse the given ini file as GUI customization\n"
Expand Down Expand Up @@ -476,6 +477,7 @@ int main( int argc, char *argv[] )
int mySnapshotHeight = 600;

bool myHideSplash = false;
bool mySkipVersionCheck = false;
#if defined(ANDROID)
QgsDebugMsg( QString( "Android: Splash hidden" ) );
myHideSplash = true;
Expand Down Expand Up @@ -543,6 +545,10 @@ int main( int argc, char *argv[] )
{
myHideSplash = true;
}
else if ( arg == "--noversioncheck" || arg == "-V" )
{
mySkipVersionCheck = true;
}
else if ( arg == "--noplugins" || arg == "-P" )
{
myRestorePlugins = false;
Expand Down Expand Up @@ -1032,7 +1038,7 @@ int main( int argc, char *argv[] )
// this should be done in QgsApplication::init() but it doesn't know the settings dir.
QgsApplication::setMaxThreads( QSettings().value( "/qgis/max_threads", -1 ).toInt() );

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

myApp.connect(
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -531,7 +531,7 @@ static bool cmpByText_( QAction* a, QAction* b )
QgisApp *QgisApp::smInstance = nullptr;

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

mWelcomePage = new QgsWelcomePage;
mWelcomePage = new QgsWelcomePage( skipVersionCheck );

mCentralContainer = new QStackedWidget;
mCentralContainer->insertWidget( 0, mMapCanvas );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -134,7 +134,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
Q_OBJECT
public:
//! Constructor
QgisApp( QSplashScreen *splash, bool restorePlugins = true, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipVersionCheck = false, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
//! Constructor for unit tests
QgisApp();
//! Destructor
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -590,6 +590,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
mLegendGroupsBoldChkBx->setChecked( mSettings->value( "/qgis/legendGroupsBold", false ).toBool() );
cbxHideSplash->setChecked( mSettings->value( "/qgis/hideSplash", false ).toBool() );
cbxShowTips->setChecked( mSettings->value( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), true ).toBool() );
cbxCheckVersion->setChecked( mSettings->value( "/qgis/checkVersion", true ).toBool() );
cbxAttributeTableDocked->setChecked( mSettings->value( "/qgis/dockAttributeTable", false ).toBool() );
cbxSnappingOptionsDocked->setChecked( mSettings->value( "/qgis/dockSnapping", false ).toBool() );
cbxAddPostgisDC->setChecked( mSettings->value( "/qgis/addPostgisDC", false ).toBool() );
Expand Down Expand Up @@ -1131,6 +1132,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( "/qgis/legendGroupsBold", mLegendGroupsBoldChkBx->isChecked() );
mSettings->setValue( "/qgis/hideSplash", cbxHideSplash->isChecked() );
mSettings->setValue( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), cbxShowTips->isChecked() );
mSettings->setValue( "/qgis/checkVersion", cbxCheckVersion->isChecked() );
mSettings->setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
mSettings->setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->itemData( cmbAttrTableBehaviour->currentIndex() ) );
mSettings->setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsversioninfo.cpp
Expand Up @@ -78,7 +78,7 @@ void QgsVersionInfo::versionReplyFinished()
mErrorString = tr( "Connection refused - server may be down" );
break;
case QNetworkReply::HostNotFoundError:
mErrorString = tr( "The host name qgis.org could not be resolved. Check your DNS settings or contact your system administrator." );
mErrorString = tr( "The host name %1 could not be resolved. Check your DNS settings or contact your system administrator." ).arg( reply->request().url().host() );
break;
case QNetworkReply::NoError:
mErrorString = "";
Expand Down
6 changes: 4 additions & 2 deletions src/app/qgswelcomepage.cpp
Expand Up @@ -24,9 +24,11 @@
#include <QListView>
#include <QSettings>

QgsWelcomePage::QgsWelcomePage( QWidget* parent )
QgsWelcomePage::QgsWelcomePage( bool skipVersionCheck, QWidget* parent )
: QWidget( parent )
{
QSettings settings;

QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->setMargin( 0 );
setLayout( mainLayout );
Expand Down Expand Up @@ -58,7 +60,7 @@ QgsWelcomePage::QgsWelcomePage( QWidget* parent )
mVersionInformation->setVisible( false );

mVersionInfo = new QgsVersionInfo();
if ( !QgsApplication::isRunningFromBuildDir() )
if ( !QgsApplication::isRunningFromBuildDir() && settings.value( "/qgis/checkVersion", true ).toBool() && !skipVersionCheck )
{
connect( mVersionInfo, SIGNAL( versionInfoAvailable() ), this, SLOT( versionInfoReceived() ) );
mVersionInfo->checkVersion();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgswelcomepage.h
Expand Up @@ -28,7 +28,7 @@ class QgsWelcomePage : public QWidget
Q_OBJECT

public:
explicit QgsWelcomePage( QWidget* parent = nullptr );
explicit QgsWelcomePage( bool skipVersionCheck = false, QWidget* parent = nullptr );

~QgsWelcomePage();

Expand Down
26 changes: 26 additions & 0 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -619,11 +619,37 @@
</item>
<item>
<widget class="QCheckBox" name="cbxShowTips">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show tips at start up</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="minimumSize">
<size>
<width>12</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxCheckVersion">
<property name="text">
<string>Check QGIS version at startup</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit bd3bbc4

Please sign in to comment.