File indexing completed on 2024-02-25 17:31:03

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Red Hat Inc
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  *
0006  * SPDX-FileCopyrightText: 2018 Jan Grulich <jgrulich@redhat.com>
0007  */
0008 
0009 #include "screencastwidget.h"
0010 #include "waylandintegration.h"
0011 
0012 #include <KLocalizedString>
0013 
0014 ScreenCastWidget::ScreenCastWidget(QWidget *parent)
0015     : QListWidget(parent)
0016 {
0017     QMapIterator<quint32, WaylandIntegration::WaylandOutput> it(WaylandIntegration::screens());
0018     while (it.hasNext()) {
0019         it.next();
0020         QListWidgetItem *widgetItem = new QListWidgetItem(this);
0021         widgetItem->setData(Qt::UserRole, it.key());
0022         if (it.value().outputType() == WaylandIntegration::WaylandOutput::Laptop) {
0023             widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("computer-laptop")));
0024             widgetItem->setText(i18n("Laptop screen\nModel: %1", it.value().model()));
0025         } else if (it.value().outputType() == WaylandIntegration::WaylandOutput::Monitor) {
0026             widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("video-display")));
0027             widgetItem->setText(i18n("Manufacturer: %1\nModel: %2", it.value().manufacturer(), it.value().model()));
0028         } else {
0029             widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("video-television")));
0030             widgetItem->setText(i18n("Manufacturer: %1\nModel: %2", it.value().manufacturer(), it.value().model()));
0031         }
0032     }
0033 }
0034 
0035 ScreenCastWidget::~ScreenCastWidget()
0036 {
0037 }
0038 
0039 QList<quint32> ScreenCastWidget::selectedScreens() const
0040 {
0041     QList<quint32> selectedScreens;
0042 
0043     const auto selectedItems = this->selectedItems();
0044     for (QListWidgetItem *item : selectedItems) {
0045         selectedScreens << item->data(Qt::UserRole).toUInt();
0046     }
0047 
0048     return selectedScreens;
0049 }