18 #include "kinstance.h" 25 #include "kcharsets.h" 26 #include "kiconloader.h" 27 #include "kaboutdata.h" 28 #include "kstandarddirs.h" 31 #include "kmimesourcefactory.h" 38 #include <tqptrdict.h> 39 static TQPtrList<KInstance> *allInstances = 0;
40 static TQPtrDict<TQCString> *allOldInstances = 0;
41 #define DEBUG_ADD do { if (!allInstances) { allInstances = new TQPtrList<KInstance>(); allOldInstances = new TQPtrDict<TQCString>(); } allInstances->append(this); allOldInstances->insert( this, new TQCString( _name)); } while (false); 42 #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false); 43 #define DEBUG_CHECK_ALIVE do { if (!allInstances->contains((KInstance*)this)) { TQCString *old = allOldInstances->find((KInstance*)this); qWarning("ACCESSING DELETED KINSTANCE! (%s)", old ? old->data() : "<unknown>"); assert(false); } } while (false); 47 #define DEBUG_CHECK_ALIVE 50 class KInstancePrivate
55 mimeSourceFactory = 0L;
60 delete mimeSourceFactory;
73 _name( name ), _aboutData( new
KAboutData( name,
"", 0 ) )
76 Q_ASSERT(!name.isEmpty());
77 if (!KGlobal::_instance)
79 KGlobal::_instance =
this;
83 d =
new KInstancePrivate ();
84 d->ownAboutdata =
true;
91 _name( aboutData->appName() ), _aboutData( aboutData )
94 Q_ASSERT(!_name.isEmpty());
96 if (!KGlobal::_instance)
98 KGlobal::_instance =
this;
102 d =
new KInstancePrivate ();
103 d->ownAboutdata =
false;
107 : _dirs ( src->_dirs ),
108 _config ( src->_config ),
109 _iconLoader ( src->_iconLoader ),
110 _name( src->_name ), _aboutData( src->_aboutData )
113 Q_ASSERT(!_name.isEmpty());
115 if (!KGlobal::_instance || KGlobal::_instance == src )
117 KGlobal::_instance =
this;
121 d =
new KInstancePrivate ();
122 d->ownAboutdata = src->d->ownAboutdata;
123 d->sharedConfig = src->d->sharedConfig;
127 src->_iconLoader = 0L;
128 src->_aboutData = 0L;
151 if (KGlobal::_instance ==
this)
152 KGlobal::_instance = 0;
153 if (KGlobal::activeInstance() ==
this)
174 extern bool kde_kiosk_exception;
175 extern bool kde_kiosk_admin;
181 if ( !d->configName.isEmpty() )
186 d->sharedConfig->setGroup(
"KDE Action Restrictions" );
187 TQString kioskException = d->sharedConfig->readEntry(
"kiosk_exception");
188 if (d->sharedConfig->readBoolEntry(
"custom_config",
true))
190 d->sharedConfig->setGroup(TQString::null);
199 if ( d->sharedConfig == 0 )
201 if ( !_name.isEmpty() )
208 if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv(
"KDE_KIOSK_NO_RESTRICTIONS")).isEmpty())
210 kde_kiosk_exception =
true;
215 _config = d->sharedConfig;
230 return d->sharedConfig;
236 d->configName = configName;
242 if( _iconLoader == 0 ) {
272 if (!d->mimeSourceFactory)
275 d->mimeSourceFactory->setInstance(const_cast<KInstance *>(
this));
278 return d->mimeSourceFactory;
281 void KInstance::virtual_hook(
int,
void* )
static void reconfigure()
Reconfigure the theme.
Can be used to control the lifetime of an object that has derived KShared.
void reconfigure(const TQString &_appname, KStandardDirs *_dirs)
Called by KInstance::newIconLoader to reconfigure the icon loader.
KConfig variant using shared memory.
void newIconLoader() const
Re-allocate the global iconloader.
virtual ~KInstance()
Destructor.
static void setActiveInstance(KInstance *d)
The instance currently active (useful in a multi-instance application, such as a KParts application)...
KConfig * config() const
Returns the general config object ("appnamerc").
const KAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
KInstance(const TQCString &instanceName)
Constructor.
TQCString instanceName() const
Returns the name of the instance.
KIconLoader * iconLoader() const
Returns an iconloader object.
Site-independent access to standard KDE directories.
void enableDelayedIconSetLoading(bool enable)
Enables on-demand icon loading for QIconSets using TQIconFactory.
Access to KDE global objects for use in shared libraries.
This class is used to store information about a program.
void setConfigName(const TQString &name)
Set name of default config file.
Access KDE Configuration entries.
virtual void reparseConfiguration()
Clears all internal data structures and then reread configuration information from disk...
KStandardDirs * dirs() const
Returns the application standard dirs object.
KSharedConfig * sharedConfig() const
Returns the general config object ("appnamerc").
bool addCustomized(KConfig *config)
Reads customized entries out of the given config object and add them via addResourceDirs().
An extension to TQMimeSourceFactory that uses KIconLoader to find images.
static KSharedConfig::Ptr openConfig(const TQString &fileName, bool readOnly=false, bool bUseKDEGlobals=true)
Returns a ref-counted pointer to a shared read-write config object.
KMimeSourceFactory * mimeSourceFactory() const
Returns the KMimeSourceFactory of the instance.