Make configuration check reusable.

Instead of passing a parameter to decide if a dialog box should be shown pass a
pointer to the parent widget and make it static. This allows calling it from
outside while keeping the possibility to not show a warning.

Change-Id: I72fa53a7e8a83d527c22b698dfa434c24100ac29
This commit is contained in:
Dominik Riebeling 2012-02-14 20:51:49 +01:00
parent 9acd70288d
commit 3933afcc09
2 changed files with 19 additions and 19 deletions

View file

@ -356,7 +356,7 @@ void RbUtilQt::updateSettings()
" or review your settings."));
configDialog();
}
else if(chkConfig(false)) {
else if(chkConfig(0)) {
QApplication::processEvents();
QMessageBox::critical(this, tr("Configuration error"),
tr("Your configuration is invalid. This is most likely due "
@ -387,7 +387,7 @@ void RbUtilQt::updateDevice()
ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable);
/* Disable the whole tab widget if configuration is invalid */
bool configurationValid = !chkConfig(false);
bool configurationValid = !chkConfig(0);
ui.tabWidget->setEnabled(configurationValid);
ui.menuA_ctions->setEnabled(configurationValid);
@ -451,7 +451,7 @@ void RbUtilQt::updateManual()
void RbUtilQt::completeInstall()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to perform a complete installation?\n\n"
"This will install Rockbox %1. To install the most recent "
@ -507,7 +507,7 @@ void RbUtilQt::completeInstall()
void RbUtilQt::smallInstall()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to perform a minimal installation? "
"A minimal installation will contain only the absolutely "
@ -581,7 +581,7 @@ void RbUtilQt::installdone(bool error)
void RbUtilQt::installBtn()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
install();
}
@ -684,7 +684,7 @@ bool RbUtilQt::installBootloaderAuto()
void RbUtilQt::installBootloaderBtn()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(QMessageBox::question(this, tr("Confirm Installation"),
tr("Do you really want to install the Bootloader?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
@ -846,7 +846,7 @@ void RbUtilQt::installBootloaderPost(bool error)
void RbUtilQt::installFontsBtn()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
RockboxInfo installInfo(mountpoint);
if(installInfo.revision().isEmpty() && installInfo.release().isEmpty()) {
@ -910,7 +910,7 @@ void RbUtilQt::installFonts()
void RbUtilQt::installVoice()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(m_gotInfo == false)
{
@ -980,7 +980,7 @@ void RbUtilQt::installVoice()
void RbUtilQt::installDoomBtn()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(!hasDoom()){
QMessageBox::critical(this, tr("Error"),
tr("Your device doesn't have a doom plugin. Aborting."));
@ -1031,7 +1031,7 @@ void RbUtilQt::installDoom()
void RbUtilQt::installThemes()
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
ThemesInstallWindow* tw = new ThemesInstallWindow(this);
tw->setModal(true);
tw->show();
@ -1039,7 +1039,7 @@ void RbUtilQt::installThemes()
void RbUtilQt::createTalkFiles(void)
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
InstallTalkWindow *installWindow = new InstallTalkWindow(this);
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
installWindow->show();
@ -1048,16 +1048,16 @@ void RbUtilQt::createTalkFiles(void)
void RbUtilQt::createVoiceFile(void)
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
CreateVoiceWindow *installWindow = new CreateVoiceWindow(this);
connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
installWindow->show();
}
void RbUtilQt::uninstall(void)
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
UninstallWindow *uninstallWindow = new UninstallWindow(this);
uninstallWindow->show();
@ -1065,7 +1065,7 @@ void RbUtilQt::uninstall(void)
void RbUtilQt::uninstallBootloader(void)
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(QMessageBox::question(this, tr("Confirm Uninstallation"),
tr("Do you really want to uninstall the Bootloader?"),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
@ -1117,7 +1117,7 @@ void RbUtilQt::uninstallBootloader(void)
void RbUtilQt::downloadManual(void)
{
if(chkConfig(true)) return;
if(chkConfig(this)) return;
if(QMessageBox::question(this, tr("Confirm download"),
tr("Do you really want to download the manual? The manual will be saved "
"to the root folder of your player."),
@ -1290,7 +1290,7 @@ QUrl RbUtilQt::proxy()
}
bool RbUtilQt::chkConfig(bool warn)
bool RbUtilQt::chkConfig(QWidget *parent)
{
bool error = false;
if(RbSettings::value(RbSettings::Platform).toString().isEmpty()
@ -1298,7 +1298,7 @@ bool RbUtilQt::chkConfig(bool warn)
|| !QFileInfo(RbSettings::value(RbSettings::Mountpoint).toString()).isWritable()) {
error = true;
if(warn) QMessageBox::critical(this, tr("Configuration error"),
if(parent) QMessageBox::critical(parent, tr("Configuration error"),
tr("Your configuration is invalid. Please go to the configuration "
"dialog and make sure the selected values are correct."));
}

View file

@ -40,6 +40,7 @@ class RbUtilQt : public QMainWindow
public:
RbUtilQt(QWidget *parent = 0);
static QList<QTranslator*> translators;
static bool chkConfig(QWidget *parent = 0);
private:
Ui::RbUtilQtFrm ui;
@ -58,7 +59,6 @@ class RbUtilQt : public QMainWindow
ProgressLoggerGui *logger;
ZipInstaller *installer;
QUrl proxy(void);
bool chkConfig(bool);
volatile bool m_installed;
volatile bool m_error;