summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/configdialog.cpp
Unidiff
Diffstat (limited to 'microkde/kresources/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp78
1 files changed, 62 insertions, 16 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 90febca..f8240f9 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -8,152 +8,197 @@
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 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 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
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#include <qvbox.h>
32 33
33#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h>
34 36
35#include <kbuttonbox.h> 37#include <kbuttonbox.h>
36#include <kdialog.h> 38#include <kdialog.h>
37#include <klineedit.h> 39#include <klineedit.h>
38 40
39#include "factory.h" 41#include "factory.h"
40#include "configwidget.h" 42#include "configwidget.h"
41#include "configdialog.h" 43#include "configdialog.h"
42#include "syncwidget.h" 44#include "syncwidget.h"
43 45
44using namespace KRES; 46using namespace KRES;
45 47
46ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 48ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
47 Resource* resource, const char *name ) 49 Resource* resource, const char *name )
48 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), 50 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ),
49 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) 51 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false)
50{ 52{
51 53
52 Factory *factory = Factory::self( resourceFamily ); 54 Factory *factory = Factory::self( resourceFamily );
53 55
54//US resize( 250, 240 ); 56//US resize( 250, 240 );
55 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 57 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
56 58
57//US QFrame *main = makeMainWidget(); 59 QFrame *main;
58 QFrame *main = plainPage(); 60
61 if (!mResource->isSyncable())
62 main = plainPage();
63 else
64 main = addPage("Profile");
59 65
60 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 66 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
61 67
68
62 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 69 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
63 generalGroupBox->layout()->setSpacing( spacingHint() ); 70 generalGroupBox->layout()->setSpacing( spacingHint() );
64 generalGroupBox->setTitle( i18n( "General Settings" ) ); 71 generalGroupBox->setTitle( i18n( "General Settings" ) );
65 72
66 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); 73 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox );
67 74
68 mName = new KLineEdit( generalGroupBox ); 75 mName = new KLineEdit( generalGroupBox );
69 76
70 if (!mResource->isSyncable()) { 77 if (!mResource->isSyncable()) {
71 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 78 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
72 mReadOnly->setChecked( mResource->readOnly() ); 79 mReadOnly->setChecked( mResource->readOnly() );
73 } 80 }
74 81
75 mName->setText( mResource->resourceName() ); 82 mName->setText( mResource->resourceName() );
76 83
77 mainLayout->addWidget( generalGroupBox ); 84 mainLayout->addWidget( generalGroupBox );
78 85
79 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 86 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
80 resourceGroupBox->layout()->setSpacing( spacingHint()); 87 resourceGroupBox->layout()->setSpacing( spacingHint());
81 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 88 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
82 .arg( factory->typeName( resource->type() ) ) ); 89 .arg( factory->typeName( resource->type() ) ) );
83 mainLayout->addWidget( resourceGroupBox ); 90 mainLayout->addWidget( resourceGroupBox );
84 91
85 mainLayout->addStretch(); 92 mainLayout->addStretch();
86 93
87 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 94 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
88 if ( mConfigWidget ) { 95 if ( mConfigWidget ) {
89 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 96 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
90 SLOT( setReadOnly( bool ) ) ); 97 SLOT( setReadOnly( bool ) ) );
91 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 98 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
92 SLOT( setPersistentReadOnly( bool ) ) ); 99 SLOT( setPersistentReadOnly( bool ) ) );
93 mConfigWidget->setInEditMode( false ); 100 mConfigWidget->setInEditMode( false );
94 mConfigWidget->loadSettings( mResource ); 101 mConfigWidget->loadSettings( mResource );
95 mConfigWidget->show(); 102 mConfigWidget->show();
96 103
97 } 104 }
98 105
99 if (mResource->isSyncable()) 106 if (mResource->isSyncable())
100 { 107 {
101 QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 108 SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() );
102 syncGroupBox->layout()->setSpacing( spacingHint()); 109
103 syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); 110 QFrame* syncPage = addPage("Settings");
104 mainLayout->addWidget( syncGroupBox ); 111 QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
112 mSyncWidget_Settings = c->generateSettingsTab(syncPage);
113 syncLayout->addWidget( mSyncWidget_Settings );
114
115 syncPage = addPage("Conflicts");
116 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
117 mSyncWidget_Conflicts = c->generateConflictsTab(syncPage);
118 syncLayout->addWidget( mSyncWidget_Conflicts );
119
120 syncPage = addPage("Remote");
121 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
122 mSyncWidget_Remote = c->generateRemoteTab(syncPage);
123 syncLayout->addWidget( mSyncWidget_Remote );
124
105 125
106 mainLayout->addStretch(); 126 mSyncWidget_Settings->setInEditMode( false );
127 mSyncWidget_Settings->loadSettings( mResource );
128 mSyncWidget_Settings->show();
107 129
108 mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); 130 mSyncWidget_Conflicts->setInEditMode( false );
131 mSyncWidget_Conflicts->loadSettings( mResource );
132 mSyncWidget_Conflicts->show();
133
134 mSyncWidget_Remote->setInEditMode( false );
135 mSyncWidget_Remote->loadSettings( mResource );
136 mSyncWidget_Remote->show();
137
138 delete c;
139
140// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage );
141// syncGroupBox->layout()->setSpacing( spacingHint());
142// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
143// syncLayout->addWidget( syncGroupBox );
144
145// syncLayout->addStretch();
146/*US
147 mSyncWidget = factory->syncWidget( resource->type(), syncPage );
148 syncLayout->addWidget( mSyncWidget );
109 if ( mSyncWidget ) { 149 if ( mSyncWidget ) {
110 mSyncWidget->setInEditMode( false ); 150 mSyncWidget->setInEditMode( false );
111 mSyncWidget->loadSettings( mResource ); 151 mSyncWidget->loadSettings( mResource );
112 mSyncWidget->show(); 152 mSyncWidget->show();
113 } 153 }
154 */
114 } 155 }
115 156
116 157
117 158
118 159
119 connect( mName, SIGNAL( textChanged(const QString &)), 160 connect( mName, SIGNAL( textChanged(const QString &)),
120 SLOT( slotNameChanged(const QString &))); 161 SLOT( slotNameChanged(const QString &)));
121 162
122 slotNameChanged( mName->text() ); 163 slotNameChanged( mName->text() );
123 164
124//US setMinimumSize( 400, 250 ); 165//US setMinimumSize( 400, 250 );
125 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 166 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
126 167
127} 168}
128 169
129void ConfigDialog::setInEditMode( bool value ) 170void ConfigDialog::setInEditMode( bool value )
130{ 171{
131 if ( mConfigWidget ) 172 if ( mConfigWidget )
132 mConfigWidget->setInEditMode( value ); 173 mConfigWidget->setInEditMode( value );
133 174
134 if ( mSyncWidget ) 175 if ( mSyncWidget_Settings )
135 mSyncWidget->setInEditMode( value ); 176 mSyncWidget_Settings->setInEditMode( value );
177 if ( mSyncWidget_Conflicts )
178 mSyncWidget_Conflicts->setInEditMode( value );
179 if ( mSyncWidget_Remote )
180 mSyncWidget_Remote->setInEditMode( value );
136 181
137} 182}
138 183
139void ConfigDialog::slotNameChanged( const QString &text) 184void ConfigDialog::slotNameChanged( const QString &text)
140{ 185{
141 enableButtonOK( !text.isEmpty() ); 186 enableButtonOK( !text.isEmpty() );
142} 187}
143 188
144void ConfigDialog::setReadOnly( bool value ) 189void ConfigDialog::setReadOnly( bool value )
145{ 190{
146 if (!mResource->isSyncable()) { 191 if (!mResource->isSyncable()) {
147 192
148 if (mPersistentReadOnly == false) 193 if (mPersistentReadOnly == false)
149 mReadOnly->setChecked( value ); 194 mReadOnly->setChecked( value );
150 else 195 else
151 mReadOnly->setChecked( true ); 196 mReadOnly->setChecked( true );
152 } 197 }
153} 198}
154 199
155void ConfigDialog::setPersistentReadOnly( bool value ) 200void ConfigDialog::setPersistentReadOnly( bool value )
156{ 201{
157 if (!mResource->isSyncable()) { 202 if (!mResource->isSyncable()) {
158 203
159 mPersistentReadOnly = value; 204 mPersistentReadOnly = value;
@@ -161,35 +206,36 @@ void ConfigDialog::setPersistentReadOnly( bool value )
161 if (value == true) 206 if (value == true)
162 setReadOnly( true ); 207 setReadOnly( true );
163 208
164 mReadOnly->setEnabled( !value ); 209 mReadOnly->setEnabled( !value );
165 } 210 }
166} 211}
167 212
168void ConfigDialog::accept() 213void ConfigDialog::accept()
169{ 214{
170 if ( mName->text().isEmpty() ) { 215 if ( mName->text().isEmpty() ) {
171 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); 216 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) );
172 return; 217 return;
173 } 218 }
174 219
175 mResource->setResourceName( mName->text() ); 220 mResource->setResourceName( mName->text() );
176 if (!mResource->isSyncable()) 221 if (!mResource->isSyncable())
177 mResource->setReadOnly( mReadOnly->isChecked() ); 222 mResource->setReadOnly( mReadOnly->isChecked() );
178 223
179 if ( mConfigWidget ) { 224 if ( mConfigWidget ) {
180 // First save generic information 225 // First save generic information
181 // Also save setting of specific resource type 226 // Also save setting of specific resource type
182 mConfigWidget->saveSettings( mResource ); 227 mConfigWidget->saveSettings( mResource );
183 } 228 }
184 229
185 if ( mSyncWidget ) { 230 if ( mSyncWidget_Settings )
186 // First save generic information 231 mSyncWidget_Settings->saveSettings( mResource );
187 // Also save setting of specific resource type 232 if ( mSyncWidget_Conflicts )
188 mSyncWidget->saveSettings( mResource ); 233 mSyncWidget_Conflicts->saveSettings( mResource );
189 } 234 if ( mSyncWidget_Remote )
235 mSyncWidget_Remote->saveSettings( mResource );
190 236
191 237
192 KDialog::accept(); 238 KDialog::accept();
193} 239}
194 240
195//US #include "configdialog.moc" 241//US #include "configdialog.moc"