summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-13 22:22:18 (UTC)
committer ulf69 <ulf69>2004-10-13 22:22:18 (UTC)
commit909d25797c50fc38c435834a68aaf60bf87e32f9 (patch) (unidiff)
tree6aaccef9033325ece72d95b39b3c0a7e591e73c3
parent7c2a228f94d8bcb783ce6f3527cb2daa9221217b (diff)
downloadkdepimpi-909d25797c50fc38c435834a68aaf60bf87e32f9.zip
kdepimpi-909d25797c50fc38c435834a68aaf60bf87e32f9.tar.gz
kdepimpi-909d25797c50fc38c435834a68aaf60bf87e32f9.tar.bz2
bugfix: disable "IncludeInSync" if resource is readOnly, because it is an external resource
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configdialog.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 24e82bc..55253c0 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -1,179 +1,179 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
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#include <qvbox.h>
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h> 35#include <qscrollview.h>
36 36
37#include <kbuttonbox.h> 37#include <kbuttonbox.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klineedit.h> 39#include <klineedit.h>
40 40
41#include "factory.h" 41#include "factory.h"
42#include "configwidget.h" 42#include "configwidget.h"
43#include "configdialog.h" 43#include "configdialog.h"
44 44
45using namespace KRES; 45using namespace KRES;
46 46
47ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 47ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
48 Resource* resource, const char *name ) 48 Resource* resource, const char *name )
49 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), 49 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
50 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) 50 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
51{ 51{
52 52
53 Factory *factory = Factory::self( resourceFamily ); 53 Factory *factory = Factory::self( resourceFamily );
54 54
55//US resize( 250, 240 ); 55//US resize( 250, 240 );
56 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 56 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
57 57
58 QFrame *main; 58 QFrame *main;
59 59
60 main = plainPage(); 60 main = plainPage();
61 61
62 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 62 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
63 63
64 64
65 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 65 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
66 generalGroupBox->layout()->setSpacing( spacingHint() ); 66 generalGroupBox->layout()->setSpacing( spacingHint() );
67 generalGroupBox->setTitle( i18n( "General Settings" ) ); 67 generalGroupBox->setTitle( i18n( "General Settings" ) );
68 68
69 new QLabel( i18n( "Name:" ), generalGroupBox ); 69 new QLabel( i18n( "Name:" ), generalGroupBox );
70 70
71 mName = new KLineEdit( generalGroupBox ); 71 mName = new KLineEdit( generalGroupBox );
72 72
73 new QLabel("", generalGroupBox ); 73 new QLabel("", generalGroupBox );
74 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 74 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
75 mReadOnly->setChecked( mResource->readOnly() ); 75 mReadOnly->setChecked( mResource->readOnly() );
76 76
77 new QLabel("", generalGroupBox ); 77 new QLabel("", generalGroupBox );
78 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); 78 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox );
79 mIncludeInSync->setChecked( mResource->includeInSync() ); 79 mIncludeInSync->setChecked( mResource->includeInSync() );
80 80
81 mName->setText( mResource->resourceName() ); 81 mName->setText( mResource->resourceName() );
82 82
83 mainLayout->addWidget( generalGroupBox ); 83 mainLayout->addWidget( generalGroupBox );
84 84
85 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 85 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
86 resourceGroupBox->layout()->setSpacing( spacingHint()); 86 resourceGroupBox->layout()->setSpacing( spacingHint());
87 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 87 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
88 .arg( factory->typeName( resource->type() ) ) ); 88 .arg( factory->typeName( resource->type() ) ) );
89 mainLayout->addWidget( resourceGroupBox ); 89 mainLayout->addWidget( resourceGroupBox );
90 90
91 mainLayout->addStretch(); 91 mainLayout->addStretch();
92 92
93 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 93 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
94 if ( mConfigWidget ) { 94 if ( mConfigWidget ) {
95 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 95 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
96 SLOT( setReadOnly( bool ) ) ); 96 SLOT( setReadOnly( bool ) ) );
97 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ), 97 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ),
98 SLOT( setIncludeInSync( bool ) ) ); 98 SLOT( setIncludeInSync( bool ) ) );
99 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 99 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
100 SLOT( setPersistentReadOnly( bool ) ) ); 100 SLOT( setPersistentReadOnly( bool ) ) );
101 mConfigWidget->setInEditMode( false ); 101 mConfigWidget->setInEditMode( false );
102 mConfigWidget->loadSettings( mResource ); 102 mConfigWidget->loadSettings( mResource );
103 mConfigWidget->show(); 103 mConfigWidget->show();
104 104
105 } 105 }
106 106
107 107
108 connect( mName, SIGNAL( textChanged(const QString &)), 108 connect( mName, SIGNAL( textChanged(const QString &)),
109 SLOT( slotNameChanged(const QString &))); 109 SLOT( slotNameChanged(const QString &)));
110 110
111 slotNameChanged( mName->text() ); 111 slotNameChanged( mName->text() );
112 112
113//US setMinimumSize( 400, 250 ); 113//US setMinimumSize( 400, 250 );
114 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 114 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
115 115
116} 116}
117 117
118void ConfigDialog::setInEditMode( bool value ) 118void ConfigDialog::setInEditMode( bool value )
119{ 119{
120 if ( mConfigWidget ) 120 if ( mConfigWidget )
121 mConfigWidget->setInEditMode( value ); 121 mConfigWidget->setInEditMode( value );
122} 122}
123 123
124void ConfigDialog::slotNameChanged( const QString &text) 124void ConfigDialog::slotNameChanged( const QString &text)
125{ 125{
126 enableButtonOK( !text.isEmpty() ); 126 enableButtonOK( !text.isEmpty() );
127} 127}
128 128
129void ConfigDialog::setReadOnly( bool value ) 129void ConfigDialog::setReadOnly( bool value )
130{ 130{
131 if (mPersistentReadOnly == false) 131 if (mPersistentReadOnly == false)
132 mReadOnly->setChecked( value ); 132 mReadOnly->setChecked( value );
133 else 133 else
134 mReadOnly->setChecked( true ); 134 mReadOnly->setChecked( true );
135} 135}
136 136
137void ConfigDialog::setIncludeInSync( bool value ) 137void ConfigDialog::setIncludeInSync( bool value )
138{ 138{
139 if (mPersistentReadOnly == false) 139 if (mPersistentReadOnly == false)
140 mIncludeInSync->setChecked( value ); 140 mIncludeInSync->setChecked( value );
141 else 141 else
142 mIncludeInSync->setChecked( true ); 142 mIncludeInSync->setChecked( false );
143} 143}
144 144
145void ConfigDialog::setPersistentReadOnly( bool value ) 145void ConfigDialog::setPersistentReadOnly( bool value )
146{ 146{
147 mPersistentReadOnly = value; 147 mPersistentReadOnly = value;
148 148
149 if (value == true) { 149 if (value == true) {
150 setReadOnly( true ); 150 setReadOnly( true );
151 setIncludeInSync( true ); 151 setIncludeInSync( false );
152 } 152 }
153 153
154 mReadOnly->setEnabled( !value ); 154 mReadOnly->setEnabled( !value );
155 mIncludeInSync->setEnabled (!value ); 155 mIncludeInSync->setEnabled (!value );
156} 156}
157 157
158 158
159void ConfigDialog::accept() 159void ConfigDialog::accept()
160{ 160{
161 if ( mName->text().isEmpty() ) { 161 if ( mName->text().isEmpty() ) {
162 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); 162 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
163 return; 163 return;
164 } 164 }
165 165
166 mResource->setResourceName( mName->text() ); 166 mResource->setResourceName( mName->text() );
167 mResource->setReadOnly( mReadOnly->isChecked() ); 167 mResource->setReadOnly( mReadOnly->isChecked() );
168 mResource->setIncludeInSync( mIncludeInSync->isChecked() ); 168 mResource->setIncludeInSync( mIncludeInSync->isChecked() );
169 169
170 if ( mConfigWidget ) { 170 if ( mConfigWidget ) {
171 // First save generic information 171 // First save generic information
172 // Also save setting of specific resource type 172 // Also save setting of specific resource type
173 mConfigWidget->saveSettings( mResource ); 173 mConfigWidget->saveSettings( mResource );
174 } 174 }
175 175
176 KDialog::accept(); 176 KDialog::accept();
177} 177}
178 178
179//US #include "configdialog.moc" 179//US #include "configdialog.moc"