summaryrefslogtreecommitdiffstats
path: root/examples/testapp
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-06-01 15:21:55 +0200
committerkh1 <qt-info@nokia.com>2011-06-01 15:21:55 +0200
commite2e31f26bce9092426c8193abaf066536f8d3d9c (patch)
treef8fad80f9068232b68e70c9c33d993d98f675022 /examples/testapp
parentaad139ba7a0af35909b97d77406e8397f86da818 (diff)
Keep the installer on the stack.
Diffstat (limited to 'examples/testapp')
-rw-r--r--examples/testapp/mainwindow.cpp32
-rw-r--r--examples/testapp/mainwindow.h3
2 files changed, 19 insertions, 16 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."));
}
}
diff --git a/examples/testapp/mainwindow.h b/examples/testapp/mainwindow.h
index 5b7d83461..e2ae37a8c 100644
--- a/examples/testapp/mainwindow.h
+++ b/examples/testapp/mainwindow.h
@@ -39,7 +39,6 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(const QStringList &args, QWidget *parent = 0);
- ~MainWindow() { delete m_installer; }
private Q_SLOTS:
void editUpdateSettings();
@@ -49,8 +48,8 @@ private Q_SLOTS:
private:
UpdateSettingsDialog *m_dialog;
- QInstaller::Installer *m_installer;
+ QInstaller::Installer m_installer;
KDUpdater::Application updaterapp;
QInstaller::InstallerSettings m_settings;
};