Skip to content

Commit ff45376

Browse files
committed
EO-11400 - Removing the cancel button
1 parent eaecc59 commit ff45376

File tree

6 files changed

+56
-19
lines changed

6 files changed

+56
-19
lines changed

src/libs/installer/packagemanagercore.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,6 +2610,16 @@ bool PackageManagerCore::preloadPackages() const
26102610
return d->preloadPackages();
26112611
}
26122612

2613+
/*!
2614+
Returns \c true if no cancel button should be present in the installer/uninstaller.
2615+
2616+
\sa {installer::noCancelButton}{installer.noCancelButton}
2617+
*/
2618+
bool PackageManagerCore::noCancelButton() const
2619+
{
2620+
return d->noCancelButton();
2621+
}
2622+
26132623
/*!
26142624
\sa {installer::setUninstaller}{installer.setUninstaller}
26152625
\sa isUninstaller(), setUpdater(), setPackageManager()

src/libs/installer/packagemanagercore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ class INSTALLER_EXPORT PackageManagerCore : public QObject
223223
// convenience
224224
Q_INVOKABLE bool isInstaller() const;
225225
Q_INVOKABLE bool isOfflineOnly() const;
226+
227+
// Our additions
226228
Q_INVOKABLE bool useCustomIntroductionPage() const;
227229
Q_INVOKABLE bool preloadPackages() const;
230+
Q_INVOKABLE bool noCancelButton() const;
228231

229232
Q_INVOKABLE void setUninstaller();
230233
Q_INVOKABLE bool isUninstaller() const;

src/libs/installer/packagemanagercore_p.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,25 +620,33 @@ void PackageManagerCorePrivate::initialize(const QHash<QString, QString> &params
620620
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(m_core->proxyFactory());
621621
}
622622

623+
bool getConfigValueAsBool(const QString &key, bool defaultValue = false)
624+
{
625+
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
626+
return confInternal.value(key, defaultValue).toBool();
627+
}
628+
623629
bool PackageManagerCorePrivate::isOfflineOnly() const
624630
{
625631
if (!isInstaller())
626632
return false;
627633

628-
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
629-
return confInternal.value(QLatin1String("offlineOnly"), false).toBool();
634+
return getConfigValueAsBool(QLatin1String("offlineOnly"));
630635
}
631636

632637
bool PackageManagerCorePrivate::useCustomIntroductionPage() const
633638
{
634-
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
635-
return confInternal.value(QLatin1String("customIntroductionPage"), false).toBool();
639+
return getConfigValueAsBool(QLatin1String("customIntroductionPage"));
636640
}
637641

638642
bool PackageManagerCorePrivate::preloadPackages() const
639643
{
640-
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
641-
return confInternal.value(QLatin1String("preloadPackages"), false).toBool();
644+
return getConfigValueAsBool(QLatin1String("preloadPackages"));
645+
}
646+
647+
bool PackageManagerCorePrivate::noCancelButton() const
648+
{
649+
return getConfigValueAsBool(QLatin1String("noCancelButton"));
642650
}
643651

644652
QString PackageManagerCorePrivate::installerBinaryPath() const

src/libs/installer/packagemanagercore_p.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ class PackageManagerCorePrivate : public QObject
8686
void initialize(const QHash<QString, QString> &params);
8787
bool isOfflineOnly() const;
8888

89+
// Our additions
8990
bool useCustomIntroductionPage() const;
9091
bool preloadPackages() const;
92+
bool noCancelButton() const;
9193

9294
bool statusCanceledOrFailed() const;
9395
void setStatus(int status, const QString &error = QString());

src/libs/installer/packagemanagergui.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
336336
setOption(QWizard::NoBackButtonOnStartPage);
337337
setOption(QWizard::NoBackButtonOnLastPage);
338338

339+
if (m_core->noCancelButton())
340+
{
341+
// Remove the cancel button from the installer/uninstaller
342+
setOption(QWizard::NoCancelButton);
343+
}
344+
339345
connect(this, &QDialog::rejected, m_core, &PackageManagerCore::setCanceled);
340346
connect(this, &PackageManagerGui::interrupted, m_core, &PackageManagerCore::interrupt);
341347

@@ -2285,13 +2291,17 @@ void CustomIntroductionPage::entering()
22852291
showWidgets(false);
22862292
setMessage(QString());
22872293
setErrorMessage(QString());
2288-
setButtonText(QWizard::CancelButton, tr("&Quit"));
22892294

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

2300+
if (!core->noCancelButton())
2301+
{
2302+
setButtonText(QWizard::CancelButton, tr("&Quit"));
2303+
}
2304+
22952305
// Ready for installation text
22962306
if (core->isUninstaller()) {
22972307
// m_taskDetailsBrowser->setVisible(false);
@@ -2319,12 +2329,6 @@ void CustomIntroductionPage::entering()
23192329
.arg(productName()));
23202330
}
23212331

2322-
// QString htmlOutput;
2323-
// bool componentsOk = core->calculateComponents(&htmlOutput);
2324-
// m_taskDetailsBrowser->setHtml(htmlOutput);
2325-
// m_taskDetailsBrowser->setVisible(!componentsOk || isVerbose());
2326-
// setComplete(componentsOk);
2327-
23282332
if (!core->isUninstaller()) {
23292333
QString spaceInfo;
23302334
if (core->checkAvailableSpace(spaceInfo)) {
@@ -2354,8 +2358,11 @@ void CustomIntroductionPage::leaving()
23542358
m_progressBar->setValue(0);
23552359
m_progressBar->setRange(0, 0);
23562360

2357-
// Resetting the cancel button text from Quit to Cancel
2358-
setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton));
2361+
if (!packageManagerCore()->noCancelButton())
2362+
{
2363+
// Resetting the cancel button text from Quit to Cancel
2364+
setButtonText(QWizard::CancelButton, gui()->defaultButtonText(QWizard::CancelButton));
2365+
}
23592366

23602367
// Resetting button text (after changing it to Install/Uninstall/Update)
23612368
setButtonText(QWizard::NextButton, gui()->defaultButtonText(QWizard::NextButton));
@@ -3447,7 +3454,7 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)
34473454
core, &PackageManagerCore::setAutomatedPageSwitchEnabled);
34483455

34493456
m_performInstallationForm->setDetailsWidgetVisible(true);
3450-
3457+
34513458
setCommitPage(true);
34523459
}
34533460

tools/binarycreator/binarycreator.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,12 @@ static void printUsage()
654654
std::cout << " -f|--offline-only Forces the installer to act as an offline installer, " << std::endl;
655655
std::cout << " i.e. never access online repositories" << std::endl;
656656

657-
std::cout << " -xi|--custom-intro Forces the installer to use the custom introduction page" << std::endl;
658-
std::cout << " If this parameter is not given, the standard page is used" << std::endl;
657+
std::cout << " -xi|--custom-intro Forces the installer to use the custom introduction page" << std::endl;
658+
std::cout << " If this parameter is not given, the standard page is used" << std::endl;
659659

660-
std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;
660+
std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;
661+
662+
std::cout << " -xc|--no-cancel Remove all cancel buttons from the installer/uninstaller" << std::endl;
661663

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

@@ -790,6 +792,7 @@ int main(int argc, char **argv)
790792
bool offlineOnly = false;
791793
bool customIntroductionPage = false;
792794
bool preloadPackages = false;
795+
bool noCancelButton = false;
793796
QStringList resources;
794797
QStringList filteredPackages;
795798
QInstallerTools::FilterType ftype = QInstallerTools::Exclude;
@@ -854,6 +857,8 @@ int main(int argc, char **argv)
854857
customIntroductionPage = true;
855858
} else if (*it == QLatin1String("-xp") || *it == QLatin1String("--preload-packages")) {
856859
preloadPackages = true;
860+
} else if (*it == QLatin1String("-xc") || *it == QLatin1String("--no-cancel")) {
861+
noCancelButton = true;
857862
} else if (*it == QLatin1String("-t") || *it == QLatin1String("--template")) {
858863
++it;
859864
if (it == args.end()) {
@@ -999,6 +1004,8 @@ int main(int argc, char **argv)
9991004
confInternal.setValue(QLatin1String("customIntroductionPage"), customIntroductionPage);
10001005
// assume no preloading if --preload-packages not set
10011006
confInternal.setValue(QLatin1String("preloadPackages"), preloadPackages);
1007+
// assume cancel button if --no-cancel not set
1008+
confInternal.setValue(QLatin1String("noCancelButton"), noCancelButton);
10021009
}
10031010

10041011
#ifdef Q_OS_MACOS

0 commit comments

Comments
 (0)