[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: kdebase/kcontrol/display
From: Frans Englich <frans.englich () telia ! com>
Date: 2004-09-19 16:28:57
Message-ID: 200409191628.58060.frans.englich () telia ! com
[Download RAW message or body]
On Sunday 19 September 2004 09:20, Hamish Rodda wrote:
> CVS commit by rodda:
>
> Two changes:
> 1) Remember each sub-module's changed state so that if one submodule
> reports it is unchanged after another has reported a change, this module
> will not declare itself unchanged.
>
> 2) Include the new nvidia modules if present.
You have basically duplicated the KCModuleContainer class in kdelibs/kutils,
branch new_kcm_code :) It was written to replace cases like this. The branch
will probably be merged into HEAD in 3.4, so I would probably leave this
code.
Cheers,
Frans
>
>
> M +40 -26 display.cpp 1.12
> M +6 -6 display.h 1.8
>
>
> --- kdebase/kcontrol/display/display.cpp #1.11:1.12
> @@ -32,14 +32,16 @@ K_EXPORT_COMPONENT_FACTORY ( kcm_display
>
> KCMDisplay::KCMDisplay( QWidget *parent, const char *name, const
> QStringList& ) - : KCModule( parent, name ),
> - m_randr( 0 ), m_gamma( 0 ), m_xiner( 0 ), m_energy( 0 )
> + : KCModule( parent, name )
> + , m_changed(false)
> {
> m_tabs = new QTabWidget( this );
>
> - m_randr = addTab( "randr", i18n( "Size && Orientation" ) );
> - m_gamma = addTab( "kgamma", i18n( "Monitor Gamma" ) );
> + addTab( "randr", i18n( "Size && Orientation" ) );
> + addTab( "nvidiadisplay", i18n( "Graphics Adaptor" ) );
> + addTab( "nvidia3d", i18n( "3D Options" ) );
> + addTab( "kgamma", i18n( "Monitor Gamma" ) );
> if ( QApplication::desktop()->isVirtualDesktop() )
> - m_xiner = addTab( "xinerama", i18n( "Multiple Monitors" ) );
> - m_energy = addTab( "energy", i18n( "Power Control" ) );
> + addTab( "xinerama", i18n( "Multiple Monitors" ) );
> + addTab( "energy", i18n( "Power Control" ) );
>
> QVBoxLayout *top = new QVBoxLayout( this, 0, KDialog::spacingHint() );
> @@ -50,5 +52,5 @@ KCMDisplay::KCMDisplay( QWidget *parent,
> }
>
> -KCModule* KCMDisplay::addTab( const QString &name, const QString &label )
> +void KCMDisplay::addTab( const QString &name, const QString &label )
> {
> QWidget *page = new QWidget( m_tabs, name.latin1() );
> @@ -62,34 +64,46 @@ KCModule* KCMDisplay::addTab( const QStr
> m_tabs->addTab( page, label );
>
> - connect( kcm, SIGNAL( changed(bool) ), SIGNAL( changed(bool) ) );
> + connect( kcm, SIGNAL( changed(bool) ), SLOT( moduleChanged(bool) ) );
> + m_modules.insert(kcm, false);
> }
> else
> delete page;
> -
> - return kcm;
> }
>
> void KCMDisplay::load()
> {
> - if ( m_randr )
> - m_randr->load();
> - if ( m_gamma )
> - m_gamma->load();
> - if ( m_xiner )
> - m_xiner->load();
> - if ( m_energy )
> - m_energy->load();
> + for (QMap<KCModule*, bool>::ConstIterator it = m_modules.begin(); it !=
> m_modules.end(); ++it) + it.key()->load();
> }
>
> void KCMDisplay::save()
> {
> - if ( m_randr )
> - m_randr->save();
> - if ( m_gamma )
> - m_gamma->save();
> - if ( m_xiner )
> - m_xiner->save();
> - if ( m_energy )
> - m_energy->save();
> + for (QMap<KCModule*, bool>::Iterator it = m_modules.begin(); it !=
> m_modules.end(); ++it) + if (it.data())
> + it.key()->save();
> +}
> +
> +void KCMDisplay::moduleChanged( bool isChanged )
> +{
> + QMap<KCModule*, bool>::Iterator currentModule =
> m_modules.find(static_cast<KCModule*>(const_cast<QObject*>(sender()))); +
> Q_ASSERT(currentModule != m_modules.end());
> + if (currentModule.data() == isChanged)
> + return;
> +
> + currentModule.data() = isChanged;
> +
> + bool c = false;
> +
> + for (QMap<KCModule*, bool>::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);
> + }
> }
>
>
> --- kdebase/kcontrol/display/display.h #1.7:1.8
> @@ -34,13 +34,13 @@ class KCMDisplay : public KCModule
> void save();
>
> - protected:
> - KCModule* addTab( const QString &name, const QString &label );
> + private slots:
> + void moduleChanged(bool isChanged);
>
> private:
> + void addTab( const QString &name, const QString &label );
> +
> QTabWidget *m_tabs;
> - KCModule *m_randr;
> - KCModule *m_gamma;
> - KCModule *m_xiner;
> - KCModule *m_energy;
> + QMap<KCModule*, bool> m_modules;
> + bool m_changed;
> };
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic