diff src/mainwindow.cpp @ 491:1d90cd7a1c5f

Add tester for newer version
author Chris Cannam
date Thu, 18 Aug 2011 13:15:38 +0100
parents 86cdaa346e59
children 41a156d439d0
line wrap: on
line diff
--- a/src/mainwindow.cpp	Wed Aug 17 22:13:51 2011 +0100
+++ b/src/mainwindow.cpp	Thu Aug 18 13:15:38 2011 +0100
@@ -50,6 +50,7 @@
 #include "version.h"
 #include "workstatuswidget.h"
 #include "hgignoredialog.h"
+#include "versiontester.h"
 
 
 MainWindow::MainWindow(QString myDirPath) :
@@ -131,6 +132,11 @@
     cs->addDefaultName("default");
     cs->addDefaultName(getUserInfo());
 
+    VersionTester *vt = new VersionTester
+        ("easymercurial.org", "/latest-version.txt", EASYHG_VERSION);
+    connect(vt, SIGNAL(newerVersionAvailable(QString)),
+            this, SLOT(newerVersionAvailable(QString)));
+
     hgTest();
     updateRecentMenu();
 }
@@ -3062,6 +3068,17 @@
     settings.setValue("firststart", m_firstStart);
 }
 
-
-
-
+void MainWindow::newerVersionAvailable(QString version)
+{
+    QSettings settings;
+    settings.beginGroup("NewerVersionWarning");
+    QString tag = QString("version-%1-available-show").arg(version);
+    if (settings.value(tag, true).toBool()) {
+        QString title(tr("Newer version available"));
+        QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of EasyMercurial, but version %3 is now available.</p><p>Please see the <a href=\"http://easymercurial.org/\">EasyMercurial website</a> for more information.</p>").arg(EASYHG_VERSION).arg(version));
+        QMessageBox::information(this, title, text);
+        settings.setValue(tag, false);
+    }
+    settings.endGroup();
+}
+