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,155 +1,161 @@
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 )
137{ 143{
138 if ( !m_current ) 144 if ( !m_current )
139 return; 145 return;
140 146
141 QComboBox *which = (QComboBox *) sender ( ); 147 QComboBox *which = (QComboBox *) sender ( );
142 148
143 if ( which == w_channel ) 149 if ( which == w_channel )
144 m_current-> setText ( 1, str ); 150 m_current-> setText ( 1, str );
145 else if ( which == w_message ) 151 else if ( which == w_message )
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
@@ -1,279 +1,283 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
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// 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 )
56 strRealTz = pEnv; 60 strRealTz = pEnv;
57 pEnv = NULL; 61 pEnv = NULL;
58 pEnv = getenv("HOME"); 62 pEnv = getenv("HOME");
59 if ( pEnv ) 63 if ( pEnv )
60 strHome = pEnv; 64 strHome = pEnv;
61 // append the labels to their respective lists... 65 // append the labels to their respective lists...
62 listCities.setAutoDelete( true ); 66 listCities.setAutoDelete( true );
63 listTimes.setAutoDelete( true ); 67 listTimes.setAutoDelete( true );
64 68
65 listCities.append( cmdCity1 ); 69 listCities.append( cmdCity1 );
66 listCities.append( cmdCity2 ); 70 listCities.append( cmdCity2 );
67 listCities.append( cmdCity3 ); 71 listCities.append( cmdCity3 );
68 72
69 listTimes.append( lblCTime1 ); 73 listTimes.append( lblCTime1 );
70 listTimes.append( lblCTime2 ); 74 listTimes.append( lblCTime2 );
71 listTimes.append( lblCTime3 ); 75 listTimes.append( lblCTime3 );
72 76
73 77
74 // kludgy way of getting the screen size so we don't have to depend 78 // kludgy way of getting the screen size so we don't have to depend
75 // on a resize event... 79 // on a resize event...
76 QWidget *d = QApplication::desktop(); 80 QWidget *d = QApplication::desktop();
77 if ( d->width() < d->height() ) { 81 if ( d->width() < d->height() ) {
78 // append for that 4 down look 82 // append for that 4 down look
79 listCities.append( cmdCity4 ); 83 listCities.append( cmdCity4 );
80 listCities.append( cmdCity5 ); 84 listCities.append( cmdCity5 );
81 listCities.append( cmdCity6 ); 85 listCities.append( cmdCity6 );
82 listTimes.append( lblCTime4 ); 86 listTimes.append( lblCTime4 );
83 listTimes.append( lblCTime5 ); 87 listTimes.append( lblCTime5 );
84 listTimes.append( lblCTime6 ); 88 listTimes.append( lblCTime6 );
85 lblCTime7->hide(); 89 lblCTime7->hide();
86 lblCTime8->hide(); 90 lblCTime8->hide();
87 lblCTime9->hide(); 91 lblCTime9->hide();
88 cmdCity7->hide(); 92 cmdCity7->hide();
89 cmdCity8->hide(); 93 cmdCity8->hide();
90 cmdCity9->hide(); 94 cmdCity9->hide();
91 } else { 95 } else {
92 listCities.append( cmdCity7 ); 96 listCities.append( cmdCity7 );
93 listCities.append( cmdCity8 ); 97 listCities.append( cmdCity8 );
94 listCities.append( cmdCity9 ); 98 listCities.append( cmdCity9 );
95 listTimes.append( lblCTime7 ); 99 listTimes.append( lblCTime7 );
96 listTimes.append( lblCTime8 ); 100 listTimes.append( lblCTime8 );
97 listTimes.append( lblCTime9 ); 101 listTimes.append( lblCTime9 );
98 lblCTime4->hide(); 102 lblCTime4->hide();
99 lblCTime5->hide(); 103 lblCTime5->hide();
100 lblCTime6->hide(); 104 lblCTime6->hide();
101 cmdCity4->hide(); 105 cmdCity4->hide();
102 cmdCity5->hide(); 106 cmdCity5->hide();
103 cmdCity6->hide(); 107 cmdCity6->hide();
104 } 108 }
105 109
106 selWidget = frmMap->selectionWidget( this ); 110 selWidget = frmMap->selectionWidget( this );
107 selWidget->hide(); 111 selWidget->hide();
108 CityTimeBaseLayout->addWidget( selWidget ); 112 CityTimeBaseLayout->addWidget( selWidget );
109 bAdded = true; 113 bAdded = true;
110 readInTimes(); 114 readInTimes();
111 changed = FALSE; 115 changed = FALSE;
112 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), 116 QObject::connect( qApp, SIGNAL( clockChanged(bool) ),
113 this, SLOT( changeClock(bool) ) ); 117 this, SLOT( changeClock(bool) ) );
114 // now start the timer so we can update the time quickly every second 118 // now start the timer so we can update the time quickly every second
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
154 setenv( "TZ", strRealTz, true ); 158 setenv( "TZ", strRealTz, true );
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
168void CityTime::mousePressEvent( QMouseEvent * ) 172void CityTime::mousePressEvent( QMouseEvent * )
169{ 173{
170 // DEBUG enable this to get a look at the zone information DEBUG 174 // DEBUG enable this to get a look at the zone information DEBUG
171// frmMap->showZones(); 175// frmMap->showZones();
172} 176}
173 177
174void CityTime::showTime( void ) 178void CityTime::showTime( void )
175{ 179{
176 int i; 180 int i;
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 }
190 } 194 }
191 // done playing around... put it all back 195 // done playing around... put it all back
192 unsetenv( "TZ" ); 196 unsetenv( "TZ" );
193 if ( !strRealTz.isNull() ) { 197 if ( !strRealTz.isNull() ) {
194 if ( setenv( "TZ", strRealTz, true ) != 0 ) { 198 if ( setenv( "TZ", strRealTz, true ) != 0 ) {
195 QMessageBox::critical( this, tr( "Restore Time Zone" ), 199 QMessageBox::critical( this, tr( "Restore Time Zone" ),
196 tr( "There was a problem setting your timezone." 200 tr( "There was a problem setting your timezone."
197 "Your time may be wrong now..." ) ); 201 "Your time may be wrong now..." ) );
198 } 202 }
199 } 203 }
200} 204}
201 205
202void CityTime::beginNewTz() 206void CityTime::beginNewTz()
203{ 207{
204 buttonWidget->hide(); 208 buttonWidget->hide();
205 frmMap->setFocus(); 209 frmMap->setFocus();
206 selWidget->show(); 210 selWidget->show();
207 // CityTimeBaseLayout->addWidget( selWidget ); 211 // CityTimeBaseLayout->addWidget( selWidget );
208} 212}
209 213
210void CityTime::slotNewTz( const QString & strNewCountry, 214void CityTime::slotNewTz( const QString & strNewCountry,
211 const QString & strNewCity ) 215 const QString & strNewCity )
212{ 216{
213 // determine what to do based on what putton is pressed... 217 // determine what to do based on what putton is pressed...
214 QListIterator<QToolButton> itCity(listCities); 218 QListIterator<QToolButton> itCity(listCities);
215 int i; 219 int i;
216 // go through the list and make adjustments based on which button is on 220 // go through the list and make adjustments based on which button is on
217 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) { 221 for ( i = 0, itCity.toFirst(); itCity.current(), i < CITIES; i++, ++itCity ) {
218 QToolButton *cmdTmp = itCity.current(); 222 QToolButton *cmdTmp = itCity.current();
219 if ( cmdTmp->isOn() ) { 223 if ( cmdTmp->isOn() ) {
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();
233} 237}
234 238
235void CityTime::readInTimes( void ) 239void CityTime::readInTimes( void )
236{ 240{
237 Config cfg("CityTime"); 241 Config cfg("CityTime");
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();
259 for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current(); 263 for ( i = 0, itCity.toFirst(); i < CITIES && itCity.current();
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;
278 showTime(); 282 showTime();
279} 283}
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,411 +1,415 @@
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" );
29 frmMap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, frmMap->sizePolicy().hasHeightForWidth() ) ); 33 frmMap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, frmMap->sizePolicy().hasHeightForWidth() ) );
30 CityTimeBaseLayout->addWidget( frmMap ); 34 CityTimeBaseLayout->addWidget( frmMap );
31 35
32 buttonWidget = new QWidget( this ); 36 buttonWidget = new QWidget( this );
33 QWhatsThis::add( buttonWidget, tr( "Click on one of the set cities to replace it" ) ); 37 QWhatsThis::add( buttonWidget, tr( "Click on one of the set cities to replace it" ) );
34 Layout2 = new QGridLayout( buttonWidget ); 38 Layout2 = new QGridLayout( buttonWidget );
35 Layout2->setSpacing( 3 ); 39 Layout2->setSpacing( 3 );
36 Layout2->setMargin( 4 ); 40 Layout2->setMargin( 4 );
37 41
38 cmdCity7 = new QToolButton( buttonWidget, "cmdCity7" ); 42 cmdCity7 = new QToolButton( buttonWidget, "cmdCity7" );
39 cmdCity7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity7->sizePolicy().hasHeightForWidth() ) ); 43 cmdCity7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity7->sizePolicy().hasHeightForWidth() ) );
40 QFont cmdCity7_font( cmdCity7->font() ); 44 QFont cmdCity7_font( cmdCity7->font() );
41 cmdCity7_font.setBold( TRUE ); 45 cmdCity7_font.setBold( TRUE );
42 cmdCity7->setFont( cmdCity7_font ); 46 cmdCity7->setFont( cmdCity7_font );
43 cmdCity7->setFocusPolicy( QToolButton::TabFocus ); 47 cmdCity7->setFocusPolicy( QToolButton::TabFocus );
44 cmdCity7->setText( tr( "" ) ); 48 cmdCity7->setText( tr( "" ) );
45 cmdCity7->setToggleButton( TRUE ); 49 cmdCity7->setToggleButton( TRUE );
46 cmdCity7->setToggleButton( TRUE ); 50 cmdCity7->setToggleButton( TRUE );
47 51
48 Layout2->addWidget( cmdCity7, 0, 2 ); 52 Layout2->addWidget( cmdCity7, 0, 2 );
49 53
50 lblCTime9 = new QLabel( buttonWidget, "lblCTime9" ); 54 lblCTime9 = new QLabel( buttonWidget, "lblCTime9" );
51 lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) ); 55 lblCTime9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime9->sizePolicy().hasHeightForWidth() ) );
52 QFont lblCTime9_font( lblCTime9->font() ); 56 QFont lblCTime9_font( lblCTime9->font() );
53 lblCTime9_font.setPointSize( 10 ); 57 lblCTime9_font.setPointSize( 10 );
54 lblCTime9->setFont( lblCTime9_font ); 58 lblCTime9->setFont( lblCTime9_font );
55 lblCTime9->setText( tr( "" ) ); 59 lblCTime9->setText( tr( "" ) );
56 lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 60 lblCTime9->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
57 61
58 Layout2->addWidget( lblCTime9, 2, 3 ); 62 Layout2->addWidget( lblCTime9, 2, 3 );
59 63
60 cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" ); 64 cmdCity8 = new QToolButton( buttonWidget, "cmdCity8" );
61 cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) ); 65 cmdCity8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity8->sizePolicy().hasHeightForWidth() ) );
62 QFont cmdCity8_font( cmdCity8->font() ); 66 QFont cmdCity8_font( cmdCity8->font() );
63 cmdCity8_font.setBold( TRUE ); 67 cmdCity8_font.setBold( TRUE );
64 cmdCity8->setFont( cmdCity8_font ); 68 cmdCity8->setFont( cmdCity8_font );
65 cmdCity8->setFocusPolicy( QToolButton::TabFocus ); 69 cmdCity8->setFocusPolicy( QToolButton::TabFocus );
66 cmdCity8->setText( tr( "" ) ); 70 cmdCity8->setText( tr( "" ) );
67 cmdCity8->setToggleButton( TRUE ); 71 cmdCity8->setToggleButton( TRUE );
68 cmdCity8->setToggleButton( TRUE ); 72 cmdCity8->setToggleButton( TRUE );
69 73
70 Layout2->addWidget( cmdCity8, 1, 2 ); 74 Layout2->addWidget( cmdCity8, 1, 2 );
71 75
72 cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" ); 76 cmdCity2 = new QToolButton( buttonWidget, "cmdCity2" );
73 QFont cmdCity2_font( cmdCity2->font() ); 77 QFont cmdCity2_font( cmdCity2->font() );
74 cmdCity2_font.setBold( TRUE ); 78 cmdCity2_font.setBold( TRUE );
75 cmdCity2->setFont( cmdCity2_font ); 79 cmdCity2->setFont( cmdCity2_font );
76 cmdCity2->setFocusPolicy( QToolButton::TabFocus ); 80 cmdCity2->setFocusPolicy( QToolButton::TabFocus );
77 cmdCity2->setText( tr( "" ) ); 81 cmdCity2->setText( tr( "" ) );
78 cmdCity2->setToggleButton( TRUE ); 82 cmdCity2->setToggleButton( TRUE );
79 cmdCity2->setToggleButton( TRUE ); 83 cmdCity2->setToggleButton( TRUE );
80 84
81 Layout2->addWidget( cmdCity2, 1, 0 ); 85 Layout2->addWidget( cmdCity2, 1, 0 );
82 86
83 lblCTime6 = new QLabel( buttonWidget, "lblCTime6" ); 87 lblCTime6 = new QLabel( buttonWidget, "lblCTime6" );
84 QFont lblCTime6_font( lblCTime6->font() ); 88 QFont lblCTime6_font( lblCTime6->font() );
85 lblCTime6_font.setPointSize( 10 ); 89 lblCTime6_font.setPointSize( 10 );
86 lblCTime6->setFont( lblCTime6_font ); 90 lblCTime6->setFont( lblCTime6_font );
87 lblCTime6->setText( tr( "" ) ); 91 lblCTime6->setText( tr( "" ) );
88 lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 92 lblCTime6->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
89 93
90 Layout2->addWidget( lblCTime6, 5, 1 ); 94 Layout2->addWidget( lblCTime6, 5, 1 );
91 95
92 cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" ); 96 cmdCity6 = new QToolButton( buttonWidget, "cmdCity6" );
93 cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) ); 97 cmdCity6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity6->sizePolicy().hasHeightForWidth() ) );
94 QFont cmdCity6_font( cmdCity6->font() ); 98 QFont cmdCity6_font( cmdCity6->font() );
95 cmdCity6_font.setBold( TRUE ); 99 cmdCity6_font.setBold( TRUE );
96 cmdCity6->setFont( cmdCity6_font ); 100 cmdCity6->setFont( cmdCity6_font );
97 cmdCity6->setFocusPolicy( QToolButton::TabFocus ); 101 cmdCity6->setFocusPolicy( QToolButton::TabFocus );
98 cmdCity6->setText( tr( "" ) ); 102 cmdCity6->setText( tr( "" ) );
99 cmdCity6->setToggleButton( TRUE ); 103 cmdCity6->setToggleButton( TRUE );
100 cmdCity6->setToggleButton( TRUE ); 104 cmdCity6->setToggleButton( TRUE );
101 105
102 Layout2->addWidget( cmdCity6, 5, 0 ); 106 Layout2->addWidget( cmdCity6, 5, 0 );
103 107
104 cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" ); 108 cmdCity4 = new QToolButton( buttonWidget, "cmdCity4" );
105 cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) ); 109 cmdCity4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity4->sizePolicy().hasHeightForWidth() ) );
106 QFont cmdCity4_font( cmdCity4->font() ); 110 QFont cmdCity4_font( cmdCity4->font() );
107 cmdCity4_font.setBold( TRUE ); 111 cmdCity4_font.setBold( TRUE );
108 cmdCity4->setFont( cmdCity4_font ); 112 cmdCity4->setFont( cmdCity4_font );
109 cmdCity4->setFocusPolicy( QToolButton::TabFocus ); 113 cmdCity4->setFocusPolicy( QToolButton::TabFocus );
110 cmdCity4->setText( tr( "" ) ); 114 cmdCity4->setText( tr( "" ) );
111 cmdCity4->setToggleButton( TRUE ); 115 cmdCity4->setToggleButton( TRUE );
112 cmdCity4->setToggleButton( TRUE ); 116 cmdCity4->setToggleButton( TRUE );
113 117
114 Layout2->addWidget( cmdCity4, 3, 0 ); 118 Layout2->addWidget( cmdCity4, 3, 0 );
115 119
116 lblCTime5 = new QLabel( buttonWidget, "lblCTime5" ); 120 lblCTime5 = new QLabel( buttonWidget, "lblCTime5" );
117 QFont lblCTime5_font( lblCTime5->font() ); 121 QFont lblCTime5_font( lblCTime5->font() );
118 lblCTime5_font.setPointSize( 10 ); 122 lblCTime5_font.setPointSize( 10 );
119 lblCTime5->setFont( lblCTime5_font ); 123 lblCTime5->setFont( lblCTime5_font );
120 lblCTime5->setText( tr( "" ) ); 124 lblCTime5->setText( tr( "" ) );
121 lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 125 lblCTime5->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
122 126
123 Layout2->addWidget( lblCTime5, 4, 1 ); 127 Layout2->addWidget( lblCTime5, 4, 1 );
124 128
125 lblCTime2 = new QLabel( buttonWidget, "lblCTime2" ); 129 lblCTime2 = new QLabel( buttonWidget, "lblCTime2" );
126 lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) ); 130 lblCTime2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime2->sizePolicy().hasHeightForWidth() ) );
127 QFont lblCTime2_font( lblCTime2->font() ); 131 QFont lblCTime2_font( lblCTime2->font() );
128 lblCTime2_font.setPointSize( 10 ); 132 lblCTime2_font.setPointSize( 10 );
129 lblCTime2->setFont( lblCTime2_font ); 133 lblCTime2->setFont( lblCTime2_font );
130 lblCTime2->setText( tr( "" ) ); 134 lblCTime2->setText( tr( "" ) );
131 lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 135 lblCTime2->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
132 136
133 Layout2->addWidget( lblCTime2, 1, 1 ); 137 Layout2->addWidget( lblCTime2, 1, 1 );
134 138
135 lblCTime1 = new QLabel( buttonWidget, "lblCTime1" ); 139 lblCTime1 = new QLabel( buttonWidget, "lblCTime1" );
136 lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) ); 140 lblCTime1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, lblCTime1->sizePolicy().hasHeightForWidth() ) );
137 QFont lblCTime1_font( lblCTime1->font() ); 141 QFont lblCTime1_font( lblCTime1->font() );
138 lblCTime1_font.setPointSize( 10 ); 142 lblCTime1_font.setPointSize( 10 );
139 lblCTime1->setFont( lblCTime1_font ); 143 lblCTime1->setFont( lblCTime1_font );
140 lblCTime1->setText( tr( "" ) ); 144 lblCTime1->setText( tr( "" ) );
141 lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 145 lblCTime1->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
142 146
143 Layout2->addWidget( lblCTime1, 0, 1 ); 147 Layout2->addWidget( lblCTime1, 0, 1 );
144 148
145 cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" ); 149 cmdCity3 = new QToolButton( buttonWidget, "cmdCity3" );
146 cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) ); 150 cmdCity3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity3->sizePolicy().hasHeightForWidth() ) );
147 QFont cmdCity3_font( cmdCity3->font() ); 151 QFont cmdCity3_font( cmdCity3->font() );
148 cmdCity3_font.setBold( TRUE ); 152 cmdCity3_font.setBold( TRUE );
149 cmdCity3->setFont( cmdCity3_font ); 153 cmdCity3->setFont( cmdCity3_font );
150 cmdCity3->setFocusPolicy( QToolButton::TabFocus ); 154 cmdCity3->setFocusPolicy( QToolButton::TabFocus );
151 cmdCity3->setText( tr( "" ) ); 155 cmdCity3->setText( tr( "" ) );
152 cmdCity3->setToggleButton( TRUE ); 156 cmdCity3->setToggleButton( TRUE );
153 cmdCity3->setToggleButton( TRUE ); 157 cmdCity3->setToggleButton( TRUE );
154 158
155 Layout2->addWidget( cmdCity3, 2, 0 ); 159 Layout2->addWidget( cmdCity3, 2, 0 );
156 160
157 lblCTime8 = new QLabel( buttonWidget, "lblCTime8" ); 161 lblCTime8 = new QLabel( buttonWidget, "lblCTime8" );
158 lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) ); 162 lblCTime8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime8->sizePolicy().hasHeightForWidth() ) );
159 QFont lblCTime8_font( lblCTime8->font() ); 163 QFont lblCTime8_font( lblCTime8->font() );
160 lblCTime8_font.setPointSize( 10 ); 164 lblCTime8_font.setPointSize( 10 );
161 lblCTime8->setFont( lblCTime8_font ); 165 lblCTime8->setFont( lblCTime8_font );
162 lblCTime8->setText( tr( "" ) ); 166 lblCTime8->setText( tr( "" ) );
163 lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 167 lblCTime8->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
164 168
165 Layout2->addWidget( lblCTime8, 1, 3 ); 169 Layout2->addWidget( lblCTime8, 1, 3 );
166 170
167 cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" ); 171 cmdCity1 = new QToolButton( buttonWidget, "cmdCity1" );
168 cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) ); 172 cmdCity1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity1->sizePolicy().hasHeightForWidth() ) );
169 QFont cmdCity1_font( cmdCity1->font() ); 173 QFont cmdCity1_font( cmdCity1->font() );
170 cmdCity1_font.setBold( TRUE ); 174 cmdCity1_font.setBold( TRUE );
171 cmdCity1->setFont( cmdCity1_font ); 175 cmdCity1->setFont( cmdCity1_font );
172 cmdCity1->setFocusPolicy( QToolButton::TabFocus ); 176 cmdCity1->setFocusPolicy( QToolButton::TabFocus );
173 cmdCity1->setText( tr( "" ) ); 177 cmdCity1->setText( tr( "" ) );
174 cmdCity1->setToggleButton( TRUE ); 178 cmdCity1->setToggleButton( TRUE );
175 cmdCity1->setToggleButton( TRUE ); 179 cmdCity1->setToggleButton( TRUE );
176 180
177 Layout2->addWidget( cmdCity1, 0, 0 ); 181 Layout2->addWidget( cmdCity1, 0, 0 );
178 182
179 lblCTime7 = new QLabel( buttonWidget, "lblCTime7" ); 183 lblCTime7 = new QLabel( buttonWidget, "lblCTime7" );
180 lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) ); 184 lblCTime7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, lblCTime7->sizePolicy().hasHeightForWidth() ) );
181 QFont lblCTime7_font( lblCTime7->font() ); 185 QFont lblCTime7_font( lblCTime7->font() );
182 lblCTime7_font.setPointSize( 10 ); 186 lblCTime7_font.setPointSize( 10 );
183 lblCTime7->setFont( lblCTime7_font ); 187 lblCTime7->setFont( lblCTime7_font );
184 lblCTime7->setText( tr( "" ) ); 188 lblCTime7->setText( tr( "" ) );
185 lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 189 lblCTime7->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
186 190
187 Layout2->addWidget( lblCTime7, 0, 3 ); 191 Layout2->addWidget( lblCTime7, 0, 3 );
188 192
189 lblCTime4 = new QLabel( buttonWidget, "lblCTime4" ); 193 lblCTime4 = new QLabel( buttonWidget, "lblCTime4" );
190 QFont lblCTime4_font( lblCTime4->font() ); 194 QFont lblCTime4_font( lblCTime4->font() );
191 lblCTime4_font.setPointSize( 10 ); 195 lblCTime4_font.setPointSize( 10 );
192 lblCTime4->setFont( lblCTime4_font ); 196 lblCTime4->setFont( lblCTime4_font );
193 lblCTime4->setText( tr( "" ) ); 197 lblCTime4->setText( tr( "" ) );
194 lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 198 lblCTime4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
195 199
196 Layout2->addWidget( lblCTime4, 3, 1 ); 200 Layout2->addWidget( lblCTime4, 3, 1 );
197 201
198 cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" ); 202 cmdCity5 = new QToolButton( buttonWidget, "cmdCity5" );
199 cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) ); 203 cmdCity5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity5->sizePolicy().hasHeightForWidth() ) );
200 QFont cmdCity5_font( cmdCity5->font() ); 204 QFont cmdCity5_font( cmdCity5->font() );
201 cmdCity5_font.setBold( TRUE ); 205 cmdCity5_font.setBold( TRUE );
202 cmdCity5->setFont( cmdCity5_font ); 206 cmdCity5->setFont( cmdCity5_font );
203 cmdCity5->setFocusPolicy( QToolButton::TabFocus ); 207 cmdCity5->setFocusPolicy( QToolButton::TabFocus );
204 cmdCity5->setText( tr( "" ) ); 208 cmdCity5->setText( tr( "" ) );
205 cmdCity5->setToggleButton( TRUE ); 209 cmdCity5->setToggleButton( TRUE );
206 cmdCity5->setToggleButton( TRUE ); 210 cmdCity5->setToggleButton( TRUE );
207 211
208 Layout2->addWidget( cmdCity5, 4, 0 ); 212 Layout2->addWidget( cmdCity5, 4, 0 );
209 213
210 lblCTime3 = new QLabel( buttonWidget, "lblCTime3" ); 214 lblCTime3 = new QLabel( buttonWidget, "lblCTime3" );
211 QFont lblCTime3_font( lblCTime3->font() ); 215 QFont lblCTime3_font( lblCTime3->font() );
212 lblCTime3_font.setPointSize( 10 ); 216 lblCTime3_font.setPointSize( 10 );
213 lblCTime3->setFont( lblCTime3_font ); 217 lblCTime3->setFont( lblCTime3_font );
214 lblCTime3->setText( tr( "" ) ); 218 lblCTime3->setText( tr( "" ) );
215 lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); 219 lblCTime3->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
216 220
217 Layout2->addWidget( lblCTime3, 2, 1 ); 221 Layout2->addWidget( lblCTime3, 2, 1 );
218 222
219 cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" ); 223 cmdCity9 = new QToolButton( buttonWidget, "cmdCity9" );
220 cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) ); 224 cmdCity9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)1, cmdCity9->sizePolicy().hasHeightForWidth() ) );
221 QFont cmdCity9_font( cmdCity9->font() ); 225 QFont cmdCity9_font( cmdCity9->font() );
222 cmdCity9_font.setBold( TRUE ); 226 cmdCity9_font.setBold( TRUE );
223 cmdCity9->setFont( cmdCity9_font ); 227 cmdCity9->setFont( cmdCity9_font );
224 cmdCity9->setFocusPolicy( QToolButton::TabFocus ); 228 cmdCity9->setFocusPolicy( QToolButton::TabFocus );
225 cmdCity9->setText( tr( "" ) ); 229 cmdCity9->setText( tr( "" ) );
226 cmdCity9->setToggleButton( TRUE ); 230 cmdCity9->setToggleButton( TRUE );
227 cmdCity9->setToggleButton( TRUE ); 231 cmdCity9->setToggleButton( TRUE );
228 232
229 Layout2->addWidget( cmdCity9, 2, 2 ); 233 Layout2->addWidget( cmdCity9, 2, 2 );
230 CityTimeBaseLayout->addWidget( buttonWidget ); 234 CityTimeBaseLayout->addWidget( buttonWidget );
231 235
232 // signals and slots connections 236 // signals and slots connections
233 connect( frmMap, SIGNAL( signalTz(const QString&,const QString&) ), this, SLOT( slotNewTz(const QString&,const QString&) ) ); 237 connect( frmMap, SIGNAL( signalTz(const QString&,const QString&) ), this, SLOT( slotNewTz(const QString&,const QString&) ) );
234 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 238 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
235 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 239 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
236 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 240 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
237 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 241 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
238 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 242 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
239 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 243 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
240 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 244 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
241 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 245 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
242 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 246 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
243 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 247 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
244 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 248 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
245 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 249 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
246 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 250 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
247 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 251 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
248 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 252 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
249 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 253 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
250 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 254 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
251 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 255 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
252 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 256 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
253 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 257 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
254 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 258 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
255 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 259 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
256 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 260 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
257 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 261 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
258 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 262 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
259 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 263 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
260 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 264 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
261 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 265 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
262 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 266 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
263 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 267 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
264 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 268 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
265 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 269 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
266 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 270 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
267 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 271 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
268 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 272 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
269 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 273 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
270 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 274 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
271 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 275 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
272 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 276 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
273 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 277 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
274 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 278 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
275 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 279 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
276 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 280 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
277 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 281 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
278 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 282 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
279 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 283 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
280 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 284 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
281 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 285 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
282 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 286 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
283 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 287 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
284 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 288 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
285 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 289 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
286 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 290 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
287 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 291 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
288 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 292 connect( cmdCity6, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
289 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 293 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
290 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 294 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
291 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) ); 295 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity1, SLOT( setDisabled(bool) ) );
292 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) ); 296 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity3, SLOT( setDisabled(bool) ) );
293 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) ); 297 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity4, SLOT( setDisabled(bool) ) );
294 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) ); 298 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity5, SLOT( setDisabled(bool) ) );
295 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) ); 299 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity6, SLOT( setDisabled(bool) ) );
296 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) ); 300 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity7, SLOT( setDisabled(bool) ) );
297 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) ); 301 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity8, SLOT( setDisabled(bool) ) );
298 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 302 connect( cmdCity1, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
299 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 303 connect( cmdCity2, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
300 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 304 connect( cmdCity3, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
301 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 305 connect( cmdCity4, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
302 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 306 connect( cmdCity5, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
303 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 307 connect( cmdCity7, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
304 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) ); 308 connect( cmdCity8, SIGNAL( toggled(bool) ), cmdCity9, SLOT( setDisabled(bool) ) );
305 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) ); 309 connect( cmdCity9, SIGNAL( toggled(bool) ), cmdCity2, SLOT( setDisabled(bool) ) );
306 connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 310 connect( cmdCity1, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
307 connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 311 connect( cmdCity2, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
308 connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 312 connect( cmdCity7, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
309 connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 313 connect( cmdCity3, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
310 connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 314 connect( cmdCity4, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
311 connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 315 connect( cmdCity5, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
312 connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 316 connect( cmdCity6, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
313 connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 317 connect( cmdCity8, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
314 connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) ); 318 connect( cmdCity9, SIGNAL( toggled(bool) ), this, SLOT( beginNewTz() ) );
315 319
316 // tab order 320 // tab order
317 setTabOrder( cmdCity1, cmdCity2 ); 321 setTabOrder( cmdCity1, cmdCity2 );
318 setTabOrder( cmdCity2, cmdCity3 ); 322 setTabOrder( cmdCity2, cmdCity3 );
319 setTabOrder( cmdCity3, cmdCity4 ); 323 setTabOrder( cmdCity3, cmdCity4 );
320 setTabOrder( cmdCity4, cmdCity5 ); 324 setTabOrder( cmdCity4, cmdCity5 );
321 setTabOrder( cmdCity5, cmdCity6 ); 325 setTabOrder( cmdCity5, cmdCity6 );
322 setTabOrder( cmdCity6, cmdCity7 ); 326 setTabOrder( cmdCity6, cmdCity7 );
323 setTabOrder( cmdCity7, cmdCity8 ); 327 setTabOrder( cmdCity7, cmdCity8 );
324 setTabOrder( cmdCity8, cmdCity9 ); 328 setTabOrder( cmdCity8, cmdCity9 );
325 setTabOrder( cmdCity9, frmMap ); 329 setTabOrder( cmdCity9, frmMap );
326} 330}
327 331
328/* 332/*
329 * Destroys the object and frees any allocated resources 333 * Destroys the object and frees any allocated resources
330 */ 334 */
331CityTimeBase::~CityTimeBase() 335CityTimeBase::~CityTimeBase()
332{ 336{
333 // no need to delete child widgets, Qt does it all for us 337 // no need to delete child widgets, Qt does it all for us
334} 338}
335 339
336/* 340/*
337 * Main event handler. Reimplemented to handle application 341 * Main event handler. Reimplemented to handle application
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
@@ -1,724 +1,728 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
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// 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
46// the maximum distance we'll allow the pointer to be away from a city 50// the maximum distance we'll allow the pointer to be away from a city
47// and still show the city's time 51// and still show the city's time
48static const int iTHRESHOLD = 50000; 52static const int iTHRESHOLD = 50000;
49 53
50// The label offset (how far away from pointer) 54// The label offset (how far away from pointer)
51static const int iLABELOFFSET = 8; 55static const int iLABELOFFSET = 8;
52 56
53// the size of the dot to draw, and where to start it 57// the size of the dot to draw, and where to start it
54static const int iCITYSIZE = 3; 58static const int iCITYSIZE = 3;
55const int iCITYOFFSET = 2; 59const int iCITYOFFSET = 2;
56 60
57// the darkening function 61// the darkening function
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 ),
143 ox( 0 ), 147 ox( 0 ),
144 oy( 0 ), 148 oy( 0 ),
145 drawableW( -1 ), 149 drawableW( -1 ),
146 drawableH( -1 ), 150 drawableH( -1 ),
147 bZoom( FALSE ), 151 bZoom( FALSE ),
148 bIllum( TRUE ), 152 bIllum( TRUE ),
149 cursor( 0 ) 153 cursor( 0 )
150{ 154{
151 viewport()->setFocusPolicy( StrongFocus ); 155 viewport()->setFocusPolicy( StrongFocus );
152 156
153 // set mouse tracking so we can use the mouse move event 157 // set mouse tracking so we can use the mouse move event
154 zones.setAutoDelete( true ); 158 zones.setAutoDelete( true );
155 // get the map loaded 159 // get the map loaded
156 // just set the current image to point 160 // just set the current image to point
157 pixCurr = new QPixmap(); 161 pixCurr = new QPixmap();
158 162
159 QPixmap pixZoom = Resource::loadPixmap( "mag" ); 163 QPixmap pixZoom = Resource::loadPixmap( "mag" );
160 164
161 cmdZoom = new QToolButton( this, "Zoom command" ); 165 cmdZoom = new QToolButton( this, "Zoom command" );
162 cmdZoom->setPixmap( pixZoom ); 166 cmdZoom->setPixmap( pixZoom );
163 cmdZoom->setToggleButton( true ); 167 cmdZoom->setToggleButton( true );
164 168
165 cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, 169 cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0,
166 (QSizePolicy::SizeType)0, 170 (QSizePolicy::SizeType)0,
167 cmdZoom->sizePolicy().hasHeightForWidth() ) ); 171 cmdZoom->sizePolicy().hasHeightForWidth() ) );
168 cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); 172 cmdZoom->setMaximumSize( cmdZoom->sizeHint() );
169 // probably don't need this, but just in case... 173 // probably don't need this, but just in case...
170 cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); 174 cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() );
171 175
172 176
173 lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); 177 lblCity = new QLabel( tr( "CITY" ), this, "City Label" );
174 lblCity->setMinimumSize( lblCity->sizeHint() ); 178 lblCity->setMinimumSize( lblCity->sizeHint() );
175 lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); 179 lblCity->setFrameStyle( QFrame::Plain | QFrame::Box );
176 lblCity->setBackgroundColor( yellow ); 180 lblCity->setBackgroundColor( yellow );
177 lblCity->hide(); 181 lblCity->hide();
178 182
179 // A timer to make sure the label gets hidden 183 // A timer to make sure the label gets hidden
180 tHide = new QTimer( this, "Label Timer" ); 184 tHide = new QTimer( this, "Label Timer" );
181 QObject::connect( tHide, SIGNAL( timeout() ), 185 QObject::connect( tHide, SIGNAL( timeout() ),
182 lblCity, SLOT( hide() ) ); 186 lblCity, SLOT( hide() ) );
183 QObject::connect( tHide, SIGNAL( timeout() ), 187 QObject::connect( tHide, SIGNAL( timeout() ),
184 this, SLOT( slotRedraw() ) ); 188 this, SLOT( slotRedraw() ) );
185 QTimer *tUpdate = new QTimer( this, "Update Timer" ); 189 QTimer *tUpdate = new QTimer( this, "Update Timer" );
186 QObject::connect( tUpdate, SIGNAL( timeout() ), 190 QObject::connect( tUpdate, SIGNAL( timeout() ),
187 this, SLOT( slotUpdate() ) ); 191 this, SLOT( slotUpdate() ) );
188 QObject::connect( qApp, SIGNAL( timeChanged() ), 192 QObject::connect( qApp, SIGNAL( timeChanged() ),
189 this, SLOT( slotUpdate() ) ); 193 this, SLOT( slotUpdate() ) );
190 QObject::connect( cmdZoom, SIGNAL( toggled(bool) ), 194 QObject::connect( cmdZoom, SIGNAL( toggled(bool) ),
191 this, SLOT( slotZoom(bool) ) ); 195 this, SLOT( slotZoom(bool) ) );
192 QObject::connect( &norm, SIGNAL( signalNewPoint(const QPoint&) ), 196 QObject::connect( &norm, SIGNAL( signalNewPoint(const QPoint&) ),
193 this, SLOT( slotFindCity(const QPoint&) ) ); 197 this, SLOT( slotFindCity(const QPoint&) ) );
194 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), 198 QObject::connect( qApp, SIGNAL( clockChanged(bool) ),
195 this, SLOT( changeClock(bool) ) ); 199 this, SLOT( changeClock(bool) ) );
196 // update the sun's movement every 5 minutes 200 // update the sun's movement every 5 minutes
197 tUpdate->start( 5 * 60 * 1000 ); 201 tUpdate->start( 5 * 60 * 1000 );
198 // May as well read in the timezone information too... 202 // May as well read in the timezone information too...
199 readZones(); 203 readZones();
200} 204}
201 205
202ZoneMap::~ZoneMap() 206ZoneMap::~ZoneMap()
203{ 207{
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,
231 // pass it along 235 // pass it along
232 slotRedraw(); 236 slotRedraw();
233 norm.start(); 237 norm.start();
234 norm.addEvent( event->pos() ); 238 norm.addEvent( event->pos() );
235} 239}
236 240
237void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) 241void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event )
238{ 242{
239 norm.addEvent( event->pos() ); 243 norm.addEvent( event->pos() );
240} 244}
241 245
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 )
330{ 334{
331 lblCity->hide(); 335 lblCity->hide();
332 // given coordinates on the screen find the closest city and display the 336 // given coordinates on the screen find the closest city and display the
333 // label close to it 337 // label close to it
334 int tmpx, tmpy, x, y; 338 int tmpx, tmpy, x, y;
335 long lDistance, 339 long lDistance,
336 lClosest; 340 lClosest;
337 ZoneField *pZone, 341 ZoneField *pZone,
338 *pClosest; 342 *pClosest;
339 343
340 if ( tHide->isActive() ) { 344 if ( tHide->isActive() ) {
341 tHide->stop(); 345 tHide->stop();
342 } 346 }
343 viewportToContents(pos.x(), pos.y(), tmpx, tmpy); 347 viewportToContents(pos.x(), pos.y(), tmpx, tmpy);
344 winToZone( tmpx, tmpy, x, y ); 348 winToZone( tmpx, tmpy, x, y );
345 // Find city alogorithim: start out at an (near) infinite distance away and 349 // Find city alogorithim: start out at an (near) infinite distance away and
346 // then find the closest city, (similar to the Z-buffer technique, I guess) 350 // then find the closest city, (similar to the Z-buffer technique, I guess)
347 // the only problem is that this is all done with doubles, but I don't know 351 // the only problem is that this is all done with doubles, but I don't know
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;
374 // we'll use city and country a couple of times, get them to save some 378 // we'll use city and country a couple of times, get them to save some
375 // time 379 // time
376 QString strCity = pLast->city(); 380 QString strCity = pLast->city();
377 QString strCountry = pLast->country(); 381 QString strCountry = pLast->country();
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
435void ZoneMap::resizeEvent( QResizeEvent *e ) 439void 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
462 QWidget *returnWidget = new QWidget( parent ); 466 QWidget *returnWidget = new QWidget( parent );
463 467
464 QVBoxLayout *layout = new QVBoxLayout( returnWidget ); 468 QVBoxLayout *layout = new QVBoxLayout( returnWidget );
465 QHBox *hBox = new QHBox( returnWidget ); 469 QHBox *hBox = new QHBox( returnWidget );
466 QListView *continentView = new QListView( hBox ); 470 QListView *continentView = new QListView( hBox );
467 continentView->addColumn( tr("Continent") ); 471 continentView->addColumn( tr("Continent") );
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 {
481 name = pZone->country().left( 24 ); 485 name = pZone->country().left( 24 );
482 } 486 }
483 item = new QListViewItem( continentView, name, pZone->country() ); 487 item = new QListViewItem( continentView, name, pZone->country() );
484 continentList.append( pZone->country() ); 488 continentList.append( pZone->country() );
485 } 489 }
486 } 490 }
487 491
488 cityView = new QListView( hBox ); 492 cityView = new QListView( hBox );
489 cityView->addColumn( tr("City") ); 493 cityView->addColumn( tr("City") );
490 494
491 layout->addWidget( hBox ); 495 layout->addWidget( hBox );
492 return returnWidget; 496 return returnWidget;
493} 497}
494 498
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 }
508} 512}
509 513
510void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { 514void ZoneMap::slotCitySelected( QListViewItem *cityItem ) {
511 if ( cityItem ) { 515 if ( cityItem ) {
512 emit signalTz( selectedCont, cityItem->text( 0 ) ); 516 emit signalTz( selectedCont, cityItem->text( 0 ) );
513 } 517 }
514} 518}
515 519
516void ZoneMap::drawCities( QPainter *p ) 520void ZoneMap::drawCities( QPainter *p )
517{ 521{
518 int x, y, j; 522 int x, y, j;
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
536 double dJulian, 540 double dJulian,
537 dSunRad, 541 dSunRad,
538 dSunDecl, 542 dSunDecl,
539 dSunRadius, 543 dSunRadius,
540 dSunLong; 544 dSunLong;
541 int wImage = pImage->width(), 545 int wImage = pImage->width(),
542 hImage = pImage->height(), 546 hImage = pImage->height(),
543 iStart, 547 iStart,
544 iStop, 548 iStop,
545 iMid, 549 iMid,
546 relw, 550 relw,
547 i; 551 i;
548 short wtab[ wImage ]; 552 short wtab[ wImage ];
549 time_t tCurrent; 553 time_t tCurrent;
550 struct tm *pTm; 554 struct tm *pTm;
551 555
552 // get the position of the sun bassed on our current time... 556 // get the position of the sun bassed on our current time...
553 tCurrent = time( NULL ); 557 tCurrent = time( NULL );
554 pTm = gmtime( &tCurrent ); 558 pTm = gmtime( &tCurrent );
555 dJulian = jtime( pTm ); 559 dJulian = jtime( pTm );
556 sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong ); 560 sunpos( dJulian, 0, &dSunRad, &dSunDecl, &dSunRadius, &dSunLong );
557 561
558 // now get the projected illumination 562 // now get the projected illumination
559 projillum( wtab, wImage, hImage, dSunDecl ); 563 projillum( wtab, wImage, hImage, dSunDecl );
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,
586 j; 590 j;
587 uchar *p; 591 uchar *p;
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;
632 pixCurr->convertFromImage( imgOrig.smoothScale(w, h), 636 pixCurr->convertFromImage( imgOrig.smoothScale(w, h),
633 QPixmap::ThresholdDither ); 637 QPixmap::ThresholdDither );
634} 638}
635 639
636void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity ) 640void ZoneMap::drawCity( QPainter *p, const ZoneField *pCity )
637{ 641{
638 int x, 642 int x,
639 y; 643 y;
640 644
641 p->setPen( red ); 645 p->setPen( red );
642 zoneToWin( pCity->x(), pCity->y(), x, y ); 646 zoneToWin( pCity->x(), pCity->y(), x, y );
643 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE ); 647 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE );
644} 648}
645 649
646void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) 650void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
647{ 651{
648 // if there is a need to resize, then do it... 652 // if there is a need to resize, then do it...
649 // get our drawable area 653 // get our drawable area
650 drawableW = width() - 2 * frameWidth(); 654 drawableW = width() - 2 * frameWidth();
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;
695 // make the map... 699 // make the map...
696 makeMap( pixCurr->width(), pixCurr->height() ); 700 makeMap( pixCurr->width(), pixCurr->height() );
697 updateContents( 0, 0, wImg, hImg ); 701 updateContents( 0, 0, wImg, hImg );
698} 702}
699 703
700void ZoneMap::slotUpdate( void ) 704void ZoneMap::slotUpdate( void )
701{ 705{
702 // recalculate the light, most people will never see this, 706 // recalculate the light, most people will never see this,
703 // but it is good to be complete 707 // but it is good to be complete
704 makeMap ( pixCurr->width(), pixCurr->height() ); 708 makeMap ( pixCurr->width(), pixCurr->height() );
705 updateContents( contentsX(), contentsY(), drawableW, drawableH ); 709 updateContents( contentsX(), contentsY(), drawableW, drawableH );
706} 710}
707 711
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{
723 ampm = whichClock; 727 ampm = whichClock;
724} 728}
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
@@ -1,68 +1,72 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> 4             .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
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 "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
44 Config cfg( "Launcher" ); 48 Config cfg( "Launcher" );
45 cfg.setGroup( "DocTab" ); 49 cfg.setGroup( "DocTab" );
46 _enable->setChecked( cfg.readBoolEntry( "Enable", true ) ); 50 _enable->setChecked( cfg.readBoolEntry( "Enable", true ) );
47 51
48 lay->addWidget( _enable ); 52 lay->addWidget( _enable );
49 lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) ); 53 lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) );
50 54
51 lay->addStretch(); 55 lay->addStretch();
52 56
53 QWhatsThis::add( _enable, tr( "Check, if you want the Documents Tab to be visible." ) ); 57 QWhatsThis::add( _enable, tr( "Check, if you want the Documents Tab to be visible." ) );
54} 58}
55 59
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
@@ -1,84 +1,88 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org> 4             .=l. Copyright (c) 2003 Michael Lauer <mickeyl@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
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 "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 );
45 49
46 QHBoxLayout* hbox = new QHBoxLayout( lay, 4 ); 50 QHBoxLayout* hbox = new QHBoxLayout( lay, 4 );
47 hbox->addWidget( new QLabel( "Initial Width:", this ) ); 51 hbox->addWidget( new QLabel( "Initial Width:", this ) );
48 _size = new QSpinBox( 10, 100, 10, this ); 52 _size = new QSpinBox( 10, 100, 10, this );
49 _size->setSuffix( "%" ); 53 _size->setSuffix( "%" );
50 hbox->addWidget( _size ); 54 hbox->addWidget( _size );
51 hbox->addStretch(); 55 hbox->addStretch();
52 56
53 Config cfg( "Launcher" ); 57 Config cfg( "Launcher" );
54 cfg.setGroup( "InputMethods" ); 58 cfg.setGroup( "InputMethods" );
55 _resize->setChecked( cfg.readBoolEntry( "Resize", true ) ); 59 _resize->setChecked( cfg.readBoolEntry( "Resize", true ) );
56 _float->setChecked( cfg.readBoolEntry( "Float", false ) ); 60 _float->setChecked( cfg.readBoolEntry( "Float", false ) );
57 _size->setValue( cfg.readNumEntry( "Width", 100 ) ); 61 _size->setValue( cfg.readNumEntry( "Width", 100 ) );
58 62
59 lay->addWidget( _resize ); 63 lay->addWidget( _resize );
60 lay->addWidget( _float ); 64 lay->addWidget( _float );
61 lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) ); 65 lay->addWidget( new QLabel( tr( "<b>Note:</b> Changing these settings may need restarting Opie to become effective." ), this ) );
62 66
63 lay->addStretch(); 67 lay->addStretch();
64 68
65 QWhatsThis::add( _resize, tr( "Check, if you want the application to be automatically resized if the input method pops up." ) ); 69 QWhatsThis::add( _resize, tr( "Check, if you want the application to be automatically resized if the input method pops up." ) );
66 QWhatsThis::add( _float, tr( "Check, if you want to move and/or resize input methods" ) ); 70 QWhatsThis::add( _float, tr( "Check, if you want to move and/or resize input methods" ) );
67 QWhatsThis::add( _size, tr( "Specify the percentage of the screen width for the input method" ) ); 71 QWhatsThis::add( _size, tr( "Specify the percentage of the screen width for the input method" ) );
68} 72}
69 73
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();
83} 87}
84 88
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
@@ -1,514 +1,516 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
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
330QWidget *TabDialog::createBgTab ( QWidget *parent ) 332QWidget *TabDialog::createBgTab ( QWidget *parent )
331{ 333{
332 QWidget *tab = new QWidget( parent, "BgTab" ); 334 QWidget *tab = new QWidget( parent, "BgTab" );
333 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 335 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
334 336
335 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 337 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
336 gridLayout-> setColStretch ( 1, 10 ); 338 gridLayout-> setColStretch ( 1, 10 );
337 339
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 );
394 396
395 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 397 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
396 gridLayout-> setColStretch ( 1, 10 ); 398 gridLayout-> setColStretch ( 1, 10 );
397 399
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
@@ -1,172 +1,176 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
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
@@ -1,314 +1,317 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
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 "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>
46#include <qgroupbox.h> 49#include <qgroupbox.h>
47#include <qcombobox.h> 50#include <qcombobox.h>
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
@@ -1,440 +1,446 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
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#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");
41 passcode = cfg.readEntry("passcode"); 47 passcode = cfg.readEntry("passcode");
42 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); 48 passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE));
43 cfg.setGroup("Sync"); 49 cfg.setGroup("Sync");
44 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 50 int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24
45 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); 51 int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
46 selectNet(auth_peer,auth_peer_bits,TRUE); 52 selectNet(auth_peer,auth_peer_bits,TRUE);
47 53
48 connect(syncnet, SIGNAL(textChanged(const QString&)), 54 connect(syncnet, SIGNAL(textChanged(const QString&)),
49 this, SLOT(setSyncNet(const QString&))); 55 this, SLOT(setSyncNet(const QString&)));
50 56
51 57
52 58
53 /* 59 /*
54 cfg.setGroup("Remote"); 60 cfg.setGroup("Remote");
55 if ( telnetAvailable() ) 61 if ( telnetAvailable() )
56 telnet->setChecked(cfg.readEntry("allow_telnet")); 62 telnet->setChecked(cfg.readEntry("allow_telnet"));
57 else 63 else
58 telnet->hide(); 64 telnet->hide();
59 65
60 if ( sshAvailable() ) 66 if ( sshAvailable() )
61 ssh->setChecked(cfg.readEntry("allow_ssh")); 67 ssh->setChecked(cfg.readEntry("allow_ssh"));
62 else 68 else
63 ssh->hide(); 69 ssh->hide();
64 */ 70 */
65 71
66 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 72 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
67 Config loginCfg(configFile,Config::File); 73 Config loginCfg(configFile,Config::File);
68 74
69 loginCfg.setGroup("General"); 75 loginCfg.setGroup("General");
70 autoLoginName=loginCfg.readEntry("AutoLogin",""); 76 autoLoginName=loginCfg.readEntry("AutoLogin","");
71 77
72 if (autoLoginName.stripWhiteSpace().isEmpty()) { 78 if (autoLoginName.stripWhiteSpace().isEmpty()) {
73 autoLogin=false; 79 autoLogin=false;
74 } else { 80 } else {
75 autoLogin=true; 81 autoLogin=true;
76 } 82 }
77 83
78 cfg.setGroup("SyncMode"); 84 cfg.setGroup("SyncMode");
79 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp 85 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp
80 switch( mode ) { 86 switch( mode ) {
81 case 0x01: 87 case 0x01:
82 syncModeCombo->setCurrentItem( 0 ); 88 syncModeCombo->setCurrentItem( 0 );
83 break; 89 break;
84 case 0x02: 90 case 0x02:
85 default: 91 default:
86 syncModeCombo->setCurrentItem( 1 ); 92 syncModeCombo->setCurrentItem( 1 );
87 break; 93 break;
88 case 0x04: 94 case 0x04:
89 syncModeCombo->setCurrentItem( 2 ); 95 syncModeCombo->setCurrentItem( 2 );
90 break; 96 break;
91 } 97 }
92 98
93 99
94 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 100 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
95 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 101 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
96 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); 102 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
97 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); 103 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
98 connect(restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); 104 connect(restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
99 connect(deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); 105 connect(deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
100 106
101 loadUsers(); 107 loadUsers();
102 updateGUI(); 108 updateGUI();
103 109
104 dl = new QPEDialogListener(this); 110 dl = new QPEDialogListener(this);
105 QPEApplication::showDialog( this ); 111 QPEApplication::showDialog( this );
106} 112}
107 113
108Security::~Security() 114Security::~Security()
109{ 115{
110} 116}
111 117
112void Security::deleteListEntry() 118void Security::deleteListEntry()
113{ 119{
114 syncnet->removeItem(syncnet->currentItem()); 120 syncnet->removeItem(syncnet->currentItem());
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
128 if ( unrecbox.exec() == QMessageBox::Yes) 134 if ( unrecbox.exec() == QMessageBox::Yes)
129 { 135 {
130 syncnet->clear(); 136 syncnet->clear();
131 insertDefaultRanges(); 137 insertDefaultRanges();
132 } 138 }
133 syncModeCombo->setCurrentItem( 2 ); 139 syncModeCombo->setCurrentItem( 2 );
134} 140}
135 141
136void Security::insertDefaultRanges() 142void Security::insertDefaultRanges()
137{ 143{
138 syncnet->insertItem( tr( "192.168.129.0/24" ) ); 144 syncnet->insertItem( tr( "192.168.129.0/24" ) );
139 syncnet->insertItem( tr( "192.168.1.0/24" ) ); 145 syncnet->insertItem( tr( "192.168.1.0/24" ) );
140 syncnet->insertItem( tr( "192.168.0.0/16" ) ); 146 syncnet->insertItem( tr( "192.168.0.0/16" ) );
141 syncnet->insertItem( tr( "172.16.0.0/12" ) ); 147 syncnet->insertItem( tr( "172.16.0.0/12" ) );
142 syncnet->insertItem( tr( "10.0.0.0/8" ) ); 148 syncnet->insertItem( tr( "10.0.0.0/8" ) );
143 syncnet->insertItem( tr( "1.0.0.0/8" ) ); 149 syncnet->insertItem( tr( "1.0.0.0/8" ) );
144 syncnet->insertItem( tr( "Any" ) ); 150 syncnet->insertItem( tr( "Any" ) );
145 syncnet->insertItem( tr( "None" ) ); 151 syncnet->insertItem( tr( "None" ) );
146} 152}
147 153
148void Security::updateGUI() 154void Security::updateGUI()
149{ 155{
150 bool empty = passcode.isEmpty(); 156 bool empty = passcode.isEmpty();
151 157
152 changepasscode->setText( empty ? tr("Set passcode" ) 158 changepasscode->setText( empty ? tr("Set passcode" )
153 : tr("Change passcode" ) ); 159 : tr("Change passcode" ) );
154 passcode_poweron->setEnabled( !empty ); 160 passcode_poweron->setEnabled( !empty );
155 clearpasscode->setEnabled( !empty ); 161 clearpasscode->setEnabled( !empty );
156 162
157 autologinToggle->setChecked(autoLogin); 163 autologinToggle->setChecked(autoLogin);
158 userlist->setEnabled(autoLogin); 164 userlist->setEnabled(autoLogin);
159} 165}
160 166
161 167
162void Security::show() 168void Security::show()
163{ 169{
164 //valid=FALSE; 170 //valid=FALSE;
165 setEnabled(FALSE); 171 setEnabled(FALSE);
166 SecurityBase::show(); 172 SecurityBase::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()
189{ 195{
190 applySecurity(); 196 applySecurity();
191 QDialog::accept(); 197 QDialog::accept();
192 QCopEnvelope env("QPE/System", "securityChanged()" ); 198 QCopEnvelope env("QPE/System", "securityChanged()" );
193} 199}
194 200
195void Security::done(int r) 201void Security::done(int r)
196{ 202{
197 QDialog::done(r); 203 QDialog::done(r);
198 close(); 204 close();
199} 205}
200 206
201void Security::selectNet(int auth_peer,int auth_peer_bits, bool update) 207void Security::selectNet(int auth_peer,int auth_peer_bits, bool update)
202{ 208{
203 QString sn; 209 QString sn;
204 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 210 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
205 sn = tr("Any"); 211 sn = tr("Any");
206 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 212 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
207 sn = tr("None"); 213 sn = tr("None");
208 } else { 214 } else {
209 sn = 215 sn =
210 QString::number((auth_peer>>24)&0xff) + "." 216 QString::number((auth_peer>>24)&0xff) + "."
211 + QString::number((auth_peer>>16)&0xff) + "." 217 + QString::number((auth_peer>>16)&0xff) + "."
212 + QString::number((auth_peer>>8)&0xff) + "." 218 + QString::number((auth_peer>>8)&0xff) + "."
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);
236 netrange = cfg.readEntry(target,""); 242 netrange = cfg.readEntry(target,"");
237 if (! netrange.isEmpty()){ 243 if (! netrange.isEmpty()){
238 //make sure we have no "twin" entries 244 //make sure we have no "twin" entries
239 for (int i=0; i<syncnet->count(); i++) { 245 for (int i=0; i<syncnet->count(); i++) {
240 if ( syncnet->text(i) == netrange ) { 246 if ( syncnet->text(i) == netrange ) {
241 already_there=TRUE; 247 already_there=TRUE;
242 } 248 }
243 } 249 }
244 if (! already_there) { 250 if (! already_there) {
245 syncnet->insertItem( tr( netrange ) ); 251 syncnet->insertItem( tr( netrange ) );
246 } else { 252 } else {
247 already_there=FALSE; 253 already_there=FALSE;
248 } 254 }
249 } 255 }
250 } 256 }
251 } 257 }
252 } 258 }
253 259
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") ) {
267 auth_peer = 0; 273 auth_peer = 0;
268 auth_peer_bits = 0; 274 auth_peer_bits = 0;
269 } else if ( sn == tr("None") ) { 275 } else if ( sn == tr("None") ) {
270 auth_peer = 0; 276 auth_peer = 0;
271 auth_peer_bits = 32; 277 auth_peer_bits = 32;
272 } else { 278 } else {
273 int x=0; 279 int x=0;
274 for (int i=0; i<4; i++) { 280 for (int i=0; i<4; i++) {
275 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 281 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
276 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 282 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
277 x = nx+1; 283 x = nx+1;
278 } 284 }
279 uint n = (uint)sn.find(' ',x)-x; 285 uint n = (uint)sn.find(' ',x)-x;
280 auth_peer_bits = sn.mid(x,n).toInt(); 286 auth_peer_bits = sn.mid(x,n).toInt();
281 } 287 }
282} 288}
283 289
284void Security::loadUsers ( void ) 290void Security::loadUsers ( void )
285{ 291{
286 QFile passwd("/etc/passwd"); 292 QFile passwd("/etc/passwd");
287 if ( passwd.open(IO_ReadOnly) ) { 293 if ( passwd.open(IO_ReadOnly) ) {
288 QTextStream t( &passwd ); 294 QTextStream t( &passwd );
289 QString s; 295 QString s;
290 QStringList account; 296 QStringList account;
291 while ( !t.eof() ) { 297 while ( !t.eof() ) {
292 account = QStringList::split(':',t.readLine()); 298 account = QStringList::split(':',t.readLine());
293 299
294 // Hide disabled accounts 300 // Hide disabled accounts
295 if (*account.at(1)!="*") { 301 if (*account.at(1)!="*") {
296 302
297 userlist->insertItem(*account.at(0)); 303 userlist->insertItem(*account.at(0));
298 // Highlight this item if it is set to autologinToggle 304 // Highlight this item if it is set to autologinToggle
299 if ( *account.at(0) == autoLoginName) 305 if ( *account.at(0) == autoLoginName)
300 userlist->setCurrentItem(userlist->count()-1); 306 userlist->setCurrentItem(userlist->count()-1);
301 } 307 }
302 } 308 }
303 passwd.close(); 309 passwd.close();
304 } 310 }
305 311
306} 312}
307 313
308void Security::toggleAutoLogin(bool val) 314void Security::toggleAutoLogin(bool val)
309{ 315{
310 autoLogin=val; 316 autoLogin=val;
311 userlist->setEnabled(val); 317 userlist->setEnabled(val);
312 if (!autoLogin) 318 if (!autoLogin)
313 autoLoginName=userlist->currentText(); 319 autoLoginName=userlist->currentText();
314} 320}
315 321
316 322
317 323
318 324
319void Security::setSyncNet(const QString& sn) 325void Security::setSyncNet(const QString& sn)
320{ 326{
321 int auth_peer,auth_peer_bits; 327 int auth_peer,auth_peer_bits;
322 parseNet(sn,auth_peer,auth_peer_bits); 328 parseNet(sn,auth_peer,auth_peer_bits);
323 selectNet(auth_peer,auth_peer_bits,FALSE); 329 selectNet(auth_peer,auth_peer_bits,FALSE);
324} 330}
325 331
326void Security::applySecurity() 332void Security::applySecurity()
327{ 333{
328 if ( valid ) { 334 if ( valid ) {
329 Config cfg("Security"); 335 Config cfg("Security");
330 cfg.setGroup("Passcode"); 336 cfg.setGroup("Passcode");
331 cfg.writeEntry("passcode",passcode); 337 cfg.writeEntry("passcode",passcode);
332 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); 338 cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked());
333 cfg.setGroup("Sync"); 339 cfg.setGroup("Sync");
334 int auth_peer=0; 340 int auth_peer=0;
335 int auth_peer_bits; 341 int auth_peer_bits;
336 QString sn = syncnet->currentText(); 342 QString sn = syncnet->currentText();
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;
355 switch( syncModeCombo->currentItem() ) { 361 switch( syncModeCombo->currentItem() ) {
356 case 0: 362 case 0:
357 value = 0x01; 363 value = 0x01;
358 break; 364 break;
359 case 1: 365 case 1:
360 value = 0x02; 366 value = 0x02;
361 break; 367 break;
362 case 2: 368 case 2:
363 value = 0x04; 369 value = 0x04;
364 break; 370 break;
365 } 371 }
366 cfg.setGroup("SyncMode"); 372 cfg.setGroup("SyncMode");
367 cfg.writeEntry( "Mode", value ); 373 cfg.writeEntry( "Mode", value );
368 374
369 /* 375 /*
370 cfg.setGroup("Remote"); 376 cfg.setGroup("Remote");
371 if ( telnetAvailable() ) 377 if ( telnetAvailable() )
372 cfg.writeEntry("allow_telnet",telnet->isChecked()); 378 cfg.writeEntry("allow_telnet",telnet->isChecked());
373 if ( sshAvailable() ) 379 if ( sshAvailable() )
374 cfg.writeEntry("allow_ssh",ssh->isChecked()); 380 cfg.writeEntry("allow_ssh",ssh->isChecked());
375 // ### write ssh/telnet sys config files 381 // ### write ssh/telnet sys config files
376 */ 382 */
377 383
378 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; 384 QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf";
379 Config loginCfg(configFile,Config::File); 385 Config loginCfg(configFile,Config::File);
380 loginCfg.setGroup("General"); 386 loginCfg.setGroup("General");
381 387
382 if (autoLogin) { 388 if (autoLogin) {
383 loginCfg.writeEntry("AutoLogin",autoLoginName); 389 loginCfg.writeEntry("AutoLogin",autoLoginName);
384 } else { 390 } else {
385 loginCfg.removeEntry("AutoLogin"); 391 loginCfg.removeEntry("AutoLogin");
386 } 392 }
387 393
388 } 394 }
389} 395}
390 396
391 397
392 398
393 399
394void Security::changeLoginName( int idx ) 400void Security::changeLoginName( int idx )
395{ 401{
396 autoLoginName = userlist->text(idx);; 402 autoLoginName = userlist->text(idx);;
397 updateGUI(); 403 updateGUI();
398} 404}
399 405
400void Security::changePassCode() 406void Security::changePassCode()
401{ 407{
402 QString new1; 408 QString new1;
403 QString new2; 409 QString new2;
404 410
405 do { 411 do {
406 new1 = enterPassCode(tr("Enter new passcode")); 412 new1 = enterPassCode(tr("Enter new passcode"));
407 if ( new1.isNull() ) 413 if ( new1.isNull() )
408 return; 414 return;
409 new2 = enterPassCode(tr("Re-enter new passcode")); 415 new2 = enterPassCode(tr("Re-enter new passcode"));
410 if ( new2.isNull() ) 416 if ( new2.isNull() )
411 return; 417 return;
412 } while (new1 != new2); 418 } while (new1 != new2);
413 419
414 passcode = new1; 420 passcode = new1;
415 updateGUI(); 421 updateGUI();
416} 422}
417 423
418void Security::clearPassCode() 424void Security::clearPassCode()
419{ 425{
420 passcode = QString::null; 426 passcode = QString::null;
421 updateGUI(); 427 updateGUI();
422} 428}
423 429
424 430
425QString Security::enterPassCode(const QString& prompt) 431QString Security::enterPassCode(const QString& prompt)
426{ 432{
427 return Password::getPassword(prompt); 433 return Password::getPassword(prompt);
428} 434}
429 435
430bool Security::telnetAvailable() const 436bool Security::telnetAvailable() const
431{ 437{
432 // ### not implemented 438 // ### not implemented
433 return FALSE; 439 return FALSE;
434} 440}
435 441
436bool Security::sshAvailable() const 442bool Security::sshAvailable() const
437{ 443{
438 // ### not implemented 444 // ### not implemented
439 return FALSE; 445 return FALSE;
440} 446}
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,179 +1,185 @@
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
16static const char *listDir = "/usr/lib/ipkg/externinfo/"; 22static const char *listDir = "/usr/lib/ipkg/externinfo/";
17 23
18static void createSymlinks( const QString &location, const QString &package ) 24static void createSymlinks( const QString &location, const QString &package )
19{ 25{
20 26
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
@@ -1,268 +1,275 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
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
27 33
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;
47static QGuardedPtr<QWidget> mainWindow; 54static QGuardedPtr<QWidget> mainWindow;
48 55
49#ifdef _OS_LINUX_ 56#ifdef _OS_LINUX_
50static char **argv0 = 0; 57static char **argv0 = 0;
51static int argv_lth; 58static int argv_lth;
52extern char **environ; 59extern char **environ;
53#ifndef SPT_BUFSIZE 60#ifndef SPT_BUFSIZE
54#define SPT_BUFSIZE 2048 61#define SPT_BUFSIZE 2048
55#endif 62#endif
56#include <stdarg.h> 63#include <stdarg.h>
57using namespace Opie::Ui; 64using 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}
80#endif 87#endif
81 88
82 89
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
170int main( int argc, char** argv ) 177int main( int argc, char** argv )
171{ 178{
172 app = new QPEApplication( argc, argv ); 179 app = new QPEApplication( argc, argv );
173 180
174 loader = new PluginLoader( "application" ); 181 loader = new PluginLoader( "application" );
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
257 // in the apps and on destructing these objects are not available 264 // in the apps and on destructing these objects are not available
258 // anymore. In future fix up the apps but for now 265 // anymore. In future fix up the apps but for now
259 // we just skip deletion and hope things go well -zecke 266 // we just skip deletion and hope things go well -zecke
260// delete app; 267// delete app;
261 // hack instead -zecke 268 // hack instead -zecke
262// delete app->pidChannel; 269// delete app->pidChannel;
263// app->pidChannel = 0; 270// app->pidChannel = 0;
264 271
265 return rv; 272 return rv;
266} 273}
267 274
268#include "main.moc" 275#include "main.moc"