summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2015-01-31 18:30:42 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2015-05-02 16:52:13 +0200
commit72b81c25590b972c785ff30e0e9732a756ab9e9e (patch)
tree7b28c503d92431b01a9345ecbd06d702751ceede
parent43b1ccffcc2df42146bde053bb13e5168dfa2334 (diff)
Improve update check information dialog.
Show the user both the current and updated version. Change-Id: Ief693cce020a39a0c79bf2705da4a44b7bd15928
-rw-r--r--rbutil/rbutilqt/base/utils.cpp14
-rw-r--r--rbutil/rbutilqt/base/utils.h1
-rw-r--r--rbutil/rbutilqt/changelog.txt3
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp9
-rw-r--r--rbutil/rbutilqt/test/test-compareversion.cpp48
5 files changed, 60 insertions, 15 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index d2ed49bae3..724a1553f1 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -342,6 +342,20 @@ QString Utils::checkEnvironment(bool permission)
else
return text;
}
+
+/** @brief Trim version string from filename to version part only.
+ * @param s Version string
+ * @return Version part of string if found, input string on error.
+ */
+QString Utils::trimVersionString(QString s)
+{
+ QRegExp r = QRegExp(".*([\\d\\.]+\\d+[a-z]?).*");
+ if(r.indexIn(s) != -1) {
+ return r.cap(1);
+ }
+ return s;
+}
+
/** @brief Compare two version strings.
* @param s1 first version string
* @param s2 second version string
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h
index 9905341ad1..bc45ebd857 100644
--- a/rbutil/rbutilqt/base/utils.h
+++ b/rbutil/rbutilqt/base/utils.h
@@ -49,6 +49,7 @@ public:
static QString findExecutable(QString name);
static QString checkEnvironment(bool permission);
static int compareVersionStrings(QString s1, QString s2);
+ static QString trimVersionString(QString s);
static QString filesystemName(QString path);
static QStringList mountpoints(enum MountpointsFilter type = MountpointsAll);
static QString resolveDevicename(QString path);
diff --git a/rbutil/rbutilqt/changelog.txt b/rbutil/rbutilqt/changelog.txt
index d11122455c..0fc2c95784 100644
--- a/rbutil/rbutilqt/changelog.txt
+++ b/rbutil/rbutilqt/changelog.txt
@@ -21,6 +21,7 @@ Version 1.4
* Fix manual link for Archos Recorder V2.
Version 1.4.1
-* Fix crash on detecting player in MTP mode.
+* Fix crash on detecting player in MTP mode (FS#12989).
* Extend hint when uninstallation requires reinstalling the Original Firmware.
+* Improve update check information dialog.
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index b1ea041858..4c06163404 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -729,10 +729,11 @@ void RbUtilQt::downloadUpdateDone(bool error)
#endif
url += foundVersion;
- QMessageBox::information(this,tr("RockboxUtility Update available"),
- tr("<b>New RockboxUtility Version available.</b> <br><br>"
- "Download it from here: <a href='%1'>%2</a>")
- .arg(url).arg(foundVersion));
+ QMessageBox::information(this,tr("Rockbox Utility Update available"),
+ tr("<b>New Rockbox Utility version available.</b><br><br>"
+ "You are currently using version %1. "
+ "Get version %2 at <a href='%3'>%3</a>")
+ .arg(VERSION).arg(Utils::trimVersionString(foundVersion)).arg(url));
ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
}
else {
diff --git a/rbutil/rbutilqt/test/test-compareversion.cpp b/rbutil/rbutilqt/test/test-compareversion.cpp
index fa1b889254..c075c2af12 100644
--- a/rbutil/rbutilqt/test/test-compareversion.cpp
+++ b/rbutil/rbutilqt/test/test-compareversion.cpp
@@ -27,17 +27,18 @@ class TestVersionCompare : public QObject
{
Q_OBJECT
private slots:
- void testMain();
+ void testCompare();
+ void testTrim();
};
-struct testvector {
+struct compvector {
const char* first;
const char* second;
const int expected;
};
-const struct testvector testdata[] =
+const struct compvector compdata[] =
{
{ "1.2.3", "1.2.3 ", 0 },
{ "1.2.3", " 1.2.3", 0 },
@@ -73,17 +74,44 @@ const struct testvector testdata[] =
{ "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 },
};
+struct trimvector {
+ const char* input;
+ const QString expected;
+};
+
+const struct trimvector trimdata[] =
+{
+ { "prog-1.2-64bit.tar.bz2", "1.2" },
+ { "prog-1.2.tar.bz2", "1.2" },
+ { "1.2.3", "1.2.3" },
+ { " 1.2.3", "1.2.3" },
+ { "1.2.3 ", "1.2.3" },
+ { "10.22.33", "10.22.33" },
+ { "test-1.2.3", "1.2.3" },
+ { "1.2.3", "1.2.3" },
+ { "test-1.2.3.tar.gz", "1.2.3" },
+ { "prog-1.2-64bit.tar.bz2", "1.2" },
+ { "prog-1.2a.tar.bz2", "1.2a" },
+ { "prog-1.2a-64bit.tar.bz2","1.2a" },
+};
-void TestVersionCompare::testMain()
+void TestVersionCompare::testCompare()
{
unsigned int i;
- for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
- QCOMPARE(Utils::compareVersionStrings(testdata[i].first,
- testdata[i].second), testdata[i].expected);
+ for(i = 0; i < sizeof(compdata) / sizeof(struct compvector); i++) {
+ QCOMPARE(Utils::compareVersionStrings(compdata[i].first,
+ compdata[i].second), compdata[i].expected);
// inverse test possible because function return values are symmetrical.
- if(testdata[i].expected != 0)
- QCOMPARE(Utils::compareVersionStrings(testdata[i].second,
- testdata[i].first), -testdata[i].expected);
+ if(compdata[i].expected != 0)
+ QCOMPARE(Utils::compareVersionStrings(compdata[i].second,
+ compdata[i].first), -compdata[i].expected);
+ }
+}
+
+void TestVersionCompare::testTrim()
+{
+ for(int i = 0; i < sizeof(trimdata) / sizeof(struct trimvector); i++) {
+ QCOMPARE(Utils::trimVersionString(trimdata[i].input), trimdata[i].expected);
}
}