mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
Improve update check information dialog.
Show the user both the current and updated version. Change-Id: Ief693cce020a39a0c79bf2705da4a44b7bd15928
This commit is contained in:
parent
43b1ccffcc
commit
72b81c2559
5 changed files with 60 additions and 15 deletions
|
|
@ -342,6 +342,20 @@ QString Utils::checkEnvironment(bool permission)
|
||||||
else
|
else
|
||||||
return text;
|
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.
|
/** @brief Compare two version strings.
|
||||||
* @param s1 first version string
|
* @param s1 first version string
|
||||||
* @param s2 second version string
|
* @param s2 second version string
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
static QString findExecutable(QString name);
|
static QString findExecutable(QString name);
|
||||||
static QString checkEnvironment(bool permission);
|
static QString checkEnvironment(bool permission);
|
||||||
static int compareVersionStrings(QString s1, QString s2);
|
static int compareVersionStrings(QString s1, QString s2);
|
||||||
|
static QString trimVersionString(QString s);
|
||||||
static QString filesystemName(QString path);
|
static QString filesystemName(QString path);
|
||||||
static QStringList mountpoints(enum MountpointsFilter type = MountpointsAll);
|
static QStringList mountpoints(enum MountpointsFilter type = MountpointsAll);
|
||||||
static QString resolveDevicename(QString path);
|
static QString resolveDevicename(QString path);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ Version 1.4
|
||||||
* Fix manual link for Archos Recorder V2.
|
* Fix manual link for Archos Recorder V2.
|
||||||
|
|
||||||
Version 1.4.1
|
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.
|
* Extend hint when uninstallation requires reinstalling the Original Firmware.
|
||||||
|
* Improve update check information dialog.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -729,10 +729,11 @@ void RbUtilQt::downloadUpdateDone(bool error)
|
||||||
#endif
|
#endif
|
||||||
url += foundVersion;
|
url += foundVersion;
|
||||||
|
|
||||||
QMessageBox::information(this,tr("RockboxUtility Update available"),
|
QMessageBox::information(this,tr("Rockbox Utility Update available"),
|
||||||
tr("<b>New RockboxUtility Version available.</b> <br><br>"
|
tr("<b>New Rockbox Utility version available.</b><br><br>"
|
||||||
"Download it from here: <a href='%1'>%2</a>")
|
"You are currently using version %1. "
|
||||||
.arg(url).arg(foundVersion));
|
"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."));
|
ui.statusbar->showMessage(tr("New version of Rockbox Utility available."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,18 @@ class TestVersionCompare : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private slots:
|
private slots:
|
||||||
void testMain();
|
void testCompare();
|
||||||
|
void testTrim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct testvector {
|
struct compvector {
|
||||||
const char* first;
|
const char* first;
|
||||||
const char* second;
|
const char* second;
|
||||||
const int expected;
|
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 },
|
||||||
{ "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 },
|
{ "prog-1.2a-64bit.tar.bz2","prog-1.2.3-64bit.tar.bz2", 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct trimvector {
|
||||||
|
const char* input;
|
||||||
|
const QString expected;
|
||||||
|
};
|
||||||
|
|
||||||
void TestVersionCompare::testMain()
|
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::testCompare()
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for(i = 0; i < sizeof(testdata) / sizeof(struct testvector); i++) {
|
for(i = 0; i < sizeof(compdata) / sizeof(struct compvector); i++) {
|
||||||
QCOMPARE(Utils::compareVersionStrings(testdata[i].first,
|
QCOMPARE(Utils::compareVersionStrings(compdata[i].first,
|
||||||
testdata[i].second), testdata[i].expected);
|
compdata[i].second), compdata[i].expected);
|
||||||
// inverse test possible because function return values are symmetrical.
|
// inverse test possible because function return values are symmetrical.
|
||||||
if(testdata[i].expected != 0)
|
if(compdata[i].expected != 0)
|
||||||
QCOMPARE(Utils::compareVersionStrings(testdata[i].second,
|
QCOMPARE(Utils::compareVersionStrings(compdata[i].second,
|
||||||
testdata[i].first), -testdata[i].expected);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue