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.
181 lines
5.7 KiB
181 lines
5.7 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
*/
|
||
|
|
||
|
#include "ksettings/componentsdialog.h"
|
||
|
#include <klocale.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <klistview.h>
|
||
15 years ago
|
#include <tqlabel.h>
|
||
|
#include <tqheader.h>
|
||
15 years ago
|
#include <kplugininfo.h>
|
||
|
#include <kiconloader.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kconfig.h>
|
||
|
#include <kseparator.h>
|
||
|
|
||
|
namespace KSettings
|
||
|
{
|
||
|
|
||
|
class ComponentsDialog::ComponentsDialogPrivate
|
||
|
{
|
||
|
public:
|
||
|
KListView * listview;
|
||
15 years ago
|
TQFrame * infowidget;
|
||
|
TQLabel * iconwidget;
|
||
|
TQLabel * commentwidget;
|
||
|
TQLabel * descriptionwidget;
|
||
|
TQMap<TQCheckListItem*, KPluginInfo*> plugininfomap;
|
||
|
TQValueList<KPluginInfo*> plugininfolist;
|
||
15 years ago
|
};
|
||
|
|
||
15 years ago
|
ComponentsDialog::ComponentsDialog( TQWidget * parent, const char * name )
|
||
15 years ago
|
: KDialogBase( parent, name, false, i18n( "Select Components" ) )
|
||
|
, d( new ComponentsDialogPrivate )
|
||
|
{
|
||
15 years ago
|
TQWidget * page = new TQWidget( this );
|
||
15 years ago
|
setMainWidget( page );
|
||
15 years ago
|
( new TQHBoxLayout( page, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
|
||
15 years ago
|
d->listview = new KListView( page );
|
||
|
d->listview->setMinimumSize( 200, 200 );
|
||
15 years ago
|
d->infowidget = new TQFrame( page );
|
||
15 years ago
|
d->infowidget->setMinimumSize( 200, 200 );
|
||
15 years ago
|
( new TQVBoxLayout( d->infowidget, 0, KDialog::spacingHint() ) )->setAutoAdd( true );
|
||
|
d->iconwidget = new TQLabel( d->infowidget );
|
||
15 years ago
|
( void )new KSeparator( d->infowidget );
|
||
15 years ago
|
d->commentwidget = new TQLabel( d->infowidget );
|
||
13 years ago
|
d->commentwidget->setAlignment( TQt::WordBreak );
|
||
15 years ago
|
d->descriptionwidget = new TQLabel( d->infowidget );
|
||
13 years ago
|
d->descriptionwidget->setAlignment( TQt::WordBreak );
|
||
15 years ago
|
|
||
15 years ago
|
d->listview->addColumn( TQString::null );
|
||
15 years ago
|
d->listview->header()->hide();
|
||
|
d->listview->setRootIsDecorated( true );
|
||
|
d->listview->setSorting( -1 );
|
||
|
d->listview->setAcceptDrops( false );
|
||
|
d->listview->setSelectionModeExt( KListView::Single );
|
||
|
d->listview->setAllColumnsShowFocus( true );
|
||
|
|
||
15 years ago
|
connect( d->listview, TQT_SIGNAL( pressed( TQListViewItem * ) ), this,
|
||
|
TQT_SLOT( executed( TQListViewItem * ) ) );
|
||
|
connect( d->listview, TQT_SIGNAL( spacePressed( TQListViewItem * ) ), this,
|
||
|
TQT_SLOT( executed( TQListViewItem * ) ) );
|
||
|
connect( d->listview, TQT_SIGNAL( returnPressed( TQListViewItem * ) ), this,
|
||
|
TQT_SLOT( executed( TQListViewItem * ) ) );
|
||
|
connect( d->listview, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), this,
|
||
|
TQT_SLOT( executed( TQListViewItem * ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
ComponentsDialog::~ComponentsDialog()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void ComponentsDialog::addPluginInfo( KPluginInfo * info )
|
||
|
{
|
||
|
d->plugininfolist.append( info );
|
||
|
}
|
||
|
|
||
15 years ago
|
void ComponentsDialog::setPluginInfos( const TQMap<TQString, KPluginInfo*> &
|
||
15 years ago
|
plugininfos )
|
||
|
{
|
||
15 years ago
|
for( TQMap<TQString, KPluginInfo*>::ConstIterator it = plugininfos.begin();
|
||
15 years ago
|
it != plugininfos.end(); ++it )
|
||
|
{
|
||
|
d->plugininfolist.append( it.data() );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void ComponentsDialog::setPluginInfos( const TQValueList<KPluginInfo *> &plugins )
|
||
15 years ago
|
{
|
||
|
d->plugininfolist = plugins;
|
||
|
}
|
||
|
|
||
|
void ComponentsDialog::show()
|
||
|
{
|
||
|
// clear the treelist
|
||
|
d->listview->clear();
|
||
|
d->plugininfomap.clear();
|
||
|
|
||
|
// construct the treelist
|
||
15 years ago
|
for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
|
||
15 years ago
|
it != d->plugininfolist.end(); ++it )
|
||
|
{
|
||
|
( *it )->load();
|
||
15 years ago
|
TQCheckListItem * item = new TQCheckListItem( d->listview, ( *it )->name(),
|
||
|
TQCheckListItem::CheckBox );
|
||
15 years ago
|
if( ! ( *it )->icon().isEmpty() )
|
||
|
item->setPixmap( 0, SmallIcon( ( *it )->icon(), IconSize( KIcon::Small ) ) );
|
||
|
item->setOn( ( *it )->isPluginEnabled() );
|
||
|
d->plugininfomap[ item ] = ( *it );
|
||
|
}
|
||
|
KDialogBase::show();
|
||
|
}
|
||
|
|
||
15 years ago
|
void ComponentsDialog::executed( TQListViewItem * item )
|
||
15 years ago
|
{
|
||
|
kdDebug( 704 ) << k_funcinfo << endl;
|
||
|
if( item == 0 )
|
||
|
return;
|
||
|
if( item->rtti() != 1 ) // check for QCheckListItem
|
||
|
return;
|
||
|
|
||
15 years ago
|
TQCheckListItem * citem = static_cast<TQCheckListItem *>( item );
|
||
15 years ago
|
bool checked = citem->isOn();
|
||
|
|
||
|
kdDebug( 704 ) << "it's a " << ( checked ? "checked" : "unchecked" )
|
||
15 years ago
|
<< " TQCheckListItem" << endl;
|
||
15 years ago
|
|
||
|
KPluginInfo * info = d->plugininfomap[ citem ];
|
||
|
info->setPluginEnabled( checked );
|
||
|
//checkDependencies( info );
|
||
|
// show info about the component on the right
|
||
|
d->iconwidget->setPixmap( SmallIcon( info->icon(), KIcon::SizeLarge ) );
|
||
|
d->commentwidget->setText( info->comment() );
|
||
|
//d->descriptionwidget->setText( info->description() );
|
||
|
}
|
||
|
|
||
|
void ComponentsDialog::savePluginInfos()
|
||
|
{
|
||
15 years ago
|
for( TQValueList<KPluginInfo*>::ConstIterator it = d->plugininfolist.begin();
|
||
15 years ago
|
it != d->plugininfolist.end(); ++it )
|
||
|
{
|
||
|
if( ( *it )->config() )
|
||
|
{
|
||
|
( *it )->save();
|
||
|
( *it )->config()->sync();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ComponentsDialog::slotOk()
|
||
|
{
|
||
|
savePluginInfos();
|
||
|
KDialogBase::slotOk();
|
||
|
}
|
||
|
|
||
|
void ComponentsDialog::slotApply()
|
||
|
{
|
||
|
savePluginInfos();
|
||
|
KDialogBase::slotApply();
|
||
|
}
|
||
|
|
||
|
} //namespace
|
||
|
|
||
|
#include "componentsdialog.moc"
|
||
|
// vim: sw=4 sts=4 et
|