summaryrefslogtreecommitdiff
path: root/ui/qt5/pkgcustom.cc
blob: 33a56b31e2461ea935035f850d559356d226e6fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * pkgcustom.cc - Implementation of the UI.Packages.Custom page
 * horizon-qt5, the Qt 5 user interface for
 * Project Horizon
 *
 * Copyright (c) 2019 Adélie Linux and contributors.  All rights reserved.
 * This code is licensed under the AGPL 3.0 license, as noted in the
 * LICENSE-code file in the root directory of this repository.
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

#include "pkgcustom.hh"

#include <QGroupBox>
#include <QTreeView>
#include <QVBoxLayout>

PkgCustomPage::PkgCustomPage(QWidget *parent) : HorizonWizardPage(parent) {
    setTitle(tr("Software Selection"));
    loadWatermark("software");

    QLabel *descLabel = new QLabel(tr(
        "Choose the software you want to install on this computer.\n\n"
        "You may select any category or software package to read a brief description of it."));
    descLabel->setWordWrap(true);

    QTreeView *pkgTree = new QTreeView;
    model = new PkgItemModel(nullptr, this);
    pkgTree->setHeaderHidden(true);
    pkgTree->setModel(model);
    pkgTree->setUniformRowHeights(true);

    QItemSelectionModel *selModel = pkgTree->selectionModel();
    connect(selModel, &QItemSelectionModel::currentChanged, [=](const QModelIndex &current){
        QVariant data = model->data(current, Qt::StatusTipRole);
        if(data.isValid()) {
            pkgDescLabel->setText(data.toString());
        }
    });

    pkgDescLabel = new QLabel(tr("Select an item to view its description.\n\n "));
    pkgDescLabel->setWordWrap(true);
    QGroupBox *descBox = new QGroupBox("Description");
    QVBoxLayout *descLayout = new QVBoxLayout;
    descLayout->addWidget(pkgDescLabel);
    descBox->setLayout(descLayout);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(descLabel);
    layout->addWidget(pkgTree);
    layout->addWidget(descBox);
    setLayout(layout);
}

void PkgCustomPage::initializePage() {
    model->setPackageList(&(horizonWizard()->packages));
}