author | zautrix <zautrix> | 2005-04-02 12:16:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-02 12:16:34 (UTC) |
commit | 997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (patch) (unidiff) | |
tree | f788b37459574b5cea0d2ab874882c6a396c240d /kaddressbook/views | |
parent | e0d51120d2f0c178115746e0c1357af40f95bc77 (diff) | |
download | kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.zip kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.gz kdepimpi-997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe.tar.bz2 |
more fixes
-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/configurecardviewdialog.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 6 |
4 files changed, 16 insertions, 2 deletions
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp index c243fa0..7386207 100644 --- a/kaddressbook/views/colorlistbox.cpp +++ b/kaddressbook/views/colorlistbox.cpp | |||
@@ -1,230 +1,235 @@ | |||
1 | /* | 1 | /* |
2 | * kmail: KDE mail client | 2 | * kmail: KDE mail client |
3 | * This file: Copyright (C) 2000 Espen Sand, espen@kde.org | 3 | * This file: Copyright (C) 2000 Espen Sand, espen@kde.org |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | 22 | ||
23 | #include <kcolordialog.h> | 23 | #include <kcolordialog.h> |
24 | 24 | ||
25 | #ifndef KAB_EMBEDDED | 25 | #ifndef KAB_EMBEDDED |
26 | #include <kcolordrag.h> | 26 | #include <kcolordrag.h> |
27 | #endif //KAB_EMBEDDED | 27 | #endif //KAB_EMBEDDED |
28 | 28 | ||
29 | #include "colorlistbox.h" | 29 | #include "colorlistbox.h" |
30 | 30 | ||
31 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) | 31 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) |
32 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) | 32 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) |
33 | { | 33 | { |
34 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); | 34 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); |
35 | connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); | ||
35 | setAcceptDrops( true); | 36 | setAcceptDrops( true); |
36 | } | 37 | } |
37 | 38 | ||
38 | 39 | ||
39 | void ColorListBox::setEnabled( bool state ) | 40 | void ColorListBox::setEnabled( bool state ) |
40 | { | 41 | { |
41 | if( state == isEnabled() ) | 42 | if( state == isEnabled() ) |
42 | { | 43 | { |
43 | return; | 44 | return; |
44 | } | 45 | } |
45 | 46 | ||
46 | QListBox::setEnabled( state ); | 47 | QListBox::setEnabled( state ); |
47 | for( uint i=0; i<count(); i++ ) | 48 | for( uint i=0; i<count(); i++ ) |
48 | { | 49 | { |
49 | updateItem( i ); | 50 | updateItem( i ); |
50 | } | 51 | } |
51 | } | 52 | } |
52 | 53 | ||
53 | 54 | ||
54 | void ColorListBox::setColor( uint index, const QColor &color ) | 55 | void ColorListBox::setColor( uint index, const QColor &color ) |
55 | { | 56 | { |
56 | if( index < count() ) | 57 | if( index < count() ) |
57 | { | 58 | { |
58 | ColorListItem *colorItem = (ColorListItem*)item(index); | 59 | ColorListItem *colorItem = (ColorListItem*)item(index); |
59 | colorItem->setColor(color); | 60 | colorItem->setColor(color); |
60 | updateItem( colorItem ); | 61 | updateItem( colorItem ); |
61 | } | 62 | } |
62 | } | 63 | } |
63 | 64 | ||
64 | 65 | ||
65 | QColor ColorListBox::color( uint index ) const | 66 | QColor ColorListBox::color( uint index ) const |
66 | { | 67 | { |
67 | if( index < count() ) | 68 | if( index < count() ) |
68 | { | 69 | { |
69 | ColorListItem *colorItem = (ColorListItem*)item(index); | 70 | ColorListItem *colorItem = (ColorListItem*)item(index); |
70 | return( colorItem->color() ); | 71 | return( colorItem->color() ); |
71 | } | 72 | } |
72 | else | 73 | else |
73 | { | 74 | { |
74 | return( black ); | 75 | return( black ); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | void ColorListBox::slotNewColor(QListBoxItem * i) | |
79 | { | ||
80 | if ( i ) | ||
81 | newColor( index( i ) ); | ||
82 | } | ||
78 | 83 | ||
79 | void ColorListBox::newColor( int index ) | 84 | void ColorListBox::newColor( int index ) |
80 | { | 85 | { |
81 | if( isEnabled() == false ) | 86 | if( isEnabled() == false ) |
82 | { | 87 | { |
83 | return; | 88 | return; |
84 | } | 89 | } |
85 | 90 | ||
86 | if( (uint)index < count() ) | 91 | if( (uint)index < count() ) |
87 | { | 92 | { |
88 | QColor c = color( index ); | 93 | QColor c = color( index ); |
89 | #ifndef KAB_EMBEDDED | 94 | #ifndef KAB_EMBEDDED |
90 | if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) | 95 | if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) |
91 | { | 96 | { |
92 | setColor( index, c ); | 97 | setColor( index, c ); |
93 | } | 98 | } |
94 | #else //KAB_EMBEDDED | 99 | #else //KAB_EMBEDDED |
95 | KColorDialog* k = new KColorDialog( this ); | 100 | KColorDialog* k = new KColorDialog( this ); |
96 | k->setColor( c ); | 101 | k->setColor( c ); |
97 | int res = k->exec(); | 102 | int res = k->exec(); |
98 | if ( res ) { | 103 | if ( res ) { |
99 | setColor( index, k->getColor() ); | 104 | setColor( index, k->getColor() ); |
100 | } | 105 | } |
101 | delete k; | 106 | delete k; |
102 | #endif //KAB_EMBEDDED | 107 | #endif //KAB_EMBEDDED |
103 | 108 | ||
104 | } | 109 | } |
105 | } | 110 | } |
106 | 111 | ||
107 | 112 | ||
108 | void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) | 113 | void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) |
109 | { | 114 | { |
110 | #ifndef KAB_EMBEDDED | 115 | #ifndef KAB_EMBEDDED |
111 | if( KColorDrag::canDecode(e) && isEnabled() ) | 116 | if( KColorDrag::canDecode(e) && isEnabled() ) |
112 | { | 117 | { |
113 | mCurrentOnDragEnter = currentItem(); | 118 | mCurrentOnDragEnter = currentItem(); |
114 | e->accept( true ); | 119 | e->accept( true ); |
115 | } | 120 | } |
116 | else | 121 | else |
117 | { | 122 | { |
118 | mCurrentOnDragEnter = -1; | 123 | mCurrentOnDragEnter = -1; |
119 | e->accept( false ); | 124 | e->accept( false ); |
120 | } | 125 | } |
121 | #else //KAB_EMBEDDED | 126 | #else //KAB_EMBEDDED |
122 | qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); | 127 | qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); |
123 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
124 | 129 | ||
125 | } | 130 | } |
126 | 131 | ||
127 | 132 | ||
128 | void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) | 133 | void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) |
129 | { | 134 | { |
130 | #ifndef KAB_EMBEDDED | 135 | #ifndef KAB_EMBEDDED |
131 | 136 | ||
132 | if( mCurrentOnDragEnter != -1 ) | 137 | if( mCurrentOnDragEnter != -1 ) |
133 | { | 138 | { |
134 | setCurrentItem( mCurrentOnDragEnter ); | 139 | setCurrentItem( mCurrentOnDragEnter ); |
135 | mCurrentOnDragEnter = -1; | 140 | mCurrentOnDragEnter = -1; |
136 | } | 141 | } |
137 | #else //KAB_EMBEDDED | 142 | #else //KAB_EMBEDDED |
138 | qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); | 143 | qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); |
139 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
140 | } | 145 | } |
141 | 146 | ||
142 | 147 | ||
143 | void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) | 148 | void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) |
144 | { | 149 | { |
145 | #ifndef KAB_EMBEDDED | 150 | #ifndef KAB_EMBEDDED |
146 | if( KColorDrag::canDecode(e) && isEnabled() ) | 151 | if( KColorDrag::canDecode(e) && isEnabled() ) |
147 | { | 152 | { |
148 | ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); | 153 | ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); |
149 | if( item != 0 ) | 154 | if( item != 0 ) |
150 | { | 155 | { |
151 | setCurrentItem ( item ); | 156 | setCurrentItem ( item ); |
152 | } | 157 | } |
153 | } | 158 | } |
154 | #else //KAB_EMBEDDED | 159 | #else //KAB_EMBEDDED |
155 | qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); | 160 | qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); |
156 | #endif //KAB_EMBEDDED | 161 | #endif //KAB_EMBEDDED |
157 | 162 | ||
158 | } | 163 | } |
159 | 164 | ||
160 | 165 | ||
161 | void ColorListBox::dropEvent( QDropEvent *e ) | 166 | void ColorListBox::dropEvent( QDropEvent *e ) |
162 | { | 167 | { |
163 | #ifndef KAB_EMBEDDED | 168 | #ifndef KAB_EMBEDDED |
164 | QColor color; | 169 | QColor color; |
165 | if( KColorDrag::decode( e, color ) ) | 170 | if( KColorDrag::decode( e, color ) ) |
166 | { | 171 | { |
167 | int index = currentItem(); | 172 | int index = currentItem(); |
168 | if( index != -1 ) | 173 | if( index != -1 ) |
169 | { | 174 | { |
170 | ColorListItem *colorItem = (ColorListItem*)item(index); | 175 | ColorListItem *colorItem = (ColorListItem*)item(index); |
171 | colorItem->setColor(color); | 176 | colorItem->setColor(color); |
172 | triggerUpdate( false ); // Redraw item | 177 | triggerUpdate( false ); // Redraw item |
173 | } | 178 | } |
174 | mCurrentOnDragEnter = -1; | 179 | mCurrentOnDragEnter = -1; |
175 | } | 180 | } |
176 | 181 | ||
177 | #else //KAB_EMBEDDED | 182 | #else //KAB_EMBEDDED |
178 | qDebug("ColorListBox::dropEvent drag&drop currently not supported"); | 183 | qDebug("ColorListBox::dropEvent drag&drop currently not supported"); |
179 | #endif //KAB_EMBEDDED | 184 | #endif //KAB_EMBEDDED |
180 | 185 | ||
181 | } | 186 | } |
182 | 187 | ||
183 | 188 | ||
184 | 189 | ||
185 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) | 190 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) |
186 | : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) | 191 | : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) |
187 | { | 192 | { |
188 | setText( text ); | 193 | setText( text ); |
189 | } | 194 | } |
190 | 195 | ||
191 | 196 | ||
192 | const QColor &ColorListItem::color( void ) | 197 | const QColor &ColorListItem::color( void ) |
193 | { | 198 | { |
194 | return( mColor ); | 199 | return( mColor ); |
195 | } | 200 | } |
196 | 201 | ||
197 | 202 | ||
198 | void ColorListItem::setColor( const QColor &color ) | 203 | void ColorListItem::setColor( const QColor &color ) |
199 | { | 204 | { |
200 | mColor = color; | 205 | mColor = color; |
201 | } | 206 | } |
202 | 207 | ||
203 | 208 | ||
204 | void ColorListItem::paint( QPainter *p ) | 209 | void ColorListItem::paint( QPainter *p ) |
205 | { | 210 | { |
206 | QFontMetrics fm = p->fontMetrics(); | 211 | QFontMetrics fm = p->fontMetrics(); |
207 | int h = fm.height(); | 212 | int h = fm.height(); |
208 | 213 | ||
209 | p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); | 214 | p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); |
210 | 215 | ||
211 | p->setPen( Qt::black ); | 216 | p->setPen( Qt::black ); |
212 | p->drawRect( 3, 1, mBoxWidth, h-1 ); | 217 | p->drawRect( 3, 1, mBoxWidth, h-1 ); |
213 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); | 218 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); |
214 | } | 219 | } |
215 | 220 | ||
216 | 221 | ||
217 | int ColorListItem::height(const QListBox *lb ) const | 222 | int ColorListItem::height(const QListBox *lb ) const |
218 | { | 223 | { |
219 | return( lb->fontMetrics().lineSpacing()+1 ); | 224 | return( lb->fontMetrics().lineSpacing()+1 ); |
220 | } | 225 | } |
221 | 226 | ||
222 | 227 | ||
223 | int ColorListItem::width(const QListBox *lb ) const | 228 | int ColorListItem::width(const QListBox *lb ) const |
224 | { | 229 | { |
225 | return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); | 230 | return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); |
226 | } | 231 | } |
227 | 232 | ||
228 | #ifndef KAB_EMBEDDED | 233 | #ifndef KAB_EMBEDDED |
229 | #include "colorlistbox.moc" | 234 | #include "colorlistbox.moc" |
230 | #endif //KAB_EMBEDDED | 235 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h index 4a0e705..bb91484 100644 --- a/kaddressbook/views/colorlistbox.h +++ b/kaddressbook/views/colorlistbox.h | |||
@@ -1,76 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | * kmail: KDE mail client | 2 | * kmail: KDE mail client |
3 | * This file: Copyright (C) 2000 Espen Sand, espen@kde.org | 3 | * This file: Copyright (C) 2000 Espen Sand, espen@kde.org |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef _COLOR_LISTBOX_H_ | 21 | #ifndef _COLOR_LISTBOX_H_ |
22 | #define _COLOR_LISTBOX_H_ | 22 | #define _COLOR_LISTBOX_H_ |
23 | 23 | ||
24 | #include <klistbox.h> | 24 | #include <klistbox.h> |
25 | 25 | ||
26 | class QDragEnterEvent; | 26 | class QDragEnterEvent; |
27 | class QDragLeaveEvent; | 27 | class QDragLeaveEvent; |
28 | class QDragMoveEvent; | 28 | class QDragMoveEvent; |
29 | class QDropEvent; | 29 | class QDropEvent; |
30 | 30 | ||
31 | class ColorListBox : public KListBox | 31 | class ColorListBox : public KListBox |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
36 | ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); | 36 | ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); |
37 | void setColor( uint index, const QColor &color ); | 37 | void setColor( uint index, const QColor &color ); |
38 | QColor color( uint index ) const; | 38 | QColor color( uint index ) const; |
39 | 39 | ||
40 | public slots: | 40 | public slots: |
41 | virtual void setEnabled( bool state ); | 41 | virtual void setEnabled( bool state ); |
42 | 42 | ||
43 | protected: | 43 | protected: |
44 | void dragEnterEvent( QDragEnterEvent *e ); | 44 | void dragEnterEvent( QDragEnterEvent *e ); |
45 | void dragLeaveEvent( QDragLeaveEvent *e ); | 45 | void dragLeaveEvent( QDragLeaveEvent *e ); |
46 | void dragMoveEvent( QDragMoveEvent *e ); | 46 | void dragMoveEvent( QDragMoveEvent *e ); |
47 | void dropEvent( QDropEvent *e ); | 47 | void dropEvent( QDropEvent *e ); |
48 | 48 | ||
49 | private slots: | 49 | private slots: |
50 | void newColor( int index ); | 50 | void newColor( int index ); |
51 | void slotNewColor(QListBoxItem * i); | ||
51 | 52 | ||
52 | private: | 53 | private: |
53 | int mCurrentOnDragEnter; | 54 | int mCurrentOnDragEnter; |
54 | 55 | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | 58 | ||
58 | class ColorListItem : public QListBoxItem | 59 | class ColorListItem : public QListBoxItem |
59 | { | 60 | { |
60 | public: | 61 | public: |
61 | ColorListItem( const QString &text, const QColor &color=Qt::black ); | 62 | ColorListItem( const QString &text, const QColor &color=Qt::black ); |
62 | const QColor &color( void ); | 63 | const QColor &color( void ); |
63 | void setColor( const QColor &color ); | 64 | void setColor( const QColor &color ); |
64 | 65 | ||
65 | protected: | 66 | protected: |
66 | virtual void paint( QPainter * ); | 67 | virtual void paint( QPainter * ); |
67 | virtual int height( const QListBox * ) const; | 68 | virtual int height( const QListBox * ) const; |
68 | virtual int width( const QListBox * ) const; | 69 | virtual int width( const QListBox * ) const; |
69 | 70 | ||
70 | private: | 71 | private: |
71 | QColor mColor; | 72 | QColor mColor; |
72 | int mBoxWidth; | 73 | int mBoxWidth; |
73 | }; | 74 | }; |
74 | 75 | ||
75 | #endif | 76 | #endif |
76 | 77 | ||
diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp index 366e54c..e0fbd21 100644 --- a/kaddressbook/views/configurecardviewdialog.cpp +++ b/kaddressbook/views/configurecardviewdialog.cpp | |||
@@ -1,365 +1,369 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <qgroupbox.h> | 29 | #include <qgroupbox.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kglobalsettings.h> | 36 | #include <kglobalsettings.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kfontdialog.h> | 40 | #include <kfontdialog.h> |
41 | 41 | ||
42 | #ifndef KAB_EMBEDDED | 42 | #ifndef KAB_EMBEDDED |
43 | #include <kpushbutton.h> | 43 | #include <kpushbutton.h> |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #endif //KAB_EMBEDDED | 46 | #endif //KAB_EMBEDDED |
47 | 47 | ||
48 | #include "colorlistbox.h" | 48 | #include "colorlistbox.h" |
49 | 49 | ||
50 | #include "configurecardviewdialog.h" | 50 | #include "configurecardviewdialog.h" |
51 | 51 | ||
52 | ///////////////////////////////// | 52 | ///////////////////////////////// |
53 | // ConfigureCardViewDialog | 53 | // ConfigureCardViewDialog |
54 | 54 | ||
55 | ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, | 55 | ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name ) | 56 | const char *name ) |
57 | : ViewConfigureWidget( ab, parent, name ) | 57 | : ViewConfigureWidget( ab, parent, name ) |
58 | { | 58 | { |
59 | #ifndef KAB_EMBEDDED | 59 | #ifndef KAB_EMBEDDED |
60 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, | 60 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, |
61 | DesktopIcon( "looknfeel" ) ); | 61 | DesktopIcon( "looknfeel" ) ); |
62 | #else //KAB_EMBEDDED | 62 | #else //KAB_EMBEDDED |
63 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, | 63 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, |
64 | KGlobal::iconLoader()->loadIcon( "looknfeel", | 64 | KGlobal::iconLoader()->loadIcon( "looknfeel", |
65 | KIcon::Panel ) ); | 65 | KIcon::Panel ) ); |
66 | #endif //KAB_EMBEDDED | 66 | #endif //KAB_EMBEDDED |
67 | 67 | ||
68 | mAdvancedPage = new CardViewLookNFeelPage( page ); | 68 | mAdvancedPage = new CardViewLookNFeelPage( page ); |
69 | } | 69 | } |
70 | 70 | ||
71 | ConfigureCardViewWidget::~ConfigureCardViewWidget() | 71 | ConfigureCardViewWidget::~ConfigureCardViewWidget() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void ConfigureCardViewWidget::restoreSettings( KConfig *config ) | 75 | void ConfigureCardViewWidget::restoreSettings( KConfig *config ) |
76 | { | 76 | { |
77 | ViewConfigureWidget::restoreSettings( config ); | 77 | ViewConfigureWidget::restoreSettings( config ); |
78 | 78 | ||
79 | mAdvancedPage->restoreSettings( config ); | 79 | mAdvancedPage->restoreSettings( config ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void ConfigureCardViewWidget::saveSettings( KConfig *config ) | 82 | void ConfigureCardViewWidget::saveSettings( KConfig *config ) |
83 | { | 83 | { |
84 | ViewConfigureWidget::saveSettings( config ); | 84 | ViewConfigureWidget::saveSettings( config ); |
85 | 85 | ||
86 | mAdvancedPage->saveSettings( config ); | 86 | mAdvancedPage->saveSettings( config ); |
87 | } | 87 | } |
88 | 88 | ||
89 | //////////////////////// | 89 | //////////////////////// |
90 | // CardViewLookNFeelPage | 90 | // CardViewLookNFeelPage |
91 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) | 91 | CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) |
92 | : QVBox( parent, name ) | 92 | : QVBox( parent, name ) |
93 | { | 93 | { |
94 | initGUI(); | 94 | initGUI(); |
95 | } | 95 | } |
96 | 96 | ||
97 | CardViewLookNFeelPage::~CardViewLookNFeelPage() | 97 | CardViewLookNFeelPage::~CardViewLookNFeelPage() |
98 | { | 98 | { |
99 | } | 99 | } |
100 | 100 | ||
101 | void CardViewLookNFeelPage::restoreSettings( KConfig *config ) | 101 | void CardViewLookNFeelPage::restoreSettings( KConfig *config ) |
102 | { | 102 | { |
103 | // colors | 103 | // colors |
104 | cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); | 104 | cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); |
105 | QColor c; | 105 | QColor c; |
106 | qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); | 106 | qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); |
107 | 107 | ||
108 | #ifndef KAB_EMBEDDED | 108 | #ifndef KAB_EMBEDDED |
109 | c = KGlobalSettings::baseColor(); | 109 | c = KGlobalSettings::baseColor(); |
110 | #else //KAB_EMBEDDED | 110 | #else //KAB_EMBEDDED |
111 | c = QColor(0,0,0); | 111 | c = QColor(0,0,0); |
112 | #endif //KAB_EMBEDDED | 112 | #endif //KAB_EMBEDDED |
113 | 113 | ||
114 | c = colorGroup().background(); | 114 | c = colorGroup().background(); |
115 | lbColors->insertItem( new ColorListItem( i18n("Background Color"), | 115 | lbColors->insertItem( new ColorListItem( i18n("Background Color"), |
116 | config->readColorEntry( "BackgroundColor", &c ) ) ); | 116 | config->readColorEntry( "BackgroundColor", &c ) ) ); |
117 | c = colorGroup().foreground(); | 117 | c = colorGroup().foreground(); |
118 | lbColors->insertItem( new ColorListItem( i18n("Text Color"), | 118 | lbColors->insertItem( new ColorListItem( i18n("Text Color"), |
119 | config->readColorEntry( "TextColor", &c ) ) ); | 119 | config->readColorEntry( "TextColor", &c ) ) ); |
120 | c = colorGroup().button(); | 120 | c = colorGroup().button(); |
121 | lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), | 121 | lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), |
122 | config->readColorEntry( "HeaderColor", &c ) ) ); | 122 | config->readColorEntry( "HeaderColor", &c ) ) ); |
123 | c = colorGroup().buttonText(); | 123 | c = colorGroup().buttonText(); |
124 | lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), | 124 | lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), |
125 | config->readColorEntry( "HeaderTextColor", &c ) ) ); | 125 | config->readColorEntry( "HeaderTextColor", &c ) ) ); |
126 | c = colorGroup().highlight(); | 126 | c = colorGroup().highlight(); |
127 | lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), | 127 | lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), |
128 | config->readColorEntry( "HighlightColor", &c ) ) ); | 128 | config->readColorEntry( "HighlightColor", &c ) ) ); |
129 | c = colorGroup().highlightedText(); | 129 | c = colorGroup().highlightedText(); |
130 | lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), | 130 | lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), |
131 | config->readColorEntry( "HighlightedTextColor", &c ) ) ); | 131 | config->readColorEntry( "HighlightedTextColor", &c ) ) ); |
132 | 132 | ||
133 | enableColors(); | 133 | enableColors(); |
134 | 134 | ||
135 | // fonts | 135 | // fonts |
136 | QFont fnt = font(); | 136 | QFont fnt = font(); |
137 | updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); | 137 | updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); |
138 | fnt.setBold( true ); | 138 | fnt.setBold( true ); |
139 | updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); | 139 | updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); |
140 | cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); | 140 | cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); |
141 | enableFonts(); | 141 | enableFonts(); |
142 | 142 | ||
143 | // layout | 143 | // layout |
144 | sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); | 144 | sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); |
145 | sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); | 145 | sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); |
146 | sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); | 146 | sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); |
147 | cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); | 147 | cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); |
148 | cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); | 148 | cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); |
149 | 149 | ||
150 | // behaviour | 150 | // behaviour |
151 | cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); | 151 | cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); |
152 | cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); | 152 | cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void CardViewLookNFeelPage::saveSettings( KConfig *config ) | 155 | void CardViewLookNFeelPage::saveSettings( KConfig *config ) |
156 | { | 156 | { |
157 | // colors | 157 | // colors |
158 | config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); | 158 | config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); |
159 | if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. | 159 | if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. |
160 | { | 160 | { |
161 | config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); | 161 | config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); |
162 | config->writeEntry( "TextColor", lbColors->color( 1 ) ); | 162 | config->writeEntry( "TextColor", lbColors->color( 1 ) ); |
163 | config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); | 163 | config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); |
164 | config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); | 164 | config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); |
165 | config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); | 165 | config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); |
166 | config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); | 166 | config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); |
167 | } | 167 | } |
168 | // fonts | 168 | // fonts |
169 | config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); | 169 | config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); |
170 | if ( cbEnableCustomFonts->isChecked() ) | 170 | if ( cbEnableCustomFonts->isChecked() ) |
171 | { | 171 | { |
172 | config->writeEntry( "TextFont", lTextFont->font() ); | 172 | config->writeEntry( "TextFont", lTextFont->font() ); |
173 | config->writeEntry( "HeaderFont", lHeaderFont->font() ); | 173 | config->writeEntry( "HeaderFont", lHeaderFont->font() ); |
174 | } | 174 | } |
175 | // layout | 175 | // layout |
176 | config->writeEntry( "ItemMargin", sbMargin->value() ); | 176 | config->writeEntry( "ItemMargin", sbMargin->value() ); |
177 | config->writeEntry( "ItemSpacing", sbSpacing->value() ); | 177 | config->writeEntry( "ItemSpacing", sbSpacing->value() ); |
178 | config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); | 178 | config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); |
179 | config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); | 179 | config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); |
180 | config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); | 180 | config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); |
181 | 181 | ||
182 | // behaviour | 182 | // behaviour |
183 | config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); | 183 | config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); |
184 | config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); | 184 | config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); |
185 | } | 185 | } |
186 | 186 | ||
187 | void CardViewLookNFeelPage::setTextFont() | 187 | void CardViewLookNFeelPage::setTextFont() |
188 | { | 188 | { |
189 | QFont f( lTextFont->font() ); | 189 | QFont f( lTextFont->font() ); |
190 | #ifndef KAB_EMBEDDED | 190 | #ifndef KAB_EMBEDDED |
191 | if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) | 191 | if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) |
192 | updateFontLabel( f, lTextFont ); | 192 | updateFontLabel( f, lTextFont ); |
193 | #else //KAB_EMBEDDED | 193 | #else //KAB_EMBEDDED |
194 | bool ok; | 194 | bool ok; |
195 | QFont fout = KFontDialog::getFont( f, ok); | 195 | QFont fout = KFontDialog::getFont( f, ok); |
196 | if ( ok ) | 196 | if ( ok ) |
197 | updateFontLabel( fout, lTextFont ); | 197 | updateFontLabel( fout, lTextFont ); |
198 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
199 | } | 199 | } |
200 | 200 | ||
201 | void CardViewLookNFeelPage::setHeaderFont() | 201 | void CardViewLookNFeelPage::setHeaderFont() |
202 | { | 202 | { |
203 | QFont f( lHeaderFont->font() ); | 203 | QFont f( lHeaderFont->font() ); |
204 | #ifndef KAB_EMBEDDED | 204 | #ifndef KAB_EMBEDDED |
205 | if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) | 205 | if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) |
206 | updateFontLabel( f, lHeaderFont ); | 206 | updateFontLabel( f, lHeaderFont ); |
207 | #else //KAB_EMBEDDED | 207 | #else //KAB_EMBEDDED |
208 | bool ok; | 208 | bool ok; |
209 | QFont fout = KFontDialog::getFont( f, ok); | 209 | QFont fout = KFontDialog::getFont( f, ok); |
210 | if ( ok ) | 210 | if ( ok ) |
211 | updateFontLabel( fout, lHeaderFont ); | 211 | updateFontLabel( fout, lHeaderFont ); |
212 | #endif //KAB_EMBEDDED | 212 | #endif //KAB_EMBEDDED |
213 | } | 213 | } |
214 | 214 | ||
215 | void CardViewLookNFeelPage::enableFonts() | 215 | void CardViewLookNFeelPage::enableFonts() |
216 | { | 216 | { |
217 | vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); | 217 | vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); |
218 | if ( cbEnableCustomFonts->isChecked() ) | ||
219 | vbFonts->setFocus(); | ||
218 | } | 220 | } |
219 | 221 | ||
220 | void CardViewLookNFeelPage::enableColors() | 222 | void CardViewLookNFeelPage::enableColors() |
221 | { | 223 | { |
222 | lbColors->setEnabled( cbEnableCustomColors->isChecked() ); | 224 | lbColors->setEnabled( cbEnableCustomColors->isChecked() ); |
225 | if ( cbEnableCustomColors->isChecked() ) | ||
226 | lbColors->setFocus(); | ||
223 | } | 227 | } |
224 | 228 | ||
225 | void CardViewLookNFeelPage::initGUI() | 229 | void CardViewLookNFeelPage::initGUI() |
226 | { | 230 | { |
227 | int spacing = KDialog::spacingHint(); | 231 | int spacing = KDialog::spacingHint(); |
228 | int margin = KDialog::marginHint(); | 232 | int margin = KDialog::marginHint(); |
229 | 233 | ||
230 | QTabWidget *tabs = new QTabWidget( this ); | 234 | QTabWidget *tabs = new QTabWidget( this ); |
231 | 235 | ||
232 | // Layout | 236 | // Layout |
233 | QVBox *loTab = new QVBox( this, "layouttab" ); | 237 | QVBox *loTab = new QVBox( this, "layouttab" ); |
234 | 238 | ||
235 | loTab->setSpacing( spacing ); | 239 | loTab->setSpacing( spacing ); |
236 | loTab->setMargin( margin ); | 240 | loTab->setMargin( margin ); |
237 | 241 | ||
238 | QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); | 242 | QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); |
239 | 243 | ||
240 | cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); | 244 | cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); |
241 | 245 | ||
242 | QHBox *hbSW = new QHBox( gbGeneral ); | 246 | QHBox *hbSW = new QHBox( gbGeneral ); |
243 | QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); | 247 | QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); |
244 | sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); | 248 | sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); |
245 | lSW->setBuddy( sbSepWidth); | 249 | lSW->setBuddy( sbSepWidth); |
246 | 250 | ||
247 | QHBox *hbPadding = new QHBox( gbGeneral ); | 251 | QHBox *hbPadding = new QHBox( gbGeneral ); |
248 | QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); | 252 | QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); |
249 | sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); | 253 | sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); |
250 | lSpacing->setBuddy( sbSpacing ); | 254 | lSpacing->setBuddy( sbSpacing ); |
251 | 255 | ||
252 | QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); | 256 | QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); |
253 | 257 | ||
254 | QHBox *hbMargin = new QHBox( gbCards ); | 258 | QHBox *hbMargin = new QHBox( gbCards ); |
255 | QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); | 259 | QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); |
256 | sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); | 260 | sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); |
257 | lMargin->setBuddy( sbMargin ); | 261 | lMargin->setBuddy( sbMargin ); |
258 | 262 | ||
259 | cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); | 263 | cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); |
260 | 264 | ||
261 | loTab->setStretchFactor( new QWidget( loTab ), 1 ); | 265 | loTab->setStretchFactor( new QWidget( loTab ), 1 ); |
262 | 266 | ||
263 | QWhatsThis::add( sbMargin, i18n( | 267 | QWhatsThis::add( sbMargin, i18n( |
264 | "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " | 268 | "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " |
265 | "incrementing the item margin will add space between the focus rectangle and the item data." | 269 | "incrementing the item margin will add space between the focus rectangle and the item data." |
266 | ) ); | 270 | ) ); |
267 | QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); | 271 | QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); |
268 | QWhatsThis::add( sbSpacing, i18n( | 272 | QWhatsThis::add( sbSpacing, i18n( |
269 | "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " | 273 | "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " |
270 | "borders, other items or column separators." | 274 | "borders, other items or column separators." |
271 | ) ); | 275 | ) ); |
272 | QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); | 276 | QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); |
273 | QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); | 277 | QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); |
274 | QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); | 278 | QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); |
275 | 279 | ||
276 | tabs->addTab( loTab, i18n("&Layout") ); | 280 | tabs->addTab( loTab, i18n("&Layout") ); |
277 | 281 | ||
278 | // Colors | 282 | // Colors |
279 | QVBox *colorTab = new QVBox( this, "colortab" ); | 283 | QVBox *colorTab = new QVBox( this, "colortab" ); |
280 | colorTab->setSpacing( spacing ); | 284 | colorTab->setSpacing( spacing ); |
281 | colorTab->setMargin( spacing ); | 285 | colorTab->setMargin( spacing ); |
282 | cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); | 286 | cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); |
283 | connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); | 287 | connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); |
284 | lbColors = new ColorListBox( colorTab ); | 288 | lbColors = new ColorListBox( colorTab ); |
285 | tabs->addTab( colorTab, i18n("&Colors") ); | 289 | tabs->addTab( colorTab, i18n("&Colors") ); |
286 | 290 | ||
287 | QWhatsThis::add( cbEnableCustomColors, i18n( | 291 | QWhatsThis::add( cbEnableCustomColors, i18n( |
288 | "If custom colors are enabled, you may choose the colors for the view below. " | 292 | "If custom colors are enabled, you may choose the colors for the view below. " |
289 | "Otherwise colors from your current KDE color scheme are used." | 293 | "Otherwise colors from your current KDE color scheme are used." |
290 | ) ); | 294 | ) ); |
291 | QWhatsThis::add( lbColors, i18n( | 295 | QWhatsThis::add( lbColors, i18n( |
292 | "Double click or press RETURN on a item to select a color for the related strings in the view." | 296 | "Double click or press RETURN on a item to select a color for the related strings in the view." |
293 | ) ); | 297 | ) ); |
294 | 298 | ||
295 | // Fonts | 299 | // Fonts |
296 | QVBox *fntTab = new QVBox( this, "fonttab" ); | 300 | QVBox *fntTab = new QVBox( this, "fonttab" ); |
297 | 301 | ||
298 | fntTab->setSpacing( spacing ); | 302 | fntTab->setSpacing( spacing ); |
299 | fntTab->setMargin( spacing ); | 303 | fntTab->setMargin( spacing ); |
300 | 304 | ||
301 | cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); | 305 | cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); |
302 | connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); | 306 | connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); |
303 | 307 | ||
304 | vbFonts = new QWidget( fntTab ); | 308 | vbFonts = new QWidget( fntTab ); |
305 | QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); | 309 | QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); |
306 | gFnts->setSpacing( spacing ); | 310 | gFnts->setSpacing( spacing ); |
307 | gFnts->setAutoAdd( true ); | 311 | gFnts->setAutoAdd( true ); |
308 | gFnts->setColStretch( 1, 1 ); | 312 | gFnts->setColStretch( 1, 1 ); |
309 | QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); | 313 | QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); |
310 | lTextFont = new QLabel( vbFonts ); | 314 | lTextFont = new QLabel( vbFonts ); |
311 | lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); | 315 | lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); |
312 | #ifndef KAB_EMBEDDED | 316 | #ifndef KAB_EMBEDDED |
313 | btnFont = new KPushButton( i18n("Choose..."), vbFonts ); | 317 | btnFont = new KPushButton( i18n("Choose..."), vbFonts ); |
314 | #else //KAB_EMBEDDED | 318 | #else //KAB_EMBEDDED |
315 | btnFont = new QPushButton( i18n("Choose..."), vbFonts ); | 319 | btnFont = new QPushButton( i18n("Choose..."), vbFonts ); |
316 | #endif //KAB_EMBEDDED | 320 | #endif //KAB_EMBEDDED |
317 | 321 | ||
318 | lTFnt->setBuddy( btnFont ); | 322 | lTFnt->setBuddy( btnFont ); |
319 | 323 | ||
320 | connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); | 324 | connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); |
321 | 325 | ||
322 | QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); | 326 | QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); |
323 | lHeaderFont = new QLabel( vbFonts ); | 327 | lHeaderFont = new QLabel( vbFonts ); |
324 | lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); | 328 | lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); |
325 | #ifndef KAB_EMBEDDED | 329 | #ifndef KAB_EMBEDDED |
326 | btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); | 330 | btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); |
327 | #else //KAB_EMBEDDED | 331 | #else //KAB_EMBEDDED |
328 | btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); | 332 | btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); |
329 | #endif //KAB_EMBEDDED | 333 | #endif //KAB_EMBEDDED |
330 | lHFnt->setBuddy( btnHeaderFont ); | 334 | lHFnt->setBuddy( btnHeaderFont ); |
331 | connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); | 335 | connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); |
332 | 336 | ||
333 | fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); | 337 | fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); |
334 | 338 | ||
335 | QWhatsThis::add( cbEnableCustomFonts, i18n( | 339 | QWhatsThis::add( cbEnableCustomFonts, i18n( |
336 | "If custom fonts are enabled, you may choose which fonts to use for this view below. " | 340 | "If custom fonts are enabled, you may choose which fonts to use for this view below. " |
337 | "Otherwise the default KDE font will be used, in bold style for the header and " | 341 | "Otherwise the default KDE font will be used, in bold style for the header and " |
338 | "normal style for the data." | 342 | "normal style for the data." |
339 | ) ); | 343 | ) ); |
340 | 344 | ||
341 | tabs->addTab( fntTab, i18n("&Fonts") ); | 345 | tabs->addTab( fntTab, i18n("&Fonts") ); |
342 | 346 | ||
343 | // Behaviour | 347 | // Behaviour |
344 | QVBox *behaviourTab = new QVBox( this ); | 348 | QVBox *behaviourTab = new QVBox( this ); |
345 | behaviourTab->setMargin( margin ); | 349 | behaviourTab->setMargin( margin ); |
346 | behaviourTab->setSpacing( spacing ); | 350 | behaviourTab->setSpacing( spacing ); |
347 | 351 | ||
348 | cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); | 352 | cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); |
349 | cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); | 353 | cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); |
350 | 354 | ||
351 | behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); | 355 | behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); |
352 | 356 | ||
353 | tabs->addTab( behaviourTab, i18n("Be&havior") ); | 357 | tabs->addTab( behaviourTab, i18n("Be&havior") ); |
354 | 358 | ||
355 | } | 359 | } |
356 | 360 | ||
357 | void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 361 | void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) |
358 | { | 362 | { |
359 | l->setFont( fnt ); | 363 | l->setFont( fnt ); |
360 | l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); | 364 | l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); |
361 | } | 365 | } |
362 | 366 | ||
363 | #ifndef KAB_EMBEDDED | 367 | #ifndef KAB_EMBEDDED |
364 | #include "configurecardviewdialog.moc" | 368 | #include "configurecardviewdialog.moc" |
365 | #endif //KAB_EMBEDDED | 369 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp index 8bcceb2..0e36abd 100644 --- a/kaddressbook/views/configuretableviewdialog.cpp +++ b/kaddressbook/views/configuretableviewdialog.cpp | |||
@@ -1,341 +1,345 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qradiobutton.h> | 28 | #include <qradiobutton.h> |
29 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | #include <qbuttongroup.h> | 31 | #include <qbuttongroup.h> |
32 | #include <qtabwidget.h> | 32 | #include <qtabwidget.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | 35 | ||
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <klineedit.h> | 38 | #include <klineedit.h> |
39 | #include <kurlrequester.h> | 39 | #include <kurlrequester.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | #include <kfontdialog.h> | 41 | #include <kfontdialog.h> |
42 | 42 | ||
43 | #ifndef KAB_EMBEDDED | 43 | #ifndef KAB_EMBEDDED |
44 | #include <kimageio.h> | 44 | #include <kimageio.h> |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #endif //KAB_EMBEDDED | 46 | #endif //KAB_EMBEDDED |
47 | 47 | ||
48 | #include <kconfig.h> | 48 | #include <kconfig.h> |
49 | 49 | ||
50 | #include "colorlistbox.h" | 50 | #include "colorlistbox.h" |
51 | 51 | ||
52 | #include "configuretableviewdialog.h" | 52 | #include "configuretableviewdialog.h" |
53 | 53 | ||
54 | ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, | 54 | ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, |
55 | QWidget *parent, | 55 | QWidget *parent, |
56 | const char *name ) | 56 | const char *name ) |
57 | : ViewConfigureWidget( ab, parent, name ) | 57 | : ViewConfigureWidget( ab, parent, name ) |
58 | { | 58 | { |
59 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, | 59 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, |
60 | KGlobal::iconLoader()->loadIcon( "looknfeel", | 60 | KGlobal::iconLoader()->loadIcon( "looknfeel", |
61 | KIcon::Panel ) ); | 61 | KIcon::Panel ) ); |
62 | 62 | ||
63 | mPage = new LookAndFeelPage( page ); | 63 | mPage = new LookAndFeelPage( page ); |
64 | } | 64 | } |
65 | 65 | ||
66 | ConfigureTableViewWidget::~ConfigureTableViewWidget() | 66 | ConfigureTableViewWidget::~ConfigureTableViewWidget() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void ConfigureTableViewWidget::restoreSettings( KConfig *config ) | 70 | void ConfigureTableViewWidget::restoreSettings( KConfig *config ) |
71 | { | 71 | { |
72 | ViewConfigureWidget::restoreSettings( config ); | 72 | ViewConfigureWidget::restoreSettings( config ); |
73 | 73 | ||
74 | mPage->restoreSettings( config ); | 74 | mPage->restoreSettings( config ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void ConfigureTableViewWidget::saveSettings( KConfig *config ) | 77 | void ConfigureTableViewWidget::saveSettings( KConfig *config ) |
78 | { | 78 | { |
79 | ViewConfigureWidget::saveSettings( config ); | 79 | ViewConfigureWidget::saveSettings( config ); |
80 | 80 | ||
81 | mPage->saveSettings( config ); | 81 | mPage->saveSettings( config ); |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) | 86 | LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) |
87 | : QVBox(parent, name) | 87 | : QVBox(parent, name) |
88 | { | 88 | { |
89 | initGUI(); | 89 | initGUI(); |
90 | 90 | ||
91 | // Set initial state | 91 | // Set initial state |
92 | enableBackgroundToggled(mBackgroundBox->isChecked()); | 92 | enableBackgroundToggled(mBackgroundBox->isChecked()); |
93 | } | 93 | } |
94 | 94 | ||
95 | void LookAndFeelPage::restoreSettings( KConfig *config ) | 95 | void LookAndFeelPage::restoreSettings( KConfig *config ) |
96 | { | 96 | { |
97 | mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); | 97 | mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); |
98 | mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); | 98 | mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); |
99 | mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); | 99 | mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); |
100 | 100 | ||
101 | if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) | 101 | if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) |
102 | mNoneButton->setChecked(true); | 102 | mNoneButton->setChecked(true); |
103 | 103 | ||
104 | mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); | 104 | mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); |
105 | mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); | 105 | mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); |
106 | 106 | ||
107 | // colors | 107 | // colors |
108 | cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); | 108 | cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); |
109 | QColor c; | 109 | QColor c; |
110 | qDebug("LookAndFeelPage::restoreSettings make base color configurable"); | 110 | qDebug("LookAndFeelPage::restoreSettings make base color configurable"); |
111 | 111 | ||
112 | #ifndef KAB_EMBEDDED | 112 | #ifndef KAB_EMBEDDED |
113 | c = KGlobalSettings::baseColor(); | 113 | c = KGlobalSettings::baseColor(); |
114 | #else //KAB_EMBEDDED | 114 | #else //KAB_EMBEDDED |
115 | c = QColor(0,0,0); | 115 | c = QColor(0,0,0); |
116 | #endif //KAB_EMBEDDED | 116 | #endif //KAB_EMBEDDED |
117 | 117 | ||
118 | c = colorGroup().background(); | 118 | c = colorGroup().background(); |
119 | lbColors->insertItem( new ColorListItem( i18n("Background Color"), | 119 | lbColors->insertItem( new ColorListItem( i18n("Background Color"), |
120 | config->readColorEntry( "BackgroundColor", &c ) ) ); | 120 | config->readColorEntry( "BackgroundColor", &c ) ) ); |
121 | c = colorGroup().foreground(); | 121 | c = colorGroup().foreground(); |
122 | lbColors->insertItem( new ColorListItem( i18n("Text Color"), | 122 | lbColors->insertItem( new ColorListItem( i18n("Text Color"), |
123 | config->readColorEntry( "TextColor", &c ) ) ); | 123 | config->readColorEntry( "TextColor", &c ) ) ); |
124 | c = colorGroup().button(); | 124 | c = colorGroup().button(); |
125 | lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), | 125 | lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), |
126 | config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); | 126 | config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); |
127 | c = colorGroup().buttonText(); | 127 | c = colorGroup().buttonText(); |
128 | lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), | 128 | lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), |
129 | config->readColorEntry( "HeaderTextColor", &c ) ) ); | 129 | config->readColorEntry( "HeaderTextColor", &c ) ) ); |
130 | c = colorGroup().highlight(); | 130 | c = colorGroup().highlight(); |
131 | lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), | 131 | lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), |
132 | config->readColorEntry( "HighlightColor", &c ) ) ); | 132 | config->readColorEntry( "HighlightColor", &c ) ) ); |
133 | c = colorGroup().highlightedText(); | 133 | c = colorGroup().highlightedText(); |
134 | lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), | 134 | lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), |
135 | config->readColorEntry( "HighlightedTextColor", &c ) ) ); | 135 | config->readColorEntry( "HighlightedTextColor", &c ) ) ); |
136 | c = colorGroup().background(); | 136 | c = colorGroup().background(); |
137 | lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), | 137 | lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), |
138 | config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); | 138 | config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); |
139 | 139 | ||
140 | enableColors(); | 140 | enableColors(); |
141 | 141 | ||
142 | // fonts | 142 | // fonts |
143 | QFont fnt = font(); | 143 | QFont fnt = font(); |
144 | updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); | 144 | updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); |
145 | fnt.setBold( true ); | 145 | fnt.setBold( true ); |
146 | updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); | 146 | updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); |
147 | cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); | 147 | cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); |
148 | enableFonts(); | 148 | enableFonts(); |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | void LookAndFeelPage::saveSettings( KConfig *config ) | 152 | void LookAndFeelPage::saveSettings( KConfig *config ) |
153 | { | 153 | { |
154 | config->writeEntry("ABackground", mAlternateButton->isChecked()); | 154 | config->writeEntry("ABackground", mAlternateButton->isChecked()); |
155 | config->writeEntry("SingleLine", mLineButton->isChecked()); | 155 | config->writeEntry("SingleLine", mLineButton->isChecked()); |
156 | config->writeEntry("ToolTips", mToolTipBox->isChecked()); | 156 | config->writeEntry("ToolTips", mToolTipBox->isChecked()); |
157 | config->writeEntry("Background", mBackgroundBox->isChecked()); | 157 | config->writeEntry("Background", mBackgroundBox->isChecked()); |
158 | config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); | 158 | config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); |
159 | 159 | ||
160 | // colors | 160 | // colors |
161 | config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); | 161 | config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); |
162 | if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. | 162 | if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. |
163 | { | 163 | { |
164 | config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); | 164 | config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); |
165 | config->writeEntry( "TextColor", lbColors->color( 1 ) ); | 165 | config->writeEntry( "TextColor", lbColors->color( 1 ) ); |
166 | config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); | 166 | config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); |
167 | config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); | 167 | config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); |
168 | config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); | 168 | config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); |
169 | config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); | 169 | config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); |
170 | config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); | 170 | config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); |
171 | } | 171 | } |
172 | // fonts | 172 | // fonts |
173 | config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); | 173 | config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); |
174 | if ( cbEnableCustomFonts->isChecked() ) | 174 | if ( cbEnableCustomFonts->isChecked() ) |
175 | { | 175 | { |
176 | config->writeEntry( "TextFont", lTextFont->font() ); | 176 | config->writeEntry( "TextFont", lTextFont->font() ); |
177 | config->writeEntry( "HeaderFont", lHeaderFont->font() ); | 177 | config->writeEntry( "HeaderFont", lHeaderFont->font() ); |
178 | } | 178 | } |
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | void LookAndFeelPage::setTextFont() | 182 | void LookAndFeelPage::setTextFont() |
183 | { | 183 | { |
184 | QFont f( lTextFont->font() ); | 184 | QFont f( lTextFont->font() ); |
185 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
186 | if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) | 186 | if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) |
187 | updateFontLabel( f, lTextFont ); | 187 | updateFontLabel( f, lTextFont ); |
188 | #else //KAB_EMBEDDED | 188 | #else //KAB_EMBEDDED |
189 | bool ok; | 189 | bool ok; |
190 | QFont fout = KFontDialog::getFont( f, ok); | 190 | QFont fout = KFontDialog::getFont( f, ok); |
191 | if ( ok ) | 191 | if ( ok ) |
192 | updateFontLabel( fout, lTextFont ); | 192 | updateFontLabel( fout, lTextFont ); |
193 | #endif //KAB_EMBEDDED | 193 | #endif //KAB_EMBEDDED |
194 | } | 194 | } |
195 | 195 | ||
196 | void LookAndFeelPage::setHeaderFont() | 196 | void LookAndFeelPage::setHeaderFont() |
197 | { | 197 | { |
198 | QFont f( lHeaderFont->font() ); | 198 | QFont f( lHeaderFont->font() ); |
199 | #ifndef KAB_EMBEDDED | 199 | #ifndef KAB_EMBEDDED |
200 | if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) | 200 | if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) |
201 | updateFontLabel( f, lHeaderFont ); | 201 | updateFontLabel( f, lHeaderFont ); |
202 | #else //KAB_EMBEDDED | 202 | #else //KAB_EMBEDDED |
203 | bool ok; | 203 | bool ok; |
204 | QFont fout = KFontDialog::getFont( f, ok); | 204 | QFont fout = KFontDialog::getFont( f, ok); |
205 | if ( ok ) | 205 | if ( ok ) |
206 | updateFontLabel( fout, lHeaderFont ); | 206 | updateFontLabel( fout, lHeaderFont ); |
207 | #endif //KAB_EMBEDDED | 207 | #endif //KAB_EMBEDDED |
208 | } | 208 | } |
209 | 209 | ||
210 | void LookAndFeelPage::enableFonts() | 210 | void LookAndFeelPage::enableFonts() |
211 | { | 211 | { |
212 | vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); | 212 | vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); |
213 | if ( cbEnableCustomFonts->isChecked() ) | ||
214 | vbFonts->setFocus(); | ||
213 | } | 215 | } |
214 | 216 | ||
215 | void LookAndFeelPage::enableColors() | 217 | void LookAndFeelPage::enableColors() |
216 | { | 218 | { |
217 | lbColors->setEnabled( cbEnableCustomColors->isChecked() ); | 219 | lbColors->setEnabled( cbEnableCustomColors->isChecked() ); |
220 | if ( cbEnableCustomColors->isChecked() ) | ||
221 | lbColors->setFocus(); | ||
218 | } | 222 | } |
219 | 223 | ||
220 | void LookAndFeelPage::initGUI() | 224 | void LookAndFeelPage::initGUI() |
221 | { | 225 | { |
222 | int spacing = KDialog::spacingHint(); | 226 | int spacing = KDialog::spacingHint(); |
223 | int margin = KDialog::marginHint(); | 227 | int margin = KDialog::marginHint(); |
224 | 228 | ||
225 | QTabWidget *tabs = new QTabWidget( this ); | 229 | QTabWidget *tabs = new QTabWidget( this ); |
226 | 230 | ||
227 | // General | 231 | // General |
228 | QVBox *generalTab = new QVBox( this, "generaltab" ); | 232 | QVBox *generalTab = new QVBox( this, "generaltab" ); |
229 | 233 | ||
230 | generalTab->setSpacing( spacing ); | 234 | generalTab->setSpacing( spacing ); |
231 | generalTab->setMargin( margin ); | 235 | generalTab->setMargin( margin ); |
232 | 236 | ||
233 | QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, | 237 | QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, |
234 | i18n("Row Separator"), generalTab); | 238 | i18n("Row Separator"), generalTab); |
235 | 239 | ||
236 | mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), | 240 | mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), |
237 | group, "mAlternateButton"); | 241 | group, "mAlternateButton"); |
238 | mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); | 242 | mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); |
239 | mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); | 243 | mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); |
240 | 244 | ||
241 | mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, | 245 | mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, |
242 | "mBackgroundBox"); | 246 | "mBackgroundBox"); |
243 | connect(mBackgroundBox, SIGNAL(toggled(bool)), | 247 | connect(mBackgroundBox, SIGNAL(toggled(bool)), |
244 | SLOT(enableBackgroundToggled(bool))); | 248 | SLOT(enableBackgroundToggled(bool))); |
245 | // LR image not implemented | 249 | // LR image not implemented |
246 | mBackgroundBox->setEnabled( false ); | 250 | mBackgroundBox->setEnabled( false ); |
247 | mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); | 251 | mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); |
248 | #ifndef KAB_EMBEDDED | 252 | #ifndef KAB_EMBEDDED |
249 | mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | | 253 | mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | |
250 | KFile::LocalOnly); | 254 | KFile::LocalOnly); |
251 | mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); | 255 | mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); |
252 | #endif //KAB_EMBEDDED | 256 | #endif //KAB_EMBEDDED |
253 | 257 | ||
254 | // ToolTip Checkbox | 258 | // ToolTip Checkbox |
255 | mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, | 259 | mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, |
256 | "mToolTipBox"); | 260 | "mToolTipBox"); |
257 | 261 | ||
258 | tabs->addTab( generalTab, i18n("&General") ); | 262 | tabs->addTab( generalTab, i18n("&General") ); |
259 | 263 | ||
260 | // Colors | 264 | // Colors |
261 | QVBox *colorTab = new QVBox( this, "colortab" ); | 265 | QVBox *colorTab = new QVBox( this, "colortab" ); |
262 | colorTab->setSpacing( spacing ); | 266 | colorTab->setSpacing( spacing ); |
263 | colorTab->setMargin( spacing ); | 267 | colorTab->setMargin( spacing ); |
264 | cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); | 268 | cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); |
265 | connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); | 269 | connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); |
266 | lbColors = new ColorListBox( colorTab ); | 270 | lbColors = new ColorListBox( colorTab ); |
267 | tabs->addTab( colorTab, i18n("&Colors") ); | 271 | tabs->addTab( colorTab, i18n("&Colors") ); |
268 | 272 | ||
269 | QWhatsThis::add( cbEnableCustomColors, i18n( | 273 | QWhatsThis::add( cbEnableCustomColors, i18n( |
270 | "If custom colors are enabled, you may choose the colors for the view below. " | 274 | "If custom colors are enabled, you may choose the colors for the view below. " |
271 | "Otherwise colors from your current KDE color scheme are used." | 275 | "Otherwise colors from your current KDE color scheme are used." |
272 | ) ); | 276 | ) ); |
273 | QWhatsThis::add( lbColors, i18n( | 277 | QWhatsThis::add( lbColors, i18n( |
274 | "Double click or press RETURN on a item to select a color for the related strings in the view." | 278 | "Double click or press RETURN on a item to select a color for the related strings in the view." |
275 | ) ); | 279 | ) ); |
276 | 280 | ||
277 | // Fonts | 281 | // Fonts |
278 | QVBox *fntTab = new QVBox( this, "fonttab" ); | 282 | QVBox *fntTab = new QVBox( this, "fonttab" ); |
279 | 283 | ||
280 | fntTab->setSpacing( spacing ); | 284 | fntTab->setSpacing( spacing ); |
281 | fntTab->setMargin( spacing ); | 285 | fntTab->setMargin( spacing ); |
282 | 286 | ||
283 | cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); | 287 | cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); |
284 | connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); | 288 | connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); |
285 | 289 | ||
286 | vbFonts = new QWidget( fntTab ); | 290 | vbFonts = new QWidget( fntTab ); |
287 | QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); | 291 | QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); |
288 | gFnts->setSpacing( spacing ); | 292 | gFnts->setSpacing( spacing ); |
289 | gFnts->setAutoAdd( true ); | 293 | gFnts->setAutoAdd( true ); |
290 | gFnts->setColStretch( 1, 1 ); | 294 | gFnts->setColStretch( 1, 1 ); |
291 | QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); | 295 | QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); |
292 | lTextFont = new QLabel( vbFonts ); | 296 | lTextFont = new QLabel( vbFonts ); |
293 | lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); | 297 | lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); |
294 | #ifndef KAB_EMBEDDED | 298 | #ifndef KAB_EMBEDDED |
295 | btnFont = new KPushButton( i18n("Choose..."), vbFonts ); | 299 | btnFont = new KPushButton( i18n("Choose..."), vbFonts ); |
296 | #else //KAB_EMBEDDED | 300 | #else //KAB_EMBEDDED |
297 | btnFont = new QPushButton( i18n("Choose..."), vbFonts ); | 301 | btnFont = new QPushButton( i18n("Choose..."), vbFonts ); |
298 | #endif //KAB_EMBEDDED | 302 | #endif //KAB_EMBEDDED |
299 | 303 | ||
300 | lTFnt->setBuddy( btnFont ); | 304 | lTFnt->setBuddy( btnFont ); |
301 | 305 | ||
302 | connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); | 306 | connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); |
303 | 307 | ||
304 | QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); | 308 | QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); |
305 | lHeaderFont = new QLabel( vbFonts ); | 309 | lHeaderFont = new QLabel( vbFonts ); |
306 | lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); | 310 | lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); |
307 | #ifndef KAB_EMBEDDED | 311 | #ifndef KAB_EMBEDDED |
308 | btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); | 312 | btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); |
309 | #else //KAB_EMBEDDED | 313 | #else //KAB_EMBEDDED |
310 | btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); | 314 | btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); |
311 | #endif //KAB_EMBEDDED | 315 | #endif //KAB_EMBEDDED |
312 | lHFnt->setBuddy( btnHeaderFont ); | 316 | lHFnt->setBuddy( btnHeaderFont ); |
313 | connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); | 317 | connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); |
314 | 318 | ||
315 | fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); | 319 | fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); |
316 | 320 | ||
317 | QWhatsThis::add( cbEnableCustomFonts, i18n( | 321 | QWhatsThis::add( cbEnableCustomFonts, i18n( |
318 | "If custom fonts are enabled, you may choose which fonts to use for this view below. " | 322 | "If custom fonts are enabled, you may choose which fonts to use for this view below. " |
319 | "Otherwise the default KDE font will be used, in bold style for the header and " | 323 | "Otherwise the default KDE font will be used, in bold style for the header and " |
320 | "normal style for the data." | 324 | "normal style for the data." |
321 | ) ); | 325 | ) ); |
322 | 326 | ||
323 | tabs->addTab( fntTab, i18n("&Fonts") ); | 327 | tabs->addTab( fntTab, i18n("&Fonts") ); |
324 | 328 | ||
325 | } | 329 | } |
326 | 330 | ||
327 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) | 331 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) |
328 | { | 332 | { |
329 | mBackgroundName->setEnabled(enabled); | 333 | mBackgroundName->setEnabled(enabled); |
330 | } | 334 | } |
331 | 335 | ||
332 | 336 | ||
333 | void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) | 337 | void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) |
334 | { | 338 | { |
335 | l->setFont( fnt ); | 339 | l->setFont( fnt ); |
336 | l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); | 340 | l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); |
337 | } | 341 | } |
338 | 342 | ||
339 | #ifndef KAB_EMBEDDED | 343 | #ifndef KAB_EMBEDDED |
340 | #include "configuretableviewdialog.moc" | 344 | #include "configuretableviewdialog.moc" |
341 | #endif //KAB_EMBEDDED | 345 | #endif //KAB_EMBEDDED |