forked from len0rd/rockbox
Make Detect::check() return an error string instead of a boolean result and move the handling of an occurred error to the application to make detection Gui-clean. Move detect class to base folder.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18873 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6371460172
commit
b208000c36
5 changed files with 64 additions and 62 deletions
|
|
@ -22,10 +22,9 @@
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
|
|
||||||
// Windows Includes
|
// Windows Includes
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
|
|
@ -403,9 +402,9 @@ int Detect::installedTargetId(QString mountpoint)
|
||||||
* @param settings A pointer to rbutils settings class
|
* @param settings A pointer to rbutils settings class
|
||||||
* @param permission if it should check for permission
|
* @param permission if it should check for permission
|
||||||
* @param targetId the targetID to check for. if it is -1 no check is done.
|
* @param targetId the targetID to check for. if it is -1 no check is done.
|
||||||
* @return true if everything is ok, or user wants to continue
|
* @return string with error messages if problems occurred, empty strings if none.
|
||||||
*/
|
*/
|
||||||
bool Detect::check(RbSettings* settings,bool permission,int targetId)
|
QString Detect::check(RbSettings* settings, bool permission, int targetId)
|
||||||
{
|
{
|
||||||
QString text = "";
|
QString text = "";
|
||||||
|
|
||||||
|
|
@ -415,7 +414,8 @@ bool Detect::check(RbSettings* settings,bool permission,int targetId)
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
if(Detect::userPermissions() != Detect::ADMIN)
|
if(Detect::userPermissions() != Detect::ADMIN)
|
||||||
{
|
{
|
||||||
text += QObject::tr("Permissions are not sufficient! \n Run with admin rights. \n\n");
|
text += QObject::tr("<li>Permissions insufficient for bootloader "
|
||||||
|
"installation.\nAdministrator priviledges are necessary.</li>");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -426,25 +426,16 @@ bool Detect::check(RbSettings* settings,bool permission,int targetId)
|
||||||
int installedID = Detect::installedTargetId(settings->mountpoint());
|
int installedID = Detect::installedTargetId(settings->mountpoint());
|
||||||
if( installedID != -1 && installedID != targetId)
|
if( installedID != -1 && installedID != targetId)
|
||||||
{
|
{
|
||||||
text += QObject::tr("Target mismatch detected. \n\n"
|
text += QObject::tr("<li>Target mismatch detected.\n"
|
||||||
"Installed target: %1.\n"
|
"Installed target: %1, selected target: %2.</li>")
|
||||||
"New Target: %2.\n\n").arg(settings->nameOfTargetId(installedID),settings->curName());
|
.arg(settings->nameOfTargetId(installedID),settings->curName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// show message Box
|
if(!text.isEmpty())
|
||||||
if(text != "")
|
return QObject::tr("Problem detected:") + "<ul>" + text + "</ul>";
|
||||||
{
|
else
|
||||||
text += QObject::tr("\n Do you want to continue ?");
|
return text;
|
||||||
if(QMessageBox::warning(NULL, QObject::tr("Problems detected"),text,
|
|
||||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
static QString installedVersion(QString mountpoint);
|
static QString installedVersion(QString mountpoint);
|
||||||
static int installedTargetId(QString mountpoint);
|
static int installedTargetId(QString mountpoint);
|
||||||
|
|
||||||
static bool check(RbSettings* settings,bool permission,int targetId);
|
static QString check(RbSettings* settings, bool permission, int targetId);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -121,11 +121,17 @@ void Install::accept()
|
||||||
}
|
}
|
||||||
settings->sync();
|
settings->sync();
|
||||||
|
|
||||||
if(Detect::check(settings,false,settings->curTargetId()) == false)
|
QString warning = Detect::check(settings, false, settings->curTargetId());
|
||||||
|
if(!warning.isEmpty())
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Aborted!"),LOGERROR);
|
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||||
logger->abort();
|
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
|
||||||
return;
|
== QMessageBox::Abort)
|
||||||
|
{
|
||||||
|
logger->addItem(tr("Aborted!"),LOGERROR);
|
||||||
|
logger->abort();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! check if we should backup
|
//! check if we should backup
|
||||||
|
|
|
||||||
|
|
@ -499,12 +499,17 @@ bool RbUtilQt::installAuto()
|
||||||
|
|
||||||
// check installed Version and Target
|
// check installed Version and Target
|
||||||
QString rbVersion = Detect::installedVersion(settings->mountpoint());
|
QString rbVersion = Detect::installedVersion(settings->mountpoint());
|
||||||
|
QString warning = Detect::check(settings, false, settings->curTargetId());
|
||||||
|
|
||||||
if(Detect::check(settings,false,settings->curTargetId()) == false)
|
if(!warning.isEmpty())
|
||||||
{
|
{
|
||||||
logger->addItem(tr("Aborted!"),LOGERROR);
|
if(QMessageBox::warning(this, tr("Really continue?"), warning,
|
||||||
logger->abort();
|
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) == QMessageBox::Abort)
|
||||||
return false;
|
{
|
||||||
|
logger->addItem(tr("Aborted!"), LOGERROR);
|
||||||
|
logger->abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check version
|
// check version
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ SOURCES += rbutilqt.cpp \
|
||||||
rbsettings.cpp \
|
rbsettings.cpp \
|
||||||
base/rbunzip.cpp \
|
base/rbunzip.cpp \
|
||||||
base/rbzip.cpp \
|
base/rbzip.cpp \
|
||||||
detect.cpp \
|
base/detect.cpp \
|
||||||
sysinfo.cpp \
|
sysinfo.cpp \
|
||||||
base/bootloaderinstallbase.cpp \
|
base/bootloaderinstallbase.cpp \
|
||||||
base/bootloaderinstallmi4.cpp \
|
base/bootloaderinstallmi4.cpp \
|
||||||
|
|
@ -127,7 +127,7 @@ HEADERS += rbutilqt.h \
|
||||||
base/rbunzip.h \
|
base/rbunzip.h \
|
||||||
base/rbzip.h \
|
base/rbzip.h \
|
||||||
sysinfo.h \
|
sysinfo.h \
|
||||||
detect.h \
|
base/detect.h \
|
||||||
base/bootloaderinstallbase.h \
|
base/bootloaderinstallbase.h \
|
||||||
base/bootloaderinstallmi4.h \
|
base/bootloaderinstallmi4.h \
|
||||||
base/bootloaderinstallhex.h \
|
base/bootloaderinstallhex.h \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue