Diffstat (limited to 'core/settings/launcher/tabdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/launcher/tabdialog.cpp | 632 |
1 files changed, 317 insertions, 315 deletions
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp index 763b360..546e229 100644 --- a/core/settings/launcher/tabdialog.cpp +++ b/core/settings/launcher/tabdialog.cpp | |||
@@ -22,308 +22,310 @@ | |||
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "tabdialog.h" | ||
29 | |||
30 | /* OPIE */ | ||
28 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | #include <opie2/ofontselector.h> | ||
33 | #include <opie2/otabwidget.h> | ||
34 | #include <opie2/ocolorbutton.h> | ||
35 | #include <opie2/ofiledialog.h> | ||
36 | #include <opie2/odebug.h> | ||
29 | 37 | ||
38 | /* QT */ | ||
30 | #include <qlayout.h> | 39 | #include <qlayout.h> |
31 | #include <qvbox.h> | 40 | #include <qvbox.h> |
32 | #include <qtabbar.h> | 41 | #include <qtabbar.h> |
33 | #include <qiconview.h> | 42 | #include <qiconview.h> |
34 | #include <qapplication.h> | 43 | #include <qapplication.h> |
35 | #include <qlabel.h> | 44 | #include <qlabel.h> |
36 | #include <qradiobutton.h> | 45 | #include <qradiobutton.h> |
37 | #include <qbuttongroup.h> | 46 | #include <qbuttongroup.h> |
38 | #include <qwhatsthis.h> | 47 | #include <qwhatsthis.h> |
39 | #include <qcheckbox.h> | 48 | #include <qcheckbox.h> |
40 | 49 | ||
41 | #include <opie2/ofontselector.h> | ||
42 | #include <opie2/otabwidget.h> | ||
43 | #include <opie2/ocolorbutton.h> | ||
44 | #include <opie2/ofiledialog.h> | ||
45 | |||
46 | #include "tabdialog.h" | ||
47 | |||
48 | 50 | ||
49 | using namespace Opie::Ui; | 51 | using namespace Opie::Ui; |
50 | class SampleItem : public QIconViewItem { | 52 | class SampleItem : public QIconViewItem { |
51 | public: | 53 | public: |
52 | SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text ) | 54 | SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text ) |
53 | { | 55 | { |
54 | m_large = pix; | 56 | m_large = pix; |
55 | m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 )); | 57 | m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 )); |
56 | } | 58 | } |
57 | 59 | ||
58 | void sizeChange ( ) | 60 | void sizeChange ( ) |
59 | { | 61 | { |
60 | calcRect ( ); | 62 | calcRect ( ); |
61 | repaint ( ); | 63 | repaint ( ); |
62 | } | 64 | } |
63 | 65 | ||
64 | QPixmap *pixmap ( ) const | 66 | QPixmap *pixmap ( ) const |
65 | { | 67 | { |
66 | if ( iconView ( )-> itemTextPos ( ) == QIconView::Right ) | 68 | if ( iconView ( )-> itemTextPos ( ) == QIconView::Right ) |
67 | return (QPixmap *) &m_small; | 69 | return (QPixmap *) &m_small; |
68 | else | 70 | else |
69 | return (QPixmap *) &m_large; | 71 | return (QPixmap *) &m_large; |
70 | } | 72 | } |
71 | 73 | ||
72 | private: | 74 | private: |
73 | QPixmap m_large, m_small; | 75 | QPixmap m_large, m_small; |
74 | }; | 76 | }; |
75 | 77 | ||
76 | class SampleView : public QIconView { | 78 | class SampleView : public QIconView { |
77 | public: | 79 | public: |
78 | SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name ) | 80 | SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name ) |
79 | { | 81 | { |
80 | setItemsMovable ( false ); | 82 | setItemsMovable ( false ); |
81 | setAutoArrange ( true ); | 83 | setAutoArrange ( true ); |
82 | setSorting ( true ); | 84 | setSorting ( true ); |
83 | setFrameStyle ( QFrame::NoFrame ); | 85 | setFrameStyle ( QFrame::NoFrame ); |
84 | setSpacing ( 4 ); | 86 | setSpacing ( 4 ); |
85 | setMargin ( 0 ); | 87 | setMargin ( 0 ); |
86 | setSelectionMode ( QIconView::NoSelection ); | 88 | setSelectionMode ( QIconView::NoSelection ); |
87 | setBackgroundMode ( PaletteBase ); | 89 | setBackgroundMode ( PaletteBase ); |
88 | setViewMode ( TabConfig::Icon ); | 90 | setViewMode ( TabConfig::Icon ); |
89 | calculateGrid ( Bottom ); | 91 | calculateGrid ( Bottom ); |
90 | 92 | ||
91 | 93 | ||
92 | new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); | 94 | new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); |
93 | new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); | 95 | new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); |
94 | new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); | 96 | new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); |
95 | 97 | ||
96 | setBackgroundType ( TabConfig::Ruled, QString::null ); | 98 | setBackgroundType ( TabConfig::Ruled, QString::null ); |
97 | 99 | ||
98 | setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); | 100 | setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); |
99 | } | 101 | } |
100 | 102 | ||
101 | void setViewMode ( TabConfig::ViewMode m ) | 103 | void setViewMode ( TabConfig::ViewMode m ) |
102 | { | 104 | { |
103 | viewport ( )-> setUpdatesEnabled ( false ); | 105 | viewport ( )-> setUpdatesEnabled ( false ); |
104 | 106 | ||
105 | switch ( m ) { | 107 | switch ( m ) { |
106 | case TabConfig::List: | 108 | case TabConfig::List: |
107 | setItemTextPos( QIconView::Right ); | 109 | setItemTextPos( QIconView::Right ); |
108 | break; | 110 | break; |
109 | case TabConfig::Icon: | 111 | case TabConfig::Icon: |
110 | setItemTextPos( QIconView::Bottom ); | 112 | setItemTextPos( QIconView::Bottom ); |
111 | break; | 113 | break; |
112 | } | 114 | } |
113 | // hideOrShowItems ( false ); | 115 | // hideOrShowItems ( false ); |
114 | 116 | ||
115 | for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) | 117 | for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) |
116 | ((SampleItem *) it )-> sizeChange ( ); | 118 | ((SampleItem *) it )-> sizeChange ( ); |
117 | arrangeItemsInGrid ( true ); | 119 | arrangeItemsInGrid ( true ); |
118 | viewport ( )-> setUpdatesEnabled ( true ); | 120 | viewport ( )-> setUpdatesEnabled ( true ); |
119 | update ( ); | 121 | update ( ); |
120 | } | 122 | } |
121 | 123 | ||
122 | 124 | ||
123 | void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) | 125 | void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) |
124 | { | 126 | { |
125 | switch ( t ) { | 127 | switch ( t ) { |
126 | case TabConfig::Ruled: { | 128 | case TabConfig::Ruled: { |
127 | QPixmap bg ( width ( ), 9 ); | 129 | QPixmap bg ( width ( ), 9 ); |
128 | QPainter painter ( &bg ); | 130 | QPainter painter ( &bg ); |
129 | for ( int i = 0; i < 3; i++ ) { | 131 | for ( int i = 0; i < 3; i++ ) { |
130 | painter. setPen ( white ); | 132 | painter. setPen ( white ); |
131 | painter. drawLine ( 0, i*3, width()-1, i*3 ); | 133 | painter. drawLine ( 0, i*3, width()-1, i*3 ); |
132 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); | 134 | painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); |
133 | painter. setPen ( colorGroup().background().light(105) ); | 135 | painter. setPen ( colorGroup().background().light(105) ); |
134 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); | 136 | painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); |
135 | } | 137 | } |
136 | painter.end ( ); | 138 | painter.end ( ); |
137 | setBackgroundPixmap ( bg ); | 139 | setBackgroundPixmap ( bg ); |
138 | break; | 140 | break; |
139 | } | 141 | } |
140 | 142 | ||
141 | case TabConfig::SolidColor: { | 143 | case TabConfig::SolidColor: { |
142 | setBackgroundPixmap ( QPixmap ( )); | 144 | setBackgroundPixmap ( QPixmap ( )); |
143 | if ( val. isEmpty ( )) | 145 | if ( val. isEmpty ( )) |
144 | setBackgroundColor ( colorGroup ( ). base ( )); | 146 | setBackgroundColor ( colorGroup ( ). base ( )); |
145 | else | 147 | else |
146 | setBackgroundColor ( val ); | 148 | setBackgroundColor ( val ); |
147 | break; | 149 | break; |
148 | } | 150 | } |
149 | 151 | ||
150 | case TabConfig::Image: { | 152 | case TabConfig::Image: { |
151 | qDebug( "Loading image: %s", val.latin1() ); | 153 | odebug << "Loading image: " << val << "" << oendl; |
152 | QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); | 154 | QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); |
153 | if ( bg. isNull ( )) { | 155 | if ( bg. isNull ( )) { |
154 | QImageIO imgio; | 156 | QImageIO imgio; |
155 | imgio. setFileName ( val ); | 157 | imgio. setFileName ( val ); |
156 | QSize ds = qApp-> desktop ( )-> size ( ); | 158 | QSize ds = qApp-> desktop ( )-> size ( ); |
157 | QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr | 159 | QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr |
158 | imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); | 160 | imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); |
159 | imgio. read ( ); | 161 | imgio. read ( ); |
160 | bg = imgio. image ( ); | 162 | bg = imgio. image ( ); |
161 | } | 163 | } |
162 | setBackgroundPixmap ( bg ); | 164 | setBackgroundPixmap ( bg ); |
163 | break; | 165 | break; |
164 | } | 166 | } |
165 | } | 167 | } |
166 | m_bgtype = t; | 168 | m_bgtype = t; |
167 | viewport ( )-> update ( ); | 169 | viewport ( )-> update ( ); |
168 | } | 170 | } |
169 | 171 | ||
170 | void setTextColor ( const QColor &tc ) | 172 | void setTextColor ( const QColor &tc ) |
171 | { | 173 | { |
172 | m_textcolor = tc; | 174 | m_textcolor = tc; |
173 | QColorGroup cg = colorGroup ( ); | 175 | QColorGroup cg = colorGroup ( ); |
174 | cg. setColor ( QColorGroup::Text, tc ); | 176 | cg. setColor ( QColorGroup::Text, tc ); |
175 | setPalette ( QPalette ( cg, cg, cg )); | 177 | setPalette ( QPalette ( cg, cg, cg )); |
176 | viewport ( )-> update ( ); | 178 | viewport ( )-> update ( ); |
177 | } | 179 | } |
178 | 180 | ||
179 | void setViewFont ( const QFont &f ) | 181 | void setViewFont ( const QFont &f ) |
180 | { | 182 | { |
181 | setFont ( f ); | 183 | setFont ( f ); |
182 | } | 184 | } |
183 | 185 | ||
184 | void setItemTextPos ( ItemTextPos pos ) | 186 | void setItemTextPos ( ItemTextPos pos ) |
185 | { | 187 | { |
186 | calculateGrid ( pos ); | 188 | calculateGrid ( pos ); |
187 | QIconView::setItemTextPos( pos ); | 189 | QIconView::setItemTextPos( pos ); |
188 | } | 190 | } |
189 | 191 | ||
190 | void calculateGrid ( ItemTextPos pos ) | 192 | void calculateGrid ( ItemTextPos pos ) |
191 | { | 193 | { |
192 | int dw = QApplication::desktop ( )-> width ( ); | 194 | int dw = QApplication::desktop ( )-> width ( ); |
193 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); | 195 | int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); |
194 | if ( pos == Bottom ) { | 196 | if ( pos == Bottom ) { |
195 | int cols = 3; | 197 | int cols = 3; |
196 | if ( viewerWidth <= 200 ) | 198 | if ( viewerWidth <= 200 ) |
197 | cols = 2; | 199 | cols = 2; |
198 | else if ( viewerWidth >= 400 ) | 200 | else if ( viewerWidth >= 400 ) |
199 | cols = viewerWidth/96; | 201 | cols = viewerWidth/96; |
200 | setSpacing ( 4 ); | 202 | setSpacing ( 4 ); |
201 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 203 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
202 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); | 204 | setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); |
203 | } | 205 | } |
204 | else { | 206 | else { |
205 | int cols = 2; | 207 | int cols = 2; |
206 | if ( viewerWidth < 150 ) | 208 | if ( viewerWidth < 150 ) |
207 | cols = 1; | 209 | cols = 1; |
208 | else if ( viewerWidth >= 400 ) | 210 | else if ( viewerWidth >= 400 ) |
209 | cols = viewerWidth / 150; | 211 | cols = viewerWidth / 150; |
210 | setSpacing ( 2 ); | 212 | setSpacing ( 2 ); |
211 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); | 213 | setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); |
212 | setGridY ( fontMetrics ( ). height ( ) + 2 ); | 214 | setGridY ( fontMetrics ( ). height ( ) + 2 ); |
213 | } | 215 | } |
214 | } | 216 | } |
215 | 217 | ||
216 | void paletteChange( const QPalette &p ) | 218 | void paletteChange( const QPalette &p ) |
217 | { | 219 | { |
218 | static bool excllock = false; | 220 | static bool excllock = false; |
219 | 221 | ||
220 | if ( excllock ) | 222 | if ( excllock ) |
221 | return; | 223 | return; |
222 | excllock = true; | 224 | excllock = true; |
223 | 225 | ||
224 | unsetPalette ( ); | 226 | unsetPalette ( ); |
225 | QIconView::paletteChange ( p ); | 227 | QIconView::paletteChange ( p ); |
226 | if ( m_bgtype == TabConfig::Ruled ) | 228 | if ( m_bgtype == TabConfig::Ruled ) |
227 | setBackgroundType ( TabConfig::Ruled, QString::null ); | 229 | setBackgroundType ( TabConfig::Ruled, QString::null ); |
228 | QColorGroup cg = colorGroup ( ); | 230 | QColorGroup cg = colorGroup ( ); |
229 | cg.setColor ( QColorGroup::Text, m_textcolor ); | 231 | cg.setColor ( QColorGroup::Text, m_textcolor ); |
230 | setPalette ( QPalette ( cg, cg, cg )); | 232 | setPalette ( QPalette ( cg, cg, cg )); |
231 | 233 | ||
232 | excllock = false; | 234 | excllock = false; |
233 | } | 235 | } |
234 | 236 | ||
235 | void setBackgroundPixmap ( const QPixmap &pm ) | 237 | void setBackgroundPixmap ( const QPixmap &pm ) |
236 | { | 238 | { |
237 | m_bgpix = pm; | 239 | m_bgpix = pm; |
238 | } | 240 | } |
239 | 241 | ||
240 | void setBackgroundColor ( const QColor &c ) | 242 | void setBackgroundColor ( const QColor &c ) |
241 | { | 243 | { |
242 | m_bgcolor = c; | 244 | m_bgcolor = c; |
243 | } | 245 | } |
244 | 246 | ||
245 | void drawBackground ( QPainter *p, const QRect &r ) | 247 | void drawBackground ( QPainter *p, const QRect &r ) |
246 | { | 248 | { |
247 | if ( !m_bgpix. isNull ( )) { | 249 | if ( !m_bgpix. isNull ( )) { |
248 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), | 250 | p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), |
249 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); | 251 | ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); |
250 | } | 252 | } |
251 | else | 253 | else |
252 | p-> fillRect ( r, m_bgcolor ); | 254 | p-> fillRect ( r, m_bgcolor ); |
253 | } | 255 | } |
254 | 256 | ||
255 | private: | 257 | private: |
256 | QColor m_textcolor; | 258 | QColor m_textcolor; |
257 | QColor m_bgcolor; | 259 | QColor m_bgcolor; |
258 | QPixmap m_bgpix; | 260 | QPixmap m_bgpix; |
259 | TabConfig::BackgroundType m_bgtype; | 261 | TabConfig::BackgroundType m_bgtype; |
260 | }; | 262 | }; |
261 | 263 | ||
262 | 264 | ||
263 | 265 | ||
264 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) | 266 | TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) |
265 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) | 267 | : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) |
266 | { | 268 | { |
267 | setCaption ( tr( "Edit Tab" )); | 269 | setCaption ( tr( "Edit Tab" )); |
268 | 270 | ||
269 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); | 271 | QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); |
270 | 272 | ||
271 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 273 | OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
272 | QWidget *bgtab; | 274 | QWidget *bgtab; |
273 | 275 | ||
274 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); | 276 | tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); |
275 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); | 277 | tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); |
276 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); | 278 | tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); |
277 | 279 | ||
278 | tw-> setCurrentTab ( bgtab ); | 280 | tw-> setCurrentTab ( bgtab ); |
279 | 281 | ||
280 | QWidget *sample = new QVBox ( this ); | 282 | QWidget *sample = new QVBox ( this ); |
281 | QTabBar *tb = new QTabBar ( sample ); | 283 | QTabBar *tb = new QTabBar ( sample ); |
282 | QString name ( tr( "Previewing %1" ). arg ( tabname )); | 284 | QString name ( tr( "Previewing %1" ). arg ( tabname )); |
283 | 285 | ||
284 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); | 286 | tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); |
285 | 287 | ||
286 | m_sample = new SampleView ( sample ); | 288 | m_sample = new SampleView ( sample ); |
287 | 289 | ||
288 | lay-> addWidget ( tw, 10 ); | 290 | lay-> addWidget ( tw, 10 ); |
289 | lay-> addWidget ( sample, 1 ); | 291 | lay-> addWidget ( sample, 1 ); |
290 | 292 | ||
291 | m_iconsize-> setButton ( tc. m_view ); | 293 | m_iconsize-> setButton ( tc. m_view ); |
292 | iconSizeClicked ( tc. m_view ); | 294 | iconSizeClicked ( tc. m_view ); |
293 | //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); | 295 | //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); |
294 | iconColorClicked ( m_iconcolor-> color ( )); | 296 | iconColorClicked ( m_iconcolor-> color ( )); |
295 | m_bgtype-> setButton ( tc. m_bg_type ); | 297 | m_bgtype-> setButton ( tc. m_bg_type ); |
296 | //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); | 298 | //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); |
297 | m_bgimage = tc. m_bg_image; | 299 | m_bgimage = tc. m_bg_image; |
298 | bgTypeClicked ( tc. m_bg_type ); | 300 | bgTypeClicked ( tc. m_bg_type ); |
299 | m_fontuse-> setChecked ( tc. m_font_use ); | 301 | m_fontuse-> setChecked ( tc. m_font_use ); |
300 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); | 302 | m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); |
301 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); | 303 | m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); |
302 | fontClicked ( m_fontselect-> selectedFont ( )); | 304 | fontClicked ( m_fontselect-> selectedFont ( )); |
303 | 305 | ||
304 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); | 306 | QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); |
305 | } | 307 | } |
306 | 308 | ||
307 | 309 | ||
308 | TabDialog::~TabDialog ( ) | 310 | TabDialog::~TabDialog ( ) |
309 | { | 311 | { |
310 | } | 312 | } |
311 | 313 | ||
312 | QWidget *TabDialog::createFontTab ( QWidget *parent ) | 314 | QWidget *TabDialog::createFontTab ( QWidget *parent ) |
313 | { | 315 | { |
314 | QWidget *tab = new QWidget ( parent, "FontTab" ); | 316 | QWidget *tab = new QWidget ( parent, "FontTab" ); |
315 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); | 317 | QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); |
316 | 318 | ||
317 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); | 319 | m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); |
318 | vertLayout-> addWidget ( m_fontuse ); | 320 | vertLayout-> addWidget ( m_fontuse ); |
319 | 321 | ||
320 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); | 322 | m_fontselect = new OFontSelector ( false, tab, "fontsel" ); |
321 | vertLayout-> addWidget ( m_fontselect ); | 323 | vertLayout-> addWidget ( m_fontselect ); |
322 | 324 | ||
323 | connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); | 325 | connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); |
324 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), | 326 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
325 | this, SLOT( fontClicked(const QFont&))); | 327 | this, SLOT( fontClicked(const QFont&))); |
326 | 328 | ||
327 | return tab; | 329 | return tab; |
328 | } | 330 | } |
329 | 331 | ||
@@ -338,56 +340,56 @@ QWidget *TabDialog::createBgTab ( QWidget *parent ) | |||
338 | QLabel* label = new QLabel( tr( "Type:" ), tab ); | 340 | QLabel* label = new QLabel( tr( "Type:" ), tab ); |
339 | gridLayout-> addWidget ( label, 0, 0 ); | 341 | gridLayout-> addWidget ( label, 0, 0 ); |
340 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); | 342 | m_bgtype = new QButtonGroup( tab, "buttongroup" ); |
341 | m_bgtype-> hide ( ); | 343 | m_bgtype-> hide ( ); |
342 | m_bgtype-> setExclusive ( true ); | 344 | m_bgtype-> setExclusive ( true ); |
343 | 345 | ||
344 | QRadioButton *rb; | 346 | QRadioButton *rb; |
345 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); | 347 | rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); |
346 | m_bgtype-> insert ( rb, TabConfig::Ruled ); | 348 | m_bgtype-> insert ( rb, TabConfig::Ruled ); |
347 | gridLayout-> addWidget( rb, 0, 1 ); | 349 | gridLayout-> addWidget( rb, 0, 1 ); |
348 | 350 | ||
349 | QHBoxLayout *hb = new QHBoxLayout ( ); | 351 | QHBoxLayout *hb = new QHBoxLayout ( ); |
350 | hb-> setSpacing ( 3 ); | 352 | hb-> setSpacing ( 3 ); |
351 | 353 | ||
352 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); | 354 | rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); |
353 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); | 355 | m_bgtype-> insert ( rb, TabConfig::SolidColor ); |
354 | hb-> addWidget ( rb ); | 356 | hb-> addWidget ( rb ); |
355 | hb-> addSpacing ( 10 ); | 357 | hb-> addSpacing ( 10 ); |
356 | 358 | ||
357 | m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); | 359 | m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); |
358 | connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); | 360 | connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); |
359 | hb-> addWidget ( m_solidcolor ); | 361 | hb-> addWidget ( m_solidcolor ); |
360 | hb-> addStretch ( 10 ); | 362 | hb-> addStretch ( 10 ); |
361 | 363 | ||
362 | gridLayout-> addLayout ( hb, 1, 1 ); | 364 | gridLayout-> addLayout ( hb, 1, 1 ); |
363 | 365 | ||
364 | hb = new QHBoxLayout ( ); | 366 | hb = new QHBoxLayout ( ); |
365 | hb-> setSpacing ( 3 ); | 367 | hb-> setSpacing ( 3 ); |
366 | 368 | ||
367 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); | 369 | rb = new QRadioButton( tr( "Image" ), tab, "image" ); |
368 | m_bgtype-> insert ( rb, TabConfig::Image ); | 370 | m_bgtype-> insert ( rb, TabConfig::Image ); |
369 | hb-> addWidget( rb ); | 371 | hb-> addWidget( rb ); |
370 | hb-> addSpacing ( 10 ); | 372 | hb-> addSpacing ( 10 ); |
371 | 373 | ||
372 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); | 374 | m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); |
373 | connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); | 375 | connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); |
374 | hb-> addWidget ( m_imagebrowse ); | 376 | hb-> addWidget ( m_imagebrowse ); |
375 | hb-> addStretch ( 10 ); | 377 | hb-> addStretch ( 10 ); |
376 | 378 | ||
377 | gridLayout-> addLayout ( hb, 2, 1 ); | 379 | gridLayout-> addLayout ( hb, 2, 1 ); |
378 | 380 | ||
379 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); | 381 | QPushButton *p = new QPushButton ( tr( "Default" ), tab ); |
380 | connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); | 382 | connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); |
381 | gridLayout-> addWidget ( p, 3, 1 ); | 383 | gridLayout-> addWidget ( p, 3, 1 ); |
382 | 384 | ||
383 | connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); | 385 | connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); |
384 | 386 | ||
385 | vertLayout-> addStretch ( 10 ); | 387 | vertLayout-> addStretch ( 10 ); |
386 | 388 | ||
387 | return tab; | 389 | return tab; |
388 | } | 390 | } |
389 | 391 | ||
390 | QWidget *TabDialog::createIconTab ( QWidget *parent ) | 392 | QWidget *TabDialog::createIconTab ( QWidget *parent ) |
391 | { | 393 | { |
392 | QWidget *tab = new QWidget( parent, "IconTab" ); | 394 | QWidget *tab = new QWidget( parent, "IconTab" ); |
393 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 395 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
@@ -398,117 +400,117 @@ QWidget *TabDialog::createIconTab ( QWidget *parent ) | |||
398 | QLabel* label = new QLabel( tr( "Size:" ), tab ); | 400 | QLabel* label = new QLabel( tr( "Size:" ), tab ); |
399 | gridLayout-> addWidget ( label, 0, 0 ); | 401 | gridLayout-> addWidget ( label, 0, 0 ); |
400 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); | 402 | m_iconsize = new QButtonGroup( tab, "buttongroup" ); |
401 | m_iconsize-> hide ( ); | 403 | m_iconsize-> hide ( ); |
402 | m_iconsize-> setExclusive ( true ); | 404 | m_iconsize-> setExclusive ( true ); |
403 | 405 | ||
404 | QRadioButton *rb; | 406 | QRadioButton *rb; |
405 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); | 407 | rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); |
406 | m_iconsize-> insert ( rb, TabConfig::List ); | 408 | m_iconsize-> insert ( rb, TabConfig::List ); |
407 | gridLayout-> addWidget( rb, 0, 1 ); | 409 | gridLayout-> addWidget( rb, 0, 1 ); |
408 | 410 | ||
409 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); | 411 | rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); |
410 | m_iconsize-> insert ( rb, TabConfig::Icon ); | 412 | m_iconsize-> insert ( rb, TabConfig::Icon ); |
411 | gridLayout-> addWidget( rb, 1, 1 ); | 413 | gridLayout-> addWidget( rb, 1, 1 ); |
412 | 414 | ||
413 | connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); | 415 | connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); |
414 | 416 | ||
415 | //vertLayout-> addSpacing ( 8 ); | 417 | // vertLayout-> addSpacing ( 8 ); |
416 | 418 | ||
417 | //gridLayout = new QGridLayout ( vertLayout ); | 419 | // gridLayout = new QGridLayout ( vertLayout ); |
418 | gridLayout-> addRowSpacing ( 2, 8 ); | 420 | gridLayout-> addRowSpacing ( 2, 8 ); |
419 | 421 | ||
420 | label = new QLabel ( tr( "Color:" ), tab ); | 422 | label = new QLabel ( tr( "Color:" ), tab ); |
421 | gridLayout-> addWidget ( label, 3, 0 ); | 423 | gridLayout-> addWidget ( label, 3, 0 ); |
422 | 424 | ||
423 | m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) ); | 425 | m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) ); |
424 | connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); | 426 | connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); |
425 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); | 427 | gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); |
426 | 428 | ||
427 | vertLayout-> addStretch ( 10 ); | 429 | vertLayout-> addStretch ( 10 ); |
428 | 430 | ||
429 | return tab; | 431 | return tab; |
430 | } | 432 | } |
431 | 433 | ||
432 | 434 | ||
433 | void TabDialog::iconSizeClicked ( int s ) | 435 | void TabDialog::iconSizeClicked ( int s ) |
434 | { | 436 | { |
435 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); | 437 | m_sample-> setViewMode ((TabConfig::ViewMode) s ); |
436 | } | 438 | } |
437 | 439 | ||
438 | void TabDialog::fontClicked ( const QFont &f ) | 440 | void TabDialog::fontClicked ( const QFont &f ) |
439 | { | 441 | { |
440 | m_sample-> setViewFont ( f ); | 442 | m_sample-> setViewFont ( f ); |
441 | } | 443 | } |
442 | 444 | ||
443 | void TabDialog::bgTypeClicked ( int t ) | 445 | void TabDialog::bgTypeClicked ( int t ) |
444 | { | 446 | { |
445 | QString s; | 447 | QString s; |
446 | 448 | ||
447 | if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) | 449 | if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) |
448 | m_bgtype-> setButton ( t ); | 450 | m_bgtype-> setButton ( t ); |
449 | 451 | ||
450 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); | 452 | m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); |
451 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); | 453 | m_imagebrowse-> setEnabled ( t == TabConfig::Image ); |
452 | 454 | ||
453 | if ( t == TabConfig::SolidColor ) | 455 | if ( t == TabConfig::SolidColor ) |
454 | s = m_solidcolor-> color ( ). name ( ); | 456 | s = m_solidcolor-> color ( ). name ( ); |
455 | else if ( t == TabConfig::Image ) | 457 | else if ( t == TabConfig::Image ) |
456 | s = Resource::findPixmap ( m_bgimage ); | 458 | s = Resource::findPixmap ( m_bgimage ); |
457 | 459 | ||
458 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); | 460 | m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); |
459 | } | 461 | } |
460 | 462 | ||
461 | void TabDialog::bgColorClicked ( const QColor & ) | 463 | void TabDialog::bgColorClicked ( const QColor & ) |
462 | { | 464 | { |
463 | bgTypeClicked ( TabConfig::SolidColor ); | 465 | bgTypeClicked ( TabConfig::SolidColor ); |
464 | } | 466 | } |
465 | 467 | ||
466 | void TabDialog::iconColorClicked ( const QColor &col ) | 468 | void TabDialog::iconColorClicked ( const QColor &col ) |
467 | { | 469 | { |
468 | m_sample-> setTextColor ( col ); | 470 | m_sample-> setTextColor ( col ); |
469 | } | 471 | } |
470 | 472 | ||
471 | void TabDialog::bgImageClicked ( ) | 473 | void TabDialog::bgImageClicked ( ) |
472 | { | 474 | { |
473 | // ### use OFileSelector here ### | 475 | // ### use OFileSelector here ### |
474 | // this is just a quick c&p from the old appearance app | 476 | // this is just a quick c&p from the old appearance app |
475 | 477 | ||
476 | MimeTypes types; | 478 | MimeTypes types; |
477 | QStringList list; | 479 | QStringList list; |
478 | list << "image/*"; | 480 | list << "image/*"; |
479 | types. insert ( "Images", list ); | 481 | types. insert ( "Images", list ); |
480 | 482 | ||
481 | QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types ); | 483 | QString file = OFileDialog::getOpenFileName ( 1, "/", QString::null, types ); |
482 | if ( !file. isEmpty ( )) { | 484 | if ( !file. isEmpty ( )) { |
483 | m_bgimage = DocLnk ( file ). file ( ); | 485 | m_bgimage = DocLnk ( file ). file ( ); |
484 | bgTypeClicked ( TabConfig::Image ); | 486 | bgTypeClicked ( TabConfig::Image ); |
485 | } | 487 | } |
486 | } | 488 | } |
487 | 489 | ||
488 | void TabDialog::bgDefaultClicked ( ) | 490 | void TabDialog::bgDefaultClicked ( ) |
489 | { | 491 | { |
490 | m_bgimage = "launcher/opie-background"; | 492 | m_bgimage = "launcher/opie-background"; |
491 | bgTypeClicked ( TabConfig::Image ); | 493 | bgTypeClicked ( TabConfig::Image ); |
492 | } | 494 | } |
493 | 495 | ||
494 | void TabDialog::accept ( ) | 496 | void TabDialog::accept ( ) |
495 | { | 497 | { |
496 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); | 498 | m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); |
497 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); | 499 | m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); |
498 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); | 500 | m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); |
499 | m_tc. m_bg_image = m_bgimage; | 501 | m_tc. m_bg_image = m_bgimage; |
500 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); | 502 | m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); |
501 | 503 | ||
502 | m_tc. m_font_use = m_fontuse-> isChecked ( ); | 504 | m_tc. m_font_use = m_fontuse-> isChecked ( ); |
503 | 505 | ||
504 | if ( m_tc. m_font_use ) { | 506 | if ( m_tc. m_font_use ) { |
505 | QFont f = m_fontselect-> selectedFont ( ); | 507 | QFont f = m_fontselect-> selectedFont ( ); |
506 | 508 | ||
507 | m_tc. m_font_family = f. family ( ); | 509 | m_tc. m_font_family = f. family ( ); |
508 | m_tc. m_font_size = f. pointSize ( ); | 510 | m_tc. m_font_size = f. pointSize ( ); |
509 | m_tc. m_font_weight = f. weight ( ); | 511 | m_tc. m_font_weight = f. weight ( ); |
510 | m_tc. m_font_italic = f. italic ( ); | 512 | m_tc. m_font_italic = f. italic ( ); |
511 | } | 513 | } |
512 | 514 | ||
513 | QDialog::accept ( ); | 515 | QDialog::accept ( ); |
514 | } | 516 | } |