author | sandman <sandman> | 2002-10-31 03:07:50 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-31 03:07:50 (UTC) |
commit | d9d6cc6b3a537439affc8095dedd046c86f09d9e (patch) (unidiff) | |
tree | 3b18a42dfc9f32eecc799104b3fea201ff8a14ba /core/settings/launcher/tabssettings.cpp | |
parent | 035eaf63bb2156ea7facd6b50f8891503d1f7bed (diff) | |
download | opie-d9d6cc6b3a537439affc8095dedd046c86f09d9e.zip opie-d9d6cc6b3a537439affc8095dedd046c86f09d9e.tar.gz opie-d9d6cc6b3a537439affc8095dedd046c86f09d9e.tar.bz2 |
- added a "[x] Use custom font" checkbox -- if this is not checked
(default), then launcher uses the global font for the tabs.
- reworked the internal handling of "All tabs", to make it possible to use
this information for newly added tabs (still missing)
Diffstat (limited to 'core/settings/launcher/tabssettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/launcher/tabssettings.cpp | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp index a5afaf2..9d6e8c1 100644 --- a/core/settings/launcher/tabssettings.cpp +++ b/core/settings/launcher/tabssettings.cpp | |||
@@ -46,9 +46,9 @@ | |||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | 48 | ||
49 | 49 | ||
50 | #define GLOBALID "_launchersettings_global_dummy_" | 50 | #define GLOBALID ".global." |
51 | 51 | ||
52 | 52 | ||
53 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) | 53 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) |
54 | : QWidget ( parent, name ) | 54 | : QWidget ( parent, name ) |
@@ -123,44 +123,52 @@ void TabsSettings::readTabSettings ( Config &cfg ) | |||
123 | { | 123 | { |
124 | QString grp ( "Tab %1" ); // No tr | 124 | QString grp ( "Tab %1" ); // No tr |
125 | m_tabs. clear ( ); | 125 | m_tabs. clear ( ); |
126 | 126 | ||
127 | TabConfig global_def; | ||
128 | global_def. m_view = TabConfig::Icon; | ||
129 | global_def. m_bg_type = TabConfig::Ruled; | ||
130 | global_def. m_bg_image = "launcher/opie-background"; | ||
131 | global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); | ||
132 | global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); | ||
133 | global_def. m_font_use = false; | ||
134 | global_def. m_font_family = font ( ). family ( ); | ||
135 | global_def. m_font_size = font ( ). pointSize ( ); | ||
136 | global_def. m_font_weight = 50; | ||
137 | global_def. m_font_italic = false; | ||
138 | global_def. m_changed = false; | ||
139 | |||
140 | |||
127 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 141 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
128 | TabConfig tc; | 142 | TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; |
129 | tc. m_view = TabConfig::Icon; | ||
130 | tc. m_bg_type = TabConfig::Ruled; | ||
131 | tc. m_changed = false; | ||
132 | 143 | ||
133 | cfg. setGroup ( grp. arg ( *it )); | 144 | cfg. setGroup ( grp. arg ( *it )); |
134 | if ( *it == GLOBALID ) | ||
135 | cfg. clearGroup ( ); | ||
136 | 145 | ||
137 | QString view = cfg. readEntry ( "View", "Icon" ); | 146 | QString view = cfg. readEntry ( "View" ); |
147 | if ( view == "Icon" ) // No tr | ||
148 | tc. m_view = TabConfig::Icon; | ||
138 | if ( view == "List" ) // No tr | 149 | if ( view == "List" ) // No tr |
139 | tc. m_view = TabConfig::List; | 150 | tc. m_view = TabConfig::List; |
140 | 151 | ||
141 | QString bgType = cfg. readEntry ( "BackgroundType", "Image" ); | 152 | QString bgType = cfg. readEntry ( "BackgroundType" ); |
142 | if ( bgType == "SolidColor" ) | 153 | if ( bgType == "Image" ) |
154 | tc. m_bg_type = TabConfig::Image; | ||
155 | else if ( bgType == "SolidColor" ) | ||
143 | tc. m_bg_type = TabConfig::SolidColor; | 156 | tc. m_bg_type = TabConfig::SolidColor; |
144 | else if ( bgType == "Image" ) // No tr | 157 | else if ( bgType == "Image" ) // No tr |
145 | tc. m_bg_type = TabConfig::Image; | 158 | tc. m_bg_type = TabConfig::Image; |
146 | 159 | ||
147 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", "launcher/opie-background" ); | 160 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); |
148 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", colorGroup ( ). color ( QColorGroup::Base ). name ( )); | 161 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); |
149 | tc. m_text_color = cfg. readEntry ( "TextColor", colorGroup ( ). color ( QColorGroup::Text ). name ( )); | 162 | tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); |
150 | QStringList f = cfg. readListEntry ( "Font", ',' ); | 163 | QStringList f = cfg. readListEntry ( "Font", ',' ); |
151 | if ( f. count ( ) == 4 ) { | 164 | if ( f. count ( ) == 4 ) { |
165 | tc. m_font_use = true; | ||
152 | tc. m_font_family = f [0]; | 166 | tc. m_font_family = f [0]; |
153 | tc. m_font_size = f [1]. toInt ( ); | 167 | tc. m_font_size = f [1]. toInt ( ); |
154 | tc. m_font_weight = f [2]. toInt ( ); | 168 | tc. m_font_weight = f [2]. toInt ( ); |
155 | tc. m_font_italic = ( f [3]. toInt ( )); | 169 | tc. m_font_italic = ( f [3]. toInt ( )); |
156 | } else { | 170 | } |
157 | tc. m_font_family = font ( ). family ( ); | ||
158 | tc. m_font_size = font ( ). pointSize ( ); | ||
159 | tc. m_font_weight = 50; | ||
160 | tc. m_font_italic = false; | ||
161 | } | ||
162 | |||
163 | m_tabs [*it] = tc; | 171 | m_tabs [*it] = tc; |
164 | } | 172 | } |
165 | 173 | ||
166 | // if all tabs have the same config, then initialize the GLOBALID tab to these values | 174 | // if all tabs have the same config, then initialize the GLOBALID tab to these values |
@@ -175,10 +183,12 @@ void TabsSettings::readTabSettings ( Config &cfg ) | |||
175 | first = &m_tabs [*it]; | 183 | first = &m_tabs [*it]; |
176 | else | 184 | else |
177 | same &= ( *first == m_tabs [*it] ); | 185 | same &= ( *first == m_tabs [*it] ); |
178 | } | 186 | } |
179 | if ( same ) | 187 | if ( same ) { |
180 | m_tabs [GLOBALID] = *first; | 188 | m_tabs [GLOBALID] = *first; |
189 | m_tabs [GLOBALID]. m_changed = true; | ||
190 | } | ||
181 | } | 191 | } |
182 | 192 | ||
183 | 193 | ||
184 | void TabsSettings::accept ( ) | 194 | void TabsSettings::accept ( ) |
@@ -190,9 +200,9 @@ void TabsSettings::accept ( ) | |||
190 | 200 | ||
191 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 201 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
192 | TabConfig &tc = m_tabs [*it]; | 202 | TabConfig &tc = m_tabs [*it]; |
193 | 203 | ||
194 | if ( !tc. m_changed || ( *it == GLOBALID )) | 204 | if ( !tc. m_changed ) |
195 | continue; | 205 | continue; |
196 | 206 | ||
197 | cfg. setGroup ( grp. arg ( *it )); | 207 | cfg. setGroup ( grp. arg ( *it )); |
198 | switch ( tc. m_view ) { | 208 | switch ( tc. m_view ) { |
@@ -210,10 +220,15 @@ void TabsSettings::accept ( ) | |||
210 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); | 220 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); |
211 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); | 221 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); |
212 | cfg. writeEntry ( "TextColor", tc. m_text_color ); | 222 | cfg. writeEntry ( "TextColor", tc. m_text_color ); |
213 | 223 | ||
214 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); | 224 | if ( tc. m_font_use ) { |
215 | cfg. writeEntry ( "Font", f ); | 225 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); |
226 | cfg. writeEntry ( "Font", f ); | ||
227 | } | ||
228 | else | ||
229 | cfg. removeEntry ( "Font" ); | ||
230 | |||
216 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); | 231 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); |
217 | 232 | ||
218 | switch ( tc. m_bg_type ) { | 233 | switch ( tc. m_bg_type ) { |
219 | case TabConfig::Ruled: | 234 | case TabConfig::Ruled: |
@@ -233,11 +248,13 @@ void TabsSettings::accept ( ) | |||
233 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); | 248 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); |
234 | te << *it << tc. m_text_color; | 249 | te << *it << tc. m_text_color; |
235 | 250 | ||
236 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); | 251 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); |
237 | fe << *it << tc. m_font_family; | 252 | fe << *it; |
253 | fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); | ||
238 | fe << tc. m_font_size; | 254 | fe << tc. m_font_size; |
239 | fe << tc. m_font_weight << ( tc. m_font_italic ? 1 : 0 ); | 255 | fe << tc. m_font_weight; |
256 | fe << ( tc. m_font_italic ? 1 : 0 ); | ||
240 | 257 | ||
241 | tc. m_changed = false; | 258 | tc. m_changed = false; |
242 | } | 259 | } |
243 | cfg. setGroup ( "GUI" ); | 260 | cfg. setGroup ( "GUI" ); |