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

kresources

  • kresources
configdialog.cpp
1 /*
2  This file is part of libkresources.
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 <klocale.h>
25 #include <klineedit.h>
26 #include <kmessagebox.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, /*KConfig *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"

kresources

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

kresources

Skip menu "kresources"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kresources by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |