not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / randr / krandrmodule.cpp
blobc1e4384c7f98af353bc402ac8ebde49493bd1949
1 /*
2 * Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
3 * Copyright (c) 2002,2003 Hamish Rodda <rodda@kde.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "krandrmodule.h"
21 #include "legacyrandrconfig.h"
22 #include <QTextStream>
23 #include "legacyrandrscreen.h"
24 #include "randrdisplay.h"
25 #include "randrconfig.h"
27 #include <KPluginFactory>
28 #include <KPluginLoader>
29 #include <KDebug>
30 #include <config-randr.h>
32 #include "randr.h"
34 // DLL Interface for kcontrol
35 K_PLUGIN_FACTORY(KSSFactory, registerPlugin<KRandRModule>();)
36 K_EXPORT_PLUGIN(KSSFactory("krandr"))
38 KRandRModule::KRandRModule(QWidget *parent, const QVariantList&)
39 : KCModule(KSSFactory::componentData(), parent)
41 m_display = new RandRDisplay();
42 if (!m_display->isValid())
44 QVBoxLayout *topLayout = new QVBoxLayout(this);
45 QLabel *label =
46 new QLabel(i18n("Your X server does not support resizing and "
47 "rotating the display. Please update to version 4.3 "
48 "or greater. You need the X Resize, Rotate, and Reflect "
49 "extension (RANDR) version 1.1 or greater to use this "
50 "feature."), this);
52 label->setWordWrap(true);
53 topLayout->addWidget(label);
54 kWarning() << "Error: " << m_display->errorCode() ;
55 return;
58 QVBoxLayout* topLayout = new QVBoxLayout(this);
59 topLayout->setMargin(0);
60 topLayout->setSpacing(KDialog::spacingHint());
62 #ifdef HAS_RANDR_1_2
63 if (RandR::has_1_2)
65 m_config = new RandRConfig(this, m_display);
66 connect(m_config, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
67 topLayout->addWidget(m_config);
69 else
70 #endif
72 m_legacyConfig = new LegacyRandRConfig(this, m_display);
73 connect(m_legacyConfig, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
74 topLayout->addWidget(m_legacyConfig);
77 //topLayout->addStretch(1);
79 setButtons(KCModule::Apply);
82 KRandRModule::~KRandRModule(void)
84 delete m_display;
87 void KRandRModule::defaults()
89 #ifdef HAS_RANDR_1_2
90 if (RandR::has_1_2)
91 m_config->defaults();
92 else
93 #endif
94 m_legacyConfig->defaults();
97 void KRandRModule::load()
99 kDebug() << "Loading KRandRModule...";
101 #ifdef HAS_RANDR_1_2
102 if (RandR::has_1_2)
103 m_config->load();
104 else
105 #endif
106 m_legacyConfig->load();
108 emit changed(false);
111 void KRandRModule::save()
113 #ifdef HAS_RANDR_1_2
114 if (RandR::has_1_2)
115 m_config->save();
116 else
117 #endif
118 m_legacyConfig->save();
122 void KRandRModule::apply()
124 #ifdef HAS_RANDR_1_2
125 if (RandR::has_1_2)
126 m_config->apply();
127 else
128 #endif
129 m_legacyConfig->apply();
133 #include "krandrmodule.moc"