add more spacing
[personal-kdebase.git] / workspace / libs / kephal / outputs / backendoutputs.cpp
blobe4716a08bb666489086600f12fde60a0483a0719
1 /*
2 * Copyright 2008 Aike J Sommer <dev@aikesommer.name>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2,
7 * or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "backendoutputs.h"
23 #include <QDebug>
26 namespace Kephal {
28 BackendOutput::BackendOutput(QObject * parent)
29 : Output(parent)
33 void BackendOutput::mark() {
34 m_markedActive = isActivated();
35 if (m_markedActive) {
36 m_markedGeom = geom();
37 m_markedRate = rate();
38 m_markedRotation = rotation();
39 m_markedReflectX = reflectX();
40 m_markedReflectY = reflectY();
44 void BackendOutput::revert() {
45 if (m_markedActive) {
46 applyGeom(m_markedGeom, m_markedRate);
47 applyOrientation(m_markedRotation, m_markedReflectX, m_markedReflectY);
48 } else {
49 deactivate();
55 BackendOutputs * BackendOutputs::m_instance = 0;
57 BackendOutputs * BackendOutputs::self() {
58 return m_instance;
61 BackendOutputs::BackendOutputs(QObject * parent)
62 : Outputs(parent)
64 m_instance = this;
67 BackendOutputs::~BackendOutputs()
69 m_instance = 0;
72 QList<BackendOutput *> BackendOutputs::backendOutputs() {
73 QList<BackendOutput *> result;
74 foreach (Output * output, outputs()) {
75 result << (BackendOutput *) output;
77 return result;
80 BackendOutput * BackendOutputs::backendOutput(const QString & id) {
81 foreach (BackendOutput * output, backendOutputs()) {
82 if (output->id() == id) {
83 return output;
86 return 0;
89 bool BackendOutputs::activateLayout(const QMap<Output *, QRect> & layout) {
90 qDebug() << "activate layout:" << layout;
92 QList<BackendOutput *> outputs = backendOutputs();
93 foreach (BackendOutput * output, outputs) {
94 //output->mark();
95 if (! layout.contains(output)) {
96 qDebug() << "deactivating output:" << output->id();
97 output->deactivate();
101 for (QMap<Output *, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
102 BackendOutput * output = (BackendOutput *) i.key();
103 qDebug() << "setting output" << output->id() << "to" << i.value();
105 if (! output->applyGeom(i.value(), 0)) {
106 qDebug() << "setting" << output->id() << "to" << i.value() << "failed!!";
107 return false;
111 return true;
116 #ifndef NO_KDE
117 #include "backendoutputs.moc"
118 #endif