1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/***************************************************************************
* Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> *
* Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License (version 2) as *
* published by the Free Software Foundation. (The original KSplash/ML *
* codebase (upto version 0.95.3) is BSD-licensed.) *
* *
***************************************************************************/
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <tqcolor.h>
#include <tqcursor.h>
#include <tqdesktopwidget.h>
#include <tqfont.h>
#include <tqpixmap.h>
#include <tqrect.h>
#include <tqstring.h>
#include "objkstheme.h"
#include "objkstheme.moc"
ObjKsTheme::ObjKsTheme( const TQString& theme )
:mActiveTheme (theme), mThemeDir("/"), mThemeConfig (0L), mThemePrefix( "Themes/" ), d(0)
{
// Get Xinerama config.
KConfig *config = kapp->config();
config->setGroup( "Xinerama" );
TQDesktopWidget *desktop = kapp->desktop();
mXineramaScreen = config->readNumEntry("KSplashScreen", desktop->primaryScreen());
// For Xinerama, let's put the mouse on the first head. Otherwise it could appear anywhere!
if (desktop->isVirtualDesktop() && mXineramaScreen != -2)
{
TQRect rect = desktop->screenGeometry( mXineramaScreen );
if (!rect.contains(TQCursor::pos()))
TQCursor::setPos(rect.center());
}
// Does the active theme exist?
if( !loadThemeRc( mActiveTheme, false ) )
if( !loadLocalConfig( mActiveTheme, false ) )
if( !loadThemeRc( "Default", false ) )
loadLocalConfig( "Default", true ); //force: we need some defaults
loadCmdLineArgs(KCmdLineArgs::parsedArgs());
mThemePrefix += ( mActiveTheme + "/" );
}
ObjKsTheme::~ObjKsTheme()
{
}
bool ObjKsTheme::loadThemeRc( const TQString& activeTheme, bool force )
{
//kdDebug() << "ObjKsTheme::loadThemeRc: " << activeTheme << endl;
TQString prefix("Themes/");
TQString themeFile;
KConfig *cf = 0L;
// Try our best to find a theme file.
themeFile = locate( "appdata", prefix + activeTheme + "/" + TQString("Theme.rc") );
themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+TQString("Theme.RC")):themeFile;
themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+TQString("theme.rc")):themeFile;
themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+activeTheme+TQString(".rc")):themeFile;
if( !themeFile.isEmpty() )
cf = new KConfig( themeFile );
if( cf )
{
mActiveTheme = activeTheme;
mThemeDir = prefix + activeTheme+"/";
if( loadKConfig( cf, activeTheme, force ) )
{
mThemeConfig = cf;
return true;
}
else
delete cf;
}
return false;
}
bool ObjKsTheme::loadLocalConfig( const TQString& activeTheme, bool force )
{
//kdDebug() << "ObjKsTheme::loadLocalConfig" << endl;
KConfig *cfg = kapp->config();
return( loadKConfig( cfg, activeTheme, force ) );
}
// ObjKsConfig::loadKConfig(): Load our settings from a KConfig object.
bool ObjKsTheme::loadKConfig( KConfig *cfg, const TQString& activeTheme, bool force )
{
//kdDebug() << "ObjKsTheme::loadKConfig" << endl;
if( !cfg )
return false;
// Themes are always stored in the group [KSplash Theme: ThemeName],
// and ThemeName should always be the same name as the themedir, if any.
// If we can't find this theme group, then we can't load.
if( !cfg->hasGroup( TQString("KSplash Theme: %1").arg(activeTheme) ) && !force )
return false;
cfg->setGroup( TQString("KSplash Theme: %1").arg(activeTheme) );
mThemeConfig = cfg;
mThemeEngine = cfg->readEntry( "Engine", "Default" );
m_icons.clear();
m_icons.append( cfg->readEntry( "Icon1", "filetypes" ) );
m_icons.append( cfg->readEntry( "Icon2", "exec" ) );
m_icons.append( cfg->readEntry( "Icon3", "key_bindings" ) );
m_icons.append( cfg->readEntry( "Icon4", "window_list" ) );
m_icons.append( cfg->readEntry( "Icon5", "desktop" ) );
m_icons.append( cfg->readEntry( "Icon6", "style" ) );
m_icons.append( cfg->readEntry( "Icon7", "kcmsystem" ) );
m_icons.append( cfg->readEntry( "Icon8", "go" ) );
m_text.clear();
m_text.append( cfg->readEntry( "Message1", i18n("Setting up interprocess communication") ) );
m_text.append( cfg->readEntry( "Message2", i18n("Initializing system services") ) );
m_text.append( cfg->readEntry( "Message3", i18n("Initializing peripherals") ) );
m_text.append( cfg->readEntry( "Message4", i18n("Loading the window manager") ) );
m_text.append( cfg->readEntry( "Message5", i18n("Loading the desktop") ) );
m_text.append( cfg->readEntry( "Message6", i18n("Loading the panel") ) );
m_text.append( cfg->readEntry( "Message7", i18n("Restoring session") ) );
m_text.append( cfg->readEntry( "Message8", i18n("Trinity is up and running") ) );
return true;
}
/*
* ObjKsTheme::loadCmdLineArgs(): Handle any overrides which the user might have
* specified.
*/
void ObjKsTheme::loadCmdLineArgs( KCmdLineArgs *args )
{
mManagedMode = args->isSet( "managed" );
mTesting = args->isSet("test");
mLoColor = ( TQPixmap::defaultDepth() <= 8 );
TQString theme = args->getOption( "theme" );
if( theme != mActiveTheme && !theme.isNull() )
if( loadThemeRc( theme, false ) )
mActiveTheme = theme;
//args->clear();
}
TQString ObjKsTheme::locateThemeData( const TQString &resource )
{
if ( !mLoColor )
return locate( "appdata", mThemePrefix+resource );
else
{
TQString res = locate( "appdata", mThemePrefix+"locolor/"+resource );
if ( res.isEmpty() )
res = locate( "appdata", mThemePrefix+resource );
return res;
}
}
|