author | sandman <sandman> | 2002-06-27 20:23:25 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-27 20:23:25 (UTC) |
commit | c9871ef295afed6bc4f4cc5451f46bf3b6e8d462 (patch) (unidiff) | |
tree | 2fa3264c0a847100d1368df6e1eae2dd5b7a47ac /noncore/styles/liquid/settings/liquidset.cpp | |
parent | 9cd1aef30015628e06e8f24b9b7e91acb631b52b (diff) | |
download | opie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.zip opie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.tar.gz opie-c9871ef295afed6bc4f4cc5451f46bf3b6e8d462.tar.bz2 |
Enhanced liquid style:
1) All WType_Popup's now get a transparent background (volume-applet)
2) Settings/Liquid Settings - a new app that acts like the KDE Control
Panel page for Liquid
Diffstat (limited to 'noncore/styles/liquid/settings/liquidset.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/styles/liquid/settings/liquidset.cpp | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/noncore/styles/liquid/settings/liquidset.cpp b/noncore/styles/liquid/settings/liquidset.cpp new file mode 100644 index 0000000..0ef5dbe --- a/dev/null +++ b/noncore/styles/liquid/settings/liquidset.cpp | |||
@@ -0,0 +1,199 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | |||
22 | |||
23 | #include "liquidset.h" | ||
24 | #include "../liquid.h" | ||
25 | |||
26 | #include <qpe/qpeapplication.h> | ||
27 | #include <qpe/global.h> | ||
28 | |||
29 | #include <qslider.h> | ||
30 | #include <qtoolbutton.h> | ||
31 | #include <qbuttongroup.h> | ||
32 | #include <qradiobutton.h> | ||
33 | #include <qcheckbox.h> | ||
34 | #include <qlabel.h> | ||
35 | #include <qlayout.h> | ||
36 | #include <qpalette.h> | ||
37 | |||
38 | #include <qpe/config.h> | ||
39 | |||
40 | #include <opie/colorpopupmenu.h> | ||
41 | |||
42 | |||
43 | static void changeButtonColor ( QWidget *btn, const QColor &col ) | ||
44 | { | ||
45 | QPalette pal = btn-> palette ( ); | ||
46 | |||
47 | pal. setColor ( QPalette::Active, QColorGroup::Button, col ); | ||
48 | pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); | ||
49 | pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); | ||
50 | |||
51 | btn-> setPalette ( pal ); | ||
52 | } | ||
53 | |||
54 | |||
55 | LiquidSet::LiquidSet ( QWidget* parent, const char *name, WFlags fl ) | ||
56 | : QDialog ( parent, name, fl ) | ||
57 | { | ||
58 | setCaption ( tr( "Liquid Style" ) ); | ||
59 | |||
60 | Config config ( "qpe" ); | ||
61 | config. setGroup ( "MosfetMenus" ); | ||
62 | |||
63 | m_type = config. readNumEntry ( "Type", TransStippleBg ); | ||
64 | m_menucol = QColor ( config. readEntry ( "Color", QApplication::palette ( ). active ( ). button ( ). name ( ))); | ||
65 | m_textcol = QColor ( config. readEntry ( "TextColor", QApplication::palette ( ). active ( ). text ( ). name ( ))); | ||
66 | int opacity = config. readNumEntry ( "Opacity", 10 ); | ||
67 | m_shadow = config. readBoolEntry ( "ShadowText", true ); | ||
68 | |||
69 | QVBoxLayout *vbox = new QVBoxLayout ( this ); | ||
70 | vbox-> setSpacing ( 3 ); | ||
71 | vbox-> setMargin ( 6 ); | ||
72 | |||
73 | QButtonGroup *btngrp = new QButtonGroup ( this ); | ||
74 | btngrp-> hide ( ); | ||
75 | |||
76 | QRadioButton *rad; | ||
77 | |||
78 | rad = new QRadioButton ( tr( "No translucency" ), this ); | ||
79 | btngrp-> insert ( rad, None ); | ||
80 | vbox-> addWidget ( rad ); | ||
81 | |||
82 | rad = new QRadioButton ( tr( "Stippled, background color" ), this ); | ||
83 | btngrp-> insert ( rad, StippledBg ); | ||
84 | vbox-> addWidget ( rad ); | ||
85 | |||
86 | rad = new QRadioButton ( tr( "Stippled, button color" ), this ); | ||
87 | btngrp-> insert ( rad, StippledBtn ); | ||
88 | vbox-> addWidget ( rad ); | ||
89 | |||
90 | rad = new QRadioButton ( tr( "Translucent stippled, background color" ), this ); | ||
91 | btngrp-> insert ( rad, TransStippleBg ); | ||
92 | vbox-> addWidget ( rad ); | ||
93 | |||
94 | rad = new QRadioButton ( tr( "Translucent stippled, button color" ), this ); | ||
95 | btngrp-> insert ( rad, TransStippleBtn ); | ||
96 | vbox-> addWidget ( rad ); | ||
97 | |||
98 | rad = new QRadioButton ( tr( "Custom translucency" ), this ); | ||
99 | btngrp-> insert ( rad, Custom ); | ||
100 | vbox-> addWidget ( rad ); | ||
101 | |||
102 | btngrp-> setExclusive ( true ); | ||
103 | btngrp-> setButton ( m_type ); | ||
104 | |||
105 | QGridLayout *grid = new QGridLayout ( vbox ); | ||
106 | grid-> addColSpacing ( 0, 16 ); | ||
107 | grid-> addColSpacing ( 3, 8 ); | ||
108 | |||
109 | grid-> addWidget ( m_menulbl = new QLabel ( tr( "Menu color" ), this ), 0, 1 ); | ||
110 | grid-> addWidget ( m_textlbl = new QLabel ( tr( "Text color" ), this ), 0, 4 ); | ||
111 | grid-> addWidget ( m_opaclbl = new QLabel ( tr( "Opacity" ), this ), 1, 1 ); | ||
112 | |||
113 | m_menubtn = new QToolButton ( this ); | ||
114 | grid-> addWidget ( m_menubtn, 0, 2 ); | ||
115 | |||
116 | QPopupMenu *popup; | ||
117 | |||
118 | popup = new ColorPopupMenu ( m_menucol, this ); | ||
119 | m_menubtn-> setPopup ( popup ); | ||
120 | m_menubtn-> setPopupDelay ( 0 ); | ||
121 | connect ( popup, SIGNAL( colorSelected ( const QColor & )), this, SLOT( changeMenuColor ( const QColor & ))); | ||
122 | changeMenuColor ( m_menucol ); | ||
123 | |||
124 | m_textbtn = new QToolButton ( this ); | ||
125 | grid-> addWidget ( m_textbtn, 0, 5 ); | ||
126 | |||
127 | popup = new ColorPopupMenu ( m_textcol, this ); | ||
128 | m_textbtn-> setPopup ( popup ); | ||
129 | m_textbtn-> setPopupDelay ( 0 ); | ||
130 | connect ( popup, SIGNAL( colorSelected ( const QColor & )), this, SLOT( changeTextColor ( const QColor & ))); | ||
131 | changeTextColor ( m_textcol ); | ||
132 | |||
133 | m_opacsld = new QSlider ( Horizontal, this ); | ||
134 | m_opacsld-> setRange ( -20, 20 ); | ||
135 | m_opacsld-> setValue ( opacity ); | ||
136 | m_opacsld-> setTickmarks ( QSlider::Below ); | ||
137 | grid-> addMultiCellWidget ( m_opacsld, 1, 1, 2, 5 ); | ||
138 | |||
139 | vbox-> addSpacing ( 4 ); | ||
140 | |||
141 | QCheckBox *shadow = new QCheckBox ( tr( "Use shadowed text" ), this ); | ||
142 | shadow-> setChecked ( m_shadow ); | ||
143 | vbox-> addWidget ( shadow ); | ||
144 | |||
145 | vbox-> addStretch ( 10 ); | ||
146 | |||
147 | connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( changeType ( int ) ) ); | ||
148 | connect ( shadow, SIGNAL( toggled ( bool ) ), this, SLOT( changeShadow ( bool ) ) ); | ||
149 | } | ||
150 | |||
151 | void LiquidSet::changeType ( int t ) | ||
152 | { | ||
153 | bool custom = ( t == Custom ); | ||
154 | |||
155 | m_menulbl-> setEnabled ( custom ); | ||
156 | m_textlbl-> setEnabled ( custom ); | ||
157 | m_opaclbl-> setEnabled ( custom ); | ||
158 | m_menubtn-> setEnabled ( custom ); | ||
159 | m_textbtn-> setEnabled ( custom ); | ||
160 | m_opacsld-> setEnabled ( custom ); | ||
161 | |||
162 | m_type = t; | ||
163 | } | ||
164 | |||
165 | void LiquidSet::changeMenuColor ( const QColor &col ) | ||
166 | { | ||
167 | m_menubtn-> setPalette ( col ); | ||
168 | m_menucol = col; | ||
169 | } | ||
170 | |||
171 | void LiquidSet::changeTextColor ( const QColor &col ) | ||
172 | { | ||
173 | m_textbtn-> setPalette ( col ); | ||
174 | m_textcol = col; | ||
175 | } | ||
176 | |||
177 | void LiquidSet::changeShadow ( bool b ) | ||
178 | { | ||
179 | m_shadow = b; | ||
180 | } | ||
181 | |||
182 | |||
183 | void LiquidSet::accept ( ) | ||
184 | { | ||
185 | Config config ( "qpe" ); | ||
186 | config. setGroup ( "MosfetMenus" ); | ||
187 | |||
188 | config. writeEntry ( "Type", m_type ); | ||
189 | config. writeEntry ( "Color", m_menucol. name ( )); | ||
190 | config. writeEntry ( "TextColor", m_textcol. name ( )); | ||
191 | config. writeEntry ( "Opacity", m_opacsld-> value ( )); | ||
192 | config. writeEntry ( "ShadowText", m_shadow ); | ||
193 | config. write ( ); | ||
194 | |||
195 | Global::applyStyle ( ); | ||
196 | |||
197 | QDialog::accept ( ); | ||
198 | } | ||
199 | |||