Skip to content

Commit f5e5187

Browse files
authored
Merge pull request #30 from hjaltisan/EO11400
Button changes
2 parents eaecc59 + 5e8b26f commit f5e5187

File tree

8 files changed

+139
-26
lines changed

8 files changed

+139
-26
lines changed

src/libs/installer/packagemanagercore.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,16 @@ bool PackageManagerCore::isOfflineOnly() const
25902590
return d->isOfflineOnly();
25912591
}
25922592

2593+
/*!
2594+
Returns \c true if this is our customized installer.
2595+
2596+
\sa {installer::isCustomInstaller}{installer.isCustomInstaller}
2597+
*/
2598+
bool PackageManagerCore::isCustomInstaller() const
2599+
{
2600+
return d->isCustomInstaller();
2601+
}
2602+
25932603
/*!
25942604
Returns \c true if using the custom introduction page.
25952605
@@ -2610,6 +2620,26 @@ bool PackageManagerCore::preloadPackages() const
26102620
return d->preloadPackages();
26112621
}
26122622

2623+
/*!
2624+
Returns \c true if no cancel button should be present in the installer/uninstaller.
2625+
2626+
\sa {installer::noCancelButton}{installer.noCancelButton}
2627+
*/
2628+
bool PackageManagerCore::noCancelButton() const
2629+
{
2630+
return d->noCancelButton();
2631+
}
2632+
2633+
/*!
2634+
Returns \c true if no details should be available in the installer/uninstaller.
2635+
2636+
\sa {installer::noDetails}{installer.noDetails}
2637+
*/
2638+
bool PackageManagerCore::noDetails() const
2639+
{
2640+
return d->noDetails();
2641+
}
2642+
26132643
/*!
26142644
\sa {installer::setUninstaller}{installer.setUninstaller}
26152645
\sa isUninstaller(), setUpdater(), setPackageManager()

src/libs/installer/packagemanagercore.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ class INSTALLER_EXPORT PackageManagerCore : public QObject
223223
// convenience
224224
Q_INVOKABLE bool isInstaller() const;
225225
Q_INVOKABLE bool isOfflineOnly() const;
226+
227+
// Our additions
228+
Q_INVOKABLE bool isCustomInstaller() const;
226229
Q_INVOKABLE bool useCustomIntroductionPage() const;
227230
Q_INVOKABLE bool preloadPackages() const;
231+
Q_INVOKABLE bool noCancelButton() const;
232+
Q_INVOKABLE bool noDetails() const;
228233

229234
Q_INVOKABLE void setUninstaller();
230235
Q_INVOKABLE bool isUninstaller() const;

src/libs/installer/packagemanagercore_p.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,25 +620,43 @@ 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"));
635+
}
636+
637+
bool PackageManagerCorePrivate::isCustomInstaller() const
638+
{
639+
return getConfigValueAsBool(QLatin1String("customInstaller"));
630640
}
631641

632642
bool PackageManagerCorePrivate::useCustomIntroductionPage() const
633643
{
634-
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
635-
return confInternal.value(QLatin1String("customIntroductionPage"), false).toBool();
644+
return getConfigValueAsBool(QLatin1String("customIntroductionPage"));
636645
}
637646

638647
bool PackageManagerCorePrivate::preloadPackages() const
639648
{
640-
QSettings confInternal(QLatin1String(":/config/config-internal.ini"), QSettings::IniFormat);
641-
return confInternal.value(QLatin1String("preloadPackages"), false).toBool();
649+
return getConfigValueAsBool(QLatin1String("preloadPackages"));
650+
}
651+
652+
bool PackageManagerCorePrivate::noCancelButton() const
653+
{
654+
return getConfigValueAsBool(QLatin1String("noCancelButton"));
655+
}
656+
657+
bool PackageManagerCorePrivate::noDetails() const
658+
{
659+
return getConfigValueAsBool(QLatin1String("noDetails"));
642660
}
643661

644662
QString PackageManagerCorePrivate::installerBinaryPath() const

src/libs/installer/packagemanagercore_p.h

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

89+
// Our additions
90+
bool isCustomInstaller() const;
8991
bool useCustomIntroductionPage() const;
9092
bool preloadPackages() const;
93+
bool noCancelButton() const;
94+
bool noDetails() const;
9195

9296
bool statusCanceledOrFailed() const;
9397
void setStatus(int status, const QString &error = QString());

src/libs/installer/packagemanagergui.cpp

Lines changed: 38 additions & 17 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

@@ -1849,6 +1855,9 @@ CustomIntroductionPage::CustomIntroductionPage(PackageManagerCore *core)
18491855
m_taskButton = nullptr;
18501856
}
18511857
#endif
1858+
1859+
// By setting this as a commit page, we make sure that the back button on the following page will be disabled
1860+
setCommitPage(true);
18521861
}
18531862

18541863
/*!
@@ -2285,17 +2294,21 @@ void CustomIntroductionPage::entering()
22852294
showWidgets(false);
22862295
setMessage(QString());
22872296
setErrorMessage(QString());
2288-
setButtonText(QWizard::CancelButton, tr("&Quit"));
22892297

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

2303+
if (!core->noCancelButton())
2304+
{
2305+
setButtonText(QWizard::CancelButton, tr("&Quit"));
2306+
}
2307+
22952308
// Ready for installation text
22962309
if (core->isUninstaller()) {
22972310
// m_taskDetailsBrowser->setVisible(false);
2298-
setButtonText(QWizard::NextButton, tr("U&ninstall"));
2311+
setButtonText(QWizard::CommitButton, tr("U&ninstall"));
22992312
setColoredTitle(tr("Ready to Uninstall %1").arg(productName()));
23002313
m_spaceLabel->setText(tr("Setup is now ready to begin removing %1 from your computer.<br>"
23012314
"<font color=\"red\">The program directory %2 will be deleted completely</font>, "
@@ -2306,25 +2319,19 @@ void CustomIntroductionPage::entering()
23062319
// setComplete(true);
23072320
// return;
23082321
} else if (core->isMaintainer()) {
2309-
setButtonText(QWizard::NextButton, tr("U&pdate"));
2322+
setButtonText(QWizard::CommitButton, tr("U&pdate"));
23102323
// setColoredTitle(tr("Ready to Update Packages"));
23112324
m_spaceLabel->setText(tr("Setup is now ready to begin updating your installation."));
23122325
} else {
23132326
Q_ASSERT(core->isInstaller());
23142327
core->calculateComponentsToInstall();
23152328
showInstallerInformation();
2316-
setButtonText(QWizard::NextButton, tr("&Install"));
2329+
setButtonText(QWizard::CommitButton, tr("&Install"));
23172330
// setColoredTitle(tr("Ready to Install"));
23182331
m_spaceLabel->setText(tr("Setup is now ready to begin installing %1 on your computer.")
23192332
.arg(productName()));
23202333
}
23212334

2322-
// QString htmlOutput;
2323-
// bool componentsOk = core->calculateComponents(&htmlOutput);
2324-
// m_taskDetailsBrowser->setHtml(htmlOutput);
2325-
// m_taskDetailsBrowser->setVisible(!componentsOk || isVerbose());
2326-
// setComplete(componentsOk);
2327-
23282335
if (!core->isUninstaller()) {
23292336
QString spaceInfo;
23302337
if (core->checkAvailableSpace(spaceInfo)) {
@@ -2354,11 +2361,14 @@ void CustomIntroductionPage::leaving()
23542361
m_progressBar->setValue(0);
23552362
m_progressBar->setRange(0, 0);
23562363

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

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

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

34253435
m_performInstallationForm->setupUi(this);
34263436

3437+
if (core->noDetails())
3438+
{
3439+
m_performInstallationForm->noDetails();
3440+
}
3441+
34273442
connect(ProgressCoordinator::instance(), &ProgressCoordinator::detailTextChanged,
34283443
m_performInstallationForm, &PerformInstallationForm::appendProgressDetails);
34293444
connect(ProgressCoordinator::instance(), &ProgressCoordinator::detailTextResetNeeded,
@@ -3446,8 +3461,11 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)
34463461
connect(this, &PerformInstallationPage::setAutomatedPageSwitchEnabled,
34473462
core, &PackageManagerCore::setAutomatedPageSwitchEnabled);
34483463

3449-
m_performInstallationForm->setDetailsWidgetVisible(true);
3450-
3464+
if (!core->noDetails())
3465+
{
3466+
m_performInstallationForm->setDetailsWidgetVisible(true);
3467+
}
3468+
34513469
setCommitPage(true);
34523470
}
34533471

@@ -3495,10 +3513,13 @@ void PerformInstallationPage::entering()
34953513
QTimer::singleShot(30, packageManagerCore(), SLOT(runInstaller()));
34963514
}
34973515

3498-
m_performInstallationForm->enableDetails();
3516+
if (!packageManagerCore()->noDetails())
3517+
{
3518+
m_performInstallationForm->enableDetails();
3519+
}
34993520
emit setAutomatedPageSwitchEnabled(true);
35003521

3501-
if (isVerbose())
3522+
if (isVerbose() && !packageManagerCore()->noDetails())
35023523
m_performInstallationForm->toggleDetails();
35033524
}
35043525

src/libs/installer/performinstallationform.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,12 @@ void PerformInstallationForm::onDownloadStatusChanged(const QString &status)
273273
m_downloadStatus->setText(m_downloadStatus->fontMetrics().elidedText(status, Qt::ElideRight,
274274
m_downloadStatus->width()));
275275
}
276+
277+
/*!
278+
Removes the show/hide details button along with the details browser
279+
*/
280+
void PerformInstallationForm::noDetails() const
281+
{
282+
m_detailsButton->setVisible(false);
283+
m_detailsBrowser->setVisible(false);
284+
}

src/libs/installer/performinstallationform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public slots:
6969
void toggleDetails();
7070
void clearDetailsBrowser();
7171
void onDownloadStatusChanged(const QString &status);
72+
void noDetails() const;
7273

7374
private:
7475
QProgressBar *m_progressBar;

tools/binarycreator/binarycreator.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,16 @@ 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 << " -x|--custom-installer Sets all the flags that we use for our reduced installer" << std::endl;
659658

660-
std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;
659+
std::cout << " -xi|--custom-intro Forces the installer to use the custom introduction page" << std::endl;
660+
std::cout << " If this parameter is not given, the standard page is used" << std::endl;
661+
662+
std::cout << " -xp|--preload-packages Preload all packages before displaying anything " << std::endl;
663+
664+
std::cout << " -xc|--no-cancel Remove all cancel buttons from the installer/uninstaller" << std::endl;
665+
666+
std::cout << " -xd|--no-details Don't offer any details in installer/uninstaller " << std::endl;
661667

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

@@ -788,8 +794,11 @@ int main(int argc, char **argv)
788794
QStringList repositoryDirectories;
789795
bool onlineOnly = false;
790796
bool offlineOnly = false;
797+
bool customInstaller = false;
791798
bool customIntroductionPage = false;
792799
bool preloadPackages = false;
800+
bool noCancelButton = false;
801+
bool noDetails = false;
793802
QStringList resources;
794803
QStringList filteredPackages;
795804
QInstallerTools::FilterType ftype = QInstallerTools::Exclude;
@@ -850,10 +859,20 @@ int main(int argc, char **argv)
850859
onlineOnly = true;
851860
} else if (*it == QLatin1String("-f") || *it == QLatin1String("--offline-only")) {
852861
offlineOnly = true;
862+
} else if (*it == QLatin1String("-x") || *it == QLatin1String("--custom-installer")) {
863+
customInstaller = true;
864+
customIntroductionPage = true;
865+
preloadPackages = true;
866+
noCancelButton = true;
867+
noDetails = true;
853868
} else if (*it == QLatin1String("-xi") || *it == QLatin1String("--custom-intro")) {
854869
customIntroductionPage = true;
855870
} else if (*it == QLatin1String("-xp") || *it == QLatin1String("--preload-packages")) {
856871
preloadPackages = true;
872+
} else if (*it == QLatin1String("-xc") || *it == QLatin1String("--no-cancel")) {
873+
noCancelButton = true;
874+
} else if (*it == QLatin1String("-xd") || *it == QLatin1String("--no-details")) {
875+
noDetails = true;
857876
} else if (*it == QLatin1String("-t") || *it == QLatin1String("--template")) {
858877
++it;
859878
if (it == args.end()) {
@@ -995,10 +1014,16 @@ int main(int argc, char **argv)
9951014
if (onlineOnly)
9961015
offlineOnly = !onlineOnly;
9971016
confInternal.setValue(QLatin1String("offlineOnly"), offlineOnly);
1017+
// assume regular installer if --custom-installer not set
1018+
confInternal.setValue(QLatin1String("customInstaller"), customInstaller);
9981019
// assume standard introduction page if --custom-intro not set
9991020
confInternal.setValue(QLatin1String("customIntroductionPage"), customIntroductionPage);
10001021
// assume no preloading if --preload-packages not set
10011022
confInternal.setValue(QLatin1String("preloadPackages"), preloadPackages);
1023+
// assume cancel button if --no-cancel not set
1024+
confInternal.setValue(QLatin1String("noCancelButton"), noCancelButton);
1025+
// assume details are available if --no-details not set
1026+
confInternal.setValue(QLatin1String("noDetails"), noDetails);
10021027
}
10031028

10041029
#ifdef Q_OS_MACOS

0 commit comments

Comments
 (0)