author | sandman <sandman> | 2002-09-12 01:54:38 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-12 01:54:38 (UTC) |
commit | 5443baf95c52ed0ead459fec48cb877d71a0e427 (patch) (unidiff) | |
tree | 80718baad2fda769200ef442bcd7bf4e86ba9c82 /core/settings/launcher/tabssettings.cpp | |
parent | b35aa16e051554783b30f1551ad7677e382cc823 (diff) | |
download | opie-5443baf95c52ed0ead459fec48cb877d71a0e427.zip opie-5443baf95c52ed0ead459fec48cb877d71a0e427.tar.gz opie-5443baf95c52ed0ead459fec48cb877d71a0e427.tar.bz2 |
New launcher/taskbar settings (merge from QPE 1.6 - reworked)
Diffstat (limited to 'core/settings/launcher/tabssettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/launcher/tabssettings.cpp | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp new file mode 100644 index 0000000..292c615 --- a/dev/null +++ b/core/settings/launcher/tabssettings.cpp | |||
@@ -0,0 +1,177 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the 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 | #include "tabssettings.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpe/resource.h> | ||
25 | #include <qpe/applnk.h> | ||
26 | #include <qpe/mimetype.h> | ||
27 | #include <qpe/qcopenvelope_qws.h> | ||
28 | #include <qpe/config.h> | ||
29 | |||
30 | #include <qlistview.h> | ||
31 | #include <qheader.h> | ||
32 | #include <qlayout.h> | ||
33 | #include <qlabel.h> | ||
34 | #include <qwhatsthis.h> | ||
35 | |||
36 | #include <stdlib.h> | ||
37 | |||
38 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) | ||
39 | : QWidget ( parent, name ) | ||
40 | { | ||
41 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); | ||
42 | |||
43 | QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); | ||
44 | lay-> addWidget ( l ); | ||
45 | |||
46 | m_list = new QListView ( this ); | ||
47 | m_list-> addColumn ( "foobar" ); | ||
48 | m_list-> header ( )-> hide ( ); | ||
49 | |||
50 | lay-> addWidget ( m_list ); | ||
51 | |||
52 | QWhatsThis::add ( m_list, tr( "foobar" )); | ||
53 | |||
54 | init ( ); | ||
55 | } | ||
56 | |||
57 | void TabsSettings::init ( ) | ||
58 | { | ||
59 | QListViewItem *lvi; | ||
60 | |||
61 | AppLnkSet rootFolder( MimeType::appsFolderName ( )); | ||
62 | QStringList types = rootFolder. types ( ); | ||
63 | for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { | ||
64 | lvi = new QListViewItem ( m_list, rootFolder. typeName ( *it )); | ||
65 | lvi-> setPixmap ( 0, rootFolder. typePixmap ( *it )); | ||
66 | m_ids << *it; | ||
67 | } | ||
68 | QImage img ( Resource::loadImage ( "DocsIcon" )); | ||
69 | QPixmap pix; | ||
70 | pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); | ||
71 | lvi = new QListViewItem ( m_list, tr( "Documents" )); | ||
72 | lvi-> setPixmap ( 0, pix ); | ||
73 | m_ids += "Documents"; // No tr | ||
74 | |||
75 | readTabSettings ( ); | ||
76 | } | ||
77 | |||
78 | void TabsSettings::readTabSettings ( ) | ||
79 | { | ||
80 | Config cfg ( "Launcher" ); | ||
81 | QString grp ( "Tab %1" ); // No tr | ||
82 | m_tabs. clear ( ); | ||
83 | |||
84 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | ||
85 | TabSettings ts; | ||
86 | ts. m_view = Icon; | ||
87 | ts. m_bg_type = Ruled; | ||
88 | ts. m_changed = false; | ||
89 | |||
90 | cfg. setGroup ( grp. arg ( *it )); | ||
91 | |||
92 | QString view = cfg. readEntry ( "View", "Icon" ); | ||
93 | if ( view == "List" ) // No tr | ||
94 | ts. m_view = List; | ||
95 | |||
96 | QString bgType = cfg. readEntry ( "BackgroundType", "Ruled" ); | ||
97 | if ( bgType == "SolidColor" ) | ||
98 | ts. m_bg_type = SolidColor; | ||
99 | else if ( bgType == "Image" ) // No tr | ||
100 | ts. m_bg_type = Image; | ||
101 | |||
102 | ts. m_bg_image = cfg. readEntry ( "BackgroundImage", "wallpaper/opie" ); | ||
103 | ts. m_bg_color = cfg. readEntry ( "BackgroundColor" ); | ||
104 | ts. m_text_color = cfg. readEntry ( "TextColor" ); | ||
105 | QStringList f = cfg. readListEntry ( "Font", ',' ); | ||
106 | if ( f. count ( ) == 4 ) { | ||
107 | ts. m_font_family = f [0]; | ||
108 | ts. m_font_size = f [1]. toInt ( ); | ||
109 | } else { | ||
110 | ts. m_font_family = font ( ). family ( ); | ||
111 | ts. m_font_size = font ( ). pointSize ( ); | ||
112 | } | ||
113 | m_tabs [*it] = ts; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | |||
118 | void TabsSettings::accept ( ) | ||
119 | { | ||
120 | Config cfg ( "Launcher" ); | ||
121 | |||
122 | // Launcher Tab | ||
123 | QString grp ( "Tab %1" ); // No tr | ||
124 | |||
125 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | ||
126 | TabSettings &tab = m_tabs [*it]; | ||
127 | |||
128 | cfg. setGroup ( grp. arg ( *it )); | ||
129 | if ( !tab. m_changed ) | ||
130 | continue; | ||
131 | switch ( tab. m_view ) { | ||
132 | case Icon: | ||
133 | cfg.writeEntry ( "View", "Icon" ); | ||
134 | break; | ||
135 | case List: | ||
136 | cfg.writeEntry ( "View", "List" ); | ||
137 | break; | ||
138 | } | ||
139 | |||
140 | QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); | ||
141 | e << *it << tab. m_view; | ||
142 | |||
143 | cfg. writeEntry ( "BackgroundImage", tab. m_bg_image ); | ||
144 | cfg. writeEntry ( "BackgroundColor", tab. m_bg_color ); | ||
145 | cfg. writeEntry ( "TextColor", tab. m_text_color ); | ||
146 | |||
147 | QString f = tab. m_font_family + "," + QString::number ( tab. m_font_size ) + ",50,0"; | ||
148 | cfg. writeEntry ( "Font", f ); | ||
149 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); | ||
150 | |||
151 | switch ( tab. m_bg_type ) { | ||
152 | case Ruled: | ||
153 | cfg.writeEntry( "BackgroundType", "Ruled" ); | ||
154 | be << *it << tab. m_bg_type << QString(""); | ||
155 | break; | ||
156 | case SolidColor: | ||
157 | cfg.writeEntry( "BackgroundType", "SolidColor" ); | ||
158 | be << *it << tab. m_bg_type << tab. m_bg_color; | ||
159 | break; | ||
160 | case Image: | ||
161 | cfg.writeEntry( "BackgroundType", "Image" ); | ||
162 | be << *it << tab. m_bg_type << tab. m_bg_image; | ||
163 | break; | ||
164 | } | ||
165 | |||
166 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); | ||
167 | te << *it << tab. m_text_color; | ||
168 | |||
169 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); | ||
170 | fe << *it << tab. m_font_family; | ||
171 | fe << tab. m_font_size; | ||
172 | fe << 50 << 0; | ||
173 | |||
174 | tab. m_changed = false; | ||
175 | } | ||
176 | } | ||
177 | |||