Changeset View
Changeset View
Standalone View
Standalone View
src/screencastwidget.cpp
Show All 20 Lines | |||||
21 | #include "screencastwidget.h" | 21 | #include "screencastwidget.h" | ||
22 | #include "waylandintegration.h" | 22 | #include "waylandintegration.h" | ||
23 | 23 | | |||
24 | #include <KLocalizedString> | 24 | #include <KLocalizedString> | ||
25 | 25 | | |||
26 | ScreenCastWidget::ScreenCastWidget(QWidget *parent) | 26 | ScreenCastWidget::ScreenCastWidget(QWidget *parent) | ||
27 | : QListWidget(parent) | 27 | : QListWidget(parent) | ||
28 | { | 28 | { | ||
29 | QMapIterator<quint32, WaylandIntegration::WaylandOutput> it(WaylandIntegration::screens()); | 29 | QVectorIterator<KWayland::Client::ScreencastingSource> it(WaylandIntegration::screencastingSources()); | ||
30 | while (it.hasNext()) { | 30 | while (it.hasNext()) { | ||
31 | it.next(); | 31 | const auto current = it.next(); | ||
32 | QListWidgetItem *widgetItem = new QListWidgetItem(this); | 32 | QListWidgetItem *widgetItem = new QListWidgetItem(this); | ||
33 | widgetItem->setData(Qt::UserRole, it.key()); | 33 | widgetItem->setData(Qt::UserRole, QVariant::fromValue(current)); | ||
34 | if (it.value().outputType() == WaylandIntegration::WaylandOutput::Laptop) { | 34 | widgetItem->setIcon(QIcon::fromTheme(current.iconName())); | ||
35 | widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("computer-laptop"))); | 35 | widgetItem->setText(current.description()); | ||
36 | widgetItem->setText(i18n("Laptop screen\nModel: %1", it.value().model())); | | |||
37 | } else if (it.value().outputType() == WaylandIntegration::WaylandOutput::Monitor) { | | |||
38 | widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("video-display"))); | | |||
39 | widgetItem->setText(i18n("Manufacturer: %1\nModel: %2", it.value().manufacturer(), it.value().model())); | | |||
40 | } else { | | |||
41 | widgetItem->setIcon(QIcon::fromTheme(QStringLiteral("video-television"))); | | |||
42 | widgetItem->setText(i18n("Manufacturer: %1\nModel: %2", it.value().manufacturer(), it.value().model())); | | |||
43 | } | | |||
44 | } | 36 | } | ||
45 | 37 | | |||
38 | Q_ASSERT(count() > 0); | ||||
46 | itemAt(0, 0)->setSelected(true); | 39 | itemAt(0, 0)->setSelected(true); | ||
47 | } | 40 | } | ||
48 | 41 | | |||
49 | ScreenCastWidget::~ScreenCastWidget() | 42 | ScreenCastWidget::~ScreenCastWidget() | ||
50 | { | 43 | { | ||
51 | } | 44 | } | ||
52 | 45 | | |||
53 | QList<quint32> ScreenCastWidget::selectedScreens() const | 46 | QVector<KWayland::Client::ScreencastingSource> ScreenCastWidget::selectedScreens() const | ||
54 | { | 47 | { | ||
55 | QList<quint32> selectedScreens; | 48 | QVector<KWayland::Client::ScreencastingSource> selectedScreens; | ||
56 | | ||||
57 | for (QListWidgetItem *item : selectedItems()) { | 49 | for (QListWidgetItem *item : selectedItems()) { | ||
58 | selectedScreens << item->data(Qt::UserRole).toUInt(); | 50 | selectedScreens << item->data(Qt::UserRole).value<KWayland::Client::ScreencastingSource>(); | ||
59 | } | 51 | } | ||
60 | | ||||
61 | return selectedScreens; | 52 | return selectedScreens; | ||
62 | } | 53 | } |