Diffstat (limited to 'microkde/kresources/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/configdialog.cpp | 89 |
1 files changed, 65 insertions, 24 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 0fc199c..90febca 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -30,125 +30,166 @@ | |||
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 | #include "syncwidget.h" | ||
42 | 43 | ||
43 | using namespace KRES; | 44 | using namespace KRES; |
44 | 45 | ||
45 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | 46 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, |
46 | /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) | 47 | Resource* resource, const char *name ) |
47 | : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), | 48 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), |
48 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) | 49 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) |
49 | { | 50 | { |
51 | |||
50 | Factory *factory = Factory::self( resourceFamily ); | 52 | Factory *factory = Factory::self( resourceFamily ); |
51 | 53 | ||
52 | //US resize( 250, 240 ); | 54 | //US resize( 250, 240 ); |
53 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); | 55 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); |
54 | 56 | ||
55 | //US QFrame *main = makeMainWidget(); | 57 | //US QFrame *main = makeMainWidget(); |
56 | QFrame *main = plainPage(); | 58 | QFrame *main = plainPage(); |
57 | 59 | ||
58 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | 60 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); |
59 | 61 | ||
60 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 62 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
61 | generalGroupBox->layout()->setSpacing( spacingHint() ); | 63 | generalGroupBox->layout()->setSpacing( spacingHint() ); |
62 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 64 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
63 | 65 | ||
64 | new QLabel( i18n( "Name:" ), generalGroupBox ); | 66 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); |
65 | 67 | ||
66 | mName = new KLineEdit( generalGroupBox ); | 68 | mName = new KLineEdit( generalGroupBox ); |
67 | 69 | ||
68 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 70 | if (!mResource->isSyncable()) { |
71 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | ||
72 | mReadOnly->setChecked( mResource->readOnly() ); | ||
73 | } | ||
69 | 74 | ||
70 | mName->setText( mResource->resourceName() ); | 75 | mName->setText( mResource->resourceName() ); |
71 | mReadOnly->setChecked( mResource->readOnly() ); | ||
72 | 76 | ||
73 | mainLayout->addWidget( generalGroupBox ); | 77 | mainLayout->addWidget( generalGroupBox ); |
74 | 78 | ||
75 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 79 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
76 | resourceGroupBox->layout()->setSpacing( spacingHint()); | 80 | resourceGroupBox->layout()->setSpacing( spacingHint()); |
77 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) | 81 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) |
78 | .arg( factory->typeName( resource->type() ) ) ); | 82 | .arg( factory->typeName( resource->type() ) ) ); |
79 | mainLayout->addWidget( resourceGroupBox ); | 83 | mainLayout->addWidget( resourceGroupBox ); |
80 | 84 | ||
81 | mainLayout->addStretch(); | 85 | mainLayout->addStretch(); |
82 | 86 | ||
83 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); | 87 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); |
84 | if ( mConfigWidget ) { | 88 | if ( mConfigWidget ) { |
85 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | 89 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), |
86 | SLOT( setReadOnly( bool ) ) ); | 90 | SLOT( setReadOnly( bool ) ) ); |
87 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), | 91 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), |
88 | SLOT( setPersistentReadOnly( bool ) ) ); | 92 | SLOT( setPersistentReadOnly( bool ) ) ); |
89 | mConfigWidget->setInEditMode( false ); | 93 | mConfigWidget->setInEditMode( false ); |
90 | mConfigWidget->loadSettings( mResource ); | 94 | mConfigWidget->loadSettings( mResource ); |
91 | mConfigWidget->show(); | 95 | mConfigWidget->show(); |
92 | 96 | ||
93 | } | 97 | } |
94 | 98 | ||
95 | connect( mName, SIGNAL( textChanged(const QString &)), | 99 | if (mResource->isSyncable()) |
100 | { | ||
101 | QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | ||
102 | syncGroupBox->layout()->setSpacing( spacingHint()); | ||
103 | syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | ||
104 | mainLayout->addWidget( syncGroupBox ); | ||
105 | |||
106 | mainLayout->addStretch(); | ||
107 | |||
108 | mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); | ||
109 | if ( mSyncWidget ) { | ||
110 | mSyncWidget->setInEditMode( false ); | ||
111 | mSyncWidget->loadSettings( mResource ); | ||
112 | mSyncWidget->show(); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | |||
117 | |||
118 | |||
119 | connect( mName, SIGNAL( textChanged(const QString &)), | ||
96 | SLOT( slotNameChanged(const QString &))); | 120 | SLOT( slotNameChanged(const QString &))); |
97 | 121 | ||
98 | slotNameChanged( mName->text() ); | 122 | slotNameChanged( mName->text() ); |
99 | 123 | ||
100 | //US setMinimumSize( 400, 250 ); | 124 | //US setMinimumSize( 400, 250 ); |
101 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | 125 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); |
102 | 126 | ||
103 | } | 127 | } |
104 | 128 | ||
105 | void ConfigDialog::setInEditMode( bool value ) | 129 | void ConfigDialog::setInEditMode( bool value ) |
106 | { | 130 | { |
107 | if ( mConfigWidget ) | 131 | if ( mConfigWidget ) |
108 | mConfigWidget->setInEditMode( value ); | 132 | mConfigWidget->setInEditMode( value ); |
133 | |||
134 | if ( mSyncWidget ) | ||
135 | mSyncWidget->setInEditMode( value ); | ||
136 | |||
109 | } | 137 | } |
110 | 138 | ||
111 | void ConfigDialog::slotNameChanged( const QString &text) | 139 | void ConfigDialog::slotNameChanged( const QString &text) |
112 | { | 140 | { |
113 | enableButtonOK( !text.isEmpty() ); | 141 | enableButtonOK( !text.isEmpty() ); |
114 | } | 142 | } |
115 | 143 | ||
116 | void ConfigDialog::setReadOnly( bool value ) | 144 | void ConfigDialog::setReadOnly( bool value ) |
117 | { | 145 | { |
118 | if (mPersistentReadOnly == false) | 146 | if (!mResource->isSyncable()) { |
119 | mReadOnly->setChecked( value ); | 147 | |
120 | else | 148 | if (mPersistentReadOnly == false) |
121 | mReadOnly->setChecked( true ); | 149 | mReadOnly->setChecked( value ); |
150 | else | ||
151 | mReadOnly->setChecked( true ); | ||
152 | } | ||
122 | } | 153 | } |
123 | 154 | ||
124 | void ConfigDialog::setPersistentReadOnly( bool value ) | 155 | void ConfigDialog::setPersistentReadOnly( bool value ) |
125 | { | 156 | { |
126 | mPersistentReadOnly = value; | 157 | if (!mResource->isSyncable()) { |
127 | 158 | ||
128 | if (value == true) | 159 | mPersistentReadOnly = value; |
129 | setReadOnly( true ); | 160 | |
130 | 161 | if (value == true) | |
131 | mReadOnly->setEnabled( !value ); | 162 | setReadOnly( true ); |
132 | 163 | ||
164 | mReadOnly->setEnabled( !value ); | ||
165 | } | ||
133 | } | 166 | } |
134 | 167 | ||
135 | void ConfigDialog::accept() | 168 | void ConfigDialog::accept() |
136 | { | 169 | { |
137 | if ( mName->text().isEmpty() ) { | 170 | if ( mName->text().isEmpty() ) { |
138 | KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); | 171 | KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); |
139 | return; | 172 | return; |
140 | } | 173 | } |
141 | 174 | ||
142 | mResource->setResourceName( mName->text() ); | 175 | mResource->setResourceName( mName->text() ); |
143 | mResource->setReadOnly( mReadOnly->isChecked() ); | 176 | if (!mResource->isSyncable()) |
177 | mResource->setReadOnly( mReadOnly->isChecked() ); | ||
144 | 178 | ||
145 | if ( mConfigWidget ) { | 179 | if ( mConfigWidget ) { |
146 | // First save generic information | 180 | // First save generic information |
147 | // Also save setting of specific resource type | 181 | // Also save setting of specific resource type |
148 | mConfigWidget->saveSettings( mResource ); | 182 | mConfigWidget->saveSettings( mResource ); |
149 | } | 183 | } |
150 | 184 | ||
185 | if ( mSyncWidget ) { | ||
186 | // First save generic information | ||
187 | // Also save setting of specific resource type | ||
188 | mSyncWidget->saveSettings( mResource ); | ||
189 | } | ||
190 | |||
191 | |||
151 | KDialog::accept(); | 192 | KDialog::accept(); |
152 | } | 193 | } |
153 | 194 | ||
154 | //US #include "configdialog.moc" | 195 | //US #include "configdialog.moc" |