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 "dbusapi_configurations.h"
22 #include "kephal/configurations.h"
23 #include "configurationsadaptor.h"
24 #include "kephal/outputs.h"
30 using namespace Kephal
;
32 DBusAPIConfigurations::DBusAPIConfigurations(QObject
* parent
)
35 new ConfigurationsAdaptor(this);
36 QDBusConnection dbus
= QDBusConnection::sessionBus();
39 result
= dbus
.registerObject("/Configurations", this);
40 qDebug() << "configurations registered on the bus:" << result
;
42 connect(Configurations::self(), SIGNAL(configurationActivated(Kephal::Configuration
*)), this, SLOT(configurationActivatedSlot(Kephal::Configuration
*)));
43 connect(Configurations::self(), SIGNAL(confirmed()), this, SIGNAL(confirmed()));
44 connect(Configurations::self(), SIGNAL(reverted()), this, SIGNAL(reverted()));
45 connect(Configurations::self(), SIGNAL(confirmTimeout(int)), this, SIGNAL(confirmTimeout(int)));
48 QStringList
DBusAPIConfigurations::configurations() {
50 foreach (const QString
& name
, Configurations::self()->configurations().keys()) {
56 int DBusAPIConfigurations::numAvailablePositions(QString output
) {
57 Output
* o
= Outputs::self()->output(output
);
59 m_outputAvailablePositions
.insert(output
, o
->availablePositions());
60 return m_outputAvailablePositions
[output
].size();
65 QPoint
DBusAPIConfigurations::availablePosition(QString output
, int index
) {
66 if (m_outputAvailablePositions
.contains(output
)) {
67 return m_outputAvailablePositions
[output
][index
];
72 QStringList
DBusAPIConfigurations::alternateConfigurations() {
74 foreach (Configuration
* config
, Configurations::self()->alternateConfigurations()) {
75 result
<< config
->name();
80 QString
DBusAPIConfigurations::activeConfiguration() {
81 Configuration
* config
= Configurations::self()->activeConfiguration();
83 return config
->name();
88 bool DBusAPIConfigurations::move(QString output
, QPoint position
) {
89 Output
* o
= Outputs::self()->output(output
);
91 return Configurations::self()->move(o
, position
);
96 bool DBusAPIConfigurations::resize(QString output
, QSize size
) {
97 Output
* o
= Outputs::self()->output(output
);
99 return Configurations::self()->resize(o
, size
);
104 bool DBusAPIConfigurations::rotate(QString output
, int rotation
) {
105 Output
* o
= Outputs::self()->output(output
);
107 return Configurations::self()->rotate(o
, (Rotation
) rotation
);
112 bool DBusAPIConfigurations::changeRate(QString output
, qreal rate
) {
113 Output
* o
= Outputs::self()->output(output
);
115 return Configurations::self()->changeRate(o
, rate
);
120 bool DBusAPIConfigurations::reflectX(QString output
, bool reflect
) {
121 Output
* o
= Outputs::self()->output(output
);
123 return Configurations::self()->reflectX(o
, reflect
);
128 bool DBusAPIConfigurations::reflectY(QString output
, bool reflect
) {
129 Output
* o
= Outputs::self()->output(output
);
131 return Configurations::self()->reflectY(o
, reflect
);
136 bool DBusAPIConfigurations::isModifiable(QString config
) {
137 Configuration
* c
= Configurations::self()->configuration(config
);
139 return c
->isModifiable();
144 bool DBusAPIConfigurations::isActivated(QString config
) {
145 Configuration
* c
= Configurations::self()->configuration(config
);
147 return c
->isActivated();
152 void DBusAPIConfigurations::activate(QString config
) {
153 Configuration
* c
= Configurations::self()->configuration(config
);
159 int DBusAPIConfigurations::primaryScreen(QString config
) {
160 Configuration
* c
= Configurations::self()->configuration(config
);
162 return c
->primaryScreen();
167 int DBusAPIConfigurations::screen(QString outputId
) {
168 Output
* output
= Outputs::self()->output(outputId
);
170 return Configurations::self()->screen(output
);
175 void DBusAPIConfigurations::setPolling(bool polling
) {
176 Configurations::self()->setPolling(polling
);
179 bool DBusAPIConfigurations::polling() {
180 return Configurations::self()->polling();
183 void DBusAPIConfigurations::configurationActivatedSlot(Kephal::Configuration
* configuration
) {
184 emit
configurationActivated(configuration
->name());
187 void DBusAPIConfigurations::confirm() {
188 Configurations::self()->confirm();
191 void DBusAPIConfigurations::revert() {
192 Configurations::self()->revert();
196 #include "dbusapi_configurations.moc"