summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagergui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/packagemanagergui.cpp')
-rw-r--r--src/libs/installer/packagemanagergui.cpp380
1 files changed, 145 insertions, 235 deletions
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 1e01e69ff..4ce38a388 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -46,11 +46,11 @@
#include "fileutils.h"
#include "messageboxhandler.h"
#include "packagemanagercore.h"
-#include "qinstallerglobal.h"
#include "progresscoordinator.h"
#include "performinstallationform.h"
#include "settings.h"
#include "utils.h"
+#include "scriptengine.h"
#include "kdsysinfo.h"
@@ -85,8 +85,6 @@
#include <QScrollBar>
#include <QShowEvent>
-#include <QtScript/QScriptEngine>
-
using namespace KDUpdater;
using namespace QInstaller;
@@ -134,6 +132,7 @@ public:
setObjectName(QLatin1String("Dynamic") + widget->objectName());
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
+ setPixmap(QWizard::BannerPixmap, QPixmap());
setLayout(new QVBoxLayout);
setSubTitle(QString());
@@ -216,19 +215,13 @@ public:
QHash<int, QWizardPage*> m_defaultPages;
QHash<int, QString> m_defaultButtonText;
- QScriptValue m_controlScript;
- QScriptEngine m_controlScriptEngine;
+ QScriptValue m_controlScriptContext;
QHash<QWizard::WizardButton, QString> m_wizardButtonTypes;
};
// -- PackageManagerGui
-QScriptEngine *PackageManagerGui::controlScriptEngine() const
-{
- return &d->m_controlScriptEngine;
-}
-
/*!
\class QInstaller::PackageManagerGui
Is the "gui" object in a none interactive installation
@@ -244,7 +237,7 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
setWindowTitle(tr("Maintain %1").arg(m_core->value(scTitle)));
#ifndef Q_OS_MAC
- setWindowIcon(QIcon(m_core->settings().icon()));
+ setWindowIcon(QIcon(m_core->settings().installerWindowIcon()));
#else
setPixmap(QWizard::BackgroundPixmap, m_core->settings().background());
#endif
@@ -292,6 +285,8 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
for (int i = QWizard::BackButton; i < QWizard::CustomButton1; ++i)
d->m_defaultButtonText.insert(i, buttonText(QWizard::WizardButton(i)));
+
+ m_core->scriptEngine()->setGuiQObject(this);
}
PackageManagerGui::~PackageManagerGui()
@@ -311,20 +306,30 @@ QString PackageManagerGui::defaultButtonText(int wizardButton) const
void PackageManagerGui::clickButton(int wb, int delay)
{
- if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb) )) {
+ // transform the FinishButton to CancelButton, because of the needed misuse of the
+ // CancelButton as a FinishButton to have some more control of closing the wizard
+ if (!m_core->isInstaller() && currentId() == PackageManagerCore::InstallationFinished &&
+ wb == QWizard::FinishButton) {
+ wb = QWizard::CancelButton;
+ }
+ if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb) ))
QTimer::singleShot(delay, b, SLOT(click()));
- } else {
+ else
qWarning() << "Button with type: " << d->buttonType(wb) << "not found!";
- }
}
bool PackageManagerGui::isButtonEnabled(int wb)
{
- if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb) )) {
- return b->isEnabled();
- } else {
- qWarning() << "Button with type: " << d->buttonType(wb) << "not found!";
+ // transform the FinishButton to CancelButton, because of the needed misuse of the
+ // CancelButton as a FinishButton to have some more control of closing the wizard
+ if (!m_core->isInstaller() && currentId() == PackageManagerCore::InstallationFinished &&
+ wb == QWizard::FinishButton) {
+ wb = QWizard::CancelButton;
}
+ if (QAbstractButton *b = button(static_cast<QWizard::WizardButton>(wb) ))
+ return b->isEnabled();
+
+ qWarning() << "Button with type: " << d->buttonType(wb) << "not found!";
return false;
}
@@ -350,58 +355,8 @@ void PackageManagerGui::setValidatorForCustomPageRequested(Component *component,
*/
void PackageManagerGui::loadControlScript(const QString &scriptPath)
{
- QFile file(scriptPath);
- if (!file.open(QIODevice::ReadOnly)) {
- throw Error(QObject::tr("Could not open the requested script file at %1: %2")
- .arg(scriptPath, file.errorString()));
- }
-
- QScriptValue installerObject = d->m_controlScriptEngine.newQObject(m_core);
- installerObject.setProperty(QLatin1String("componentByName"), d->m_controlScriptEngine
- .newFunction(qInstallerComponentByName, 1));
-
- d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("installer"),
- installerObject);
- d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("gui"),
- d->m_controlScriptEngine.newQObject(this));
- d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("packagemanagergui"),
- d->m_controlScriptEngine.newQObject(this));
- registerMessageBox(&d->m_controlScriptEngine);
-
-#undef REGISTER_BUTTON
-#define REGISTER_BUTTON(x) buttons.setProperty(QLatin1String(#x), \
- d->m_controlScriptEngine.newVariant(static_cast<int>(QWizard::x)));
-
- QScriptValue buttons = d->m_controlScriptEngine.newArray();
- REGISTER_BUTTON(BackButton)
- REGISTER_BUTTON(NextButton)
- REGISTER_BUTTON(CommitButton)
- REGISTER_BUTTON(FinishButton)
- REGISTER_BUTTON(CancelButton)
- REGISTER_BUTTON(HelpButton)
- REGISTER_BUTTON(CustomButton1)
- REGISTER_BUTTON(CustomButton2)
- REGISTER_BUTTON(CustomButton3)
-
-#undef REGISTER_BUTTON
-
- d->m_controlScriptEngine.globalObject().setProperty(QLatin1String("buttons"), buttons);
-
- d->m_controlScriptEngine.evaluate(QLatin1String(file.readAll()), scriptPath);
- if (d->m_controlScriptEngine.hasUncaughtException()) {
- throw Error(QObject::tr("Exception while loading the control script %1")
- .arg(uncaughtExceptionString(&(d->m_controlScriptEngine)/*, scriptPath*/)));
- }
-
- QScriptValue comp = d->m_controlScriptEngine.evaluate(QLatin1String("Controller"));
- if (d->m_controlScriptEngine.hasUncaughtException()) {
- throw Error(QObject::tr("Exception while loading the control script %1")
- .arg(uncaughtExceptionString(&(d->m_controlScriptEngine)/*, scriptPath*/)));
- }
-
- d->m_controlScript = comp;
- d->m_controlScript.construct();
-
+ d->m_controlScriptContext = m_core->scriptEngine()->loadInConext(
+ QLatin1String("Controller"), scriptPath);
qDebug() << "Loaded control script" << scriptPath;
}
@@ -413,24 +368,18 @@ void PackageManagerGui::slotCurrentPageChanged(int id)
void PackageManagerGui::callControlScriptMethod(const QString &methodName)
{
- if (!d->m_controlScript.isValid())
- return;
-
- QScriptValue method = d->m_controlScript.property(QLatin1String("prototype")).property(methodName);
-
- if (!method.isValid()) {
- qDebug() << "Control script callback" << methodName << "does not exist.";
+ if (!d->m_controlScriptContext.isValid())
return;
- }
-
- qDebug() << "Calling control script callback" << methodName;
-
- method.call(d->m_controlScript);
+ try {
+ QScriptValue returnValue = m_core->scriptEngine()->callScriptMethod(
+ d->m_controlScriptContext, methodName);
- if (d->m_controlScriptEngine.hasUncaughtException()) {
- qCritical()
- << uncaughtExceptionString(&(d->m_controlScriptEngine) /*, QLatin1String("control script")*/);
- // TODO: handle error
+ if (!returnValue.isValid()) {
+ qDebug() << "Control script callback" << methodName << "does not exist.";
+ return;
+ }
+ } catch (const QInstaller::Error &e) {
+ qCritical() << qPrintable(e.message());
}
}
@@ -461,7 +410,6 @@ bool PackageManagerGui::event(QEvent *event)
void PackageManagerGui::showEvent(QShowEvent *event)
{
-#ifndef Q_OS_LINUX
if (!event->spontaneous()) {
foreach (int id, pageIds()) {
const QString subTitle = page(id)->subTitle();
@@ -472,7 +420,6 @@ void PackageManagerGui::showEvent(QShowEvent *event)
}
}
}
-#endif
QWizard::showEvent(event);
QMetaObject::invokeMethod(this, "dependsOnLocalInstallerBinary", Qt::QueuedConnection);
}
@@ -692,6 +639,9 @@ PackageManagerPage::PackageManagerPage(PackageManagerCore *core)
, m_core(core)
, validatorComponent(0)
{
+ setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
+ setPixmap(QWizard::BannerPixmap, bannerPixmap());
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
}
PackageManagerCore *PackageManagerPage::packageManagerCore() const
@@ -699,44 +649,14 @@ PackageManagerCore *PackageManagerPage::packageManagerCore() const
return m_core;
}
-QVariantHash PackageManagerPage::elementsForPage(const QString &pageName) const
-{
- const QVariant variant = m_core->settings().value(pageName);
-
- QVariantHash hash;
- if (variant.canConvert<QVariantHash>())
- hash = variant.value<QVariantHash>();
- return hash;
-}
-
-QString PackageManagerPage::titleForPage(const QString &pageName, const QString &value) const
-{
- return titleFromHash(m_core->settings().titlesForPage(pageName), value);
-}
-
-QString PackageManagerPage::subTitleForPage(const QString &pageName, const QString &value) const
-{
- return titleFromHash(m_core->settings().subTitlesForPage(pageName), value);
-}
-
-QString PackageManagerPage::titleFromHash(const QVariantHash &hash, const QString &value) const
+QPixmap PackageManagerPage::watermarkPixmap() const
{
- QString defaultValue = hash.value(QLatin1String("Default")).toString();
- if (defaultValue.isEmpty())
- defaultValue = value;
-
- if (m_core->isUpdater())
- return hash.value(QLatin1String("Updater"), defaultValue).toString();
- if (m_core->isInstaller())
- return hash.value(QLatin1String("Installer"), defaultValue).toString();
- if (m_core->isPackageManager())
- return hash.value(QLatin1String("PackageManager"), defaultValue).toString();
- return hash.value(QLatin1String("Uninstaller"), defaultValue).toString();
+ return QPixmap(m_core->value(QLatin1String("WatermarkPixmap")));
}
-QPixmap PackageManagerPage::watermarkPixmap() const
+QPixmap PackageManagerPage::bannerPixmap() const
{
- return QPixmap(m_core->value(QLatin1String("WatermarkPixmap")));
+ return QPixmap(m_core->value(QLatin1String("BannerPixmap")));
}
QPixmap PackageManagerPage::logoPixmap() const
@@ -815,10 +735,13 @@ void PackageManagerPage::setVisible(bool visible)
return;
}
- if (visible)
+ if (visible) {
entering();
- else
+ emit entered();
+ } else {
leaving();
+ emit left();
+ }
}
int PackageManagerPage::nextId() const
@@ -851,16 +774,12 @@ IntroductionPage::IntroductionPage(PackageManagerCore *core)
, m_widget(0)
{
setObjectName(QLatin1String("IntroductionPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("IntroductionPage")));
- setTitle(titleForPage(QLatin1String("IntroductionPage"), tr("Setup - %1")).arg(productName()));
+ setTitle(tr("Setup - %1").arg(productName()));
m_msgLabel = new QLabel(this);
m_msgLabel->setWordWrap(true);
m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("IntroductionPage"));
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Welcome to the %1 "
- "Setup Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Welcome to the %1 Setup Wizard.").arg(productName()));
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
@@ -916,10 +835,9 @@ private:
LicenseAgreementPage::LicenseAgreementPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("LicenseAgreementPage"));
- setTitle(titleForPage(QLatin1String("LicenseAgreementPage"), tr("License Agreement")));
+ setTitle(tr("License Agreement"));
m_licenseListWidget = new QListWidget(this);
m_licenseListWidget->setObjectName(QLatin1String("LicenseListWidget"));
@@ -1046,11 +964,10 @@ void LicenseAgreementPage::updateUi()
rejectButtonText = tr("I do not accept the licenses.");
}
- setSubTitle(subTitleForPage(QLatin1String("LicenseAgreementPage"), subTitleText));
+ setSubTitle(subTitleText);
- const QVariantHash hash = elementsForPage(QLatin1String("LicenseAgreementPage"));
- m_acceptLabel->setText(hash.value(QLatin1String("AcceptLicenseLabel"), acceptButtonText).toString());
- m_rejectLabel->setText(hash.value(QLatin1String("RejectLicenseLabel"), rejectButtonText).toString());
+ m_acceptLabel->setText(acceptButtonText);
+ m_rejectLabel->setText(rejectButtonText);
}
@@ -1072,8 +989,10 @@ public:
{
m_treeView->setObjectName(QLatin1String("ComponentsTreeView"));
- connect(m_allModel, SIGNAL(defaultCheckStateChanged(bool)), q, SLOT(setModified(bool)));
- connect(m_updaterModel, SIGNAL(defaultCheckStateChanged(bool)), q, SLOT(setModified(bool)));
+ connect(m_allModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
+ SLOT(onModelStateChanged(QInstaller::ComponentModel::ModelState)));
+ connect(m_updaterModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
+ SLOT(onModelStateChanged(QInstaller::ComponentModel::ModelState)));
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(m_treeView, 3);
@@ -1099,18 +1018,15 @@ public:
m_checkDefault = new QPushButton;
connect(m_checkDefault, SIGNAL(clicked()), this, SLOT(selectDefault()));
- connect(m_allModel, SIGNAL(defaultCheckStateChanged(bool)), m_checkDefault, SLOT(setEnabled(bool)));
- const QVariantHash hash = q->elementsForPage(QLatin1String("ComponentSelectionPage"));
if (m_core->isInstaller()) {
m_checkDefault->setObjectName(QLatin1String("SelectDefaultComponentsButton"));
m_checkDefault->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+A", "select default components")));
- m_checkDefault->setText(hash.value(QLatin1String("SelectDefaultComponentsButton"), ComponentSelectionPage::tr("Def&ault"))
- .toString());
+ m_checkDefault->setText(ComponentSelectionPage::tr("Def&ault"));
} else {
m_checkDefault->setEnabled(false);
m_checkDefault->setObjectName(QLatin1String("ResetComponentsButton"));
m_checkDefault->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+R", "reset to already installed components")));
- m_checkDefault->setText(hash.value(QLatin1String("ResetComponentsButton"), ComponentSelectionPage::tr("&Reset")).toString());
+ m_checkDefault->setText(ComponentSelectionPage::tr("&Reset"));
}
hlayout = new QHBoxLayout;
hlayout->addWidget(m_checkDefault);
@@ -1120,15 +1036,14 @@ public:
connect(m_checkAll, SIGNAL(clicked()), this, SLOT(selectAll()));
m_checkAll->setObjectName(QLatin1String("SelectAllComponentsButton"));
m_checkAll->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+S", "select all components")));
- m_checkAll->setText(hash.value(QLatin1String("SelectAllComponentsButton"), ComponentSelectionPage::tr("&Select All")).toString());
+ m_checkAll->setText(ComponentSelectionPage::tr("&Select All"));
m_uncheckAll = new QPushButton;
hlayout->addWidget(m_uncheckAll);
connect(m_uncheckAll, SIGNAL(clicked()), this, SLOT(deselectAll()));
m_uncheckAll->setObjectName(QLatin1String("DeselectAllComponentsButton"));
m_uncheckAll->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+D", "deselect all components")));
- m_uncheckAll->setText(hash.value(QLatin1String("DeselectAllComponentsButton"), ComponentSelectionPage::tr("&Deselect All"))
- .toString());
+ m_uncheckAll->setText(ComponentSelectionPage::tr("&Deselect All"));
hlayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding));
@@ -1140,9 +1055,7 @@ public:
m_checkDefault->setVisible(m_core->isInstaller() || m_core->isPackageManager());
if (m_treeView->selectionModel()) {
disconnect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex)));
- disconnect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentChanged(QModelIndex)));
+ this, SLOT(currentSelectedChanged(QModelIndex)));
}
m_currentModel = m_core->isUpdater() ? m_updaterModel : m_allModel;
@@ -1166,61 +1079,63 @@ public:
m_treeView->setRootIsDecorated(hasChildren);
connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex)));
- connect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentChanged(QModelIndex)));
+ this, SLOT(currentSelectedChanged(QModelIndex)));
m_treeView->setCurrentIndex(m_currentModel->index(0, 0));
}
public slots:
- void currentChanged(const QModelIndex &current)
+ void currentSelectedChanged(const QModelIndex &current)
{
- // if there is not selection or the current selected node didn't change, return
- if (!current.isValid() || current != m_treeView->selectionModel()->currentIndex())
+ if (!current.isValid())
return;
+ m_sizeLabel->setText(QString());
m_descriptionLabel->setText(m_currentModel->data(m_currentModel->index(current.row(),
ComponentModelHelper::NameColumn, current.parent()), Qt::ToolTipRole).toString());
- m_sizeLabel->clear();
- if (!m_core->isUninstaller()) {
- Component *component = m_currentModel->componentFromIndex(current);
- if (component && component->updateUncompressedSize() > 0) {
- const QVariantHash hash = q->elementsForPage(QLatin1String("ComponentSelectionPage"));
- m_sizeLabel->setText(hash.value(QLatin1String("ComponentSizeLabel"),
- ComponentSelectionPage::tr("This component will occupy approximately %1 on your hard disk drive.")).toString()
- .arg(m_currentModel->data(m_currentModel->index(current.row(),
- ComponentModelHelper::UncompressedSizeColumn, current.parent())).toString()));
- }
+ Component *component = m_currentModel->componentFromIndex(current);
+ if ((m_core->isUninstaller()) || (!component))
+ return;
+
+ if (component->isSelected() && (component->value(scUncompressedSizeSum).toLongLong() > 0)) {
+ m_sizeLabel->setText(ComponentSelectionPage::tr("This component "
+ "will occupy approximately %1 on your hard disk drive.")
+ .arg(humanReadableSize(component->value(scUncompressedSizeSum).toLongLong())));
}
}
- // TODO: all *select* function ignore the fact that components can be selected inside the tree view as
- // well, which will result in e.g. a disabled button state as long as "ALL" components not
- // unchecked again.
void selectAll()
{
- m_currentModel->selectAll();
-
- m_checkAll->setEnabled(false);
- m_uncheckAll->setEnabled(true);
+ m_currentModel->setCheckedState(ComponentModel::AllChecked);
}
void deselectAll()
{
- m_currentModel->deselectAll();
-
- m_checkAll->setEnabled(true);
- m_uncheckAll->setEnabled(false);
+ m_currentModel->setCheckedState(ComponentModel::AllUnchecked);
}
void selectDefault()
{
- m_currentModel->selectDefault();
+ m_currentModel->setCheckedState(ComponentModel::DefaultChecked);
+ }
- m_checkAll->setEnabled(true);
- m_uncheckAll->setEnabled(true);
+ void onModelStateChanged(QInstaller::ComponentModel::ModelState state)
+ {
+ q->setModified(state.testFlag(ComponentModel::DefaultChecked) == false);
+ // If all components in the checked list are only checkable when run without forced installation, set
+ // ComponentModel::AllUnchecked as well, as we cannot uncheck anything. Helps to keep the UI correct.
+ if ((!m_core->noForceInstallation()) && (m_currentModel->checked() == m_currentModel->uncheckable()))
+ state |= ComponentModel::AllUnchecked;
+
+ // enable the button if the corresponding flag is not set
+ m_checkAll->setEnabled(state.testFlag(ComponentModel::AllChecked) == false);
+ m_uncheckAll->setEnabled(state.testFlag(ComponentModel::AllUnchecked) == false);
+ m_checkDefault->setEnabled(state.testFlag(ComponentModel::DefaultChecked) == false);
+
+ // update the current selected node (important to reflect possible sub-node changes)
+ if (m_treeView->selectionModel())
+ currentSelectedChanged(m_treeView->selectionModel()->currentIndex());
}
public:
@@ -1248,10 +1163,9 @@ ComponentSelectionPage::ComponentSelectionPage(PackageManagerCore *core)
: PackageManagerPage(core)
, d(new Private(this, core))
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("ComponentSelectionPage"));
- setTitle(titleForPage(QLatin1String("ComponentSelectionPage"), tr("Select Components")));
+ setTitle(tr("Select Components"));
}
ComponentSelectionPage::~ComponentSelectionPage()
@@ -1273,7 +1187,7 @@ void ComponentSelectionPage::entering()
if (core->isInstaller()) index = 1;
if (core->isUninstaller()) index = 2;
if (core->isPackageManager()) index = 3;
- setSubTitle(subTitleForPage(QLatin1String("ComponentSelectionPage"), tr(strings[index])));
+ setSubTitle(tr(strings[index]));
d->updateTreeView();
setModified(isComplete());
@@ -1331,8 +1245,8 @@ void ComponentSelectionPage::setModified(bool modified)
bool ComponentSelectionPage::isComplete() const
{
if (packageManagerCore()->isInstaller() || packageManagerCore()->isUpdater())
- return d->m_currentModel->hasCheckedComponents();
- return !d->m_currentModel->defaultCheckState();
+ return d->m_currentModel->checked().count();
+ return d->m_currentModel->checkedState().testFlag(ComponentModel::DefaultChecked) == false;
}
@@ -1341,20 +1255,16 @@ bool ComponentSelectionPage::isComplete() const
TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("TargetDirectoryPage"));
- setSubTitle(subTitleForPage(QLatin1String("TargetDirectoryPage")));
- setTitle(titleForPage(QLatin1String("TargetDirectoryPage"), tr("Installation Folder")));
+ setTitle(tr("Installation Folder"));
QVBoxLayout *layout = new QVBoxLayout(this);
QLabel *msgLabel = new QLabel(this);
msgLabel->setWordWrap(true);
msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
- msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Please specify the folder "
- "where %1 will be installed.")).toString().arg(productName()));
+ msgLabel->setText(tr("Please specify the folder where %1 will be installed.").arg(productName()));
layout->addWidget(msgLabel);
QHBoxLayout *hlayout = new QHBoxLayout;
@@ -1368,8 +1278,7 @@ TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core)
browseButton->setObjectName(QLatin1String("BrowseDirectoryButton"));
connect(browseButton, SIGNAL(clicked()), this, SLOT(dirRequested()));
browseButton->setShortcut(QKeySequence(tr("Alt+R", "browse file system to choose a file")));
- browseButton->setText(hash.value(QLatin1String("BrowseDirectoryButton"), tr("B&rowse..."))
- .toString());
+ browseButton->setText(tr("B&rowse..."));
hlayout->addWidget(browseButton);
layout->addLayout(hlayout);
@@ -1403,12 +1312,10 @@ void TargetDirectoryPage::initializePage()
bool TargetDirectoryPage::validatePage()
{
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
if (targetDir().isEmpty()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("EmptyTargetDirectoryMessage"), tr("Error"), hash
- .value(QLatin1String("EmptyTargetDirectoryMessage"), tr("The install directory cannot be "
- "empty, please specify a valid folder.")).toString(), QMessageBox::Ok);
+ QLatin1String("EmptyTargetDirectoryMessage"), tr("Error"), tr("The install directory cannot be "
+ "empty, please specify a valid folder."), QMessageBox::Ok);
return false;
}
@@ -1421,9 +1328,8 @@ bool TargetDirectoryPage::validatePage()
// it exists, but is not empty
if (dir == QDir::root()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("ForbiddenTargetDirectoryMessage"), tr("Error"), hash
- .value(QLatin1String("ForbiddenTargetDirectoryMessage"), tr("As the install directory is "
- "completely deleted, installing in %1 is forbidden.")).toString().arg(QDir::rootPath()),
+ QLatin1String("ForbiddenTargetDirectoryMessage"), tr("Error"), tr("As the install directory "
+ "is completely deleted on uninstall, installing in %1 is forbidden.").arg(QDir::rootPath()),
QMessageBox::Ok);
return false;
}
@@ -1432,11 +1338,10 @@ bool TargetDirectoryPage::validatePage()
return true;
return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("OverwriteTargetDirectoryMessage"), tr("Warning"), hash
- .value(QLatin1String("OverwriteTargetDirectoryMessage"), tr("You have selected an existing, "
+ QLatin1String("OverwriteTargetDirectoryMessage"), tr("Warning"), tr("You have selected an existing, "
"non-empty folder for installation. Note that it will be completely wiped on uninstallation of "
"this application. It is not advisable to install into this folder as installation might fail. "
- "Do you want to continue?")).toString(), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
+ "Do you want to continue?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
}
return true;
}
@@ -1456,9 +1361,7 @@ void TargetDirectoryPage::targetDirSelected()
void TargetDirectoryPage::dirRequested()
{
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
- const QString newDirName = QFileDialog::getExistingDirectory(this, hash
- .value(QLatin1String("SelectInstallationFolderCaption"), tr("Select Installation Folder")).toString(),
+ const QString newDirName = QFileDialog::getExistingDirectory(this, tr("Select Installation Folder"),
targetDir());
if (newDirName.isEmpty() || newDirName == targetDir())
return;
@@ -1471,12 +1374,11 @@ void TargetDirectoryPage::dirRequested()
StartMenuDirectoryPage::StartMenuDirectoryPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("StartMenuDirectoryPage"));
- setTitle(titleForPage(QLatin1String("StartMenuDirectoryPage"), tr("Start Menu shortcuts")));
- setSubTitle(subTitleForPage(QLatin1String("StartMenuDirectoryPage"), tr("Select the Start Menu in which "
- "you would like to create the program's shortcuts. You can also enter a name to create a new folder.")));
+ setTitle(tr("Start Menu shortcuts"));
+ setSubTitle(tr("Select the Start Menu in which you would like to create the program's shortcuts. You can "
+ "also enter a name to create a new folder."));
m_lineEdit = new QLineEdit(this);
m_lineEdit->setObjectName(QLatin1String("LineEdit"));
@@ -1531,12 +1433,12 @@ StartMenuDirectoryPage::StartMenuDirectoryPage(PackageManagerCore *core)
QString StartMenuDirectoryPage::startMenuDir() const
{
- return m_lineEdit->text();
+ return m_lineEdit->text().trimmed();
}
void StartMenuDirectoryPage::setStartMenuDir(const QString &startMenuDir)
{
- m_lineEdit->setText(startMenuDir);
+ m_lineEdit->setText(startMenuDir.trimmed());
}
void StartMenuDirectoryPage::leaving()
@@ -1561,10 +1463,8 @@ ReadyForInstallationPage::ReadyForInstallationPage(PackageManagerCore *core)
: PackageManagerPage(core)
, m_msgLabel(new QLabel)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("ReadyForInstallationPage"));
- setSubTitle(subTitleForPage(QLatin1String("ReadyForInstallationPage")));
QVBoxLayout *baseLayout = new QVBoxLayout();
baseLayout->setObjectName(QLatin1String("BaseLayout"));
@@ -1612,7 +1512,7 @@ void ReadyForInstallationPage::entering()
m_taskDetailsButton->setVisible(false);
m_taskDetailsBrowser->setVisible(false);
setButtonText(QWizard::CommitButton, tr("U&ninstall"));
- setTitle(titleForPage(objectName(), tr("Ready to Uninstall")));
+ setTitle(tr("Ready to Uninstall"));
m_msgLabel->setText(tr("Setup is now ready to begin removing %1 from your computer.<br>"
"<font color=\"red\">The program directory %2 will be deleted completely</font>, "
"including all content in that directory!")
@@ -1622,12 +1522,12 @@ void ReadyForInstallationPage::entering()
return;
} else if (packageManagerCore()->isPackageManager() || packageManagerCore()->isUpdater()) {
setButtonText(QWizard::CommitButton, tr("U&pdate"));
- setTitle(titleForPage(objectName(), tr("Ready to Update Packages")));
+ setTitle(tr("Ready to Update Packages"));
m_msgLabel->setText(tr("Setup is now ready to begin updating your installation."));
} else {
Q_ASSERT(packageManagerCore()->isInstaller());
setButtonText(QWizard::CommitButton, tr("&Install"));
- setTitle(titleForPage(objectName(), tr("Ready to Install")));
+ setTitle(tr("Ready to Install"));
m_msgLabel->setText(tr("Setup is now ready to begin installing %1 on your computer.")
.arg(productName()));
}
@@ -1791,10 +1691,8 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)
: PackageManagerPage(core)
, m_performInstallationForm(new PerformInstallationForm(this))
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("PerformInstallationPage"));
- setSubTitle(subTitleForPage(QLatin1String("PerformInstallationPage")));
m_performInstallationForm->setupUi(this);
@@ -1836,17 +1734,17 @@ void PerformInstallationPage::entering()
if (packageManagerCore()->isUninstaller()) {
setButtonText(QWizard::CommitButton, tr("&Uninstall"));
- setTitle(titleForPage(objectName(), tr("Uninstalling %1")).arg(productName()));
+ setTitle(tr("Uninstalling %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runUninstaller()));
} else if (packageManagerCore()->isPackageManager() || packageManagerCore()->isUpdater()) {
setButtonText(QWizard::CommitButton, tr("&Update"));
- setTitle(titleForPage(objectName(), tr("Updating components of %1")).arg(productName()));
+ setTitle(tr("Updating components of %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runPackageUpdater()));
} else {
setButtonText(QWizard::CommitButton, tr("&Install"));
- setTitle(titleForPage(objectName(), tr("Installing %1")).arg(productName()));
+ setTitle(tr("Installing %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runInstaller()));
}
@@ -1913,21 +1811,16 @@ FinishedPage::FinishedPage(PackageManagerCore *core)
, m_commitButton(0)
{
setObjectName(QLatin1String("FinishedPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("FinishedPage")));
- setTitle(titleForPage(QLatin1String("FinishedPage"), tr("Completing the %1 Wizard")).arg(productName()));
+ setTitle(tr("Completing the %1 Wizard").arg(productName()));
m_msgLabel = new QLabel(this);
m_msgLabel->setWordWrap(true);
m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("FinishedPage"));
#ifdef Q_OS_MAC
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Click Done to exit the %1 "
- "Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Click Done to exit the %1 Wizard.").arg(productName()));
#else
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Click Finish to exit the "
- "%1 Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Click Finish to exit the %1 Wizard.").arg(productName()));
#endif
m_runItCheckBox = new QCheckBox(this);
@@ -1956,6 +1849,13 @@ void FinishedPage::entering()
m_commitButton = cancel;
cancel->setEnabled(true);
cancel->setVisible(true);
+ // we don't use the usual FinishButton so we need to connect the misused CancelButton
+ connect(cancel, SIGNAL(clicked()), gui(), SIGNAL(finishButtonClicked()));
+ connect(cancel, SIGNAL(clicked()), packageManagerCore(), SIGNAL(finishButtonClicked()));
+ // for the moment we don't want the rejected signal connected
+ disconnect(gui(), SIGNAL(rejected()), packageManagerCore(), SLOT(setCanceled()));
+
+ connect(gui()->button(QWizard::CommitButton), SIGNAL(clicked()), this, SLOT(cleanupChangedConnects()));
}
setButtonText(QWizard::CommitButton, tr("Restart"));
setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::FinishButton));
@@ -2012,13 +1912,26 @@ void FinishedPage::leaving()
void FinishedPage::handleFinishClicked()
{
const QString program = packageManagerCore()->replaceVariables(packageManagerCore()->value(scRunProgram));
+ const QStringList args = packageManagerCore()->replaceVariables(
+ packageManagerCore()->value(scRunProgramArguments)).split(QLatin1Char(' '));
if (!m_runItCheckBox->isChecked() || program.isEmpty())
return;
- qDebug() << "starting" << program;
- QProcess::startDetached(program);
+ qDebug() << "starting" << program << args;
+ QProcess::startDetached(program, args);
}
+void FinishedPage::cleanupChangedConnects()
+{
+ if (QAbstractButton *cancel = gui()->button(QWizard::CancelButton)) {
+ // remove the workaround connect from entering page
+ disconnect(cancel, SIGNAL(clicked()), gui(), SIGNAL(finishButtonClicked()));
+ disconnect(cancel, SIGNAL(clicked()), packageManagerCore(), SIGNAL(finishButtonClicked()));
+ connect(gui(), SIGNAL(rejected()), packageManagerCore(), SLOT(setCanceled()));
+
+ disconnect(gui()->button(QWizard::CommitButton), SIGNAL(clicked()), this, SLOT(cleanupChangedConnects()));
+ }
+}
// -- RestartPage
@@ -2026,10 +1939,7 @@ RestartPage::RestartPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
setObjectName(QLatin1String("RestartPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("RestartPage")));
- setTitle(titleForPage(QLatin1String("RestartPage"), tr("Completing the %1 Setup Wizard"))
- .arg(productName()));
+ setTitle(tr("Completing the %1 Setup Wizard").arg(productName()));
setFinalPage(false);
setCommitPage(false);