summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
Unidiff
Diffstat (limited to 'microkde/kresources') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp25
-rw-r--r--microkde/kresources/configdialog.h3
-rw-r--r--microkde/kresources/configwidget.h2
3 files changed, 26 insertions, 4 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
@@ -24,114 +24,131 @@
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32 32
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34 34
35#include <kbuttonbox.h> 35#include <kbuttonbox.h>
36#include <kdialog.h> 36#include <kdialog.h>
37#include <klineedit.h> 37#include <klineedit.h>
38 38
39#include "factory.h" 39#include "factory.h"
40#include "configwidget.h" 40#include "configwidget.h"
41#include "configdialog.h" 41#include "configdialog.h"
42 42
43using namespace KRES; 43using namespace KRES;
44 44
45ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 45ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
46 /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) 46 /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name )
47 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), 47 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
48 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ) 48 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
49{ 49{
50 Factory *factory = Factory::self( resourceFamily ); 50 Factory *factory = Factory::self( resourceFamily );
51 51
52//US resize( 250, 240 ); 52//US resize( 250, 240 );
53 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 53 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
54 54
55//US QFrame *main = makeMainWidget(); 55//US QFrame *main = makeMainWidget();
56 QFrame *main = plainPage(); 56 QFrame *main = plainPage();
57 57
58 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 58 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
59 59
60 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 60 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
61 generalGroupBox->layout()->setSpacing( spacingHint() ); 61 generalGroupBox->layout()->setSpacing( spacingHint() );
62 generalGroupBox->setTitle( i18n( "General Settings" ) ); 62 generalGroupBox->setTitle( i18n( "General Settings" ) );
63 63
64 new QLabel( i18n( "Name:" ), generalGroupBox ); 64 new QLabel( i18n( "Name:" ), generalGroupBox );
65 65
66 mName = new KLineEdit( generalGroupBox ); 66 mName = new KLineEdit( generalGroupBox );
67 67
68 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 68 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
69 69
70 mName->setText( mResource->resourceName() ); 70 mName->setText( mResource->resourceName() );
71 mReadOnly->setChecked( mResource->readOnly() ); 71 mReadOnly->setChecked( mResource->readOnly() );
72 72
73 mainLayout->addWidget( generalGroupBox ); 73 mainLayout->addWidget( generalGroupBox );
74 74
75 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 75 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
76 resourceGroupBox->layout()->setSpacing( spacingHint()); 76 resourceGroupBox->layout()->setSpacing( spacingHint());
77 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 77 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
78 .arg( factory->typeName( resource->type() ) ) ); 78 .arg( factory->typeName( resource->type() ) ) );
79 mainLayout->addWidget( resourceGroupBox ); 79 mainLayout->addWidget( resourceGroupBox );
80 80
81 mainLayout->addStretch(); 81 mainLayout->addStretch();
82 82
83 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 83 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
84 if ( mConfigWidget ) { 84 if ( mConfigWidget ) {
85 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
86 SLOT( setReadOnly( bool ) ) );
87 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
88 SLOT( setPersistentReadOnly( bool ) ) );
85 mConfigWidget->setInEditMode( false ); 89 mConfigWidget->setInEditMode( false );
86 mConfigWidget->loadSettings( mResource ); 90 mConfigWidget->loadSettings( mResource );
87 mConfigWidget->show(); 91 mConfigWidget->show();
88 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 92
89 SLOT( setReadOnly( bool ) ) );
90 } 93 }
91 94
92 connect( mName, SIGNAL( textChanged(const QString &)), 95 connect( mName, SIGNAL( textChanged(const QString &)),
93 SLOT( slotNameChanged(const QString &))); 96 SLOT( slotNameChanged(const QString &)));
94 97
95 slotNameChanged( mName->text() ); 98 slotNameChanged( mName->text() );
96 99
97//US setMinimumSize( 400, 250 ); 100//US setMinimumSize( 400, 250 );
98 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 101 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
99 102
100} 103}
101 104
102void ConfigDialog::setInEditMode( bool value ) 105void ConfigDialog::setInEditMode( bool value )
103{ 106{
104 if ( mConfigWidget ) 107 if ( mConfigWidget )
105 mConfigWidget->setInEditMode( value ); 108 mConfigWidget->setInEditMode( value );
106} 109}
107 110
108void ConfigDialog::slotNameChanged( const QString &text) 111void ConfigDialog::slotNameChanged( const QString &text)
109{ 112{
110 enableButtonOK( !text.isEmpty() ); 113 enableButtonOK( !text.isEmpty() );
111} 114}
112 115
113void ConfigDialog::setReadOnly( bool value ) 116void ConfigDialog::setReadOnly( bool value )
114{ 117{
115 mReadOnly->setChecked( value ); 118 if (mPersistentReadOnly == false)
119 mReadOnly->setChecked( value );
120 else
121 mReadOnly->setChecked( true );
122}
123
124void ConfigDialog::setPersistentReadOnly( bool value )
125{
126 mPersistentReadOnly = value;
127
128 if (value == true)
129 setReadOnly( true );
130
131 mReadOnly->setEnabled( !value );
132
116} 133}
117 134
118void ConfigDialog::accept() 135void ConfigDialog::accept()
119{ 136{
120 if ( mName->text().isEmpty() ) { 137 if ( mName->text().isEmpty() ) {
121 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); 138 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
122 return; 139 return;
123 } 140 }
124 141
125 mResource->setResourceName( mName->text() ); 142 mResource->setResourceName( mName->text() );
126 mResource->setReadOnly( mReadOnly->isChecked() ); 143 mResource->setReadOnly( mReadOnly->isChecked() );
127 144
128 if ( mConfigWidget ) { 145 if ( mConfigWidget ) {
129 // First save generic information 146 // First save generic information
130 // Also save setting of specific resource type 147 // Also save setting of specific resource type
131 mConfigWidget->saveSettings( mResource ); 148 mConfigWidget->saveSettings( mResource );
132 } 149 }
133 150
134 KDialog::accept(); 151 KDialog::accept();
135} 152}
136 153
137//US #include "configdialog.moc" 154//US #include "configdialog.moc"
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
@@ -24,37 +24,40 @@
24 24
25#include <kdialogbase.h> 25#include <kdialogbase.h>
26 26
27class KLineEdit; 27class KLineEdit;
28class QCheckBox; 28class QCheckBox;
29class KButtonBox; 29class KButtonBox;
30 30
31namespace KRES { 31namespace KRES {
32 class Resource; 32 class Resource;
33 class ConfigWidget; 33 class ConfigWidget;
34 34
35class ConfigDialog : public KDialogBase 35class ConfigDialog : public KDialogBase
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 // Resource=0: create new resource 39 // Resource=0: create new resource
40 ConfigDialog( QWidget *parent, const QString& resourceFamily, 40 ConfigDialog( QWidget *parent, const QString& resourceFamily,
41 Resource* resource, const char *name = 0); 41 Resource* resource, const char *name = 0);
42 42
43 void setInEditMode( bool value ); 43 void setInEditMode( bool value );
44 44
45 protected slots: 45 protected slots:
46 void accept(); 46 void accept();
47 void setReadOnly( bool value ); 47 void setReadOnly( bool value );
48 void setPersistentReadOnly( bool value );
48 void slotNameChanged( const QString &text); 49 void slotNameChanged( const QString &text);
49 50
50 private: 51 private:
51 ConfigWidget *mConfigWidget; 52 ConfigWidget *mConfigWidget;
52 Resource* mResource; 53 Resource* mResource;
53 54
54 KLineEdit *mName; 55 KLineEdit *mName;
55 QCheckBox *mReadOnly; 56 QCheckBox *mReadOnly;
57//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
58 bool mPersistentReadOnly;
56}; 59};
57 60
58} 61}
59 62
60#endif 63#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
@@ -29,31 +29,33 @@
29#include "resource.h" 29#include "resource.h"
30 30
31namespace KRES { 31namespace KRES {
32 32
33class ConfigWidget : public QWidget 33class ConfigWidget : public QWidget
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 36
37public: 37public:
38 ConfigWidget( QWidget *parent = 0, const char *name = 0 ); 38 ConfigWidget( QWidget *parent = 0, const char *name = 0 );
39 39
40 /** 40 /**
41 Sets the widget to 'edit' mode. Reimplement this method if you are 41 Sets the widget to 'edit' mode. Reimplement this method if you are
42 interested in the mode change (to disable some GUI element for 42 interested in the mode change (to disable some GUI element for
43 example). By default the widget is in 'create new' mode. 43 example). By default the widget is in 'create new' mode.
44 */ 44 */
45 virtual void setInEditMode( bool value ); 45 virtual void setInEditMode( bool value );
46 46
47public slots: 47public slots:
48 virtual void loadSettings( Resource *resource ); 48 virtual void loadSettings( Resource *resource );
49 virtual void saveSettings( Resource *resource ); 49 virtual void saveSettings( Resource *resource );
50 50
51signals: 51signals:
52 void setReadOnly( bool value ); 52 void setReadOnly( bool value );
53 void setPersistentReadOnly( bool value );
54
53 55
54protected: 56protected:
55 Resource* mResource; 57 Resource* mResource;
56}; 58};
57 59
58} 60}
59#endif 61#endif