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 <QDBusInterface>
23 #include "screens/dbus/dbusscreens.h"
24 #include "outputs/dbus/dbusoutputs.h"
25 #include "configurations/dbus/dbusconfigurations.h"
26 #include "configurations/noconfigurations.h"
27 #include "screens/output/outputscreens.h"
28 #include "outputs/desktopwidget/desktopwidgetoutputs.h"
30 using namespace Kephal
;
34 * This factory-method is invoked the first time any of Screens::self(),
35 * Outputs::self() or Configurations::self() is called.
36 * It will create the singleton-instances and check for their validity.
37 * If the dbus-based implementations are not valid a fallback to
38 * QDesktopWidget will be used instead.
40 * The method is hooked into the ...::self()-methods with these lines
42 * ADD_DEFINITIONS (-DSCREENS_FACTORY=libkephal_factory)
43 * ADD_DEFINITIONS (-DOUTPUTS_FACTORY=libkephal_factory)
44 * ADD_DEFINITIONS (-DCONFIGURATIONS_FACTORY=libkephal_factory)
46 void libkephal_factory() {
47 //qDebug() << "trying to access kephald...";
48 QDBusInterface
interface("org.kde.kded", "/modules/kded_kephal");
50 DBusConfigurations
* configurations
= new DBusConfigurations(qApp
);
51 DBusOutputs
* outputs
= new DBusOutputs(qApp
);
52 DBusScreens
* screens
= new DBusScreens(qApp
);
53 if ((! screens
->isValid()) || (! outputs
->isValid()) || (! configurations
->isValid())) {
54 qWarning() << "could not access kephald, falling back to QDesktopWidget";
58 delete configurations
;
60 new NoConfigurations(qApp
);
61 new DesktopWidgetOutputs(qApp
);
62 new OutputScreens(qApp
);