add more spacing
[personal-kdebase.git] / workspace / libs / kephal / configurations / dbus / dbusconfigurations.cpp
blob456f56e2704388af48630d6edc792fe1d2f29b27
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 "dbusconfigurations.h"
24 #include "configurations_interface.h"
26 #include "kephal/outputs.h"
29 namespace Kephal {
31 DBusConfiguration::DBusConfiguration(DBusConfigurations * parent, QString name)
32 : Configuration(parent),
33 m_name(name),
34 m_parent(parent)
38 QString DBusConfiguration::name() {
39 return m_name;
42 bool DBusConfiguration::isModifiable() {
43 return m_parent->interface()->isModifiable(m_name);
46 bool DBusConfiguration::isActivated() {
47 return m_parent->interface()->isActivated(m_name);
50 QMap<int, QPoint> DBusConfiguration::layout() {
51 return QMap<int, QPoint>();
54 void DBusConfiguration::activate() {
55 m_parent->interface()->activate(m_name);
58 int DBusConfiguration::primaryScreen() {
59 return m_parent->interface()->primaryScreen(m_name);
64 DBusConfigurations::DBusConfigurations(QObject * parent)
65 : Configurations(parent)
67 m_interface = new org::kde::Kephal::Configurations(
68 "org.kde.Kephal",
69 "/Configurations",
70 QDBusConnection::sessionBus(),
71 this);
73 if (! m_interface->isValid()) {
74 m_valid = false;
75 return;
78 m_valid = true;
80 const QStringList names = m_interface->configurations();
81 foreach (const QString& name, names) {
82 m_configs.insert(name, new DBusConfiguration(this, name));
85 connect(m_interface, SIGNAL(configurationActivated(QString)), this, SLOT(configurationActivatedSlot(QString)));
86 connect(m_interface, SIGNAL(confirmed()), this, SIGNAL(confirmed()));
87 connect(m_interface, SIGNAL(reverted()), this, SIGNAL(reverted()));
88 connect(m_interface, SIGNAL(confirmTimeout(int)), this, SIGNAL(confirmTimeout(int)));
92 QMap<QString, Configuration *> DBusConfigurations::configurations() {
93 QMap<QString, Configuration *> result;
94 for (QMap<QString, DBusConfiguration *>::const_iterator i = m_configs.constBegin(); i != m_configs.constEnd(); ++i) {
95 result.insert(i.key(), i.value());
97 return result;
100 Configuration * DBusConfigurations::activeConfiguration() {
101 QString name = m_interface->activeConfiguration();
102 if ((! name.isEmpty()) && m_configs.contains(name)) {
103 return m_configs[name];
105 return 0;
108 QList<Configuration *> DBusConfigurations::alternateConfigurations() {
109 const QStringList names = m_interface->alternateConfigurations();
110 QList<Configuration *> result;
111 foreach (const QString& name, names) {
112 if (m_configs.contains(name)) {
113 result << m_configs[name];
116 return result;
119 QList<QPoint> DBusConfigurations::possiblePositions(Output * output) {
120 QList<QPoint> result;
121 int num = m_interface->numAvailablePositions(output->id());
122 for (int i = 0; i < num; ++i) {
123 result << m_interface->availablePosition(output->id(), i);
125 return result;
128 bool DBusConfigurations::move(Output * output, const QPoint & position) {
129 return m_interface->move(output->id(), position);
132 bool DBusConfigurations::resize(Output * output, const QSize & size) {
133 return m_interface->resize(output->id(), size);
136 bool DBusConfigurations::rotate(Output * output, Rotation rotation) {
137 return m_interface->rotate(output->id(), rotation);
140 bool DBusConfigurations::reflectX(Output * output, bool reflect) {
141 return m_interface->reflectX(output->id(), reflect);
144 bool DBusConfigurations::reflectY(Output * output, bool reflect) {
145 return m_interface->reflectY(output->id(), reflect);
148 bool DBusConfigurations::changeRate(Output * output, float rate) {
149 return m_interface->changeRate(output->id(), rate);
152 bool DBusConfigurations::isValid() {
153 return m_valid;
156 org::kde::Kephal::Configurations * DBusConfigurations::interface() {
157 return m_interface;
160 int DBusConfigurations::screen(Output * output) {
161 return m_interface->screen(output->id());
164 void DBusConfigurations::applyOutputSettings() {
167 void DBusConfigurations::setPolling(bool polling) {
168 m_interface->setPolling(polling);
171 bool DBusConfigurations::polling() {
172 return m_interface->polling();
175 void DBusConfigurations::configurationActivatedSlot(QString name) {
176 if ((! name.isEmpty()) && m_configs.contains(name)) {
177 emit configurationActivated(m_configs[name]);
181 void DBusConfigurations::confirm() {
182 m_interface->confirm();
185 void DBusConfigurations::revert() {
186 m_interface->revert();