• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tderesources
 

tderesources

configdialog.cpp
00001 /*
00002     This file is part of libtderesources.
00003 
00004     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
00005     Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
00006     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021     Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include <tdelocale.h>
00025 #include <klineedit.h>
00026 #include <tdemessagebox.h>
00027 
00028 #include <tqgroupbox.h>
00029 #include <tqlabel.h>
00030 #include <tqlayout.h>
00031 #include <tqcheckbox.h>
00032 
00033 #include "factory.h"
00034 #include "configdialog.h"
00035 
00036 using namespace KRES;
00037 
00038 ConfigDialog::ConfigDialog( TQWidget *parent, const TQString& resourceFamily,
00039     /*const TQString& type,*/ Resource* resource, /*TDEConfig *config, */const char *name )
00040   : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
00041     Ok|Cancel, Ok, false )/*, mConfig( config )*/, mResource( resource )
00042 {
00043   Factory *factory = Factory::self( resourceFamily );
00044 
00045   TQFrame *main = makeMainWidget();
00046 
00047   TQVBoxLayout *mainLayout = new TQVBoxLayout( main, 0, spacingHint() );
00048 
00049   TQGroupBox *generalGroupBox = new TQGroupBox( 2, Qt::Horizontal, main );
00050   generalGroupBox->layout()->setSpacing( spacingHint() );
00051   generalGroupBox->setTitle( i18n( "General Settings" ) );
00052 
00053   new TQLabel( i18n( "Name:" ), generalGroupBox );
00054 
00055   mName = new KLineEdit( generalGroupBox );
00056 
00057   mReadOnly = new TQCheckBox( i18n( "Read-only" ), generalGroupBox );
00058 
00059   mName->setText( mResource->resourceName() );
00060   mReadOnly->setChecked( mResource->readOnly() );
00061 
00062   mainLayout->addWidget( generalGroupBox );
00063 
00064   TQGroupBox *resourceGroupBox = new TQGroupBox( 2, Qt::Horizontal,  main );
00065   resourceGroupBox->layout()->setSpacing( spacingHint() );
00066   resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
00067                               .arg( factory->typeName( resource->type() ) ) );
00068   mainLayout->addWidget( resourceGroupBox );
00069 
00070   mainLayout->addStretch();
00071 
00072   mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
00073   if ( mConfigWidget ) {
00074     mConfigWidget->setInEditMode( false );
00075     mConfigWidget->loadSettings( mResource );
00076     mConfigWidget->show();
00077     connect( mConfigWidget, TQT_SIGNAL( setReadOnly( bool ) ),
00078         TQT_SLOT( setReadOnly( bool ) ) );
00079   }
00080 
00081   connect( mName, TQT_SIGNAL( textChanged(const TQString &)),
00082       TQT_SLOT( slotNameChanged(const TQString &)));
00083 
00084   slotNameChanged( mName->text() );
00085   setMinimumSize( sizeHint() );
00086 }
00087 
00088 void ConfigDialog::setInEditMode( bool value )
00089 {
00090   if ( mConfigWidget )
00091     mConfigWidget->setInEditMode( value );
00092 }
00093 
00094 void ConfigDialog::slotNameChanged( const TQString &text)
00095 {
00096   enableButtonOK( !text.isEmpty() );
00097 }
00098 
00099 void ConfigDialog::setReadOnly( bool value )
00100 {
00101   mReadOnly->setChecked( value );
00102 }
00103 
00104 void ConfigDialog::accept()
00105 {
00106   if ( mName->text().isEmpty() ) {
00107     KMessageBox::sorry( this, i18n( "Please enter a resource name." ) );
00108     return;
00109   }
00110 
00111   mResource->setResourceName( mName->text() );
00112   mResource->setReadOnly( mReadOnly->isChecked() );
00113 
00114   if ( mConfigWidget ) {
00115     // First save generic information
00116     // Also save setting of specific resource type
00117     mConfigWidget->saveSettings( mResource );
00118   }
00119 
00120   KDialog::accept();
00121 }
00122 
00123 #include "configdialog.moc"

tderesources

Skip menu "tderesources"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

tderesources

Skip menu "tderesources"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tderesources by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.