author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kresources/configdialog.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kresources/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/configdialog.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 55253c0..4820faf 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -1,179 +1,182 @@ | |||
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 <q3groupbox.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 <q3vbox.h> |
33 | 33 | ||
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qscrollview.h> | 35 | #include <q3scrollview.h> |
36 | //Added by qt3to4: | ||
37 | #include <Q3VBoxLayout> | ||
38 | #include <Q3Frame> | ||
36 | 39 | ||
37 | #include <kbuttonbox.h> | 40 | #include <kbuttonbox.h> |
38 | #include <kdialog.h> | 41 | #include <kdialog.h> |
39 | #include <klineedit.h> | 42 | #include <klineedit.h> |
40 | 43 | ||
41 | #include "factory.h" | 44 | #include "factory.h" |
42 | #include "configwidget.h" | 45 | #include "configwidget.h" |
43 | #include "configdialog.h" | 46 | #include "configdialog.h" |
44 | 47 | ||
45 | using namespace KRES; | 48 | using namespace KRES; |
46 | 49 | ||
47 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | 50 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, |
48 | Resource* resource, const char *name ) | 51 | Resource* resource, const char *name ) |
49 | : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), | 52 | : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), |
50 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) | 53 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) |
51 | { | 54 | { |
52 | 55 | ||
53 | Factory *factory = Factory::self( resourceFamily ); | 56 | Factory *factory = Factory::self( resourceFamily ); |
54 | 57 | ||
55 | //US resize( 250, 240 ); | 58 | //US resize( 250, 240 ); |
56 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); | 59 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); |
57 | 60 | ||
58 | QFrame *main; | 61 | Q3Frame *main; |
59 | 62 | ||
60 | main = plainPage(); | 63 | main = plainPage(); |
61 | 64 | ||
62 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | 65 | Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main, 0, spacingHint() ); |
63 | 66 | ||
64 | 67 | ||
65 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 68 | Q3GroupBox *generalGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main ); |
66 | generalGroupBox->layout()->setSpacing( spacingHint() ); | 69 | generalGroupBox->layout()->setSpacing( spacingHint() ); |
67 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 70 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
68 | 71 | ||
69 | new QLabel( i18n( "Name:" ), generalGroupBox ); | 72 | new QLabel( i18n( "Name:" ), generalGroupBox ); |
70 | 73 | ||
71 | mName = new KLineEdit( generalGroupBox ); | 74 | mName = new KLineEdit( generalGroupBox ); |
72 | 75 | ||
73 | new QLabel("", generalGroupBox ); | 76 | new QLabel("", generalGroupBox ); |
74 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 77 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); |
75 | mReadOnly->setChecked( mResource->readOnly() ); | 78 | mReadOnly->setChecked( mResource->readOnly() ); |
76 | 79 | ||
77 | new QLabel("", generalGroupBox ); | 80 | new QLabel("", generalGroupBox ); |
78 | mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); | 81 | mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); |
79 | mIncludeInSync->setChecked( mResource->includeInSync() ); | 82 | mIncludeInSync->setChecked( mResource->includeInSync() ); |
80 | 83 | ||
81 | mName->setText( mResource->resourceName() ); | 84 | mName->setText( mResource->resourceName() ); |
82 | 85 | ||
83 | mainLayout->addWidget( generalGroupBox ); | 86 | mainLayout->addWidget( generalGroupBox ); |
84 | 87 | ||
85 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 88 | Q3GroupBox *resourceGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main ); |
86 | resourceGroupBox->layout()->setSpacing( spacingHint()); | 89 | resourceGroupBox->layout()->setSpacing( spacingHint()); |
87 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) | 90 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) |
88 | .arg( factory->typeName( resource->type() ) ) ); | 91 | .arg( factory->typeName( resource->type() ) ) ); |
89 | mainLayout->addWidget( resourceGroupBox ); | 92 | mainLayout->addWidget( resourceGroupBox ); |
90 | 93 | ||
91 | mainLayout->addStretch(); | 94 | mainLayout->addStretch(); |
92 | 95 | ||
93 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); | 96 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); |
94 | if ( mConfigWidget ) { | 97 | if ( mConfigWidget ) { |
95 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | 98 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), |
96 | SLOT( setReadOnly( bool ) ) ); | 99 | SLOT( setReadOnly( bool ) ) ); |
97 | connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ), | 100 | connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ), |
98 | SLOT( setIncludeInSync( bool ) ) ); | 101 | SLOT( setIncludeInSync( bool ) ) ); |
99 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), | 102 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), |
100 | SLOT( setPersistentReadOnly( bool ) ) ); | 103 | SLOT( setPersistentReadOnly( bool ) ) ); |
101 | mConfigWidget->setInEditMode( false ); | 104 | mConfigWidget->setInEditMode( false ); |
102 | mConfigWidget->loadSettings( mResource ); | 105 | mConfigWidget->loadSettings( mResource ); |
103 | mConfigWidget->show(); | 106 | mConfigWidget->show(); |
104 | 107 | ||
105 | } | 108 | } |
106 | 109 | ||
107 | 110 | ||
108 | connect( mName, SIGNAL( textChanged(const QString &)), | 111 | connect( mName, SIGNAL( textChanged(const QString &)), |
109 | SLOT( slotNameChanged(const QString &))); | 112 | SLOT( slotNameChanged(const QString &))); |
110 | 113 | ||
111 | slotNameChanged( mName->text() ); | 114 | slotNameChanged( mName->text() ); |
112 | 115 | ||
113 | //US setMinimumSize( 400, 250 ); | 116 | //US setMinimumSize( 400, 250 ); |
114 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | 117 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); |
115 | 118 | ||
116 | } | 119 | } |
117 | 120 | ||
118 | void ConfigDialog::setInEditMode( bool value ) | 121 | void ConfigDialog::setInEditMode( bool value ) |
119 | { | 122 | { |
120 | if ( mConfigWidget ) | 123 | if ( mConfigWidget ) |
121 | mConfigWidget->setInEditMode( value ); | 124 | mConfigWidget->setInEditMode( value ); |
122 | } | 125 | } |
123 | 126 | ||
124 | void ConfigDialog::slotNameChanged( const QString &text) | 127 | void ConfigDialog::slotNameChanged( const QString &text) |
125 | { | 128 | { |
126 | enableButtonOK( !text.isEmpty() ); | 129 | enableButtonOK( !text.isEmpty() ); |
127 | } | 130 | } |
128 | 131 | ||
129 | void ConfigDialog::setReadOnly( bool value ) | 132 | void ConfigDialog::setReadOnly( bool value ) |
130 | { | 133 | { |
131 | if (mPersistentReadOnly == false) | 134 | if (mPersistentReadOnly == false) |
132 | mReadOnly->setChecked( value ); | 135 | mReadOnly->setChecked( value ); |
133 | else | 136 | else |
134 | mReadOnly->setChecked( true ); | 137 | mReadOnly->setChecked( true ); |
135 | } | 138 | } |
136 | 139 | ||
137 | void ConfigDialog::setIncludeInSync( bool value ) | 140 | void ConfigDialog::setIncludeInSync( bool value ) |
138 | { | 141 | { |
139 | if (mPersistentReadOnly == false) | 142 | if (mPersistentReadOnly == false) |
140 | mIncludeInSync->setChecked( value ); | 143 | mIncludeInSync->setChecked( value ); |
141 | else | 144 | else |
142 | mIncludeInSync->setChecked( false ); | 145 | mIncludeInSync->setChecked( false ); |
143 | } | 146 | } |
144 | 147 | ||
145 | void ConfigDialog::setPersistentReadOnly( bool value ) | 148 | void ConfigDialog::setPersistentReadOnly( bool value ) |
146 | { | 149 | { |
147 | mPersistentReadOnly = value; | 150 | mPersistentReadOnly = value; |
148 | 151 | ||
149 | if (value == true) { | 152 | if (value == true) { |
150 | setReadOnly( true ); | 153 | setReadOnly( true ); |
151 | setIncludeInSync( false ); | 154 | setIncludeInSync( false ); |
152 | } | 155 | } |
153 | 156 | ||
154 | mReadOnly->setEnabled( !value ); | 157 | mReadOnly->setEnabled( !value ); |
155 | mIncludeInSync->setEnabled (!value ); | 158 | mIncludeInSync->setEnabled (!value ); |
156 | } | 159 | } |
157 | 160 | ||
158 | 161 | ||
159 | void ConfigDialog::accept() | 162 | void ConfigDialog::accept() |
160 | { | 163 | { |
161 | if ( mName->text().isEmpty() ) { | 164 | if ( mName->text().isEmpty() ) { |
162 | KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); | 165 | KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); |
163 | return; | 166 | return; |
164 | } | 167 | } |
165 | 168 | ||
166 | mResource->setResourceName( mName->text() ); | 169 | mResource->setResourceName( mName->text() ); |
167 | mResource->setReadOnly( mReadOnly->isChecked() ); | 170 | mResource->setReadOnly( mReadOnly->isChecked() ); |
168 | mResource->setIncludeInSync( mIncludeInSync->isChecked() ); | 171 | mResource->setIncludeInSync( mIncludeInSync->isChecked() ); |
169 | 172 | ||
170 | if ( mConfigWidget ) { | 173 | if ( mConfigWidget ) { |
171 | // First save generic information | 174 | // First save generic information |
172 | // Also save setting of specific resource type | 175 | // Also save setting of specific resource type |
173 | mConfigWidget->saveSettings( mResource ); | 176 | mConfigWidget->saveSettings( mResource ); |
174 | } | 177 | } |
175 | 178 | ||
176 | KDialog::accept(); | 179 | KDialog::accept(); |
177 | } | 180 | } |
178 | 181 | ||
179 | //US #include "configdialog.moc" | 182 | //US #include "configdialog.moc" |