• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeui
 

kdeui

  • kdeui
kcmodule.cpp
1 /*
2  This file is part of the KDE libraries
3 
4 <<<Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
5  Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 
22 */
23 
24 #include <tqlayout.h>
25 
26 #include <kaboutdata.h>
27 #include <kconfigskeleton.h>
28 #include <kconfigdialogmanager.h>
29 #include <kdebug.h>
30 #include <kglobal.h>
31 #include <kinstance.h>
32 #include <klocale.h>
33 
34 #include "kcmodule.h"
35 #include "kcmodule.moc"
36 
37 class KCModulePrivate
38 {
39 public:
40  KCModulePrivate():
41  _about( 0 ),
42  _useRootOnlyMsg( false ),
43  _hasOwnInstance( true ),
44  _unmanagedWidgetChangeState( false )
45  { }
46 
47  KInstance *_instance;
48  KAboutData *_about;
49  TQString _rootOnlyMsg;
50  bool _useRootOnlyMsg;
51  bool _hasOwnInstance;
52  TQPtrList<KConfigDialogManager> managers;
53  TQString _quickHelp;
54 
55  // this member is used to record the state on non-automatically
56  // managed widgets, allowing for mixed KConfigXT-drive and manual
57  // widgets to coexist peacefully and do the correct thing with
58  // the changed(bool) signal
59  bool _unmanagedWidgetChangeState;
60 };
61 
62 KCModule::KCModule(TQWidget *parent, const char *name, const TQStringList &)
63  : TQWidget(parent, name)
64 {
65  init();
66  if (name && strlen(name)) {
67  d->_instance = new KInstance(name);
68  KGlobal::locale()->insertCatalogue(name);
69  } else
70  d->_instance = new KInstance("kcmunnamed");
71  KGlobal::setActiveInstance(this->instance());
72 
73  d->managers.setAutoDelete( true );
74 
75 }
76 
77 KCModule::KCModule(KInstance *instance, TQWidget *parent, const TQStringList & )
78  : TQWidget(parent, instance ? instance->instanceName().data() : 0)
79 {
80  init();
81  d->_instance = instance;
82 
83  if (instance)
84  {
85  KGlobal::locale()->insertCatalogue(instance->instanceName());
86  }
87 
88  d->_hasOwnInstance = false;
89  KGlobal::setActiveInstance(this->instance());
90 }
91 
92 void KCModule::init()
93 {
94  d = new KCModulePrivate;
95  _btn = Help|Default|Apply;
96 }
97 
98 KConfigDialogManager* KCModule::addConfig( KConfigSkeleton *config, TQWidget* widget )
99 {
100  KConfigDialogManager* manager = new KConfigDialogManager( widget, config, name() );
101  connect( manager, TQT_SIGNAL( widgetModified() ), TQT_SLOT( widgetChanged() ));
102  d->managers.append( manager );
103  return manager;
104 }
105 
106 KCModule::~KCModule()
107 {
108  if (d->_hasOwnInstance)
109  delete d->_instance;
110  delete d->_about;
111  delete d;
112 }
113 
114 void KCModule::load()
115 {
116  KConfigDialogManager* manager;
117  for( manager = d->managers.first(); manager; manager = d->managers.next() )
118  manager->updateWidgets();
119 }
120 
121 void KCModule::save()
122 {
123  KConfigDialogManager* manager;
124  for( manager = d->managers.first(); manager; manager = d->managers.next() )
125  manager->updateSettings();
126  emit( changed( false ));
127 }
128 
129 void KCModule::defaults()
130 {
131  KConfigDialogManager* manager;
132  for( manager = d->managers.first(); manager; manager = d->managers.next() )
133  manager->updateWidgetsDefault();
134 }
135 
136 void KCModule::widgetChanged()
137 {
138  emit changed(d->_unmanagedWidgetChangeState || managedWidgetChangeState());
139 }
140 
141 bool KCModule::managedWidgetChangeState() const
142 {
143  KConfigDialogManager* manager;
144  for( manager = d->managers.first(); manager; manager = d->managers.next() )
145  {
146  if ( manager->hasChanged() )
147  return true;
148  }
149 
150  return false;
151 }
152 
153 void KCModule::unmanagedWidgetChangeState(bool changed)
154 {
155  d->_unmanagedWidgetChangeState = changed;
156  widgetChanged();
157 }
158 
159 const KAboutData *KCModule::aboutData() const
160 {
161  return d->_about;
162 }
163 
164 void KCModule::setAboutData( KAboutData* about )
165 {
166  delete d->_about;
167  d->_about = about;
168 }
169 
170 void KCModule::setRootOnlyMsg(const TQString& msg)
171 {
172  d->_rootOnlyMsg = msg;
173 }
174 
175 TQString KCModule::rootOnlyMsg() const
176 {
177  return d->_rootOnlyMsg;
178 }
179 
180 void KCModule::setUseRootOnlyMsg(bool on)
181 {
182  d->_useRootOnlyMsg = on;
183 }
184 
185 bool KCModule::useRootOnlyMsg() const
186 {
187  return d->_useRootOnlyMsg;
188 }
189 
190 void KCModule::changed()
191 {
192  emit changed(true);
193 }
194 
195 KInstance *KCModule::instance() const
196 {
197  return d->_instance;
198 }
199 
200 void KCModule::setQuickHelp( const TQString& help )
201 {
202  d->_quickHelp = help;
203  emit( quickHelpChanged() );
204 }
205 
206 TQString KCModule::quickHelp() const
207 {
208  return d->_quickHelp;
209 }
210 
211 
212 const TQPtrList<KConfigDialogManager>& KCModule::configs() const
213 {
214  return d->managers;
215 }
216 
217 void KCModule::virtual_hook( int, void* )
218 { /*BASE::virtual_hook( id, data );*/ }
219 
220 // vim: sw=4 et sts=4
KConfigDialogManager::updateWidgetsDefault
void updateWidgetsDefault()
KGlobal::locale
static KLocale * locale()
KConfigDialogManager::updateWidgets
void updateWidgets()
KCModule::setUseRootOnlyMsg
void setUseRootOnlyMsg(bool on)
Change whether or not the RootOnly message should be shown.
Definition: kcmodule.cpp:180
KCModule::unmanagedWidgetChangeState
void unmanagedWidgetChangeState(bool)
Call this method when your manually managed widgets change state between changed and not changed...
Definition: kcmodule.cpp:153
KCModule::load
virtual void load()
Load the configuration data into the module.
Definition: kcmodule.cpp:114
KGlobal::setActiveInstance
static void setActiveInstance(KInstance *d)
KConfigDialogManager
klocale.h
KConfigSkeleton
KCModule::useRootOnlyMsg
bool useRootOnlyMsg() const
Tell if KControl should show a RootOnly message when run as a normal user.
Definition: kcmodule.cpp:185
KCModule::widgetChanged
void widgetChanged()
A managed widget was changed, the widget settings and the current settings are compared and a corresp...
Definition: kcmodule.cpp:136
KCModule::configs
const TQPtrList< KConfigDialogManager > & configs() const
Definition: kcmodule.cpp:212
KConfigDialogManager::hasChanged
bool hasChanged()
KInstance::instanceName
TQCString instanceName() const
KCModule::setAboutData
void setAboutData(KAboutData *about)
This sets the KAboutData returned by aboutData()
Definition: kcmodule.cpp:164
KCModule::setQuickHelp
void setQuickHelp(const TQString &help)
Sets the quick help.
Definition: kcmodule.cpp:200
KLocale::insertCatalogue
void insertCatalogue(const TQString &catalog)
KInstance
KCModule::setRootOnlyMsg
void setRootOnlyMsg(const TQString &msg)
Sets the RootOnly message.
Definition: kcmodule.cpp:170
KAboutData
KCModule::addConfig
KConfigDialogManager * addConfig(KConfigSkeleton *config, TQWidget *widget)
Adds a KConfigskeleton config to watch the widget widget.
Definition: kcmodule.cpp:98
KCModule::managedWidgetChangeState
bool managedWidgetChangeState() const
Returns the changed state of automatically managed widgets in this dialog.
Definition: kcmodule.cpp:141
KCModule::aboutData
virtual const KAboutData * aboutData() const
This is generally only called for the KBugReport.
Definition: kcmodule.cpp:159
KCModule::rootOnlyMsg
TQString rootOnlyMsg() const
Get the RootOnly message for this module.
Definition: kcmodule.cpp:175
KCModule::quickHelp
virtual TQString quickHelp() const
Return a quick-help text.
Definition: kcmodule.cpp:206
KCModule::defaults
virtual void defaults()
Sets the configuration to sensible default values.
Definition: kcmodule.cpp:129
KNotifyClient::instance
KInstance * instance()
KConfigDialogManager::updateSettings
void updateSettings()
KCModule::save
virtual void save()
Save the configuration data.
Definition: kcmodule.cpp:121
KCModule::changed
void changed()
Calling this slot is equivalent to emitting changed(true).
Definition: kcmodule.cpp:190

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeui

Skip menu "kdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeui by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |