1 /* This file is part of the KDE project
2 Copyright (C) 2003-2004 Nadeem Hasan <nhasan@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, 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 GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include <QApplication>
23 #include <QVBoxLayout>
24 #include <QDesktopWidget>
26 #include <kcmoduleloader.h>
31 #include <KPluginFactory>
32 #include <KPluginLoader>
34 K_PLUGIN_FACTORY(DisplayFactory
,
35 registerPlugin
<KCMDisplay
>();
37 K_EXPORT_PLUGIN(DisplayFactory("display"))
39 KCMDisplay::KCMDisplay( QWidget
*parent
, const QVariantList
& )
40 : KCModule( DisplayFactory::componentData(), parent
)
43 m_tabs
= new QTabWidget( this );
45 addTab( "randr", i18n( "Size && Orientation" ) );
46 addTab( "nvidiadisplay", i18n( "Graphics Adaptor" ) );
47 addTab( "nvidia3d", i18n( "3D Options" ) );
48 addTab( "kgamma", i18n( "Monitor Gamma" ) );
49 if ( QApplication::desktop()->isVirtualDesktop() )
50 addTab( "xinerama", i18n( "Multiple Monitors" ) );
51 addTab( "energy", i18n( "Power Control" ) );
53 QVBoxLayout
*top
= new QVBoxLayout( this );
55 top
->setSpacing( KDialog::spacingHint() );
56 top
->addWidget( m_tabs
);
58 setButtons( Apply
|Help
);
62 void KCMDisplay::addTab( const QString
&name
, const QString
&label
)
64 QWidget
*page
= new QWidget( m_tabs
);
65 QVBoxLayout
*top
= new QVBoxLayout( page
);
66 top
->setMargin( KDialog::marginHint() );
68 KCModule
*kcm
= KCModuleLoader::loadModule( name
, KCModuleLoader::None
,page
);
72 top
->addWidget( kcm
);
73 m_tabs
->addTab( page
, label
);
75 connect( kcm
, SIGNAL( changed(bool) ), SLOT( moduleChanged(bool) ) );
76 m_modules
.insert(kcm
, false);
82 void KCMDisplay::load()
84 for (QMap
<KCModule
*, bool>::ConstIterator it
= m_modules
.constBegin(); it
!= m_modules
.constEnd(); ++it
)
88 void KCMDisplay::save()
90 for (QMap
<KCModule
*, bool>::Iterator it
= m_modules
.begin(); it
!= m_modules
.end(); ++it
)
95 void KCMDisplay::moduleChanged( bool isChanged
)
97 QMap
<KCModule
*, bool>::Iterator currentModule
= m_modules
.find(static_cast<KCModule
*>(const_cast<QObject
*>(sender())));
98 Q_ASSERT(currentModule
!= m_modules
.end());
99 if (currentModule
.value() == isChanged
)
102 currentModule
.value() = isChanged
;
106 for (QMap
<KCModule
*, bool>::ConstIterator it
= m_modules
.constBegin(); it
!= m_modules
.constEnd(); ++it
) {
113 if (m_changed
!= c
) {
119 #include "display.moc"