summaryrefslogtreecommitdiffstats
path: root/examples/testapp/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/testapp/mainwindow.cpp')
-rw-r--r--examples/testapp/mainwindow.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/examples/testapp/mainwindow.cpp b/examples/testapp/mainwindow.cpp
index 7347de99c..81a613e2c 100644
--- a/examples/testapp/mainwindow.cpp
+++ b/examples/testapp/mainwindow.cpp
@@ -54,9 +54,9 @@ using namespace QInstallerCreator;
MainWindow::MainWindow(const QStringList &args, QWidget *parent)
: QMainWindow(parent)
, m_dialog(new UpdateSettingsDialog(this))
- , m_installer(new Installer(QInstaller::MagicUpdaterMarker))
{
- m_installer->setUpdaterApplication(&updaterapp);
+ m_installer.setUpdater();
+ m_installer.setUpdaterApplication(&updaterapp);
QMenu *fm = menuBar()->addMenu(QObject::tr("File"));
fm->addAction(QObject::tr("Check for Updates"), this, SLOT(checkForUpdates()),
@@ -69,7 +69,7 @@ MainWindow::MainWindow(const QStringList &args, QWidget *parent)
label->setWordWrap(true);
label->setAlignment(Qt::AlignCenter);
setCentralWidget(label);
- label->setText(QString::fromLatin1("Version: %1\n").arg(m_installer->settings().applicationVersion())
+ label->setText(QString::fromLatin1("Version: %1\n").arg(m_installer.settings().applicationVersion())
+ args.join(QLatin1String(" ")));
updaterapp.packagesInfo()->setApplicationName(m_settings.applicationName());
@@ -92,44 +92,48 @@ void MainWindow::checkForUpdates()
UpdateSettings settings;
try {
- m_installer->setTemporaryRepositories(settings.repositories());
+ m_installer.setTemporaryRepositories(settings.repositories());
settings.setLastCheck(QDateTime::currentDateTime());
- m_installer->fetchUpdaterPackages();
+ if (!m_installer.fetchUpdaterPackages()) {
+ settings.setLastResult(tr("Software Update failed."));
+ QMessageBox::information(this, tr("Check for Updates"), tr("Failed to retrieve updates!"));
+ return;
+ }
// no updates for us
- if(m_installer->components(false, UpdaterMode).isEmpty()) {
+ if(m_installer.components(false, UpdaterMode).isEmpty()) {
QMessageBox::information(this, tr("Check for Updates"), tr("There are currently no updates "
"available for you."));
return;
}
// set the target directory to the actual one
- m_installer->setValue(QLatin1String("TargetDir"), QFileInfo(updaterapp.packagesInfo()->fileName())
+ m_installer.setValue(QLatin1String("TargetDir"), QFileInfo(updaterapp.packagesInfo()->fileName())
.absolutePath());
// this will automatically mark components as to get installed
- ComponentSelectionDialog componentSelection(m_installer, this);
+ ComponentSelectionDialog componentSelection(&m_installer, this);
if(componentSelection.exec() == QDialog::Rejected)
return;
QProgressDialog dialog(this);
dialog.setRange(0, 100);
dialog.show();
- connect(&dialog, SIGNAL(canceled()), m_installer, SLOT(interrupt()));
- connect(m_installer, SIGNAL(installationProgressTextChanged(QString)), &dialog,
+ connect(&dialog, SIGNAL(canceled()), &m_installer, SLOT(interrupt()));
+ connect(&m_installer, SIGNAL(installationProgressTextChanged(QString)), &dialog,
SLOT(setLabelText(QString)));
- connect(m_installer, SIGNAL(installationProgressChanged(int)), &dialog, SLOT(setValue(int)));
- m_installer->installSelectedComponents();
+ connect(&m_installer, SIGNAL(installationProgressChanged(int)), &dialog, SLOT(setValue(int)));
+ m_installer.installSelectedComponents();
updatesInstalled();
} catch (const QInstaller::Error &error) {
QMessageBox::critical(this, tr("Check for Updates"), tr("Error while installing updates:\n%1")
.arg(error.what()));
- m_installer->rollBackInstallation();
+ m_installer.rollBackInstallation();
settings.setLastResult(tr("Software Update failed."));
} catch (...) {
QMessageBox::critical(this, tr("Check for Updates"), tr("Unknown error while installing updates."));
- m_installer->rollBackInstallation();
+ m_installer.rollBackInstallation();
settings.setLastResult(tr("Software Update failed."));
}
}