author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kresources/configdialog.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'microkde/kresources/configdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | microkde/kresources/configdialog.cpp | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp new file mode 100644 index 0000000..48d9137 --- a/dev/null +++ b/microkde/kresources/configdialog.cpp | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | This file is part of libkresources. | ||
3 | |||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | ||
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||
7 | |||
8 | This library is free software; you can redistribute it and/or | ||
9 | modify it under the terms of the GNU Library General Public | ||
10 | License as published by the Free Software Foundation; either | ||
11 | version 2 of the License, or (at your option) any later version. | ||
12 | |||
13 | This library is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Library General Public License for more details. | ||
17 | |||
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 | ||
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
21 | Boston, MA 02111-1307, USA. | ||
22 | */ | ||
23 | |||
24 | #include <klocale.h> | ||
25 | #include <kglobal.h> | ||
26 | #include <kmessagebox.h> | ||
27 | |||
28 | #include <qgroupbox.h> | ||
29 | #include <qlabel.h> | ||
30 | #include <qlayout.h> | ||
31 | #include <qpushbutton.h> | ||
32 | |||
33 | #include <qcheckbox.h> | ||
34 | |||
35 | #include <kbuttonbox.h> | ||
36 | #include <kdialog.h> | ||
37 | #include <klineedit.h> | ||
38 | |||
39 | #include "factory.h" | ||
40 | #include "configwidget.h" | ||
41 | #include "configdialog.h" | ||
42 | |||
43 | using namespace KRES; | ||
44 | |||
45 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | ||
46 | /*const QString& type,*/ Resource* resource, /*KConfig *config, */const char *name ) | ||
47 | : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), | ||
48 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ) | ||
49 | { | ||
50 | Factory *factory = Factory::self( resourceFamily ); | ||
51 | |||
52 | //US resize( 250, 240 ); | ||
53 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); | ||
54 | |||
55 | //US QFrame *main = makeMainWidget(); | ||
56 | QFrame *main = plainPage(); | ||
57 | |||
58 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | ||
59 | |||
60 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | ||
61 | generalGroupBox->layout()->setSpacing( spacingHint() ); | ||
62 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | ||
63 | |||
64 | new QLabel( i18n( "Name:" ), generalGroupBox ); | ||
65 | |||
66 | mName = new KLineEdit( generalGroupBox ); | ||
67 | |||
68 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | ||
69 | |||
70 | mName->setText( mResource->resourceName() ); | ||
71 | mReadOnly->setChecked( mResource->readOnly() ); | ||
72 | |||
73 | mainLayout->addWidget( generalGroupBox ); | ||
74 | |||
75 | QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | ||
76 | resourceGroupBox->layout()->setSpacing( spacingHint()); | ||
77 | resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) | ||
78 | .arg( factory->typeName( resource->type() ) ) ); | ||
79 | mainLayout->addWidget( resourceGroupBox ); | ||
80 | |||
81 | mainLayout->addStretch(); | ||
82 | |||
83 | mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); | ||
84 | if ( mConfigWidget ) { | ||
85 | mConfigWidget->setInEditMode( false ); | ||
86 | mConfigWidget->loadSettings( mResource ); | ||
87 | mConfigWidget->show(); | ||
88 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | ||
89 | SLOT( setReadOnly( bool ) ) ); | ||
90 | } | ||
91 | |||
92 | connect( mName, SIGNAL( textChanged(const QString &)), | ||
93 | SLOT( slotNameChanged(const QString &))); | ||
94 | |||
95 | slotNameChanged( mName->text() ); | ||
96 | |||
97 | //US setMinimumSize( 400, 250 ); | ||
98 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | ||
99 | |||
100 | } | ||
101 | |||
102 | void ConfigDialog::setInEditMode( bool value ) | ||
103 | { | ||
104 | if ( mConfigWidget ) | ||
105 | mConfigWidget->setInEditMode( value ); | ||
106 | } | ||
107 | |||
108 | void ConfigDialog::slotNameChanged( const QString &text) | ||
109 | { | ||
110 | enableButtonOK( !text.isEmpty() ); | ||
111 | } | ||
112 | |||
113 | void ConfigDialog::setReadOnly( bool value ) | ||
114 | { | ||
115 | mReadOnly->setChecked( value ); | ||
116 | } | ||
117 | |||
118 | void ConfigDialog::accept() | ||
119 | { | ||
120 | if ( mName->text().isEmpty() ) { | ||
121 | KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | mResource->setResourceName( mName->text() ); | ||
126 | mResource->setReadOnly( mReadOnly->isChecked() ); | ||
127 | |||
128 | if ( mConfigWidget ) { | ||
129 | // First save generic information | ||
130 | // Also save setting of specific resource type | ||
131 | mConfigWidget->saveSettings( mResource ); | ||
132 | } | ||
133 | |||
134 | KDialog::accept(); | ||
135 | } | ||
136 | |||
137 | //US #include "configdialog.moc" | ||