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

tderesources

  • tderesources
configdialog.cpp
1 /*
2  This file is part of libtderesources.
3 
4  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5  Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include <tdelocale.h>
25 #include <klineedit.h>
26 #include <tdemessagebox.h>
27 
28 #include <tqgroupbox.h>
29 #include <tqlabel.h>
30 #include <tqlayout.h>
31 #include <tqcheckbox.h>
32 
33 #include "factory.h"
34 #include "configdialog.h"
35 
36 using namespace KRES;
37 
38 ConfigDialog::ConfigDialog( TQWidget *parent, const TQString& resourceFamily,
39  /*const TQString& type,*/ Resource* resource, /*TDEConfig *config, */const char *name )
40  : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
41  Ok|Cancel, Ok, false )/*, mConfig( config )*/, mResource( resource )
42 {
43  Factory *factory = Factory::self( resourceFamily );
44 
45  TQFrame *main = makeMainWidget();
46 
47  TQVBoxLayout *mainLayout = new TQVBoxLayout( main, 0, spacingHint() );
48 
49  TQGroupBox *generalGroupBox = new TQGroupBox( 2, Qt::Horizontal, main );
50  generalGroupBox->layout()->setSpacing( spacingHint() );
51  generalGroupBox->setTitle( i18n( "General Settings" ) );
52 
53  new TQLabel( i18n( "Name:" ), generalGroupBox );
54 
55  mName = new KLineEdit( generalGroupBox );
56 
57  mReadOnly = new TQCheckBox( i18n( "Read-only" ), generalGroupBox );
58 
59  mName->setText( mResource->resourceName() );
60  mReadOnly->setChecked( mResource->readOnly() );
61 
62  mainLayout->addWidget( generalGroupBox );
63 
64  TQGroupBox *resourceGroupBox = new TQGroupBox( 2, Qt::Horizontal, main );
65  resourceGroupBox->layout()->setSpacing( spacingHint() );
66  resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
67  .arg( factory->typeName( resource->type() ) ) );
68  mainLayout->addWidget( resourceGroupBox );
69 
70  mainLayout->addStretch();
71 
72  mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
73  if ( mConfigWidget ) {
74  mConfigWidget->setInEditMode( false );
75  mConfigWidget->loadSettings( mResource );
76  mConfigWidget->show();
77  connect( mConfigWidget, TQT_SIGNAL( setReadOnly( bool ) ),
78  TQT_SLOT( setReadOnly( bool ) ) );
79  }
80 
81  connect( mName, TQT_SIGNAL( textChanged(const TQString &)),
82  TQT_SLOT( slotNameChanged(const TQString &)));
83 
84  slotNameChanged( mName->text() );
85  setMinimumSize( sizeHint() );
86 }
87 
88 void ConfigDialog::setInEditMode( bool value )
89 {
90  if ( mConfigWidget )
91  mConfigWidget->setInEditMode( value );
92 }
93 
94 void ConfigDialog::slotNameChanged( const TQString &text)
95 {
96  enableButtonOK( !text.isEmpty() );
97 }
98 
99 void ConfigDialog::setReadOnly( bool value )
100 {
101  mReadOnly->setChecked( value );
102 }
103 
104 void ConfigDialog::accept()
105 {
106  if ( mName->text().isEmpty() ) {
107  KMessageBox::sorry( this, i18n( "Please enter a resource name." ) );
108  return;
109  }
110 
111  mResource->setResourceName( mName->text() );
112  mResource->setReadOnly( mReadOnly->isChecked() );
113 
114  if ( mConfigWidget ) {
115  // First save generic information
116  // Also save setting of specific resource type
117  mConfigWidget->saveSettings( mResource );
118  }
119 
120  KDialog::accept();
121 }
122 
123 #include "configdialog.moc"
KRES::Factory::configWidget
ConfigWidget * configWidget(const TQString &type, TQWidget *parent=0)
Returns the config widget for the given resource type, or a null pointer if resource type doesn't exi...
Definition: factory.cpp:80
KRES::Factory::typeName
TQString typeName(const TQString &type) const
Returns the name for a special type.
Definition: factory.cpp:110
KRES::Resource::type
TQString type() const
Returns the type of this resource.
Definition: resource.cpp:138
KRES
Definition: configdialog.h:31
KRES::Resource
This class provides a resource which is managed in a general way.
Definition: resource.h:255
KRES::Factory
Class for loading resource plugins.
Definition: factory.h:62

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tderesources by doxygen 1.8.8
This website is maintained by Timothy Pearson.