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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** TQt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
KbfxThemeInfo * KbfxConfigDlgThemes::_info_box = 0;
void KbfxConfigDlgThemes::init()
{
KbfxFormReady = FALSE;
img_nopreview = image0;
connect ( this, TQT_SIGNAL ( KbfxThemeDoInstall ( TQString & ) ),
this, TQT_SLOT ( KbfxThemeInstall ( TQString & ) ) );
}
/*
void KbfxConfigDlgThemes::KbfxDudeAnimationButtonToggled(bool)
{
if(KbfxAnimationButton->state() == 2)
{
KbfxAnimationButton->setText(tr2i18n("Animation is ON"));
KbfxAnimationButton->setPaletteBackgroundColor(TQColor(0,255,0));
ConfigInit().m_SpinxDudeBlink = TRUE;
}
if(KbfxAnimationButton->state() == 0)
{
KbfxAnimationButton->setText(tr2i18n("Animation is OFF"));
KbfxAnimationButton->setPaletteBackgroundColor(TQColor(221,223,228));
ConfigInit().m_SpinxDudeBlink = FALSE;
}
kdDebug() << "SpinxDudeBlink State is:"
<< ConfigInit().m_SpinxDudeBlink
<< endl;
}
*/
void KbfxConfigDlgThemes::KbfxURLRequesterThemesPathUrlSelected ( const TQString &path )
{
TQString tmppath = path;
if ( tmppath.startsWith ( "file://" ) ) tmppath.remove ( "file://" );
if ( !tmppath.endsWith ( "/" ) ) tmppath.append ( "/" );
TQDir d ( tmppath );
d.setFilter ( TQDir::Dirs );
if ( !d.exists() )
{
kdDebug() << "Themes folder does not exist: " << tmppath << endl;
KMessageBox::error ( 0,
tr2i18n ( "<p align='center'>Invalid user themes folder!</p>"
"<p align='center'>Will use default user themes folder.</p>" ),
tr2i18n ( "Error loading themes" ) );
tmppath = ConfigInit().m_UserSpinxThemeBasePathDefault;
}
KbfxURLRequesterThemesPath->setURL ( tmppath );
KbfxThemeList->clear();
KbfxThemeList->insertStringList ( KbfxThemesData().setThemeList ( tmppath ).keys() );
KbfxThemeList->setCurrentItem ( 0 );
ConfigInit().m_SpinxThemeName = KbfxThemeList->currentText();
ConfigInit().m_SpinxThemeBasePath = KbfxThemesData().setThemeList ( ConfigInit().m_UserSpinxThemeBasePath ) [ConfigInit().m_SpinxThemeName];
ConfigInit().m_UserSpinxThemeBasePath = tmppath;
setKbfxThemePreview();
}
void KbfxConfigDlgThemes::KbfxThemeSelected ( const TQString &name )
{
if (KbfxFormReady)
{
ConfigInit().m_SpinxThemeName = name;
ConfigInit().m_SpinxThemeBasePath = KbfxThemesData().setThemeList ( ConfigInit().m_UserSpinxThemeBasePath ) [ConfigInit().m_SpinxThemeName];
ConfigInit().readFontrc ( ConfigInit().m_SpinxThemeBasePath,
ConfigInit().m_SpinxThemeName );
ConfigInit().readThemerc ( ConfigInit().m_SpinxThemeBasePath,
ConfigInit().m_SpinxThemeName );
kdDebug() << "Selected theme: "
<< name
<< endl
<< "Base path: "
<< ConfigInit().m_SpinxThemeBasePath
<< endl;
setKbfxThemePreview();
}
}
void KbfxConfigDlgThemes::setKbfxThemePreview()
{
TQString path = ConfigInit().m_SpinxThemeBasePath + ConfigInit().m_SpinxThemeName + "/preview.png";
TQImage tmp ( path );
if ( tmp.isNull() )
{
kdDebug() << "No preview available for theme: "
<< ConfigInit().m_SpinxThemeBasePath + ConfigInit().m_SpinxThemeName
<< endl;
// TQString default_path = locate("data", "kbfx/images/nopreview.png");
KbfxPixmapPreview->setPixmap ( img_nopreview );
}
else
{
KbfxPixmapPreview->setPixmap ( path );
}
}
void KbfxConfigDlgThemes::ChangeForm()
{
KbfxFormReady = FALSE;
KbfxURLRequesterThemesPath->setURL ( ConfigInit().m_UserSpinxThemeBasePath );
KbfxThemeList->clear();
KbfxThemeList->insertStringList ( KbfxThemesData().setThemeList ( ConfigInit().m_UserSpinxThemeBasePath ).keys() );
kdDebug() << "Theme path: "
<< KbfxThemesData().setThemeList ( ConfigInit().m_UserSpinxThemeBasePath ) [ConfigInit().m_SpinxThemeName]
<< endl;
KbfxThemeList->setSelected ( KbfxThemeList->findItem ( ConfigInit().m_SpinxThemeName ), TRUE );
setKbfxThemePreview();
KbfxDudeImage->setPixmap ( ConfigInit().m_SpinxDudeImage );
kdDebug() << "Dude image: "
<< ConfigInit().m_SpinxDudeImage
<< endl
<< "Default dude image: "
<< ConfigInit().m_SpinxDudeImageDefault
<< endl;
KbfxFormReady = TRUE;
KbfxShowOldThemes->setChecked ( ConfigInit().m_KbfxShowOldThemes );
KbfxWatch->setChecked ( ConfigInit().m_KbfxWatcher );
/*
if(ConfigInit().m_SpinxDudeBlink == TRUE && KbfxAnimationButton->state() == 0)
KbfxAnimationButton->toggle();
if(ConfigInit().m_SpinxDudeBlink == FALSE && KbfxAnimationButton->state() == 2)
KbfxAnimationButton->toggle();
*/
}
void KbfxConfigDlgThemes::KbfxDeleteThemeClicked()
{
int messageBoxReturn;
int messageBoxUserResReturn;
TQString KbfxThemeRcDestination = KGlobal::dirs()->saveLocation ( "data", TQString ( "kbfx/themerc/" ), TRUE );
KbfxThemeRcDestination.append( ConfigInit().m_SpinxThemeName );
messageBoxReturn = KMessageBox::warningContinueCancel ( 0,
tr2i18n ( "<p align='center'>Are you sure you want to uninstall the KBFX theme <strong>%1</strong>?</p>" ).arg ( ConfigInit().m_SpinxThemeName ),
tr2i18n ( "Uninstall KBFX theme" ),
tr2i18n ( "Uninstall" ) );
if ( messageBoxReturn == KMessageBox::Cancel ) return;
messageBoxUserResReturn = KMessageBox::questionYesNo ( 0,
tr2i18n ( "<p align='center'>Do you want to keep your personal settings for theme <strong>%1</strong>?</p>" ).arg ( ConfigInit().m_SpinxThemeName ),
tr2i18n ( "Personal settings" ),
tr2i18n ( "Keep settings" ),
tr2i18n ( "Delete settings" ) );
if ( messageBoxUserResReturn == KMessageBox::No )
{
if ( TQFile::exists ( KbfxThemeRcDestination + "_fontrc" ) )
{
TQFile::remove ( KbfxThemeRcDestination + "_fontrc" );
kdDebug() << "Deleting user's fontrc file: "
<< KbfxThemeRcDestination + "_fontrc"
<< endl;
}
if ( TQFile::exists ( KbfxThemeRcDestination + "_layoutrc" ) )
{
TQFile::remove ( KbfxThemeRcDestination + "_layoutrc" );
kdDebug() << "Deleting user's layoutrc file: "
<< KbfxThemeRcDestination + "_layoutrc"
<< endl;
}
}
kdDebug() << "Deleting theme: "
<< ConfigInit().m_SpinxThemeName
<< " - "
<< ConfigInit().m_SpinxThemeBasePath + ConfigInit().m_SpinxThemeName
<< endl;
if ( !KIO::NetAccess::del ( ConfigInit().m_SpinxThemeBasePath+ConfigInit().m_SpinxThemeName, 0 ) )
{
KMessageBox::sorry ( 0,
tr2i18n ( "<p align='center'>Could not uninstall this KBFX theme.</p>"
"<p align='center'>You may not have sufficient permissions to delete "
"the folder <strong>%1<strong>.</p>" ).arg ( ConfigInit().m_SpinxThemeBasePath + ConfigInit().m_SpinxThemeName ) );
return;
}
ChangeForm();
}
void KbfxConfigDlgThemes::KbfxInstallThemeClicked()
{
KFileDialog KbfxInstallDialog ( TQString(),
"*.tar *.tar.bz2 *.tar.gz *.kbfxtheme|" + tr2i18n ( "KBFX theme packages (*.tar, *.tar.bz2, *.tar.gz, *.kbfxtheme)" ),
0,
0,
TRUE );
KbfxInstallDialog.setCaption ( tr2i18n ( "Select KBFX theme package to install" ) );
KbfxInstallDialog.setMode ( KFile::File | KFile::ExistingOnly );
if ( !KbfxInstallDialog.exec() ) return;
KbfxInstallDialogURL = KbfxInstallDialog.selectedURL().path();
emit KbfxThemeDoInstall ( KbfxInstallDialogURL );
}
void KbfxConfigDlgThemes::KbfxThemeInstall ( TQString &installUrl )
{
KTar KbfxThemeArchive ( installUrl );
if ( !KbfxThemeArchive.open ( IO_ReadOnly ) )
{
KMessageBox::sorry ( 0, tr2i18n ( "<p align='center'>Could not read this KBFX theme package.</p>" ) );
kdDebug() << "Error reading archive: " << installUrl << endl;
return;
}
const TQString KbfxThemeDestination = KGlobal::dirs()->saveLocation ( "data",
TQString ( "kbfx/skins/" ),
TRUE );
kdDebug() << "Copying theme: " << KbfxThemeDestination << endl;
const KArchiveDirectory *KbfxThemeArchiveDir = KbfxThemeArchive.directory();
KbfxThemeArchiveDir->copyTo ( KbfxThemeDestination, TRUE );
ChangeForm();
}
void KbfxConfigDlgThemes::KbfxSelectDudeImageClicked()
{
KFileDialog KbfxDudeImageDialog ( TQString(),
"image/jpeg image/png image/x-xpm image/gif ",
0,
0,
TRUE );
KbfxDudeImageDialog.setCaption ( tr2i18n ( "Select personal image" ) );
KbfxDudeImageDialog.setMode ( KFile::File | KFile::ExistingOnly );
if ( !KbfxDudeImageDialog.exec() ) return;
ConfigInit().m_SpinxDudeImage = KbfxDudeImageDialog.selectedURL().path();
TQImage tmp ( ConfigInit().m_SpinxDudeImage );
if ( tmp.isNull() )
{
KMessageBox::error ( 0,
tr2i18n ( "<p align='center'>Image cannot be used as a personal image!</p>"
"<p align='center'>Will use default personal image.</p>" ),
tr2i18n ( "Error loading image" ) );
ConfigInit().m_SpinxDudeImage=ConfigInit().m_SpinxDudeImageDefault;
}
KbfxDudeImage->setPixmap ( ConfigInit().m_SpinxDudeImage );
kdDebug() << "Dude image changed: "
<< ConfigInit().m_SpinxDudeImage
<< endl;
}
void KbfxConfigDlgThemes::KbfxDeleteDudeImageClicked()
{
TQString tmp_dude = ConfigInit().m_SpinxThemeBasePath + ConfigInit().m_SpinxThemeName + "/menu_top_image_person.png";
TQFile tmp ( tmp_dude );
if ( tmp.exists() )
{
ConfigInit().m_SpinxDudeImage = tmp_dude;
}
else
{
ConfigInit().m_SpinxDudeImage = locate ( "data","kbfx/skins/default/menu_top_image_person.png" );
}
KbfxDudeImage->setPixmap ( ConfigInit().m_SpinxDudeImage );
}
void KbfxConfigDlgThemes::KbfxThemeInfoClicked()
{
TQPixmap _logo = TQPixmap (ConfigInit ().m_SpinxThemeBasePath + ConfigInit ().m_SpinxThemeName + "/logo.png");
ConfigInit().readThemeInfo ( ConfigInit().m_SpinxThemeBasePath, ConfigInit().m_SpinxThemeName );
_info_box = new KbfxThemeInfo (this,"infodlg",(WType_Dialog|WShowModal));
if ( !_logo.isNull() )
{
_info_box->KbfxThemeLogo->setPixmap( _logo );
}
else
{
_info_box->KbfxThemeLogo->hide();
_info_box->hideSpacer();
}
_info_box->KbfxThemeName->setText( ConfigInit().m_SpinxThemeName );
_info_box->KbfxThemeVersion->setText( ConfigInit().m_InfoVersion );
_info_box->KbfxAuthorName->setText( ConfigInit().m_InfoAuthor );
if ( ConfigInit().m_InfoEmail == ConfigInit().m_InfoEmailDefault )
{
_info_box->KbfxAuthorEmail->setText( ConfigInit().m_InfoEmail );
}
else
{
_info_box->KbfxAuthorEmail->setText( "<a href='mailto:" + ConfigInit().m_InfoEmail + "'>" + ConfigInit().m_InfoEmail + "</a>" );
}
if ( ConfigInit().m_InfoUrl == ConfigInit().m_InfoUrlDefault )
{
_info_box->KbfxThemeHomepage->setText( ConfigInit().m_InfoUrl );
}
else
{
_info_box->KbfxThemeHomepage->setText( "<a href='" + ConfigInit().m_InfoUrl + "'>" + ConfigInit().m_InfoUrl + "</a>" );
}
_info_box->show();
_info_box->update();
}
void KbfxConfigDlgThemes::KbfxShowOldThemes_toggled( bool state )
{
ConfigInit().m_KbfxShowOldThemes = state;
kdDebug() << "Show Old Themes is: " << ConfigInit().m_KbfxShowOldThemes << endl;
ChangeForm();
}
void KbfxConfigDlgThemes::KbfxWatch_toggled( bool state )
{
ConfigInit().m_KbfxWatcher = state;
kdDebug() << "Watch for Installs is: " << ConfigInit().m_KbfxWatcher << endl;
}
|