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.cpp89
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
@@ -39,14 +39,16 @@
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
43using namespace KRES; 44using namespace KRES;
44 45
45ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 46ConfigDialog::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 );
@@ -61,14 +63,16 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
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
@@ -82,21 +86,41 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
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
@@ -106,6 +130,10 @@ 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
111void ConfigDialog::slotNameChanged( const QString &text) 139void ConfigDialog::slotNameChanged( const QString &text)
@@ -115,32 +143,38 @@ void ConfigDialog::slotNameChanged( const QString &text)
115 143
116void ConfigDialog::setReadOnly( bool value ) 144void 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
124void ConfigDialog::setPersistentReadOnly( bool value ) 155void 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
135void ConfigDialog::accept() 168void 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
@@ -148,6 +182,13 @@ void ConfigDialog::accept()
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