From 40426b314c02727bab5e8cd720838037644defad Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 6 Dec 2023 08:05:41 -0600 Subject: Qt UI: Refactor package selection page, again * Allows one to choose Standard, Mobile, or Compact of any DE. * Refactor automatic package selection to better reflect what users are likely to expect from their selection. * Use tabs to separate graphical desktop, text-only / server, and custom options. This will allow us to add more options later, as well. * Fit in given size. --- ui/qt5/pkgsimple.cc | 77 ++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'ui/qt5/pkgsimple.cc') diff --git a/ui/qt5/pkgsimple.cc b/ui/qt5/pkgsimple.cc index e168583..eab4066 100644 --- a/ui/qt5/pkgsimple.cc +++ b/ui/qt5/pkgsimple.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { @@ -30,12 +31,13 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { QRadioButton *mobileButton, *compactButton, *textButton, *customButton; QLabel *standardLabel, *mobileLabel, *compactLabel, *textLabel, *customLabel; + QTabWidget *tabWidget; standardButton = new QRadioButton(tr("&Standard")); standardButton->setIcon(QIcon::fromTheme("preferences-desktop-theme")); standardButton->setIconSize(QSize(32, 32)); standardLabel = new QLabel( - tr("Includes a full desktop environment, including Web browser, email client, media player, and office suite.")); + tr("Includes a full desktop environment, Web browser, email client, media player, and software suite.")); standardLabel->setBuddy(standardButton); standardLabel->setIndent(40); standardLabel->setWordWrap(true); @@ -45,7 +47,7 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { 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.")); + tr("Includes the Standard software set and additional utilities for notebook and tablet computers.")); mobileLabel->setBuddy(mobileButton); mobileLabel->setIndent(40); mobileLabel->setWordWrap(true); @@ -54,7 +56,7 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { compactButton = new QRadioButton(tr("&Compact")); compactButton->setIcon(QIcon::fromTheme("preferences-ubuntu-panel")); compactButton->setIconSize(QSize(32, 32)); - compactLabel = new QLabel(tr("Includes a lightweight LXQt desktop environment and a text editor.")); + compactLabel = new QLabel(tr("Desktop environment and lightweight utilities only.")); compactLabel->setBuddy(compactButton); compactLabel->setIndent(40); compactLabel->setWordWrap(true); @@ -94,51 +96,54 @@ PkgSimplePage::PkgSimplePage(QWidget *parent) : HorizonWizardPage(parent) { horizonWizard()->desktopType = static_cast(desktopGroup->id(choice)); }); - auto *buttonLayout = new QVBoxLayout; - buttonLayout->addWidget(standardButton); - buttonLayout->addWidget(standardLabel); - buttonLayout->addWidget(mobileButton); - buttonLayout->addWidget(mobileLabel); - buttonLayout->addWidget(compactButton); - buttonLayout->addWidget(compactLabel); - buttonLayout->addWidget(textButton); - buttonLayout->addWidget(textLabel); - buttonLayout->addWidget(customButton); - buttonLayout->addWidget(customLabel); - - QButtonGroup *group = new QButtonGroup(this); + auto *desktopLayout = new QHBoxLayout; + for(auto button: {deskPlasmaButton, deskLXQtButton, deskMATEButton, deskXFCEButton}) { + desktopLayout->addWidget(button); + } + auto *gfxButtonLayout = new QVBoxLayout; + gfxButtonLayout->addLayout(desktopLayout); + gfxButtonLayout->addStretch(); + gfxButtonLayout->addWidget(standardButton); + gfxButtonLayout->addWidget(standardLabel); + gfxButtonLayout->addWidget(mobileButton); + gfxButtonLayout->addWidget(mobileLabel); + gfxButtonLayout->addWidget(compactButton); + gfxButtonLayout->addWidget(compactLabel); + auto *gfxTab = new QWidget; + gfxTab->setLayout(gfxButtonLayout); + + auto *textButtonLayout = new QVBoxLayout; + textButtonLayout->addWidget(textButton); + textButtonLayout->addWidget(textLabel); + auto *textTab = new QWidget; + textTab->setLayout(textButtonLayout); + + auto *customButtonLayout = new QVBoxLayout; + customButtonLayout->addWidget(customButton); + customButtonLayout->addWidget(customLabel); + auto *customTab = new QWidget; + customTab->setLayout(customButtonLayout); + + auto *group = new QButtonGroup(this); group->addButton(standardButton, HorizonWizard::Standard); group->addButton(mobileButton, HorizonWizard::Mobile); group->addButton(compactButton, HorizonWizard::Compact); group->addButton(textButton, HorizonWizard::TextOnly); group->addButton(customButton, HorizonWizard::Custom); connect(group, QOverload::of(&QButtonGroup::buttonClicked), - [this, group, buttonLayout](QAbstractButton *choice) { + [this, group](QAbstractButton *choice) { horizonWizard()->pkgtype = static_cast(group->id(choice)); - if(choice == standardButton) { - auto *desktopLayout = new QHBoxLayout; - desktopLayout->setObjectName("desk-buttons"); - for(auto button: {deskPlasmaButton, deskLXQtButton, deskMATEButton, deskXFCEButton}) { - button->show(); - desktopLayout->addWidget(button); - } - buttonLayout->insertLayout(2, desktopLayout); - layout()->invalidate(); - } else { - auto item = buttonLayout->itemAt(2); - if(item->layout() && item->layout()->objectName() == "desk-buttons") { - buttonLayout->removeItem(item); - for (auto button: {deskPlasmaButton, deskLXQtButton, deskMATEButton, deskXFCEButton}) { - button->hide(); - } - } - } }); + tabWidget = new QTabWidget(this); + tabWidget->addTab(gfxTab, tr("Desktop")); + tabWidget->addTab(textTab, tr("Text/Server")); + tabWidget->addTab(customTab, tr("Custom")); + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(descLabel); mainLayout->addStretch(); - mainLayout->addLayout(buttonLayout); + mainLayout->addWidget(tabWidget); setLayout(mainLayout); } -- cgit v1.2.3-60-g2f50