From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcontrol/display/display.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 kcontrol/display/display.cpp (limited to 'kcontrol/display/display.cpp') diff --git a/kcontrol/display/display.cpp b/kcontrol/display/display.cpp new file mode 100644 index 000000000..1c514810c --- /dev/null +++ b/kcontrol/display/display.cpp @@ -0,0 +1,110 @@ +/* This file is part of the KDE project + Copyright (C) 2003-2004 Nadeem Hasan + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include +#include +#include + +#include "display.h" + +typedef KGenericFactory DisplayFactory; +K_EXPORT_COMPONENT_FACTORY ( kcm_display, DisplayFactory( "display" ) ) + +KCMDisplay::KCMDisplay( QWidget *parent, const char *name, const QStringList& ) + : KCModule( parent, name ) + , m_changed(false) +{ + m_tabs = new QTabWidget( this ); + + addTab( "randr", i18n( "Size && Orientation" ) ); + addTab( "nvidiadisplay", i18n( "Graphics Adaptor" ) ); + addTab( "nvidia3d", i18n( "3D Options" ) ); + addTab( "kgamma", i18n( "Monitor Gamma" ) ); + if ( QApplication::desktop()->isVirtualDesktop() ) + addTab( "xinerama", i18n( "Multiple Monitors" ) ); + addTab( "energy", i18n( "Power Control" ) ); + + QVBoxLayout *top = new QVBoxLayout( this, 0, KDialog::spacingHint() ); + top->addWidget( m_tabs ); + + setButtons( Apply|Help ); + load(); +} + +void KCMDisplay::addTab( const QString &name, const QString &label ) +{ + QWidget *page = new QWidget( m_tabs, name.latin1() ); + QVBoxLayout *top = new QVBoxLayout( page, KDialog::marginHint() ); + + KCModule *kcm = KCModuleLoader::loadModule( name, page ); + + if ( kcm ) + { + top->addWidget( kcm ); + m_tabs->addTab( page, label ); + + connect( kcm, SIGNAL( changed(bool) ), SLOT( moduleChanged(bool) ) ); + m_modules.insert(kcm, false); + } + else + delete page; +} + +void KCMDisplay::load() +{ + for (QMap::ConstIterator it = m_modules.begin(); it != m_modules.end(); ++it) + it.key()->load(); +} + +void KCMDisplay::save() +{ + for (QMap::Iterator it = m_modules.begin(); it != m_modules.end(); ++it) + if (it.data()) + it.key()->save(); +} + +void KCMDisplay::moduleChanged( bool isChanged ) +{ + QMap::Iterator currentModule = m_modules.find(static_cast(const_cast(sender()))); + Q_ASSERT(currentModule != m_modules.end()); + if (currentModule.data() == isChanged) + return; + + currentModule.data() = isChanged; + + bool c = false; + + for (QMap::ConstIterator it = m_modules.begin(); it != m_modules.end(); ++it) { + if (it.data()) { + c = true; + break; + } + } + + if (m_changed != c) { + m_changed = c; + emit changed(c); + } +} + +#include "display.moc" -- cgit v1.2.1