-rw-r--r-- | microkde/kresources/configdialog.cpp | 23 | ||||
-rw-r--r-- | microkde/kresources/configdialog.h | 3 | ||||
-rw-r--r-- | microkde/kresources/configwidget.h | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 48d9137..0fc199c 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp @@ -36,25 +36,25 @@ #include <kdialog.h> #include <klineedit.h> #include "factory.h" #include "configwidget.h" #include "configdialog.h" using namespace KRES; ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), - Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ) + Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) { Factory *factory = Factory::self( resourceFamily ); //US resize( 250, 240 ); resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); //US QFrame *main = makeMainWidget(); QFrame *main = plainPage(); QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); @@ -73,29 +73,32 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, mainLayout->addWidget( generalGroupBox ); QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); resourceGroupBox->layout()->setSpacing( spacingHint()); resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) .arg( factory->typeName( resource->type() ) ) ); mainLayout->addWidget( resourceGroupBox ); mainLayout->addStretch(); mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); if ( mConfigWidget ) { + connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), + SLOT( setReadOnly( bool ) ) ); + connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), + SLOT( setPersistentReadOnly( bool ) ) ); mConfigWidget->setInEditMode( false ); mConfigWidget->loadSettings( mResource ); mConfigWidget->show(); - connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), - SLOT( setReadOnly( bool ) ) ); + } connect( mName, SIGNAL( textChanged(const QString &)), SLOT( slotNameChanged(const QString &))); slotNameChanged( mName->text() ); //US setMinimumSize( 400, 250 ); setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); } @@ -103,25 +106,39 @@ void ConfigDialog::setInEditMode( bool value ) { if ( mConfigWidget ) mConfigWidget->setInEditMode( value ); } void ConfigDialog::slotNameChanged( const QString &text) { enableButtonOK( !text.isEmpty() ); } void ConfigDialog::setReadOnly( bool value ) { + if (mPersistentReadOnly == false) mReadOnly->setChecked( value ); + else + mReadOnly->setChecked( true ); +} + +void ConfigDialog::setPersistentReadOnly( bool value ) +{ + mPersistentReadOnly = value; + + if (value == true) + setReadOnly( true ); + + mReadOnly->setEnabled( !value ); + } void ConfigDialog::accept() { if ( mName->text().isEmpty() ) { KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); return; } mResource->setResourceName( mName->text() ); mResource->setReadOnly( mReadOnly->isChecked() ); diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h index 6acc5d9..ba66f8e 100644 --- a/microkde/kresources/configdialog.h +++ b/microkde/kresources/configdialog.h @@ -36,25 +36,28 @@ class ConfigDialog : public KDialogBase { Q_OBJECT public: // Resource=0: create new resource ConfigDialog( QWidget *parent, const QString& resourceFamily, Resource* resource, const char *name = 0); void setInEditMode( bool value ); protected slots: void accept(); void setReadOnly( bool value ); + void setPersistentReadOnly( bool value ); void slotNameChanged( const QString &text); private: ConfigWidget *mConfigWidget; Resource* mResource; KLineEdit *mName; QCheckBox *mReadOnly; +//US add a persistent readonly flag. We need that for opie and qtopia addressbooks. + bool mPersistentReadOnly; }; } #endif diff --git a/microkde/kresources/configwidget.h b/microkde/kresources/configwidget.h index 04dd696..b97e278 100644 --- a/microkde/kresources/configwidget.h +++ b/microkde/kresources/configwidget.h @@ -41,19 +41,21 @@ public: Sets the widget to 'edit' mode. Reimplement this method if you are interested in the mode change (to disable some GUI element for example). By default the widget is in 'create new' mode. */ virtual void setInEditMode( bool value ); public slots: virtual void loadSettings( Resource *resource ); virtual void saveSettings( Resource *resource ); signals: void setReadOnly( bool value ); + void setPersistentReadOnly( bool value ); + protected: Resource* mResource; }; } #endif |