1
/*************************************************************************************
2
* Copyright 2014 Sebastian Kügler <sebas@kde.org> *
4
* This library is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU Lesser General Public *
6
* License as published by the Free Software Foundation; either *
7
* version 2.1 of the License, or (at your option) any later version. *
9
* This library is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12
* Lesser General Public License for more details. *
14
* You should have received a copy of the GNU Lesser General Public *
15
* License along with this library; if not, write to the Free Software *
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
17
*************************************************************************************/
19
#include "qscreenoutput.h"
20
#include "qscreenbackend.h"
25
#include <QGuiApplication>
28
using namespace KScreen;
30
QScreenOutput::QScreenOutput(const QScreen *qscreen, QObject *parent)
38
QScreenOutput::~QScreenOutput()
42
int QScreenOutput::id() const
47
void QScreenOutput::setId(const int newId)
52
KScreen::Edid *QScreenOutput::edid()
55
m_edid = new KScreen::Edid(0, 0, this);
60
const QScreen *QScreenOutput::qscreen() const
65
Output *QScreenOutput::toKScreenOutput(Config *parent) const
67
Output *output = new Output(parent);
69
output->setName(m_qscreen->name());
70
updateKScreenOutput(output);
74
void QScreenOutput::updateKScreenOutput(Output *output) const
76
// Initialize primary output
77
output->setEnabled(true);
78
output->setConnected(true);
79
output->setPrimary(QGuiApplication::primaryScreen() == m_qscreen);
81
// Rotation - translate QScreen::primaryOrientation() to Output::rotation()
82
if (m_qscreen->primaryOrientation() == Qt::PortraitOrientation) {
84
output->setRotation(Output::Right);
85
} else if (m_qscreen->primaryOrientation() == Qt::InvertedLandscapeOrientation) {
87
output->setRotation(Output::Inverted);
88
} else if (m_qscreen->primaryOrientation() == Qt::InvertedPortraitOrientation) {
90
output->setRotation(Output::Left);
93
// Physical size, geometry, etc.
96
physicalWidth = m_qscreen->size().width() / (m_qscreen->physicalDotsPerInchX() / 25.4);
97
mm.setWidth(qRound(physicalWidth));
99
physicalHeight = m_qscreen->size().height() / (m_qscreen->physicalDotsPerInchY() / 25.4);
100
mm.setHeight(qRound(physicalHeight));
101
output->setSizeMm(mm);
102
output->setPos(m_qscreen->availableGeometry().topLeft());
104
// Modes: we create a single default mode and go with that
105
Mode *mode = new Mode(output);
106
const QString modeid = QStringLiteral("defaultmode");
108
mode->setRefreshRate(m_qscreen->refreshRate());
109
mode->setSize(m_qscreen->size());
111
const QString modename = QString::number(m_qscreen->size().width()) + QStringLiteral("x") + QString::number(m_qscreen->size().height()) \
112
+ QStringLiteral("@") + QString::number(m_qscreen->refreshRate());
113
mode->setName(modename);
116
modes[modeid] = mode;
117
output->setModes(modes);
118
output->setCurrentModeId(modeid);
121
#include "qscreenoutput.moc"