You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.2 KiB
123 lines
3.2 KiB
/*
|
|
Copyright (c) 1999-2000 Stefan Schimanski <1Stein@gmx.de>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <klocale.h>
|
|
#include <tqlayout.h>
|
|
#include <tqlabel.h>
|
|
#include <klistbox.h>
|
|
#include <tqdir.h>
|
|
#include <tqfileinfo.h>
|
|
#include <kglobal.h>
|
|
#include <kdebug.h>
|
|
#include <kstandarddirs.h>
|
|
#include <kconfig.h>
|
|
|
|
#include "pref.h"
|
|
#include "userinterface.h"
|
|
|
|
|
|
KaimanPrefDlg::KaimanPrefDlg(TQObject *parent )
|
|
: CModule(i18n("Kaiman Skins"), i18n("Skin Selection for the Kaiman Plugin"), "style", parent)
|
|
{
|
|
// create widgets
|
|
TQVBoxLayout *topLayout = new TQVBoxLayout( this, 6, 11 );
|
|
TQLabel *label = new TQLabel( i18n("Kaiman Skins"), this, "label" );
|
|
topLayout->addWidget( label );
|
|
|
|
_skinList = new KListBox( this, "skinList" );
|
|
topLayout->addWidget( _skinList, 1 );
|
|
reopen();
|
|
}
|
|
|
|
|
|
KaimanPrefDlg::~KaimanPrefDlg()
|
|
{
|
|
}
|
|
|
|
|
|
void KaimanPrefDlg::save()
|
|
{
|
|
KConfig *config=KGlobal::config();
|
|
config->setGroup("Kaiman");
|
|
config->writeEntry("SkinResource", skin() );
|
|
config->sync();
|
|
|
|
Kaiman *l=Kaiman::kaiman;
|
|
if ( l ) {
|
|
l->changeStyle( skin() );
|
|
}
|
|
}
|
|
|
|
void KaimanPrefDlg::reopen()
|
|
{
|
|
_skinList->clear();
|
|
// fill with available skins
|
|
KGlobal::dirs()->addResourceType("skins", KStandardDirs::kde_default("data") + "noatun/skins/kaiman/");
|
|
TQStringList list = KGlobal::dirs()->resourceDirs("skins");
|
|
for (TQStringList::ConstIterator it = list.begin(); it != list.end(); it++)
|
|
readSkinDir(*it);
|
|
|
|
// load current config
|
|
KConfig *config=KGlobal::config();
|
|
config->setGroup("Kaiman");
|
|
TQString skin = config->readEntry( "SkinResource", Kaiman::DEFAULT_SKIN );
|
|
TQListBoxItem *item = _skinList->findItem( skin );
|
|
if ( item )
|
|
_skinList->setCurrentItem( item );
|
|
else
|
|
_skinList->setCurrentItem( 0 );
|
|
}
|
|
|
|
|
|
void KaimanPrefDlg::setSkin( TQString skin )
|
|
{
|
|
_skinList->setCurrentItem( _skinList->findItem( skin ) );
|
|
}
|
|
|
|
|
|
TQString KaimanPrefDlg::skin()
|
|
{
|
|
return _skinList->currentText();
|
|
}
|
|
|
|
|
|
void KaimanPrefDlg::readSkinDir( const TQString &dir )
|
|
{
|
|
kdDebug() << "readSkinDir " << dir << endl;
|
|
|
|
TQDir directory( dir );
|
|
if (!directory.exists())
|
|
return;
|
|
|
|
const TQFileInfoList *list = directory.entryInfoList();
|
|
TQFileInfoListIterator it(*list);
|
|
|
|
while ( it.current() ) {
|
|
kdDebug() << it.current()->absFilePath() << endl;
|
|
TQFileInfo skindata( it.current()->absFilePath()+"/skindata" );
|
|
|
|
if ( skindata.exists() ) {
|
|
_skinList->insertItem( it.current()->baseName() );
|
|
}
|
|
|
|
++it;
|
|
}
|
|
}
|
|
|
|
#include "pref.moc"
|