summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/button/remapdlg.cpp72
-rw-r--r--core/settings/citytime/citytime.cpp94
-rw-r--r--core/settings/citytime/citytimebase.cpp120
-rw-r--r--core/settings/citytime/zonemap.cpp402
-rw-r--r--core/settings/launcher/doctabsettings.cpp6
-rw-r--r--core/settings/launcher/inputmethodsettings.cpp6
-rw-r--r--core/settings/launcher/tabdialog.cpp632
-rw-r--r--core/settings/launcher/taskbarsettings.cpp196
-rw-r--r--core/settings/light-and-power/light.cpp387
-rw-r--r--core/settings/security/security.cpp58
-rw-r--r--core/settings/security/security.pro14
-rw-r--r--core/symlinker/main.cpp220
-rw-r--r--core/symlinker/symlinker.pro18
-rw-r--r--core/tools/quicklauncher/main.cpp231
14 files changed, 1255 insertions, 1201 deletions
diff --git a/core/settings/button/remapdlg.cpp b/core/settings/button/remapdlg.cpp
index 4effebc..cadb955 100644
--- a/core/settings/button/remapdlg.cpp
+++ b/core/settings/button/remapdlg.cpp
@@ -1,136 +1,142 @@
1
2#include "remapdlg.h"
3#include "buttonutils.h"
4
5/* OPIE */
6#include <opie2/odebug.h>
7
8/* QT */
1#include <qlistview.h> 9#include <qlistview.h>
2#include <qcombobox.h> 10#include <qcombobox.h>
3#include <qtimer.h> 11#include <qtimer.h>
4 12
5#include "remapdlg.h"
6#include "buttonutils.h"
7 13
8 14
9using namespace Opie::Core; 15using namespace Opie::Core;
10class NoSortItem : public QListViewItem { 16class NoSortItem : public QListViewItem {
11public: 17public:
12 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 ) 18 NoSortItem ( QListView *lv, uint pos, const QString &str, const QCString &s1 = 0, const QCString &s2 = 0 )
13 : QListViewItem ( lv, str, s1, s2 ) 19 : QListViewItem ( lv, str, s1, s2 )
14 { 20 {
15 m_key = QString ( QChar ( 'a' + pos )); 21 m_key = QString ( QChar ( 'a' + pos ));
16 m_def = false; 22 m_def = false;
17 } 23 }
18 24
19 void setDefault ( bool b ) 25 void setDefault ( bool b )
20 { 26 {
21 m_def = b; 27 m_def = b;
22 } 28 }
23 29
24 virtual QString key ( int /*column*/, bool /*ascending*/ ) const 30 virtual QString key ( int /*column*/, bool /*ascending*/ ) const
25 { 31 {
26 return m_key; 32 return m_key;
27 } 33 }
28 34
29 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) 35 virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
30 { 36 {
31 if ( m_def ) { 37 if ( m_def ) {
32 QFont f ( listView ( )-> font ( )); 38 QFont f ( listView ( )-> font ( ));
33 f. setBold ( true ); 39 f. setBold ( true );
34 p-> setFont ( f ); 40 p-> setFont ( f );
35 } 41 }
36 QListViewItem::paintCell ( p, cg, column, width, align ); 42 QListViewItem::paintCell ( p, cg, column, width, align );
37 } 43 }
38 44
39private: 45private:
40 QString m_key; 46 QString m_key;
41 bool m_def; 47 bool m_def;
42}; 48};
43 49
44 50
45RemapDlg::RemapDlg ( const Opie::Core::ODeviceButton *b, bool hold, QWidget *parent, const char *name ) 51RemapDlg::RemapDlg ( const Opie::Core::ODeviceButton *b, bool hold, QWidget *parent, const char *name )
46 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp ) 52 : RemapDlgBase ( parent, name, true, WStyle_ContextHelp )
47{ 53{
48 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( ))); 54 setCaption ( tr( "%1 %2", "(hold|press) buttoname" ). arg( hold ? tr( "Held" ) : tr( "Pressed" )). arg ( b-> userText ( )));
49 55
50 m_current = 0; 56 m_current = 0;
51 57
52 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 }; 58 static const char * const def_channels [] = { "QPE/Application/", "QPE/Launcher", "QPE/System", "QPE/TaskBar", "QPE/", 0 };
53 w_channel-> insertStrList ((const char **) def_channels ); 59 w_channel-> insertStrList ((const char **) def_channels );
54 60
55 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( ); 61 m_msg = hold ? b-> heldAction ( ) : b-> pressedAction ( );
56 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( ); 62 m_msg_preset = hold ? b-> factoryPresetHeldAction ( ) : b-> factoryPresetPressedAction ( );
57 63
58 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" )); 64 m_map_none = new NoSortItem ( w_list, 0, tr( "No mapping" ));
59 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 65 m_map_preset = new NoSortItem ( w_list, 1, tr( "Default" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
60 ((NoSortItem *) m_map_preset )-> setDefault ( true ); 66 ((NoSortItem *) m_map_preset )-> setDefault ( true );
61 67
62 if (m_msg. channel ( ) == "ignore") 68 if (m_msg. channel ( ) == "ignore")
63 { 69 {
64 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( )); 70 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg_preset. channel ( ), m_msg_preset. message ( ));
65 71
66 m_current = m_map_none; 72 m_current = m_map_none;
67 } 73 }
68 else 74 else
69 { 75 {
70 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( )); 76 m_map_custom = new NoSortItem ( w_list, 2, tr( "Custom" ), m_msg. channel ( ), m_msg. message ( ));
71 m_current = m_map_custom; 77 m_current = m_map_custom;
72 } 78 }
73 79
74 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" )); 80 QListViewItem *it = new NoSortItem ( w_list, 3, tr( "Actions" ));
75 ButtonUtils::inst ( )-> insertActions ( it ); 81 ButtonUtils::inst ( )-> insertActions ( it );
76 it-> setOpen ( true ); 82 it-> setOpen ( true );
77 83
78 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" )); 84 m_map_show = new NoSortItem ( w_list, 4, tr( "Show" ));
79 85
80 w_list-> setCurrentItem ( m_current ); 86 w_list-> setCurrentItem ( m_current );
81 87
82 QTimer::singleShot ( 0, this, SLOT( delayedInit())); 88 QTimer::singleShot ( 0, this, SLOT( delayedInit()));
83} 89}
84 90
85RemapDlg::~RemapDlg ( ) 91RemapDlg::~RemapDlg ( )
86{ 92{
87} 93}
88 94
89void RemapDlg::delayedInit ( ) 95void RemapDlg::delayedInit ( )
90{ 96{
91 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( ); 97 bool b = w_list-> viewport ( )-> isUpdatesEnabled ( );
92 w_list-> viewport ( )-> setUpdatesEnabled ( false ); 98 w_list-> viewport ( )-> setUpdatesEnabled ( false );
93 99
94 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show ); 100 ButtonUtils::inst ( )-> insertAppLnks ( m_map_show );
95 101
96 w_list-> viewport ( )-> setUpdatesEnabled ( b ); 102 w_list-> viewport ( )-> setUpdatesEnabled ( b );
97 103
98 m_map_show-> repaint ( ); 104 m_map_show-> repaint ( );
99} 105}
100 106
101void RemapDlg::itemChanged ( QListViewItem *it ) 107void RemapDlg::itemChanged ( QListViewItem *it )
102{ 108{
103 bool enabled = false; 109 bool enabled = false;
104 OQCopMessage m; 110 OQCopMessage m;
105 111
106 m_current = it; 112 m_current = it;
107 113
108 if ( it == m_map_none ) 114 if ( it == m_map_none )
109 { 115 {
110 m_msg = m = OQCopMessage ( "ignore", 0 ); 116 m_msg = m = OQCopMessage ( "ignore", 0 );
111 qDebug ("***ignoring"); 117 odebug << "***ignoring" << oendl;
112 } 118 }
113 else if ( it == m_map_preset ) 119 else if ( it == m_map_preset )
114 { 120 {
115 m_msg = m = m_msg_preset; 121 m_msg = m = m_msg_preset;
116 qDebug ("***Preset"); 122 odebug << "***Preset" << oendl;
117 } 123 }
118 else if ( it && !it-> childCount ( ) ) 124 else if ( it && !it-> childCount ( ) )
119 { 125 {
120 qDebug ("***Custom: %s %s ",it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 126 odebug << "***Custom: " << it-> text ( 1 ). latin1 ( ) << " " << it-> text ( 2 ). latin1 ( ) << oendl;
121 enabled = ( it == m_map_custom ); 127 enabled = ( it == m_map_custom );
122 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( )); 128 m_msg = m = OQCopMessage ( it-> text ( 1 ). latin1 ( ), it-> text ( 2 ). latin1 ( ));
123 } 129 }
124 130
125 w_channel-> setEnabled ( enabled ); 131 w_channel-> setEnabled ( enabled );
126 w_message-> setEnabled ( enabled ); 132 w_message-> setEnabled ( enabled );
127 133
128 w_channel-> setEditText ( m. channel ( )); 134 w_channel-> setEditText ( m. channel ( ));
129//hack for if user has typed in a message, such as 'suspend()' 135//hack for if user has typed in a message, such as 'suspend()'
130//so raise() is always present 136//so raise() is always present
131 if(m. message ( ) != "raise()") 137 if(m. message ( ) != "raise()")
132 w_message->insertItem("raise()"); 138 w_message->insertItem("raise()");
133 w_message-> setEditText ( m. message ( )); 139 w_message-> setEditText ( m. message ( ));
134} 140}
135 141
136void RemapDlg::textChanged ( const QString &str ) 142void RemapDlg::textChanged ( const QString &str )
@@ -146,10 +152,10 @@ void RemapDlg::textChanged ( const QString &str )
146 m_current-> setText ( 2, str ); 152 m_current-> setText ( 2, str );
147} 153}
148 154
149OQCopMessage RemapDlg::message ( ) 155OQCopMessage RemapDlg::message ( )
150{ 156{
151//make sure to update message if typed in 157//make sure to update message if typed in
152 itemChanged(w_list->currentItem()); 158 itemChanged(w_list->currentItem());
153 return m_msg; 159 return m_msg;
154} 160}
155 161
diff --git a/core/settings/citytime/citytime.cpp b/core/settings/citytime/citytime.cpp
index 721285d..d73bda1 100644
--- a/core/settings/citytime/citytime.cpp
+++ b/core/settings/citytime/citytime.cpp
@@ -20,36 +20,40 @@
20 20
21// changes by Maximilian Reiss <harlekin@handhelds.org> 21// changes by Maximilian Reiss <harlekin@handhelds.org>
22 22
23#include "zonemap.h" 23#include "zonemap.h"
24#include "citytime.h" 24#include "citytime.h"
25 25
26/* OPIE */
26#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
27#include <qpe/config.h> 28#include <qpe/config.h>
28#include <qpe/tzselect.h> 29#include <qpe/tzselect.h>
29#if !defined(QT_NO_COP) 30#if !defined(QT_NO_COP)
30#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
31#endif 32#endif
33#include <opie2/odebug.h>
32 34
35/* QT */
33#include <qlabel.h> 36#include <qlabel.h>
34#include <qmessagebox.h> 37#include <qmessagebox.h>
35#include <qtoolbutton.h> 38#include <qtoolbutton.h>
36#include <qlayout.h> 39#include <qlayout.h>
37 40
41/* STD */
38#include <stdlib.h> 42#include <stdlib.h>
39 43
40CityTime::CityTime( QWidget *parent, const char* name, 44CityTime::CityTime( QWidget *parent, const char* name,
41 WFlags fl ) 45 WFlags fl )
42 : CityTimeBase( parent, name, fl ), 46 : CityTimeBase( parent, name, fl ),
43 strRealTz(0), 47 strRealTz(0),
44 bAdded(false) 48 bAdded(false)
45{ 49{
46 Config config( "qpe" ); 50 Config config( "qpe" );
47 config.setGroup( "Time" ); 51 config.setGroup( "Time" );
48 bWhichClock = config.readBoolEntry( "AMPM", TRUE ); 52 bWhichClock = config.readBoolEntry( "AMPM", TRUE );
49 qDebug( QString("%1").arg(bWhichClock) ); 53 odebug << QString("%1").arg(bWhichClock) << oendl;
50 frmMap->changeClock( bWhichClock ); 54 frmMap->changeClock( bWhichClock );
51 55
52 char *pEnv; 56 char *pEnv;
53 pEnv = NULL; 57 pEnv = NULL;
54 pEnv = getenv("TZ"); 58 pEnv = getenv("TZ");
55 if ( pEnv ) 59 if ( pEnv )
@@ -115,39 +119,39 @@ CityTime::CityTime( QWidget *parent, const char* name,
115 timerEvent( 0 ); 119 timerEvent( 0 );
116} 120}
117 121
118CityTime::~CityTime() 122CityTime::~CityTime()
119{ 123{
120 if ( changed ) { 124 if ( changed ) {
121 Config cfg("CityTime"); 125 Config cfg("CityTime");
122 cfg.setGroup("TimeZones"); 126 cfg.setGroup("TimeZones");
123 QListIterator<QToolButton> itCity( listCities ); 127 QListIterator<QToolButton> itCity( listCities );
124 int i; 128 int i;
125 bool realTzWritten = FALSE; 129 bool realTzWritten = FALSE;
126 for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { 130 for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) {
127 if ( !strCityTz[i].isNull() ) { 131 if ( !strCityTz[i].isNull() ) {
128 cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); 132 cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]);
129 cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); 133 cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text());
130 if ( strCityTz[i] == strRealTz ) 134 if ( strCityTz[i] == strRealTz )
131 realTzWritten = TRUE; 135 realTzWritten = TRUE;
132 } 136 }
133 } 137 }
134 if ( realTzWritten ) { 138 if ( realTzWritten ) {
135 cfg.removeEntry("Zone"+QString::number(CITIES)); 139 cfg.removeEntry("Zone"+QString::number(CITIES));
136 cfg.removeEntry("ZoneName"+QString::number(CITIES)); 140 cfg.removeEntry("ZoneName"+QString::number(CITIES));
137 } else { 141 } else {
138 cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); 142 cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz);
139 if ( nameRealTz.isEmpty() ) { 143 if ( nameRealTz.isEmpty() ) {
140 int i = strRealTz.find( '/' ); 144 int i = strRealTz.find( '/' );
141 nameRealTz = strRealTz.mid( i+1 ); 145 nameRealTz = strRealTz.mid( i+1 );
142 } 146 }
143 cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); 147 cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz);
144 } 148 }
145 QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); 149 QCopEnvelope ( "QPE/System", "timeZoneListChange()" );
146 150
147 changed = FALSE; 151 changed = FALSE;
148 } 152 }
149 // restore the timezone, just in case we messed with it and 153 // restore the timezone, just in case we messed with it and
150 // are destroyed at an inoppurtune moment 154 // are destroyed at an inoppurtune moment
151 if ( !strRealTz.isNull() ) { 155 if ( !strRealTz.isNull() ) {
152 // this should be checked, but there is not much that can done at this 156 // this should be checked, but there is not much that can done at this
153 //point if it fails 157 //point if it fails
@@ -155,13 +159,13 @@ CityTime::~CityTime()
155 } 159 }
156} 160}
157 161
158void CityTime::timerEvent( QTimerEvent *e ) 162void CityTime::timerEvent( QTimerEvent *e )
159{ 163{
160 if ( e ) 164 if ( e )
161 killTimer( timerId ); 165 killTimer( timerId );
162 // change the time again!! 166 // change the time again!!
163 showTime(); 167 showTime();
164 int ms = 1000 - QTime::currentTime().msec(); 168 int ms = 1000 - QTime::currentTime().msec();
165 timerId = startTimer( ms ); 169 timerId = startTimer( ms );
166} 170}
167 171
@@ -177,13 +181,13 @@ void CityTime::showTime( void )
177 QListIterator<QLabel> itTime(listTimes); 181 QListIterator<QLabel> itTime(listTimes);
178 182
179 // traverse the list... 183 // traverse the list...
180 for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { 184 for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) {
181 if ( !strCityTz[i].isNull() ) { 185 if ( !strCityTz[i].isNull() ) {
182 if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { 186 if ( setenv( "TZ", strCityTz[i], true ) == 0 ) {
183 itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); 187 itTime.current()->setText( TimeString::shortTime( bWhichClock ) );
184 } else { 188 } else {
185 QMessageBox::critical( this, tr( "Time Changing" ), 189 QMessageBox::critical( this, tr( "Time Changing" ),
186 tr( "There was a problem setting timezone %1" ) 190 tr( "There was a problem setting timezone %1" )
187 .arg( QString::number( i + 1 ) ) ); 191 .arg( QString::number( i + 1 ) ) );
188 } 192 }
189 } 193 }
@@ -220,13 +224,13 @@ void CityTime::slotNewTz( const QString & strNewCountry,
220 strCityTz[i] = strNewCountry + strNewCity; 224 strCityTz[i] = strNewCountry + strNewCity;
221 QString s = strNewCity; 225 QString s = strNewCity;
222 cmdTmp->setText( s.replace( QRegExp("_"), " " ) ); 226 cmdTmp->setText( s.replace( QRegExp("_"), " " ) );
223 cmdTmp->toggle(); 227 cmdTmp->toggle();
224 // we can actually break, since there is only one button 228 // we can actually break, since there is only one button
225 // that is ever pressed! 229 // that is ever pressed!
226 changed = TRUE; 230 changed = TRUE;
227 break; 231 break;
228 } 232 }
229 } 233 }
230 showTime(); 234 showTime();
231 buttonWidget->show(); 235 buttonWidget->show();
232 selWidget->hide(); 236 selWidget->hide();
@@ -238,21 +242,21 @@ void CityTime::readInTimes( void )
238 cfg.setGroup("TimeZones"); 242 cfg.setGroup("TimeZones");
239 QListIterator<QToolButton> itCity( listCities ); 243 QListIterator<QToolButton> itCity( listCities );
240 int i=0; 244 int i=0;
241 nameRealTz = QString::null; 245 nameRealTz = QString::null;
242 QString zn; 246 QString zn;
243 for ( ; i < CITIES ; i++ ) { 247 for ( ; i < CITIES ; i++ ) {
244 zn = cfg.readEntry("Zone"+QString::number(i), QString::null); 248 zn = cfg.readEntry("Zone"+QString::number(i), QString::null);
245 if ( zn.isNull() ) 249 if ( zn.isNull() )
246 break; 250 break;
247 QString nm = cfg.readEntry("ZoneName"+QString::number(i)); 251 QString nm = cfg.readEntry("ZoneName"+QString::number(i));
248 strCityTz[i] = zn; 252 strCityTz[i] = zn;
249 itCity.current()->setText(nm); 253 itCity.current()->setText(nm);
250 if ( zn == strRealTz ) 254 if ( zn == strRealTz )
251 nameRealTz = nm; 255 nameRealTz = nm;
252 ++itCity; 256 ++itCity;
253 } 257 }
254 if ( i == 0 ) { 258 if ( i == 0 ) {
255 // write in our own in a shameless self promotion and some humor 259 // write in our own in a shameless self promotion and some humor
256 QStringList list = timezoneDefaults(); 260 QStringList list = timezoneDefaults();
257 int i; 261 int i;
258 QStringList::Iterator it = list.begin(); 262 QStringList::Iterator it = list.begin();
@@ -260,18 +264,18 @@ void CityTime::readInTimes( void )
260 i++, ++itCity ) { 264 i++, ++itCity ) {
261 strCityTz[i] = *it++; 265 strCityTz[i] = *it++;
262 itCity.current()->setText( *it++ ); 266 itCity.current()->setText( *it++ );
263 } 267 }
264 } 268 }
265 if ( nameRealTz.isEmpty() ) { 269 if ( nameRealTz.isEmpty() ) {
266 //remember the current time zone even if we don't have room 270 //remember the current time zone even if we don't have room
267 //to show it. 271 //to show it.
268 zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); 272 zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null);
269 if ( zn == strRealTz ) 273 if ( zn == strRealTz )
270 nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); 274 nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES));
271 i++; 275 i++;
272 } 276 }
273} 277}
274 278
275void CityTime::changeClock( bool newClock ) 279void CityTime::changeClock( bool newClock )
276{ 280{
277 bWhichClock = newClock; 281 bWhichClock = newClock;
diff --git a/core/settings/citytime/citytimebase.cpp b/core/settings/citytime/citytimebase.cpp
index 323929b..77cb91d 100644
--- a/core/settings/citytime/citytimebase.cpp
+++ b/core/settings/citytime/citytimebase.cpp
@@ -1,28 +1,32 @@
1 1
2 2
3// changes by Maximilian Reiss <harlekin@handhelds.org> 3// changes by Maximilian Reiss <harlekin@handhelds.org>
4 4
5#include "citytimebase.h" 5#include "citytimebase.h"
6#include "zonemap.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
6 10
11/* QT */
7#include <qlabel.h> 12#include <qlabel.h>
8#include <qtoolbutton.h> 13#include <qtoolbutton.h>
9#include "zonemap.h"
10#include <qlayout.h> 14#include <qlayout.h>
11#include <qwhatsthis.h> 15#include <qwhatsthis.h>
12 16
13 17
14/* 18/*
15 * Constructs a CityTimeBase which is a child of 'parent', with the 19 * Constructs a CityTimeBase which is a child of 'parent', with the
16 * name 'name' and widget flags set to 'f' 20 * name 'name' and widget flags set to 'f'
17 */ 21 */
18CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags ) 22CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags )
19 : QWidget( parent, name, WStyle_ContextHelp ) 23 : QWidget( parent, name, WStyle_ContextHelp )
20{ 24{
21 if ( !name ) 25 if ( !name )
22 setName( "CityTimeBase" ); 26 setName( "CityTimeBase" );
23 setCaption( tr( "City Time" ) ); 27 setCaption( tr( "City Time" ) );
24 CityTimeBaseLayout = new QVBoxLayout( this ); 28 CityTimeBaseLayout = new QVBoxLayout( this );
25 CityTimeBaseLayout->setSpacing( 3 ); 29 CityTimeBaseLayout->setSpacing( 3 );
26 CityTimeBaseLayout->setMargin( 0 ); 30 CityTimeBaseLayout->setMargin( 0 );
27 31
28 frmMap = new ZoneMap( this, "frmMap" ); 32 frmMap = new ZoneMap( this, "frmMap" );
@@ -338,74 +342,74 @@ CityTimeBase::~CityTimeBase()
338 * font changes 342 * font changes
339 */ 343 */
340bool CityTimeBase::event( QEvent* ev ) 344bool CityTimeBase::event( QEvent* ev )
341{ 345{
342 bool ret = QWidget::event( ev ); 346 bool ret = QWidget::event( ev );
343 if ( ev->type() == QEvent::ApplicationFontChange ) { 347 if ( ev->type() == QEvent::ApplicationFontChange ) {
344 QFont cmdCity7_font( cmdCity7->font() ); 348 QFont cmdCity7_font( cmdCity7->font() );
345 cmdCity7_font.setBold( TRUE ); 349 cmdCity7_font.setBold( TRUE );
346 cmdCity7->setFont( cmdCity7_font ); 350 cmdCity7->setFont( cmdCity7_font );
347 QFont lblCTime9_font( lblCTime9->font() ); 351 QFont lblCTime9_font( lblCTime9->font() );
348 lblCTime9_font.setPointSize( 10 ); 352 lblCTime9_font.setPointSize( 10 );
349 lblCTime9->setFont( lblCTime9_font ); 353 lblCTime9->setFont( lblCTime9_font );
350 QFont cmdCity8_font( cmdCity8->font() ); 354 QFont cmdCity8_font( cmdCity8->font() );
351 cmdCity8_font.setBold( TRUE ); 355 cmdCity8_font.setBold( TRUE );
352 cmdCity8->setFont( cmdCity8_font ); 356 cmdCity8->setFont( cmdCity8_font );
353 QFont cmdCity2_font( cmdCity2->font() ); 357 QFont cmdCity2_font( cmdCity2->font() );
354 cmdCity2_font.setBold( TRUE ); 358 cmdCity2_font.setBold( TRUE );
355 cmdCity2->setFont( cmdCity2_font ); 359 cmdCity2->setFont( cmdCity2_font );
356 QFont lblCTime6_font( lblCTime6->font() ); 360 QFont lblCTime6_font( lblCTime6->font() );
357 lblCTime6_font.setPointSize( 10 ); 361 lblCTime6_font.setPointSize( 10 );
358 lblCTime6->setFont( lblCTime6_font ); 362 lblCTime6->setFont( lblCTime6_font );
359 QFont cmdCity6_font( cmdCity6->font() ); 363 QFont cmdCity6_font( cmdCity6->font() );
360 cmdCity6_font.setBold( TRUE ); 364 cmdCity6_font.setBold( TRUE );
361 cmdCity6->setFont( cmdCity6_font ); 365 cmdCity6->setFont( cmdCity6_font );
362 QFont cmdCity4_font( cmdCity4->font() ); 366 QFont cmdCity4_font( cmdCity4->font() );
363 cmdCity4_font.setBold( TRUE ); 367 cmdCity4_font.setBold( TRUE );
364 cmdCity4->setFont( cmdCity4_font ); 368 cmdCity4->setFont( cmdCity4_font );
365 QFont lblCTime5_font( lblCTime5->font() ); 369 QFont lblCTime5_font( lblCTime5->font() );
366 lblCTime5_font.setPointSize( 10 ); 370 lblCTime5_font.setPointSize( 10 );
367 lblCTime5->setFont( lblCTime5_font ); 371 lblCTime5->setFont( lblCTime5_font );
368 QFont lblCTime2_font( lblCTime2->font() ); 372 QFont lblCTime2_font( lblCTime2->font() );
369 lblCTime2_font.setPointSize( 10 ); 373 lblCTime2_font.setPointSize( 10 );
370 lblCTime2->setFont( lblCTime2_font ); 374 lblCTime2->setFont( lblCTime2_font );
371 QFont lblCTime1_font( lblCTime1->font() ); 375 QFont lblCTime1_font( lblCTime1->font() );
372 lblCTime1_font.setPointSize( 10 ); 376 lblCTime1_font.setPointSize( 10 );
373 lblCTime1->setFont( lblCTime1_font ); 377 lblCTime1->setFont( lblCTime1_font );
374 QFont cmdCity3_font( cmdCity3->font() ); 378 QFont cmdCity3_font( cmdCity3->font() );
375 cmdCity3_font.setBold( TRUE ); 379 cmdCity3_font.setBold( TRUE );
376 cmdCity3->setFont( cmdCity3_font ); 380 cmdCity3->setFont( cmdCity3_font );
377 QFont lblCTime8_font( lblCTime8->font() ); 381 QFont lblCTime8_font( lblCTime8->font() );
378 lblCTime8_font.setPointSize( 10 ); 382 lblCTime8_font.setPointSize( 10 );
379 lblCTime8->setFont( lblCTime8_font ); 383 lblCTime8->setFont( lblCTime8_font );
380 QFont cmdCity1_font( cmdCity1->font() ); 384 QFont cmdCity1_font( cmdCity1->font() );
381 cmdCity1_font.setBold( TRUE ); 385 cmdCity1_font.setBold( TRUE );
382 cmdCity1->setFont( cmdCity1_font ); 386 cmdCity1->setFont( cmdCity1_font );
383 QFont lblCTime7_font( lblCTime7->font() ); 387 QFont lblCTime7_font( lblCTime7->font() );
384 lblCTime7_font.setPointSize( 10 ); 388 lblCTime7_font.setPointSize( 10 );
385 lblCTime7->setFont( lblCTime7_font ); 389 lblCTime7->setFont( lblCTime7_font );
386 QFont lblCTime4_font( lblCTime4->font() ); 390 QFont lblCTime4_font( lblCTime4->font() );
387 lblCTime4_font.setPointSize( 10 ); 391 lblCTime4_font.setPointSize( 10 );
388 lblCTime4->setFont( lblCTime4_font ); 392 lblCTime4->setFont( lblCTime4_font );
389 QFont cmdCity5_font( cmdCity5->font() ); 393 QFont cmdCity5_font( cmdCity5->font() );
390 cmdCity5_font.setBold( TRUE ); 394 cmdCity5_font.setBold( TRUE );
391 cmdCity5->setFont( cmdCity5_font ); 395 cmdCity5->setFont( cmdCity5_font );
392 QFont lblCTime3_font( lblCTime3->font() ); 396 QFont lblCTime3_font( lblCTime3->font() );
393 lblCTime3_font.setPointSize( 10 ); 397 lblCTime3_font.setPointSize( 10 );
394 lblCTime3->setFont( lblCTime3_font ); 398 lblCTime3->setFont( lblCTime3_font );
395 QFont cmdCity9_font( cmdCity9->font() ); 399 QFont cmdCity9_font( cmdCity9->font() );
396 cmdCity9_font.setBold( TRUE ); 400 cmdCity9_font.setBold( TRUE );
397 cmdCity9->setFont( cmdCity9_font ); 401 cmdCity9->setFont( cmdCity9_font );
398 } 402 }
399 return ret; 403 return ret;
400} 404}
401 405
402void CityTimeBase::beginNewTz() 406void CityTimeBase::beginNewTz()
403{ 407{
404 qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" ); 408 owarn << "CityTimeBase::beginNewTz(): Not implemented yet!" << oendl;
405} 409}
406 410
407void CityTimeBase::slotNewTz(const QString &, const QString &) 411void CityTimeBase::slotNewTz(const QString &, const QString &)
408{ 412{
409 qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" ); 413 owarn << "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" << oendl;
410} 414}
411 415
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp
index b6843d2..e4a25ef 100644
--- a/core/settings/citytime/zonemap.cpp
+++ b/core/settings/citytime/zonemap.cpp
@@ -20,26 +20,30 @@
20 20
21// changes by Maximilian Reiss <harlekin@handhelds.org> 21// changes by Maximilian Reiss <harlekin@handhelds.org>
22 22
23#include "sun.h" 23#include "sun.h"
24#include "zonemap.h" 24#include "zonemap.h"
25 25
26/* OPIE */
26#include <qpe/resource.h> 27#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <opie2/odebug.h>
28 30
31/* QT */
29#include <qfile.h> 32#include <qfile.h>
30#include <qlabel.h> 33#include <qlabel.h>
31#include <qmessagebox.h> 34#include <qmessagebox.h>
32#include <qtextstream.h> 35#include <qtextstream.h>
33#include <qtimer.h> 36#include <qtimer.h>
34#include <qtoolbutton.h> 37#include <qtoolbutton.h>
35#include <qlayout.h> 38#include <qlayout.h>
36#include <qhbox.h> 39#include <qhbox.h>
37#include <qlistview.h> 40#include <qlistview.h>
38#include <qwhatsthis.h> 41#include <qwhatsthis.h>
39 42
43/* STD */
40#include <limits.h> 44#include <limits.h>
41 45
42// the map file... 46// the map file...
43static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; 47static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab";
44static const char strMAP[] = "citytime/simple_grid_400"; 48static const char strMAP[] = "citytime/simple_grid_400";
45 49
@@ -58,85 +62,85 @@ const int iCITYOFFSET = 2;
58static inline void darken( QImage *pImage, int start, int stop, int row ); 62static inline void darken( QImage *pImage, int start, int stop, int row );
59static void dayNight( QImage *pImage ); 63static void dayNight( QImage *pImage );
60 64
61ZoneField::ZoneField( const QString& strLine ) 65ZoneField::ZoneField( const QString& strLine )
62{ 66{
63 // make a bunch of RegExp's to match the data from the line 67 // make a bunch of RegExp's to match the data from the line
64 QRegExp regCoord( "[-+][0-9]+" );// the latitude 68 QRegExp regCoord( "[-+][0-9]+" ); // the latitude
65 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) 69 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough)
66 QRegExp regCity( "[A-Za-z_-]*" ); // the city 70 QRegExp regCity( "[A-Za-z_-]*" ); // the city
67 71
68 int iStart, 72 int iStart,
69 iStop, 73 iStop,
70 iLen, 74 iLen,
71 tmp; 75 tmp;
72 QString strTmp; 76 QString strTmp;
73 // we should be able to assume that the country code is always the first 77 // we should be able to assume that the country code is always the first
74 // two chars, so just grap them and let it go... 78 // two chars, so just grap them and let it go...
75 strCountryCode = strLine.left( 2 ); 79 strCountryCode = strLine.left( 2 );
76 iStart = regCoord.match( strLine, 0, &iLen ); 80 iStart = regCoord.match( strLine, 0, &iLen );
77 if ( iStart >= 0 ) { 81 if ( iStart >= 0 ) {
78 strTmp = strLine.mid( iStart, iLen ); 82 strTmp = strLine.mid( iStart, iLen );
79 tmp = strTmp.toInt(); 83 tmp = strTmp.toInt();
80 // okay, there are two versions of the format, make a decision based on 84 // okay, there are two versions of the format, make a decision based on
81 // the size... 85 // the size...
82 // Oh BTW, we are storing everything in seconds! 86 // Oh BTW, we are storing everything in seconds!
83 if ( iLen < 7 ) { 87 if ( iLen < 7 ) {
84 _y = tmp / 100; 88 _y = tmp / 100;
85 _y *= 60; 89 _y *= 60;
86 _y += tmp % 100; 90 _y += tmp % 100;
87 _y *= 60; 91 _y *= 60;
88 } else { 92 } else {
89 _y = tmp / 10000; 93 _y = tmp / 10000;
90 _y *= 60; 94 _y *= 60;
91 tmp %= 10000; 95 tmp %= 10000;
92 _y += tmp / 100; 96 _y += tmp / 100;
93 _y *= 60; 97 _y *= 60;
94 tmp %= 100; 98 tmp %= 100;
95 _y += tmp; 99 _y += tmp;
96 } 100 }
97 } 101 }
98 iStart = regCoord.match( strLine, iStart + iLen, &iLen ); 102 iStart = regCoord.match( strLine, iStart + iLen, &iLen );
99 if ( iStart >= 0 ) { 103 if ( iStart >= 0 ) {
100 strTmp = strLine.mid( iStart, iLen ); 104 strTmp = strLine.mid( iStart, iLen );
101 tmp = strTmp.toInt(); 105 tmp = strTmp.toInt();
102 if ( iLen < 8 ) { 106 if ( iLen < 8 ) {
103 _x = tmp / 100; 107 _x = tmp / 100;
104 _x *= 60; 108 _x *= 60;
105 _x += tmp % 100; 109 _x += tmp % 100;
106 _x *= 60; 110 _x *= 60;
107 } else { 111 } else {
108 _x = tmp / 10000; 112 _x = tmp / 10000;
109 _x *= 60; 113 _x *= 60;
110 tmp %= 10000; 114 tmp %= 10000;
111 _x += tmp / 100; 115 _x += tmp / 100;
112 _x *= 60; 116 _x *= 60;
113 tmp %= 100; 117 tmp %= 100;
114 _x += tmp; 118 _x += tmp;
115 } 119 }
116 } 120 }
117 iStart = regCountry.match( strLine, 0, &iLen ); 121 iStart = regCountry.match( strLine, 0, &iLen );
118 // help with the shortcoming in 2.x regexp... 122 // help with the shortcoming in 2.x regexp...
119 iStop = strLine.findRev( '/' ); 123 iStop = strLine.findRev( '/' );
120 if ( iStart >= 0 ) { 124 if ( iStart >= 0 ) {
121 iLen = (iStop - iStart) + 1; 125 iLen = (iStop - iStart) + 1;
122 strCountry = strLine.mid( iStart, iLen ); 126 strCountry = strLine.mid( iStart, iLen );
123 } 127 }
124 // now match the city... 128 // now match the city...
125 iStart = regCity.match( strLine, iStart + iLen, &iLen ); 129 iStart = regCity.match( strLine, iStart + iLen, &iLen );
126 if ( iStart >= 0 ) { 130 if ( iStart >= 0 ) {
127 strCity = strLine.mid( iStart, iLen ); 131 strCity = strLine.mid( iStart, iLen );
128 } 132 }
129} 133}
130 134
131void ZoneField::showStructure( void ) const 135void ZoneField::showStructure( void ) const
132{ 136{
133 qDebug( "Country: %s", strCountry.latin1() ); 137 odebug << "Country: " << strCountry << "" << oendl;
134 qDebug( "City: %s", strCity.latin1() ); 138 odebug << "City: " << strCity << "" << oendl;
135 qDebug( "x: %d", _x ); 139 odebug << "x: " << _x << "" << oendl;
136 qDebug( "y: %d\n", _y ); 140 odebug << "y: " << _y << "\n" << oendl;
137} 141}
138 142
139ZoneMap::ZoneMap( QWidget *parent, const char* name ) 143ZoneMap::ZoneMap( QWidget *parent, const char* name )
140 : QScrollView( parent, name ), 144 : QScrollView( parent, name ),
141 pLast( 0 ), 145 pLast( 0 ),
142 pRepaint( 0 ), 146 pRepaint( 0 ),
@@ -204,27 +208,27 @@ ZoneMap::~ZoneMap()
204} 208}
205 209
206void ZoneMap::readZones( void ) 210void ZoneMap::readZones( void )
207{ 211{
208 QFile fZone( strZONEINFO ); 212 QFile fZone( strZONEINFO );
209 if ( !fZone.open( IO_ReadOnly ) ) { 213 if ( !fZone.open( IO_ReadOnly ) ) {
210 QMessageBox::warning (this, 214 QMessageBox::warning (this,
211 tr( "Unable to Find Timezone Info" ), 215 tr( "Unable to Find Timezone Info" ),
212 tr( "<p>Unable to find any timezone information in %1" ) 216 tr( "<p>Unable to find any timezone information in %1" )
213 .arg( strZONEINFO )); 217 .arg( strZONEINFO ));
214 exit(-1); 218 exit(-1);
215 } else { 219 } else {
216 QTextStream tZone( &fZone ); 220 QTextStream tZone( &fZone );
217 while ( !tZone.atEnd() ) { 221 while ( !tZone.atEnd() ) {
218 QString strLine = tZone.readLine(); 222 QString strLine = tZone.readLine();
219 // only pass on lines that aren't comments 223 // only pass on lines that aren't comments
220 if ( strLine[0] != '#' ) { 224 if ( strLine[0] != '#' ) {
221 zones.append( new ZoneField( strLine ) ); 225 zones.append( new ZoneField( strLine ) );
222 } 226 }
223 } 227 }
224 fZone.close(); 228 fZone.close();
225 } 229 }
226} 230}
227 231
228void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) 232void ZoneMap::viewportMousePressEvent( QMouseEvent* event )
229{ 233{
230 // add the mouse event into the normalizer, and get the average, 234 // add the mouse event into the normalizer, and get the average,
@@ -242,88 +246,88 @@ void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event )
242void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) 246void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* )
243{ 247{
244 // get the averaged points in case a timeout hasn't occurred, 248 // get the averaged points in case a timeout hasn't occurred,
245 // more for "mouse clicks" 249 // more for "mouse clicks"
246 norm.stop(); 250 norm.stop();
247 if ( pLast != NULL ) { 251 if ( pLast != NULL ) {
248 emit signalTz( pLast->country(), pLast->city() ); 252 emit signalTz( pLast->country(), pLast->city() );
249 pLast = NULL; 253 pLast = NULL;
250 } 254 }
251 tHide->start( 2000, true ); 255 tHide->start( 2000, true );
252} 256}
253 257
254void ZoneMap::keyPressEvent( QKeyEvent *ke ) 258void ZoneMap::keyPressEvent( QKeyEvent *ke )
255{ 259{
256 switch ( ke->key() ) { 260 switch ( ke->key() ) {
257 case Key_Left: 261 case Key_Left:
258 case Key_Right: 262 case Key_Right:
259 case Key_Up: 263 case Key_Up:
260 case Key_Down: { 264 case Key_Down: {
261 tHide->stop(); 265 tHide->stop();
262 if ( !cursor ) 266 if ( !cursor )
263 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); 267 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 );
264 ZoneField *city = findCityNear( cursor, ke->key() ); 268 ZoneField *city = findCityNear( cursor, ke->key() );
265 if ( city ) { 269 if ( city ) {
266 cursor = city; 270 cursor = city;
267 int tmpx, tmpy; 271 int tmpx, tmpy;
268 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); 272 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy );
269 ensureVisible( tmpx, tmpy ); 273 ensureVisible( tmpx, tmpy );
270 showCity( cursor ); 274 showCity( cursor );
271 tHide->start( 3000, true ); 275 tHide->start( 3000, true );
272 } 276 }
273 } 277 }
274 break; 278 break;
275 279
276 case Key_Space: 280 case Key_Space:
277 case Key_Enter: 281 case Key_Enter:
278 case Key_Return: 282 case Key_Return:
279 if ( cursor ) { 283 if ( cursor ) {
280 emit signalTz( cursor->country(), cursor->city() ); 284 emit signalTz( cursor->country(), cursor->city() );
281 tHide->start( 0, true ); 285 tHide->start( 0, true );
282 } 286 }
283 break; 287 break;
284 } 288 }
285} 289}
286 290
287ZoneField *ZoneMap::findCityNear( ZoneField *city, int key ) 291ZoneField *ZoneMap::findCityNear( ZoneField *city, int key )
288{ 292{
289 ZoneField *pZone; 293 ZoneField *pZone;
290 ZoneField *pClosest = 0; 294 ZoneField *pClosest = 0;
291 long ddist = LONG_MAX; 295 long ddist = LONG_MAX;
292 296
293 QListIterator<ZoneField> it( zones ); 297 QListIterator<ZoneField> it( zones );
294 for (; it.current(); ++it) { 298 for (; it.current(); ++it) {
295 pZone = it.current(); 299 pZone = it.current();
296 long dx = (pZone->x() - city->x())/100; 300 long dx = (pZone->x() - city->x())/100;
297 long dy = (pZone->y() - city->y())/100; 301 long dy = (pZone->y() - city->y())/100;
298 switch ( key ) { 302 switch ( key ) {
299 case Key_Right: 303 case Key_Right:
300 case Key_Left: 304 case Key_Left:
301 if ( key == Key_Left ) 305 if ( key == Key_Left )
302 dx = -dx; 306 dx = -dx;
303 if ( dx > 0 ) { 307 if ( dx > 0 ) {
304 long dist = QABS(dy)*4 + dx; 308 long dist = QABS(dy)*4 + dx;
305 if ( dist < ddist ) { 309 if ( dist < ddist ) {
306 ddist = dist; 310 ddist = dist;
307 pClosest = pZone; 311 pClosest = pZone;
308 } 312 }
309 } 313 }
310 break; 314 break;
311 case Key_Down: 315 case Key_Down:
312 case Key_Up: 316 case Key_Up:
313 if ( key == Key_Down ) 317 if ( key == Key_Down )
314 dy = -dy; 318 dy = -dy;
315 if ( dy > 0 ) { 319 if ( dy > 0 ) {
316 long dist = QABS(dx)*4 + dy; 320 long dist = QABS(dx)*4 + dy;
317 if ( dist < ddist ) { 321 if ( dist < ddist ) {
318 ddist = dist; 322 ddist = dist;
319 pClosest = pZone; 323 pClosest = pZone;
320 } 324 }
321 } 325 }
322 break; 326 break;
323 } 327 }
324 } 328 }
325 329
326 return pClosest; 330 return pClosest;
327} 331}
328 332
329void ZoneMap::slotFindCity( const QPoint &pos ) 333void ZoneMap::slotFindCity( const QPoint &pos )
@@ -348,26 +352,26 @@ void ZoneMap::slotFindCity( const QPoint &pos )
348 // another way to do it at the moment. Another problem is a linked list is 352 // another way to do it at the moment. Another problem is a linked list is
349 // used obviously something indexed would help 353 // used obviously something indexed would help
350 QListIterator<ZoneField> it( zones ); 354 QListIterator<ZoneField> it( zones );
351 pClosest = 0; 355 pClosest = 0;
352 lClosest = LONG_MAX; 356 lClosest = LONG_MAX;
353 for (; it.current(); ++it) { 357 for (; it.current(); ++it) {
354 pZone = it.current(); 358 pZone = it.current();
355 // use the manhattenLength, a good enough of an appoximation here 359 // use the manhattenLength, a good enough of an appoximation here
356 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); 360 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() );
357 // first to zero wins! 361 // first to zero wins!
358 if ( lDistance < lClosest ) { 362 if ( lDistance < lClosest ) {
359 lClosest = lDistance; 363 lClosest = lDistance;
360 pClosest = pZone; 364 pClosest = pZone;
361 } 365 }
362 } 366 }
363 367
364 // Okay, we found the closest city, but it might still be too far away. 368 // Okay, we found the closest city, but it might still be too far away.
365 if ( lClosest <= iTHRESHOLD ) { 369 if ( lClosest <= iTHRESHOLD ) {
366 showCity( pClosest ); 370 showCity( pClosest );
367 cursor = pClosest; 371 cursor = pClosest;
368 } 372 }
369} 373}
370 374
371void ZoneMap::showCity( ZoneField *city ) 375void ZoneMap::showCity( ZoneField *city )
372{ 376{
373 pLast = city; 377 pLast = city;
@@ -378,57 +382,57 @@ void ZoneMap::showCity( ZoneField *city )
378 // Display the time at this location by setting the environment timezone 382 // Display the time at this location by setting the environment timezone
379 // getting the current time [there] and then swapping back the variable 383 // getting the current time [there] and then swapping back the variable
380 // so no one notices... 384 // so no one notices...
381 QString strSave; 385 QString strSave;
382 char *p = getenv( "TZ" ); 386 char *p = getenv( "TZ" );
383 if ( p ) { 387 if ( p ) {
384 strSave = p; 388 strSave = p;
385 } 389 }
386 // set the timezone :) 390 // set the timezone :)
387 setenv( "TZ", strCountry + strCity, true ); 391 setenv( "TZ", strCountry + strCity, true );
388 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + 392 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" +
389 TimeString::shortTime( ampm ) ); 393 TimeString::shortTime( ampm ) );
390 lblCity->setMinimumSize( lblCity->sizeHint() ); 394 lblCity->setMinimumSize( lblCity->sizeHint() );
391 // undue our damage... 395 // undue our damage...
392 unsetenv( "TZ" ); 396 unsetenv( "TZ" );
393 if ( p ) 397 if ( p )
394 setenv( "TZ", strSave, true ); 398 setenv( "TZ", strSave, true );
395 // Now decide where to move the label, x & y can be reused 399 // Now decide where to move the label, x & y can be reused
396 int tmpx, tmpy, x, y; 400 int tmpx, tmpy, x, y;
397 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy ); 401 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy );
398 contentsToViewport(tmpx, tmpy, x, y); 402 contentsToViewport(tmpx, tmpy, x, y);
399 if ( lblCity->width() > drawableW - x ) { 403 if ( lblCity->width() > drawableW - x ) {
400 // oops... try putting it on the right 404 // oops... try putting it on the right
401 x = x - lblCity->width() - iLABELOFFSET; 405 x = x - lblCity->width() - iLABELOFFSET;
402 } else { 406 } else {
403 // the default... 407 // the default...
404 x += iLABELOFFSET; 408 x += iLABELOFFSET;
405 } 409 }
406 if ( lblCity->height() > drawableH - y ) { 410 if ( lblCity->height() > drawableH - y ) {
407 // move it up... 411 // move it up...
408 y = y - lblCity->height() - iLABELOFFSET; 412 y = y - lblCity->height() - iLABELOFFSET;
409 } else if ( y < 0 ) { 413 } else if ( y < 0 ) {
410 // the city is actually off the screen... 414 // the city is actually off the screen...
411 // this only happens on the a zoom when you are near the top, 415 // this only happens on the a zoom when you are near the top,
412 // a quick workaround.. 416 // a quick workaround..
413 y = iLABELOFFSET; 417 y = iLABELOFFSET;
414 } else { 418 } else {
415 // the default 419 // the default
416 y += iLABELOFFSET; 420 y += iLABELOFFSET;
417 } 421 }
418 422
419 // draw in the city and the label 423 // draw in the city and the label
420 if ( pRepaint ) { 424 if ( pRepaint ) {
421 int repx, 425 int repx,
422 repy; 426 repy;
423 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); 427 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy );
424 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, 428 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET,
425 iCITYSIZE, iCITYSIZE ); 429 iCITYSIZE, iCITYSIZE );
426 } 430 }
427 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, 431 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE,
428 iCITYSIZE ); 432 iCITYSIZE );
429 pRepaint = pLast; 433 pRepaint = pLast;
430 434
431 lblCity->move( x, y ); 435 lblCity->move( x, y );
432 lblCity->show(); 436 lblCity->show();
433} 437}
434 438
@@ -436,26 +440,26 @@ void ZoneMap::resizeEvent( QResizeEvent *e )
436{ 440{
437 // keep the zoom button down in the corner 441 // keep the zoom button down in the corner
438 QSize _size = e->size(); 442 QSize _size = e->size();
439 cmdZoom->move( _size.width() - cmdZoom->width(), 443 cmdZoom->move( _size.width() - cmdZoom->width(),
440 _size.height() - cmdZoom->height() ); 444 _size.height() - cmdZoom->height() );
441 if ( !bZoom ) { 445 if ( !bZoom ) {
442 drawableW = width() - 2 * frameWidth(); 446 drawableW = width() - 2 * frameWidth();
443 drawableH = height() - 2 * frameWidth(); 447 drawableH = height() - 2 * frameWidth();
444 makeMap( drawableW, drawableH ); 448 makeMap( drawableW, drawableH );
445 resizeContents( drawableW, drawableH ); 449 resizeContents( drawableW, drawableH );
446 } 450 }
447} 451}
448 452
449void ZoneMap::showZones( void ) const 453void ZoneMap::showZones( void ) const
450{ 454{
451 // go through the zones in the list and just display the values... 455 // go through the zones in the list and just display the values...
452 QListIterator<ZoneField> itZone( zones ); 456 QListIterator<ZoneField> itZone( zones );
453 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 457 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
454 ZoneField *pZone = itZone.current(); 458 ZoneField *pZone = itZone.current();
455 pZone->showStructure(); 459 pZone->showStructure();
456 } 460 }
457} 461}
458 462
459 463
460QWidget* ZoneMap::selectionWidget( QWidget *parent) { 464QWidget* ZoneMap::selectionWidget( QWidget *parent) {
461 465
@@ -468,13 +472,13 @@ QWidget* ZoneMap::selectionWidget( QWidget *parent) {
468 QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); 472 QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") );
469 connect ( continentView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotGetCities(QListViewItem*) ) ); 473 connect ( continentView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotGetCities(QListViewItem*) ) );
470 474
471 QStringList continentList; 475 QStringList continentList;
472 QListIterator<ZoneField> itZone( zones ); 476 QListIterator<ZoneField> itZone( zones );
473 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 477 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
474 ZoneField *pZone = itZone.current(); 478 ZoneField *pZone = itZone.current();
475 if ( continentList.contains( pZone->country() ) == 0 ) { 479 if ( continentList.contains( pZone->country() ) == 0 ) {
476 QString name; 480 QString name;
477 QListViewItem *item; 481 QListViewItem *item;
478 if ( !(pZone->country().length() > 24) ) { 482 if ( !(pZone->country().length() > 24) ) {
479 name = pZone->country().left(pZone->country().length()-1 ); 483 name = pZone->country().left(pZone->country().length()-1 );
480 } else { 484 } else {
@@ -495,13 +499,13 @@ QWidget* ZoneMap::selectionWidget( QWidget *parent) {
495void ZoneMap::slotGetCities( QListViewItem * contItem) { 499void ZoneMap::slotGetCities( QListViewItem * contItem) {
496 500
497 cityView->clear(); 501 cityView->clear();
498 selectedCont = contItem->text( 1 ); 502 selectedCont = contItem->text( 1 );
499 QListIterator<ZoneField> itZone( zones ); 503 QListIterator<ZoneField> itZone( zones );
500 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 504 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
501 ZoneField *pZone = itZone.current(); 505 ZoneField *pZone = itZone.current();
502 if ( pZone->country() == contItem->text( 1 ) ) { 506 if ( pZone->country() == contItem->text( 1 ) ) {
503 QListViewItem *item; 507 QListViewItem *item;
504 item = new QListViewItem( cityView, pZone->city() ); 508 item = new QListViewItem( cityView, pZone->city() );
505 connect ( cityView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotCitySelected(QListViewItem*) ) ); 509 connect ( cityView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotCitySelected(QListViewItem*) ) );
506 } 510 }
507 } 511 }
@@ -519,17 +523,17 @@ void ZoneMap::drawCities( QPainter *p )
519 // draw in the cities 523 // draw in the cities
520 // for testing only as when you put it 524 // for testing only as when you put it
521 // on the small screen it looks awful and not to mention useless 525 // on the small screen it looks awful and not to mention useless
522 p->setPen( red ); 526 p->setPen( red );
523 QListIterator<ZoneField> itZone( zones ); 527 QListIterator<ZoneField> itZone( zones );
524 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { 528 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) {
525 ZoneField *pZone = itZone.current(); 529 ZoneField *pZone = itZone.current();
526 zoneToWin( pZone->x(), pZone->y(), x, y ); 530 zoneToWin( pZone->x(), pZone->y(), x, y );
527 if ( x > wImg ) 531 if ( x > wImg )
528 x = x - wImg; 532 x = x - wImg;
529 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 533 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
530 } 534 }
531} 535}
532 536
533static void dayNight(QImage *pImage) 537static void dayNight(QImage *pImage)
534{ 538{
535 // create a mask the functions from sun.h 539 // create a mask the functions from sun.h
@@ -560,26 +564,26 @@ static void dayNight(QImage *pImage)
560 relw = wImage - int( wImage * 0.0275 ); 564 relw = wImage - int( wImage * 0.0275 );
561 565
562 // draw the map, keeping in mind that we may go too far off the map... 566 // draw the map, keeping in mind that we may go too far off the map...
563 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 ); 567 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 );
564 568
565 for ( i = 0; i < hImage; i++ ) { 569 for ( i = 0; i < hImage; i++ ) {
566 if ( wtab[i] > 0 ) { 570 if ( wtab[i] > 0 ) {
567 iStart = iMid - wtab[i]; 571 iStart = iMid - wtab[i];
568 iStop = iMid + wtab[i]; 572 iStop = iMid + wtab[i];
569 if ( iStart < 0 ) { 573 if ( iStart < 0 ) {
570 darken( pImage, iStop, wImage + iStart, i ); 574 darken( pImage, iStop, wImage + iStart, i );
571 } else if ( iStop > wImage ) { 575 } else if ( iStop > wImage ) {
572 darken( pImage, iStop - wImage, iStart, i ); 576 darken( pImage, iStop - wImage, iStart, i );
573 } else { 577 } else {
574 darken( pImage, 0, iStart, i ); 578 darken( pImage, 0, iStart, i );
575 darken( pImage, iStop, wImage, i ); 579 darken( pImage, iStop, wImage, i );
576 } 580 }
577 } else { 581 } else {
578 darken( pImage, 0, wImage, i ); 582 darken( pImage, 0, wImage, i );
579 } 583 }
580 } 584 }
581} 585}
582 586
583static inline void darken( QImage *pImage, int start, int stop, int row ) 587static inline void darken( QImage *pImage, int start, int stop, int row )
584{ 588{
585 int colors, 589 int colors,
@@ -588,44 +592,44 @@ static inline void darken( QImage *pImage, int start, int stop, int row )
588 592
589 // assume that the image is similar to the one we have... 593 // assume that the image is similar to the one we have...
590 colors = pImage->numColors() / 2; 594 colors = pImage->numColors() / 2;
591 595
592 p = pImage->scanLine( row ); 596 p = pImage->scanLine( row );
593 for ( j = start; j <= stop; j++ ) { 597 for ( j = start; j <= stop; j++ ) {
594 if ( p[j] < colors ) 598 if ( p[j] < colors )
595 p[j] += colors; 599 p[j] += colors;
596 } 600 }
597} 601}
598 602
599void ZoneMap::makeMap( int w, int h ) 603void ZoneMap::makeMap( int w, int h )
600{ 604{
601 QImage imgOrig = Resource::loadImage( strMAP ); 605 QImage imgOrig = Resource::loadImage( strMAP );
602 if ( imgOrig.isNull() ) { 606 if ( imgOrig.isNull() ) {
603 QMessageBox::warning( this, 607 QMessageBox::warning( this,
604 tr( "Couldn't Find Map" ), 608 tr( "Couldn't Find Map" ),
605 tr( "<p>Couldn't load map: %1, exiting") 609 tr( "<p>Couldn't load map: %1, exiting")
606 .arg( strMAP ) ); 610 .arg( strMAP ) );
607 exit(-1); 611 exit(-1);
608 } 612 }
609 613
610 // set up the color table for darkening... 614 // set up the color table for darkening...
611 imgOrig = imgOrig.convertDepth( 8 ); 615 imgOrig = imgOrig.convertDepth( 8 );
612 int numColors = imgOrig.numColors(); 616 int numColors = imgOrig.numColors();
613 // double the colors 617 // double the colors
614 imgOrig.setNumColors( 2 * numColors ); 618 imgOrig.setNumColors( 2 * numColors );
615 // darken the new ones... 619 // darken the new ones...
616 for ( int i = 0; i < numColors; i++ ) { 620 for ( int i = 0; i < numColors; i++ ) {
617 QRgb rgb = imgOrig.color( i ); 621 QRgb rgb = imgOrig.color( i );
618 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, 622 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3,
619 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); 623 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) );
620 } 624 }
621 625
622 // else go one with making the map... 626 // else go one with making the map...
623 if ( bIllum ) { 627 if ( bIllum ) {
624 // do a daylight mask 628 // do a daylight mask
625 dayNight(&imgOrig); 629 dayNight(&imgOrig);
626 } 630 }
627 // redo the width and height 631 // redo the width and height
628 wImg = w; 632 wImg = w;
629 hImg = h; 633 hImg = h;
630 ox = ( wImg / 2 ) - int( wImg * 0.0275 ); 634 ox = ( wImg / 2 ) - int( wImg * 0.0275 );
631 oy = hImg / 2; 635 oy = hImg / 2;
@@ -651,44 +655,44 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
651 drawableH = height() - 2 * frameWidth(); 655 drawableH = height() - 2 * frameWidth();
652 656
653 int pixmapW = pixCurr->width(), 657 int pixmapW = pixCurr->width(),
654 pixmapH = pixCurr->height(); 658 pixmapH = pixCurr->height();
655 if ( !bZoom && ( ( pixmapW != drawableW ) || 659 if ( !bZoom && ( ( pixmapW != drawableW ) ||
656 ( pixmapH != drawableH) ) ) { 660 ( pixmapH != drawableH) ) ) {
657 makeMap( drawableW, drawableH ); 661 makeMap( drawableW, drawableH );
658 } 662 }
659 663
660 // taken from the scrollview example... 664 // taken from the scrollview example...
661 int rowheight = pixCurr->height(); 665 int rowheight = pixCurr->height();
662 int toprow = cy / rowheight; 666 int toprow = cy / rowheight;
663 int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight; 667 int bottomrow = ( cy + ch + rowheight - 1 ) / rowheight;
664 int colwidth = pixCurr->width(); 668 int colwidth = pixCurr->width();
665 int leftcol= cx / colwidth; 669 int leftcol= cx / colwidth;
666 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth; 670 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth;
667 for ( int r = toprow; r <= bottomrow; r++ ) { 671 for ( int r = toprow; r <= bottomrow; r++ ) {
668 int py = r * rowheight; 672 int py = r * rowheight;
669 for ( int c = leftcol; c <= rightcol; c++ ) { 673 for ( int c = leftcol; c <= rightcol; c++ ) {
670 int px = c * colwidth; 674 int px = c * colwidth;
671 p->drawPixmap( px, py, *pixCurr ); 675 p->drawPixmap( px, py, *pixCurr );
672 } 676 }
673 } 677 }
674 678
675 // Draw that city! 679 // Draw that city!
676 if ( pLast ) 680 if ( pLast )
677 drawCity( p, pLast ); 681 drawCity( p, pLast );
678} 682}
679 683
680void ZoneMap::slotZoom( bool setZoom ) 684void ZoneMap::slotZoom( bool setZoom )
681{ 685{
682 bZoom = setZoom; 686 bZoom = setZoom;
683 if ( bZoom ) { 687 if ( bZoom ) {
684 makeMap( 2 * wImg , 2 * hImg ); 688 makeMap( 2 * wImg , 2 * hImg );
685 resizeContents( wImg, hImg ); 689 resizeContents( wImg, hImg );
686 } else { 690 } else {
687 makeMap( drawableW, drawableH ); 691 makeMap( drawableW, drawableH );
688 resizeContents( drawableW, drawableH ); 692 resizeContents( drawableW, drawableH );
689 } 693 }
690} 694}
691 695
692void ZoneMap::slotIllum( bool setIllum ) 696void ZoneMap::slotIllum( bool setIllum )
693{ 697{
694 bIllum = !setIllum; 698 bIllum = !setIllum;
@@ -708,15 +712,15 @@ void ZoneMap::slotUpdate( void )
708void ZoneMap::slotRedraw( void ) 712void ZoneMap::slotRedraw( void )
709{ 713{
710 // paint over that pesky city... 714 // paint over that pesky city...
711 int x, 715 int x,
712 y; 716 y;
713 if ( pRepaint ) { 717 if ( pRepaint ) {
714 pLast = 0; 718 pLast = 0;
715 zoneToWin(pRepaint->x(), pRepaint->y(), x, y); 719 zoneToWin(pRepaint->x(), pRepaint->y(), x, y);
716 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 720 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
717 pRepaint = 0; 721 pRepaint = 0;
718 } 722 }
719} 723}
720 724
721void ZoneMap::changeClock( bool whichClock ) 725void ZoneMap::changeClock( bool whichClock )
722{ 726{
diff --git a/core/settings/launcher/doctabsettings.cpp b/core/settings/launcher/doctabsettings.cpp
index 179a7f9..dfdc9be 100644
--- a/core/settings/launcher/doctabsettings.cpp
+++ b/core/settings/launcher/doctabsettings.cpp
@@ -25,19 +25,23 @@
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "doctabsettings.h" 29#include "doctabsettings.h"
30 30
31/* OPIE */
31#include <qpe/config.h> 32#include <qpe/config.h>
33#include <opie2/odebug.h>
32 34
35/* QT */
33#include <qcheckbox.h> 36#include <qcheckbox.h>
34#include <qlayout.h> 37#include <qlayout.h>
35#include <qlabel.h> 38#include <qlabel.h>
36#include <qwhatsthis.h> 39#include <qwhatsthis.h>
37 40
41
38DocTabSettings::DocTabSettings( QWidget *parent, const char *name ):QWidget( parent, name ) 42DocTabSettings::DocTabSettings( QWidget *parent, const char *name ):QWidget( parent, name )
39{ 43{
40 QBoxLayout *lay = new QVBoxLayout( this, 4, 4 ); 44 QBoxLayout *lay = new QVBoxLayout( this, 4, 4 );
41 45
42 _enable = new QCheckBox( tr( "Enable the Documents Tab" ), this ); 46 _enable = new QCheckBox( tr( "Enable the Documents Tab" ), this );
43 47
@@ -56,13 +60,13 @@ DocTabSettings::DocTabSettings( QWidget *parent, const char *name ):QWidget( par
56void DocTabSettings::appletChanged() 60void DocTabSettings::appletChanged()
57{ 61{
58} 62}
59 63
60void DocTabSettings::accept() 64void DocTabSettings::accept()
61{ 65{
62 qDebug( "DocTabSettings::accept()" ); 66 odebug << "DocTabSettings::accept()" << oendl;
63 Config cfg( "Launcher" ); 67 Config cfg( "Launcher" );
64 cfg.setGroup( "DocTab" ); 68 cfg.setGroup( "DocTab" );
65 cfg.writeEntry( "Enable", _enable->isChecked() ); 69 cfg.writeEntry( "Enable", _enable->isChecked() );
66 cfg.write(); 70 cfg.write();
67} 71}
68 72
diff --git a/core/settings/launcher/inputmethodsettings.cpp b/core/settings/launcher/inputmethodsettings.cpp
index e342c09..0422075 100644
--- a/core/settings/launcher/inputmethodsettings.cpp
+++ b/core/settings/launcher/inputmethodsettings.cpp
@@ -25,20 +25,24 @@
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "inputmethodsettings.h" 29#include "inputmethodsettings.h"
30 30
31/* OPIE */
31#include <qpe/config.h> 32#include <qpe/config.h>
33#include <opie2/odebug.h>
32 34
35/* QT */
33#include <qspinbox.h> 36#include <qspinbox.h>
34#include <qcheckbox.h> 37#include <qcheckbox.h>
35#include <qlayout.h> 38#include <qlayout.h>
36#include <qlabel.h> 39#include <qlabel.h>
37#include <qwhatsthis.h> 40#include <qwhatsthis.h>
38 41
42
39InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QWidget( parent, name ) 43InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QWidget( parent, name )
40{ 44{
41 QBoxLayout *lay = new QVBoxLayout( this, 4, 4 ); 45 QBoxLayout *lay = new QVBoxLayout( this, 4, 4 );
42 46
43 _resize = new QCheckBox( tr( "Resize application on Popup" ), this ); 47 _resize = new QCheckBox( tr( "Resize application on Popup" ), this );
44 _float = new QCheckBox( tr( "Enable floating and resizing" ), this ); 48 _float = new QCheckBox( tr( "Enable floating and resizing" ), this );
@@ -70,13 +74,13 @@ InputMethodSettings::InputMethodSettings( QWidget *parent, const char *name ):QW
70void InputMethodSettings::appletChanged() 74void InputMethodSettings::appletChanged()
71{ 75{
72} 76}
73 77
74void InputMethodSettings::accept() 78void InputMethodSettings::accept()
75{ 79{
76 qDebug( "InputMethodSettings::accept()" ); 80 odebug << "InputMethodSettings::accept()" << oendl;
77 Config cfg( "Launcher" ); 81 Config cfg( "Launcher" );
78 cfg.setGroup( "InputMethods" ); 82 cfg.setGroup( "InputMethods" );
79 cfg.writeEntry( "Resize", _resize->isChecked() ); 83 cfg.writeEntry( "Resize", _resize->isChecked() );
80 cfg.writeEntry( "Float", _float->isChecked() ); 84 cfg.writeEntry( "Float", _float->isChecked() );
81 cfg.writeEntry( "Width", _size->value() ); 85 cfg.writeEntry( "Width", _size->value() );
82 cfg.write(); 86 cfg.write();
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
49using namespace Opie::Ui; 51using namespace Opie::Ui;
50class SampleItem : public QIconViewItem { 52class SampleItem : public QIconViewItem {
51public: 53public:
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
72private: 74private:
73 QPixmap m_large, m_small; 75 QPixmap m_large, m_small;
74}; 76};
75 77
76class SampleView : public QIconView { 78class SampleView : public QIconView {
77public: 79public:
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
255private: 257private:
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
264TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) 266TabDialog::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
308TabDialog::~TabDialog ( ) 310TabDialog::~TabDialog ( )
309{ 311{
310} 312}
311 313
312QWidget *TabDialog::createFontTab ( QWidget *parent ) 314QWidget *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
390QWidget *TabDialog::createIconTab ( QWidget *parent ) 392QWidget *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
433void TabDialog::iconSizeClicked ( int s ) 435void TabDialog::iconSizeClicked ( int s )
434{ 436{
435 m_sample-> setViewMode ((TabConfig::ViewMode) s ); 437 m_sample-> setViewMode ((TabConfig::ViewMode) s );
436} 438}
437 439
438void TabDialog::fontClicked ( const QFont &f ) 440void TabDialog::fontClicked ( const QFont &f )
439{ 441{
440 m_sample-> setViewFont ( f ); 442 m_sample-> setViewFont ( f );
441} 443}
442 444
443void TabDialog::bgTypeClicked ( int t ) 445void 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
461void TabDialog::bgColorClicked ( const QColor & ) 463void TabDialog::bgColorClicked ( const QColor & )
462{ 464{
463 bgTypeClicked ( TabConfig::SolidColor ); 465 bgTypeClicked ( TabConfig::SolidColor );
464} 466}
465 467
466void TabDialog::iconColorClicked ( const QColor &col ) 468void TabDialog::iconColorClicked ( const QColor &col )
467{ 469{
468 m_sample-> setTextColor ( col ); 470 m_sample-> setTextColor ( col );
469} 471}
470 472
471void TabDialog::bgImageClicked ( ) 473void 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
488void TabDialog::bgDefaultClicked ( ) 490void 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
494void TabDialog::accept ( ) 496void 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}
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
index 43886c9..8dd9e97 100644
--- a/core/settings/launcher/taskbarsettings.cpp
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -13,160 +13,164 @@
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskbarsettings.h" 29#include "taskbarsettings.h"
30 30
31/* OPIE */
31#include <qpe/config.h> 32#include <qpe/config.h>
32#include <qpe/qlibrary.h> 33#include <qpe/qlibrary.h>
33#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
34#include <qpe/taskbarappletinterface.h> 35#include <qpe/taskbarappletinterface.h>
35#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37#include <opie2/odebug.h>
36 38
39/* QT */
37#include <qdir.h> 40#include <qdir.h>
38#include <qlistview.h> 41#include <qlistview.h>
39#include <qheader.h> 42#include <qheader.h>
40#include <qlayout.h> 43#include <qlayout.h>
41#include <qlabel.h> 44#include <qlabel.h>
42#include <qwhatsthis.h> 45#include <qwhatsthis.h>
43 46
47/* STD */
44#include <stdlib.h> 48#include <stdlib.h>
45 49
46 50
47TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) 51TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
48 : QWidget ( parent, name ) 52 : QWidget ( parent, name )
49{ 53{
50 m_applets_changed = false; 54 m_applets_changed = false;
51 55
52 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 56 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
53 57
54 QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); 58 QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this );
55 lay-> addWidget ( l ); 59 lay-> addWidget ( l );
56 60
57 m_list = new QListView ( this ); 61 m_list = new QListView ( this );
58 m_list-> addColumn ( "foobar" ); 62 m_list-> addColumn ( "foobar" );
59 m_list-> header ( )-> hide ( ); 63 m_list-> header ( )-> hide ( );
60 64
61 lay-> addWidget ( m_list ); 65 lay-> addWidget ( m_list );
62 66
63 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); 67 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
64 68
65 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); 69 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
66 70
67 init ( ); 71 init ( );
68} 72}
69 73
70void TaskbarSettings::init ( ) 74void TaskbarSettings::init ( )
71{ 75{
72 Config cfg ( "Taskbar" ); 76 Config cfg ( "Taskbar" );
73 cfg. setGroup ( "Applets" ); 77 cfg. setGroup ( "Applets" );
74 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 78 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
75 79
76 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; 80 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
77#ifdef Q_OS_MACX 81#ifdef Q_OS_MACX
78 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 82 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
79#else 83#else
80 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 84 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
81#endif /* Q_OS_MACX */ 85#endif /* Q_OS_MACX */
82 86
83 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 87 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
84 QString name; 88 QString name;
85 QPixmap icon; 89 QPixmap icon;
86 TaskbarNamedAppletInterface *iface = 0; 90 TaskbarNamedAppletInterface *iface = 0;
87 91
88 qWarning("Load applet: %s", (*it).latin1() ); 92 owarn << "Load applet: " << (*it) << "" << oendl;
89 QLibrary *lib = new QLibrary ( path + "/" + *it ); 93 QLibrary *lib = new QLibrary ( path + "/" + *it );
90 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); 94 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface );
91 qWarning("<1>"); 95 owarn << "<1>" << oendl;
92 if ( iface ) { 96 if ( iface ) {
93 qWarning("<2>"); 97 owarn << "<2>" << oendl;
94 QString lang = getenv( "LANG" ); 98 QString lang = getenv( "LANG" );
95 QTranslator *trans = new QTranslator ( qApp ); 99 QTranslator *trans = new QTranslator ( qApp );
96 QString type = (*it). left ((*it). find (".")); 100 QString type = (*it). left ((*it). find ("."));
97 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; 101 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
98 if ( trans-> load ( tfn )) 102 if ( trans-> load ( tfn ))
99 qApp-> installTranslator ( trans ); 103 qApp-> installTranslator ( trans );
100 else 104 else
101 delete trans; 105 delete trans;
102 name = iface-> name ( ); 106 name = iface-> name ( );
103 icon = iface-> icon ( ); 107 icon = iface-> icon ( );
104 iface-> release ( ); 108 iface-> release ( );
105 } 109 }
106 qWarning("<3>"); 110 owarn << "<3>" << oendl;
107 if ( !iface ) { 111 if ( !iface ) {
108 qWarning("<4>"); 112 owarn << "<4>" << oendl;
109 lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); 113 lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface );
110 114
111 if ( iface ) { 115 if ( iface ) {
112 qWarning("<5>"); 116 owarn << "<5>" << oendl;
113 name = (*it). mid ( 3 ); 117 name = (*it). mid ( 3 );
114 qWarning("Found applet: %s", name.latin1() ); 118 owarn << "Found applet: " << name << "" << oendl;
115#ifdef Q_OS_MACX 119#ifdef Q_OS_MACX
116 int sep = name. find( ".dylib" ); 120 int sep = name. find( ".dylib" );
117#else 121#else
118 int sep = name. find( ".so" ); 122 int sep = name. find( ".so" );
119#endif /* Q_OS_MACX */ 123#endif /* Q_OS_MACX */
120 if ( sep > 0 ) 124 if ( sep > 0 )
121 name. truncate ( sep ); 125 name. truncate ( sep );
122 sep = name. find ( "applet" ); 126 sep = name. find ( "applet" );
123 if ( sep == (int) name.length ( ) - 6 ) 127 if ( sep == (int) name.length ( ) - 6 )
124 name. truncate ( sep ); 128 name. truncate ( sep );
125 name[0] = name[0]. upper ( ); 129 name[0] = name[0]. upper ( );
126 iface-> release ( ); 130 iface-> release ( );
127 } 131 }
128 } 132 }
129 qWarning("<6>"); 133 owarn << "<6>" << oendl;
130 134
131 if ( iface ) { 135 if ( iface ) {
132 qWarning("<7>"); 136 owarn << "<7>" << oendl;
133 QCheckListItem *item; 137 QCheckListItem *item;
134 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 138 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
135 if ( !icon. isNull ( )) 139 if ( !icon. isNull ( ))
136 item-> setPixmap ( 0, icon ); 140 item-> setPixmap ( 0, icon );
137 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 141 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
138 m_applets [*it] = item; 142 m_applets [*it] = item;
139 } 143 }
140 lib-> unload ( ); 144 lib-> unload ( );
141 delete lib; 145 delete lib;
142 } 146 }
143} 147}
144 148
145void TaskbarSettings::appletChanged() 149void TaskbarSettings::appletChanged()
146{ 150{
147 m_applets_changed = true; 151 m_applets_changed = true;
148} 152}
149 153
150void TaskbarSettings::accept ( ) 154void TaskbarSettings::accept ( )
151{ 155{
152 Config cfg ( "Taskbar" ); 156 Config cfg ( "Taskbar" );
153 cfg. setGroup ( "Applets" ); 157 cfg. setGroup ( "Applets" );
154 158
155 if ( m_applets_changed ) { 159 if ( m_applets_changed ) {
156 QStringList exclude; 160 QStringList exclude;
157 QMap <QString, QCheckListItem *>::Iterator it; 161 QMap <QString, QCheckListItem *>::Iterator it;
158 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { 162 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
159 if ( !(*it)-> isOn ( )) 163 if ( !(*it)-> isOn ( ))
160 exclude << it. key ( ); 164 exclude << it. key ( );
161 } 165 }
162 cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); 166 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
163 } 167 }
164 cfg. writeEntry ( "SafeMode", false ); 168 cfg. writeEntry ( "SafeMode", false );
165 cfg. write ( ); 169 cfg. write ( );
166 170
167 if ( m_applets_changed ) { 171 if ( m_applets_changed ) {
168 QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); 172 QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" );
169 m_applets_changed = false; 173 m_applets_changed = false;
170 } 174 }
171} 175}
172 176
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index d64a063..424a64c 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -26,20 +26,23 @@
26 26
27*/ 27*/
28 28
29#include "light.h" 29#include "light.h"
30#include "sensor.h" 30#include "sensor.h"
31 31
32/* OPIE */
32#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34#include <opie2/odebug.h>
33 35
34#include <qpe/config.h> 36#include <qpe/config.h>
35#include <qpe/power.h> 37#include <qpe/power.h>
36#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 38#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
37#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
38#endif 40#endif
39 41
42/* QT */
40#include <qlabel.h> 43#include <qlabel.h>
41#include <qcheckbox.h> 44#include <qcheckbox.h>
42#include <qtabwidget.h> 45#include <qtabwidget.h>
43#include <qslider.h> 46#include <qslider.h>
44#include <qspinbox.h> 47#include <qspinbox.h>
45#include <qpushbutton.h> 48#include <qpushbutton.h>
@@ -48,267 +51,267 @@
48 51
49 52
50 53
51using namespace Opie::Core; 54using namespace Opie::Core;
52 55
53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 56LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 57 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
55{ 58{
56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 59 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
57 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 60 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
58 61
59 // check whether to show the light sensor stuff 62 // check whether to show the light sensor stuff
60 63
61 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 64 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
62 auto_brightness-> hide ( ); 65 auto_brightness-> hide ( );
63 CalibrateLightSensor-> hide ( ); 66 CalibrateLightSensor-> hide ( );
64 auto_brightness_ac-> hide ( ); 67 auto_brightness_ac-> hide ( );
65 CalibrateLightSensor_ac-> hide ( ); 68 CalibrateLightSensor_ac-> hide ( );
66 } 69 }
67 70
68 // check whether to show the contrast stuff 71 // check whether to show the contrast stuff
69 72
70 if (m_cres) { 73 if (m_cres) {
71 GroupLight->setTitle(tr("Backlight && Contrast")); 74 GroupLight->setTitle(tr("Backlight && Contrast"));
72 GroupLight_ac->setTitle(GroupLight->title()); 75 GroupLight_ac->setTitle(GroupLight->title());
73 } else { 76 } else {
74 contrast->hide(); 77 contrast->hide();
75 contrast_ac->hide(); 78 contrast_ac->hide();
76 } 79 }
77 80
78 // check whether to show the cpu frequency stuff 81 // check whether to show the cpu frequency stuff
79 82
80 QStrList freq = ODevice::inst()->allowedCpuFrequencies(); 83 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
81 if ( freq.count() ) { 84 if ( freq.count() ) {
82 frequency->insertStrList( freq ); 85 frequency->insertStrList( freq );
83 frequency_ac->insertStrList( freq ); 86 frequency_ac->insertStrList( freq );
84 } else { 87 } else {
85 frequencyLabel->hide(); 88 frequencyLabel->hide();
86 frequency->hide(); 89 frequency->hide();
87 frequencyLabel_ac->hide(); 90 frequencyLabel_ac->hide();
88 frequency_ac->hide(); 91 frequency_ac->hide();
89 } 92 }
90 93
91 // check whether to show the hinge action stuff 94 // check whether to show the hinge action stuff
92 95
93 if ( !ODevice::inst()->hasHingeSensor() ) { 96 if ( !ODevice::inst()->hasHingeSensor() ) {
94 closeHingeLabel->hide(); 97 closeHingeLabel->hide();
95 closeHingeAction->hide(); 98 closeHingeAction->hide();
96 closeHingeLabel_ac->hide(); 99 closeHingeLabel_ac->hide();
97 closeHingeAction_ac->hide(); 100 closeHingeAction_ac->hide();
98 } 101 }
99 102
100 Config config ( "apm" ); 103 Config config ( "apm" );
101 config. setGroup ( "Battery" ); 104 config. setGroup ( "Battery" );
102 105
103 // battery spinboxes 106 // battery spinboxes
104 interval_dim-> setValue ( config. readNumEntry ( "Dim", 20 )); 107 interval_dim-> setValue ( config. readNumEntry ( "Dim", 20 ));
105 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 30 )); 108 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 30 ));
106 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 109 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
107 110
108 // battery check and slider 111 // battery check and slider
109 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 112 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
110 113
111 // CPU frequency 114 // CPU frequency
112 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 115 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
113 116
114 // hinge action 117 // hinge action
115 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 118 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
116 119
117 int bright = config. readNumEntry ( "Brightness", 127 ); 120 int bright = config. readNumEntry ( "Brightness", 127 );
118 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 121 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
119 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 122 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
120 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 123 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
121 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 124 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
122 brightness-> setValue ( bright ); 125 brightness-> setValue ( bright );
123 126
124 if (m_cres) { 127 if (m_cres) {
125 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 128 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
126 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 129 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
127 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 130 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
128 contrast-> setValue ( contr ); 131 contrast-> setValue ( contr );
129 } 132 }
130 133
131 // light sensor 134 // light sensor
132 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 135 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
133 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 136 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
134 137
135 config. setGroup ( "AC" ); 138 config. setGroup ( "AC" );
136 139
137 // ac spinboxes 140 // ac spinboxes
138 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 141 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
139 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 142 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
140 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 143 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
141 144
142 // ac check and slider 145 // ac check and slider
143 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 146 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
144 147
145 // CPU frequency 148 // CPU frequency
146 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 149 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
147 150
148 // hinge action 151 // hinge action
149 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 152 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
150 153
151 bright = config. readNumEntry ( "Brightness", 255 ); 154 bright = config. readNumEntry ( "Brightness", 255 );
152 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 155 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
153 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 156 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
154 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 157 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
155 brightness_ac-> setValue ( bright ); 158 brightness_ac-> setValue ( bright );
156 159
157 if (m_cres) { 160 if (m_cres) {
158 contr = config. readNumEntry ( "Contrast", 127); 161 contr = config. readNumEntry ( "Contrast", 127);
159 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 162 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
160 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 163 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
161 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 164 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
162 contrast_ac-> setValue ( contr ); 165 contrast_ac-> setValue ( contr );
163 } 166 }
164 167
165 // light sensor 168 // light sensor
166 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 169 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
167 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 170 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
168 171
169 // warnings 172 // warnings
170 config. setGroup ( "Warnings" ); 173 config. setGroup ( "Warnings" );
171 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 174 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
172 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 175 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
173 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 176 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
174 177
175 m_resettimer = new QTimer ( this ); 178 m_resettimer = new QTimer ( this );
176 connect ( m_resettimer, SIGNAL( timeout()), this, SLOT( resetBacklight())); 179 connect ( m_resettimer, SIGNAL( timeout()), this, SLOT( resetBacklight()));
177 180
178 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 181 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
179 tabs-> setCurrentPage ( 0 ); 182 tabs-> setCurrentPage ( 0 );
180 } 183 }
181 else { 184 else {
182 tabs-> setCurrentPage ( 1 ); 185 tabs-> setCurrentPage ( 1 );
183 } 186 }
184 187
185 connect ( brightness, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int))); 188 connect ( brightness, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int)));
186 connect ( brightness_ac, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int))); 189 connect ( brightness_ac, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int)));
187 if (m_cres) { 190 if (m_cres) {
188 connect ( contrast, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int))); 191 connect ( contrast, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int)));
189 connect ( contrast_ac, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int))); 192 connect ( contrast_ac, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int)));
190 } 193 }
191 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 194 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
192 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 195 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
193 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 196 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
194 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 197 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
195} 198}
196 199
197LightSettings::~LightSettings ( ) 200LightSettings::~LightSettings ( )
198{ 201{
199} 202}
200 203
201void LightSettings::calibrateSensor ( ) 204void LightSettings::calibrateSensor ( )
202{ 205{
203 Sensor *s = new Sensor ( m_sensordata, this ); 206 Sensor *s = new Sensor ( m_sensordata, this );
204 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int))); 207 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int)));
205 QPEApplication::execDialog( s ); 208 QPEApplication::execDialog( s );
206 delete s; 209 delete s;
207} 210}
208 211
209void LightSettings::calibrateSensorAC ( ) 212void LightSettings::calibrateSensorAC ( )
210{ 213{
211 Sensor *s = new Sensor ( m_sensordata_ac, this ); 214 Sensor *s = new Sensor ( m_sensordata_ac, this );
212 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int))); 215 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int)));
213 QPEApplication::execDialog ( s ); 216 QPEApplication::execDialog ( s );
214 delete s; 217 delete s;
215} 218}
216 219
217void LightSettings::setBacklight ( int bright ) 220void LightSettings::setBacklight ( int bright )
218{ 221{
219 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 222 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
220 e << bright; 223 e << bright;
221 224
222 if ( bright != -1 ) { 225 if ( bright != -1 ) {
223 m_resettimer-> stop ( ); 226 m_resettimer-> stop ( );
224 m_resettimer-> start ( 4000, true ); 227 m_resettimer-> start ( 4000, true );
225 } 228 }
226} 229}
227 230
228void LightSettings::setContrast ( int contr ) 231void LightSettings::setContrast ( int contr )
229{ 232{
230 if (contr == -1) contr = m_oldcontrast; 233 if (contr == -1) contr = m_oldcontrast;
231 ODevice::inst ( )-> setDisplayContrast(contr); 234 ODevice::inst ( )-> setDisplayContrast(contr);
232} 235}
233 236
234void LightSettings::setFrequency ( int index ) 237void LightSettings::setFrequency ( int index )
235{ 238{
236 qWarning("LightSettings::setFrequency(%d)", index); 239 owarn << "LightSettings::setFrequency(" << index << ")" << oendl;
237 ODevice::inst ( )-> setCurrentCpuFrequency(index); 240 ODevice::inst ( )-> setCurrentCpuFrequency(index);
238} 241}
239 242
240void LightSettings::resetBacklight ( ) 243void LightSettings::resetBacklight ( )
241{ 244{
242 setBacklight ( -1 ); 245 setBacklight ( -1 );
243 setContrast ( -1 ); 246 setContrast ( -1 );
244} 247}
245 248
246void LightSettings::setCloseHingeAction ( int index ) 249void LightSettings::setCloseHingeAction ( int index )
247{ 250{
248 qWarning("LightSettings::setCloseHingeStatus(%d)", index); 251 owarn << "LightSettings::setCloseHingeStatus(" << index << ")" << oendl;
249} 252}
250 253
251void LightSettings::accept ( ) 254void LightSettings::accept ( )
252{ 255{
253 Config config ( "apm" ); 256 Config config ( "apm" );
254 257
255 // bat 258 // bat
256 config. setGroup ( "Battery" ); 259 config. setGroup ( "Battery" );
257 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 260 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
258 config. writeEntry ( "Dim", interval_dim-> value ( )); 261 config. writeEntry ( "Dim", interval_dim-> value ( ));
259 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 262 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
260 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 263 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
261 config. writeEntry ( "Brightness", brightness-> value () ); 264 config. writeEntry ( "Brightness", brightness-> value () );
262 if (m_cres) 265 if (m_cres)
263 config. writeEntry ( "Contrast", contrast-> value () ); 266 config. writeEntry ( "Contrast", contrast-> value () );
264 config. writeEntry ( "Freq", frequency->currentItem() ); 267 config. writeEntry ( "Freq", frequency->currentItem() );
265 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); 268 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() );
266 269
267 // ac 270 // ac
268 config. setGroup ( "AC" ); 271 config. setGroup ( "AC" );
269 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 272 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
270 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 273 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
271 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 274 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
272 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 275 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
273 config. writeEntry ( "Brightness", brightness_ac-> value () ); 276 config. writeEntry ( "Brightness", brightness_ac-> value () );
274 if (m_cres) 277 if (m_cres)
275 config. writeEntry ( "Contrast", contrast_ac-> value () ); 278 config. writeEntry ( "Contrast", contrast_ac-> value () );
276 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 279 config. writeEntry ( "Freq", frequency_ac->currentItem() );
277 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); 280 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() );
278 281
279 // only make light sensor stuff appear if the unit has a sensor 282 // only make light sensor stuff appear if the unit has a sensor
280 if ( ODevice::inst ( )-> hasLightSensor ( )) { 283 if ( ODevice::inst ( )-> hasLightSensor ( )) {
281 config. setGroup ( "Battery" ); 284 config. setGroup ( "Battery" );
282 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 285 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
283 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 286 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
284 config. setGroup ( "AC" ); 287 config. setGroup ( "AC" );
285 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 288 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
286 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 289 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
287 } 290 }
288 291
289 // advanced 292 // advanced
290 config. setGroup ( "Warnings" ); 293 config. setGroup ( "Warnings" );
291 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 294 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
292 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 295 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
293 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 296 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
294 config. write ( ); 297 config. write ( );
295 298
296 // notify the launcher 299 // notify the launcher
297 { 300 {
298 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 301 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
299 } 302 }
300 { 303 {
301 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 304 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
302 e << -1; 305 e << -1;
303 } 306 }
304 LightSettingsBase::accept ( ); 307 LightSettingsBase::accept ( );
305} 308}
306 309
307void LightSettings::done ( int r ) 310void LightSettings::done ( int r )
308{ 311{
309 m_resettimer-> stop ( ); 312 m_resettimer-> stop ( );
310 resetBacklight ( ); 313 resetBacklight ( );
311 314
312 LightSettingsBase::done ( r ); 315 LightSettingsBase::done ( r );
313 close ( ); 316 close ( );
314} 317}
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp
index 4eddb55..b917aea 100644
--- a/core/settings/security/security.cpp
+++ b/core/settings/security/security.cpp
@@ -16,25 +16,31 @@
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20#include "security.h" 20#include "security.h"
21 21
22/* OPIE */
22#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
23#include <qpe/config.h> 24#include <qpe/config.h>
24#include <qpe/password.h> 25#include <qpe/password.h>
25#include <qpe/qpedialog.h> 26#include <qpe/qpedialog.h>
26#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <opie2/odebug.h>
27 29
30/* QT */
28#include <qcheckbox.h> 31#include <qcheckbox.h>
29#include <qpushbutton.h> 32#include <qpushbutton.h>
30#include <qcombobox.h> 33#include <qcombobox.h>
31#include <qmessagebox.h> 34#include <qmessagebox.h>
32#include <qfile.h> 35#include <qfile.h>
33#include <qtextstream.h> 36#include <qtextstream.h>
34 37
38
39using namespace Opie::Core;
40
35 Security::Security( QWidget* parent, const char* name, WFlags fl ) 41 Security::Security( QWidget* parent, const char* name, WFlags fl )
36: SecurityBase( parent, name, TRUE, WStyle_ContextHelp ) 42: SecurityBase( parent, name, TRUE, WStyle_ContextHelp )
37{ 43{
38 valid=FALSE; 44 valid=FALSE;
39 Config cfg("Security"); 45 Config cfg("Security");
40 cfg.setGroup("Passcode"); 46 cfg.setGroup("Passcode");
@@ -115,13 +121,13 @@ void Security::deleteListEntry()
115} 121}
116 122
117void Security::restoreDefaults() 123void Security::restoreDefaults()
118{ 124{
119 QMessageBox unrecbox( 125 QMessageBox unrecbox(
120 tr("Attention"), 126 tr("Attention"),
121 tr("<p>All user-defined net ranges will be lost."), 127 tr( "<p>All user-defined net ranges will be lost."),
122 QMessageBox::Warning, 128 QMessageBox::Warning,
123 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 129 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
124 0, QString::null, TRUE, WStyle_StaysOnTop); 130 0, QString::null, TRUE, WStyle_StaysOnTop);
125 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); 131 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
126 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); 132 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok"));
127 133
@@ -167,22 +173,22 @@ void Security::show()
167 if ( passcode.isEmpty() ) { 173 if ( passcode.isEmpty() ) {
168 // could insist... 174 // could insist...
169 //changePassCode(); 175 //changePassCode();
170 //if ( passcode.isEmpty() ) 176 //if ( passcode.isEmpty() )
171 //reject(); 177 //reject();
172 } else { 178 } else {
173 if (!valid) // security passcode was not asked yet, so ask now 179 if (!valid) // security passcode was not asked yet, so ask now
174 { 180 {
175 QString pc = enterPassCode(tr("Enter passcode")); 181 QString pc = enterPassCode(tr("Enter passcode"));
176 if ( pc != passcode ) { 182 if ( pc != passcode ) {
177 QMessageBox::critical(this, tr("Passcode incorrect"), 183 QMessageBox::critical(this, tr("Passcode incorrect"),
178 tr("The passcode entered is incorrect.\nAccess denied")); 184 tr("The passcode entered is incorrect.\nAccess denied"));
179 reject(); 185 reject();
180 return; 186 return;
181 } 187 }
182 } 188 }
183 } 189 }
184 setEnabled(TRUE); 190 setEnabled(TRUE);
185 valid=TRUE; 191 valid=TRUE;
186} 192}
187 193
188void Security::accept() 194void Security::accept()
@@ -213,23 +219,23 @@ void Security::selectNet(int auth_peer,int auth_peer_bits, bool update)
213 + QString::number((auth_peer>>0)&0xff) + "/" 219 + QString::number((auth_peer>>0)&0xff) + "/"
214 + QString::number(auth_peer_bits); 220 + QString::number(auth_peer_bits);
215 } 221 }
216 222
217 //insert user-defined list of netranges upon start 223 //insert user-defined list of netranges upon start
218 if (update) { 224 if (update) {
219 //User selected/active netrange first 225 //User selected/active netrange first
220 syncnet->insertItem( tr( sn ) ); 226 syncnet->insertItem( tr( sn ) );
221 227
222 Config cfg("Security"); 228 Config cfg("Security");
223 cfg.setGroup("Sync"); 229 cfg.setGroup("Sync");
224 230
225 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe 231 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe
226 QString test = cfg.readEntry("net0",""); 232 QString test = cfg.readEntry("net0","");
227 if (test.isEmpty()) { 233 if (test.isEmpty()) {
228 insertDefaultRanges(); 234 insertDefaultRanges();
229 } else { 235 } else {
230 // 10 ought to be enough for everybody... :) 236 // 10 ought to be enough for everybody... :)
231 // If you need more, don't forget to edit applySecurity() as well 237 // If you need more, don't forget to edit applySecurity() as well
232 bool already_there=FALSE; 238 bool already_there=FALSE;
233 for (int i=0; i<10; i++) { 239 for (int i=0; i<10; i++) {
234 QString target, netrange; 240 QString target, netrange;
235 target.sprintf("net%d", i); 241 target.sprintf("net%d", i);
@@ -254,13 +260,13 @@ void Security::selectNet(int auth_peer,int auth_peer_bits, bool update)
254 for (int i=0; i<syncnet->count(); i++) { 260 for (int i=0; i<syncnet->count(); i++) {
255 if ( syncnet->text(i).left(sn.length()) == sn ) { 261 if ( syncnet->text(i).left(sn.length()) == sn ) {
256 syncnet->setCurrentItem(i); 262 syncnet->setCurrentItem(i);
257 return; 263 return;
258 } 264 }
259 } 265 }
260 qDebug("No match for \"%s\"",sn.latin1()); 266 odebug << "No match for \"" << sn << "\"" << oendl;
261} 267}
262 268
263void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 269void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
264{ 270{
265 auth_peer=0; 271 auth_peer=0;
266 if ( sn == tr("Any") ) { 272 if ( sn == tr("Any") ) {
@@ -337,18 +343,18 @@ void Security::applySecurity()
337 parseNet(sn,auth_peer,auth_peer_bits); 343 parseNet(sn,auth_peer,auth_peer_bits);
338 344
339 //this is the *selected* (active) net range 345 //this is the *selected* (active) net range
340 cfg.writeEntry("auth_peer",auth_peer); 346 cfg.writeEntry("auth_peer",auth_peer);
341 cfg.writeEntry("auth_peer_bits",auth_peer_bits); 347 cfg.writeEntry("auth_peer_bits",auth_peer_bits);
342 348
343 //write back all other net ranges in *cleartext* 349 //write back all other net ranges in *cleartext*
344 for (int i=0; i<10; i++) { 350 for (int i=0; i<10; i++) {
345 QString target; 351 QString target;
346 target.sprintf("net%d", i); 352 target.sprintf("net%d", i);
347 cfg.writeEntry(target,syncnet->text(i)); 353 cfg.writeEntry(target,syncnet->text(i));
348 } 354 }
349 355
350#ifdef ODP 356#ifdef ODP
351 #error "Use 0,1,2 and use Launcher" 357 #error "Use 0,1,2 and use Launcher"
352#endif 358#endif
353 /* keep the old code so we don't use currentItem directly */ 359 /* keep the old code so we don't use currentItem directly */
354 int value = 0x02; 360 int value = 0x02;
diff --git a/core/settings/security/security.pro b/core/settings/security/security.pro
index 4a29ee2..4c1e68b 100644
--- a/core/settings/security/security.pro
+++ b/core/settings/security/security.pro
@@ -1,10 +1,10 @@
1 CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2 HEADERS = security.h 2HEADERS = security.h
3 SOURCES = security.cpp main.cpp 3SOURCES = security.cpp main.cpp
4 INTERFACES= securitybase.ui 4INTERFACES = securitybase.ui
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6 DEPENDPATH+= ../$(OPIEDIR)/include 6DEPENDPATH += ../$(OPIEDIR)/include
7LIBS += -lqpe 7LIBS += -lqpe -lopiecore2
8 TARGET = security 8TARGET = security
9 9
10include ( $(OPIEDIR)/include.pro ) 10include ( $(OPIEDIR)/include.pro )
diff --git a/core/symlinker/main.cpp b/core/symlinker/main.cpp
index 6a04980..96e7f3c 100644
--- a/core/symlinker/main.cpp
+++ b/core/symlinker/main.cpp
@@ -1,15 +1,21 @@
1
2/* OPIE */
3#include <opie2/odebug.h>
4
5/* QT */
1#include <qapplication.h> 6#include <qapplication.h>
2#include <qfile.h> 7#include <qfile.h>
3#include <qfileinfo.h> 8#include <qfileinfo.h>
4#include <qdir.h> 9#include <qdir.h>
5#include <qtextstream.h> 10#include <qtextstream.h>
6#include <qstringlist.h> 11#include <qstringlist.h>
7 12
13/* STD */
8#include <stdlib.h> 14#include <stdlib.h>
9#include <unistd.h> //symlink() 15#include <unistd.h> //symlink()
10#include <sys/stat.h> // mkdir() 16#include <sys/stat.h> // mkdir()
11 17
12#include <sys/vfs.h> 18#include <sys/vfs.h>
13#include <mntent.h> 19#include <mntent.h>
14#include <errno.h> 20#include <errno.h>
15 21
@@ -21,159 +27,159 @@ static void createSymlinks( const QString &location, const QString &package )
21 QFile inFile( location + "/usr/lib/ipkg/info/" + package + ".list" ); 27 QFile inFile( location + "/usr/lib/ipkg/info/" + package + ".list" );
22 mkdir( "/usr/lib/ipkg", 0777 ); 28 mkdir( "/usr/lib/ipkg", 0777 );
23 mkdir( listDir, 0777 ); 29 mkdir( listDir, 0777 );
24 30
25 QFile outFile( listDir + package + ".list"); 31 QFile outFile( listDir + package + ".list");
26 32
27// qDebug( "createSymlinks %s -> %s", inFile.name().ascii(), outFile.name().ascii() ); 33// odebug << "createSymlinks " << inFile.name().ascii() << " -> " << outFile.name().ascii() << "" << oendl;
28 34
29 35
30 36
31 if ( inFile.open(IO_ReadOnly) && outFile.open(IO_WriteOnly)) { 37 if ( inFile.open(IO_ReadOnly) && outFile.open(IO_WriteOnly)) {
32 QTextStream in(&inFile); 38 QTextStream in(&inFile);
33 QTextStream out(&outFile); 39 QTextStream out(&outFile);
34 40
35 QString s; 41 QString s;
36 while ( !in.eof() ) { // until end of file... 42 while ( !in.eof() ) { // until end of file...
37 s = in.readLine(); // line of text excluding '\n' 43 s = in.readLine(); // line of text excluding '\n'
38 // qDebug( "Read: %s", s.ascii() ); 44// odebug << "Read: " << s.ascii() << "" << oendl;
39 if (s.find(location,0,true) >= 0){ 45 if (s.find(location,0,true) >= 0){
40 // qDebug( "Found!" ); 46// odebug << "Found!" << oendl;
41 s = s.replace(location,""); 47 s = s.replace(location,"");
42 } 48 }
43 // qDebug( "Read after: %s", s.ascii() ); 49// odebug << "Read after: " << s.ascii() << "" << oendl;
44 50
45 // for s, do link/mkdir. 51 // for s, do link/mkdir.
46 if ( s.right(1) == "/" ) { 52 if ( s.right(1) == "/" ) {
47 // qDebug("do mkdir for %s", s.ascii()); 53// odebug << "do mkdir for " << s.ascii() << "" << oendl;
48 mkdir( s.ascii(), 0777 ); 54 mkdir( s.ascii(), 0777 );
49 //possible optimization: symlink directories 55 //possible optimization: symlink directories
50 //that don't exist already. -- Risky. 56 //that don't exist already. -- Risky.
51 } else { 57 } else {
52 // qDebug("do symlink for %s", s.ascii()); 58// odebug << "do symlink for " << s.ascii() << "" << oendl;
53 QFileInfo ffi( s ); 59 QFileInfo ffi( s );
54 //Don't try to symlink if a regular file exists already 60 //Don't try to symlink if a regular file exists already
55 if ( !ffi.exists() || ffi.isSymLink() ) { 61 if ( !ffi.exists() || ffi.isSymLink() ) {
56 if (symlink( (location+s).ascii(), s.ascii() ) != 0){ 62 if (symlink( (location+s).ascii(), s.ascii() ) != 0){
57 if (errno == ENOENT){ 63 if (errno == ENOENT){
58 // perror("Symlink Failed! "); 64// perror("Symlink Failed! ");
59 QString e=s.ascii(); 65 QString e=s.ascii();
60 e = e.replace(ffi.fileName(),""); 66 e = e.replace(ffi.fileName(),"");
61 // qDebug("DirName : %s",e.ascii() ); 67// odebug << "DirName : " << e.ascii() << "" << oendl;
62 system ( QString("mkdir -p ")+e.ascii() ); 68 system ( QString("mkdir -p ")+e.ascii() );
63 if (symlink( (location+s).ascii(), s.ascii() ) != 0) 69 if (symlink( (location+s).ascii(), s.ascii() ) != 0)
64 qDebug ("Big problem creating symlink and directory"); 70 odebug << "Big problem creating symlink and directory" << oendl;
65 } 71 }
66 } 72 }
67 // qDebug ( "Created %s" ,s.ascii() ); 73// qDebug ( "Created %s" ,s.ascii() );
68 out << s << "\n"; 74 out << s << "\n";
69 } else { 75 } else {
70 qDebug( "%s exists already, not symlinked", s.ascii() ); 76 odebug << "" << s.ascii() << " exists already, not symlinked" << oendl;
71 } 77 }
72 } 78 }
73 } 79 }
74 inFile.close(); 80 inFile.close();
75 outFile.close(); 81 outFile.close();
76 } 82 }
77} 83}
78 84
79 85
80 86
81static void removeSymlinks( const QString &package ) 87static void removeSymlinks( const QString &package )
82{ 88{
83 QFile inFile( listDir + package + ".list" ); 89 QFile inFile( listDir + package + ".list" );
84 90
85 if ( inFile.open(IO_ReadOnly) ) { 91 if ( inFile.open(IO_ReadOnly) ) {
86 QTextStream in(&inFile); 92 QTextStream in(&inFile);
87 93
88 QString s; 94 QString s;
89 while ( !in.eof() ) { // until end of file... 95 while ( !in.eof() ) { // until end of file...
90 s = in.readLine(); // line of text excluding '\n' 96 s = in.readLine(); // line of text excluding '\n'
91 // qDebug("remove symlink %s", s.ascii()); 97// odebug << "remove symlink " << s.ascii() << "" << oendl;
92 QFileInfo ffi( s ); 98 QFileInfo ffi( s );
93 //Confirm that it's still a symlink. 99 //Confirm that it's still a symlink.
94 if ( ffi.isSymLink() ){ 100 if ( ffi.isSymLink() ){
95 unlink( s.ascii() ); 101 unlink( s.ascii() );
96 // qDebug ( "Removed %s", s.ascii() );} 102// qDebug ( "Removed %s", s.ascii() );}
97 // else 103// else
98 // qDebug( "Not removed %s", s.ascii() ); 104// odebug << "Not removed " << s.ascii() << "" << oendl;
99 } 105 }
100 } 106 }
101 inFile.close(); 107 inFile.close();
102 inFile.remove(); 108 inFile.remove();
103 } 109 }
104} 110}
105 111
106 112
107 113
108/* 114/*
109 Slightly hacky: we can't use StorageInfo, since we don't have a 115 Slightly hacky: we can't use StorageInfo, since we don't have a
110 QApplication. We look for filesystems that have the directory 116 QApplication. We look for filesystems that have the directory
111 /usr/lib/ipkg/info, and assume that they are removable media 117 /usr/lib/ipkg/info, and assume that they are removable media
112 with packages installed. This is safe even if eg. /usr is on a 118 with packages installed. This is safe even if eg. /usr is on a
113 separate filesystem, since then we would be testing for 119 separate filesystem, since then we would be testing for
114 /usr/usr/lib/ipkg/info, which should not exist. (And if it 120 /usr/usr/lib/ipkg/info, which should not exist. (And if it
115 does they deserve to have it treated as removable.) 121 does they deserve to have it treated as removable.)
116 */ 122 */
117 123
118static void updateSymlinks() 124static void updateSymlinks()
119{ 125{
120 QDir lists( listDir ); 126 QDir lists( listDir );
121 QStringList knownPackages = lists.entryList( "*.list" ); // No tr 127 QStringList knownPackages = lists.entryList( "*.list" ); // No tr
122 128
123 struct mntent *me; 129 struct mntent *me;
124 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 130 FILE *mntfp = setmntent( "/etc/mtab", "r" );
125 131
126 if ( mntfp ) { 132 if ( mntfp ) {
127 while ( (me = getmntent( mntfp )) != 0 ) { 133 while ( (me = getmntent( mntfp )) != 0 ) {
128 QString root = me->mnt_dir; 134 QString root = me->mnt_dir;
129 if ( root == "/" ) 135 if ( root == "/" )
130 continue; 136 continue;
131 137
132 QString info = root + "/usr/lib/ipkg/info"; 138 QString info = root + "/usr/lib/ipkg/info";
133 QDir infoDir( info ); 139 QDir infoDir( info );
134 // qDebug( "looking at %s", info.ascii() ); 140// odebug << "looking at " << info.ascii() << "" << oendl;
135 if ( infoDir.isReadable() ) { 141 if ( infoDir.isReadable() ) {
136 const QFileInfoList *packages = infoDir.entryInfoList( "*.list" ); // No tr 142 const QFileInfoList *packages = infoDir.entryInfoList( "*.list" ); // No tr
137 QFileInfoListIterator it( *packages ); 143 QFileInfoListIterator it( *packages );
138 QFileInfo *fi; 144 QFileInfo *fi;
139 while (( fi = *it )) { 145 while (( fi = *it )) {
140 ++it; 146 ++it;
141 if ( knownPackages.contains( fi->fileName() ) ) { 147 if ( knownPackages.contains( fi->fileName() ) ) {
142 // qDebug( "found %s and we've seen it before", fi->fileName().latin1() ); 148// odebug << "found " << fi->fileName() << " and we've seen it before" << oendl;
143 knownPackages.remove( fi->fileName() ); 149 knownPackages.remove( fi->fileName() );
144 } else { 150 } else {
145 //it's a new one 151 //it's a new one
146 createSymlinks( root, fi->baseName() ); 152 createSymlinks( root, fi->baseName() );
147 } 153 }
148 154
149 } 155 }
150 156
151 } 157 }
152 } 158 }
153 endmntent( mntfp ); 159 endmntent( mntfp );
154 } 160 }
155 161
156 for ( QStringList::Iterator it = knownPackages.begin(); 162 for ( QStringList::Iterator it = knownPackages.begin();
157 it != knownPackages.end(); ++it ) { 163 it != knownPackages.end(); ++it ) {
158 // strip ".info" off the end. 164 // strip ".info" off the end.
159 removeSymlinks( (*it).left((*it).length()-5) ); 165 removeSymlinks( (*it).left((*it).length()-5) );
160 } 166 }
161} 167}
162 168
163 169
164 170
165int main( int argc, char *argv[] ) 171int main( int argc, char *argv[] )
166{ 172{
167 QApplication a( argc, argv, QApplication::Tty ); 173 QApplication a( argc, argv, QApplication::Tty );
168 174
169 QString command = argc > 1 ? argv[1] : "update"; // No tr 175 QString command = argc > 1 ? argv[1] : "update"; // No tr
170 176
171 if ( command == "update" ) // No tr 177 if ( command == "update" ) // No tr
172 updateSymlinks(); 178 updateSymlinks();
173 else if ( command == "create" && argc > 3 ) // No tr 179 else if ( command == "create" && argc > 3 ) // No tr
174 createSymlinks( argv[2], argv[3] ); 180 createSymlinks( argv[2], argv[3] );
175 else if ( command == "remove" && argc > 2 ) // No tr 181 else if ( command == "remove" && argc > 2 ) // No tr
176 removeSymlinks( argv[2] ); 182 removeSymlinks( argv[2] );
177 else 183 else
178 qWarning( "Argument error" ); 184 owarn << "Argument error" << oendl;
179} 185}
diff --git a/core/symlinker/symlinker.pro b/core/symlinker/symlinker.pro
index f850d46..50ad785 100644
--- a/core/symlinker/symlinker.pro
+++ b/core/symlinker/symlinker.pro
@@ -1,15 +1,15 @@
1 TEMPLATE= app 1TEMPLATE = app
2 CONFIG += qt warn_on 2CONFIG += qt warn_on
3 DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS = 5HEADERS =
6 SOURCES = main.cpp 6SOURCES = main.cpp
7 INTERFACES= 7INTERFACES =
8 8
9 TARGET = opie-update-symlinks 9TARGET = opie-update-symlinks
10INCLUDEPATH += $(OPIEDIR)/include 10INCLUDEPATH += $(OPIEDIR)/include
11DEPENDPATH += $(OPIEDIR)/include . 11DEPENDPATH += $(OPIEDIR)/include .
12LIBS += -lqpe 12LIBS += -lqpe -lopiecore2
13 13
14include ( $(OPIEDIR)/include.pro ) 14include ( $(OPIEDIR)/include.pro )
15 15
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp
index d467d6e..c2467fb 100644
--- a/core/tools/quicklauncher/main.cpp
+++ b/core/tools/quicklauncher/main.cpp
@@ -15,12 +15,18 @@
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "dropins.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
25
26/* QT */
21#include <qpainter.h> 27#include <qpainter.h>
22#include <qstrlist.h> 28#include <qstrlist.h>
23#include <qtimer.h> 29#include <qtimer.h>
24#include <qguardedptr.h> 30#include <qguardedptr.h>
25#include <qcopchannel_qws.h> 31#include <qcopchannel_qws.h>
26#define QTOPIA_INTERNAL_INITAPP 32#define QTOPIA_INTERNAL_INITAPP
@@ -28,19 +34,20 @@
28#ifdef private 34#ifdef private
29# undef private 35# undef private
30#endif 36#endif
31#define private public 37#define private public
32#include <qtopia/qpeapplication.h> 38#include <qtopia/qpeapplication.h>
33#undef private 39#undef private
40
41/* STD */
34#include <stdio.h> 42#include <stdio.h>
35#include <stdlib.h> 43#include <stdlib.h>
36#include <sys/types.h> 44#include <sys/types.h>
37#include <sys/stat.h> 45#include <sys/stat.h>
38#include <unistd.h> 46#include <unistd.h>
39 47
40#include "dropins.h"
41 48
42using QuickPrivate::PluginLoader; 49using QuickPrivate::PluginLoader;
43 50
44static QPEApplication *app = 0; 51static QPEApplication *app = 0;
45static PluginLoader *loader = 0; 52static PluginLoader *loader = 0;
46static ApplicationInterface *appIface = 0; 53static ApplicationInterface *appIface = 0;
@@ -58,22 +65,22 @@ using namespace Opie::Ui;
58void setproctitle (const char *fmt,...) { 65void setproctitle (const char *fmt,...) {
59 int i; 66 int i;
60 char buf[SPT_BUFSIZE]; 67 char buf[SPT_BUFSIZE];
61 va_list ap; 68 va_list ap;
62 69
63 if (!argv0) 70 if (!argv0)
64 return; 71 return;
65 72
66 va_start(ap, fmt); 73 va_start(ap, fmt);
67 (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); 74 (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap);
68 va_end(ap); 75 va_end(ap);
69 76
70 i = strlen (buf); 77 i = strlen (buf);
71 if (i > argv_lth - 2) { 78 if (i > argv_lth - 2) {
72 i = argv_lth - 2; 79 i = argv_lth - 2;
73 buf[i] = '\0'; 80 buf[i] = '\0';
74 } 81 }
75 memset(argv0[0], '\0', argv_lth); /* clear the memory area */ 82 memset(argv0[0], '\0', argv_lth); /* clear the memory area */
76 (void) strcpy (argv0[0], buf); 83 (void) strcpy (argv0[0], buf);
77 84
78 argv0[1] = NULL; 85 argv0[1] = NULL;
79} 86}
@@ -83,87 +90,87 @@ void setproctitle (const char *fmt,...) {
83class QuickLauncher : public QObject 90class QuickLauncher : public QObject
84{ 91{
85 Q_OBJECT 92 Q_OBJECT
86public: 93public:
87 QuickLauncher() : QObject() 94 QuickLauncher() : QObject()
88 { 95 {
89 QCString ch("QPE/QuickLauncher-"); 96 QCString ch("QPE/QuickLauncher-");
90 ch += QString::number(getpid()); 97 ch += QString::number(getpid());
91 qlChannel = new QCopChannel( ch, this); 98 qlChannel = new QCopChannel( ch, this);
92 connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)), 99 connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)),
93 this, SLOT(message(const QCString&,const QByteArray&)) ); 100 this, SLOT(message(const QCString&,const QByteArray&)) );
94 } 101 }
95 102
96 static void exec( int /*argc*/, char **argv ) 103 static void exec( int /*argc*/, char **argv )
97 { 104 {
98 QString appName = argv[0]; 105 QString appName = argv[0];
99 int sep = appName.findRev( '/' ); 106 int sep = appName.findRev( '/' );
100 if ( sep > 0 ) 107 if ( sep > 0 )
101 appName = appName.mid( sep+1 ); 108 appName = appName.mid( sep+1 );
102 109
103 appIface = 0; 110 appIface = 0;
104 if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { 111 if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) {
105 mainWindow = appIface->createMainWindow( appName ); 112 mainWindow = appIface->createMainWindow( appName );
106 } 113 }
107 if ( mainWindow ) { 114 if ( mainWindow ) {
108 if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { 115 if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) {
109 app->showMainDocumentWidget( mainWindow ); 116 app->showMainDocumentWidget( mainWindow );
110 } else { 117 } else {
111 app->showMainWidget( mainWindow ); 118 app->showMainWidget( mainWindow );
112 } 119 }
113 } else { 120 } else {
114 qWarning( "Could not create application main window" ); 121 owarn << "Could not create application main window" << oendl;
115 exit(-1); 122 exit(-1);
116 } 123 }
117 } 124 }
118 125
119private slots: 126private slots:
120 void message(const QCString &msg, const QByteArray & data) 127 void message(const QCString &msg, const QByteArray & data)
121 { 128 {
122 QStrList argList; 129 QStrList argList;
123 130
124 if ( msg == "execute(QStrList)" ) { 131 if ( msg == "execute(QStrList)" ) {
125 delete qlChannel; 132 delete qlChannel;
126 QDataStream stream( data, IO_ReadOnly ); 133 QDataStream stream( data, IO_ReadOnly );
127 QStrList argList; 134 QStrList argList;
128 stream >> argList; 135 stream >> argList;
129 qDebug( "QuickLauncher execute: %s", argList.at(0) ); 136 odebug << "QuickLauncher execute: " << argList.at(0) << "" << oendl;
130 doQuickLaunch( argList ); 137 doQuickLaunch( argList );
131 delete this; 138 delete this;
132 } else if ( msg == "execute(QString)" ) { 139 } else if ( msg == "execute(QString)" ) {
133 delete qlChannel; 140 delete qlChannel;
134 QDataStream stream( data, IO_ReadOnly ); 141 QDataStream stream( data, IO_ReadOnly );
135 QString arg; 142 QString arg;
136 stream >> arg; 143 stream >> arg;
137 qDebug( "QuickLauncher execute: %s", arg.latin1() ); 144 odebug << "QuickLauncher execute: " << arg << "" << oendl;
138 QStrList argList; 145 QStrList argList;
139 argList.append( arg.utf8() ); 146 argList.append( arg.utf8() );
140 doQuickLaunch( argList ); 147 doQuickLaunch( argList );
141 delete this; 148 delete this;
142 } 149 }
143 } 150 }
144 151
145private: 152private:
146 void doQuickLaunch( QStrList &argList ) 153 void doQuickLaunch( QStrList &argList )
147 { 154 {
148 static int myargc = argList.count(); 155 static int myargc = argList.count();
149 static char **myargv = new char *[myargc + 1]; 156 static char **myargv = new char *[myargc + 1];
150 for ( int j = 0; j < myargc; j++ ) { 157 for ( int j = 0; j < myargc; j++ ) {
151 myargv[j] = new char [strlen(argList.at(j))+1]; 158 myargv[j] = new char [strlen(argList.at(j))+1];
152 strcpy( myargv[j], argList.at(j) ); 159 strcpy( myargv[j], argList.at(j) );
153 } 160 }
154 myargv[myargc] = NULL; 161 myargv[myargc] = NULL;
155#ifdef _OS_LINUX_ 162#ifdef _OS_LINUX_
156 // Change name of process 163 // Change name of process
157 setproctitle(myargv[0]); 164 setproctitle(myargv[0]);
158#endif 165#endif
159 166
160 connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); 167 connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit()));
161 app->exit_loop(); 168 app->exit_loop();
162 app->initApp( myargc, myargv ); 169 app->initApp( myargc, myargv );
163 exec( myargc, myargv ); 170 exec( myargc, myargv );
164 } 171 }
165 172
166private: 173private:
167 QCopChannel *qlChannel; 174 QCopChannel *qlChannel;
168}; 175};
169 176
@@ -175,82 +182,82 @@ int main( int argc, char** argv )
175 182
176 unsetenv( "LD_BIND_NOW" ); 183 unsetenv( "LD_BIND_NOW" );
177 184
178 QCString arg0 = argv[0]; 185 QCString arg0 = argv[0];
179 int sep = arg0.findRev( '/' ); 186 int sep = arg0.findRev( '/' );
180 if ( sep > 0 ) 187 if ( sep > 0 )
181 arg0 = arg0.mid( sep+1 ); 188 arg0 = arg0.mid( sep+1 );
182 if ( arg0 != "quicklauncher" ) { 189 if ( arg0 != "quicklauncher" ) {
183 qDebug( "QuickLauncher invoked as: %s", arg0.data() ); 190 odebug << "QuickLauncher invoked as: " << arg0.data() << "" << oendl;
184 QuickLauncher::exec( argc, argv ); 191 QuickLauncher::exec( argc, argv );
185 } else { 192 } else {
186#ifdef _OS_LINUX_ 193#ifdef _OS_LINUX_
187 // Setup to change proc title 194 // Setup to change proc title
188 int i; 195 int i;
189 char **envp = environ; 196 char **envp = environ;
190 /* Move the environment so we can reuse the memory. 197 /* Move the environment so we can reuse the memory.
191 * (Code borrowed from sendmail.) */ 198 * (Code borrowed from sendmail.) */
192 for (i = 0; envp[i] != NULL; i++) 199 for (i = 0; envp[i] != NULL; i++)
193 continue; 200 continue;
194 environ = (char **) malloc(sizeof(char *) * (i + 1)); 201 environ = (char **) malloc(sizeof(char *) * (i + 1));
195 if (environ == NULL) 202 if (environ == NULL)
196 return -1; 203 return -1;
197 for (i = 0; envp[i] != NULL; i++) 204 for (i = 0; envp[i] != NULL; i++)
198 if ((environ[i] = strdup(envp[i])) == NULL) 205 if ((environ[i] = strdup(envp[i])) == NULL)
199 return -1; 206 return -1;
200 environ[i] = NULL; 207 environ[i] = NULL;
201 208
202 argv0 = argv; 209 argv0 = argv;
203 if (i > 0) 210 if (i > 0)
204 argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; 211 argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0];
205 else 212 else
206 argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; 213 argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0];
207#endif 214#endif
208 (void)new QuickLauncher(); 215 (void)new QuickLauncher();
209 qDebug( "QuickLauncher running" ); 216 odebug << "QuickLauncher running" << oendl;
210 // Pre-load default fonts 217 // Pre-load default fonts
211 QFontMetrics fm( QApplication::font() ); 218 QFontMetrics fm( QApplication::font() );
212 fm.ascent(); // causes font load. 219 fm.ascent(); // causes font load.
213 QFont f( QApplication::font() ); 220 QFont f( QApplication::font() );
214 f.setWeight( QFont::Bold ); 221 f.setWeight( QFont::Bold );
215 QFontMetrics fmb( f ); 222 QFontMetrics fmb( f );
216 fmb.ascent(); // causes font load. 223 fmb.ascent(); // causes font load.
217 224
218 // Each of the following force internal structures/internal 225 // Each of the following force internal structures/internal
219 // initialization to be performed. This may mean allocating 226 // initialization to be performed. This may mean allocating
220 // memory that is not needed by all applications. 227 // memory that is not needed by all applications.
221#if 0 228#if 0
222 TimeZone::current().isValid(); // popuplate timezone cache 229 TimeZone::current().isValid(); // popuplate timezone cache
223 TimeString::currentDateFormat(); // create internal structures 230 TimeString::currentDateFormat(); // create internal structures
224 TimeString::currentAMPM(); 231 TimeString::currentAMPM();
225#endif 232#endif
226 Resource::loadIconSet("new"); // do internal init 233 Resource::loadIconSet("new"); // do internal init
227 234
228 /* make sure libopie gets lined in */ 235 /* make sure libopie gets lined in */
229 { 236 {
230 Opie::Ui::OWait item; 237 Opie::Ui::OWait item;
231 } 238 }
232 239
233 // Create a widget to force initialization of title bar images, etc. 240 // Create a widget to force initialization of title bar images, etc.
234 QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); 241 QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit()));
235 QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); 242 QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool);
236 w->setGeometry( -100, -100, 10, 10 ); 243 w->setGeometry( -100, -100, 10, 10 );
237 w->show(); 244 w->show();
238 QTimer::singleShot( 0, w, SLOT(close()) ); 245 QTimer::singleShot( 0, w, SLOT(close()) );
239 246
240 app->enter_loop(); 247 app->enter_loop();
241 } 248 }
242 249
243 int rv = app->exec(); 250 int rv = app->exec();
244 251
245 if ( mainWindow ) 252 if ( mainWindow )
246 delete (QWidget*)mainWindow; 253 delete (QWidget*)mainWindow;
247 254
248 delete app; 255 delete app;
249 if ( appIface ) 256 if ( appIface )
250 loader->releaseInterface( appIface ); 257 loader->releaseInterface( appIface );
251 delete loader; 258 delete loader;
252 // Neither QLibrary nor my Dropin is a QObject and they don't depend 259 // Neither QLibrary nor my Dropin is a QObject and they don't depend
253 // on a qApp so we destroy QWidget::destroyMapper() without 260 // on a qApp so we destroy QWidget::destroyMapper() without
254 // crashing the app 261 // crashing the app
255 // 262 //
256 // The problem is there are some 'static' resources not freed 263 // The problem is there are some 'static' resources not freed