24 #include <tdelocale.h>
25 #include <klineedit.h>
26 #include <tdemessagebox.h>
28 #include <tqgroupbox.h>
31 #include <tqcheckbox.h>
34 #include "configdialog.h"
38 ConfigDialog::ConfigDialog( TQWidget *parent,
const TQString& resourceFamily,
39 Resource* resource,
const char *name )
40 : KDialogBase( parent, name, true, i18n(
"Resource Configuration" ),
41 Ok|Cancel, Ok, false ), mResource( resource )
43 Factory *factory = Factory::self( resourceFamily );
45 TQFrame *main = makeMainWidget();
47 TQVBoxLayout *mainLayout =
new TQVBoxLayout( main, 0, spacingHint() );
49 TQGroupBox *generalGroupBox =
new TQGroupBox( 2, TQt::Horizontal, main );
50 generalGroupBox->layout()->setSpacing( spacingHint() );
51 generalGroupBox->setTitle( i18n(
"General Settings" ) );
53 new TQLabel( i18n(
"Name:" ), generalGroupBox );
55 mName =
new KLineEdit( generalGroupBox );
57 mReadOnly =
new TQCheckBox( i18n(
"Read-only" ), generalGroupBox );
59 mName->setText( mResource->resourceName() );
60 mReadOnly->setChecked( mResource->readOnly() );
62 mainLayout->addWidget( generalGroupBox );
64 TQGroupBox *resourceGroupBox =
new TQGroupBox( 2, TQt::Horizontal, main );
65 resourceGroupBox->layout()->setSpacing( spacingHint() );
66 resourceGroupBox->setTitle( i18n(
"%1 Resource Settings" )
68 mainLayout->addWidget( resourceGroupBox );
70 mainLayout->addStretch();
73 if ( mConfigWidget ) {
74 mConfigWidget->setInEditMode(
false );
75 mConfigWidget->loadSettings( mResource );
76 mConfigWidget->show();
77 connect( mConfigWidget, TQ_SIGNAL( setReadOnly(
bool ) ),
78 TQ_SLOT( setReadOnly(
bool ) ) );
81 connect( mName, TQ_SIGNAL( textChanged(
const TQString &)),
82 TQ_SLOT( slotNameChanged(
const TQString &)));
84 slotNameChanged( mName->text() );
85 setMinimumSize( sizeHint() );
88 void ConfigDialog::setInEditMode(
bool value )
91 mConfigWidget->setInEditMode( value );
94 void ConfigDialog::slotNameChanged(
const TQString &text)
96 enableButtonOK( !text.isEmpty() );
99 void ConfigDialog::setReadOnly(
bool value )
101 mReadOnly->setChecked( value );
104 void ConfigDialog::accept()
106 if ( mName->text().isEmpty() ) {
107 KMessageBox::sorry(
this, i18n(
"Please enter a resource name." ) );
111 mResource->setResourceName( mName->text() );
112 mResource->setReadOnly( mReadOnly->isChecked() );
114 if ( mConfigWidget ) {
117 mConfigWidget->saveSettings( mResource );
123 #include "configdialog.moc"
Class for loading resource plugins.
TQString typeName(const TQString &type) const
Returns the name for a special type.
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...
This class provides a resource which is managed in a general way.
TQString type() const
Returns the type of this resource.