From 7060a34f73bbd26af6fabaaba4926565d78818b4 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 25 Mar 2023 23:53:16 -0500 Subject: Qt UI: Support DE choice, current as default In the Runtime Environment, we default to Plasma. In the Install Environment, we use the current desktop. Closes: #340 --- ui/qt5/pkgsimple.cc | 79 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 17 deletions(-) (limited to 'ui/qt5/pkgsimple.cc') diff --git a/ui/qt5/pkgsimple.cc b/ui/qt5/pkgsimple.cc index 2cd61b9..7ad65f8 100644 --- a/ui/qt5/pkgsimple.cc +++ b/ui/qt5/pkgsimple.cc @@ -23,17 +23,19 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { loadWatermark("software"); QLabel *descLabel = new QLabel(tr( - "Select the software you want to install on this computer.\n\n" - "You can install and uninstall more software at any time using the Package Manager. For more information, see the User Handbook in Online Help.")); + "Select the software you want to install on this computer.\n\n" + "You can install and uninstall more software at any time using the Package Manager. For more information, see the User Handbook in Online Help.")); descLabel->setWordWrap(true); QRadioButton *mobileButton, *compactButton, *textButton, *customButton; QLabel *standardLabel, *mobileLabel, *compactLabel, *textLabel, *customLabel; + standardButton = new QRadioButton(tr("&Standard")); standardButton->setIcon(QIcon::fromTheme("preferences-desktop-theme")); standardButton->setIconSize(QSize(32, 32)); - standardLabel = new QLabel(tr("Includes a full KDE desktop environment, including Web browser, email client, media player, and office suite.")); + standardLabel = new QLabel( + tr("Includes a full desktop environment, including Web browser, email client, media player, and office suite.")); standardLabel->setBuddy(standardButton); standardLabel->setWordWrap(true); standardButton->setWhatsThis(standardLabel->text()); @@ -41,7 +43,8 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { mobileButton = new QRadioButton(tr("&Mobile")); mobileButton->setIcon(QIcon::fromTheme("battery")); mobileButton->setIconSize(QSize(32, 32)); - mobileLabel = new QLabel(tr("Includes the Standard software and additional utilities for notebook and tablet computers.")); + mobileLabel = new QLabel( + tr("Includes the Standard software and additional utilities for notebook and tablet computers.")); mobileLabel->setBuddy(mobileButton); mobileLabel->setWordWrap(true); mobileButton->setWhatsThis(mobileLabel->text()); @@ -57,7 +60,8 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { textButton = new QRadioButton(tr("&Text-Only")); textButton->setIcon(QIcon::fromTheme("utilities-terminal")); textButton->setIconSize(QSize(32, 32)); - textLabel = new QLabel(tr("Includes support for text-mode only. Select this option on servers, or computers with very limited resources.")); + textLabel = new QLabel( + tr("Includes only text-mode support. Select for servers, or computers with very limited resources.")); textLabel->setBuddy(textButton); textLabel->setWordWrap(true); textButton->setWhatsThis(textLabel->text()); @@ -70,6 +74,33 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { customLabel->setWordWrap(true); customButton->setWhatsThis(customLabel->text()); + deskPlasmaButton = new QRadioButton(tr("KDE Plasma")); + deskLXQtButton = new QRadioButton(tr("LXQt")); + deskMATEButton = new QRadioButton(tr("MATE")); + deskXFCEButton = new QRadioButton(tr("XFCE")); + + QButtonGroup *desktopGroup = new QButtonGroup(this); + desktopGroup->addButton(deskPlasmaButton, HorizonWizard::Plasma); + desktopGroup->addButton(deskLXQtButton, HorizonWizard::LXQt); + desktopGroup->addButton(deskMATEButton, HorizonWizard::MATE); + desktopGroup->addButton(deskXFCEButton, HorizonWizard::XFCE); + connect(desktopGroup, QOverload::of(&QButtonGroup::buttonClicked), + [=](QAbstractButton *choice) { + horizonWizard()->desktopType = static_cast(desktopGroup->id(choice)); + }); + + QGridLayout *buttonLayout = new QGridLayout; + buttonLayout->addWidget(standardButton, 0, 0); + buttonLayout->addWidget(standardLabel, 0, 1); + buttonLayout->addWidget(mobileButton, 2, 0); + buttonLayout->addWidget(mobileLabel, 2, 1); + buttonLayout->addWidget(compactButton, 3, 0); + buttonLayout->addWidget(compactLabel, 3, 1); + buttonLayout->addWidget(textButton, 4, 0); + buttonLayout->addWidget(textLabel, 4, 1); + buttonLayout->addWidget(customButton, 5, 0); + buttonLayout->addWidget(customLabel, 5, 1); + QButtonGroup *group = new QButtonGroup(this); group->addButton(standardButton, HorizonWizard::Standard); group->addButton(mobileButton, HorizonWizard::Mobile); @@ -79,20 +110,23 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { connect(group, QOverload::of(&QButtonGroup::buttonClicked), [=](QAbstractButton *choice) { horizonWizard()->pkgtype = static_cast(group->id(choice)); + if(choice == standardButton) { + QHBoxLayout *desktopLayout = new QHBoxLayout; + for(auto button: {deskPlasmaButton, deskLXQtButton, deskMATEButton, deskXFCEButton}) { + button->show(); + desktopLayout->addWidget(button); + } + buttonLayout->addLayout(desktopLayout, 1, 1); + layout()->invalidate(); + } else { + auto item = buttonLayout->itemAtPosition(1, 1); + buttonLayout->removeItem(item); + for(auto button: {deskPlasmaButton, deskLXQtButton, deskMATEButton, deskXFCEButton}) { + button->hide(); + } + } }); - QGridLayout *buttonLayout = new QGridLayout; - buttonLayout->addWidget(standardButton, 0, 0); - buttonLayout->addWidget(standardLabel, 0, 1); - buttonLayout->addWidget(mobileButton, 1, 0); - buttonLayout->addWidget(mobileLabel, 1, 1); - buttonLayout->addWidget(compactButton, 2, 0); - buttonLayout->addWidget(compactLabel, 2, 1); - buttonLayout->addWidget(textButton, 3, 0); - buttonLayout->addWidget(textLabel, 3, 1); - buttonLayout->addWidget(customButton, 4, 0); - buttonLayout->addWidget(customLabel, 4, 1); - QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(descLabel); mainLayout->addStretch(); @@ -102,6 +136,17 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { void PkgSimplePage::initializePage() { standardButton->click(); +#ifdef HAS_INSTALL_ENV + auto curr_desktop = qEnvironmentVariable("XDG_CURRENT_DESKTOP").toStdString(); + if(curr_desktop == "LXQt") { + deskLXQtButton->click(); + } else if(curr_desktop == "MATE") { + deskMATEButton->click(); + } else if(curr_desktop == "XFCE") { + deskXFCEButton->click(); + } else +#endif /* HAS_INSTALL_ENV */ + deskPlasmaButton->click(); } int PkgSimplePage::nextId() const { -- cgit v1.2.3-60-g2f50