Skip to content

Commit

Permalink
Merge pull request #30 from hjaltisan/EO11400
Browse files Browse the repository at this point in the history
Button changes
  • Loading branch information
hjaltisan authored Dec 7, 2020
2 parents eaecc59 + 5e8b26f commit f5e5187
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 26 deletions.
30 changes: 30 additions & 0 deletions src/libs/installer/packagemanagercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,16 @@ bool PackageManagerCore::isOfflineOnly() const
return d->isOfflineOnly();
}

/*!
Returns \c true if this is our customized installer.
\sa {installer::isCustomInstaller}{installer.isCustomInstaller}
*/
bool PackageManagerCore::isCustomInstaller() const
{
return d->isCustomInstaller();
}

/*!
Returns \c true if using the custom introduction page.
Expand All @@ -2610,6 +2620,26 @@ bool PackageManagerCore::preloadPackages() const
return d->preloadPackages();
}

/*!
Returns \c true if no cancel button should be present in the installer/uninstaller.
\sa {installer::noCancelButton}{installer.noCancelButton}
*/
bool PackageManagerCore::noCancelButton() const
{
return d->noCancelButton();
}

/*!
Returns \c true if no details should be available in the installer/uninstaller.
\sa {installer::noDetails}{installer.noDetails}
*/
bool PackageManagerCore::noDetails() const
{
return d->noDetails();
}

/*!
\sa {installer::setUninstaller}{installer.setUninstaller}
\sa isUninstaller(), setUpdater(), setPackageManager()
Expand Down
5 changes: 5 additions & 0 deletions src/libs/installer/packagemanagercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ class INSTALLER_EXPORT PackageManagerCore : public QObject
// convenience
Q_INVOKABLE bool isInstaller() const;
Q_INVOKABLE bool isOfflineOnly() const;

// Our additions
Q_INVOKABLE bool isCustomInstaller() const;
Q_INVOKABLE bool useCustomIntroductionPage() const;
Q_INVOKABLE bool preloadPackages() const;
Q_INVOKABLE bool noCancelButton() const;
Q_INVOKABLE bool noDetails() const;

Q_INVOKABLE void setUninstaller();
Q_INVOKABLE bool isUninstaller() const;
Expand Down
30 changes: 24 additions & 6 deletions src/libs/installer/packagemanagercore_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,25 +620,43 @@ void PackageManagerCorePrivate::initialize(const QHash<QString, QString> &params
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
}

bool getConfigValueAsBool(const QString &key, bool defaultValue = false)
{
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
return confInternal.value(key, defaultValue).toBool();
}

bool PackageManagerCorePrivate::isOfflineOnly() const
{
if (!isInstaller())
return false;

QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
return confInternal.value(QLatin1String("offlineOnly"), false).toBool();
return getConfigValueAsBool(QLatin1String("offlineOnly"));
}

bool PackageManagerCorePrivate::isCustomInstaller() const
{
return getConfigValueAsBool(QLatin1String("customInstaller"));
}

bool PackageManagerCorePrivate::useCustomIntroductionPage() const
{
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
return confInternal.value(QLatin1String("customIntroductionPage"), false).toBool();
return getConfigValueAsBool(QLatin1String("customIntroductionPage"));
}

bool PackageManagerCorePrivate::preloadPackages() const
{
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
return confInternal.value(QLatin1String("preloadPackages"), false).toBool();
return getConfigValueAsBool(QLatin1String("preloadPackages"));
}

bool PackageManagerCorePrivate::noCancelButton() const
{
return getConfigValueAsBool(QLatin1String("noCancelButton"));
}

bool PackageManagerCorePrivate::noDetails() const
{
return getConfigValueAsBool(QLatin1String("noDetails"));
}

QString PackageManagerCorePrivate::installerBinaryPath() const
Expand Down
4 changes: 4 additions & 0 deletions src/libs/installer/packagemanagercore_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ class PackageManagerCorePrivate : public QObject
void initialize(const QHash<QString, QString> &params);
bool isOfflineOnly() const;

// Our additions
bool isCustomInstaller() const;
bool useCustomIntroductionPage() const;
bool preloadPackages() const;
bool noCancelButton() const;
bool noDetails() const;

bool statusCanceledOrFailed() const;
void setStatus(int status, const QString &error = QString());
Expand Down
55 changes: 38 additions & 17 deletions src/libs/installer/packagemanagergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
setOption(QWizard::NoBackButtonOnStartPage);
setOption(QWizard::NoBackButtonOnLastPage);

if (m_core->noCancelButton())
{
// Remove the cancel button from the installer/uninstaller
setOption(QWizard::NoCancelButton);
}

connect(this, &QDialog::rejected, m_core, &PackageManagerCore::setCanceled);
connect(this, &PackageManagerGui::interrupted, m_core, &PackageManagerCore::interrupt);

Expand Down Expand Up @@ -1849,6 +1855,9 @@ CustomIntroductionPage::CustomIntroductionPage(PackageManagerCore *core)
m_taskButton = nullptr;
}
#endif

// By setting this as a commit page, we make sure that the back button on the following page will be disabled
setCommitPage(true);
}

/*!
Expand Down Expand Up @@ -2285,17 +2294,21 @@ void CustomIntroductionPage::entering()
showWidgets(false);
setMessage(QString());
setErrorMessage(QString());
setButtonText(QWizard::CancelButton, tr("&Quit"));

m_progressBar->setValue(0);
m_progressBar->setRange(0, 0);
PackageManagerCore *core = packageManagerCore();
setSettingsButtonRequested((!core->isOfflineOnly()) && (!core->isUninstaller()));

if (!core->noCancelButton())
{
setButtonText(QWizard::CancelButton, tr("&Quit"));
}

// Ready for installation text
if (core->isUninstaller()) {
// m_taskDetailsBrowser->setVisible(false);
setButtonText(QWizard::NextButton, tr("U&ninstall"));
setButtonText(QWizard::CommitButton, tr("U&ninstall"));
setColoredTitle(tr("Ready to Uninstall %1").arg(productName()));
m_spaceLabel->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>, "
Expand All @@ -2306,25 +2319,19 @@ void CustomIntroductionPage::entering()
// setComplete(true);
// return;
} else if (core->isMaintainer()) {
setButtonText(QWizard::NextButton, tr("U&pdate"));
setButtonText(QWizard::CommitButton, tr("U&pdate"));
// setColoredTitle(tr("Ready to Update Packages"));
m_spaceLabel->setText(tr("Setup is now ready to begin updating your installation."));
} else {
Q_ASSERT(core->isInstaller());
core->calculateComponentsToInstall();
showInstallerInformation();
setButtonText(QWizard::NextButton, tr("&Install"));
setButtonText(QWizard::CommitButton, tr("&Install"));
// setColoredTitle(tr("Ready to Install"));
m_spaceLabel->setText(tr("Setup is now ready to begin installing %1 on your computer.")
.arg(productName()));
}

// QString htmlOutput;
// bool componentsOk = core->calculateComponents(&htmlOutput);
// m_taskDetailsBrowser->setHtml(htmlOutput);
// m_taskDetailsBrowser->setVisible(!componentsOk || isVerbose());
// setComplete(componentsOk);

if (!core->isUninstaller()) {
QString spaceInfo;
if (core->checkAvailableSpace(spaceInfo)) {
Expand Down Expand Up @@ -2354,11 +2361,14 @@ void CustomIntroductionPage::leaving()
m_progressBar->setValue(0);
m_progressBar->setRange(0, 0);

// Resetting the cancel button text from Quit to Cancel
setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton));
if (!packageManagerCore()->noCancelButton())
{
// Resetting the cancel button text from Quit to Cancel
setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton));
}

// Resetting button text (after changing it to Install/Uninstall/Update)
setButtonText(QWizard::NextButton, gui()->defaultButtonText(QWizard::NextButton));
setButtonText(QWizard::CommitButton, gui()->defaultButtonText(QWizard::CommitButton));

// Store the install location
packageManagerCore()->setValue(scTargetDir, targetDir());
Expand Down Expand Up @@ -3424,6 +3434,11 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)

m_performInstallationForm->setupUi(this);

if (core->noDetails())
{
m_performInstallationForm->noDetails();
}

connect(ProgressCoordinator::instance(), &ProgressCoordinator::detailTextChanged,
m_performInstallationForm, &PerformInstallationForm::appendProgressDetails);
connect(ProgressCoordinator::instance(), &ProgressCoordinator::detailTextResetNeeded,
Expand All @@ -3446,8 +3461,11 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)
connect(this, &PerformInstallationPage::setAutomatedPageSwitchEnabled,
core, &PackageManagerCore::setAutomatedPageSwitchEnabled);

m_performInstallationForm->setDetailsWidgetVisible(true);

if (!core->noDetails())
{
m_performInstallationForm->setDetailsWidgetVisible(true);
}

setCommitPage(true);
}

Expand Down Expand Up @@ -3495,10 +3513,13 @@ void PerformInstallationPage::entering()
QTimer::singleShot(30, packageManagerCore(), SLOT(runInstaller()));
}

m_performInstallationForm->enableDetails();
if (!packageManagerCore()->noDetails())
{
m_performInstallationForm->enableDetails();
}
emit setAutomatedPageSwitchEnabled(true);

if (isVerbose())
if (isVerbose() && !packageManagerCore()->noDetails())
m_performInstallationForm->toggleDetails();
}

Expand Down
9 changes: 9 additions & 0 deletions src/libs/installer/performinstallationform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,12 @@ void PerformInstallationForm::onDownloadStatusChanged(const QString &status)
m_downloadStatus->setText(m_downloadStatus->fontMetrics().elidedText(status, Qt::ElideRight,
m_downloadStatus->width()));
}

/*!
Removes the show/hide details button along with the details browser
*/
void PerformInstallationForm::noDetails() const
{
m_detailsButton->setVisible(false);
m_detailsBrowser->setVisible(false);
}
1 change: 1 addition & 0 deletions src/libs/installer/performinstallationform.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public slots:
void toggleDetails();
void clearDetailsBrowser();
void onDownloadStatusChanged(const QString &status);
void noDetails() const;

private:
QProgressBar *m_progressBar;
Expand Down
31 changes: 28 additions & 3 deletions tools/binarycreator/binarycreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,16 @@ static void printUsage()
std::cout << " -f|--offline-only Forces the installer to act as an offline installer, " << std::endl;
std::cout << " i.e. never access online repositories" << std::endl;

std::cout << " -xi|--custom-intro Forces the installer to use the custom introduction page" << std::endl;
std::cout << " If this parameter is not given, the standard page is used" << std::endl;
std::cout << " -x|--custom-installer Sets all the flags that we use for our reduced installer" << std::endl;

std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;
std::cout << " -xi|--custom-intro Forces the installer to use the custom introduction page" << std::endl;
std::cout << " If this parameter is not given, the standard page is used" << std::endl;

std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;

std::cout << " -xc|--no-cancel Remove all cancel buttons from the installer/uninstaller" << std::endl;

std::cout << " -xd|--no-details Don't offer any details in installer/uninstaller " << std::endl;

std::cout << " -r|--resources r1,.,rn include the given resource files into the binary" << std::endl;

Expand Down Expand Up @@ -788,8 +794,11 @@ int main(int argc, char **argv)
QStringList repositoryDirectories;
bool onlineOnly = false;
bool offlineOnly = false;
bool customInstaller = false;
bool customIntroductionPage = false;
bool preloadPackages = false;
bool noCancelButton = false;
bool noDetails = false;
QStringList resources;
QStringList filteredPackages;
QInstallerTools::FilterType ftype = QInstallerTools::Exclude;
Expand Down Expand Up @@ -850,10 +859,20 @@ int main(int argc, char **argv)
onlineOnly = true;
} else if (*it == QLatin1String("-f") || *it == QLatin1String("--offline-only")) {
offlineOnly = true;
} else if (*it == QLatin1String("-x") || *it == QLatin1String("--custom-installer")) {
customInstaller = true;
customIntroductionPage = true;
preloadPackages = true;
noCancelButton = true;
noDetails = true;
} else if (*it == QLatin1String("-xi") || *it == QLatin1String("--custom-intro")) {
customIntroductionPage = true;
} else if (*it == QLatin1String("-xp") || *it == QLatin1String("--preload-packages")) {
preloadPackages = true;
} else if (*it == QLatin1String("-xc") || *it == QLatin1String("--no-cancel")) {
noCancelButton = true;
} else if (*it == QLatin1String("-xd") || *it == QLatin1String("--no-details")) {
noDetails = true;
} else if (*it == QLatin1String("-t") || *it == QLatin1String("--template")) {
++it;
if (it == args.end()) {
Expand Down Expand Up @@ -995,10 +1014,16 @@ int main(int argc, char **argv)
if (onlineOnly)
offlineOnly = !onlineOnly;
confInternal.setValue(QLatin1String("offlineOnly"), offlineOnly);
// assume regular installer if --custom-installer not set
confInternal.setValue(QLatin1String("customInstaller"), customInstaller);
// assume standard introduction page if --custom-intro not set
confInternal.setValue(QLatin1String("customIntroductionPage"), customIntroductionPage);
// assume no preloading if --preload-packages not set
confInternal.setValue(QLatin1String("preloadPackages"), preloadPackages);
// assume cancel button if --no-cancel not set
confInternal.setValue(QLatin1String("noCancelButton"), noCancelButton);
// assume details are available if --no-details not set
confInternal.setValue(QLatin1String("noDetails"), noDetails);
}

#ifdef Q_OS_MACOS
Expand Down

0 comments on commit f5e5187

Please sign in to comment.