File indexing completed on 2024-11-17 04:40:43

0001 /*
0002    SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "selectprogrampage.h"
0008 #include "ui_selectprogrampage.h"
0009 
0010 SelectProgramPage::SelectProgramPage(QWidget *parent)
0011     : QWidget(parent)
0012     , ui(new Ui::SelectProgramPage)
0013 {
0014     ui->setupUi(this);
0015     connect(ui->listProgramFound, &QListWidget::itemSelectionChanged, this, &SelectProgramPage::slotItemSelectionChanged);
0016     connect(ui->listProgramFound, &QListWidget::itemDoubleClicked, this, &SelectProgramPage::slotItemDoubleClicked);
0017     connect(ui->manualSelectionCheckBox, &QCheckBox::clicked, this, &SelectProgramPage::slotSelectManualSelectionChanged);
0018 }
0019 
0020 SelectProgramPage::~SelectProgramPage()
0021 {
0022     delete ui;
0023 }
0024 
0025 void SelectProgramPage::setFoundProgram(const QStringList &list)
0026 {
0027     ui->listProgramFound->setNoProgramFound(list.isEmpty());
0028     ui->listProgramFound->addItems(list);
0029 }
0030 
0031 void SelectProgramPage::slotItemSelectionChanged()
0032 {
0033     if (ui->listProgramFound->currentItem()) {
0034         Q_EMIT programSelected(ui->listProgramFound->currentItem()->text());
0035     }
0036 }
0037 
0038 void SelectProgramPage::slotItemDoubleClicked(QListWidgetItem *item)
0039 {
0040     if (item) {
0041         Q_EMIT doubleClicked();
0042     }
0043 }
0044 
0045 void SelectProgramPage::disableSelectProgram()
0046 {
0047     ui->listProgramFound->setEnabled(false);
0048 }
0049 
0050 void SelectProgramPage::slotSelectManualSelectionChanged(bool b)
0051 {
0052     ui->listProgramFound->setEnabled(!b);
0053     Q_EMIT selectManualSelectionChanged(b);
0054 }
0055 
0056 #include "moc_selectprogrampage.cpp"