summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/launcher/launcher.pro17
-rw-r--r--core/settings/launcher/launchersettings.cpp39
-rw-r--r--core/settings/launcher/launchersettings.h23
-rw-r--r--core/settings/launcher/main.cpp35
-rw-r--r--core/settings/launcher/tabssettings.cpp177
-rw-r--r--core/settings/launcher/tabssettings.h52
-rw-r--r--core/settings/launcher/taskbarsettings.cpp169
-rw-r--r--core/settings/launcher/taskbarsettings.h35
8 files changed, 547 insertions, 0 deletions
diff --git a/core/settings/launcher/launcher.pro b/core/settings/launcher/launcher.pro
new file mode 100644
index 0000000..a46a22f
--- a/dev/null
+++ b/core/settings/launcher/launcher.pro
@@ -0,0 +1,17 @@
1TEMPLATE = app
2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = launchersettings.h \
5 tabssettings.h \
6 taskbarsettings.h
7
8SOURCES = main.cpp \
9 launchersettings.cpp \
10 tabssettings.cpp \
11 taskbarsettings.cpp
12
13INCLUDEPATH += $(OPIEDIR)/include
14DEPENDPATH += $(OPIEDIR)/include
15LIBS += -lqpe -lopie
16TARGET = launchersettings
17
diff --git a/core/settings/launcher/launchersettings.cpp b/core/settings/launcher/launchersettings.cpp
new file mode 100644
index 0000000..b794519
--- a/dev/null
+++ b/core/settings/launcher/launchersettings.cpp
@@ -0,0 +1,39 @@
1
2#include <qlayout.h>
3
4#include <opie/otabwidget.h>
5
6#include "launchersettings.h"
7#include "tabssettings.h"
8#include "taskbarsettings.h"
9
10
11LauncherSettings::LauncherSettings ( ) : QDialog ( 0, "LauncherSettings", false )
12{
13 setCaption ( tr( "Launcher Settings" ));
14
15 QVBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
16
17 OTabWidget *tw = new OTabWidget ( this, "otab" );
18 lay-> addWidget ( tw );
19
20 m_tabs = new TabsSettings ( tw );
21 m_taskbar = new TaskbarSettings ( tw );
22
23 tw-> addTab ( m_taskbar, "appearance/styletabicon.png", tr( "Taskbar" ));
24 tw-> addTab ( m_tabs, "appearance/styletabicon.png", tr( "Tabs" ));
25}
26
27void LauncherSettings::accept ( )
28{
29 m_taskbar-> accept ( );
30 m_tabs-> accept ( );
31
32 QDialog::accept ( );
33}
34
35void LauncherSettings::done ( int r )
36{
37 QDialog::done ( r );
38 close ( );
39}
diff --git a/core/settings/launcher/launchersettings.h b/core/settings/launcher/launchersettings.h
new file mode 100644
index 0000000..c91c765
--- a/dev/null
+++ b/core/settings/launcher/launchersettings.h
@@ -0,0 +1,23 @@
1#ifndef __LAUNCHER_SETTINGS_H__
2#define __LAUNCHER_SETTINGS_H__
3
4#include <qdialog.h>
5
6class TabsSettings;
7class TaskbarSettings;
8
9class LauncherSettings : public QDialog {
10 Q_OBJECT
11
12public:
13 LauncherSettings ( );
14
15 virtual void accept ( );
16 virtual void done ( int r );
17
18private:
19 TabsSettings *m_tabs;
20 TaskbarSettings *m_taskbar;
21};
22
23#endif
diff --git a/core/settings/launcher/main.cpp b/core/settings/launcher/main.cpp
new file mode 100644
index 0000000..ca7102d
--- a/dev/null
+++ b/core/settings/launcher/main.cpp
@@ -0,0 +1,35 @@
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 "launchersettings.h"
22
23#include <qpe/qpeapplication.h>
24
25
26int main ( int argc, char** argv )
27{
28 QPEApplication a ( argc,argv );
29
30 LauncherSettings dlg;
31 a. showMainWidget ( &dlg );
32
33 return a. exec ( );
34}
35
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
38TabsSettings::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
57void 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
78void 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
118void 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
diff --git a/core/settings/launcher/tabssettings.h b/core/settings/launcher/tabssettings.h
new file mode 100644
index 0000000..17b6e25
--- a/dev/null
+++ b/core/settings/launcher/tabssettings.h
@@ -0,0 +1,52 @@
1#ifndef __TABS_SETTINGS_H__
2#define __TABS_SETTINGS_H__
3
4#include <qwidget.h>
5#include <qmap.h>
6
7class QListView;
8
9
10class TabsSettings : public QWidget {
11 Q_OBJECT
12
13public:
14 TabsSettings ( QWidget *parent = 0, const char *name = 0 );
15
16 void accept ( );
17
18 enum ViewMode {
19 Icon,
20 List
21 };
22 enum BackgroundType {
23 Ruled,
24 SolidColor,
25 Image
26 };
27 struct TabSettings {
28 ViewMode m_view;
29 BackgroundType m_bg_type;
30 QString m_bg_image;
31 QString m_bg_color;
32 QString m_text_color;
33 QString m_font_family;
34 int m_font_size;
35 bool m_changed;
36 };
37
38protected:
39 void init ( );
40 void readTabSettings ( );
41
42private:
43 QListView *m_list;
44 //QString currentTab;
45 QStringList m_ids;
46 QMap <QString, TabSettings> m_tabs;
47};
48
49
50
51
52#endif
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
new file mode 100644
index 0000000..8f16951
--- a/dev/null
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -0,0 +1,169 @@
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 "taskbarsettings.h"
22
23#include <qpe/config.h>
24#include <qpe/qlibrary.h>
25#include <qpe/qpeapplication.h>
26#include <qpe/taskbarappletinterface.h>
27#include <qpe/qcopenvelope_qws.h>
28
29#include <qdir.h>
30#include <qlistview.h>
31#include <qcheckbox.h>
32#include <qheader.h>
33#include <qlayout.h>
34#include <qlabel.h>
35#include <qwhatsthis.h>
36
37#include <stdlib.h>
38
39
40TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
41 : QWidget ( parent, name )
42{
43 m_applets_changed = false;
44
45 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
46
47 QLabel *l = new QLabel ( tr( "Load applets:" ), this );
48 lay-> addWidget ( l );
49
50 m_list = new QListView ( this );
51 m_list-> addColumn ( "foobar" );
52 m_list-> header ( )-> hide ( );
53
54 lay-> addWidget ( m_list );
55
56 m_omenu = new QCheckBox ( tr( "Show O-Menu" ), this );
57 lay-> addWidget ( m_omenu );
58
59 m_omenu_tabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
60 lay-> addWidget ( m_omenu_tabs );
61
62 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
63 QWhatsThis::add( m_omenu_tabs, tr( "Adds the contents of the Launcher as menus in the O-Menu." ));
64 QWhatsThis::add( m_omenu, tr( "Check if you want the O-Menu in the taskbar." ));
65
66 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( )));
67 connect ( m_omenu, SIGNAL( toggled ( bool )), m_omenu_tabs, SLOT( setEnabled ( bool )));
68
69 // This option does not make sense ! (sandman)
70 m_omenu_tabs-> hide ( );
71
72 init ( );
73}
74
75void TaskbarSettings::init ( )
76{
77 Config cfg ( "Taskbar" );
78 cfg. setGroup ( "Applets" );
79 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
80
81 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
82 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
83
84 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
85 QString name;
86 QPixmap icon;
87 TaskbarNamedAppletInterface *iface = 0;
88
89 QLibrary *lib = new QLibrary ( path + "/" + *it );
90 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface );
91 if ( iface ) {
92 QString lang = getenv( "LANG" );
93 QTranslator *trans = new QTranslator ( qApp );
94 QString type = (*it). left ((*it). find ("."));
95 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
96 if ( trans-> load ( tfn ))
97 qApp-> installTranslator ( trans );
98 else
99 delete trans;
100 name = iface-> name ( );
101 icon = iface-> icon ( );
102 iface-> release ( );
103 lib-> unload ( );
104 } else {
105 delete lib;
106 name = (*it). mid ( 3 );
107 int sep = name. find( ".so" );
108 if ( sep > 0 )
109 name. truncate ( sep );
110 sep = name. find ( "applet" );
111 if ( sep == (int) name.length ( ) - 6 )
112 name. truncate ( sep );
113 name[0] = name[0]. upper ( );
114 }
115 QCheckListItem *item;
116 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
117 if ( !icon. isNull ( ))
118 item-> setPixmap ( 0, icon );
119 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
120 m_applets [*it] = item;
121 }
122
123 cfg. setGroup ( "Menu" );
124
125 m_omenu_tabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true ));
126 m_omenu-> setChecked ( cfg. readBoolEntry ( "ShowMenu", true ));
127
128 m_omenu_tabs-> setEnabled ( m_omenu-> isChecked ( ));
129}
130
131void TaskbarSettings::appletChanged()
132{
133 m_applets_changed = true;
134}
135
136void TaskbarSettings::accept ( )
137{
138 Config cfg ( "Taskbar" );
139 cfg. setGroup ( "Applets" );
140 if ( m_applets_changed ) {
141 QStringList exclude;
142 QMap <QString, QCheckListItem *>::Iterator it;
143 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
144 if ( !(*it)-> isOn ( ))
145 exclude << it. key ( );
146 }
147 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
148 }
149 cfg. writeEntry ( "SafeMode", false );
150
151 cfg. setGroup ( "Menu" );
152
153 if ( m_omenu_tabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
154 m_applets_changed = true;
155 cfg. writeEntry ( "LauncherTabs", m_omenu_tabs-> isChecked ( ));
156 }
157
158 if ( m_omenu-> isChecked ( ) != cfg. readBoolEntry ( "ShowMenu", true )) {
159 m_applets_changed = true;
160 cfg. writeEntry ( "ShowMenu", m_omenu-> isChecked ( ));
161 }
162 cfg. write ( );
163
164 if ( m_applets_changed ) {
165 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
166 m_applets_changed = false;
167 }
168}
169
diff --git a/core/settings/launcher/taskbarsettings.h b/core/settings/launcher/taskbarsettings.h
new file mode 100644
index 0000000..b8c6fbb
--- a/dev/null
+++ b/core/settings/launcher/taskbarsettings.h
@@ -0,0 +1,35 @@
1#ifndef __TASKBAR_SETTINGS_H__
2#define __TASKBAR_SETTINGS_H__
3
4#include <qwidget.h>
5#include <qmap.h>
6
7class QListView;
8class QCheckListItem;
9class QCheckBox;
10
11
12class TaskbarSettings : public QWidget {
13 Q_OBJECT
14
15public:
16 TaskbarSettings ( QWidget *parent = 0, const char *name = 0 );
17
18 void accept ( );
19
20protected slots:
21 void appletChanged ( );
22
23protected:
24 void init ( );
25
26private:
27 QListView *m_list;
28 QCheckBox *m_omenu;
29 QCheckBox *m_omenu_tabs;
30
31 QMap <QString, QCheckListItem *> m_applets;
32 bool m_applets_changed;
33};
34
35#endif