File indexing completed on 2024-12-15 03:45:04

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #include "screeninfosource.h"
0008 
0009 #include <QGuiApplication>
0010 #include <QScreen>
0011 #include <QVariant>
0012 
0013 using namespace KUserFeedback;
0014 
0015 ScreenInfoSource::ScreenInfoSource() :
0016     AbstractDataSource(QStringLiteral("screens"), Provider::DetailedSystemInformation)
0017 {
0018 }
0019 
0020 QString ScreenInfoSource::description() const
0021 {
0022     return tr("Size and resolution of all connected screens.");
0023 }
0024 
0025 QVariant ScreenInfoSource::data()
0026 {
0027     QVariantList l;
0028     foreach (auto screen, QGuiApplication::screens()) {
0029         QVariantMap m;
0030         m.insert(QStringLiteral("width"), screen->size().width());
0031         m.insert(QStringLiteral("height"), screen->size().height());
0032         m.insert(QStringLiteral("dpi"), qRound(screen->physicalDotsPerInch()));
0033         m.insert(QStringLiteral("devicePixelRatio"), screen->devicePixelRatio());
0034         l.push_back(m);
0035     }
0036     return l;
0037 }
0038 
0039 QString ScreenInfoSource::name() const
0040 {
0041     return tr("Screen parameters");
0042 }