author | ar <ar> | 2004-02-08 16:09:19 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-08 16:09:19 (UTC) |
commit | 6506eeeeaa8d52ae0895630de00e38bc2b8ff10c (patch) (unidiff) | |
tree | a306b368cc4192e6a8528c7d602e4726c73a247c | |
parent | 811821ed75b87468f521bef2077cf5988aac9b47 (diff) | |
download | opie-6506eeeeaa8d52ae0895630de00e38bc2b8ff10c.zip opie-6506eeeeaa8d52ae0895630de00e38bc2b8ff10c.tar.gz opie-6506eeeeaa8d52ae0895630de00e38bc2b8ff10c.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 2 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 3 | ||||
-rw-r--r-- | core/launcher/serverapp.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 2 | ||||
-rw-r--r-- | core/obex/obexhandler.cpp | 3 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 2 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 3 | ||||
-rw-r--r-- | core/settings/button/buttonsettings.cpp | 3 | ||||
-rw-r--r-- | core/settings/launcher/tabssettings.cpp | 4 | ||||
-rw-r--r-- | core/settings/light-and-power/light.cpp | 3 | ||||
-rw-r--r-- | core/settings/security/security.cpp | 2 |
13 files changed, 16 insertions, 17 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index 4adcab4..3b64fb5 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -1,170 +1,170 @@ | |||
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 "battery.h" | 20 | #include "battery.h" |
21 | #include "batterystatus.h" | 21 | #include "batterystatus.h" |
22 | 22 | ||
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/power.h> | 25 | #include <qpe/power.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | 30 | ||
31 | 31 | ||
32 | BatteryMeter::BatteryMeter( QWidget *parent ) | 32 | BatteryMeter::BatteryMeter( QWidget *parent ) |
33 | : QWidget( parent ), charging(false) | 33 | : QWidget( parent ), charging(false) |
34 | { | 34 | { |
35 | ps = new PowerStatus; | 35 | ps = new PowerStatus; |
36 | startTimer( 10000 ); | 36 | startTimer( 10000 ); |
37 | 37 | ||
38 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); | 38 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); |
39 | setFixedHeight( AppLnk::smallIconSize() ); | 39 | setFixedHeight( AppLnk::smallIconSize() ); |
40 | 40 | ||
41 | chargeTimer = new QTimer( this ); | 41 | chargeTimer = new QTimer( this ); |
42 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); | 42 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); |
43 | timerEvent(0); | 43 | timerEvent(0); |
44 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 44 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
45 | Config c( "qpe" ); | 45 | Config c( "qpe" ); |
46 | c.setGroup( "Battery" ); | 46 | c.setGroup( "Battery" ); |
47 | style = c.readNumEntry( "Style", 0 ); | 47 | style = c.readNumEntry( "Style", 0 ); |
48 | } | 48 | } |
49 | 49 | ||
50 | BatteryMeter::~BatteryMeter() | 50 | BatteryMeter::~BatteryMeter() |
51 | { | 51 | { |
52 | delete ps; | 52 | delete ps; |
53 | } | 53 | } |
54 | 54 | ||
55 | QSize BatteryMeter::sizeHint() const | 55 | QSize BatteryMeter::sizeHint() const |
56 | { | 56 | { |
57 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); | 57 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); |
58 | } | 58 | } |
59 | 59 | ||
60 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) | 60 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) |
61 | { | 61 | { |
62 | if ( e->button() == RightButton ) | 62 | if ( e->button() == RightButton ) |
63 | { | 63 | { |
64 | style = 1-style; | 64 | style = 1-style; |
65 | Config c( "qpe" ); | 65 | Config c( "qpe" ); |
66 | c.setGroup( "Battery" ); | 66 | c.setGroup( "Battery" ); |
67 | c.writeEntry( "Style", style ); | 67 | c.writeEntry( "Style", style ); |
68 | repaint( true ); | 68 | repaint( true ); |
69 | } | 69 | } |
70 | QWidget::mousePressEvent( e ); | 70 | QWidget::mousePressEvent( e ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) | 73 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) |
74 | { | 74 | { |
75 | if ( batteryView && batteryView->isVisible() ) { | 75 | if ( batteryView && batteryView->isVisible() ) { |
76 | delete (QWidget *) batteryView; | 76 | delete (QWidget *) batteryView; |
77 | } else { | 77 | } else { |
78 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); | 78 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); |
79 | batteryView->showMaximized(); | 79 | QPEApplication::showWidget( batteryView ); |
80 | batteryView->raise(); | 80 | batteryView->raise(); |
81 | batteryView->show(); | 81 | batteryView->show(); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | void BatteryMeter::timerEvent( QTimerEvent * ) | 85 | void BatteryMeter::timerEvent( QTimerEvent * ) |
86 | { | 86 | { |
87 | PowerStatus prev = *ps; | 87 | PowerStatus prev = *ps; |
88 | 88 | ||
89 | *ps = PowerStatusManager::readStatus(); | 89 | *ps = PowerStatusManager::readStatus(); |
90 | 90 | ||
91 | if ( prev != *ps ) { | 91 | if ( prev != *ps ) { |
92 | percent = ps->batteryPercentRemaining(); | 92 | percent = ps->batteryPercentRemaining(); |
93 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { | 93 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { |
94 | percent = 0; | 94 | percent = 0; |
95 | charging = true; | 95 | charging = true; |
96 | chargeTimer->start( 500 ); | 96 | chargeTimer->start( 500 ); |
97 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { | 97 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { |
98 | charging = false; | 98 | charging = false; |
99 | chargeTimer->stop(); | 99 | chargeTimer->stop(); |
100 | if ( batteryView ) | 100 | if ( batteryView ) |
101 | batteryView->updatePercent( percent ); | 101 | batteryView->updatePercent( percent ); |
102 | } | 102 | } |
103 | repaint( style != 0 ); | 103 | repaint( style != 0 ); |
104 | if ( batteryView ) | 104 | if ( batteryView ) |
105 | batteryView->repaint(); | 105 | batteryView->repaint(); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | void BatteryMeter::chargeTimeout() | 109 | void BatteryMeter::chargeTimeout() |
110 | { | 110 | { |
111 | percent += 20; | 111 | percent += 20; |
112 | if ( percent > 100 ) | 112 | if ( percent > 100 ) |
113 | percent = 0; | 113 | percent = 0; |
114 | 114 | ||
115 | repaint(FALSE); | 115 | repaint(FALSE); |
116 | if ( batteryView ) | 116 | if ( batteryView ) |
117 | batteryView->updatePercent( percent ); | 117 | batteryView->updatePercent( percent ); |
118 | } | 118 | } |
119 | 119 | ||
120 | void BatteryMeter::paintEvent( QPaintEvent* ) | 120 | void BatteryMeter::paintEvent( QPaintEvent* ) |
121 | { | 121 | { |
122 | 122 | ||
123 | if ( style == 1 ) | 123 | if ( style == 1 ) |
124 | { | 124 | { |
125 | QPainter p(this); | 125 | QPainter p(this); |
126 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); | 126 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); |
127 | QFontMetrics fm( f ); | 127 | QFontMetrics fm( f ); |
128 | p.setFont( f ); | 128 | p.setFont( f ); |
129 | p.drawText( 0, height()/2, QString::number( percent ) ); | 129 | p.drawText( 0, height()/2, QString::number( percent ) ); |
130 | p.drawText( width()/4, height(), "%" ); | 130 | p.drawText( width()/4, height(), "%" ); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | 133 | ||
134 | QPainter p(this); | 134 | QPainter p(this); |
135 | QColor color; | 135 | QColor color; |
136 | QColor g = gray.light( 160 ); | 136 | QColor g = gray.light( 160 ); |
137 | switch ( ps->acStatus() ) | 137 | switch ( ps->acStatus() ) |
138 | { | 138 | { |
139 | case PowerStatus::Offline: color = blue.light( 150 ); break; | 139 | case PowerStatus::Offline: color = blue.light( 150 ); break; |
140 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; | 140 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; |
141 | default: color = red.light( 160 ); | 141 | default: color = red.light( 160 ); |
142 | } | 142 | } |
143 | 143 | ||
144 | int w = height() / 2; | 144 | int w = height() / 2; |
145 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line | 145 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line |
146 | int h = height() - 4; | 146 | int h = height() - 4; |
147 | int pix = (percent * h) / 100; | 147 | int pix = (percent * h) / 100; |
148 | int y2 = height() -2; | 148 | int y2 = height() -2; |
149 | int y = y2 - pix; | 149 | int y = y2 - pix; |
150 | int x1 = (width() - w ) / 2; | 150 | int x1 = (width() - w ) / 2; |
151 | 151 | ||
152 | p.setPen(QColor(80,80,80)); | 152 | p.setPen(QColor(80,80,80)); |
153 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header | 153 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header |
154 | p.drawRect(x1,1,w,height()-1); // corpus | 154 | p.drawRect(x1,1,w,height()-1); // corpus |
155 | p.setBrush(color); | 155 | p.setBrush(color); |
156 | 156 | ||
157 | int extra = ((percent * h) % 100)/(100/4); | 157 | int extra = ((percent * h) % 100)/(100/4); |
158 | 158 | ||
159 | int middle = w/2; | 159 | int middle = w/2; |
160 | for ( int i = 0; i < middle; i++ ) | 160 | for ( int i = 0; i < middle; i++ ) |
161 | { | 161 | { |
162 | p.setPen( gray.dark( 100+i*20 ) ); | 162 | p.setPen( gray.dark( 100+i*20 ) ); |
163 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); | 163 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); |
164 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); | 164 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); |
165 | p.setPen( color.dark( 100+i*20 ) ); | 165 | p.setPen( color.dark( 100+i*20 ) ); |
166 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); | 166 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); |
167 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); | 167 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index bdddd37..98e7481 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,779 +1,778 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 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 <qtopia/global.h> | 21 | #include <qtopia/global.h> |
22 | #ifdef Q_WS_QWS | 22 | #ifdef Q_WS_QWS |
23 | #include <qtopia/qcopenvelope_qws.h> | 23 | #include <qtopia/qcopenvelope_qws.h> |
24 | #endif | 24 | #endif |
25 | #include <qtopia/resource.h> | 25 | #include <qtopia/resource.h> |
26 | #include <qtopia/applnk.h> | 26 | #include <qtopia/applnk.h> |
27 | #include <qtopia/config.h> | 27 | #include <qtopia/config.h> |
28 | #include <qtopia/global.h> | 28 | #include <qtopia/global.h> |
29 | #include <qtopia/qpeapplication.h> | 29 | #include <qtopia/qpeapplication.h> |
30 | #include <qtopia/mimetype.h> | 30 | #include <qtopia/mimetype.h> |
31 | #include <qtopia/private/categories.h> | 31 | #include <qtopia/private/categories.h> |
32 | //#include <qtopia/custom.h> | 32 | //#include <qtopia/custom.h> |
33 | 33 | ||
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #endif | 37 | #endif |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qvbox.h> | 40 | #include <qvbox.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qstyle.h> | 42 | #include <qstyle.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
45 | #include <qwidgetstack.h> | 45 | #include <qwidgetstack.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qregexp.h> | 47 | #include <qregexp.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qframe.h> | 49 | #include <qframe.h> |
50 | #include <qpainter.h> | 50 | #include <qpainter.h> |
51 | #include <qlabel.h> | 51 | #include <qlabel.h> |
52 | #include <qtextstream.h> | 52 | #include <qtextstream.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | 54 | ||
55 | #include "startmenu.h" | 55 | #include "startmenu.h" |
56 | #include "taskbar.h" | 56 | #include "taskbar.h" |
57 | 57 | ||
58 | #include "serverinterface.h" | 58 | #include "serverinterface.h" |
59 | #include "launcherview.h" | 59 | #include "launcherview.h" |
60 | #include "launcher.h" | 60 | #include "launcher.h" |
61 | #include "server.h" | 61 | #include "server.h" |
62 | 62 | ||
63 | #define QTOPIA_INTERNAL_FSLP | 63 | #define QTOPIA_INTERNAL_FSLP |
64 | #include <qtopia/lnkproperties.h> | 64 | #include <qtopia/lnkproperties.h> |
65 | #include <stdlib.h> | 65 | #include <stdlib.h> |
66 | #include <assert.h> | 66 | #include <assert.h> |
67 | 67 | ||
68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | #include <stdio.h> | 70 | #include <stdio.h> |
71 | #include <sys/vfs.h> | 71 | #include <sys/vfs.h> |
72 | #include <mntent.h> | 72 | #include <mntent.h> |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #ifdef Q_WS_QWS | 75 | #ifdef Q_WS_QWS |
76 | #include <qkeyboard_qws.h> | 76 | #include <qkeyboard_qws.h> |
77 | #include <qpe/lnkproperties.h> | 77 | #include <qpe/lnkproperties.h> |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | 80 | ||
81 | static bool isVisibleWindow( int ); | 81 | static bool isVisibleWindow( int ); |
82 | //=========================================================================== | 82 | //=========================================================================== |
83 | 83 | ||
84 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | 84 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : |
85 | QVBox( parent ), docview( 0 ) | 85 | QVBox( parent ), docview( 0 ) |
86 | { | 86 | { |
87 | docLoadingWidgetEnabled = false; | 87 | docLoadingWidgetEnabled = false; |
88 | docLoadingWidget = 0; | 88 | docLoadingWidget = 0; |
89 | docLoadingWidgetProgress = 0; | 89 | docLoadingWidgetProgress = 0; |
90 | launcher = parent; | 90 | launcher = parent; |
91 | categoryBar = new LauncherTabBar( this ); | 91 | categoryBar = new LauncherTabBar( this ); |
92 | QPalette pal = categoryBar->palette(); | 92 | QPalette pal = categoryBar->palette(); |
93 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 93 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
94 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 94 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
95 | categoryBar->setPalette( pal ); | 95 | categoryBar->setPalette( pal ); |
96 | stack = new QWidgetStack(this); | 96 | stack = new QWidgetStack(this); |
97 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); | 97 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); |
98 | categoryBar->show(); | 98 | categoryBar->show(); |
99 | stack->show(); | 99 | stack->show(); |
100 | 100 | ||
101 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 101 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
102 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 102 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
103 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 103 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
104 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | 104 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); |
105 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 105 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
106 | this, SLOT(appMessage(const QCString&, const QByteArray&))); | 106 | this, SLOT(appMessage(const QCString&, const QByteArray&))); |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | createDocLoadingWidget(); | 109 | createDocLoadingWidget(); |
110 | } | 110 | } |
111 | 111 | ||
112 | void LauncherTabWidget::createDocLoadingWidget() | 112 | void LauncherTabWidget::createDocLoadingWidget() |
113 | { | 113 | { |
114 | // Construct the 'doc loading widget' shown when finding documents | 114 | // Construct the 'doc loading widget' shown when finding documents |
115 | 115 | ||
116 | // ### LauncherView class needs changing to be more generic so | 116 | // ### LauncherView class needs changing to be more generic so |
117 | // this widget can change its background similar to the iconviews | 117 | // this widget can change its background similar to the iconviews |
118 | // so the background for this matches | 118 | // so the background for this matches |
119 | docLoadingWidget = new LauncherView( stack ); | 119 | docLoadingWidget = new LauncherView( stack ); |
120 | docLoadingWidget->hideIcons(); | 120 | docLoadingWidget->hideIcons(); |
121 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 121 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
122 | 122 | ||
123 | docLoadingVBox->setSpacing( 20 ); | 123 | docLoadingVBox->setSpacing( 20 ); |
124 | docLoadingVBox->setMargin( 10 ); | 124 | docLoadingVBox->setMargin( 10 ); |
125 | 125 | ||
126 | QWidget *space1 = new QWidget( docLoadingVBox ); | 126 | QWidget *space1 = new QWidget( docLoadingVBox ); |
127 | docLoadingVBox->setStretchFactor( space1, 1 ); | 127 | docLoadingVBox->setStretchFactor( space1, 1 ); |
128 | 128 | ||
129 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 129 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); |
130 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 130 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
131 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); | 131 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); |
132 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); | 132 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); |
133 | 133 | ||
134 | Config cfg( "Launcher" ); | 134 | Config cfg( "Launcher" ); |
135 | cfg.setGroup( "DocTab" ); | 135 | cfg.setGroup( "DocTab" ); |
136 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 136 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
137 | 137 | ||
138 | QLabel *textLabel = new QLabel( docLoadingVBox ); | 138 | QLabel *textLabel = new QLabel( docLoadingVBox ); |
139 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); | 139 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); |
140 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); | 140 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); |
141 | docLoadingWidgetProgress->setProgress( 0 ); | 141 | docLoadingWidgetProgress->setProgress( 0 ); |
142 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); | 142 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); |
143 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker | 143 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker |
144 | setProgressStyle(); | 144 | setProgressStyle(); |
145 | 145 | ||
146 | if ( docTabEnabled ) | 146 | if ( docTabEnabled ) |
147 | { | 147 | { |
148 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); | 148 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | { | 151 | { |
152 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" | 152 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" |
153 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 153 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
154 | docLoadingWidgetProgress->hide(); | 154 | docLoadingWidgetProgress->hide(); |
155 | docLoadingWidgetEnabled = true; | 155 | docLoadingWidgetEnabled = true; |
156 | } | 156 | } |
157 | 157 | ||
158 | QWidget *space2 = new QWidget( docLoadingVBox ); | 158 | QWidget *space2 = new QWidget( docLoadingVBox ); |
159 | docLoadingVBox->setStretchFactor( space2, 1 ); | 159 | docLoadingVBox->setStretchFactor( space2, 1 ); |
160 | 160 | ||
161 | cfg.setGroup( "Tab Documents" ); // No tr | 161 | cfg.setGroup( "Tab Documents" ); // No tr |
162 | setTabViewAppearance( docLoadingWidget, cfg ); | 162 | setTabViewAppearance( docLoadingWidget, cfg ); |
163 | 163 | ||
164 | stack->addWidget( docLoadingWidget, 0 ); | 164 | stack->addWidget( docLoadingWidget, 0 ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void LauncherTabWidget::initLayout() | 167 | void LauncherTabWidget::initLayout() |
168 | { | 168 | { |
169 | layout()->activate(); | 169 | layout()->activate(); |
170 | docView()->setFocus(); | 170 | docView()->setFocus(); |
171 | categoryBar->showTab("Documents"); | 171 | categoryBar->showTab("Documents"); |
172 | } | 172 | } |
173 | 173 | ||
174 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 174 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
175 | { | 175 | { |
176 | if ( message == "nextView()" ) | 176 | if ( message == "nextView()" ) |
177 | categoryBar->nextTab(); | 177 | categoryBar->nextTab(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void LauncherTabWidget::raiseTabWidget() | 180 | void LauncherTabWidget::raiseTabWidget() |
181 | { | 181 | { |
182 | if ( categoryBar->currentView() == docView() | 182 | if ( categoryBar->currentView() == docView() |
183 | && docLoadingWidgetEnabled ) { | 183 | && docLoadingWidgetEnabled ) { |
184 | stack->raiseWidget( docLoadingWidget ); | 184 | stack->raiseWidget( docLoadingWidget ); |
185 | docLoadingWidget->updateGeometry(); | 185 | docLoadingWidget->updateGeometry(); |
186 | } else { | 186 | } else { |
187 | stack->raiseWidget( categoryBar->currentView() ); | 187 | stack->raiseWidget( categoryBar->currentView() ); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | void LauncherTabWidget::tabProperties() | 191 | void LauncherTabWidget::tabProperties() |
192 | { | 192 | { |
193 | LauncherView *view = categoryBar->currentView(); | 193 | LauncherView *view = categoryBar->currentView(); |
194 | QPopupMenu *m = new QPopupMenu( this ); | 194 | QPopupMenu *m = new QPopupMenu( this ); |
195 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 195 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
196 | m->insertItem( tr("List View"), LauncherView::List ); | 196 | m->insertItem( tr("List View"), LauncherView::List ); |
197 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 197 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
198 | int rv = m->exec( QCursor::pos() ); | 198 | int rv = m->exec( QCursor::pos() ); |
199 | if ( rv >= 0 && rv != view->viewMode() ) { | 199 | if ( rv >= 0 && rv != view->viewMode() ) { |
200 | view->setViewMode( (LauncherView::ViewMode)rv ); | 200 | view->setViewMode( (LauncherView::ViewMode)rv ); |
201 | } | 201 | } |
202 | 202 | ||
203 | delete m; | 203 | delete m; |
204 | } | 204 | } |
205 | 205 | ||
206 | void LauncherTabWidget::deleteView( const QString& id ) | 206 | void LauncherTabWidget::deleteView( const QString& id ) |
207 | { | 207 | { |
208 | LauncherTab *t = categoryBar->launcherTab(id); | 208 | LauncherTab *t = categoryBar->launcherTab(id); |
209 | if ( t ) { | 209 | if ( t ) { |
210 | stack->removeWidget( t->view ); | 210 | stack->removeWidget( t->view ); |
211 | delete t->view; | 211 | delete t->view; |
212 | categoryBar->removeTab( t ); | 212 | categoryBar->removeTab( t ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 216 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
217 | { | 217 | { |
218 | LauncherView* view = new LauncherView( stack ); | 218 | LauncherView* view = new LauncherView( stack ); |
219 | connect( view, SIGNAL(clicked(const AppLnk*)), | 219 | connect( view, SIGNAL(clicked(const AppLnk*)), |
220 | this, SIGNAL(clicked(const AppLnk*))); | 220 | this, SIGNAL(clicked(const AppLnk*))); |
221 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 221 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
222 | this, SIGNAL(rightPressed(AppLnk*))); | 222 | this, SIGNAL(rightPressed(AppLnk*))); |
223 | 223 | ||
224 | int n = categoryBar->count(); | 224 | int n = categoryBar->count(); |
225 | stack->addWidget( view, n ); | 225 | stack->addWidget( view, n ); |
226 | 226 | ||
227 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); | 227 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); |
228 | categoryBar->insertTab( tab, n-1 ); | 228 | categoryBar->insertTab( tab, n-1 ); |
229 | 229 | ||
230 | if ( id == "Documents" ) | 230 | if ( id == "Documents" ) |
231 | docview = view; | 231 | docview = view; |
232 | 232 | ||
233 | qDebug("inserting %s at %d", id.latin1(), n-1 ); | 233 | qDebug("inserting %s at %d", id.latin1(), n-1 ); |
234 | 234 | ||
235 | Config cfg("Launcher"); | 235 | Config cfg("Launcher"); |
236 | setTabAppearance( tab, cfg ); | 236 | setTabAppearance( tab, cfg ); |
237 | 237 | ||
238 | cfg.setGroup( "GUI" ); | 238 | cfg.setGroup( "GUI" ); |
239 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); | 239 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); |
240 | 240 | ||
241 | return view; | 241 | return view; |
242 | } | 242 | } |
243 | 243 | ||
244 | LauncherView *LauncherTabWidget::view( const QString &id ) | 244 | LauncherView *LauncherTabWidget::view( const QString &id ) |
245 | { | 245 | { |
246 | LauncherTab *t = categoryBar->launcherTab(id); | 246 | LauncherTab *t = categoryBar->launcherTab(id); |
247 | if ( !t ) | 247 | if ( !t ) |
248 | return 0; | 248 | return 0; |
249 | return t->view; | 249 | return t->view; |
250 | } | 250 | } |
251 | 251 | ||
252 | LauncherView *LauncherTabWidget::docView() | 252 | LauncherView *LauncherTabWidget::docView() |
253 | { | 253 | { |
254 | return docview; | 254 | return docview; |
255 | } | 255 | } |
256 | 256 | ||
257 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) | 257 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) |
258 | { | 258 | { |
259 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { | 259 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { |
260 | docLoadingWidgetEnabled = v; | 260 | docLoadingWidgetEnabled = v; |
261 | raiseTabWidget(); | 261 | raiseTabWidget(); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | void LauncherTabWidget::setLoadingProgress( int percent ) | 265 | void LauncherTabWidget::setLoadingProgress( int percent ) |
266 | { | 266 | { |
267 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); | 267 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | // ### this function could more to LauncherView | 270 | // ### this function could more to LauncherView |
271 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) | 271 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) |
272 | { | 272 | { |
273 | // View | 273 | // View |
274 | QString view = cfg.readEntry( "View", "Icon" ); | 274 | QString view = cfg.readEntry( "View", "Icon" ); |
275 | if ( view == "List" ) // No tr | 275 | if ( view == "List" ) // No tr |
276 | v->setViewMode( LauncherView::List ); | 276 | v->setViewMode( LauncherView::List ); |
277 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 277 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
278 | if ( bgType == "Image" ) { // No tr | 278 | if ( bgType == "Image" ) { // No tr |
279 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 279 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
280 | v->setBackgroundType( LauncherView::Image, pm ); | 280 | v->setBackgroundType( LauncherView::Image, pm ); |
281 | } else if ( bgType == "SolidColor" ) { | 281 | } else if ( bgType == "SolidColor" ) { |
282 | QString c = cfg.readEntry( "BackgroundColor" ); | 282 | QString c = cfg.readEntry( "BackgroundColor" ); |
283 | v->setBackgroundType( LauncherView::SolidColor, c ); | 283 | v->setBackgroundType( LauncherView::SolidColor, c ); |
284 | } else { | 284 | } else { |
285 | v->setBackgroundType( LauncherView::Ruled, QString::null ); | 285 | v->setBackgroundType( LauncherView::Ruled, QString::null ); |
286 | } | 286 | } |
287 | QString textCol = cfg.readEntry( "TextColor" ); | 287 | QString textCol = cfg.readEntry( "TextColor" ); |
288 | if ( textCol.isEmpty() ) | 288 | if ( textCol.isEmpty() ) |
289 | v->setTextColor( QColor() ); | 289 | v->setTextColor( QColor() ); |
290 | else | 290 | else |
291 | v->setTextColor( QColor(textCol) ); | 291 | v->setTextColor( QColor(textCol) ); |
292 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); | 292 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); |
293 | 293 | ||
294 | 294 | ||
295 | QStringList font = cfg.readListEntry( "Font", ',' ); | 295 | QStringList font = cfg.readListEntry( "Font", ',' ); |
296 | if ( font.count() == 4 ) | 296 | if ( font.count() == 4 ) |
297 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 297 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
298 | 298 | ||
299 | // ### FIXME TabColor TabTextColor | 299 | // ### FIXME TabColor TabTextColor |
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | // ### Could move to LauncherTab | 303 | // ### Could move to LauncherTab |
304 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) | 304 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) |
305 | { | 305 | { |
306 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr | 306 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr |
307 | 307 | ||
308 | setTabViewAppearance( tab->view, cfg ); | 308 | setTabViewAppearance( tab->view, cfg ); |
309 | 309 | ||
310 | // Tabs | 310 | // Tabs |
311 | QString tabCol = cfg.readEntry( "TabColor" ); | 311 | QString tabCol = cfg.readEntry( "TabColor" ); |
312 | if ( tabCol.isEmpty() ) | 312 | if ( tabCol.isEmpty() ) |
313 | tab->bgColor = QColor(); | 313 | tab->bgColor = QColor(); |
314 | else | 314 | else |
315 | tab->bgColor = QColor(tabCol); | 315 | tab->bgColor = QColor(tabCol); |
316 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 316 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
317 | if ( tabTextCol.isEmpty() ) | 317 | if ( tabTextCol.isEmpty() ) |
318 | tab->fgColor = QColor(); | 318 | tab->fgColor = QColor(); |
319 | else | 319 | else |
320 | tab->fgColor = QColor(tabTextCol); | 320 | tab->fgColor = QColor(tabTextCol); |
321 | } | 321 | } |
322 | 322 | ||
323 | void LauncherTabWidget::paletteChange( const QPalette &p ) | 323 | void LauncherTabWidget::paletteChange( const QPalette &p ) |
324 | { | 324 | { |
325 | QVBox::paletteChange( p ); | 325 | QVBox::paletteChange( p ); |
326 | QPalette pal = palette(); | 326 | QPalette pal = palette(); |
327 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 327 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
328 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 328 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
329 | categoryBar->setPalette( pal ); | 329 | categoryBar->setPalette( pal ); |
330 | categoryBar->update(); | 330 | categoryBar->update(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void LauncherTabWidget::styleChange( QStyle & ) | 333 | void LauncherTabWidget::styleChange( QStyle & ) |
334 | { | 334 | { |
335 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); | 335 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void LauncherTabWidget::setProgressStyle() | 338 | void LauncherTabWidget::setProgressStyle() |
339 | { | 339 | { |
340 | if (docLoadingWidgetProgress) { | 340 | if (docLoadingWidgetProgress) { |
341 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); | 341 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); |
342 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); | 342 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); |
343 | docLoadingWidgetProgress->setMargin( 1 ); | 343 | docLoadingWidgetProgress->setMargin( 1 ); |
344 | docLoadingWidgetProgress->setLineWidth( 1 ); | 344 | docLoadingWidgetProgress->setLineWidth( 1 ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void LauncherTabWidget::setBusy(bool on) | 348 | void LauncherTabWidget::setBusy(bool on) |
349 | { | 349 | { |
350 | if ( on ) | 350 | if ( on ) |
351 | currentView()->setBusy(TRUE); | 351 | currentView()->setBusy(TRUE); |
352 | else { | 352 | else { |
353 | for ( int i = 0; i < categoryBar->count(); i++ ) { | 353 | for ( int i = 0; i < categoryBar->count(); i++ ) { |
354 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; | 354 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; |
355 | view->setBusy( FALSE ); | 355 | view->setBusy( FALSE ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { | 360 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { |
361 | for (int i = 0; i < categoryBar->count(); i++ ) { | 361 | for (int i = 0; i < categoryBar->count(); i++ ) { |
362 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 362 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
363 | view->setBusyIndicatorType( str ); | 363 | view->setBusyIndicatorType( str ); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | LauncherView *LauncherTabWidget::currentView(void) | 367 | LauncherView *LauncherTabWidget::currentView(void) |
368 | { | 368 | { |
369 | return (LauncherView*)stack->visibleWidget(); | 369 | return (LauncherView*)stack->visibleWidget(); |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | 373 | ||
374 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) | 374 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) |
375 | { | 375 | { |
376 | QDataStream stream( data, IO_ReadOnly ); | 376 | QDataStream stream( data, IO_ReadOnly ); |
377 | if ( msg == "setTabView(QString,int)" ) { | 377 | if ( msg == "setTabView(QString,int)" ) { |
378 | QString id; | 378 | QString id; |
379 | stream >> id; | 379 | stream >> id; |
380 | int mode; | 380 | int mode; |
381 | stream >> mode; | 381 | stream >> mode; |
382 | if ( view(id) ) | 382 | if ( view(id) ) |
383 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 383 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
384 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 384 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
385 | QString id; | 385 | QString id; |
386 | stream >> id; | 386 | stream >> id; |
387 | int mode; | 387 | int mode; |
388 | stream >> mode; | 388 | stream >> mode; |
389 | QString pixmapOrColor; | 389 | QString pixmapOrColor; |
390 | stream >> pixmapOrColor; | 390 | stream >> pixmapOrColor; |
391 | if ( view(id) ) | 391 | if ( view(id) ) |
392 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 392 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
393 | if ( id == "Documents" ) | 393 | if ( id == "Documents" ) |
394 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 394 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
395 | } else if ( msg == "setTextColor(QString,QString)" ) { | 395 | } else if ( msg == "setTextColor(QString,QString)" ) { |
396 | QString id; | 396 | QString id; |
397 | stream >> id; | 397 | stream >> id; |
398 | QString color; | 398 | QString color; |
399 | stream >> color; | 399 | stream >> color; |
400 | if ( view(id) ) | 400 | if ( view(id) ) |
401 | view(id)->setTextColor( QColor(color) ); | 401 | view(id)->setTextColor( QColor(color) ); |
402 | if ( id == "Documents" ) | 402 | if ( id == "Documents" ) |
403 | docLoadingWidget->setTextColor( QColor(color) ); | 403 | docLoadingWidget->setTextColor( QColor(color) ); |
404 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 404 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
405 | QString id; | 405 | QString id; |
406 | stream >> id; | 406 | stream >> id; |
407 | QString fam; | 407 | QString fam; |
408 | stream >> fam; | 408 | stream >> fam; |
409 | int size; | 409 | int size; |
410 | stream >> size; | 410 | stream >> size; |
411 | int weight; | 411 | int weight; |
412 | stream >> weight; | 412 | stream >> weight; |
413 | int italic; | 413 | int italic; |
414 | stream >> italic; | 414 | stream >> italic; |
415 | if ( view(id) ) { | 415 | if ( view(id) ) { |
416 | if ( !fam.isEmpty() ) { | 416 | if ( !fam.isEmpty() ) { |
417 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 417 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
418 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 418 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
419 | } else { | 419 | } else { |
420 | view(id)->clearViewFont(); | 420 | view(id)->clearViewFont(); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 423 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
424 | QString type; | 424 | QString type; |
425 | stream >> type; | 425 | stream >> type; |
426 | setBusyIndicatorType( type ); | 426 | setBusyIndicatorType( type ); |
427 | }else if ( msg == "home()" ) { | 427 | }else if ( msg == "home()" ) { |
428 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 428 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
429 | if (categoryBar) | 429 | if (categoryBar) |
430 | categoryBar->nextTab(); | 430 | categoryBar->nextTab(); |
431 | }else | 431 | }else |
432 | static_cast<QWidget*>(parent())->raise(); | 432 | static_cast<QWidget*>(parent())->raise(); |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | //--------------------------------------------------------------------------- | 438 | //--------------------------------------------------------------------------- |
439 | 439 | ||
440 | Launcher::Launcher() | 440 | Launcher::Launcher() |
441 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 441 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
442 | { | 442 | { |
443 | tabs = 0; | 443 | tabs = 0; |
444 | tb = 0; | 444 | tb = 0; |
445 | Config cfg( "Launcher" ); | 445 | Config cfg( "Launcher" ); |
446 | cfg.setGroup( "DocTab" ); | 446 | cfg.setGroup( "DocTab" ); |
447 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 447 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void Launcher::createGUI() | 450 | void Launcher::createGUI() |
451 | { | 451 | { |
452 | setCaption( tr("Launcher") ); | 452 | setCaption( tr("Launcher") ); |
453 | 453 | ||
454 | // we have a pretty good idea how big we'll be | 454 | // we have a pretty good idea how big we'll be |
455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
456 | 456 | ||
457 | tb = new TaskBar; | 457 | tb = new TaskBar; |
458 | tabs = new LauncherTabWidget( this ); | 458 | tabs = new LauncherTabWidget( this ); |
459 | setCentralWidget( tabs ); | 459 | setCentralWidget( tabs ); |
460 | 460 | ||
461 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 461 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
462 | tb->show(); | 462 | tb->show(); |
463 | 463 | ||
464 | qApp->installEventFilter( this ); | 464 | qApp->installEventFilter( this ); |
465 | 465 | ||
466 | 466 | ||
467 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 467 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
468 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 468 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
469 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 469 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
470 | 470 | ||
471 | connect( tb, SIGNAL(tabSelected(const QString&)), | 471 | connect( tb, SIGNAL(tabSelected(const QString&)), |
472 | this, SLOT(showTab(const QString&)) ); | 472 | this, SLOT(showTab(const QString&)) ); |
473 | connect( tabs, SIGNAL(selected(const QString&)), | 473 | connect( tabs, SIGNAL(selected(const QString&)), |
474 | this, SLOT(viewSelected(const QString&)) ); | 474 | this, SLOT(viewSelected(const QString&)) ); |
475 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 475 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
476 | this, SLOT(select(const AppLnk*))); | 476 | this, SLOT(select(const AppLnk*))); |
477 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 477 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
478 | this, SLOT(properties(AppLnk*))); | 478 | this, SLOT(properties(AppLnk*))); |
479 | 479 | ||
480 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 480 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
481 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 481 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
482 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 482 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
483 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 483 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
484 | #endif | 484 | #endif |
485 | 485 | ||
486 | // all documents | 486 | // all documents |
487 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 487 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
488 | QPixmap pm; | 488 | QPixmap pm; |
489 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 489 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
490 | // It could add this itself if it handles docs | 490 | // It could add this itself if it handles docs |
491 | 491 | ||
492 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 492 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
493 | 493 | ||
494 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 494 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
495 | qApp->setMainWidget( this ); | 495 | qApp->setMainWidget( this ); |
496 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 496 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
497 | } | 497 | } |
498 | 498 | ||
499 | Launcher::~Launcher() | 499 | Launcher::~Launcher() |
500 | { | 500 | { |
501 | if ( tb ) | 501 | if ( tb ) |
502 | destroyGUI(); | 502 | destroyGUI(); |
503 | } | 503 | } |
504 | 504 | ||
505 | bool Launcher::requiresDocuments() const | 505 | bool Launcher::requiresDocuments() const |
506 | { | 506 | { |
507 | Config cfg( "Launcher" ); | 507 | Config cfg( "Launcher" ); |
508 | cfg.setGroup( "DocTab" ); | 508 | cfg.setGroup( "DocTab" ); |
509 | return cfg.readBoolEntry( "Enable", true ); | 509 | return cfg.readBoolEntry( "Enable", true ); |
510 | } | 510 | } |
511 | 511 | ||
512 | void Launcher::makeVisible() | 512 | void Launcher::makeVisible() |
513 | { | 513 | { |
514 | showMaximized(); | 514 | showMaximized(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Launcher::destroyGUI() | 517 | void Launcher::destroyGUI() |
518 | { | 518 | { |
519 | delete tb; | 519 | delete tb; |
520 | tb = 0; | 520 | tb = 0; |
521 | delete tabs; | 521 | delete tabs; |
522 | tabs =0; | 522 | tabs =0; |
523 | } | 523 | } |
524 | 524 | ||
525 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 525 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
526 | { | 526 | { |
527 | #ifdef QT_QWS_CUSTOM | 527 | #ifdef QT_QWS_CUSTOM |
528 | if ( ev->type() == QEvent::KeyPress ) { | 528 | if ( ev->type() == QEvent::KeyPress ) { |
529 | QKeyEvent *ke = (QKeyEvent *)ev; | 529 | QKeyEvent *ke = (QKeyEvent *)ev; |
530 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 530 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
531 | QWidget *active = qApp->activeWindow(); | 531 | QWidget *active = qApp->activeWindow(); |
532 | if ( active && active->isPopup() ) | 532 | if ( active && active->isPopup() ) |
533 | active->close(); | 533 | active->close(); |
534 | else { | 534 | else { |
535 | Global::terminateBuiltin("calibrate"); // No tr | 535 | Global::terminateBuiltin("calibrate"); // No tr |
536 | tb->launchStartMenu(); | 536 | tb->launchStartMenu(); |
537 | } | 537 | } |
538 | return TRUE; | 538 | return TRUE; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | #else | 541 | #else |
542 | Q_UNUSED(ev); | 542 | Q_UNUSED(ev); |
543 | #endif | 543 | #endif |
544 | return FALSE; | 544 | return FALSE; |
545 | } | 545 | } |
546 | 546 | ||
547 | void Launcher::toggleSymbolInput() | 547 | void Launcher::toggleSymbolInput() |
548 | { | 548 | { |
549 | tb->toggleSymbolInput(); | 549 | tb->toggleSymbolInput(); |
550 | } | 550 | } |
551 | 551 | ||
552 | void Launcher::toggleNumLockState() | 552 | void Launcher::toggleNumLockState() |
553 | { | 553 | { |
554 | tb->toggleNumLockState(); | 554 | tb->toggleNumLockState(); |
555 | } | 555 | } |
556 | 556 | ||
557 | void Launcher::toggleCapsLockState() | 557 | void Launcher::toggleCapsLockState() |
558 | { | 558 | { |
559 | tb->toggleCapsLockState(); | 559 | tb->toggleCapsLockState(); |
560 | } | 560 | } |
561 | 561 | ||
562 | static bool isVisibleWindow(int wid) | 562 | static bool isVisibleWindow(int wid) |
563 | { | 563 | { |
564 | #ifdef Q_WS_QWS | 564 | #ifdef Q_WS_QWS |
565 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 565 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
566 | QWSWindow* w; | 566 | QWSWindow* w; |
567 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 567 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
568 | if ( w->winId() == wid ) | 568 | if ( w->winId() == wid ) |
569 | return !w->isFullyObscured(); | 569 | return !w->isFullyObscured(); |
570 | } | 570 | } |
571 | #endif | 571 | #endif |
572 | return FALSE; | 572 | return FALSE; |
573 | } | 573 | } |
574 | 574 | ||
575 | void Launcher::viewSelected(const QString& s) | 575 | void Launcher::viewSelected(const QString& s) |
576 | { | 576 | { |
577 | setCaption( s + tr(" - Launcher") ); | 577 | setCaption( s + tr(" - Launcher") ); |
578 | } | 578 | } |
579 | 579 | ||
580 | void Launcher::showTab(const QString& id) | 580 | void Launcher::showTab(const QString& id) |
581 | { | 581 | { |
582 | tabs->categoryBar->showTab(id); | 582 | tabs->categoryBar->showTab(id); |
583 | raise(); | 583 | raise(); |
584 | } | 584 | } |
585 | 585 | ||
586 | void Launcher::select( const AppLnk *appLnk ) | 586 | void Launcher::select( const AppLnk *appLnk ) |
587 | { | 587 | { |
588 | if ( appLnk->type() == "Folder" ) { // No tr | 588 | if ( appLnk->type() == "Folder" ) { // No tr |
589 | // Not supported: flat is simpler for the user | 589 | // Not supported: flat is simpler for the user |
590 | } else { | 590 | } else { |
591 | if ( appLnk->exec().isNull() ) { | 591 | if ( appLnk->exec().isNull() ) { |
592 | int i = QMessageBox::information(this,tr("No application"), | 592 | int i = QMessageBox::information(this,tr("No application"), |
593 | tr("<p>No application is defined for this document." | 593 | tr("<p>No application is defined for this document." |
594 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 594 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
595 | 595 | ||
596 | /* ### Fixme */ | 596 | /* ### Fixme */ |
597 | if ( i == 1 ) | 597 | if ( i == 1 ) |
598 | Global::execute("textedit",appLnk->file()); | 598 | Global::execute("textedit",appLnk->file()); |
599 | 599 | ||
600 | return; | 600 | return; |
601 | } | 601 | } |
602 | tabs->setBusy(TRUE); | 602 | tabs->setBusy(TRUE); |
603 | emit executing( appLnk ); | 603 | emit executing( appLnk ); |
604 | appLnk->execute(); | 604 | appLnk->execute(); |
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | void Launcher::properties( AppLnk *appLnk ) | 608 | void Launcher::properties( AppLnk *appLnk ) |
609 | { | 609 | { |
610 | if ( appLnk->type() == "Folder" ) { // No tr | 610 | if ( appLnk->type() == "Folder" ) { // No tr |
611 | // Not supported: flat is simpler for the user | 611 | // Not supported: flat is simpler for the user |
612 | } else { | 612 | } else { |
613 | /* ### libqtopia FIXME also moving docLnks... */ | 613 | /* ### libqtopia FIXME also moving docLnks... */ |
614 | LnkProperties prop(appLnk,0 ); | 614 | LnkProperties prop(appLnk,0 ); |
615 | 615 | ||
616 | prop.showMaximized(); | 616 | QPEApplication::execDialog( &prop ); |
617 | prop.exec(); | ||
618 | } | 617 | } |
619 | } | 618 | } |
620 | 619 | ||
621 | void Launcher::storageChanged( const QList<FileSystem> &fs ) | 620 | void Launcher::storageChanged( const QList<FileSystem> &fs ) |
622 | { | 621 | { |
623 | // ### update combo boxes if we had a combo box for the storage type | 622 | // ### update combo boxes if we had a combo box for the storage type |
624 | } | 623 | } |
625 | 624 | ||
626 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 625 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
627 | { | 626 | { |
628 | QDataStream stream( data, IO_ReadOnly ); | 627 | QDataStream stream( data, IO_ReadOnly ); |
629 | if ( msg == "busy()" ) { | 628 | if ( msg == "busy()" ) { |
630 | tb->startWait(); | 629 | tb->startWait(); |
631 | } else if ( msg == "notBusy(QString)" ) { | 630 | } else if ( msg == "notBusy(QString)" ) { |
632 | QString app; | 631 | QString app; |
633 | stream >> app; | 632 | stream >> app; |
634 | tabs->setBusy(FALSE); | 633 | tabs->setBusy(FALSE); |
635 | tb->stopWait(app); | 634 | tb->stopWait(app); |
636 | } else if (msg == "applyStyle()") { | 635 | } else if (msg == "applyStyle()") { |
637 | tabs->currentView()->relayout(); | 636 | tabs->currentView()->relayout(); |
638 | } | 637 | } |
639 | } | 638 | } |
640 | 639 | ||
641 | // These are the update functions from the server | 640 | // These are the update functions from the server |
642 | void Launcher::typeAdded( const QString& type, const QString& name, | 641 | void Launcher::typeAdded( const QString& type, const QString& name, |
643 | const QPixmap& pixmap, const QPixmap& ) | 642 | const QPixmap& pixmap, const QPixmap& ) |
644 | { | 643 | { |
645 | tabs->newView( type, pixmap, name ); | 644 | tabs->newView( type, pixmap, name ); |
646 | ids.append( type ); | 645 | ids.append( type ); |
647 | tb->refreshStartMenu(); | 646 | tb->refreshStartMenu(); |
648 | 647 | ||
649 | static bool first = TRUE; | 648 | static bool first = TRUE; |
650 | if ( first ) { | 649 | if ( first ) { |
651 | first = FALSE; | 650 | first = FALSE; |
652 | tabs->categoryBar->showTab(type); | 651 | tabs->categoryBar->showTab(type); |
653 | } | 652 | } |
654 | 653 | ||
655 | tabs->view( type )->setUpdatesEnabled( FALSE ); | 654 | tabs->view( type )->setUpdatesEnabled( FALSE ); |
656 | tabs->view( type )->setSortEnabled( FALSE ); | 655 | tabs->view( type )->setSortEnabled( FALSE ); |
657 | } | 656 | } |
658 | 657 | ||
659 | void Launcher::typeRemoved( const QString& type ) | 658 | void Launcher::typeRemoved( const QString& type ) |
660 | { | 659 | { |
661 | tabs->view( type )->removeAllItems(); | 660 | tabs->view( type )->removeAllItems(); |
662 | tabs->deleteView( type ); | 661 | tabs->deleteView( type ); |
663 | ids.remove( type ); | 662 | ids.remove( type ); |
664 | tb->refreshStartMenu(); | 663 | tb->refreshStartMenu(); |
665 | } | 664 | } |
666 | 665 | ||
667 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) | 666 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) |
668 | { | 667 | { |
669 | if ( app.type() == "Separator" ) // No tr | 668 | if ( app.type() == "Separator" ) // No tr |
670 | return; | 669 | return; |
671 | 670 | ||
672 | LauncherView *view = tabs->view( type ); | 671 | LauncherView *view = tabs->view( type ); |
673 | if ( view ) | 672 | if ( view ) |
674 | view->addItem( new AppLnk( app ), FALSE ); | 673 | view->addItem( new AppLnk( app ), FALSE ); |
675 | else | 674 | else |
676 | qWarning("addAppLnk: No view for type %s. Can't add app %s!", | 675 | qWarning("addAppLnk: No view for type %s. Can't add app %s!", |
677 | type.latin1(),app.name().latin1() ); | 676 | type.latin1(),app.name().latin1() ); |
678 | 677 | ||
679 | MimeType::registerApp( app ); | 678 | MimeType::registerApp( app ); |
680 | } | 679 | } |
681 | 680 | ||
682 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) | 681 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) |
683 | { | 682 | { |
684 | LauncherView *view = tabs->view( type ); | 683 | LauncherView *view = tabs->view( type ); |
685 | if ( view ) | 684 | if ( view ) |
686 | view->removeLink( app.linkFile() ); | 685 | view->removeLink( app.linkFile() ); |
687 | else | 686 | else |
688 | qWarning("removeAppLnk: No view for %s!", type.latin1() ); | 687 | qWarning("removeAppLnk: No view for %s!", type.latin1() ); |
689 | } | 688 | } |
690 | 689 | ||
691 | void Launcher::allApplicationsRemoved() | 690 | void Launcher::allApplicationsRemoved() |
692 | { | 691 | { |
693 | MimeType::clear(); | 692 | MimeType::clear(); |
694 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) | 693 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) |
695 | tabs->view( (*it) )->removeAllItems(); | 694 | tabs->view( (*it) )->removeAllItems(); |
696 | } | 695 | } |
697 | 696 | ||
698 | void Launcher::documentAdded( const DocLnk& doc ) | 697 | void Launcher::documentAdded( const DocLnk& doc ) |
699 | { | 698 | { |
700 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); | 699 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); |
701 | } | 700 | } |
702 | 701 | ||
703 | void Launcher::showLoadingDocs() | 702 | void Launcher::showLoadingDocs() |
704 | { | 703 | { |
705 | tabs->docView()->hide(); | 704 | tabs->docView()->hide(); |
706 | } | 705 | } |
707 | 706 | ||
708 | void Launcher::showDocTab() | 707 | void Launcher::showDocTab() |
709 | { | 708 | { |
710 | if ( tabs->categoryBar->currentView() == tabs->docView() ) | 709 | if ( tabs->categoryBar->currentView() == tabs->docView() ) |
711 | tabs->docView()->show(); | 710 | tabs->docView()->show(); |
712 | } | 711 | } |
713 | 712 | ||
714 | void Launcher::documentRemoved( const DocLnk& doc ) | 713 | void Launcher::documentRemoved( const DocLnk& doc ) |
715 | { | 714 | { |
716 | tabs->docView()->removeLink( doc.linkFile() ); | 715 | tabs->docView()->removeLink( doc.linkFile() ); |
717 | } | 716 | } |
718 | 717 | ||
719 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) | 718 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) |
720 | { | 719 | { |
721 | documentRemoved( oldDoc ); | 720 | documentRemoved( oldDoc ); |
722 | documentAdded( newDoc ); | 721 | documentAdded( newDoc ); |
723 | } | 722 | } |
724 | 723 | ||
725 | void Launcher::allDocumentsRemoved() | 724 | void Launcher::allDocumentsRemoved() |
726 | { | 725 | { |
727 | tabs->docView()->removeAllItems(); | 726 | tabs->docView()->removeAllItems(); |
728 | } | 727 | } |
729 | 728 | ||
730 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) | 729 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) |
731 | { | 730 | { |
732 | tb->setApplicationState( name, state ); | 731 | tb->setApplicationState( name, state ); |
733 | } | 732 | } |
734 | 733 | ||
735 | void Launcher::applicationScanningProgress( int percent ) | 734 | void Launcher::applicationScanningProgress( int percent ) |
736 | { | 735 | { |
737 | switch ( percent ) { | 736 | switch ( percent ) { |
738 | case 0: { | 737 | case 0: { |
739 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 738 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
740 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); | 739 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); |
741 | tabs->view( (*it) )->setSortEnabled( FALSE ); | 740 | tabs->view( (*it) )->setSortEnabled( FALSE ); |
742 | } | 741 | } |
743 | break; | 742 | break; |
744 | } | 743 | } |
745 | case 100: { | 744 | case 100: { |
746 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 745 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
747 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); | 746 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); |
748 | tabs->view( (*it) )->setSortEnabled( TRUE ); | 747 | tabs->view( (*it) )->setSortEnabled( TRUE ); |
749 | } | 748 | } |
750 | break; | 749 | break; |
751 | } | 750 | } |
752 | default: | 751 | default: |
753 | break; | 752 | break; |
754 | } | 753 | } |
755 | } | 754 | } |
756 | 755 | ||
757 | void Launcher::documentScanningProgress( int percent ) | 756 | void Launcher::documentScanningProgress( int percent ) |
758 | { | 757 | { |
759 | switch ( percent ) { | 758 | switch ( percent ) { |
760 | case 0: { | 759 | case 0: { |
761 | tabs->setLoadingProgress( 0 ); | 760 | tabs->setLoadingProgress( 0 ); |
762 | tabs->setLoadingWidgetEnabled( TRUE ); | 761 | tabs->setLoadingWidgetEnabled( TRUE ); |
763 | tabs->docView()->setUpdatesEnabled( FALSE ); | 762 | tabs->docView()->setUpdatesEnabled( FALSE ); |
764 | tabs->docView()->setSortEnabled( FALSE ); | 763 | tabs->docView()->setSortEnabled( FALSE ); |
765 | break; | 764 | break; |
766 | } | 765 | } |
767 | case 100: { | 766 | case 100: { |
768 | tabs->docView()->updateTools(); | 767 | tabs->docView()->updateTools(); |
769 | tabs->docView()->setSortEnabled( TRUE ); | 768 | tabs->docView()->setSortEnabled( TRUE ); |
770 | tabs->docView()->setUpdatesEnabled( TRUE ); | 769 | tabs->docView()->setUpdatesEnabled( TRUE ); |
771 | tabs->setLoadingWidgetEnabled( FALSE ); | 770 | tabs->setLoadingWidgetEnabled( FALSE ); |
772 | break; | 771 | break; |
773 | } | 772 | } |
774 | default: | 773 | default: |
775 | tabs->setLoadingProgress( percent ); | 774 | tabs->setLoadingProgress( percent ); |
776 | break; | 775 | break; |
777 | } | 776 | } |
778 | } | 777 | } |
779 | 778 | ||
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index e8d49fd..e18bcee 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -1,850 +1,850 @@ | |||
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 "serverapp.h" | 21 | #include "serverapp.h" |
22 | 22 | ||
23 | #include <opie/odevice.h> | 23 | #include <opie/odevice.h> |
24 | 24 | ||
25 | #include <qtopia/password.h> | 25 | #include <qtopia/password.h> |
26 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
27 | #include <qtopia/power.h> | 27 | #include <qtopia/power.h> |
28 | 28 | ||
29 | #ifdef Q_WS_QWS | 29 | #ifdef Q_WS_QWS |
30 | #include <qtopia/qcopenvelope_qws.h> | 30 | #include <qtopia/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | #include <qtopia/global.h> | 32 | #include <qtopia/global.h> |
33 | //#include <qtopia/custom.h> | 33 | //#include <qtopia/custom.h> |
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #endif | 37 | #endif |
38 | #ifdef Q_OS_WIN32 | 38 | #ifdef Q_OS_WIN32 |
39 | #include <io.h> | 39 | #include <io.h> |
40 | #include <process.h> | 40 | #include <process.h> |
41 | #else | 41 | #else |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #endif | 43 | #endif |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qpixmapcache.h> | 48 | #include <qpixmapcache.h> |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include "screensaver.h" | 51 | #include "screensaver.h" |
52 | 52 | ||
53 | static ServerApplication *serverApp = 0; | 53 | static ServerApplication *serverApp = 0; |
54 | static int loggedin=0; | 54 | static int loggedin=0; |
55 | 55 | ||
56 | using namespace Opie; | 56 | using namespace Opie; |
57 | 57 | ||
58 | QCopKeyRegister::QCopKeyRegister() | 58 | QCopKeyRegister::QCopKeyRegister() |
59 | : m_keyCode( 0 ) { | 59 | : m_keyCode( 0 ) { |
60 | } | 60 | } |
61 | 61 | ||
62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { | 63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { |
64 | } | 64 | } |
65 | 65 | ||
66 | int QCopKeyRegister::keyCode()const { | 66 | int QCopKeyRegister::keyCode()const { |
67 | return m_keyCode; | 67 | return m_keyCode; |
68 | } | 68 | } |
69 | 69 | ||
70 | QCString QCopKeyRegister::channel()const { | 70 | QCString QCopKeyRegister::channel()const { |
71 | return m_channel; | 71 | return m_channel; |
72 | } | 72 | } |
73 | 73 | ||
74 | QCString QCopKeyRegister::message()const { | 74 | QCString QCopKeyRegister::message()const { |
75 | return m_message; | 75 | return m_message; |
76 | } | 76 | } |
77 | 77 | ||
78 | bool QCopKeyRegister::send() { | 78 | bool QCopKeyRegister::send() { |
79 | if (m_channel.isNull() ) | 79 | if (m_channel.isNull() ) |
80 | return false; | 80 | return false; |
81 | 81 | ||
82 | QCopEnvelope( m_channel, m_message ); | 82 | QCopEnvelope( m_channel, m_message ); |
83 | 83 | ||
84 | return true; | 84 | return true; |
85 | } | 85 | } |
86 | 86 | ||
87 | //--------------------------------------------------------------------------- | 87 | //--------------------------------------------------------------------------- |
88 | 88 | ||
89 | /* | 89 | /* |
90 | Priority is number of alerts that are needed to pop up | 90 | Priority is number of alerts that are needed to pop up |
91 | alert. | 91 | alert. |
92 | */ | 92 | */ |
93 | class DesktopPowerAlerter : public QMessageBox | 93 | class DesktopPowerAlerter : public QMessageBox |
94 | { | 94 | { |
95 | Q_OBJECT | 95 | Q_OBJECT |
96 | public: | 96 | public: |
97 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 97 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
98 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 98 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
99 | QMessageBox::Critical, | 99 | QMessageBox::Critical, |
100 | QMessageBox::Ok | QMessageBox::Default, | 100 | QMessageBox::Ok | QMessageBox::Default, |
101 | QMessageBox::NoButton, QMessageBox::NoButton, | 101 | QMessageBox::NoButton, QMessageBox::NoButton, |
102 | parent, name, FALSE ) | 102 | parent, name, FALSE ) |
103 | { | 103 | { |
104 | currentPriority = INT_MAX; | 104 | currentPriority = INT_MAX; |
105 | alertCount = 0; | 105 | alertCount = 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | void alert( const QString &text, int priority ); | 108 | void alert( const QString &text, int priority ); |
109 | void hideEvent( QHideEvent * ); | 109 | void hideEvent( QHideEvent * ); |
110 | private: | 110 | private: |
111 | int currentPriority; | 111 | int currentPriority; |
112 | int alertCount; | 112 | int alertCount; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
116 | { | 116 | { |
117 | alertCount++; | 117 | alertCount++; |
118 | if ( alertCount < priority ) | 118 | if ( alertCount < priority ) |
119 | return; | 119 | return; |
120 | if ( priority > currentPriority ) | 120 | if ( priority > currentPriority ) |
121 | return; | 121 | return; |
122 | currentPriority = priority; | 122 | currentPriority = priority; |
123 | setText( text ); | 123 | setText( text ); |
124 | show(); | 124 | show(); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
129 | { | 129 | { |
130 | QMessageBox::hideEvent( e ); | 130 | QMessageBox::hideEvent( e ); |
131 | alertCount = 0; | 131 | alertCount = 0; |
132 | currentPriority = INT_MAX; | 132 | currentPriority = INT_MAX; |
133 | } | 133 | } |
134 | 134 | ||
135 | //--------------------------------------------------------------------------- | 135 | //--------------------------------------------------------------------------- |
136 | 136 | ||
137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
138 | { | 138 | { |
139 | /* We don't do this cause it would interfere with ODevice */ | 139 | /* We don't do this cause it would interfere with ODevice */ |
140 | #if 0 | 140 | #if 0 |
141 | qwsServer->setKeyboardFilter(this); | 141 | qwsServer->setKeyboardFilter(this); |
142 | #endif | 142 | #endif |
143 | } | 143 | } |
144 | 144 | ||
145 | void KeyFilter::timerEvent(QTimerEvent* e) | 145 | void KeyFilter::timerEvent(QTimerEvent* e) |
146 | { | 146 | { |
147 | if ( e->timerId() == held_tid ) { | 147 | if ( e->timerId() == held_tid ) { |
148 | killTimer(held_tid); | 148 | killTimer(held_tid); |
149 | // button held | 149 | // button held |
150 | if ( heldButton ) { | 150 | if ( heldButton ) { |
151 | emit activate(heldButton, TRUE); | 151 | emit activate(heldButton, TRUE); |
152 | heldButton = 0; | 152 | heldButton = 0; |
153 | } | 153 | } |
154 | held_tid = 0; | 154 | held_tid = 0; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
159 | m_keys.insert( key.keyCode(), key ); | 159 | m_keys.insert( key.keyCode(), key ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
163 | m_keys.remove( key.keyCode() ); | 163 | m_keys.remove( key.keyCode() ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool KeyFilter::keyRegistered( int key ) { | 166 | bool KeyFilter::keyRegistered( int key ) { |
167 | /* | 167 | /* |
168 | * Check if we've a key registered | 168 | * Check if we've a key registered |
169 | */ | 169 | */ |
170 | if ( !m_keys[key].send()) | 170 | if ( !m_keys[key].send()) |
171 | return false; | 171 | return false; |
172 | else | 172 | else |
173 | return true; | 173 | return true; |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 178 | { |
179 | if ( !loggedin | 179 | if ( !loggedin |
180 | // Permitted keys | 180 | // Permitted keys |
181 | && keycode != Key_F34 // power | 181 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 182 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 183 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 184 | && keycode != Key_Return |
185 | && keycode != Key_Space | 185 | && keycode != Key_Space |
186 | && keycode != Key_Left | 186 | && keycode != Key_Left |
187 | && keycode != Key_Right | 187 | && keycode != Key_Right |
188 | && keycode != Key_Up | 188 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 189 | && keycode != Key_Down ) |
190 | return TRUE; | 190 | return TRUE; |
191 | 191 | ||
192 | /* check if it was registered */ | 192 | /* check if it was registered */ |
193 | if (!db ) { | 193 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 195 | return true; |
196 | }else { | 196 | }else { |
197 | 197 | ||
198 | 198 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 199 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 201 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 202 | if ( held_tid ) { |
203 | killTimer(held_tid); | 203 | killTimer(held_tid); |
204 | held_tid = 0; | 204 | held_tid = 0; |
205 | } | 205 | } |
206 | if ( button->heldAction().isNull() ) { | 206 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 207 | if ( press ) |
208 | emit activate(button, FALSE); | 208 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 209 | } else if ( press ) { |
210 | heldButton = button; | 210 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 212 | } else if ( heldButton ) { |
213 | heldButton = 0; | 213 | heldButton = 0; |
214 | emit activate(button, FALSE); | 214 | emit activate(button, FALSE); |
215 | } | 215 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 216 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | return false; | 219 | return false; |
220 | } | 220 | } |
221 | if ( keycode == HardKey_Suspend ) { | 221 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 222 | if ( press ) emit power(); |
223 | return TRUE; | 223 | return TRUE; |
224 | } | 224 | } |
225 | if ( keycode == HardKey_Backlight ) { | 225 | if ( keycode == HardKey_Backlight ) { |
226 | if ( press ) emit backlight(); | 226 | if ( press ) emit backlight(); |
227 | return TRUE; | 227 | return TRUE; |
228 | } | 228 | } |
229 | if ( keycode == Key_F32 ) { | 229 | if ( keycode == Key_F32 ) { |
230 | #ifndef QT_NO_COP | 230 | #ifndef QT_NO_COP |
231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
232 | #endif | 232 | #endif |
233 | return TRUE; | 233 | return TRUE; |
234 | } | 234 | } |
235 | if ( keycode == Key_F31 ) { | 235 | if ( keycode == Key_F31 ) { |
236 | if ( press ) emit symbol(); | 236 | if ( press ) emit symbol(); |
237 | QWSServer::screenSaverActivate(FALSE); | 237 | QWSServer::screenSaverActivate(FALSE); |
238 | return TRUE; | 238 | return TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( keycode == Key_NumLock ) | 241 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
243 | 243 | ||
244 | if ( keycode == Key_CapsLock ) | 244 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
246 | 246 | ||
247 | if ( serverApp ) | 247 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 249 | ||
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 254 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 255 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 256 | QPE_MEMALERTER_IMPL |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | 259 | ||
260 | 260 | ||
261 | //--------------------------------------------------------------------------- | 261 | //--------------------------------------------------------------------------- |
262 | 262 | ||
263 | bool ServerApplication::doRestart = FALSE; | 263 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 264 | bool ServerApplication::allowRestart = TRUE; |
265 | 265 | ||
266 | void ServerApplication::switchLCD( bool on ) { | 266 | void ServerApplication::switchLCD( bool on ) { |
267 | if ( !qApp ) | 267 | if ( !qApp ) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | ServerApplication *dapp = ServerApplication::me() ; | 270 | ServerApplication *dapp = ServerApplication::me() ; |
271 | 271 | ||
272 | if ( !dapp-> m_screensaver ) | 272 | if ( !dapp-> m_screensaver ) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | if ( on ) { | 275 | if ( on ) { |
276 | dapp-> m_screensaver-> setDisplayState ( true ); | 276 | dapp-> m_screensaver-> setDisplayState ( true ); |
277 | dapp-> m_screensaver-> setBacklight ( -3 ); | 277 | dapp-> m_screensaver-> setBacklight ( -3 ); |
278 | }else | 278 | }else |
279 | dapp-> m_screensaver-> setDisplayState ( false ); | 279 | dapp-> m_screensaver-> setDisplayState ( false ); |
280 | 280 | ||
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
285 | : QPEApplication( argc, argv, t ) | 285 | : QPEApplication( argc, argv, t ) |
286 | { | 286 | { |
287 | 287 | ||
288 | 288 | ||
289 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 289 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
290 | QPixmapCache::setCacheLimit(512); | 290 | QPixmapCache::setCacheLimit(512); |
291 | 291 | ||
292 | m_ps = new PowerStatus; | 292 | m_ps = new PowerStatus; |
293 | m_ps_last = new PowerStatus; | 293 | m_ps_last = new PowerStatus; |
294 | pa = new DesktopPowerAlerter( 0 ); | 294 | pa = new DesktopPowerAlerter( 0 ); |
295 | 295 | ||
296 | m_apm_timer = new QTimer( this ); | 296 | m_apm_timer = new QTimer( this ); |
297 | connect(m_apm_timer, SIGNAL( timeout() ), | 297 | connect(m_apm_timer, SIGNAL( timeout() ), |
298 | this, SLOT( apmTimeout() ) ); | 298 | this, SLOT( apmTimeout() ) ); |
299 | 299 | ||
300 | reloadPowerWarnSettings(); | 300 | reloadPowerWarnSettings(); |
301 | 301 | ||
302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | 304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); |
305 | 305 | ||
306 | channel = new QCopChannel("QPE/Launcher", this ); | 306 | channel = new QCopChannel("QPE/Launcher", this ); |
307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | 308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); |
309 | 309 | ||
310 | m_screensaver = new OpieScreenSaver(); | 310 | m_screensaver = new OpieScreenSaver(); |
311 | m_screensaver->setInterval( -1 ); | 311 | m_screensaver->setInterval( -1 ); |
312 | QWSServer::setScreenSaver( m_screensaver ); | 312 | QWSServer::setScreenSaver( m_screensaver ); |
313 | 313 | ||
314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | 314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), |
315 | this, SLOT( rereadVolumes() ) ); | 315 | this, SLOT( rereadVolumes() ) ); |
316 | 316 | ||
317 | 317 | ||
318 | /* ### PluginLoader libqtopia SafeMode */ | 318 | /* ### PluginLoader libqtopia SafeMode */ |
319 | #if 0 | 319 | #if 0 |
320 | if ( PluginLoader::inSafeMode() ) | 320 | if ( PluginLoader::inSafeMode() ) |
321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
323 | #endif | 323 | #endif |
324 | 324 | ||
325 | kf = new KeyFilter(this); | 325 | kf = new KeyFilter(this); |
326 | 326 | ||
327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); |
335 | 335 | ||
336 | 336 | ||
337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
338 | 338 | ||
339 | connect( this, SIGNAL(power() ), | 339 | connect( this, SIGNAL(power() ), |
340 | SLOT(togglePower() ) ); | 340 | SLOT(togglePower() ) ); |
341 | 341 | ||
342 | rereadVolumes(); | 342 | rereadVolumes(); |
343 | 343 | ||
344 | serverApp = this; | 344 | serverApp = this; |
345 | 345 | ||
346 | apmTimeout(); | 346 | apmTimeout(); |
347 | grabKeyboard(); | 347 | grabKeyboard(); |
348 | 348 | ||
349 | /* make sure the event filter is installed */ | 349 | /* make sure the event filter is installed */ |
350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | ServerApplication::~ServerApplication() | 354 | ServerApplication::~ServerApplication() |
355 | { | 355 | { |
356 | ungrabKeyboard(); | 356 | ungrabKeyboard(); |
357 | 357 | ||
358 | 358 | ||
359 | delete pa; | 359 | delete pa; |
360 | delete m_ps; | 360 | delete m_ps; |
361 | delete m_ps_last; | 361 | delete m_ps_last; |
362 | } | 362 | } |
363 | 363 | ||
364 | void ServerApplication::apmTimeout() { | 364 | void ServerApplication::apmTimeout() { |
365 | serverApp-> checkMemory( ); // in case no events are generated | 365 | serverApp-> checkMemory( ); // in case no events are generated |
366 | *m_ps_last = *m_ps; | 366 | *m_ps_last = *m_ps; |
367 | *m_ps = PowerStatusManager::readStatus(); | 367 | *m_ps = PowerStatusManager::readStatus(); |
368 | 368 | ||
369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
370 | m_screensaver-> powerStatusChanged( *m_ps ); | 370 | m_screensaver-> powerStatusChanged( *m_ps ); |
371 | 371 | ||
372 | if ( m_ps->acStatus() == PowerStatus::Online ) { | 372 | if ( m_ps->acStatus() == PowerStatus::Online ) { |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | int bat = m_ps-> batteryPercentRemaining(); | 376 | int bat = m_ps-> batteryPercentRemaining(); |
377 | 377 | ||
378 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 378 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
379 | if ( bat <= m_powerCritical ) { | 379 | if ( bat <= m_powerCritical ) { |
380 | QMessageBox battlow( | 380 | QMessageBox battlow( |
381 | tr("WARNING"), | 381 | tr("WARNING"), |
382 | tr("<p>The battery level is critical!" | 382 | tr("<p>The battery level is critical!" |
383 | "<p>Keep power off until AC is restored"), | 383 | "<p>Keep power off until AC is restored"), |
384 | QMessageBox::Warning, | 384 | QMessageBox::Warning, |
385 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 385 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
386 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 386 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
387 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 387 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
388 | battlow.exec(); | 388 | battlow.exec(); |
389 | } else if ( bat <= m_powerVeryLow ) | 389 | } else if ( bat <= m_powerVeryLow ) |
390 | pa->alert( tr( "The battery is running very low. "), 2 ); | 390 | pa->alert( tr( "The battery is running very low. "), 2 ); |
391 | } | 391 | } |
392 | 392 | ||
393 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { | 393 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { |
394 | QMessageBox battlow( | 394 | QMessageBox battlow( |
395 | tr("WARNING"), | 395 | tr("WARNING"), |
396 | tr("<p>The Back-up battery is very low" | 396 | tr("<p>The Back-up battery is very low" |
397 | "<p>Please charge the back-up battery"), | 397 | "<p>Please charge the back-up battery"), |
398 | QMessageBox::Warning, | 398 | QMessageBox::Warning, |
399 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 399 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
400 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 400 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
401 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 401 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
402 | battlow.exec(); | 402 | battlow.exec(); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | 405 | ||
406 | void ServerApplication::systemMessage( const QCString& msg, | 406 | void ServerApplication::systemMessage( const QCString& msg, |
407 | const QByteArray& data ) { | 407 | const QByteArray& data ) { |
408 | QDataStream stream ( data, IO_ReadOnly ); | 408 | QDataStream stream ( data, IO_ReadOnly ); |
409 | 409 | ||
410 | if ( msg == "setScreenSaverInterval(int)" ) { | 410 | if ( msg == "setScreenSaverInterval(int)" ) { |
411 | int time; | 411 | int time; |
412 | stream >> time; | 412 | stream >> time; |
413 | m_screensaver-> setInterval( time ); | 413 | m_screensaver-> setInterval( time ); |
414 | } | 414 | } |
415 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 415 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
416 | int t1, t2, t3; | 416 | int t1, t2, t3; |
417 | stream >> t1 >> t2 >> t3; | 417 | stream >> t1 >> t2 >> t3; |
418 | m_screensaver-> setIntervals( t1, t2, t3 ); | 418 | m_screensaver-> setIntervals( t1, t2, t3 ); |
419 | } | 419 | } |
420 | else if ( msg == "setBacklight(int)" ) { | 420 | else if ( msg == "setBacklight(int)" ) { |
421 | int bright; | 421 | int bright; |
422 | stream >> bright; | 422 | stream >> bright; |
423 | m_screensaver-> setBacklight( bright ); | 423 | m_screensaver-> setBacklight( bright ); |
424 | } | 424 | } |
425 | else if ( msg == "setScreenSaverMode(int)" ) { | 425 | else if ( msg == "setScreenSaverMode(int)" ) { |
426 | int mode; | 426 | int mode; |
427 | stream >> mode; | 427 | stream >> mode; |
428 | m_screensaver-> setMode ( mode ); | 428 | m_screensaver-> setMode ( mode ); |
429 | } | 429 | } |
430 | else if ( msg == "reloadPowerWarnSettings()" ) { | 430 | else if ( msg == "reloadPowerWarnSettings()" ) { |
431 | reloadPowerWarnSettings(); | 431 | reloadPowerWarnSettings(); |
432 | } | 432 | } |
433 | else if ( msg == "setDisplayState(int)" ) { | 433 | else if ( msg == "setDisplayState(int)" ) { |
434 | int state; | 434 | int state; |
435 | stream >> state; | 435 | stream >> state; |
436 | m_screensaver-> setDisplayState ( state != 0 ); | 436 | m_screensaver-> setDisplayState ( state != 0 ); |
437 | } | 437 | } |
438 | else if ( msg == "suspend()" ) { | 438 | else if ( msg == "suspend()" ) { |
439 | emit power(); | 439 | emit power(); |
440 | } | 440 | } |
441 | else if ( msg == "sendBusinessCard()" ) { | 441 | else if ( msg == "sendBusinessCard()" ) { |
442 | QString card = ::getenv ( "HOME" ); | 442 | QString card = ::getenv ( "HOME" ); |
443 | card += "/Applications/addressbook/businesscard.vcf"; | 443 | card += "/Applications/addressbook/businesscard.vcf"; |
444 | 444 | ||
445 | if ( QFile::exists( card ) ) { | 445 | if ( QFile::exists( card ) ) { |
446 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 446 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
447 | QString mimetype = "text/x-vCard"; | 447 | QString mimetype = "text/x-vCard"; |
448 | e << tr( "business card" ) << card << mimetype; | 448 | e << tr( "business card" ) << card << mimetype; |
449 | } | 449 | } |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | void ServerApplication::reloadPowerWarnSettings ( ) | 453 | void ServerApplication::reloadPowerWarnSettings ( ) |
454 | { | 454 | { |
455 | Config cfg ( "apm" ); | 455 | Config cfg ( "apm" ); |
456 | cfg. setGroup ( "Warnings" ); | 456 | cfg. setGroup ( "Warnings" ); |
457 | 457 | ||
458 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 458 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
459 | 459 | ||
460 | m_apm_timer-> stop ( ); | 460 | m_apm_timer-> stop ( ); |
461 | if ( iv ) | 461 | if ( iv ) |
462 | m_apm_timer-> start ( iv ); | 462 | m_apm_timer-> start ( iv ); |
463 | 463 | ||
464 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 464 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
465 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 465 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
466 | } | 466 | } |
467 | 467 | ||
468 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 468 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
469 | { | 469 | { |
470 | QDataStream stream ( data, IO_ReadOnly ); | 470 | QDataStream stream ( data, IO_ReadOnly ); |
471 | 471 | ||
472 | if ( msg == "deviceButton(int,int,int)" ) { | 472 | if ( msg == "deviceButton(int,int,int)" ) { |
473 | int keycode, press, autoRepeat; | 473 | int keycode, press, autoRepeat; |
474 | stream >> keycode >> press >> autoRepeat; | 474 | stream >> keycode >> press >> autoRepeat; |
475 | 475 | ||
476 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | 476 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); |
477 | } | 477 | } |
478 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 478 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
479 | int k; | 479 | int k; |
480 | QCString c, m; | 480 | QCString c, m; |
481 | stream >> k >> c >> m; | 481 | stream >> k >> c >> m; |
482 | 482 | ||
483 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 483 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | bool ServerApplication::screenLocked() | 488 | bool ServerApplication::screenLocked() |
489 | { | 489 | { |
490 | return loggedin == 0; | 490 | return loggedin == 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | void ServerApplication::login(bool at_poweron) | 493 | void ServerApplication::login(bool at_poweron) |
494 | { | 494 | { |
495 | if ( !loggedin ) { | 495 | if ( !loggedin ) { |
496 | Global::terminateBuiltin("calibrate"); // No tr | 496 | Global::terminateBuiltin("calibrate"); // No tr |
497 | Password::authenticate(at_poweron); | 497 | Password::authenticate(at_poweron); |
498 | loggedin=1; | 498 | loggedin=1; |
499 | #ifndef QT_NO_COP | 499 | #ifndef QT_NO_COP |
500 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 500 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
501 | #endif | 501 | #endif |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | #if defined(QPE_HAVE_TOGGLELIGHT) | 505 | #if defined(QPE_HAVE_TOGGLELIGHT) |
506 | #include <qtopia/config.h> | 506 | #include <qtopia/config.h> |
507 | 507 | ||
508 | #include <sys/ioctl.h> | 508 | #include <sys/ioctl.h> |
509 | #include <sys/types.h> | 509 | #include <sys/types.h> |
510 | #include <fcntl.h> | 510 | #include <fcntl.h> |
511 | #include <unistd.h> | 511 | #include <unistd.h> |
512 | #include <errno.h> | 512 | #include <errno.h> |
513 | #include <linux/ioctl.h> | 513 | #include <linux/ioctl.h> |
514 | #include <time.h> | 514 | #include <time.h> |
515 | #endif | 515 | #endif |
516 | 516 | ||
517 | #if 0 | 517 | #if 0 |
518 | static bool blanked=FALSE; | 518 | static bool blanked=FALSE; |
519 | 519 | ||
520 | static void blankScreen() | 520 | static void blankScreen() |
521 | { | 521 | { |
522 | #ifdef QWS | 522 | #ifdef QWS |
523 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); | 523 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); |
524 | w.resize( qt_screen->width(), qt_screen->height() ); | 524 | w.resize( qt_screen->width(), qt_screen->height() ); |
525 | w.move(0, 0); | 525 | w.move(0, 0); |
526 | 526 | ||
527 | QPainter p(&w); | 527 | QPainter p(&w); |
528 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); | 528 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); |
529 | p.end(); | 529 | p.end(); |
530 | w.repaint(); | 530 | w.repaint(); |
531 | 531 | ||
532 | blanked = TRUE; | 532 | blanked = TRUE; |
533 | #endif | 533 | #endif |
534 | } | 534 | } |
535 | 535 | ||
536 | static void darkScreen() | 536 | static void darkScreen() |
537 | { | 537 | { |
538 | /* ### Screen blanking ODevice */ | 538 | /* ### Screen blanking ODevice */ |
539 | #if 0 | 539 | #if 0 |
540 | qpe_setBacklight(0); // force off | 540 | qpe_setBacklight(0); // force off |
541 | #endif | 541 | #endif |
542 | } | 542 | } |
543 | #endif | 543 | #endif |
544 | 544 | ||
545 | namespace { | 545 | namespace { |
546 | void execAutoStart(const QDateTime& suspendTime ) { | 546 | void execAutoStart(const QDateTime& suspendTime ) { |
547 | QString appName; | 547 | QString appName; |
548 | int delay; | 548 | int delay; |
549 | QDateTime now = QDateTime::currentDateTime(); | 549 | QDateTime now = QDateTime::currentDateTime(); |
550 | 550 | ||
551 | Config cfg( "autostart" ); | 551 | Config cfg( "autostart" ); |
552 | cfg.setGroup( "AutoStart" ); | 552 | cfg.setGroup( "AutoStart" ); |
553 | appName = cfg.readEntry( "Apps", "" ); | 553 | appName = cfg.readEntry( "Apps", "" ); |
554 | delay = cfg.readNumEntry( "Delay", 0 ); | 554 | delay = cfg.readNumEntry( "Delay", 0 ); |
555 | 555 | ||
556 | // If the time between suspend and resume was longer then the | 556 | // If the time between suspend and resume was longer then the |
557 | // value saved as delay, start the app | 557 | // value saved as delay, start the app |
558 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 558 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
559 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 559 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
560 | e << QString( appName ); | 560 | e << QString( appName ); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | 565 | ||
566 | void ServerApplication::togglePower() | 566 | void ServerApplication::togglePower() |
567 | { | 567 | { |
568 | static bool excllock = false; | 568 | static bool excllock = false; |
569 | 569 | ||
570 | if ( excllock ) | 570 | if ( excllock ) |
571 | return ; | 571 | return ; |
572 | 572 | ||
573 | excllock = true; | 573 | excllock = true; |
574 | 574 | ||
575 | bool wasloggedin = loggedin; | 575 | bool wasloggedin = loggedin; |
576 | loggedin = 0; | 576 | loggedin = 0; |
577 | m_suspendTime = QDateTime::currentDateTime(); | 577 | m_suspendTime = QDateTime::currentDateTime(); |
578 | 578 | ||
579 | #ifdef QWS | 579 | #ifdef QWS |
580 | 580 | ||
581 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 581 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
582 | // Should use a big black window instead. | 582 | // Should use a big black window instead. |
583 | // But this would not show up fast enough | 583 | // But this would not show up fast enough |
584 | QGfx *g = qt_screen-> screenGfx ( ); | 584 | QGfx *g = qt_screen-> screenGfx ( ); |
585 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 585 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
586 | delete g; | 586 | delete g; |
587 | } | 587 | } |
588 | #endif | 588 | #endif |
589 | 589 | ||
590 | ODevice::inst ( )-> suspend ( ); | 590 | ODevice::inst ( )-> suspend ( ); |
591 | 591 | ||
592 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call | 592 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call |
593 | QWSServer::screenSaverActivate ( false ); | 593 | QWSServer::screenSaverActivate ( false ); |
594 | 594 | ||
595 | { | 595 | { |
596 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 596 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
597 | } | 597 | } |
598 | 598 | ||
599 | if ( wasloggedin ) | 599 | if ( wasloggedin ) |
600 | login ( true ); | 600 | login ( true ); |
601 | 601 | ||
602 | execAutoStart(m_suspendTime); | 602 | execAutoStart(m_suspendTime); |
603 | //qcopBridge->closeOpenConnections(); | 603 | //qcopBridge->closeOpenConnections(); |
604 | 604 | ||
605 | excllock = false; | 605 | excllock = false; |
606 | } | 606 | } |
607 | 607 | ||
608 | void ServerApplication::toggleLight() | 608 | void ServerApplication::toggleLight() |
609 | { | 609 | { |
610 | #ifndef QT_NO_COP | 610 | #ifndef QT_NO_COP |
611 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 611 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
612 | e << -2; // toggle | 612 | e << -2; // toggle |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
616 | 616 | ||
617 | /* | 617 | /* |
618 | * We still listen to key events but handle them in | 618 | * We still listen to key events but handle them in |
619 | * a special class | 619 | * a special class |
620 | */ | 620 | */ |
621 | 621 | ||
622 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { | 622 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { |
623 | if ( e->type() != QEvent::KeyPress && | 623 | if ( e->type() != QEvent::KeyPress && |
624 | e->type() != QEvent::KeyRelease ) | 624 | e->type() != QEvent::KeyRelease ) |
625 | return QPEApplication::eventFilter( o, e ); | 625 | return QPEApplication::eventFilter( o, e ); |
626 | 626 | ||
627 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); | 627 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); |
628 | if ( kf->checkButtonAction( true, ke->key(), | 628 | if ( kf->checkButtonAction( true, ke->key(), |
629 | e->type() == QEvent::KeyPress, | 629 | e->type() == QEvent::KeyPress, |
630 | ke-> isAutoRepeat() )) | 630 | ke-> isAutoRepeat() )) |
631 | return true; | 631 | return true; |
632 | 632 | ||
633 | return QPEApplication::eventFilter( o, e ); | 633 | return QPEApplication::eventFilter( o, e ); |
634 | 634 | ||
635 | } | 635 | } |
636 | 636 | ||
637 | #ifdef Q_WS_QWS | 637 | #ifdef Q_WS_QWS |
638 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) | 638 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) |
639 | { | 639 | { |
640 | checkMemory(); | 640 | checkMemory(); |
641 | 641 | ||
642 | if ( e->type == QWSEvent::Mouse ) { | 642 | if ( e->type == QWSEvent::Mouse ) { |
643 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 643 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
644 | static bool up = TRUE; | 644 | static bool up = TRUE; |
645 | if ( me->simpleData.state&LeftButton ) { | 645 | if ( me->simpleData.state&LeftButton ) { |
646 | if ( up ) { | 646 | if ( up ) { |
647 | up = FALSE; | 647 | up = FALSE; |
648 | screenClick(TRUE); | 648 | screenClick(TRUE); |
649 | } | 649 | } |
650 | } else if ( !up ) { | 650 | } else if ( !up ) { |
651 | up = TRUE; | 651 | up = TRUE; |
652 | screenClick(FALSE); | 652 | screenClick(FALSE); |
653 | } | 653 | } |
654 | }else if ( e->type == QWSEvent::Key ) { | 654 | }else if ( e->type == QWSEvent::Key ) { |
655 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); | 655 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); |
656 | if ( kf->checkButtonAction( false, | 656 | if ( kf->checkButtonAction( false, |
657 | ke-> simpleData.keycode, | 657 | ke-> simpleData.keycode, |
658 | ke-> simpleData.is_press, | 658 | ke-> simpleData.is_press, |
659 | ke-> simpleData.is_auto_repeat ) ) | 659 | ke-> simpleData.is_auto_repeat ) ) |
660 | return true; | 660 | return true; |
661 | } | 661 | } |
662 | 662 | ||
663 | return QPEApplication::qwsEventFilter( e ); | 663 | return QPEApplication::qwsEventFilter( e ); |
664 | } | 664 | } |
665 | #endif | 665 | #endif |
666 | 666 | ||
667 | 667 | ||
668 | /* ### FIXME libqtopia Plugin Safe Mode */ | 668 | /* ### FIXME libqtopia Plugin Safe Mode */ |
669 | 669 | ||
670 | void ServerApplication::showSafeMode() | 670 | void ServerApplication::showSafeMode() |
671 | { | 671 | { |
672 | #if 0 | 672 | #if 0 |
673 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " | 673 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " |
674 | "and the system is now in Safe Mode. " | 674 | "and the system is now in Safe Mode. " |
675 | "Plugins are not loaded in Safe Mode. " | 675 | "Plugins are not loaded in Safe Mode. " |
676 | "You can use the Plugin Manager to " | 676 | "You can use the Plugin Manager to " |
677 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { | 677 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { |
678 | Global::execute( "pluginmanager" ); | 678 | Global::execute( "pluginmanager" ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | void ServerApplication::clearSafeMode() | 683 | void ServerApplication::clearSafeMode() |
684 | { | 684 | { |
685 | #if 0 | 685 | #if 0 |
686 | // If we've been running OK for a while then we won't bother going into | 686 | // If we've been running OK for a while then we won't bother going into |
687 | // safe mode immediately on the next crash. | 687 | // safe mode immediately on the next crash. |
688 | Config cfg( "PluginLoader" ); | 688 | Config cfg( "PluginLoader" ); |
689 | cfg.setGroup( "Global" ); | 689 | cfg.setGroup( "Global" ); |
690 | QString mode = cfg.readEntry( "Mode", "Normal" ); | 690 | QString mode = cfg.readEntry( "Mode", "Normal" ); |
691 | if ( mode == "MaybeSafe" ) { | 691 | if ( mode == "MaybeSafe" ) { |
692 | cfg.writeEntry( "Mode", "Normal" ); | 692 | cfg.writeEntry( "Mode", "Normal" ); |
693 | } | 693 | } |
694 | #endif | 694 | #endif |
695 | } | 695 | } |
696 | 696 | ||
697 | 697 | ||
698 | void ServerApplication::shutdown() | 698 | void ServerApplication::shutdown() |
699 | { | 699 | { |
700 | if ( type() != GuiServer ) | 700 | if ( type() != GuiServer ) |
701 | return; | 701 | return; |
702 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 702 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
703 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 703 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
704 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 704 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
705 | sd->showMaximized(); | 705 | QPEApplication::showWidget( sd ); |
706 | } | 706 | } |
707 | 707 | ||
708 | void ServerApplication::shutdown( ShutdownImpl::Type t ) | 708 | void ServerApplication::shutdown( ShutdownImpl::Type t ) |
709 | { | 709 | { |
710 | char *opt = 0; | 710 | char *opt = 0; |
711 | 711 | ||
712 | switch ( t ) { | 712 | switch ( t ) { |
713 | case ShutdownImpl::ShutdownSystem: | 713 | case ShutdownImpl::ShutdownSystem: |
714 | opt = "-h"; | 714 | opt = "-h"; |
715 | // fall through | 715 | // fall through |
716 | case ShutdownImpl::RebootSystem: | 716 | case ShutdownImpl::RebootSystem: |
717 | if ( opt == 0 ) | 717 | if ( opt == 0 ) |
718 | opt = "-r"; | 718 | opt = "-r"; |
719 | 719 | ||
720 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) | 720 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
721 | perror("shutdown"); | 721 | perror("shutdown"); |
722 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 722 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
723 | 723 | ||
724 | break; | 724 | break; |
725 | case ShutdownImpl::RestartDesktop: | 725 | case ShutdownImpl::RestartDesktop: |
726 | restart(); | 726 | restart(); |
727 | break; | 727 | break; |
728 | case ShutdownImpl::TerminateDesktop: | 728 | case ShutdownImpl::TerminateDesktop: |
729 | prepareForTermination( FALSE ); | 729 | prepareForTermination( FALSE ); |
730 | 730 | ||
731 | // This is a workaround for a Qt bug | 731 | // This is a workaround for a Qt bug |
732 | // clipboard applet has to stop its poll timer, or Qt/E | 732 | // clipboard applet has to stop its poll timer, or Qt/E |
733 | // will hang on quit() right before it emits aboutToQuit() | 733 | // will hang on quit() right before it emits aboutToQuit() |
734 | emit aboutToQuit ( ); | 734 | emit aboutToQuit ( ); |
735 | 735 | ||
736 | quit(); | 736 | quit(); |
737 | break; | 737 | break; |
738 | } | 738 | } |
739 | } | 739 | } |
740 | 740 | ||
741 | void ServerApplication::restart() | 741 | void ServerApplication::restart() |
742 | { | 742 | { |
743 | if ( allowRestart ) { | 743 | if ( allowRestart ) { |
744 | 744 | ||
745 | /* | 745 | /* |
746 | * Applets and restart is a problem. Some applets delete | 746 | * Applets and restart is a problem. Some applets delete |
747 | * their widgets even if ownership gets transfered to the | 747 | * their widgets even if ownership gets transfered to the |
748 | * parent (Systray ) but deleting the applet may be unsafe | 748 | * parent (Systray ) but deleting the applet may be unsafe |
749 | * as well ( double deletion ). Some have topLevel widgets | 749 | * as well ( double deletion ). Some have topLevel widgets |
750 | * and when we dlclose and then delete the widget we will | 750 | * and when we dlclose and then delete the widget we will |
751 | * crash and an crash during restart is not nice | 751 | * crash and an crash during restart is not nice |
752 | */ | 752 | */ |
753 | #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED | 753 | #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED |
754 | /* same as above */ | 754 | /* same as above */ |
755 | emit aboutToQuit(); | 755 | emit aboutToQuit(); |
756 | prepareForTermination(TRUE); | 756 | prepareForTermination(TRUE); |
757 | doRestart = TRUE; | 757 | doRestart = TRUE; |
758 | quit(); | 758 | quit(); |
759 | #else | 759 | #else |
760 | prepareForTermination( true ); | 760 | prepareForTermination( true ); |
761 | for ( int fd = 3; fd < 100; fd++ ) | 761 | for ( int fd = 3; fd < 100; fd++ ) |
762 | close( fd ); | 762 | close( fd ); |
763 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 763 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
764 | exit( 1 ); | 764 | exit( 1 ); |
765 | #endif | 765 | #endif |
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | void ServerApplication::rereadVolumes() | 769 | void ServerApplication::rereadVolumes() |
770 | { | 770 | { |
771 | Config cfg( "qpe" ); | 771 | Config cfg( "qpe" ); |
772 | cfg. setGroup ( "Volume" ); | 772 | cfg. setGroup ( "Volume" ); |
773 | 773 | ||
774 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); | 774 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
775 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | 775 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
776 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | 776 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
777 | } | 777 | } |
778 | 778 | ||
779 | 779 | ||
780 | void ServerApplication::checkMemory() | 780 | void ServerApplication::checkMemory() |
781 | { | 781 | { |
782 | #if defined(QPE_HAVE_MEMALERTER) | 782 | #if defined(QPE_HAVE_MEMALERTER) |
783 | static bool ignoreNormal=TRUE; | 783 | static bool ignoreNormal=TRUE; |
784 | static bool existingMessage=FALSE; | 784 | static bool existingMessage=FALSE; |
785 | 785 | ||
786 | if(existingMessage) | 786 | if(existingMessage) |
787 | return; // don't show a second message while still on first | 787 | return; // don't show a second message while still on first |
788 | 788 | ||
789 | existingMessage = TRUE; | 789 | existingMessage = TRUE; |
790 | switch ( memstate ) { | 790 | switch ( memstate ) { |
791 | case MemUnknown: | 791 | case MemUnknown: |
792 | break; | 792 | break; |
793 | case MemLow: | 793 | case MemLow: |
794 | memstate = MemUnknown; | 794 | memstate = MemUnknown; |
795 | if ( !recoverMemory() ) { | 795 | if ( !recoverMemory() ) { |
796 | QMessageBox::warning( 0 , tr("Memory Status"), | 796 | QMessageBox::warning( 0 , tr("Memory Status"), |
797 | tr("Memory Low\nPlease save data.") ); | 797 | tr("Memory Low\nPlease save data.") ); |
798 | ignoreNormal = FALSE; | 798 | ignoreNormal = FALSE; |
799 | } | 799 | } |
800 | break; | 800 | break; |
801 | case MemNormal: | 801 | case MemNormal: |
802 | memstate = MemUnknown; | 802 | memstate = MemUnknown; |
803 | if ( !ignoreNormal ) { | 803 | if ( !ignoreNormal ) { |
804 | ignoreNormal = TRUE; | 804 | ignoreNormal = TRUE; |
805 | QMessageBox::information ( 0 , tr("Memory Status"), | 805 | QMessageBox::information ( 0 , tr("Memory Status"), |
806 | "Memory OK" ); | 806 | "Memory OK" ); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | case MemVeryLow: | 809 | case MemVeryLow: |
810 | memstate = MemUnknown; | 810 | memstate = MemUnknown; |
811 | QMessageBox::critical( 0 , tr("Memory Status"), | 811 | QMessageBox::critical( 0 , tr("Memory Status"), |
812 | tr("Critical Memory Shortage\n" | 812 | tr("Critical Memory Shortage\n" |
813 | "Please end this application\n" | 813 | "Please end this application\n" |
814 | "immediately.") ); | 814 | "immediately.") ); |
815 | recoverMemory(); | 815 | recoverMemory(); |
816 | } | 816 | } |
817 | existingMessage = FALSE; | 817 | existingMessage = FALSE; |
818 | #endif | 818 | #endif |
819 | } | 819 | } |
820 | 820 | ||
821 | bool ServerApplication::recoverMemory() | 821 | bool ServerApplication::recoverMemory() |
822 | { | 822 | { |
823 | return FALSE; | 823 | return FALSE; |
824 | } | 824 | } |
825 | 825 | ||
826 | void ServerApplication::keyClick(int , bool press, bool ) | 826 | void ServerApplication::keyClick(int , bool press, bool ) |
827 | { | 827 | { |
828 | if ( press && m_keyclick_sound ) | 828 | if ( press && m_keyclick_sound ) |
829 | ODevice::inst() -> keySound(); | 829 | ODevice::inst() -> keySound(); |
830 | 830 | ||
831 | } | 831 | } |
832 | 832 | ||
833 | void ServerApplication::screenClick(bool press) | 833 | void ServerApplication::screenClick(bool press) |
834 | { | 834 | { |
835 | if ( press && m_screentap_sound ) | 835 | if ( press && m_screentap_sound ) |
836 | ODevice::inst() -> touchSound(); | 836 | ODevice::inst() -> touchSound(); |
837 | } | 837 | } |
838 | 838 | ||
839 | void ServerApplication::soundAlarm() { | 839 | void ServerApplication::soundAlarm() { |
840 | if ( me ()->m_alarm_sound ) | 840 | if ( me ()->m_alarm_sound ) |
841 | ODevice::inst()->alarmSound(); | 841 | ODevice::inst()->alarmSound(); |
842 | } | 842 | } |
843 | 843 | ||
844 | ServerApplication *ServerApplication::me ( ) | 844 | ServerApplication *ServerApplication::me ( ) |
845 | { | 845 | { |
846 | return static_cast<ServerApplication*>( qApp ); | 846 | return static_cast<ServerApplication*>( qApp ); |
847 | } | 847 | } |
848 | 848 | ||
849 | 849 | ||
850 | #include "serverapp.moc" | 850 | #include "serverapp.moc" |
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 44fbe48..fbc5072 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -1,527 +1,527 @@ | |||
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 <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpixmap.h> | 25 | #include <qpixmap.h> |
26 | #include <qbutton.h> | 26 | #include <qbutton.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include "audiowidget.h" | 31 | #include "audiowidget.h" |
32 | #include "mediaplayerstate.h" | 32 | #include "mediaplayerstate.h" |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | extern MediaPlayerState *mediaPlayerState; | 37 | extern MediaPlayerState *mediaPlayerState; |
38 | 38 | ||
39 | 39 | ||
40 | static const int xo = -2; // movable x offset | 40 | static const int xo = -2; // movable x offset |
41 | static const int yo = 22; // movable y offset | 41 | static const int yo = 22; // movable y offset |
42 | 42 | ||
43 | struct MediaButton { | 43 | struct MediaButton { |
44 | bool isToggle, isHeld, isDown; | 44 | bool isToggle, isHeld, isDown; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | //Layout information for the audioButtons (and if it is a toggle button or not) | 47 | //Layout information for the audioButtons (and if it is a toggle button or not) |
48 | MediaButton audioButtons[] = { | 48 | MediaButton audioButtons[] = { |
49 | { TRUE, FALSE, FALSE }, // play | 49 | { TRUE, FALSE, FALSE }, // play |
50 | { FALSE, FALSE, FALSE }, // stop | 50 | { FALSE, FALSE, FALSE }, // stop |
51 | { FALSE, FALSE, FALSE }, // next | 51 | { FALSE, FALSE, FALSE }, // next |
52 | { FALSE, FALSE, FALSE }, // previous | 52 | { FALSE, FALSE, FALSE }, // previous |
53 | { FALSE, FALSE, FALSE }, // volume up | 53 | { FALSE, FALSE, FALSE }, // volume up |
54 | { FALSE, FALSE, FALSE }, // volume down | 54 | { FALSE, FALSE, FALSE }, // volume down |
55 | { TRUE, FALSE, FALSE }, // repeat/loop | 55 | { TRUE, FALSE, FALSE }, // repeat/loop |
56 | { FALSE, FALSE, FALSE }, // playlist | 56 | { FALSE, FALSE, FALSE }, // playlist |
57 | { FALSE, FALSE, FALSE }, // forward | 57 | { FALSE, FALSE, FALSE }, // forward |
58 | { FALSE, FALSE, FALSE } // back | 58 | { FALSE, FALSE, FALSE } // back |
59 | }; | 59 | }; |
60 | 60 | ||
61 | const char *skin_mask_file_names[10] = { | 61 | const char *skin_mask_file_names[10] = { |
62 | "play", "stop", "next", "prev", "up", | 62 | "play", "stop", "next", "prev", "up", |
63 | "down", "loop", "playlist", "forward", "back" | 63 | "down", "loop", "playlist", "forward", "back" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static void changeTextColor( QWidget *w ) { | 66 | static void changeTextColor( QWidget *w ) { |
67 | QPalette p = w->palette(); | 67 | QPalette p = w->palette(); |
68 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 68 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
69 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 69 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
70 | w->setPalette( p ); | 70 | w->setPalette( p ); |
71 | } | 71 | } |
72 | 72 | ||
73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
74 | 74 | ||
75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) | 76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | // qDebug("<<<<<audioWidget"); | 79 | // qDebug("<<<<<audioWidget"); |
80 | 80 | ||
81 | Config cfg("OpiePlayer"); | 81 | Config cfg("OpiePlayer"); |
82 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
83 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
84 | //skin = "scaleTest"; | 84 | //skin = "scaleTest"; |
85 | // color of background, frame, degree of transparency | 85 | // color of background, frame, degree of transparency |
86 | 86 | ||
87 | // QString skinPath = "opieplayer/skins/" + skin; | 87 | // QString skinPath = "opieplayer/skins/" + skin; |
88 | QString skinPath; | 88 | QString skinPath; |
89 | skinPath = "opieplayer2/skins/" + skin; | 89 | skinPath = "opieplayer2/skins/" + skin; |
90 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 90 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
91 | skinPath = "opieplayer2/skins/default"; | 91 | skinPath = "opieplayer2/skins/default"; |
92 | 92 | ||
93 | // qDebug("skin path " + skinPath); | 93 | // qDebug("skin path " + skinPath); |
94 | 94 | ||
95 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 95 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 96 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
97 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 97 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
98 | 98 | ||
99 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 99 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
100 | imgButtonMask->fill( 0 ); | 100 | imgButtonMask->fill( 0 ); |
101 | 101 | ||
102 | for ( int i = 0; i < 10; i++ ) { | 102 | for ( int i = 0; i < 10; i++ ) { |
103 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 103 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
104 | masks[i] = new QBitmap( filename ); | 104 | masks[i] = new QBitmap( filename ); |
105 | 105 | ||
106 | if ( !masks[i]->isNull() ) { | 106 | if ( !masks[i]->isNull() ) { |
107 | QImage imgMask = masks[i]->convertToImage(); | 107 | QImage imgMask = masks[i]->convertToImage(); |
108 | uchar **dest = imgButtonMask->jumpTable(); | 108 | uchar **dest = imgButtonMask->jumpTable(); |
109 | for ( int y = 0; y < imgUp->height(); y++ ) { | 109 | for ( int y = 0; y < imgUp->height(); y++ ) { |
110 | uchar *line = dest[y]; | 110 | uchar *line = dest[y]; |
111 | for ( int x = 0; x < imgUp->width(); x++ ) | 111 | for ( int x = 0; x < imgUp->width(); x++ ) |
112 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 112 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
113 | line[x] = i + 1; | 113 | line[x] = i + 1; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | for ( int i = 0; i < 11; i++ ) { | 119 | for ( int i = 0; i < 11; i++ ) { |
120 | buttonPixUp[i] = NULL; | 120 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 121 | buttonPixDown[i] = NULL; |
122 | } | 122 | } |
123 | 123 | ||
124 | QWidget *d = QApplication::desktop(); | 124 | QWidget *d = QApplication::desktop(); |
125 | int width = d->width(); | 125 | int width = d->width(); |
126 | int height = d->height(); | 126 | int height = d->height(); |
127 | 127 | ||
128 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 128 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
129 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); | 129 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); |
130 | QImage img; | 130 | QImage img; |
131 | img = pixBg->convertToImage(); | 131 | img = pixBg->convertToImage(); |
132 | pixBg->convertFromImage( img.smoothScale( width, height)); | 132 | pixBg->convertFromImage( img.smoothScale( width, height)); |
133 | } | 133 | } |
134 | setBackgroundPixmap( *pixBg); | 134 | setBackgroundPixmap( *pixBg); |
135 | 135 | ||
136 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 136 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
137 | 137 | ||
138 | // changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
140 | // songInfo.setFrameStyle( QFrame::NoFrame); | 140 | // songInfo.setFrameStyle( QFrame::NoFrame); |
141 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 141 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
142 | //NoFrame | 142 | //NoFrame |
143 | // songInfo.setForegroundColor(Qt::white); | 143 | // songInfo.setForegroundColor(Qt::white); |
144 | 144 | ||
145 | slider.setFixedHeight( 20 ); | 145 | slider.setFixedHeight( 20 ); |
146 | slider.setMinValue( 0 ); | 146 | slider.setMinValue( 0 ); |
147 | slider.setMaxValue( 1 ); | 147 | slider.setMaxValue( 1 ); |
148 | slider.setFocusPolicy( QWidget::NoFocus ); | 148 | slider.setFocusPolicy( QWidget::NoFocus ); |
149 | 149 | ||
150 | slider.setBackgroundPixmap( *pixBg ); | 150 | slider.setBackgroundPixmap( *pixBg ); |
151 | 151 | ||
152 | time.setFocusPolicy( QWidget::NoFocus ); | 152 | time.setFocusPolicy( QWidget::NoFocus ); |
153 | time.setAlignment( Qt::AlignCenter ); | 153 | time.setAlignment( Qt::AlignCenter ); |
154 | time.setFrame(FALSE); | 154 | time.setFrame(FALSE); |
155 | changeTextColor( &time ); | 155 | changeTextColor( &time ); |
156 | 156 | ||
157 | resizeEvent( NULL ); | 157 | resizeEvent( NULL ); |
158 | 158 | ||
159 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 159 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
160 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 160 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
161 | 161 | ||
162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
163 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 163 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
165 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 165 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
166 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 166 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
167 | 167 | ||
168 | // Intialise state | 168 | // Intialise state |
169 | setLength( mediaPlayerState->length() ); | 169 | setLength( mediaPlayerState->length() ); |
170 | setPosition( mediaPlayerState->position() ); | 170 | setPosition( mediaPlayerState->position() ); |
171 | setLooping( mediaPlayerState->fullscreen() ); | 171 | setLooping( mediaPlayerState->fullscreen() ); |
172 | // setPaused( mediaPlayerState->paused() ); | 172 | // setPaused( mediaPlayerState->paused() ); |
173 | setPlaying( mediaPlayerState->playing() ); | 173 | setPlaying( mediaPlayerState->playing() ); |
174 | this->setFocus(); | 174 | this->setFocus(); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | AudioWidget::~AudioWidget() { | 178 | AudioWidget::~AudioWidget() { |
179 | // setPlaying( false); | 179 | // setPlaying( false); |
180 | 180 | ||
181 | for ( int i = 0; i < 10; i++ ) { | 181 | for ( int i = 0; i < 10; i++ ) { |
182 | if(buttonPixUp[i]) delete buttonPixUp[i]; | 182 | if(buttonPixUp[i]) delete buttonPixUp[i]; |
183 | if(buttonPixDown[i]) delete buttonPixDown[i]; | 183 | if(buttonPixDown[i]) delete buttonPixDown[i]; |
184 | } | 184 | } |
185 | if(pixBg) delete pixBg; | 185 | if(pixBg) delete pixBg; |
186 | if(imgUp) delete imgUp; | 186 | if(imgUp) delete imgUp; |
187 | if(imgDn) delete imgDn; | 187 | if(imgDn) delete imgDn; |
188 | if(imgButtonMask) delete imgButtonMask; | 188 | if(imgButtonMask) delete imgButtonMask; |
189 | for ( int i = 0; i < 10; i++ ) { | 189 | for ( int i = 0; i < 10; i++ ) { |
190 | if(masks[i]) delete masks[i]; | 190 | if(masks[i]) delete masks[i]; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 195 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
196 | QPixmap pix( img.width(), img.height() ); | 196 | QPixmap pix( img.width(), img.height() ); |
197 | QPainter p( &pix ); | 197 | QPainter p( &pix ); |
198 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 198 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
199 | p.drawImage( 0, 0, img ); | 199 | p.drawImage( 0, 0, img ); |
200 | return new QPixmap( pix ); | 200 | return new QPixmap( pix ); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 204 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
205 | { | 205 | { |
206 | QPixmap *pixmap = new QPixmap( pix ); | 206 | QPixmap *pixmap = new QPixmap( pix ); |
207 | pixmap->setMask( mask ); | 207 | pixmap->setMask( mask ); |
208 | return pixmap; | 208 | return pixmap; |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 213 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
214 | int h = height(); | 214 | int h = height(); |
215 | int w = width(); | 215 | int w = width(); |
216 | 216 | ||
217 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 217 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
218 | slider.setFixedWidth( w - 110 ); | 218 | slider.setFixedWidth( w - 110 ); |
219 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 219 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
220 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 220 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
221 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 221 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
222 | 222 | ||
223 | xoff = ( w - imgUp->width() ) / 2; | 223 | xoff = ( w - imgUp->width() ) / 2; |
224 | yoff = (( h - imgUp->height() ) / 2) - 10; | 224 | yoff = (( h - imgUp->height() ) / 2) - 10; |
225 | QPoint p( xoff, yoff ); | 225 | QPoint p( xoff, yoff ); |
226 | 226 | ||
227 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 227 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
228 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 228 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
229 | 229 | ||
230 | for ( int i = 0; i < 10; i++ ) { | 230 | for ( int i = 0; i < 10; i++ ) { |
231 | if ( !masks[i]->isNull() ) { | 231 | if ( !masks[i]->isNull() ) { |
232 | delete buttonPixUp[i]; | 232 | delete buttonPixUp[i]; |
233 | delete buttonPixDown[i]; | 233 | delete buttonPixDown[i]; |
234 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 234 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
235 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 235 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | delete pixUp; | 239 | delete pixUp; |
240 | delete pixDn; | 240 | delete pixDn; |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | static bool audioSliderBeingMoved = FALSE; | 244 | static bool audioSliderBeingMoved = FALSE; |
245 | 245 | ||
246 | void AudioWidget::sliderPressed() { | 246 | void AudioWidget::sliderPressed() { |
247 | audioSliderBeingMoved = TRUE; | 247 | audioSliderBeingMoved = TRUE; |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void AudioWidget::sliderReleased() { | 251 | void AudioWidget::sliderReleased() { |
252 | audioSliderBeingMoved = FALSE; | 252 | audioSliderBeingMoved = FALSE; |
253 | if ( slider.width() == 0 ) | 253 | if ( slider.width() == 0 ) |
254 | return; | 254 | return; |
255 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 255 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
256 | mediaPlayerState->setPosition( val ); | 256 | mediaPlayerState->setPosition( val ); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void AudioWidget::setPosition( long i ) { | 260 | void AudioWidget::setPosition( long i ) { |
261 | // qDebug("set position %d",i); | 261 | // qDebug("set position %d",i); |
262 | long length = mediaPlayerState->length(); | 262 | long length = mediaPlayerState->length(); |
263 | updateSlider( i, length ); | 263 | updateSlider( i, length ); |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void AudioWidget::setLength( long max ) { | 267 | void AudioWidget::setLength( long max ) { |
268 | updateSlider( mediaPlayerState->position(), max ); | 268 | updateSlider( mediaPlayerState->position(), max ); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | void AudioWidget::setView( char view ) { | 272 | void AudioWidget::setView( char view ) { |
273 | 273 | ||
274 | if (mediaPlayerState->isStreaming) { | 274 | if (mediaPlayerState->isStreaming) { |
275 | if( !slider.isHidden()) slider.hide(); | 275 | if( !slider.isHidden()) slider.hide(); |
276 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 276 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
277 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 277 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
278 | } else { | 278 | } else { |
279 | // this stops the slider from being moved, thus | 279 | // this stops the slider from being moved, thus |
280 | // does not stop stream when it reaches the end | 280 | // does not stop stream when it reaches the end |
281 | slider.show(); | 281 | slider.show(); |
282 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 282 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
283 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 283 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
284 | } | 284 | } |
285 | 285 | ||
286 | if ( view == 'a' ) { | 286 | if ( view == 'a' ) { |
287 | startTimer( 150 ); | 287 | startTimer( 150 ); |
288 | // show(); | 288 | // show(); |
289 | showMaximized(); | 289 | QPEApplication::showWidget( this ); |
290 | } else { | 290 | } else { |
291 | killTimers(); | 291 | killTimers(); |
292 | hide(); | 292 | hide(); |
293 | } | 293 | } |
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | static QString timeAsString( long length ) { | 298 | static QString timeAsString( long length ) { |
299 | length /= 44100; | 299 | length /= 44100; |
300 | int minutes = length / 60; | 300 | int minutes = length / 60; |
301 | int seconds = length % 60; | 301 | int seconds = length % 60; |
302 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 302 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
303 | } | 303 | } |
304 | 304 | ||
305 | void AudioWidget::updateSlider( long i, long max ) { | 305 | void AudioWidget::updateSlider( long i, long max ) { |
306 | this->setFocus(); | 306 | this->setFocus(); |
307 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 307 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
308 | 308 | ||
309 | if ( max == 0 ) | 309 | if ( max == 0 ) |
310 | return; | 310 | return; |
311 | // Will flicker too much if we don't do this | 311 | // Will flicker too much if we don't do this |
312 | // Scale to something reasonable | 312 | // Scale to something reasonable |
313 | int width = slider.width(); | 313 | int width = slider.width(); |
314 | int val = int((double)i * width / max); | 314 | int val = int((double)i * width / max); |
315 | if ( !audioSliderBeingMoved ) { | 315 | if ( !audioSliderBeingMoved ) { |
316 | if ( slider.value() != val ) | 316 | if ( slider.value() != val ) |
317 | slider.setValue( val ); | 317 | slider.setValue( val ); |
318 | if ( slider.maxValue() != width ) | 318 | if ( slider.maxValue() != width ) |
319 | slider.setMaxValue( width ); | 319 | slider.setMaxValue( width ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void AudioWidget::setToggleButton( int i, bool down ) { | 324 | void AudioWidget::setToggleButton( int i, bool down ) { |
325 | if ( down != audioButtons[i].isDown ) | 325 | if ( down != audioButtons[i].isDown ) |
326 | toggleButton( i ); | 326 | toggleButton( i ); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void AudioWidget::toggleButton( int i ) { | 330 | void AudioWidget::toggleButton( int i ) { |
331 | audioButtons[i].isDown = !audioButtons[i].isDown; | 331 | audioButtons[i].isDown = !audioButtons[i].isDown; |
332 | QPainter p(this); | 332 | QPainter p(this); |
333 | paintButton ( &p, i ); | 333 | paintButton ( &p, i ); |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | void AudioWidget::paintButton( QPainter *p, int i ) { | 337 | void AudioWidget::paintButton( QPainter *p, int i ) { |
338 | if ( audioButtons[i].isDown ) | 338 | if ( audioButtons[i].isDown ) |
339 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 339 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
340 | else | 340 | else |
341 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 341 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void AudioWidget::timerEvent( QTimerEvent * ) { | 345 | void AudioWidget::timerEvent( QTimerEvent * ) { |
346 | /* | 346 | /* |
347 | int x = audioButtons[AudioPlay].xPos; | 347 | int x = audioButtons[AudioPlay].xPos; |
348 | int y = audioButtons[AudioPlay].yPos; | 348 | int y = audioButtons[AudioPlay].yPos; |
349 | QPainter p( this ); | 349 | QPainter p( this ); |
350 | // Optimize to only draw the little bit of the changing images which is different | 350 | // Optimize to only draw the little bit of the changing images which is different |
351 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 351 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
352 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 352 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
353 | */ | 353 | */ |
354 | /* | 354 | /* |
355 | static int frame = 0; | 355 | static int frame = 0; |
356 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 356 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
357 | frame = frame >= 7 ? 0 : frame + 1; | 357 | frame = frame >= 7 ? 0 : frame + 1; |
358 | } | 358 | } |
359 | */ | 359 | */ |
360 | } | 360 | } |
361 | 361 | ||
362 | 362 | ||
363 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 363 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
364 | for ( int i = 0; i < numButtons; i++ ) { | 364 | for ( int i = 0; i < numButtons; i++ ) { |
365 | if ( event->state() == QMouseEvent::LeftButton ) { | 365 | if ( event->state() == QMouseEvent::LeftButton ) { |
366 | 366 | ||
367 | // The test to see if the mouse click is inside the button or not | 367 | // The test to see if the mouse click is inside the button or not |
368 | int x = event->pos().x() - xoff; | 368 | int x = event->pos().x() - xoff; |
369 | int y = event->pos().y() - yoff; | 369 | int y = event->pos().y() - yoff; |
370 | 370 | ||
371 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 371 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
372 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 372 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
373 | 373 | ||
374 | // if ( isOnButton && i == AudioVolumeUp ) | 374 | // if ( isOnButton && i == AudioVolumeUp ) |
375 | // qDebug("on up"); | 375 | // qDebug("on up"); |
376 | 376 | ||
377 | if ( isOnButton && !audioButtons[i].isHeld ) { | 377 | if ( isOnButton && !audioButtons[i].isHeld ) { |
378 | audioButtons[i].isHeld = TRUE; | 378 | audioButtons[i].isHeld = TRUE; |
379 | toggleButton(i); | 379 | toggleButton(i); |
380 | switch (i) { | 380 | switch (i) { |
381 | case AudioVolumeUp: | 381 | case AudioVolumeUp: |
382 | // qDebug("more clicked"); | 382 | // qDebug("more clicked"); |
383 | emit moreClicked(); | 383 | emit moreClicked(); |
384 | return; | 384 | return; |
385 | case AudioVolumeDown: | 385 | case AudioVolumeDown: |
386 | // qDebug("less clicked"); | 386 | // qDebug("less clicked"); |
387 | emit lessClicked(); | 387 | emit lessClicked(); |
388 | return; | 388 | return; |
389 | case AudioForward: | 389 | case AudioForward: |
390 | emit forwardClicked(); | 390 | emit forwardClicked(); |
391 | return; | 391 | return; |
392 | case AudioBack: | 392 | case AudioBack: |
393 | emit backClicked(); | 393 | emit backClicked(); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 396 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
397 | audioButtons[i].isHeld = FALSE; | 397 | audioButtons[i].isHeld = FALSE; |
398 | toggleButton(i); | 398 | toggleButton(i); |
399 | } | 399 | } |
400 | } else { | 400 | } else { |
401 | if ( audioButtons[i].isHeld ) { | 401 | if ( audioButtons[i].isHeld ) { |
402 | audioButtons[i].isHeld = FALSE; | 402 | audioButtons[i].isHeld = FALSE; |
403 | if ( !audioButtons[i].isToggle ) | 403 | if ( !audioButtons[i].isToggle ) |
404 | setToggleButton( i, FALSE ); | 404 | setToggleButton( i, FALSE ); |
405 | switch (i) { | 405 | switch (i) { |
406 | case AudioPlay: | 406 | case AudioPlay: |
407 | if( mediaPlayerState->isPaused ) { | 407 | if( mediaPlayerState->isPaused ) { |
408 | mediaPlayerState->setPaused( FALSE ); | 408 | mediaPlayerState->setPaused( FALSE ); |
409 | return; | 409 | return; |
410 | } else if( !mediaPlayerState->isPaused ) { | 410 | } else if( !mediaPlayerState->isPaused ) { |
411 | mediaPlayerState->setPaused( TRUE ); | 411 | mediaPlayerState->setPaused( TRUE ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | // case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 414 | // case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
415 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 415 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
416 | // case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 416 | // case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
417 | case AudioNext: mediaPlayerState->setNext(); return; | 417 | case AudioNext: mediaPlayerState->setNext(); return; |
418 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 418 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
419 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 419 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
420 | case AudioVolumeUp: emit moreReleased(); return; | 420 | case AudioVolumeUp: emit moreReleased(); return; |
421 | case AudioVolumeDown: emit lessReleased(); return; | 421 | case AudioVolumeDown: emit lessReleased(); return; |
422 | case AudioPlayList: mediaPlayerState->setList(); return; | 422 | case AudioPlayList: mediaPlayerState->setList(); return; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 431 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
432 | mouseMoveEvent( event ); | 432 | mouseMoveEvent( event ); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 436 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
437 | mouseMoveEvent( event ); | 437 | mouseMoveEvent( event ); |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void AudioWidget::showEvent( QShowEvent* ) { | 441 | void AudioWidget::showEvent( QShowEvent* ) { |
442 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 442 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
443 | mouseMoveEvent( &event ); | 443 | mouseMoveEvent( &event ); |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | void AudioWidget::closeEvent( QCloseEvent* ) { | 447 | void AudioWidget::closeEvent( QCloseEvent* ) { |
448 | mediaPlayerState->setList(); | 448 | mediaPlayerState->setList(); |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 452 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
453 | if ( !pe->erased() ) { | 453 | if ( !pe->erased() ) { |
454 | // Combine with background and double buffer | 454 | // Combine with background and double buffer |
455 | QPixmap pix( pe->rect().size() ); | 455 | QPixmap pix( pe->rect().size() ); |
456 | QPainter p( &pix ); | 456 | QPainter p( &pix ); |
457 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 457 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
458 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 458 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
459 | for ( int i = 0; i < numButtons; i++ ) | 459 | for ( int i = 0; i < numButtons; i++ ) |
460 | paintButton( &p, i ); | 460 | paintButton( &p, i ); |
461 | QPainter p2( this ); | 461 | QPainter p2( this ); |
462 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 462 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
463 | } else { | 463 | } else { |
464 | QPainter p( this ); | 464 | QPainter p( this ); |
465 | for ( int i = 0; i < numButtons; i++ ) | 465 | for ( int i = 0; i < numButtons; i++ ) |
466 | paintButton( &p, i ); | 466 | paintButton( &p, i ); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 470 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
471 | { | 471 | { |
472 | switch ( e->key() ) { | 472 | switch ( e->key() ) { |
473 | ////////////////////////////// Zaurus keys | 473 | ////////////////////////////// Zaurus keys |
474 | case Key_Home: | 474 | case Key_Home: |
475 | break; | 475 | break; |
476 | case Key_F9: //activity | 476 | case Key_F9: //activity |
477 | hide(); | 477 | hide(); |
478 | // qDebug("Audio F9"); | 478 | // qDebug("Audio F9"); |
479 | break; | 479 | break; |
480 | case Key_F10: //contacts | 480 | case Key_F10: //contacts |
481 | break; | 481 | break; |
482 | case Key_F11: //menu | 482 | case Key_F11: //menu |
483 | break; | 483 | break; |
484 | case Key_F12: //home | 484 | case Key_F12: //home |
485 | break; | 485 | break; |
486 | case Key_F13: //mail | 486 | case Key_F13: //mail |
487 | break; | 487 | break; |
488 | case Key_Space: { | 488 | case Key_Space: { |
489 | 489 | ||
490 | if(mediaPlayerState->playing()) { | 490 | if(mediaPlayerState->playing()) { |
491 | // toggleButton(1); | 491 | // toggleButton(1); |
492 | mediaPlayerState->setPlaying(FALSE); | 492 | mediaPlayerState->setPlaying(FALSE); |
493 | // toggleButton(1); | 493 | // toggleButton(1); |
494 | } else { | 494 | } else { |
495 | // toggleButton(0); | 495 | // toggleButton(0); |
496 | mediaPlayerState->setPlaying(TRUE); | 496 | mediaPlayerState->setPlaying(TRUE); |
497 | // toggleButton(0); | 497 | // toggleButton(0); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | break; | 500 | break; |
501 | case Key_Down: //volume | 501 | case Key_Down: //volume |
502 | // toggleButton(6); | 502 | // toggleButton(6); |
503 | emit lessClicked(); | 503 | emit lessClicked(); |
504 | emit lessReleased(); | 504 | emit lessReleased(); |
505 | // toggleButton(6); | 505 | // toggleButton(6); |
506 | break; | 506 | break; |
507 | case Key_Up: //volume | 507 | case Key_Up: //volume |
508 | // toggleButton(5); | 508 | // toggleButton(5); |
509 | emit moreClicked(); | 509 | emit moreClicked(); |
510 | emit moreReleased(); | 510 | emit moreReleased(); |
511 | // toggleButton(5); | 511 | // toggleButton(5); |
512 | break; | 512 | break; |
513 | case Key_Right: //next in playlist | 513 | case Key_Right: //next in playlist |
514 | // toggleButton(3); | 514 | // toggleButton(3); |
515 | mediaPlayerState->setNext(); | 515 | mediaPlayerState->setNext(); |
516 | // toggleButton(3); | 516 | // toggleButton(3); |
517 | break; | 517 | break; |
518 | case Key_Left: // previous in playlist | 518 | case Key_Left: // previous in playlist |
519 | // toggleButton(4); | 519 | // toggleButton(4); |
520 | mediaPlayerState->setPrev(); | 520 | mediaPlayerState->setPrev(); |
521 | // toggleButton(4); | 521 | // toggleButton(4); |
522 | break; | 522 | break; |
523 | case Key_Escape: | 523 | case Key_Escape: |
524 | break; | 524 | break; |
525 | 525 | ||
526 | }; | 526 | }; |
527 | } | 527 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 82fd1e1..db99866 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1482 +1,1482 @@ | |||
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 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qtoolbar.h> | 25 | #include <qtoolbar.h> |
26 | #include <qpe/qpemenubar.h> | 26 | #include <qpe/qpemenubar.h> |
27 | #include <qpe/fileselector.h> | 27 | #include <qpe/fileselector.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <qpe/lnkproperties.h> | 29 | #include <qpe/lnkproperties.h> |
30 | #include <qpe/storage.h> | 30 | #include <qpe/storage.h> |
31 | 31 | ||
32 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qcursor.h> | 37 | #include <qcursor.h> |
38 | #include <qimage.h> | 38 | #include <qimage.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlist.h> | 43 | #include <qlist.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qmainwindow.h> | 45 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qtoolbutton.h> | 47 | #include <qtoolbutton.h> |
48 | #include <qtabwidget.h> | 48 | #include <qtabwidget.h> |
49 | #include <qlistview.h> | 49 | #include <qlistview.h> |
50 | #include <qpoint.h> | 50 | #include <qpoint.h> |
51 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
52 | #include <qpushbutton.h> | 52 | #include <qpushbutton.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qtextstream.h> | 54 | #include <qtextstream.h> |
55 | 55 | ||
56 | //#include <qtimer.h> | 56 | //#include <qtimer.h> |
57 | 57 | ||
58 | #include "playlistselection.h" | 58 | #include "playlistselection.h" |
59 | #include "playlistwidget.h" | 59 | #include "playlistwidget.h" |
60 | #include "mediaplayerstate.h" | 60 | #include "mediaplayerstate.h" |
61 | 61 | ||
62 | #include "inputDialog.h" | 62 | #include "inputDialog.h" |
63 | 63 | ||
64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
65 | #include "audiowidget.h" | 65 | #include "audiowidget.h" |
66 | #include "videowidget.h" | 66 | #include "videowidget.h" |
67 | 67 | ||
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | #include <sys/file.h> | 69 | #include <sys/file.h> |
70 | #include <sys/ioctl.h> | 70 | #include <sys/ioctl.h> |
71 | #include <sys/soundcard.h> | 71 | #include <sys/soundcard.h> |
72 | 72 | ||
73 | // for setBacklight() | 73 | // for setBacklight() |
74 | #include <linux/fb.h> | 74 | #include <linux/fb.h> |
75 | #include <sys/types.h> | 75 | #include <sys/types.h> |
76 | #include <sys/stat.h> | 76 | #include <sys/stat.h> |
77 | #include <stdlib.h> | 77 | #include <stdlib.h> |
78 | 78 | ||
79 | #define BUTTONS_ON_TOOLBAR | 79 | #define BUTTONS_ON_TOOLBAR |
80 | #define SIDE_BUTTONS | 80 | #define SIDE_BUTTONS |
81 | #define CAN_SAVE_LOAD_PLAYLISTS | 81 | #define CAN_SAVE_LOAD_PLAYLISTS |
82 | 82 | ||
83 | extern AudioWidget *audioUI; | 83 | extern AudioWidget *audioUI; |
84 | extern VideoWidget *videoUI; | 84 | extern VideoWidget *videoUI; |
85 | extern MediaPlayerState *mediaPlayerState; | 85 | extern MediaPlayerState *mediaPlayerState; |
86 | 86 | ||
87 | static inline QString fullBaseName ( const QFileInfo &fi ) | 87 | static inline QString fullBaseName ( const QFileInfo &fi ) |
88 | { | 88 | { |
89 | QString str = fi. fileName ( ); | 89 | QString str = fi. fileName ( ); |
90 | return str. left ( str. findRev ( '.' )); | 90 | return str. left ( str. findRev ( '.' )); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 94 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; |
95 | // class myFileSelector { | 95 | // class myFileSelector { |
96 | 96 | ||
97 | // }; | 97 | // }; |
98 | class PlayListWidgetPrivate { | 98 | class PlayListWidgetPrivate { |
99 | public: | 99 | public: |
100 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 100 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
101 | QFrame *playListFrame; | 101 | QFrame *playListFrame; |
102 | FileSelector *files; | 102 | FileSelector *files; |
103 | PlayListSelection *selectedFiles; | 103 | PlayListSelection *selectedFiles; |
104 | bool setDocumentUsed; | 104 | bool setDocumentUsed; |
105 | DocLnk *current; | 105 | DocLnk *current; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | class ToolButton : public QToolButton { | 109 | class ToolButton : public QToolButton { |
110 | public: | 110 | public: |
111 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 111 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
112 | : QToolButton( parent, name ) { | 112 | : QToolButton( parent, name ) { |
113 | setTextLabel( name ); | 113 | setTextLabel( name ); |
114 | setPixmap( Resource::loadPixmap( icon ) ); | 114 | setPixmap( Resource::loadPixmap( icon ) ); |
115 | setAutoRaise( TRUE ); | 115 | setAutoRaise( TRUE ); |
116 | setFocusPolicy( QWidget::NoFocus ); | 116 | setFocusPolicy( QWidget::NoFocus ); |
117 | setToggleButton( t ); | 117 | setToggleButton( t ); |
118 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 118 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
119 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 119 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
120 | } | 120 | } |
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | class MenuItem : public QAction { | 124 | class MenuItem : public QAction { |
125 | public: | 125 | public: |
126 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 126 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
127 | : QAction( text, QString::null, 0, 0 ) { | 127 | : QAction( text, QString::null, 0, 0 ) { |
128 | connect( this, SIGNAL( activated() ), handler, slot ); | 128 | connect( this, SIGNAL( activated() ), handler, slot ); |
129 | addTo( parent ); | 129 | addTo( parent ); |
130 | } | 130 | } |
131 | }; | 131 | }; |
132 | 132 | ||
133 | 133 | ||
134 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 134 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
135 | : QMainWindow( parent, name, fl ) { | 135 | : QMainWindow( parent, name, fl ) { |
136 | 136 | ||
137 | d = new PlayListWidgetPrivate; | 137 | d = new PlayListWidgetPrivate; |
138 | d->setDocumentUsed = FALSE; | 138 | d->setDocumentUsed = FALSE; |
139 | d->current = NULL; | 139 | d->current = NULL; |
140 | fromSetDocument = FALSE; | 140 | fromSetDocument = FALSE; |
141 | insanityBool=FALSE; | 141 | insanityBool=FALSE; |
142 | audioScan = FALSE; | 142 | audioScan = FALSE; |
143 | videoScan = FALSE; | 143 | videoScan = FALSE; |
144 | // menuTimer = new QTimer( this ,"menu timer"), | 144 | // menuTimer = new QTimer( this ,"menu timer"), |
145 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 145 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
146 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 146 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
147 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 147 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
148 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 148 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
149 | 149 | ||
150 | setBackgroundMode( PaletteButton ); | 150 | setBackgroundMode( PaletteButton ); |
151 | 151 | ||
152 | setCaption( tr("OpiePlayer") ); | 152 | setCaption( tr("OpiePlayer") ); |
153 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 153 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
154 | 154 | ||
155 | setToolBarsMovable( FALSE ); | 155 | setToolBarsMovable( FALSE ); |
156 | 156 | ||
157 | // Create Toolbar | 157 | // Create Toolbar |
158 | QToolBar *toolbar = new QToolBar( this ); | 158 | QToolBar *toolbar = new QToolBar( this ); |
159 | toolbar->setHorizontalStretchable( TRUE ); | 159 | toolbar->setHorizontalStretchable( TRUE ); |
160 | 160 | ||
161 | // Create Menubar | 161 | // Create Menubar |
162 | QMenuBar *menu = new QMenuBar( toolbar ); | 162 | QMenuBar *menu = new QMenuBar( toolbar ); |
163 | menu->setMargin( 0 ); | 163 | menu->setMargin( 0 ); |
164 | 164 | ||
165 | QToolBar *bar = new QToolBar( this ); | 165 | QToolBar *bar = new QToolBar( this ); |
166 | bar->setLabel( tr( "Play Operations" ) ); | 166 | bar->setLabel( tr( "Play Operations" ) ); |
167 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 167 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
168 | // this , SLOT( addSelected()) ); | 168 | // this , SLOT( addSelected()) ); |
169 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 169 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
170 | tbDeletePlaylist->setFlat(TRUE); | 170 | tbDeletePlaylist->setFlat(TRUE); |
171 | 171 | ||
172 | tbDeletePlaylist->setFixedSize(20,20); | 172 | tbDeletePlaylist->setFixedSize(20,20); |
173 | 173 | ||
174 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 174 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
175 | this , SLOT(addSelected()) ); | 175 | this , SLOT(addSelected()) ); |
176 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 176 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
177 | this , SLOT(removeSelected()) ); | 177 | this , SLOT(removeSelected()) ); |
178 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 178 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
179 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 179 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
180 | this , SLOT( btnPlay(bool) ), TRUE ); | 180 | this , SLOT( btnPlay(bool) ), TRUE ); |
181 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 181 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
182 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 182 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
183 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 183 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
184 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 184 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
185 | tbDeletePlaylist->hide(); | 185 | tbDeletePlaylist->hide(); |
186 | 186 | ||
187 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 187 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
188 | menu->insertItem( tr( "File" ), pmPlayList ); | 188 | menu->insertItem( tr( "File" ), pmPlayList ); |
189 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
191 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 191 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
192 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 192 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
193 | pmPlayList->insertSeparator(-1); | 193 | pmPlayList->insertSeparator(-1); |
194 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 194 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
195 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 195 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
196 | pmPlayList->insertSeparator(-1); | 196 | pmPlayList->insertSeparator(-1); |
197 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 197 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
198 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 198 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
199 | 199 | ||
200 | QPopupMenu *pmView = new QPopupMenu( this ); | 200 | QPopupMenu *pmView = new QPopupMenu( this ); |
201 | menu->insertItem( tr( "View" ), pmView ); | 201 | menu->insertItem( tr( "View" ), pmView ); |
202 | 202 | ||
203 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 203 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
204 | fullScreenButton->addTo(pmView); | 204 | fullScreenButton->addTo(pmView); |
205 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 205 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
206 | scaleButton->addTo(pmView); | 206 | scaleButton->addTo(pmView); |
207 | 207 | ||
208 | 208 | ||
209 | skinsMenu = new QPopupMenu( this ); | 209 | skinsMenu = new QPopupMenu( this ); |
210 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 210 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
211 | skinsMenu->isCheckable(); | 211 | skinsMenu->isCheckable(); |
212 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 212 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
213 | this, SLOT( skinsMenuActivated( int ) ) ); | 213 | this, SLOT( skinsMenuActivated( int ) ) ); |
214 | populateSkinsMenu(); | 214 | populateSkinsMenu(); |
215 | 215 | ||
216 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 216 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
217 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 217 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
218 | 218 | ||
219 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 219 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
220 | 220 | ||
221 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 221 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
222 | // tabWidget->setTabShape(QTabWidget::Triangular); | 222 | // tabWidget->setTabShape(QTabWidget::Triangular); |
223 | 223 | ||
224 | QWidget *pTab; | 224 | QWidget *pTab; |
225 | pTab = new QWidget( tabWidget, "pTab" ); | 225 | pTab = new QWidget( tabWidget, "pTab" ); |
226 | // playlistView = new QListView( pTab, "playlistview" ); | 226 | // playlistView = new QListView( pTab, "playlistview" ); |
227 | // playlistView->setMinimumSize(236,260); | 227 | // playlistView->setMinimumSize(236,260); |
228 | tabWidget->insertTab( pTab,"Playlist"); | 228 | tabWidget->insertTab( pTab,"Playlist"); |
229 | 229 | ||
230 | 230 | ||
231 | // Add the playlist area | 231 | // Add the playlist area |
232 | 232 | ||
233 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 233 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
234 | d->playListFrame = vbox3; | 234 | d->playListFrame = vbox3; |
235 | 235 | ||
236 | QGridLayout *layoutF = new QGridLayout( pTab ); | 236 | QGridLayout *layoutF = new QGridLayout( pTab ); |
237 | layoutF->setSpacing( 2); | 237 | layoutF->setSpacing( 2); |
238 | layoutF->setMargin( 2); | 238 | layoutF->setMargin( 2); |
239 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 239 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
240 | 240 | ||
241 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 241 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
242 | 242 | ||
243 | d->selectedFiles = new PlayListSelection( hbox2); | 243 | d->selectedFiles = new PlayListSelection( hbox2); |
244 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 244 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
245 | 245 | ||
246 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 246 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
247 | 247 | ||
248 | 248 | ||
249 | 249 | ||
250 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 250 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
251 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 251 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
252 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 252 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
253 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 253 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
254 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 254 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
255 | 255 | ||
256 | QWidget *aTab; | 256 | QWidget *aTab; |
257 | aTab = new QWidget( tabWidget, "aTab" ); | 257 | aTab = new QWidget( tabWidget, "aTab" ); |
258 | audioView = new QListView( aTab, "Audioview" ); | 258 | audioView = new QListView( aTab, "Audioview" ); |
259 | 259 | ||
260 | QGridLayout *layoutA = new QGridLayout( aTab ); | 260 | QGridLayout *layoutA = new QGridLayout( aTab ); |
261 | layoutA->setSpacing( 2); | 261 | layoutA->setSpacing( 2); |
262 | layoutA->setMargin( 2); | 262 | layoutA->setMargin( 2); |
263 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 263 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
264 | 264 | ||
265 | audioView->addColumn( tr("Title"),-1); | 265 | audioView->addColumn( tr("Title"),-1); |
266 | audioView->addColumn(tr("Size"), -1); | 266 | audioView->addColumn(tr("Size"), -1); |
267 | audioView->addColumn(tr("Media"),-1); | 267 | audioView->addColumn(tr("Media"),-1); |
268 | audioView->addColumn( tr( "Path" ), -1 ); | 268 | audioView->addColumn( tr( "Path" ), -1 ); |
269 | 269 | ||
270 | audioView->setColumnAlignment(1, Qt::AlignRight); | 270 | audioView->setColumnAlignment(1, Qt::AlignRight); |
271 | audioView->setColumnAlignment(2, Qt::AlignRight); | 271 | audioView->setColumnAlignment(2, Qt::AlignRight); |
272 | audioView->setAllColumnsShowFocus(TRUE); | 272 | audioView->setAllColumnsShowFocus(TRUE); |
273 | 273 | ||
274 | audioView->setMultiSelection( TRUE ); | 274 | audioView->setMultiSelection( TRUE ); |
275 | audioView->setSelectionMode( QListView::Extended); | 275 | audioView->setSelectionMode( QListView::Extended); |
276 | audioView->setSorting( 3, TRUE ); | 276 | audioView->setSorting( 3, TRUE ); |
277 | 277 | ||
278 | tabWidget->insertTab(aTab,tr("Audio")); | 278 | tabWidget->insertTab(aTab,tr("Audio")); |
279 | 279 | ||
280 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 280 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
281 | 281 | ||
282 | // audioView | 282 | // audioView |
283 | // populateAudioView(); | 283 | // populateAudioView(); |
284 | // videowidget | 284 | // videowidget |
285 | 285 | ||
286 | QWidget *vTab; | 286 | QWidget *vTab; |
287 | vTab = new QWidget( tabWidget, "vTab" ); | 287 | vTab = new QWidget( tabWidget, "vTab" ); |
288 | videoView = new QListView( vTab, "Videoview" ); | 288 | videoView = new QListView( vTab, "Videoview" ); |
289 | 289 | ||
290 | QGridLayout *layoutV = new QGridLayout( vTab ); | 290 | QGridLayout *layoutV = new QGridLayout( vTab ); |
291 | layoutV->setSpacing( 2); | 291 | layoutV->setSpacing( 2); |
292 | layoutV->setMargin( 2); | 292 | layoutV->setMargin( 2); |
293 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 293 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
294 | 294 | ||
295 | videoView->addColumn(tr("Title"),-1); | 295 | videoView->addColumn(tr("Title"),-1); |
296 | videoView->addColumn(tr("Size"),-1); | 296 | videoView->addColumn(tr("Size"),-1); |
297 | videoView->addColumn(tr("Media"),-1); | 297 | videoView->addColumn(tr("Media"),-1); |
298 | videoView->addColumn(tr( "Path" ), -1 ); | 298 | videoView->addColumn(tr( "Path" ), -1 ); |
299 | videoView->setColumnAlignment(1, Qt::AlignRight); | 299 | videoView->setColumnAlignment(1, Qt::AlignRight); |
300 | videoView->setColumnAlignment(2, Qt::AlignRight); | 300 | videoView->setColumnAlignment(2, Qt::AlignRight); |
301 | videoView->setAllColumnsShowFocus(TRUE); | 301 | videoView->setAllColumnsShowFocus(TRUE); |
302 | videoView->setMultiSelection( TRUE ); | 302 | videoView->setMultiSelection( TRUE ); |
303 | videoView->setSelectionMode( QListView::Extended); | 303 | videoView->setSelectionMode( QListView::Extended); |
304 | 304 | ||
305 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 305 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
306 | 306 | ||
307 | tabWidget->insertTab( vTab,tr("Video")); | 307 | tabWidget->insertTab( vTab,tr("Video")); |
308 | 308 | ||
309 | QWidget *LTab; | 309 | QWidget *LTab; |
310 | LTab = new QWidget( tabWidget, "LTab" ); | 310 | LTab = new QWidget( tabWidget, "LTab" ); |
311 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); | 311 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
312 | 312 | ||
313 | QGridLayout *layoutL = new QGridLayout( LTab ); | 313 | QGridLayout *layoutL = new QGridLayout( LTab ); |
314 | layoutL->setSpacing( 2); | 314 | layoutL->setSpacing( 2); |
315 | layoutL->setMargin( 2); | 315 | layoutL->setMargin( 2); |
316 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 316 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
317 | 317 | ||
318 | tabWidget->insertTab(LTab,tr("Lists")); | 318 | tabWidget->insertTab(LTab,tr("Lists")); |
319 | 319 | ||
320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 321 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 322 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
323 | 323 | ||
324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 324 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 325 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
326 | 326 | ||
327 | 327 | ||
328 | ///audioView | 328 | ///audioView |
329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 329 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 330 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
331 | 331 | ||
332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 332 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
333 | this,SLOT( playIt( QListViewItem *)) ); | 333 | this,SLOT( playIt( QListViewItem *)) ); |
334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 334 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
335 | 335 | ||
336 | 336 | ||
337 | //videoView | 337 | //videoView |
338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 338 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 339 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 340 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
341 | this,SLOT( playIt( QListViewItem *)) ); | 341 | this,SLOT( playIt( QListViewItem *)) ); |
342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 342 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
343 | 343 | ||
344 | //playlists | 344 | //playlists |
345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 345 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
346 | 346 | ||
347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 347 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
348 | 348 | ||
349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 349 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
350 | 350 | ||
351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 351 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 352 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 353 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
354 | 354 | ||
355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 355 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
356 | 356 | ||
357 | setCentralWidget( vbox5 ); | 357 | setCentralWidget( vbox5 ); |
358 | 358 | ||
359 | Config cfg( "OpiePlayer" ); | 359 | Config cfg( "OpiePlayer" ); |
360 | readConfig( cfg ); | 360 | readConfig( cfg ); |
361 | 361 | ||
362 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 362 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
363 | loadList(DocLnk( currentPlayList)); | 363 | loadList(DocLnk( currentPlayList)); |
364 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 364 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
365 | 365 | ||
366 | initializeStates(); | 366 | initializeStates(); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | PlayListWidget::~PlayListWidget() { | 370 | PlayListWidget::~PlayListWidget() { |
371 | Config cfg( "OpiePlayer" ); | 371 | Config cfg( "OpiePlayer" ); |
372 | writeConfig( cfg ); | 372 | writeConfig( cfg ); |
373 | 373 | ||
374 | if ( d->current ) | 374 | if ( d->current ) |
375 | delete d->current; | 375 | delete d->current; |
376 | if(d) delete d; | 376 | if(d) delete d; |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void PlayListWidget::initializeStates() { | 380 | void PlayListWidget::initializeStates() { |
381 | 381 | ||
382 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 382 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
383 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 383 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 384 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
385 | setPlaylist( true); | 385 | setPlaylist( true); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void PlayListWidget::readConfig( Config& cfg ) { | 389 | void PlayListWidget::readConfig( Config& cfg ) { |
390 | cfg.setGroup("PlayList"); | 390 | cfg.setGroup("PlayList"); |
391 | QString currentString = cfg.readEntry("current", "" ); | 391 | QString currentString = cfg.readEntry("current", "" ); |
392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 392 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
393 | for ( int i = 0; i < noOfFiles; i++ ) { | 393 | for ( int i = 0; i < noOfFiles; i++ ) { |
394 | QString entryName; | 394 | QString entryName; |
395 | entryName.sprintf( "File%i", i + 1 ); | 395 | entryName.sprintf( "File%i", i + 1 ); |
396 | QString linkFile = cfg.readEntry( entryName ); | 396 | QString linkFile = cfg.readEntry( entryName ); |
397 | DocLnk lnk( linkFile ); | 397 | DocLnk lnk( linkFile ); |
398 | if ( lnk.isValid() ) { | 398 | if ( lnk.isValid() ) { |
399 | d->selectedFiles->addToSelection( lnk ); | 399 | d->selectedFiles->addToSelection( lnk ); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | d->selectedFiles->setSelectedItem( currentString); | 402 | d->selectedFiles->setSelectedItem( currentString); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | void PlayListWidget::writeConfig( Config& cfg ) const { | 406 | void PlayListWidget::writeConfig( Config& cfg ) const { |
407 | 407 | ||
408 | d->selectedFiles->writeCurrent( cfg); | 408 | d->selectedFiles->writeCurrent( cfg); |
409 | cfg.setGroup("PlayList"); | 409 | cfg.setGroup("PlayList"); |
410 | int noOfFiles = 0; | 410 | int noOfFiles = 0; |
411 | d->selectedFiles->first(); | 411 | d->selectedFiles->first(); |
412 | do { | 412 | do { |
413 | const DocLnk *lnk = d->selectedFiles->current(); | 413 | const DocLnk *lnk = d->selectedFiles->current(); |
414 | if ( lnk ) { | 414 | if ( lnk ) { |
415 | QString entryName; | 415 | QString entryName; |
416 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 416 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
417 | // qDebug(entryName); | 417 | // qDebug(entryName); |
418 | cfg.writeEntry( entryName, lnk->linkFile() ); | 418 | cfg.writeEntry( entryName, lnk->linkFile() ); |
419 | // if this link does exist, add it so we have the file | 419 | // if this link does exist, add it so we have the file |
420 | // next time... | 420 | // next time... |
421 | if ( !QFile::exists( lnk->linkFile() ) ) { | 421 | if ( !QFile::exists( lnk->linkFile() ) ) { |
422 | // the way writing lnks doesn't really check for out | 422 | // the way writing lnks doesn't really check for out |
423 | // of disk space, but check it anyway. | 423 | // of disk space, but check it anyway. |
424 | // if ( !lnk->writeLink() ) { | 424 | // if ( !lnk->writeLink() ) { |
425 | // QMessageBox::critical( 0, tr("Out of space"), | 425 | // QMessageBox::critical( 0, tr("Out of space"), |
426 | // tr( "There was a problem saving " | 426 | // tr( "There was a problem saving " |
427 | // "the playlist.\n" | 427 | // "the playlist.\n" |
428 | // "Your playlist " | 428 | // "Your playlist " |
429 | // "may be missing some entries\n" | 429 | // "may be missing some entries\n" |
430 | // "the next time you start it." ) | 430 | // "the next time you start it." ) |
431 | // ); | 431 | // ); |
432 | // } | 432 | // } |
433 | 433 | ||
434 | } | 434 | } |
435 | noOfFiles++; | 435 | noOfFiles++; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | while ( d->selectedFiles->next() ); | 438 | while ( d->selectedFiles->next() ); |
439 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 439 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
440 | } | 440 | } |
441 | 441 | ||
442 | 442 | ||
443 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 443 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
444 | d->setDocumentUsed = false; | 444 | d->setDocumentUsed = false; |
445 | if ( mediaPlayerState->playlist() ) { | 445 | if ( mediaPlayerState->playlist() ) { |
446 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 446 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
447 | d->selectedFiles->addToSelection( lnk ); | 447 | d->selectedFiles->addToSelection( lnk ); |
448 | } | 448 | } |
449 | else | 449 | else |
450 | mediaPlayerState->setPlaying( true); | 450 | mediaPlayerState->setPlaying( true); |
451 | 451 | ||
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | void PlayListWidget::clearList() { | 455 | void PlayListWidget::clearList() { |
456 | while ( first() ) | 456 | while ( first() ) |
457 | d->selectedFiles->removeSelected(); | 457 | d->selectedFiles->removeSelected(); |
458 | Config cfg( "OpiePlayer" ); | 458 | Config cfg( "OpiePlayer" ); |
459 | cfg.setGroup("PlayList"); | 459 | cfg.setGroup("PlayList"); |
460 | cfg.writeEntry("CurrentPlaylist",""); | 460 | cfg.writeEntry("CurrentPlaylist",""); |
461 | currentPlayList=""; | 461 | currentPlayList=""; |
462 | 462 | ||
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | void PlayListWidget::addAllToList() { | 466 | void PlayListWidget::addAllToList() { |
467 | DocLnkSet filesAll; | 467 | DocLnkSet filesAll; |
468 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 468 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
469 | QListIterator<DocLnk> Adit( filesAll.children() ); | 469 | QListIterator<DocLnk> Adit( filesAll.children() ); |
470 | for ( ; Adit.current(); ++Adit ) | 470 | for ( ; Adit.current(); ++Adit ) |
471 | if(QFileInfo(Adit.current()->file()).exists()) | 471 | if(QFileInfo(Adit.current()->file()).exists()) |
472 | d->selectedFiles->addToSelection( **Adit ); | 472 | d->selectedFiles->addToSelection( **Adit ); |
473 | tabWidget->setCurrentPage(0); | 473 | tabWidget->setCurrentPage(0); |
474 | 474 | ||
475 | writeCurrentM3u(); | 475 | writeCurrentM3u(); |
476 | d->selectedFiles->first(); | 476 | d->selectedFiles->first(); |
477 | } | 477 | } |
478 | 478 | ||
479 | 479 | ||
480 | void PlayListWidget::addAllMusicToList() { | 480 | void PlayListWidget::addAllMusicToList() { |
481 | QListIterator<DocLnk> dit( files.children() ); | 481 | QListIterator<DocLnk> dit( files.children() ); |
482 | for ( ; dit.current(); ++dit ) | 482 | for ( ; dit.current(); ++dit ) |
483 | if(QFileInfo(dit.current()->file()).exists()) | 483 | if(QFileInfo(dit.current()->file()).exists()) |
484 | d->selectedFiles->addToSelection( **dit ); | 484 | d->selectedFiles->addToSelection( **dit ); |
485 | tabWidget->setCurrentPage(0); | 485 | tabWidget->setCurrentPage(0); |
486 | 486 | ||
487 | writeCurrentM3u(); | 487 | writeCurrentM3u(); |
488 | d->selectedFiles->first(); | 488 | d->selectedFiles->first(); |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
492 | void PlayListWidget::addAllVideoToList() { | 492 | void PlayListWidget::addAllVideoToList() { |
493 | QListIterator<DocLnk> dit( vFiles.children() ); | 493 | QListIterator<DocLnk> dit( vFiles.children() ); |
494 | for ( ; dit.current(); ++dit ) | 494 | for ( ; dit.current(); ++dit ) |
495 | if(QFileInfo( dit.current()->file()).exists()) | 495 | if(QFileInfo( dit.current()->file()).exists()) |
496 | d->selectedFiles->addToSelection( **dit ); | 496 | d->selectedFiles->addToSelection( **dit ); |
497 | tabWidget->setCurrentPage(0); | 497 | tabWidget->setCurrentPage(0); |
498 | 498 | ||
499 | writeCurrentM3u(); | 499 | writeCurrentM3u(); |
500 | d->selectedFiles->first(); | 500 | d->selectedFiles->first(); |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | void PlayListWidget::setDocument(const QString& fileref) { | 504 | void PlayListWidget::setDocument(const QString& fileref) { |
505 | fromSetDocument = true; | 505 | fromSetDocument = true; |
506 | d->setDocumentUsed = TRUE; | 506 | d->setDocumentUsed = TRUE; |
507 | setDocumentEx(fileref); | 507 | setDocumentEx(fileref); |
508 | } | 508 | } |
509 | 509 | ||
510 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 510 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
511 | qDebug("opieplayer receive "+fileref); | 511 | qDebug("opieplayer receive "+fileref); |
512 | clearList(); | 512 | clearList(); |
513 | DocLnk lnk; | 513 | DocLnk lnk; |
514 | QFileInfo fileInfo(fileref); | 514 | QFileInfo fileInfo(fileref); |
515 | if ( !fileInfo.exists() ) { | 515 | if ( !fileInfo.exists() ) { |
516 | QMessageBox::critical( 0, tr( "Invalid File" ), | 516 | QMessageBox::critical( 0, tr( "Invalid File" ), |
517 | tr( "There was a problem in getting the file." ) ); | 517 | tr( "There was a problem in getting the file." ) ); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); | 520 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); |
521 | QString extension = fileInfo.extension(false); | 521 | QString extension = fileInfo.extension(false); |
522 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 522 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
523 | readm3u( fileref); | 523 | readm3u( fileref); |
524 | } | 524 | } |
525 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 525 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
526 | readPls( fileref); | 526 | readPls( fileref); |
527 | } | 527 | } |
528 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 528 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
529 | clearList(); | 529 | clearList(); |
530 | lnk.setName( fileInfo.baseName() ); //sets name | 530 | lnk.setName( fileInfo.baseName() ); //sets name |
531 | lnk.setFile( fileref ); //sets file name | 531 | lnk.setFile( fileref ); //sets file name |
532 | lnk.setIcon("Sound"); | 532 | lnk.setIcon("Sound"); |
533 | //addToSelection( lnk ); | 533 | //addToSelection( lnk ); |
534 | 534 | ||
535 | loadList( lnk); | 535 | loadList( lnk); |
536 | d->selectedFiles->first(); | 536 | d->selectedFiles->first(); |
537 | } else { | 537 | } else { |
538 | if( fileref.find(".desktop",0,TRUE) != -1) { | 538 | if( fileref.find(".desktop",0,TRUE) != -1) { |
539 | lnk = DocLnk(fileref); | 539 | lnk = DocLnk(fileref); |
540 | } else { | 540 | } else { |
541 | lnk.setName( fileInfo.baseName() ); //sets name | 541 | lnk.setName( fileInfo.baseName() ); //sets name |
542 | lnk.setFile( fileref ); //sets file name | 542 | lnk.setFile( fileref ); //sets file name |
543 | lnk.setIcon("Sound"); | 543 | lnk.setIcon("Sound"); |
544 | } | 544 | } |
545 | 545 | ||
546 | addToSelection( lnk ); | 546 | addToSelection( lnk ); |
547 | // addToSelection( DocLnk( fileref ) ); | 547 | // addToSelection( DocLnk( fileref ) ); |
548 | lnk.removeLinkFile(); | 548 | lnk.removeLinkFile(); |
549 | // qApp->processEvents(); | 549 | // qApp->processEvents(); |
550 | } | 550 | } |
551 | setCaption(tr("OpiePlayer")); | 551 | setCaption(tr("OpiePlayer")); |
552 | d->setDocumentUsed = TRUE; | 552 | d->setDocumentUsed = TRUE; |
553 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | 553 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); |
554 | mediaPlayerState->setPlaying( FALSE ); | 554 | mediaPlayerState->setPlaying( FALSE ); |
555 | qApp->processEvents(); | 555 | qApp->processEvents(); |
556 | mediaPlayerState->setPlaying( TRUE ); | 556 | mediaPlayerState->setPlaying( TRUE ); |
557 | 557 | ||
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
561 | void PlayListWidget::setActiveWindow() { | 561 | void PlayListWidget::setActiveWindow() { |
562 | // qDebug("SETTING active window"); | 562 | // qDebug("SETTING active window"); |
563 | // When we get raised we need to ensure that it switches views | 563 | // When we get raised we need to ensure that it switches views |
564 | char origView = mediaPlayerState->view(); | 564 | char origView = mediaPlayerState->view(); |
565 | mediaPlayerState->setView( 'l' ); // invalidate | 565 | mediaPlayerState->setView( 'l' ); // invalidate |
566 | mediaPlayerState->setView( origView ); // now switch back | 566 | mediaPlayerState->setView( origView ); // now switch back |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | void PlayListWidget::useSelectedDocument() { | 570 | void PlayListWidget::useSelectedDocument() { |
571 | d->setDocumentUsed = FALSE; | 571 | d->setDocumentUsed = FALSE; |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | const DocLnk *PlayListWidget::current() { // this is fugly | 575 | const DocLnk *PlayListWidget::current() { // this is fugly |
576 | switch (tabWidget->currentPageIndex()) { | 576 | switch (tabWidget->currentPageIndex()) { |
577 | case 0: //playlist | 577 | case 0: //playlist |
578 | { | 578 | { |
579 | // qDebug("playlist"); | 579 | // qDebug("playlist"); |
580 | if ( mediaPlayerState->playlist() ) { | 580 | if ( mediaPlayerState->playlist() ) { |
581 | return d->selectedFiles->current(); | 581 | return d->selectedFiles->current(); |
582 | } | 582 | } |
583 | else if ( d->setDocumentUsed && d->current ) { | 583 | else if ( d->setDocumentUsed && d->current ) { |
584 | return d->current; | 584 | return d->current; |
585 | } else { | 585 | } else { |
586 | return &(d->files->selectedDocument()); | 586 | return &(d->files->selectedDocument()); |
587 | } | 587 | } |
588 | } | 588 | } |
589 | break; | 589 | break; |
590 | case 1://audio | 590 | case 1://audio |
591 | { | 591 | { |
592 | // qDebug("audioView"); | 592 | // qDebug("audioView"); |
593 | QListIterator<DocLnk> dit( files.children() ); | 593 | QListIterator<DocLnk> dit( files.children() ); |
594 | for ( ; dit.current(); ++dit ) { | 594 | for ( ; dit.current(); ++dit ) { |
595 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 595 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
596 | insanityBool=TRUE; | 596 | insanityBool=TRUE; |
597 | return dit; | 597 | return dit; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | break; | 601 | break; |
602 | case 2: // video | 602 | case 2: // video |
603 | { | 603 | { |
604 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 604 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
605 | for ( ; Vdit.current(); ++Vdit ) { | 605 | for ( ; Vdit.current(); ++Vdit ) { |
606 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 606 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
607 | insanityBool=TRUE; | 607 | insanityBool=TRUE; |
608 | return Vdit; | 608 | return Vdit; |
609 | } | 609 | } |
610 | } | 610 | } |
611 | } | 611 | } |
612 | break; | 612 | break; |
613 | }; | 613 | }; |
614 | return 0; | 614 | return 0; |
615 | } | 615 | } |
616 | 616 | ||
617 | bool PlayListWidget::prev() { | 617 | bool PlayListWidget::prev() { |
618 | if ( mediaPlayerState->playlist() ) { | 618 | if ( mediaPlayerState->playlist() ) { |
619 | if ( mediaPlayerState->shuffled() ) { | 619 | if ( mediaPlayerState->shuffled() ) { |
620 | const DocLnk *cur = current(); | 620 | const DocLnk *cur = current(); |
621 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 621 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
622 | for ( int i = 0; i < j; i++ ) { | 622 | for ( int i = 0; i < j; i++ ) { |
623 | if ( !d->selectedFiles->next() ) | 623 | if ( !d->selectedFiles->next() ) |
624 | d->selectedFiles->first(); | 624 | d->selectedFiles->first(); |
625 | } | 625 | } |
626 | if ( cur == current() ) | 626 | if ( cur == current() ) |
627 | if ( !d->selectedFiles->next() ) | 627 | if ( !d->selectedFiles->next() ) |
628 | d->selectedFiles->first(); | 628 | d->selectedFiles->first(); |
629 | return TRUE; | 629 | return TRUE; |
630 | } else { | 630 | } else { |
631 | if ( !d->selectedFiles->prev() ) { | 631 | if ( !d->selectedFiles->prev() ) { |
632 | if ( mediaPlayerState->looping() ) { | 632 | if ( mediaPlayerState->looping() ) { |
633 | return d->selectedFiles->last(); | 633 | return d->selectedFiles->last(); |
634 | } else { | 634 | } else { |
635 | return FALSE; | 635 | return FALSE; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | return TRUE; | 638 | return TRUE; |
639 | } | 639 | } |
640 | } else { | 640 | } else { |
641 | return mediaPlayerState->looping(); | 641 | return mediaPlayerState->looping(); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | bool PlayListWidget::next() { | 646 | bool PlayListWidget::next() { |
647 | if ( mediaPlayerState->playlist() ) { | 647 | if ( mediaPlayerState->playlist() ) { |
648 | if ( mediaPlayerState->shuffled() ) { | 648 | if ( mediaPlayerState->shuffled() ) { |
649 | return prev(); | 649 | return prev(); |
650 | } else { | 650 | } else { |
651 | if ( !d->selectedFiles->next() ) { | 651 | if ( !d->selectedFiles->next() ) { |
652 | if ( mediaPlayerState->looping() ) { | 652 | if ( mediaPlayerState->looping() ) { |
653 | return d->selectedFiles->first(); | 653 | return d->selectedFiles->first(); |
654 | } else { | 654 | } else { |
655 | return FALSE; | 655 | return FALSE; |
656 | } | 656 | } |
657 | } | 657 | } |
658 | return TRUE; | 658 | return TRUE; |
659 | } | 659 | } |
660 | } else { | 660 | } else { |
661 | return mediaPlayerState->looping(); | 661 | return mediaPlayerState->looping(); |
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | bool PlayListWidget::first() { | 666 | bool PlayListWidget::first() { |
667 | if ( mediaPlayerState->playlist() ) | 667 | if ( mediaPlayerState->playlist() ) |
668 | return d->selectedFiles->first(); | 668 | return d->selectedFiles->first(); |
669 | else | 669 | else |
670 | return mediaPlayerState->looping(); | 670 | return mediaPlayerState->looping(); |
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | bool PlayListWidget::last() { | 674 | bool PlayListWidget::last() { |
675 | if ( mediaPlayerState->playlist() ) | 675 | if ( mediaPlayerState->playlist() ) |
676 | return d->selectedFiles->last(); | 676 | return d->selectedFiles->last(); |
677 | else | 677 | else |
678 | return mediaPlayerState->looping(); | 678 | return mediaPlayerState->looping(); |
679 | } | 679 | } |
680 | 680 | ||
681 | 681 | ||
682 | void PlayListWidget::saveList() { | 682 | void PlayListWidget::saveList() { |
683 | writem3u(); | 683 | writem3u(); |
684 | } | 684 | } |
685 | 685 | ||
686 | void PlayListWidget::loadList( const DocLnk & lnk) { | 686 | void PlayListWidget::loadList( const DocLnk & lnk) { |
687 | QString name = lnk.name(); | 687 | QString name = lnk.name(); |
688 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 688 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
689 | 689 | ||
690 | if( name.length()>0) { | 690 | if( name.length()>0) { |
691 | setCaption("OpiePlayer: "+name); | 691 | setCaption("OpiePlayer: "+name); |
692 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 692 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
693 | clearList(); | 693 | clearList(); |
694 | readm3u(lnk.file()); | 694 | readm3u(lnk.file()); |
695 | tabWidget->setCurrentPage(0); | 695 | tabWidget->setCurrentPage(0); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | void PlayListWidget::setPlaylist( bool shown ) { | 699 | void PlayListWidget::setPlaylist( bool shown ) { |
700 | if ( shown ) | 700 | if ( shown ) |
701 | d->playListFrame->show(); | 701 | d->playListFrame->show(); |
702 | else | 702 | else |
703 | d->playListFrame->hide(); | 703 | d->playListFrame->hide(); |
704 | } | 704 | } |
705 | 705 | ||
706 | void PlayListWidget::setView( char view ) { | 706 | void PlayListWidget::setView( char view ) { |
707 | if ( view == 'l' ) | 707 | if ( view == 'l' ) |
708 | showMaximized(); | 708 | QPEApplication::showWidget( this ); |
709 | else | 709 | else |
710 | hide(); | 710 | hide(); |
711 | } | 711 | } |
712 | 712 | ||
713 | void PlayListWidget::addSelected() { | 713 | void PlayListWidget::addSelected() { |
714 | DocLnk lnk; | 714 | DocLnk lnk; |
715 | QString filename; | 715 | QString filename; |
716 | switch (tabWidget->currentPageIndex()) { | 716 | switch (tabWidget->currentPageIndex()) { |
717 | 717 | ||
718 | case 0: //playlist | 718 | case 0: //playlist |
719 | return; | 719 | return; |
720 | break; | 720 | break; |
721 | case 1: { //audio | 721 | case 1: { //audio |
722 | QListViewItemIterator it( audioView ); | 722 | QListViewItemIterator it( audioView ); |
723 | for ( ; it.current(); ++it ) { | 723 | for ( ; it.current(); ++it ) { |
724 | if ( it.current()->isSelected() ) { | 724 | if ( it.current()->isSelected() ) { |
725 | filename = it.current()->text(3); | 725 | filename = it.current()->text(3); |
726 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 726 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
727 | lnk.setFile( filename ); //sets file name | 727 | lnk.setFile( filename ); //sets file name |
728 | d->selectedFiles->addToSelection( lnk); | 728 | d->selectedFiles->addToSelection( lnk); |
729 | } | 729 | } |
730 | } | 730 | } |
731 | audioView->clearSelection(); | 731 | audioView->clearSelection(); |
732 | // d->selectedFiles->next(); | 732 | // d->selectedFiles->next(); |
733 | } | 733 | } |
734 | break; | 734 | break; |
735 | 735 | ||
736 | case 2: { // video | 736 | case 2: { // video |
737 | QListViewItemIterator it( videoView ); | 737 | QListViewItemIterator it( videoView ); |
738 | for ( ; it.current(); ++it ) { | 738 | for ( ; it.current(); ++it ) { |
739 | if ( it.current()->isSelected() ) { | 739 | if ( it.current()->isSelected() ) { |
740 | 740 | ||
741 | filename = it.current()->text(3); | 741 | filename = it.current()->text(3); |
742 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 742 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
743 | lnk.setFile( filename ); //sets file name | 743 | lnk.setFile( filename ); //sets file name |
744 | d->selectedFiles->addToSelection( lnk); | 744 | d->selectedFiles->addToSelection( lnk); |
745 | } | 745 | } |
746 | } | 746 | } |
747 | videoView->clearSelection(); | 747 | videoView->clearSelection(); |
748 | } | 748 | } |
749 | break; | 749 | break; |
750 | }; | 750 | }; |
751 | // tabWidget->setCurrentPage(0); | 751 | // tabWidget->setCurrentPage(0); |
752 | writeCurrentM3u(); | 752 | writeCurrentM3u(); |
753 | 753 | ||
754 | } | 754 | } |
755 | 755 | ||
756 | void PlayListWidget::removeSelected() { | 756 | void PlayListWidget::removeSelected() { |
757 | d->selectedFiles->removeSelected( ); | 757 | d->selectedFiles->removeSelected( ); |
758 | } | 758 | } |
759 | 759 | ||
760 | void PlayListWidget::playIt( QListViewItem *) { | 760 | void PlayListWidget::playIt( QListViewItem *) { |
761 | // d->setDocumentUsed = FALSE; | 761 | // d->setDocumentUsed = FALSE; |
762 | // mediaPlayerState->curPosition =0; | 762 | // mediaPlayerState->curPosition =0; |
763 | // mediaPlayerState->setPlaying(FALSE); | 763 | // mediaPlayerState->setPlaying(FALSE); |
764 | mediaPlayerState->setPlaying(TRUE); | 764 | mediaPlayerState->setPlaying(TRUE); |
765 | d->selectedFiles->unSelect(); | 765 | d->selectedFiles->unSelect(); |
766 | } | 766 | } |
767 | 767 | ||
768 | void PlayListWidget::addToSelection( QListViewItem *it) { | 768 | void PlayListWidget::addToSelection( QListViewItem *it) { |
769 | d->setDocumentUsed = FALSE; | 769 | d->setDocumentUsed = FALSE; |
770 | 770 | ||
771 | if(it) { | 771 | if(it) { |
772 | switch ( tabWidget->currentPageIndex()) { | 772 | switch ( tabWidget->currentPageIndex()) { |
773 | case 0: //playlist | 773 | case 0: //playlist |
774 | return; | 774 | return; |
775 | break; | 775 | break; |
776 | }; | 776 | }; |
777 | // case 1: { | 777 | // case 1: { |
778 | DocLnk lnk; | 778 | DocLnk lnk; |
779 | QString filename; | 779 | QString filename; |
780 | 780 | ||
781 | filename=it->text(3); | 781 | filename=it->text(3); |
782 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 782 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
783 | lnk.setFile( filename ); //sets file name | 783 | lnk.setFile( filename ); //sets file name |
784 | d->selectedFiles->addToSelection( lnk); | 784 | d->selectedFiles->addToSelection( lnk); |
785 | 785 | ||
786 | if(tabWidget->currentPageIndex() == 0) | 786 | if(tabWidget->currentPageIndex() == 0) |
787 | writeCurrentM3u(); | 787 | writeCurrentM3u(); |
788 | // tabWidget->setCurrentPage(0); | 788 | // tabWidget->setCurrentPage(0); |
789 | 789 | ||
790 | } | 790 | } |
791 | } | 791 | } |
792 | 792 | ||
793 | void PlayListWidget::tabChanged(QWidget *) { | 793 | void PlayListWidget::tabChanged(QWidget *) { |
794 | 794 | ||
795 | switch ( tabWidget->currentPageIndex()) { | 795 | switch ( tabWidget->currentPageIndex()) { |
796 | case 0: | 796 | case 0: |
797 | { | 797 | { |
798 | if( !tbDeletePlaylist->isHidden()) | 798 | if( !tbDeletePlaylist->isHidden()) |
799 | tbDeletePlaylist->hide(); | 799 | tbDeletePlaylist->hide(); |
800 | d->tbRemoveFromList->setEnabled(TRUE); | 800 | d->tbRemoveFromList->setEnabled(TRUE); |
801 | d->tbAddToList->setEnabled(FALSE); | 801 | d->tbAddToList->setEnabled(FALSE); |
802 | } | 802 | } |
803 | break; | 803 | break; |
804 | case 1: | 804 | case 1: |
805 | { | 805 | { |
806 | audioView->clear(); | 806 | audioView->clear(); |
807 | populateAudioView(); | 807 | populateAudioView(); |
808 | 808 | ||
809 | if( !tbDeletePlaylist->isHidden()) | 809 | if( !tbDeletePlaylist->isHidden()) |
810 | tbDeletePlaylist->hide(); | 810 | tbDeletePlaylist->hide(); |
811 | d->tbRemoveFromList->setEnabled(FALSE); | 811 | d->tbRemoveFromList->setEnabled(FALSE); |
812 | d->tbAddToList->setEnabled(TRUE); | 812 | d->tbAddToList->setEnabled(TRUE); |
813 | } | 813 | } |
814 | break; | 814 | break; |
815 | case 2: | 815 | case 2: |
816 | { | 816 | { |
817 | videoView->clear(); | 817 | videoView->clear(); |
818 | populateVideoView(); | 818 | populateVideoView(); |
819 | if( !tbDeletePlaylist->isHidden()) | 819 | if( !tbDeletePlaylist->isHidden()) |
820 | tbDeletePlaylist->hide(); | 820 | tbDeletePlaylist->hide(); |
821 | d->tbRemoveFromList->setEnabled(FALSE); | 821 | d->tbRemoveFromList->setEnabled(FALSE); |
822 | d->tbAddToList->setEnabled(TRUE); | 822 | d->tbAddToList->setEnabled(TRUE); |
823 | } | 823 | } |
824 | break; | 824 | break; |
825 | case 3: | 825 | case 3: |
826 | { | 826 | { |
827 | if( tbDeletePlaylist->isHidden()) | 827 | if( tbDeletePlaylist->isHidden()) |
828 | tbDeletePlaylist->show(); | 828 | tbDeletePlaylist->show(); |
829 | playLists->reread(); | 829 | playLists->reread(); |
830 | } | 830 | } |
831 | break; | 831 | break; |
832 | }; | 832 | }; |
833 | } | 833 | } |
834 | 834 | ||
835 | void PlayListWidget::btnPlay(bool b) { | 835 | void PlayListWidget::btnPlay(bool b) { |
836 | // mediaPlayerState->setPlaying(b); | 836 | // mediaPlayerState->setPlaying(b); |
837 | switch ( tabWidget->currentPageIndex()) { | 837 | switch ( tabWidget->currentPageIndex()) { |
838 | case 0: | 838 | case 0: |
839 | { | 839 | { |
840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 840 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 841 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 842 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
843 | // } else { | 843 | // } else { |
844 | mediaPlayerState->setPlaying(b); | 844 | mediaPlayerState->setPlaying(b); |
845 | insanityBool=FALSE; | 845 | insanityBool=FALSE; |
846 | qDebug("insanity"); | 846 | qDebug("insanity"); |
847 | // } | 847 | // } |
848 | } | 848 | } |
849 | break; | 849 | break; |
850 | case 1: | 850 | case 1: |
851 | { | 851 | { |
852 | // d->selectedFiles->unSelect(); | 852 | // d->selectedFiles->unSelect(); |
853 | addToSelection( audioView->currentItem() ); | 853 | addToSelection( audioView->currentItem() ); |
854 | mediaPlayerState->setPlaying( b); | 854 | mediaPlayerState->setPlaying( b); |
855 | d->selectedFiles->removeSelected( ); | 855 | d->selectedFiles->removeSelected( ); |
856 | d->selectedFiles->unSelect(); | 856 | d->selectedFiles->unSelect(); |
857 | tabWidget->setCurrentPage(1); | 857 | tabWidget->setCurrentPage(1); |
858 | insanityBool=FALSE; | 858 | insanityBool=FALSE; |
859 | }// audioView->clearSelection(); | 859 | }// audioView->clearSelection(); |
860 | break; | 860 | break; |
861 | case 2: | 861 | case 2: |
862 | { | 862 | { |
863 | 863 | ||
864 | addToSelection( videoView->currentItem() ); | 864 | addToSelection( videoView->currentItem() ); |
865 | mediaPlayerState->setPlaying( b); | 865 | mediaPlayerState->setPlaying( b); |
866 | // qApp->processEvents(); | 866 | // qApp->processEvents(); |
867 | d->selectedFiles->removeSelected( ); | 867 | d->selectedFiles->removeSelected( ); |
868 | d->selectedFiles->unSelect(); | 868 | d->selectedFiles->unSelect(); |
869 | tabWidget->setCurrentPage(2); | 869 | tabWidget->setCurrentPage(2); |
870 | insanityBool=FALSE; | 870 | insanityBool=FALSE; |
871 | }// videoView->clearSelection(); | 871 | }// videoView->clearSelection(); |
872 | break; | 872 | break; |
873 | }; | 873 | }; |
874 | 874 | ||
875 | } | 875 | } |
876 | 876 | ||
877 | void PlayListWidget::deletePlaylist() { | 877 | void PlayListWidget::deletePlaylist() { |
878 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 878 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
879 | (tr("You really want to delete\nthis playlist?")), | 879 | (tr("You really want to delete\nthis playlist?")), |
880 | (tr("Yes")), (tr("No")), 0 )){ | 880 | (tr("Yes")), (tr("No")), 0 )){ |
881 | case 0: // Yes clicked, | 881 | case 0: // Yes clicked, |
882 | QFile().remove(playLists->selectedDocument().file()); | 882 | QFile().remove(playLists->selectedDocument().file()); |
883 | QFile().remove(playLists->selectedDocument().linkFile()); | 883 | QFile().remove(playLists->selectedDocument().linkFile()); |
884 | playLists->reread(); | 884 | playLists->reread(); |
885 | break; | 885 | break; |
886 | case 1: // Cancel | 886 | case 1: // Cancel |
887 | break; | 887 | break; |
888 | }; | 888 | }; |
889 | } | 889 | } |
890 | 890 | ||
891 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 891 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
892 | { | 892 | { |
893 | switch (mouse) { | 893 | switch (mouse) { |
894 | case 1: | 894 | case 1: |
895 | break; | 895 | break; |
896 | case 2:{ | 896 | case 2:{ |
897 | 897 | ||
898 | QPopupMenu m; | 898 | QPopupMenu m; |
899 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 899 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
900 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 900 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
901 | m.insertSeparator(); | 901 | m.insertSeparator(); |
902 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 902 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
903 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 903 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
904 | 904 | ||
905 | m.exec( QCursor::pos() ); | 905 | m.exec( QCursor::pos() ); |
906 | } | 906 | } |
907 | break; | 907 | break; |
908 | }; | 908 | }; |
909 | } | 909 | } |
910 | 910 | ||
911 | void PlayListWidget::playSelected() | 911 | void PlayListWidget::playSelected() |
912 | { | 912 | { |
913 | btnPlay( true); | 913 | btnPlay( true); |
914 | // d->selectedFiles->unSelect(); | 914 | // d->selectedFiles->unSelect(); |
915 | } | 915 | } |
916 | 916 | ||
917 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 917 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
918 | { | 918 | { |
919 | switch (mouse) { | 919 | switch (mouse) { |
920 | case 1: | 920 | case 1: |
921 | 921 | ||
922 | break; | 922 | break; |
923 | case 2:{ | 923 | case 2:{ |
924 | QPopupMenu m; | 924 | QPopupMenu m; |
925 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 925 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
926 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 926 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
927 | // m.insertSeparator(); | 927 | // m.insertSeparator(); |
928 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 928 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
929 | m.exec( QCursor::pos() ); | 929 | m.exec( QCursor::pos() ); |
930 | } | 930 | } |
931 | break; | 931 | break; |
932 | }; | 932 | }; |
933 | 933 | ||
934 | } | 934 | } |
935 | 935 | ||
936 | void PlayListWidget::listDelete() { | 936 | void PlayListWidget::listDelete() { |
937 | Config cfg( "OpiePlayer" ); | 937 | Config cfg( "OpiePlayer" ); |
938 | cfg.setGroup("PlayList"); | 938 | cfg.setGroup("PlayList"); |
939 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 939 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
940 | QString file; | 940 | QString file; |
941 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 941 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
942 | switch ( tabWidget->currentPageIndex()) { | 942 | switch ( tabWidget->currentPageIndex()) { |
943 | case 0: | 943 | case 0: |
944 | break; | 944 | break; |
945 | case 1: | 945 | case 1: |
946 | { | 946 | { |
947 | file = audioView->currentItem()->text(0); | 947 | file = audioView->currentItem()->text(0); |
948 | QListIterator<DocLnk> Pdit( files.children() ); | 948 | QListIterator<DocLnk> Pdit( files.children() ); |
949 | for ( ; Pdit.current(); ++Pdit ) { | 949 | for ( ; Pdit.current(); ++Pdit ) { |
950 | if( Pdit.current()->name() == file) { | 950 | if( Pdit.current()->name() == file) { |
951 | LnkProperties prop( Pdit.current() ); | 951 | LnkProperties prop( Pdit.current() ); |
952 | QPEApplication::execDialog( &prop ); | 952 | QPEApplication::execDialog( &prop ); |
953 | } | 953 | } |
954 | } | 954 | } |
955 | populateAudioView(); | 955 | populateAudioView(); |
956 | } | 956 | } |
957 | break; | 957 | break; |
958 | case 2: | 958 | case 2: |
959 | { | 959 | { |
960 | // file = videoView->selectedItem()->text(0); | 960 | // file = videoView->selectedItem()->text(0); |
961 | // for ( int i = 0; i < noOfFiles; i++ ) { | 961 | // for ( int i = 0; i < noOfFiles; i++ ) { |
962 | // QString entryName; | 962 | // QString entryName; |
963 | // entryName.sprintf( "File%i", i + 1 ); | 963 | // entryName.sprintf( "File%i", i + 1 ); |
964 | // QString linkFile = cfg.readEntry( entryName ); | 964 | // QString linkFile = cfg.readEntry( entryName ); |
965 | // AppLnk lnk( AppLnk(linkFile)); | 965 | // AppLnk lnk( AppLnk(linkFile)); |
966 | // if( lnk.name() == file ) { | 966 | // if( lnk.name() == file ) { |
967 | // LnkProperties prop( &lnk); | 967 | // LnkProperties prop( &lnk); |
968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
969 | // prop.showMaximized(); | 969 | // prop.showMaximized(); |
970 | // prop.exec(); | 970 | // prop.exec(); |
971 | // } | 971 | // } |
972 | // } | 972 | // } |
973 | } | 973 | } |
974 | break; | 974 | break; |
975 | }; | 975 | }; |
976 | } | 976 | } |
977 | 977 | ||
978 | void PlayListWidget::scanForAudio() { | 978 | void PlayListWidget::scanForAudio() { |
979 | // qDebug("scan for audio"); | 979 | // qDebug("scan for audio"); |
980 | files.detachChildren(); | 980 | files.detachChildren(); |
981 | QListIterator<DocLnk> sdit( files.children() ); | 981 | QListIterator<DocLnk> sdit( files.children() ); |
982 | for ( ; sdit.current(); ++sdit ) { | 982 | for ( ; sdit.current(); ++sdit ) { |
983 | delete sdit.current(); | 983 | delete sdit.current(); |
984 | } | 984 | } |
985 | Global::findDocuments( &files, audioMimes); | 985 | Global::findDocuments( &files, audioMimes); |
986 | audioScan = true; | 986 | audioScan = true; |
987 | } | 987 | } |
988 | void PlayListWidget::scanForVideo() { | 988 | void PlayListWidget::scanForVideo() { |
989 | // qDebug("scan for video"); | 989 | // qDebug("scan for video"); |
990 | vFiles.detachChildren(); | 990 | vFiles.detachChildren(); |
991 | QListIterator<DocLnk> sdit( vFiles.children() ); | 991 | QListIterator<DocLnk> sdit( vFiles.children() ); |
992 | for ( ; sdit.current(); ++sdit ) { | 992 | for ( ; sdit.current(); ++sdit ) { |
993 | delete sdit.current(); | 993 | delete sdit.current(); |
994 | } | 994 | } |
995 | Global::findDocuments(&vFiles, "video/*"); | 995 | Global::findDocuments(&vFiles, "video/*"); |
996 | videoScan = true; | 996 | videoScan = true; |
997 | } | 997 | } |
998 | 998 | ||
999 | void PlayListWidget::populateAudioView() { | 999 | void PlayListWidget::populateAudioView() { |
1000 | 1000 | ||
1001 | audioView->clear(); | 1001 | audioView->clear(); |
1002 | StorageInfo storageInfo; | 1002 | StorageInfo storageInfo; |
1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1004 | if(!audioScan) scanForAudio(); | 1004 | if(!audioScan) scanForAudio(); |
1005 | 1005 | ||
1006 | QListIterator<DocLnk> dit( files.children() ); | 1006 | QListIterator<DocLnk> dit( files.children() ); |
1007 | QListIterator<FileSystem> it ( fs ); | 1007 | QListIterator<FileSystem> it ( fs ); |
1008 | 1008 | ||
1009 | QString storage; | 1009 | QString storage; |
1010 | for ( ; dit.current(); ++dit ) { | 1010 | for ( ; dit.current(); ++dit ) { |
1011 | for( ; it.current(); ++it ){ | 1011 | for( ; it.current(); ++it ){ |
1012 | const QString name = (*it)->name(); | 1012 | const QString name = (*it)->name(); |
1013 | const QString path = (*it)->path(); | 1013 | const QString path = (*it)->path(); |
1014 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1014 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | QListViewItem * newItem; | 1017 | QListViewItem * newItem; |
1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1019 | long size; | 1019 | long size; |
1020 | if( dit.current()->file().left(4) == "http" ) | 1020 | if( dit.current()->file().left(4) == "http" ) |
1021 | size=0; | 1021 | size=0; |
1022 | else | 1022 | else |
1023 | size = QFile( dit.current()->file() ).size(); | 1023 | size = QFile( dit.current()->file() ).size(); |
1024 | // qDebug(dit.current()->name()); | 1024 | // qDebug(dit.current()->name()); |
1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1026 | QString::number(size ), storage, dit.current()->file()); | 1026 | QString::number(size ), storage, dit.current()->file()); |
1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void PlayListWidget::populateVideoView() { | 1033 | void PlayListWidget::populateVideoView() { |
1034 | videoView->clear(); | 1034 | videoView->clear(); |
1035 | StorageInfo storageInfo; | 1035 | StorageInfo storageInfo; |
1036 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1036 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1037 | 1037 | ||
1038 | if(!videoScan ) scanForVideo(); | 1038 | if(!videoScan ) scanForVideo(); |
1039 | 1039 | ||
1040 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1040 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1041 | QListIterator<FileSystem> it ( fs ); | 1041 | QListIterator<FileSystem> it ( fs ); |
1042 | videoView->clear(); | 1042 | videoView->clear(); |
1043 | QString storage; | 1043 | QString storage; |
1044 | for ( ; Vdit.current(); ++Vdit ) { | 1044 | for ( ; Vdit.current(); ++Vdit ) { |
1045 | for( ; it.current(); ++it ){ | 1045 | for( ; it.current(); ++it ){ |
1046 | const QString name = (*it)->name(); | 1046 | const QString name = (*it)->name(); |
1047 | const QString path = (*it)->path(); | 1047 | const QString path = (*it)->path(); |
1048 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1048 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | QListViewItem * newItem; | 1051 | QListViewItem * newItem; |
1052 | if ( QFile( Vdit.current()->file()).exists() ) { | 1052 | if ( QFile( Vdit.current()->file()).exists() ) { |
1053 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1053 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1054 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1054 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1055 | storage, Vdit.current()->file()); | 1055 | storage, Vdit.current()->file()); |
1056 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1056 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void PlayListWidget::openFile() { | 1061 | void PlayListWidget::openFile() { |
1062 | QString filename, name; | 1062 | QString filename, name; |
1063 | InputDialog *fileDlg; | 1063 | InputDialog *fileDlg; |
1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1065 | fileDlg->exec(); | 1065 | fileDlg->exec(); |
1066 | if( fileDlg->result() == 1 ) { | 1066 | if( fileDlg->result() == 1 ) { |
1067 | filename = fileDlg->text(); | 1067 | filename = fileDlg->text(); |
1068 | // qDebug( "Selected filename is " + filename ); | 1068 | // qDebug( "Selected filename is " + filename ); |
1069 | DocLnk lnk; | 1069 | DocLnk lnk; |
1070 | Config cfg( "OpiePlayer" ); | 1070 | Config cfg( "OpiePlayer" ); |
1071 | cfg.setGroup("PlayList"); | 1071 | cfg.setGroup("PlayList"); |
1072 | 1072 | ||
1073 | QString m3uFile; | 1073 | QString m3uFile; |
1074 | m3uFile = filename; | 1074 | m3uFile = filename; |
1075 | if(filename.left(4) == "http") { | 1075 | if(filename.left(4) == "http") { |
1076 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1076 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1077 | 1077 | ||
1078 | m3uFile = filename; | 1078 | m3uFile = filename; |
1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1080 | m3uFile += "/"; | 1080 | m3uFile += "/"; |
1081 | } | 1081 | } |
1082 | filename = m3uFile; | 1082 | filename = m3uFile; |
1083 | } | 1083 | } |
1084 | lnk.setName( m3uFile ); //sets name | 1084 | lnk.setName( m3uFile ); //sets name |
1085 | lnk.setFile( filename ); //sets file name | 1085 | lnk.setFile( filename ); //sets file name |
1086 | lnk.setIcon("opieplayer2/musicfile"); | 1086 | lnk.setIcon("opieplayer2/musicfile"); |
1087 | d->selectedFiles->addToSelection( lnk ); | 1087 | d->selectedFiles->addToSelection( lnk ); |
1088 | writeCurrentM3u(); | 1088 | writeCurrentM3u(); |
1089 | } | 1089 | } |
1090 | else if( filename.right( 3) == "m3u" ) { | 1090 | else if( filename.right( 3) == "m3u" ) { |
1091 | readm3u( filename ); | 1091 | readm3u( filename ); |
1092 | 1092 | ||
1093 | } else if( filename.right(3) == "pls" ) { | 1093 | } else if( filename.right(3) == "pls" ) { |
1094 | readPls( filename ); | 1094 | readPls( filename ); |
1095 | } else { | 1095 | } else { |
1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1097 | lnk.setFile( filename ); //sets file name | 1097 | lnk.setFile( filename ); //sets file name |
1098 | d->selectedFiles->addToSelection( lnk); | 1098 | d->selectedFiles->addToSelection( lnk); |
1099 | lnk.removeLinkFile(); | 1099 | lnk.removeLinkFile(); |
1100 | writeCurrentM3u(); | 1100 | writeCurrentM3u(); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | if( fileDlg ) { | 1104 | if( fileDlg ) { |
1105 | delete fileDlg; | 1105 | delete fileDlg; |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | 1109 | ||
1110 | /* | 1110 | /* |
1111 | reads m3u and shows files/urls to playlist widget */ | 1111 | reads m3u and shows files/urls to playlist widget */ |
1112 | void PlayListWidget::readm3u( const QString &filename ) { | 1112 | void PlayListWidget::readm3u( const QString &filename ) { |
1113 | // qDebug( "read m3u filename " + filename ); | 1113 | // qDebug( "read m3u filename " + filename ); |
1114 | 1114 | ||
1115 | Om3u *m3uList; | 1115 | Om3u *m3uList; |
1116 | QString s, name; | 1116 | QString s, name; |
1117 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1117 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1118 | m3uList->readM3u(); | 1118 | m3uList->readM3u(); |
1119 | DocLnk lnk; | 1119 | DocLnk lnk; |
1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1121 | s = *it; | 1121 | s = *it; |
1122 | // qDebug("reading "+ s); | 1122 | // qDebug("reading "+ s); |
1123 | if(s.left(4)=="http") { | 1123 | if(s.left(4)=="http") { |
1124 | lnk.setName( s ); //sets file name | 1124 | lnk.setName( s ); //sets file name |
1125 | lnk.setIcon("opieplayer2/musicfile"); | 1125 | lnk.setIcon("opieplayer2/musicfile"); |
1126 | 1126 | ||
1127 | // if(s.right(4) != '.' || s.right(5) != '.') | 1127 | // if(s.right(4) != '.' || s.right(5) != '.') |
1128 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1128 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1129 | if( s.right(1) != "/") | 1129 | if( s.right(1) != "/") |
1130 | lnk.setFile( s+"/"); //if url with no extension | 1130 | lnk.setFile( s+"/"); //if url with no extension |
1131 | else | 1131 | else |
1132 | lnk.setFile( s ); //sets file name | 1132 | lnk.setFile( s ); //sets file name |
1133 | 1133 | ||
1134 | } else { | 1134 | } else { |
1135 | // if( QFileInfo( s ).exists() ) { | 1135 | // if( QFileInfo( s ).exists() ) { |
1136 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1136 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1137 | // if(s.right(4) == '.') {//if regular file | 1137 | // if(s.right(4) == '.') {//if regular file |
1138 | if(s.left(1) != "/") { | 1138 | if(s.left(1) != "/") { |
1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1141 | lnk.setIcon("SoundPlayer"); | 1141 | lnk.setIcon("SoundPlayer"); |
1142 | } else { | 1142 | } else { |
1143 | // qDebug("set link2 "+s); | 1143 | // qDebug("set link2 "+s); |
1144 | lnk.setFile( s); | 1144 | lnk.setFile( s); |
1145 | lnk.setIcon("SoundPlayer"); | 1145 | lnk.setIcon("SoundPlayer"); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | d->selectedFiles->addToSelection( lnk ); | 1148 | d->selectedFiles->addToSelection( lnk ); |
1149 | } | 1149 | } |
1150 | Config config( "OpiePlayer" ); | 1150 | Config config( "OpiePlayer" ); |
1151 | config.setGroup( "PlayList" ); | 1151 | config.setGroup( "PlayList" ); |
1152 | 1152 | ||
1153 | config.writeEntry("CurrentPlaylist",filename); | 1153 | config.writeEntry("CurrentPlaylist",filename); |
1154 | config.write(); | 1154 | config.write(); |
1155 | currentPlayList=filename; | 1155 | currentPlayList=filename; |
1156 | 1156 | ||
1157 | // m3uList->write(); | 1157 | // m3uList->write(); |
1158 | m3uList->close(); | 1158 | m3uList->close(); |
1159 | if(m3uList) delete m3uList; | 1159 | if(m3uList) delete m3uList; |
1160 | 1160 | ||
1161 | d->selectedFiles->setSelectedItem( s); | 1161 | d->selectedFiles->setSelectedItem( s); |
1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /* | 1166 | /* |
1167 | reads pls and adds files/urls to playlist */ | 1167 | reads pls and adds files/urls to playlist */ |
1168 | void PlayListWidget::readPls( const QString &filename ) { | 1168 | void PlayListWidget::readPls( const QString &filename ) { |
1169 | 1169 | ||
1170 | // qDebug( "pls filename is " + filename ); | 1170 | // qDebug( "pls filename is " + filename ); |
1171 | Om3u *m3uList; | 1171 | Om3u *m3uList; |
1172 | QString s, name; | 1172 | QString s, name; |
1173 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1173 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1174 | m3uList->readPls(); | 1174 | m3uList->readPls(); |
1175 | 1175 | ||
1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1177 | s = *it; | 1177 | s = *it; |
1178 | // s.replace( QRegExp( "%20" )," " ); | 1178 | // s.replace( QRegExp( "%20" )," " ); |
1179 | DocLnk lnk( s ); | 1179 | DocLnk lnk( s ); |
1180 | QFileInfo f( s ); | 1180 | QFileInfo f( s ); |
1181 | QString name = fullBaseName ( f); | 1181 | QString name = fullBaseName ( f); |
1182 | 1182 | ||
1183 | if( name.left( 4 ) == "http" ) { | 1183 | if( name.left( 4 ) == "http" ) { |
1184 | name = s.right( s.length() - 7); | 1184 | name = s.right( s.length() - 7); |
1185 | } else { | 1185 | } else { |
1186 | name = s; | 1186 | name = s; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1190 | 1190 | ||
1191 | lnk.setName( name ); | 1191 | lnk.setName( name ); |
1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1193 | lnk.setFile( s ); | 1193 | lnk.setFile( s ); |
1194 | } else { //if its a url | 1194 | } else { //if its a url |
1195 | if( name.right( 1 ).find( '/' ) == -1) { | 1195 | if( name.right( 1 ).find( '/' ) == -1) { |
1196 | s += "/"; | 1196 | s += "/"; |
1197 | } | 1197 | } |
1198 | lnk.setFile( s ); | 1198 | lnk.setFile( s ); |
1199 | } | 1199 | } |
1200 | lnk.setType( "audio/x-mpegurl" ); | 1200 | lnk.setType( "audio/x-mpegurl" ); |
1201 | 1201 | ||
1202 | lnk.writeLink(); | 1202 | lnk.writeLink(); |
1203 | d->selectedFiles->addToSelection( lnk ); | 1203 | d->selectedFiles->addToSelection( lnk ); |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | m3uList->close(); | 1206 | m3uList->close(); |
1207 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | /* | 1210 | /* |
1211 | writes current playlist to current m3u file */ | 1211 | writes current playlist to current m3u file */ |
1212 | void PlayListWidget::writeCurrentM3u() { | 1212 | void PlayListWidget::writeCurrentM3u() { |
1213 | // qDebug("writing to current m3u"); | 1213 | // qDebug("writing to current m3u"); |
1214 | Config cfg( "OpiePlayer" ); | 1214 | Config cfg( "OpiePlayer" ); |
1215 | cfg.setGroup("PlayList"); | 1215 | cfg.setGroup("PlayList"); |
1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1217 | Om3u *m3uList; | 1217 | Om3u *m3uList; |
1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); | 1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1219 | 1219 | ||
1220 | if( d->selectedFiles->first()) { | 1220 | if( d->selectedFiles->first()) { |
1221 | do { | 1221 | do { |
1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1223 | m3uList->add( d->selectedFiles->current()->file() ); | 1223 | m3uList->add( d->selectedFiles->current()->file() ); |
1224 | } | 1224 | } |
1225 | while ( d->selectedFiles->next() ); | 1225 | while ( d->selectedFiles->next() ); |
1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1227 | m3uList->write(); | 1227 | m3uList->write(); |
1228 | m3uList->close(); | 1228 | m3uList->close(); |
1229 | 1229 | ||
1230 | if(m3uList) delete m3uList; | 1230 | if(m3uList) delete m3uList; |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | /* | 1234 | /* |
1235 | writes current playlist to m3u file */ | 1235 | writes current playlist to m3u file */ |
1236 | void PlayListWidget::writem3u() { | 1236 | void PlayListWidget::writem3u() { |
1237 | InputDialog *fileDlg; | 1237 | InputDialog *fileDlg; |
1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1239 | fileDlg->exec(); | 1239 | fileDlg->exec(); |
1240 | QString name, filename, list; | 1240 | QString name, filename, list; |
1241 | Om3u *m3uList; | 1241 | Om3u *m3uList; |
1242 | 1242 | ||
1243 | if( fileDlg->result() == 1 ) { | 1243 | if( fileDlg->result() == 1 ) { |
1244 | name = fileDlg->text(); | 1244 | name = fileDlg->text(); |
1245 | // qDebug( filename ); | 1245 | // qDebug( filename ); |
1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1247 | filename = name; | 1247 | filename = name; |
1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1249 | } | 1249 | } |
1250 | else //otherwise dump it somewhere noticable | 1250 | else //otherwise dump it somewhere noticable |
1251 | filename = QPEApplication::documentDir() + "/" + name; | 1251 | filename = QPEApplication::documentDir() + "/" + name; |
1252 | 1252 | ||
1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1254 | filename += ".m3u"; | 1254 | filename += ".m3u"; |
1255 | 1255 | ||
1256 | if( d->selectedFiles->first()) { | 1256 | if( d->selectedFiles->first()) { |
1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1258 | 1258 | ||
1259 | do { | 1259 | do { |
1260 | m3uList->add( d->selectedFiles->current()->file()); | 1260 | m3uList->add( d->selectedFiles->current()->file()); |
1261 | } | 1261 | } |
1262 | while ( d->selectedFiles->next() ); | 1262 | while ( d->selectedFiles->next() ); |
1263 | // qDebug( list ); | 1263 | // qDebug( list ); |
1264 | m3uList->write(); | 1264 | m3uList->write(); |
1265 | m3uList->close(); | 1265 | m3uList->close(); |
1266 | if(m3uList) delete m3uList; | 1266 | if(m3uList) delete m3uList; |
1267 | 1267 | ||
1268 | if(fileDlg) delete fileDlg; | 1268 | if(fileDlg) delete fileDlg; |
1269 | 1269 | ||
1270 | DocLnk lnk; | 1270 | DocLnk lnk; |
1271 | lnk.setFile( filename); | 1271 | lnk.setFile( filename); |
1272 | lnk.setIcon("opieplayer2/playlist2"); | 1272 | lnk.setIcon("opieplayer2/playlist2"); |
1273 | lnk.setName( name); //sets file name | 1273 | lnk.setName( name); //sets file name |
1274 | 1274 | ||
1275 | // qDebug(filename); | 1275 | // qDebug(filename); |
1276 | Config config( "OpiePlayer" ); | 1276 | Config config( "OpiePlayer" ); |
1277 | config.setGroup( "PlayList" ); | 1277 | config.setGroup( "PlayList" ); |
1278 | 1278 | ||
1279 | config.writeEntry("CurrentPlaylist",filename); | 1279 | config.writeEntry("CurrentPlaylist",filename); |
1280 | currentPlayList=filename; | 1280 | currentPlayList=filename; |
1281 | 1281 | ||
1282 | if(!lnk.writeLink()) { | 1282 | if(!lnk.writeLink()) { |
1283 | // qDebug("Writing doclink did not work"); | 1283 | // qDebug("Writing doclink did not work"); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | setCaption(tr("OpiePlayer: ") + name); | 1286 | setCaption(tr("OpiePlayer: ") + name); |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1293 | { | 1293 | { |
1294 | switch ( e->key() ) { | 1294 | switch ( e->key() ) { |
1295 | ////////////////////////////// Zaurus keys | 1295 | ////////////////////////////// Zaurus keys |
1296 | case Key_F9: //activity | 1296 | case Key_F9: //activity |
1297 | // if(audioUI->isHidden()) | 1297 | // if(audioUI->isHidden()) |
1298 | // audioUI->showMaximized(); | 1298 | // audioUI->showMaximized(); |
1299 | break; | 1299 | break; |
1300 | case Key_F10: //contacts | 1300 | case Key_F10: //contacts |
1301 | // if( videoUI->isHidden()) | 1301 | // if( videoUI->isHidden()) |
1302 | // videoUI->showMaximized(); | 1302 | // videoUI->showMaximized(); |
1303 | break; | 1303 | break; |
1304 | case Key_F11: //menu | 1304 | case Key_F11: //menu |
1305 | break; | 1305 | break; |
1306 | case Key_F12: //home | 1306 | case Key_F12: //home |
1307 | // doBlank(); | 1307 | // doBlank(); |
1308 | break; | 1308 | break; |
1309 | case Key_F13: //mail | 1309 | case Key_F13: //mail |
1310 | // doUnblank(); | 1310 | // doUnblank(); |
1311 | break; | 1311 | break; |
1312 | case Key_Q: //add to playlist | 1312 | case Key_Q: //add to playlist |
1313 | addSelected(); | 1313 | addSelected(); |
1314 | break; | 1314 | break; |
1315 | case Key_R: //remove from playlist | 1315 | case Key_R: //remove from playlist |
1316 | removeSelected(); | 1316 | removeSelected(); |
1317 | break; | 1317 | break; |
1318 | // case Key_P: //play | 1318 | // case Key_P: //play |
1319 | // qDebug("Play"); | 1319 | // qDebug("Play"); |
1320 | // playSelected(); | 1320 | // playSelected(); |
1321 | // break; | 1321 | // break; |
1322 | case Key_Space: | 1322 | case Key_Space: |
1323 | // playSelected(); puh | 1323 | // playSelected(); puh |
1324 | break; | 1324 | break; |
1325 | case Key_1: | 1325 | case Key_1: |
1326 | tabWidget->setCurrentPage(0); | 1326 | tabWidget->setCurrentPage(0); |
1327 | break; | 1327 | break; |
1328 | case Key_2: | 1328 | case Key_2: |
1329 | tabWidget->setCurrentPage(1); | 1329 | tabWidget->setCurrentPage(1); |
1330 | break; | 1330 | break; |
1331 | case Key_3: | 1331 | case Key_3: |
1332 | tabWidget->setCurrentPage(2); | 1332 | tabWidget->setCurrentPage(2); |
1333 | break; | 1333 | break; |
1334 | case Key_4: | 1334 | case Key_4: |
1335 | tabWidget->setCurrentPage(3); | 1335 | tabWidget->setCurrentPage(3); |
1336 | break; | 1336 | break; |
1337 | case Key_Down: | 1337 | case Key_Down: |
1338 | if ( !d->selectedFiles->next() ) | 1338 | if ( !d->selectedFiles->next() ) |
1339 | d->selectedFiles->first(); | 1339 | d->selectedFiles->first(); |
1340 | 1340 | ||
1341 | break; | 1341 | break; |
1342 | case Key_Up: | 1342 | case Key_Up: |
1343 | if ( !d->selectedFiles->prev() ) | 1343 | if ( !d->selectedFiles->prev() ) |
1344 | // d->selectedFiles->last(); | 1344 | // d->selectedFiles->last(); |
1345 | 1345 | ||
1346 | break; | 1346 | break; |
1347 | 1347 | ||
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1351 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1352 | { | 1352 | { |
1353 | // qDebug("Key press"); | 1353 | // qDebug("Key press"); |
1354 | // switch ( e->key() ) { | 1354 | // switch ( e->key() ) { |
1355 | // ////////////////////////////// Zaurus keys | 1355 | // ////////////////////////////// Zaurus keys |
1356 | // case Key_A: //add to playlist | 1356 | // case Key_A: //add to playlist |
1357 | // qDebug("Add"); | 1357 | // qDebug("Add"); |
1358 | // addSelected(); | 1358 | // addSelected(); |
1359 | // break; | 1359 | // break; |
1360 | // case Key_R: //remove from playlist | 1360 | // case Key_R: //remove from playlist |
1361 | // removeSelected(); | 1361 | // removeSelected(); |
1362 | // break; | 1362 | // break; |
1363 | // case Key_P: //play | 1363 | // case Key_P: //play |
1364 | // qDebug("Play"); | 1364 | // qDebug("Play"); |
1365 | // playSelected(); | 1365 | // playSelected(); |
1366 | // break; | 1366 | // break; |
1367 | // case Key_Space: | 1367 | // case Key_Space: |
1368 | // qDebug("Play"); | 1368 | // qDebug("Play"); |
1369 | // playSelected(); | 1369 | // playSelected(); |
1370 | // break; | 1370 | // break; |
1371 | // } | 1371 | // } |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | void PlayListWidget::doBlank() { | 1374 | void PlayListWidget::doBlank() { |
1375 | // qDebug("do blanking"); | 1375 | // qDebug("do blanking"); |
1376 | #ifdef QT_QWS_DEVFS | 1376 | #ifdef QT_QWS_DEVFS |
1377 | fd=open("/dev/fb/0",O_RDWR); | 1377 | fd=open("/dev/fb/0",O_RDWR); |
1378 | #else | 1378 | #else |
1379 | fd=open("/dev/fb0",O_RDWR); | 1379 | fd=open("/dev/fb0",O_RDWR); |
1380 | #endif | 1380 | #endif |
1381 | if (fd != -1) { | 1381 | if (fd != -1) { |
1382 | ioctl(fd,FBIOBLANK,1); | 1382 | ioctl(fd,FBIOBLANK,1); |
1383 | // close(fd); | 1383 | // close(fd); |
1384 | } | 1384 | } |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | void PlayListWidget::doUnblank() { | 1387 | void PlayListWidget::doUnblank() { |
1388 | // this crashes opieplayer with a segfault | 1388 | // this crashes opieplayer with a segfault |
1389 | // int fd; | 1389 | // int fd; |
1390 | // fd=open("/dev/fb0",O_RDWR); | 1390 | // fd=open("/dev/fb0",O_RDWR); |
1391 | // qDebug("do unblanking"); | 1391 | // qDebug("do unblanking"); |
1392 | if (fd != -1) { | 1392 | if (fd != -1) { |
1393 | ioctl(fd,FBIOBLANK,0); | 1393 | ioctl(fd,FBIOBLANK,0); |
1394 | close(fd); | 1394 | close(fd); |
1395 | } | 1395 | } |
1396 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1396 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1397 | h <<-3;// v[1]; // -3 Force on | 1397 | h <<-3;// v[1]; // -3 Force on |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | void PlayListWidget::populateSkinsMenu() { | 1400 | void PlayListWidget::populateSkinsMenu() { |
1401 | int item = 0; | 1401 | int item = 0; |
1402 | defaultSkinIndex = 0; | 1402 | defaultSkinIndex = 0; |
1403 | QString skinName; | 1403 | QString skinName; |
1404 | Config cfg( "OpiePlayer" ); | 1404 | Config cfg( "OpiePlayer" ); |
1405 | cfg.setGroup("Options" ); | 1405 | cfg.setGroup("Options" ); |
1406 | QString skin = cfg.readEntry( "Skin", "default" ); | 1406 | QString skin = cfg.readEntry( "Skin", "default" ); |
1407 | 1407 | ||
1408 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1408 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1409 | skinsDir.setFilter( QDir::Dirs ); | 1409 | skinsDir.setFilter( QDir::Dirs ); |
1410 | skinsDir.setSorting(QDir::Name ); | 1410 | skinsDir.setSorting(QDir::Name ); |
1411 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1411 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1412 | QFileInfoListIterator it( *skinslist ); | 1412 | QFileInfoListIterator it( *skinslist ); |
1413 | QFileInfo *fi; | 1413 | QFileInfo *fi; |
1414 | while ( ( fi = it.current() ) ) { | 1414 | while ( ( fi = it.current() ) ) { |
1415 | skinName = fi->fileName(); | 1415 | skinName = fi->fileName(); |
1416 | // qDebug( fi->fileName() ); | 1416 | // qDebug( fi->fileName() ); |
1417 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1417 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1418 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1418 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1419 | } | 1419 | } |
1420 | if( skinName == "default" ) { | 1420 | if( skinName == "default" ) { |
1421 | defaultSkinIndex = item; | 1421 | defaultSkinIndex = item; |
1422 | } | 1422 | } |
1423 | if( skinName == skin ) { | 1423 | if( skinName == skin ) { |
1424 | skinsMenu->setItemChecked( item, TRUE ); | 1424 | skinsMenu->setItemChecked( item, TRUE ); |
1425 | } | 1425 | } |
1426 | ++it; | 1426 | ++it; |
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | void PlayListWidget::skinsMenuActivated( int item ) { | 1430 | void PlayListWidget::skinsMenuActivated( int item ) { |
1431 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1431 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1432 | skinsMenu->setItemChecked( i, FALSE ); | 1432 | skinsMenu->setItemChecked( i, FALSE ); |
1433 | } | 1433 | } |
1434 | skinsMenu->setItemChecked( item, TRUE ); | 1434 | skinsMenu->setItemChecked( item, TRUE ); |
1435 | 1435 | ||
1436 | Config cfg( "OpiePlayer" ); | 1436 | Config cfg( "OpiePlayer" ); |
1437 | cfg.setGroup("Options"); | 1437 | cfg.setGroup("Options"); |
1438 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1438 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1441 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1442 | // qDebug("qcop message "+msg ); | 1442 | // qDebug("qcop message "+msg ); |
1443 | QDataStream stream ( data, IO_ReadOnly ); | 1443 | QDataStream stream ( data, IO_ReadOnly ); |
1444 | if ( msg == "play()" ) { //plays current selection | 1444 | if ( msg == "play()" ) { //plays current selection |
1445 | btnPlay( true); | 1445 | btnPlay( true); |
1446 | } else if ( msg == "stop()" ) { | 1446 | } else if ( msg == "stop()" ) { |
1447 | mediaPlayerState->setPlaying( false); | 1447 | mediaPlayerState->setPlaying( false); |
1448 | } else if ( msg == "togglePause()" ) { | 1448 | } else if ( msg == "togglePause()" ) { |
1449 | mediaPlayerState->togglePaused(); | 1449 | mediaPlayerState->togglePaused(); |
1450 | } else if ( msg == "next()" ) { //select next in lis | 1450 | } else if ( msg == "next()" ) { //select next in lis |
1451 | mediaPlayerState->setNext(); | 1451 | mediaPlayerState->setNext(); |
1452 | } else if ( msg == "prev()" ) { //select previous in list | 1452 | } else if ( msg == "prev()" ) { //select previous in list |
1453 | mediaPlayerState->setPrev(); | 1453 | mediaPlayerState->setPrev(); |
1454 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1454 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1455 | mediaPlayerState->toggleLooping(); | 1455 | mediaPlayerState->toggleLooping(); |
1456 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1456 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1457 | mediaPlayerState->toggleShuffled(); | 1457 | mediaPlayerState->toggleShuffled(); |
1458 | } else if ( msg == "volUp()" ) { //volume more | 1458 | } else if ( msg == "volUp()" ) { //volume more |
1459 | // emit moreClicked(); | 1459 | // emit moreClicked(); |
1460 | // emit moreReleased(); | 1460 | // emit moreReleased(); |
1461 | } else if ( msg == "volDown()" ) { //volume less | 1461 | } else if ( msg == "volDown()" ) { //volume less |
1462 | // emit lessClicked(); | 1462 | // emit lessClicked(); |
1463 | // emit lessReleased(); | 1463 | // emit lessReleased(); |
1464 | } else if ( msg == "play(QString)" ) { //play this now | 1464 | } else if ( msg == "play(QString)" ) { //play this now |
1465 | QString file; | 1465 | QString file; |
1466 | stream >> file; | 1466 | stream >> file; |
1467 | setDocumentEx( (const QString &) file); | 1467 | setDocumentEx( (const QString &) file); |
1468 | } else if ( msg == "add(QString)" ) { //add to playlist | 1468 | } else if ( msg == "add(QString)" ) { //add to playlist |
1469 | QString file; | 1469 | QString file; |
1470 | stream >> file; | 1470 | stream >> file; |
1471 | QFileInfo fileInfo(file); | 1471 | QFileInfo fileInfo(file); |
1472 | DocLnk lnk; | 1472 | DocLnk lnk; |
1473 | lnk.setName( fileInfo.baseName() ); //sets name | 1473 | lnk.setName( fileInfo.baseName() ); //sets name |
1474 | lnk.setFile( file ); //sets file name | 1474 | lnk.setFile( file ); //sets file name |
1475 | addToSelection( lnk ); | 1475 | addToSelection( lnk ); |
1476 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1476 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1477 | QString file; | 1477 | QString file; |
1478 | stream >> file; | 1478 | stream >> file; |
1479 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | 1479 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop |
1480 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | 1480 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); |
1481 | } | 1481 | } |
1482 | } | 1482 | } |
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index d9a9478..5273ad3 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,677 +1,677 @@ | |||
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 <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 21 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | #include <qslider.h> | 29 | #include <qslider.h> |
30 | #include <qdrawutil.h> | 30 | #include <qdrawutil.h> |
31 | #include "videowidget.h" | 31 | #include "videowidget.h" |
32 | #include "mediaplayerstate.h" | 32 | #include "mediaplayerstate.h" |
33 | 33 | ||
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | # define USE_DIRECT_PAINTER | 36 | # define USE_DIRECT_PAINTER |
37 | # include <qdirectpainter_qws.h> | 37 | # include <qdirectpainter_qws.h> |
38 | # include <qgfxraster_qws.h> | 38 | # include <qgfxraster_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | 43 | ||
44 | 44 | ||
45 | static const int xo = 2; // movable x offset | 45 | static const int xo = 2; // movable x offset |
46 | static const int yo = 0; // movable y offset | 46 | static const int yo = 0; // movable y offset |
47 | 47 | ||
48 | 48 | ||
49 | struct MediaButton { | 49 | struct MediaButton { |
50 | // int xPos, yPos; | 50 | // int xPos, yPos; |
51 | bool isToggle, isHeld, isDown; | 51 | bool isToggle, isHeld, isDown; |
52 | // int controlType; | 52 | // int controlType; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | // Layout information for the videoButtons (and if it is a toggle button or not) | 56 | // Layout information for the videoButtons (and if it is a toggle button or not) |
57 | MediaButton videoButtons[] = { | 57 | MediaButton videoButtons[] = { |
58 | { FALSE, FALSE, FALSE }, // stop | 58 | { FALSE, FALSE, FALSE }, // stop |
59 | { FALSE, FALSE, FALSE }, // play | 59 | { FALSE, FALSE, FALSE }, // play |
60 | { FALSE, FALSE, FALSE }, // previous | 60 | { FALSE, FALSE, FALSE }, // previous |
61 | { FALSE, FALSE, FALSE }, // next | 61 | { FALSE, FALSE, FALSE }, // next |
62 | { FALSE, FALSE, FALSE }, // volUp | 62 | { FALSE, FALSE, FALSE }, // volUp |
63 | { FALSE, FALSE, FALSE }, // volDown | 63 | { FALSE, FALSE, FALSE }, // volDown |
64 | { TRUE, FALSE, FALSE } // fullscreen | 64 | { TRUE, FALSE, FALSE } // fullscreen |
65 | }; | 65 | }; |
66 | 66 | ||
67 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 67 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
68 | 68 | ||
69 | const char *skinV_mask_file_names[7] = { | 69 | const char *skinV_mask_file_names[7] = { |
70 | "stop","play","back","fwd","up","down","full" | 70 | "stop","play","back","fwd","up","down","full" |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 73 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
74 | 74 | ||
75 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 75 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) | 76 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | Config cfg("OpiePlayer"); | 79 | Config cfg("OpiePlayer"); |
80 | 80 | ||
81 | cfg.setGroup("Options"); | 81 | cfg.setGroup("Options"); |
82 | skin = cfg.readEntry("Skin","default"); | 82 | skin = cfg.readEntry("Skin","default"); |
83 | 83 | ||
84 | QString skinPath; | 84 | QString skinPath; |
85 | skinPath = "opieplayer2/skins/" + skin; | 85 | skinPath = "opieplayer2/skins/" + skin; |
86 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 86 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
87 | skinPath = "opieplayer2/skins/default"; | 87 | skinPath = "opieplayer2/skins/default"; |
88 | 88 | ||
89 | // qDebug("skin path " + skinPath); | 89 | // qDebug("skin path " + skinPath); |
90 | 90 | ||
91 | // QString skinPath = "opieplayer2/skins/" + skin; | 91 | // QString skinPath = "opieplayer2/skins/" + skin; |
92 | 92 | ||
93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
96 | 96 | ||
97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
98 | imgButtonMask->fill( 0 ); | 98 | imgButtonMask->fill( 0 ); |
99 | 99 | ||
100 | for ( int i = 0; i < 7; i++ ) { | 100 | for ( int i = 0; i < 7; i++ ) { |
101 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | 101 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + |
102 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 102 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
103 | // qDebug("loading "+filename); | 103 | // qDebug("loading "+filename); |
104 | masks[i] = new QBitmap( filename ); | 104 | masks[i] = new QBitmap( filename ); |
105 | 105 | ||
106 | if ( !masks[i]->isNull() ) { | 106 | if ( !masks[i]->isNull() ) { |
107 | QImage imgMask = masks[i]->convertToImage(); | 107 | QImage imgMask = masks[i]->convertToImage(); |
108 | uchar **dest = imgButtonMask->jumpTable(); | 108 | uchar **dest = imgButtonMask->jumpTable(); |
109 | for ( int y = 0; y < imgUp->height(); y++ ) { | 109 | for ( int y = 0; y < imgUp->height(); y++ ) { |
110 | uchar *line = dest[y]; | 110 | uchar *line = dest[y]; |
111 | for ( int x = 0; x < imgUp->width(); x++ ) { | 111 | for ( int x = 0; x < imgUp->width(); x++ ) { |
112 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 112 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
113 | line[x] = i + 1; | 113 | line[x] = i + 1; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | // qDebug("finished loading first pics"); | 118 | // qDebug("finished loading first pics"); |
119 | for ( int i = 0; i < 7; i++ ) { | 119 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 120 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 121 | buttonPixDown[i] = NULL; |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | QWidget *d = QApplication::desktop(); | 125 | QWidget *d = QApplication::desktop(); |
126 | int width = d->width(); | 126 | int width = d->width(); |
127 | int height = d->height(); | 127 | int height = d->height(); |
128 | 128 | ||
129 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 129 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
130 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); | 130 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); |
131 | QImage img; | 131 | QImage img; |
132 | img = pixBg->convertToImage(); | 132 | img = pixBg->convertToImage(); |
133 | pixBg->convertFromImage( img.smoothScale( width, height)); | 133 | pixBg->convertFromImage( img.smoothScale( width, height)); |
134 | } | 134 | } |
135 | setBackgroundPixmap( *pixBg ); | 135 | setBackgroundPixmap( *pixBg ); |
136 | 136 | ||
137 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 137 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
138 | 138 | ||
139 | slider = new QSlider( Qt::Horizontal, this ); | 139 | slider = new QSlider( Qt::Horizontal, this ); |
140 | slider->setMinValue( 0 ); | 140 | slider->setMinValue( 0 ); |
141 | slider->setMaxValue( 1 ); | 141 | slider->setMaxValue( 1 ); |
142 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 142 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
143 | slider->setFocusPolicy( QWidget::NoFocus ); | 143 | slider->setFocusPolicy( QWidget::NoFocus ); |
144 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 144 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
145 | 145 | ||
146 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 146 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
147 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 147 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
148 | 148 | ||
149 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 149 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
150 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 150 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
151 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 151 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
152 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 152 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
153 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 153 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
154 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 154 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
155 | 155 | ||
156 | // Intialise state | 156 | // Intialise state |
157 | setLength( mediaPlayerState->length() ); | 157 | setLength( mediaPlayerState->length() ); |
158 | setPosition( mediaPlayerState->position() ); | 158 | setPosition( mediaPlayerState->position() ); |
159 | setFullscreen( mediaPlayerState->fullscreen() ); | 159 | setFullscreen( mediaPlayerState->fullscreen() ); |
160 | // setPaused( mediaPlayerState->paused() ); | 160 | // setPaused( mediaPlayerState->paused() ); |
161 | setPlaying( mediaPlayerState->playing() ); | 161 | setPlaying( mediaPlayerState->playing() ); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | VideoWidget::~VideoWidget() { | 165 | VideoWidget::~VideoWidget() { |
166 | 166 | ||
167 | for ( int i = 0; i < 7; i++ ) | 167 | for ( int i = 0; i < 7; i++ ) |
168 | { | 168 | { |
169 | delete buttonPixUp[i]; | 169 | delete buttonPixUp[i]; |
170 | delete buttonPixDown[i]; | 170 | delete buttonPixDown[i]; |
171 | } | 171 | } |
172 | 172 | ||
173 | delete pixBg; | 173 | delete pixBg; |
174 | delete imgUp; | 174 | delete imgUp; |
175 | delete imgDn; | 175 | delete imgDn; |
176 | delete imgButtonMask; | 176 | delete imgButtonMask; |
177 | for ( int i = 0; i < 7; i++ ) | 177 | for ( int i = 0; i < 7; i++ ) |
178 | { | 178 | { |
179 | delete masks[i]; | 179 | delete masks[i]; |
180 | } | 180 | } |
181 | 181 | ||
182 | // for ( int i = 0; i < 3; i++ ) | 182 | // for ( int i = 0; i < 3; i++ ) |
183 | // delete pixmaps[i]; | 183 | // delete pixmaps[i]; |
184 | // delete currentFrame; | 184 | // delete currentFrame; |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | static bool videoSliderBeingMoved = FALSE; | 188 | static bool videoSliderBeingMoved = FALSE; |
189 | 189 | ||
190 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 190 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
191 | QPixmap pix( img.width(), img.height() ); | 191 | QPixmap pix( img.width(), img.height() ); |
192 | QPainter p( &pix ); | 192 | QPainter p( &pix ); |
193 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 193 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
194 | p.drawImage( 0, 0, img ); | 194 | p.drawImage( 0, 0, img ); |
195 | return new QPixmap( pix ); | 195 | return new QPixmap( pix ); |
196 | } | 196 | } |
197 | 197 | ||
198 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 198 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
199 | QPixmap *pixmap = new QPixmap( pix ); | 199 | QPixmap *pixmap = new QPixmap( pix ); |
200 | pixmap->setMask( mask ); | 200 | pixmap->setMask( mask ); |
201 | return pixmap; | 201 | return pixmap; |
202 | } | 202 | } |
203 | 203 | ||
204 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 204 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
205 | int h = height(); | 205 | int h = height(); |
206 | int w = width(); | 206 | int w = width(); |
207 | //int Vh = 160; | 207 | //int Vh = 160; |
208 | //int Vw = 220; | 208 | //int Vw = 220; |
209 | 209 | ||
210 | slider->setFixedWidth( w - 20 ); | 210 | slider->setFixedWidth( w - 20 ); |
211 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 211 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
212 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 212 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
213 | slider->setFocusPolicy( QWidget::NoFocus ); | 213 | slider->setFocusPolicy( QWidget::NoFocus ); |
214 | slider->setBackgroundPixmap( *pixBg ); | 214 | slider->setBackgroundPixmap( *pixBg ); |
215 | 215 | ||
216 | xoff = 0;// ( imgUp->width() ) / 2; | 216 | xoff = 0;// ( imgUp->width() ) / 2; |
217 | if(w>h) | 217 | if(w>h) |
218 | yoff = 0; | 218 | yoff = 0; |
219 | else | 219 | else |
220 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 220 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
221 | QPoint p( xoff, yoff ); | 221 | QPoint p( xoff, yoff ); |
222 | 222 | ||
223 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 223 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
224 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 224 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
225 | 225 | ||
226 | for ( int i = 0; i < 7; i++ ) | 226 | for ( int i = 0; i < 7; i++ ) |
227 | { | 227 | { |
228 | if ( !masks[i]->isNull() ) | 228 | if ( !masks[i]->isNull() ) |
229 | { | 229 | { |
230 | delete buttonPixUp[i]; | 230 | delete buttonPixUp[i]; |
231 | delete buttonPixDown[i]; | 231 | delete buttonPixDown[i]; |
232 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 232 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
233 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 233 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | delete pixUp; | 237 | delete pixUp; |
238 | delete pixDn; | 238 | delete pixDn; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void VideoWidget::sliderPressed() { | 242 | void VideoWidget::sliderPressed() { |
243 | videoSliderBeingMoved = TRUE; | 243 | videoSliderBeingMoved = TRUE; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | void VideoWidget::sliderReleased() { | 247 | void VideoWidget::sliderReleased() { |
248 | videoSliderBeingMoved = FALSE; | 248 | videoSliderBeingMoved = FALSE; |
249 | if ( slider->width() == 0 ) | 249 | if ( slider->width() == 0 ) |
250 | return; | 250 | return; |
251 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 251 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
252 | mediaPlayerState->setPosition( val ); | 252 | mediaPlayerState->setPosition( val ); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void VideoWidget::setPosition( long i ) { | 256 | void VideoWidget::setPosition( long i ) { |
257 | updateSlider( i, mediaPlayerState->length() ); | 257 | updateSlider( i, mediaPlayerState->length() ); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void VideoWidget::setLength( long max ) { | 261 | void VideoWidget::setLength( long max ) { |
262 | updateSlider( mediaPlayerState->position(), max ); | 262 | updateSlider( mediaPlayerState->position(), max ); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | void VideoWidget::setView( char view ) { | 266 | void VideoWidget::setView( char view ) { |
267 | if ( view == 'v' ) | 267 | if ( view == 'v' ) |
268 | { | 268 | { |
269 | makeVisible(); | 269 | makeVisible(); |
270 | } | 270 | } |
271 | else | 271 | else |
272 | { | 272 | { |
273 | // Effectively blank the view next time we show it so it looks nicer | 273 | // Effectively blank the view next time we show it so it looks nicer |
274 | scaledWidth = 0; | 274 | scaledWidth = 0; |
275 | scaledHeight = 0; | 275 | scaledHeight = 0; |
276 | hide(); | 276 | hide(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | void VideoWidget::updateSlider( long i, long max ) { | 281 | void VideoWidget::updateSlider( long i, long max ) { |
282 | // Will flicker too much if we don't do this | 282 | // Will flicker too much if we don't do this |
283 | if ( max == 0 ) | 283 | if ( max == 0 ) |
284 | return; | 284 | return; |
285 | int width = slider->width(); | 285 | int width = slider->width(); |
286 | int val = int((double)i * width / max); | 286 | int val = int((double)i * width / max); |
287 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) | 287 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) |
288 | { | 288 | { |
289 | if ( slider->value() != val ) | 289 | if ( slider->value() != val ) |
290 | slider->setValue( val ); | 290 | slider->setValue( val ); |
291 | if ( slider->maxValue() != width ) | 291 | if ( slider->maxValue() != width ) |
292 | slider->setMaxValue( width ); | 292 | slider->setMaxValue( width ); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | void VideoWidget::setToggleButton( int i, bool down ) { | 297 | void VideoWidget::setToggleButton( int i, bool down ) { |
298 | if ( down != videoButtons[i].isDown ) | 298 | if ( down != videoButtons[i].isDown ) |
299 | toggleButton( i ); | 299 | toggleButton( i ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | void VideoWidget::toggleButton( int i ) { | 303 | void VideoWidget::toggleButton( int i ) { |
304 | videoButtons[i].isDown = !videoButtons[i].isDown; | 304 | videoButtons[i].isDown = !videoButtons[i].isDown; |
305 | QPainter p(this); | 305 | QPainter p(this); |
306 | paintButton ( &p, i ); | 306 | paintButton ( &p, i ); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | void VideoWidget::paintButton( QPainter *p, int i ) { | 310 | void VideoWidget::paintButton( QPainter *p, int i ) { |
311 | if ( videoButtons[i].isDown ) | 311 | if ( videoButtons[i].isDown ) |
312 | { | 312 | { |
313 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 313 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
314 | } | 314 | } |
315 | else | 315 | else |
316 | { | 316 | { |
317 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 317 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 322 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
323 | for ( int i = 0; i < numVButtons; i++ ) { | 323 | for ( int i = 0; i < numVButtons; i++ ) { |
324 | if ( event->state() == QMouseEvent::LeftButton ) { | 324 | if ( event->state() == QMouseEvent::LeftButton ) { |
325 | // The test to see if the mouse click is inside the button or not | 325 | // The test to see if the mouse click is inside the button or not |
326 | int x = event->pos().x() - xoff; | 326 | int x = event->pos().x() - xoff; |
327 | int y = event->pos().y() - yoff; | 327 | int y = event->pos().y() - yoff; |
328 | 328 | ||
329 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 329 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
330 | && y < imgButtonMask->height() | 330 | && y < imgButtonMask->height() |
331 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 331 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
332 | 332 | ||
333 | if ( isOnButton && !videoButtons[i].isHeld ) { | 333 | if ( isOnButton && !videoButtons[i].isHeld ) { |
334 | videoButtons[i].isHeld = TRUE; | 334 | videoButtons[i].isHeld = TRUE; |
335 | toggleButton(i); | 335 | toggleButton(i); |
336 | 336 | ||
337 | switch (i) { | 337 | switch (i) { |
338 | case VideoVolUp: | 338 | case VideoVolUp: |
339 | emit moreClicked(); | 339 | emit moreClicked(); |
340 | return; | 340 | return; |
341 | case VideoVolDown: | 341 | case VideoVolDown: |
342 | emit lessClicked(); | 342 | emit lessClicked(); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 345 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
346 | videoButtons[i].isHeld = FALSE; | 346 | videoButtons[i].isHeld = FALSE; |
347 | toggleButton(i); | 347 | toggleButton(i); |
348 | } | 348 | } |
349 | } else { | 349 | } else { |
350 | 350 | ||
351 | if ( videoButtons[i].isHeld ) { | 351 | if ( videoButtons[i].isHeld ) { |
352 | videoButtons[i].isHeld = FALSE; | 352 | videoButtons[i].isHeld = FALSE; |
353 | if ( !videoButtons[i].isToggle ) { | 353 | if ( !videoButtons[i].isToggle ) { |
354 | setToggleButton( i, FALSE ); | 354 | setToggleButton( i, FALSE ); |
355 | } | 355 | } |
356 | 356 | ||
357 | switch(i) { | 357 | switch(i) { |
358 | 358 | ||
359 | case VideoPlay: { | 359 | case VideoPlay: { |
360 | // qDebug("play"); | 360 | // qDebug("play"); |
361 | if( !mediaPlayerState->playing()) { | 361 | if( !mediaPlayerState->playing()) { |
362 | mediaPlayerState->setPlaying( true); | 362 | mediaPlayerState->setPlaying( true); |
363 | setToggleButton( i-1, false ); | 363 | setToggleButton( i-1, false ); |
364 | setToggleButton( i, false ); | 364 | setToggleButton( i, false ); |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | if( mediaPlayerState->isPaused ) { | 367 | if( mediaPlayerState->isPaused ) { |
368 | // qDebug("isPaused"); | 368 | // qDebug("isPaused"); |
369 | setToggleButton( i, FALSE ); | 369 | setToggleButton( i, FALSE ); |
370 | mediaPlayerState->setPaused( FALSE ); | 370 | mediaPlayerState->setPaused( FALSE ); |
371 | return; | 371 | return; |
372 | } else if( !mediaPlayerState->isPaused ) { | 372 | } else if( !mediaPlayerState->isPaused ) { |
373 | // qDebug("is not paused"); | 373 | // qDebug("is not paused"); |
374 | setToggleButton( i, TRUE ); | 374 | setToggleButton( i, TRUE ); |
375 | mediaPlayerState->setPaused( TRUE ); | 375 | mediaPlayerState->setPaused( TRUE ); |
376 | return; | 376 | return; |
377 | } else { | 377 | } else { |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | 381 | ||
382 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; | 382 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; |
383 | case VideoNext: mediaPlayerState->setNext(); return; | 383 | case VideoNext: mediaPlayerState->setNext(); return; |
384 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 384 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
385 | case VideoVolUp: emit moreReleased(); return; | 385 | case VideoVolUp: emit moreReleased(); return; |
386 | case VideoVolDown: emit lessReleased(); return; | 386 | case VideoVolDown: emit lessReleased(); return; |
387 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 387 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 395 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
396 | mouseMoveEvent( event ); | 396 | mouseMoveEvent( event ); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 400 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
401 | if ( mediaPlayerState->fullscreen() ) | 401 | if ( mediaPlayerState->fullscreen() ) |
402 | { | 402 | { |
403 | mediaPlayerState->setFullscreen( FALSE ); | 403 | mediaPlayerState->setFullscreen( FALSE ); |
404 | makeVisible(); | 404 | makeVisible(); |
405 | } | 405 | } |
406 | mouseMoveEvent( event ); | 406 | mouseMoveEvent( event ); |
407 | // } | 407 | // } |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | void VideoWidget::makeVisible() { | 411 | void VideoWidget::makeVisible() { |
412 | if ( mediaPlayerState->fullscreen() ) | 412 | if ( mediaPlayerState->fullscreen() ) |
413 | { | 413 | { |
414 | setBackgroundMode( QWidget::NoBackground ); | 414 | setBackgroundMode( QWidget::NoBackground ); |
415 | showFullScreen(); | 415 | showFullScreen(); |
416 | resize( qApp->desktop()->size() ); | 416 | resize( qApp->desktop()->size() ); |
417 | slider->hide(); | 417 | slider->hide(); |
418 | } | 418 | } |
419 | else | 419 | else |
420 | { | 420 | { |
421 | setBackgroundPixmap( *pixBg ); | 421 | setBackgroundPixmap( *pixBg ); |
422 | showNormal(); | 422 | showNormal(); |
423 | showMaximized(); | 423 | QPEApplication::showWidget( this ); |
424 | slider->show(); | 424 | slider->show(); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 429 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
430 | QPainter p( this ); | 430 | QPainter p( this ); |
431 | 431 | ||
432 | if ( mediaPlayerState->fullscreen() ) { | 432 | if ( mediaPlayerState->fullscreen() ) { |
433 | // Clear the background | 433 | // Clear the background |
434 | p.setBrush( QBrush( Qt::black ) ); | 434 | p.setBrush( QBrush( Qt::black ) ); |
435 | p.drawRect( rect() ); | 435 | p.drawRect( rect() ); |
436 | } else { | 436 | } else { |
437 | if ( !pe->erased() ) { | 437 | if ( !pe->erased() ) { |
438 | // Combine with background and double buffer | 438 | // Combine with background and double buffer |
439 | QPixmap pix( pe->rect().size() ); | 439 | QPixmap pix( pe->rect().size() ); |
440 | QPainter p( &pix ); | 440 | QPainter p( &pix ); |
441 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 441 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
442 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 442 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
443 | for ( int i = 0; i < numVButtons; i++ ) { | 443 | for ( int i = 0; i < numVButtons; i++ ) { |
444 | paintButton( &p, i ); | 444 | paintButton( &p, i ); |
445 | } | 445 | } |
446 | QPainter p2( this ); | 446 | QPainter p2( this ); |
447 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 447 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
448 | } else { | 448 | } else { |
449 | QPainter p( this ); | 449 | QPainter p( this ); |
450 | for ( int i = 0; i < numVButtons; i++ ) | 450 | for ( int i = 0; i < numVButtons; i++ ) |
451 | paintButton( &p, i ); | 451 | paintButton( &p, i ); |
452 | } | 452 | } |
453 | slider->repaint( TRUE ); | 453 | slider->repaint( TRUE ); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void VideoWidget::closeEvent( QCloseEvent* ) { | 458 | void VideoWidget::closeEvent( QCloseEvent* ) { |
459 | mediaPlayerState->setList(); | 459 | mediaPlayerState->setList(); |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | bool VideoWidget::playVideo() { | 463 | bool VideoWidget::playVideo() { |
464 | bool result = FALSE; | 464 | bool result = FALSE; |
465 | // qDebug("<<<<<<<<<<<<<<<< play video"); | 465 | // qDebug("<<<<<<<<<<<<<<<< play video"); |
466 | int stream = 0; | 466 | int stream = 0; |
467 | 467 | ||
468 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 468 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
469 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 469 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
470 | int dd = QPixmap::defaultDepth(); | 470 | int dd = QPixmap::defaultDepth(); |
471 | int w = height(); | 471 | int w = height(); |
472 | int h = width(); | 472 | int h = width(); |
473 | 473 | ||
474 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 474 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
475 | 475 | ||
476 | if ( mediaPlayerState->fullscreen() ) | 476 | if ( mediaPlayerState->fullscreen() ) |
477 | { | 477 | { |
478 | #ifdef USE_DIRECT_PAINTER | 478 | #ifdef USE_DIRECT_PAINTER |
479 | QDirectPainter p(this); | 479 | QDirectPainter p(this); |
480 | 480 | ||
481 | if ( ( qt_screen->transformOrientation() == 3 ) && | 481 | if ( ( qt_screen->transformOrientation() == 3 ) && |
482 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) | 482 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) |
483 | { | 483 | { |
484 | 484 | ||
485 | w = 320; | 485 | w = 320; |
486 | h = 240; | 486 | h = 240; |
487 | 487 | ||
488 | if ( mediaPlayerState->scaled() ) | 488 | if ( mediaPlayerState->scaled() ) |
489 | { | 489 | { |
490 | // maintain aspect ratio | 490 | // maintain aspect ratio |
491 | if ( w * sh > sw * h ) | 491 | if ( w * sh > sw * h ) |
492 | w = sw * h / sh; | 492 | w = sw * h / sh; |
493 | else | 493 | else |
494 | h = sh * w / sw; | 494 | h = sh * w / sw; |
495 | } | 495 | } |
496 | else | 496 | else |
497 | { | 497 | { |
498 | w = sw; | 498 | w = sw; |
499 | h = sh; | 499 | h = sh; |
500 | } | 500 | } |
501 | 501 | ||
502 | w--; // we can't allow libmpeg to overwrite. | 502 | w--; // we can't allow libmpeg to overwrite. |
503 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 503 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
504 | 504 | ||
505 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 505 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
506 | int oy = roff.y() + (width() - h) / 2; | 506 | int oy = roff.y() + (width() - h) / 2; |
507 | int sx = 0, sy = 0; | 507 | int sx = 0, sy = 0; |
508 | 508 | ||
509 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 509 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
510 | fp += dd * ox / 8; | 510 | fp += dd * ox / 8; |
511 | uchar **jt = new uchar*[h]; | 511 | uchar **jt = new uchar*[h]; |
512 | 512 | ||
513 | for ( int i = h; i; i-- ) | 513 | for ( int i = h; i; i-- ) |
514 | { | 514 | { |
515 | jt[h - i] = fp; | 515 | jt[h - i] = fp; |
516 | fp += p.lineStep(); | 516 | fp += p.lineStep(); |
517 | } | 517 | } |
518 | 518 | ||
519 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 519 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
520 | 520 | ||
521 | delete [] jt; | 521 | delete [] jt; |
522 | } | 522 | } |
523 | else | 523 | else |
524 | { | 524 | { |
525 | #endif | 525 | #endif |
526 | QPainter p(this); | 526 | QPainter p(this); |
527 | 527 | ||
528 | w = 320; | 528 | w = 320; |
529 | h = 240; | 529 | h = 240; |
530 | 530 | ||
531 | if ( mediaPlayerState->scaled() ) | 531 | if ( mediaPlayerState->scaled() ) |
532 | { | 532 | { |
533 | // maintain aspect ratio | 533 | // maintain aspect ratio |
534 | if ( w * sh > sw * h ) | 534 | if ( w * sh > sw * h ) |
535 | w = sw * h / sh; | 535 | w = sw * h / sh; |
536 | else | 536 | else |
537 | h = sh * w / sw; | 537 | h = sh * w / sw; |
538 | } | 538 | } |
539 | else | 539 | else |
540 | { | 540 | { |
541 | w = sw; | 541 | w = sw; |
542 | h = sh; | 542 | h = sh; |
543 | } | 543 | } |
544 | 544 | ||
545 | int bytes = ( dd == 16 ) ? 2 : 4; | 545 | int bytes = ( dd == 16 ) ? 2 : 4; |
546 | QImage tempFrame( w, h, bytes << 3 ); | 546 | QImage tempFrame( w, h, bytes << 3 ); |
547 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 547 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
548 | 0, 0, sw, sh, w, h, format, 0) == 0; | 548 | 0, 0, sw, sh, w, h, format, 0) == 0; |
549 | 549 | ||
550 | if ( result && mediaPlayerState->fullscreen() ) | 550 | if ( result && mediaPlayerState->fullscreen() ) |
551 | { | 551 | { |
552 | 552 | ||
553 | int rw = h, rh = w; | 553 | int rw = h, rh = w; |
554 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 554 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
555 | 555 | ||
556 | ushort* in = (ushort*)tempFrame.bits(); | 556 | ushort* in = (ushort*)tempFrame.bits(); |
557 | ushort* out = (ushort*)rotatedFrame.bits(); | 557 | ushort* out = (ushort*)rotatedFrame.bits(); |
558 | int spl = rotatedFrame.bytesPerLine() / bytes; | 558 | int spl = rotatedFrame.bytesPerLine() / bytes; |
559 | 559 | ||
560 | for (int x=0; x<h; x++) | 560 | for (int x=0; x<h; x++) |
561 | { | 561 | { |
562 | if ( bytes == 2 ) | 562 | if ( bytes == 2 ) |
563 | { | 563 | { |
564 | ushort* lout = out++ + (w - 1)*spl; | 564 | ushort* lout = out++ + (w - 1)*spl; |
565 | for (int y=0; y<w; y++) { | 565 | for (int y=0; y<w; y++) { |
566 | *lout=*in++; | 566 | *lout=*in++; |
567 | lout-=spl; | 567 | lout-=spl; |
568 | } | 568 | } |
569 | } | 569 | } |
570 | else | 570 | else |
571 | { | 571 | { |
572 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 572 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
573 | for (int y=0; y<w; y++) | 573 | for (int y=0; y<w; y++) |
574 | { | 574 | { |
575 | *lout=*((ulong*)in)++; | 575 | *lout=*((ulong*)in)++; |
576 | lout-=spl; | 576 | lout-=spl; |
577 | } | 577 | } |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 581 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
582 | } | 582 | } |
583 | #ifdef USE_DIRECT_PAINTER | 583 | #ifdef USE_DIRECT_PAINTER |
584 | } | 584 | } |
585 | #endif | 585 | #endif |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | 589 | ||
590 | w = 220; | 590 | w = 220; |
591 | h = 160; | 591 | h = 160; |
592 | 592 | ||
593 | // maintain aspect ratio | 593 | // maintain aspect ratio |
594 | if ( w * sh > sw * h ) | 594 | if ( w * sh > sw * h ) |
595 | w = sw * h / sh; | 595 | w = sw * h / sh; |
596 | else | 596 | else |
597 | h = sh * w / sw; | 597 | h = sh * w / sw; |
598 | 598 | ||
599 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 599 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
600 | 600 | ||
601 | QPainter p( this ); | 601 | QPainter p( this ); |
602 | int deskW = qApp->desktop()->width(); | 602 | int deskW = qApp->desktop()->width(); |
603 | // Image changed size, therefore need to blank the possibly unpainted regions first | 603 | // Image changed size, therefore need to blank the possibly unpainted regions first |
604 | if ( scaledWidth != w || scaledHeight != h ) | 604 | if ( scaledWidth != w || scaledHeight != h ) |
605 | { | 605 | { |
606 | p.setBrush( QBrush( Qt::black ) ); | 606 | p.setBrush( QBrush( Qt::black ) ); |
607 | p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); | 607 | p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); |
608 | } | 608 | } |
609 | 609 | ||
610 | scaledWidth = w; | 610 | scaledWidth = w; |
611 | scaledHeight = h; | 611 | scaledHeight = h; |
612 | 612 | ||
613 | if ( result ) | 613 | if ( result ) |
614 | { | 614 | { |
615 | p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 615 | p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
616 | } | 616 | } |
617 | 617 | ||
618 | } | 618 | } |
619 | 619 | ||
620 | return result; | 620 | return result; |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | 624 | ||
625 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 625 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) |
626 | { | 626 | { |
627 | switch ( e->key() ) | 627 | switch ( e->key() ) |
628 | { | 628 | { |
629 | ////////////////////////////// Zaurus keys | 629 | ////////////////////////////// Zaurus keys |
630 | case Key_Home: | 630 | case Key_Home: |
631 | break; | 631 | break; |
632 | case Key_F9: //activity | 632 | case Key_F9: //activity |
633 | break; | 633 | break; |
634 | case Key_F10: //contacts | 634 | case Key_F10: //contacts |
635 | // hide(); | 635 | // hide(); |
636 | break; | 636 | break; |
637 | case Key_F11: //menu | 637 | case Key_F11: //menu |
638 | break; | 638 | break; |
639 | case Key_F12: //home | 639 | case Key_F12: //home |
640 | break; | 640 | break; |
641 | case Key_F13: //mail | 641 | case Key_F13: //mail |
642 | break; | 642 | break; |
643 | case Key_Space: | 643 | case Key_Space: |
644 | { | 644 | { |
645 | if(mediaPlayerState->playing()) | 645 | if(mediaPlayerState->playing()) |
646 | { | 646 | { |
647 | mediaPlayerState->setPlaying(FALSE); | 647 | mediaPlayerState->setPlaying(FALSE); |
648 | } | 648 | } |
649 | else | 649 | else |
650 | { | 650 | { |
651 | mediaPlayerState->setPlaying(TRUE); | 651 | mediaPlayerState->setPlaying(TRUE); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | break; | 654 | break; |
655 | case Key_Down: | 655 | case Key_Down: |
656 | // toggleButton(6); | 656 | // toggleButton(6); |
657 | // emit lessClicked(); | 657 | // emit lessClicked(); |
658 | // emit lessReleased(); | 658 | // emit lessReleased(); |
659 | // toggleButton(6); | 659 | // toggleButton(6); |
660 | break; | 660 | break; |
661 | case Key_Up: | 661 | case Key_Up: |
662 | // toggleButton(5); | 662 | // toggleButton(5); |
663 | // emit moreClicked(); | 663 | // emit moreClicked(); |
664 | // emit moreReleased(); | 664 | // emit moreReleased(); |
665 | // toggleButton(5); | 665 | // toggleButton(5); |
666 | break; | 666 | break; |
667 | case Key_Right: | 667 | case Key_Right: |
668 | mediaPlayerState->setNext(); | 668 | mediaPlayerState->setNext(); |
669 | break; | 669 | break; |
670 | case Key_Left: | 670 | case Key_Left: |
671 | mediaPlayerState->setPrev(); | 671 | mediaPlayerState->setPrev(); |
672 | break; | 672 | break; |
673 | case Key_Escape: | 673 | case Key_Escape: |
674 | break; | 674 | break; |
675 | 675 | ||
676 | }; | 676 | }; |
677 | } | 677 | } |
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp index 5aaf63c..c237555 100644 --- a/core/obex/obexhandler.cpp +++ b/core/obex/obexhandler.cpp | |||
@@ -1,67 +1,68 @@ | |||
1 | #include <qcopchannel_qws.h> | 1 | #include <qcopchannel_qws.h> |
2 | 2 | ||
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | #include <qpe/qpeapplication.h> | ||
4 | 5 | ||
5 | #include "obexsend.h" | 6 | #include "obexsend.h" |
6 | #include "receiver.h" | 7 | #include "receiver.h" |
7 | #include "obexhandler.h" | 8 | #include "obexhandler.h" |
8 | 9 | ||
9 | using namespace OpieObex; | 10 | using namespace OpieObex; |
10 | 11 | ||
11 | /* TRANSLATOR OpieObex::ObexHandler */ | 12 | /* TRANSLATOR OpieObex::ObexHandler */ |
12 | 13 | ||
13 | ObexHandler::ObexHandler() { | 14 | ObexHandler::ObexHandler() { |
14 | m_wasRec = false; | 15 | m_wasRec = false; |
15 | m_sender = 0l; | 16 | m_sender = 0l; |
16 | m_receiver = 0l; | 17 | m_receiver = 0l; |
17 | QCopChannel* chan = new QCopChannel("QPE/Obex"); | 18 | QCopChannel* chan = new QCopChannel("QPE/Obex"); |
18 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 19 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), |
19 | this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); | 20 | this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); |
20 | } | 21 | } |
21 | ObexHandler::~ObexHandler() { | 22 | ObexHandler::~ObexHandler() { |
22 | delete m_sender; | 23 | delete m_sender; |
23 | delete m_receiver; | 24 | delete m_receiver; |
24 | } | 25 | } |
25 | void ObexHandler::doSend(const QString& str, const QString& desc) { | 26 | void ObexHandler::doSend(const QString& str, const QString& desc) { |
26 | delete m_sender; | 27 | delete m_sender; |
27 | m_sender = new SendWidget; | 28 | m_sender = new SendWidget; |
28 | m_sender->raise(); | 29 | m_sender->raise(); |
29 | m_sender->showMaximized(); | 30 | QPEApplication::showWidget( m_sender ); |
30 | connect(m_sender, SIGNAL(done() ), | 31 | connect(m_sender, SIGNAL(done() ), |
31 | this, SLOT(slotSent() ) ); | 32 | this, SLOT(slotSent() ) ); |
32 | m_sender->send( str, desc ); | 33 | m_sender->send( str, desc ); |
33 | } | 34 | } |
34 | void ObexHandler::doReceive(bool b) { | 35 | void ObexHandler::doReceive(bool b) { |
35 | if (m_receiver && b ) return; // we should enable receiver and it is on | 36 | if (m_receiver && b ) return; // we should enable receiver and it is on |
36 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off | 37 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off |
37 | else if (m_receiver && !b ) { | 38 | else if (m_receiver && !b ) { |
38 | delete m_receiver; | 39 | delete m_receiver; |
39 | m_receiver=0; | 40 | m_receiver=0; |
40 | }else if (!m_receiver && b ) { | 41 | }else if (!m_receiver && b ) { |
41 | m_receiver= new Receiver; | 42 | m_receiver= new Receiver; |
42 | } | 43 | } |
43 | } | 44 | } |
44 | void ObexHandler::slotSent() { | 45 | void ObexHandler::slotSent() { |
45 | QString file = m_sender->file(); | 46 | QString file = m_sender->file(); |
46 | delete m_sender; | 47 | delete m_sender; |
47 | m_sender = 0; | 48 | m_sender = 0; |
48 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); | 49 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); |
49 | e << file; | 50 | e << file; |
50 | doReceive(m_wasRec ); | 51 | doReceive(m_wasRec ); |
51 | m_wasRec = false; | 52 | m_wasRec = false; |
52 | } | 53 | } |
53 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { | 54 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { |
54 | QDataStream stream( data, IO_ReadOnly ); | 55 | QDataStream stream( data, IO_ReadOnly ); |
55 | if ( msg == "send(QString,QString,QString)" ) { | 56 | if ( msg == "send(QString,QString,QString)" ) { |
56 | QString name, desc; | 57 | QString name, desc; |
57 | stream >> desc; | 58 | stream >> desc; |
58 | stream >> name; | 59 | stream >> name; |
59 | m_wasRec = (m_receiver != 0 ); | 60 | m_wasRec = (m_receiver != 0 ); |
60 | doReceive( false ); | 61 | doReceive( false ); |
61 | doSend(name, desc); | 62 | doSend(name, desc); |
62 | }else if (msg == "receive(int)") { | 63 | }else if (msg == "receive(int)") { |
63 | int rec; | 64 | int rec; |
64 | stream >> rec; | 65 | stream >> rec; |
65 | doReceive(rec); | 66 | doReceive(rec); |
66 | } | 67 | } |
67 | } | 68 | } |
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 139c91b..c83a5df 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,478 +1,478 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp | 2 | * today.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | #define QTOPIA_INTERNAL_LANGLIST | 19 | #define QTOPIA_INTERNAL_LANGLIST |
20 | 20 | ||
21 | #include "today.h" | 21 | #include "today.h" |
22 | 22 | ||
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/contact.h> | 28 | #include <qpe/contact.h> |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | 33 | ||
34 | struct TodayPlugin { | 34 | struct TodayPlugin { |
35 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} | 35 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} |
36 | QLibrary *library; | 36 | QLibrary *library; |
37 | QInterfacePtr<TodayPluginInterface> iface; | 37 | QInterfacePtr<TodayPluginInterface> iface; |
38 | TodayPluginObject *guiPart; | 38 | TodayPluginObject *guiPart; |
39 | QWidget *guiBox; | 39 | QWidget *guiBox; |
40 | QString name; | 40 | QString name; |
41 | bool active; | 41 | bool active; |
42 | bool excludeRefresh; | 42 | bool excludeRefresh; |
43 | int pos; | 43 | int pos; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static QValueList<TodayPlugin> pluginList; | 46 | static QValueList<TodayPlugin> pluginList; |
47 | 47 | ||
48 | static QMap<QString, TodayPlugin> tempList; | 48 | static QMap<QString, TodayPlugin> tempList; |
49 | 49 | ||
50 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 50 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
51 | : TodayBase( parent, name, fl ) { | 51 | : TodayBase( parent, name, fl ) { |
52 | 52 | ||
53 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 53 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
54 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 54 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
55 | 55 | ||
56 | #if defined(Q_WS_QWS) | 56 | #if defined(Q_WS_QWS) |
57 | #if !defined(QT_NO_COP) | 57 | #if !defined(QT_NO_COP) |
58 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 58 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
59 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 59 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
60 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 60 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
61 | #endif | 61 | #endif |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | setOwnerField(); | 64 | setOwnerField(); |
65 | m_refreshTimer = new QTimer( this ); | 65 | m_refreshTimer = new QTimer( this ); |
66 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 66 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
67 | m_refreshTimer->start( 15000 ); | 67 | m_refreshTimer->start( 15000 ); |
68 | m_big_box = 0L; | 68 | m_big_box = 0L; |
69 | 69 | ||
70 | 70 | ||
71 | layout = new QVBoxLayout( this ); | 71 | layout = new QVBoxLayout( this ); |
72 | layout->addWidget( Frame ); | 72 | layout->addWidget( Frame ); |
73 | layout->addWidget( OwnerField ); | 73 | layout->addWidget( OwnerField ); |
74 | 74 | ||
75 | m_sv = new QScrollView( this ); | 75 | m_sv = new QScrollView( this ); |
76 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); | 76 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); |
77 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 77 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
78 | m_sv->setFrameShape( QFrame::NoFrame ); | 78 | m_sv->setFrameShape( QFrame::NoFrame ); |
79 | 79 | ||
80 | layout->addWidget( m_sv ); | 80 | layout->addWidget( m_sv ); |
81 | layout->setStretchFactor( m_sv,4 ); | 81 | layout->setStretchFactor( m_sv,4 ); |
82 | 82 | ||
83 | qApp->processEvents(); | 83 | qApp->processEvents(); |
84 | loadPlugins(); | 84 | loadPlugins(); |
85 | showMaximized(); | 85 | QPEApplication::showWidget( this ); |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Qcop receive method. | 89 | * Qcop receive method. |
90 | */ | 90 | */ |
91 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 91 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
92 | QDataStream stream( data, IO_ReadOnly ); | 92 | QDataStream stream( data, IO_ReadOnly ); |
93 | if ( msg == "message(QString)" ) { | 93 | if ( msg == "message(QString)" ) { |
94 | QString message; | 94 | QString message; |
95 | stream >> message; | 95 | stream >> message; |
96 | setOwnerField( message ); | 96 | setOwnerField( message ); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | void Today::setRefreshTimer( int interval ) { | 100 | void Today::setRefreshTimer( int interval ) { |
101 | 101 | ||
102 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 102 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
103 | 103 | ||
104 | // 0 is "never" case | 104 | // 0 is "never" case |
105 | if ( !interval == 0 ) { | 105 | if ( !interval == 0 ) { |
106 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 106 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
107 | m_refreshTimer->changeInterval( interval ); | 107 | m_refreshTimer->changeInterval( interval ); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | /** | 112 | /** |
113 | * Initialises the owner field with the default value, the username | 113 | * Initialises the owner field with the default value, the username |
114 | */ | 114 | */ |
115 | void Today::setOwnerField() { | 115 | void Today::setOwnerField() { |
116 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); | 116 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); |
117 | if ( QFile::exists( file ) ) { | 117 | if ( QFile::exists( file ) ) { |
118 | Contact cont = Contact::readVCard( file )[0]; | 118 | Contact cont = Contact::readVCard( file )[0]; |
119 | QString returnString = cont.fullName(); | 119 | QString returnString = cont.fullName(); |
120 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); | 120 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); |
121 | } else { | 121 | } else { |
122 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 122 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Set the owner field with a given QString, for example per qcop. | 127 | * Set the owner field with a given QString, for example per qcop. |
128 | */ | 128 | */ |
129 | void Today::setOwnerField( QString &message ) { | 129 | void Today::setOwnerField( QString &message ) { |
130 | if ( !message.isEmpty() ) { | 130 | if ( !message.isEmpty() ) { |
131 | OwnerField->setText( "<b>" + message + "</b>" ); | 131 | OwnerField->setText( "<b>" + message + "</b>" ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Init stuff needed for today. Reads the config file. | 136 | * Init stuff needed for today. Reads the config file. |
137 | */ | 137 | */ |
138 | void Today::init() { | 138 | void Today::init() { |
139 | // read config | 139 | // read config |
140 | Config cfg( "today" ); | 140 | Config cfg( "today" ); |
141 | 141 | ||
142 | cfg.setGroup( "Plugins" ); | 142 | cfg.setGroup( "Plugins" ); |
143 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 143 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
144 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 144 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
145 | 145 | ||
146 | cfg.setGroup( "General" ); | 146 | cfg.setGroup( "General" ); |
147 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 147 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
148 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 148 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
149 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 149 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
150 | 150 | ||
151 | // set the date in top label | 151 | // set the date in top label |
152 | QDate date = QDate::currentDate(); | 152 | QDate date = QDate::currentDate(); |
153 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 153 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
154 | 154 | ||
155 | if ( m_hideBanner ) { | 155 | if ( m_hideBanner ) { |
156 | Opiezilla->hide(); | 156 | Opiezilla->hide(); |
157 | TodayLabel->hide(); | 157 | TodayLabel->hide(); |
158 | } else { | 158 | } else { |
159 | Opiezilla->show(); | 159 | Opiezilla->show(); |
160 | TodayLabel->show(); | 160 | TodayLabel->show(); |
161 | } | 161 | } |
162 | 162 | ||
163 | if ( m_big_box ) { | 163 | if ( m_big_box ) { |
164 | delete m_big_box; | 164 | delete m_big_box; |
165 | } | 165 | } |
166 | 166 | ||
167 | m_big_box = new QWidget( m_sv->viewport() ); | 167 | m_big_box = new QWidget( m_sv->viewport() ); |
168 | m_sv->addChild( m_big_box ); | 168 | m_sv->addChild( m_big_box ); |
169 | m_bblayout = new QVBoxLayout ( m_big_box ); | 169 | m_bblayout = new QVBoxLayout ( m_big_box ); |
170 | } | 170 | } |
171 | 171 | ||
172 | /** | 172 | /** |
173 | * Load the plugins | 173 | * Load the plugins |
174 | */ | 174 | */ |
175 | void Today::loadPlugins() { | 175 | void Today::loadPlugins() { |
176 | 176 | ||
177 | init(); | 177 | init(); |
178 | 178 | ||
179 | QValueList<TodayPlugin>::Iterator tit; | 179 | QValueList<TodayPlugin>::Iterator tit; |
180 | if ( !pluginList.isEmpty() ) { | 180 | if ( !pluginList.isEmpty() ) { |
181 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 181 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
182 | (*tit).guiBox->hide(); | 182 | (*tit).guiBox->hide(); |
183 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); | 183 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); |
184 | delete (*tit).guiBox; | 184 | delete (*tit).guiBox; |
185 | (*tit).library->unload(); | 185 | (*tit).library->unload(); |
186 | delete (*tit).library; | 186 | delete (*tit).library; |
187 | } | 187 | } |
188 | pluginList.clear(); | 188 | pluginList.clear(); |
189 | } | 189 | } |
190 | 190 | ||
191 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 191 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
192 | #ifdef Q_OS_MACX | 192 | #ifdef Q_OS_MACX |
193 | qWarning("Searching for Plugins in: %s", path.latin1()); | 193 | qWarning("Searching for Plugins in: %s", path.latin1()); |
194 | QDir dir( path, "lib*.dylib" ); | 194 | QDir dir( path, "lib*.dylib" ); |
195 | #else | 195 | #else |
196 | QDir dir( path, "lib*.so" ); | 196 | QDir dir( path, "lib*.so" ); |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | QStringList list = dir.entryList(); | 199 | QStringList list = dir.entryList(); |
200 | QStringList::Iterator it; | 200 | QStringList::Iterator it; |
201 | 201 | ||
202 | // QMap<QString, TodayPlugin> tempList; | 202 | // QMap<QString, TodayPlugin> tempList; |
203 | 203 | ||
204 | for ( it = list.begin(); it != list.end(); ++it ) { | 204 | for ( it = list.begin(); it != list.end(); ++it ) { |
205 | QInterfacePtr<TodayPluginInterface> iface; | 205 | QInterfacePtr<TodayPluginInterface> iface; |
206 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 206 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
207 | 207 | ||
208 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 208 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
209 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 209 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
210 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 210 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); |
211 | qDebug( QString(*it) ); | 211 | qDebug( QString(*it) ); |
212 | 212 | ||
213 | TodayPlugin plugin; | 213 | TodayPlugin plugin; |
214 | plugin.library = lib; | 214 | plugin.library = lib; |
215 | plugin.iface = iface; | 215 | plugin.iface = iface; |
216 | plugin.name = QString(*it); | 216 | plugin.name = QString(*it); |
217 | 217 | ||
218 | QString type = (*it).left( (*it).find(".") ); | 218 | QString type = (*it).left( (*it).find(".") ); |
219 | 219 | ||
220 | QString lang; | 220 | QString lang; |
221 | Config config("locale"); | 221 | Config config("locale"); |
222 | config.setGroup("Language"); | 222 | config.setGroup("Language"); |
223 | lang = config.readEntry( "Language", "en" ); | 223 | lang = config.readEntry( "Language", "en" ); |
224 | 224 | ||
225 | qDebug( "Languages: " + lang ); | 225 | qDebug( "Languages: " + lang ); |
226 | QTranslator * trans = new QTranslator( qApp ); | 226 | QTranslator * trans = new QTranslator( qApp ); |
227 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; | 227 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; |
228 | if ( trans->load( tfn ) ) { | 228 | if ( trans->load( tfn ) ) { |
229 | qApp->installTranslator( trans ); | 229 | qApp->installTranslator( trans ); |
230 | } else { | 230 | } else { |
231 | delete trans; | 231 | delete trans; |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | // find out if plugins should be shown | 235 | // find out if plugins should be shown |
236 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 236 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
237 | plugin.active = true; | 237 | plugin.active = true; |
238 | } else { | 238 | } else { |
239 | plugin.active = false; | 239 | plugin.active = false; |
240 | } | 240 | } |
241 | 241 | ||
242 | plugin.guiPart = plugin.iface->guiPart(); | 242 | plugin.guiPart = plugin.iface->guiPart(); |
243 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | 243 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); |
244 | 244 | ||
245 | // package the whole thing into a qwidget so it can be shown and hidden | 245 | // package the whole thing into a qwidget so it can be shown and hidden |
246 | plugin.guiBox = new QWidget( m_big_box ); | 246 | plugin.guiBox = new QWidget( m_big_box ); |
247 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 247 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
248 | QPixmap plugPix; | 248 | QPixmap plugPix; |
249 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); | 249 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
250 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 250 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
251 | plugIcon->setPixmap( plugPix ); | 251 | plugIcon->setPixmap( plugPix ); |
252 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); | 252 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); |
253 | plugIcon->setName( plugin.guiPart->appName() ); | 253 | plugIcon->setName( plugin.guiPart->appName() ); |
254 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); | 254 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); |
255 | 255 | ||
256 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); | 256 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); |
257 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 257 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
258 | boxLayout->addWidget( plugWidget, 0, AlignTop ); | 258 | boxLayout->addWidget( plugWidget, 0, AlignTop ); |
259 | boxLayout->setStretchFactor( plugIcon, 1 ); | 259 | boxLayout->setStretchFactor( plugIcon, 1 ); |
260 | boxLayout->setStretchFactor( plugWidget, 9 ); | 260 | boxLayout->setStretchFactor( plugWidget, 9 ); |
261 | 261 | ||
262 | // "prebuffer" it in one more list, to get the sorting done | 262 | // "prebuffer" it in one more list, to get the sorting done |
263 | tempList.insert( plugin.name, plugin ); | 263 | tempList.insert( plugin.name, plugin ); |
264 | 264 | ||
265 | // on first start the list is off course empty | 265 | // on first start the list is off course empty |
266 | if ( m_allApplets.isEmpty() ) { | 266 | if ( m_allApplets.isEmpty() ) { |
267 | pluginList.append( plugin ); | 267 | pluginList.append( plugin ); |
268 | m_bblayout->addWidget( plugin.guiBox ); | 268 | m_bblayout->addWidget( plugin.guiBox ); |
269 | } | 269 | } |
270 | 270 | ||
271 | // if plugin is not yet in the list, add it to the layout too | 271 | // if plugin is not yet in the list, add it to the layout too |
272 | else if ( !m_allApplets.contains( plugin.name ) ) { | 272 | else if ( !m_allApplets.contains( plugin.name ) ) { |
273 | pluginList.append( plugin ); | 273 | pluginList.append( plugin ); |
274 | } | 274 | } |
275 | } else { | 275 | } else { |
276 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 276 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
277 | delete lib; | 277 | delete lib; |
278 | } | 278 | } |
279 | 279 | ||
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | if ( !m_allApplets.isEmpty() ) { | 283 | if ( !m_allApplets.isEmpty() ) { |
284 | TodayPlugin tempPlugin; | 284 | TodayPlugin tempPlugin; |
285 | QStringList::Iterator stringit; | 285 | QStringList::Iterator stringit; |
286 | 286 | ||
287 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 287 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
288 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 288 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
289 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 289 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
290 | pluginList.append( tempPlugin ); | 290 | pluginList.append( tempPlugin ); |
291 | m_bblayout->addWidget( tempPlugin.guiBox ); | 291 | m_bblayout->addWidget( tempPlugin.guiBox ); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | } | 294 | } |
295 | m_bblayout->addStretch( 2 ); | 295 | m_bblayout->addStretch( 2 ); |
296 | draw(); | 296 | draw(); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | 300 | ||
301 | 301 | ||
302 | /** | 302 | /** |
303 | * Repaint method. Reread all fields. | 303 | * Repaint method. Reread all fields. |
304 | */ | 304 | */ |
305 | void Today::draw() { | 305 | void Today::draw() { |
306 | 306 | ||
307 | if ( pluginList.count() == 0 ) { | 307 | if ( pluginList.count() == 0 ) { |
308 | QLabel *noPlugins = new QLabel( this ); | 308 | QLabel *noPlugins = new QLabel( this ); |
309 | noPlugins->setText( tr( "No plugins found" ) ); | 309 | noPlugins->setText( tr( "No plugins found" ) ); |
310 | layout->addWidget( noPlugins ); | 310 | layout->addWidget( noPlugins ); |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | 313 | ||
314 | uint count = 0; | 314 | uint count = 0; |
315 | TodayPlugin plugin; | 315 | TodayPlugin plugin; |
316 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 316 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
317 | plugin = pluginList[i]; | 317 | plugin = pluginList[i]; |
318 | 318 | ||
319 | if ( plugin.active ) { | 319 | if ( plugin.active ) { |
320 | // qDebug( plugin.name + " is ACTIVE " ); | 320 | // qDebug( plugin.name + " is ACTIVE " ); |
321 | plugin.guiBox->show(); | 321 | plugin.guiBox->show(); |
322 | } else { | 322 | } else { |
323 | // qDebug( plugin.name + " is INACTIVE" ); | 323 | // qDebug( plugin.name + " is INACTIVE" ); |
324 | plugin.guiBox->hide(); | 324 | plugin.guiBox->hide(); |
325 | } | 325 | } |
326 | count++; | 326 | count++; |
327 | } | 327 | } |
328 | 328 | ||
329 | if ( count == 0 ) { | 329 | if ( count == 0 ) { |
330 | QLabel *noPluginsActive = new QLabel( this ); | 330 | QLabel *noPluginsActive = new QLabel( this ); |
331 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 331 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
332 | layout->addWidget( noPluginsActive ); | 332 | layout->addWidget( noPluginsActive ); |
333 | } | 333 | } |
334 | repaint(); | 334 | repaint(); |
335 | } | 335 | } |
336 | 336 | ||
337 | 337 | ||
338 | /** | 338 | /** |
339 | * The method for the configuration dialog. | 339 | * The method for the configuration dialog. |
340 | */ | 340 | */ |
341 | void Today::startConfig() { | 341 | void Today::startConfig() { |
342 | 342 | ||
343 | // disconnect timer to prevent problems while being on config dialog | 343 | // disconnect timer to prevent problems while being on config dialog |
344 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 344 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
345 | m_refreshTimer->stop( ); | 345 | m_refreshTimer->stop( ); |
346 | 346 | ||
347 | TodayConfig conf( this, "dialog", true ); | 347 | TodayConfig conf( this, "dialog", true ); |
348 | 348 | ||
349 | TodayPlugin plugin; | 349 | TodayPlugin plugin; |
350 | QList<TodayConfigWidget> configWidgetList; | 350 | QList<TodayConfigWidget> configWidgetList; |
351 | 351 | ||
352 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { | 352 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { |
353 | plugin = pluginList[i]; | 353 | plugin = pluginList[i]; |
354 | 354 | ||
355 | // load the config widgets in the tabs | 355 | // load the config widgets in the tabs |
356 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 356 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
357 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); | 357 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); |
358 | configWidgetList.append( widget ); | 358 | configWidgetList.append( widget ); |
359 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() | 359 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() |
360 | , plugin.guiPart->appName() ); | 360 | , plugin.guiPart->appName() ); |
361 | } | 361 | } |
362 | // set the order/activate tab | 362 | // set the order/activate tab |
363 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 363 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
364 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 364 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
365 | } | 365 | } |
366 | 366 | ||
367 | if ( conf.exec() == QDialog::Accepted ) { | 367 | if ( conf.exec() == QDialog::Accepted ) { |
368 | conf.writeConfig(); | 368 | conf.writeConfig(); |
369 | TodayConfigWidget *confWidget; | 369 | TodayConfigWidget *confWidget; |
370 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 370 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
371 | confWidget = configWidgetList.next() ) { | 371 | confWidget = configWidgetList.next() ) { |
372 | confWidget->writeConfig(); | 372 | confWidget->writeConfig(); |
373 | } | 373 | } |
374 | 374 | ||
375 | // make the plugins to reinitialize ( reread its configs ) | 375 | // make the plugins to reinitialize ( reread its configs ) |
376 | reinitialize(); | 376 | reinitialize(); |
377 | draw(); | 377 | draw(); |
378 | 378 | ||
379 | } else { | 379 | } else { |
380 | // since refresh is not called in that case , reconnect the signal | 380 | // since refresh is not called in that case , reconnect the signal |
381 | m_refreshTimer->start( 15000 ); // get the config value in here later | 381 | m_refreshTimer->start( 15000 ); // get the config value in here later |
382 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 382 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | 387 | ||
388 | void Today::reinitialize() { | 388 | void Today::reinitialize() { |
389 | 389 | ||
390 | Config cfg( "today" ); | 390 | Config cfg( "today" ); |
391 | cfg.setGroup( "Plugins" ); | 391 | cfg.setGroup( "Plugins" ); |
392 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 392 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
393 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 393 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
394 | 394 | ||
395 | /* reinitialize all plugins */ | 395 | /* reinitialize all plugins */ |
396 | QValueList<TodayPlugin>::Iterator it; | 396 | QValueList<TodayPlugin>::Iterator it; |
397 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 397 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
398 | if ( !(*it).excludeRefresh ) { | 398 | if ( !(*it).excludeRefresh ) { |
399 | (*it).guiPart->reinitialize(); | 399 | (*it).guiPart->reinitialize(); |
400 | qDebug( "reinit" ); | 400 | qDebug( "reinit" ); |
401 | } | 401 | } |
402 | 402 | ||
403 | /* check if plugins is still to be shown */ | 403 | /* check if plugins is still to be shown */ |
404 | if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { | 404 | if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { |
405 | (*it).active = true; | 405 | (*it).active = true; |
406 | } else { | 406 | } else { |
407 | (*it).active = false; | 407 | (*it).active = false; |
408 | } | 408 | } |
409 | 409 | ||
410 | } | 410 | } |
411 | 411 | ||
412 | cfg.setGroup( "General" ); | 412 | cfg.setGroup( "General" ); |
413 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 413 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
414 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 414 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
415 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 415 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
416 | 416 | ||
417 | // set the date in top label | 417 | // set the date in top label |
418 | QDate date = QDate::currentDate(); | 418 | QDate date = QDate::currentDate(); |
419 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 419 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
420 | 420 | ||
421 | if ( m_hideBanner ) { | 421 | if ( m_hideBanner ) { |
422 | Opiezilla->hide(); | 422 | Opiezilla->hide(); |
423 | TodayLabel->hide(); | 423 | TodayLabel->hide(); |
424 | } else { | 424 | } else { |
425 | Opiezilla->show(); | 425 | Opiezilla->show(); |
426 | TodayLabel->show(); | 426 | TodayLabel->show(); |
427 | } | 427 | } |
428 | 428 | ||
429 | delete m_bblayout; | 429 | delete m_bblayout; |
430 | m_bblayout = new QVBoxLayout( m_big_box ); | 430 | m_bblayout = new QVBoxLayout( m_big_box ); |
431 | TodayPlugin tempPlugin; | 431 | TodayPlugin tempPlugin; |
432 | QStringList::Iterator stringit; | 432 | QStringList::Iterator stringit; |
433 | 433 | ||
434 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 434 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
435 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 435 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
436 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 436 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
437 | m_bblayout->addWidget( tempPlugin.guiBox ); | 437 | m_bblayout->addWidget( tempPlugin.guiBox ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | m_bblayout->addStretch( 2 ); | 440 | m_bblayout->addStretch( 2 ); |
441 | 441 | ||
442 | } | 442 | } |
443 | 443 | ||
444 | /** | 444 | /** |
445 | * Refresh for the view. Reload all applets | 445 | * Refresh for the view. Reload all applets |
446 | * | 446 | * |
447 | */ | 447 | */ |
448 | void Today::refresh() { | 448 | void Today::refresh() { |
449 | 449 | ||
450 | QValueList<TodayPlugin>::Iterator it; | 450 | QValueList<TodayPlugin>::Iterator it; |
451 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 451 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
452 | if ( !(*it).excludeRefresh ) { | 452 | if ( !(*it).excludeRefresh ) { |
453 | (*it).guiPart->refresh(); | 453 | (*it).guiPart->refresh(); |
454 | qDebug( "refresh" ); | 454 | qDebug( "refresh" ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); | 458 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); |
459 | 459 | ||
460 | updateGeometry(); | 460 | updateGeometry(); |
461 | repaint(); | 461 | repaint(); |
462 | } | 462 | } |
463 | 463 | ||
464 | void Today::startApplication() { | 464 | void Today::startApplication() { |
465 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 465 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
466 | e << QString( sender()->name() ); | 466 | e << QString( sender()->name() ); |
467 | } | 467 | } |
468 | 468 | ||
469 | /** | 469 | /** |
470 | * launch addressbook (personal card) | 470 | * launch addressbook (personal card) |
471 | */ | 471 | */ |
472 | void Today::editCard() { | 472 | void Today::editCard() { |
473 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); | 473 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); |
474 | } | 474 | } |
475 | 475 | ||
476 | Today::~Today() { | 476 | Today::~Today() { |
477 | } | 477 | } |
478 | 478 | ||
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index e71c5b0..9ced0d8 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -1,229 +1,230 @@ | |||
1 | /* | 1 | /* |
2 | * todayconfig.cpp | 2 | * todayconfig.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002, 2003 by Maximilian Reiß | 4 | * copyright : (c) 2002, 2003 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include "todayconfig.h" | 17 | #include "todayconfig.h" |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpeapplication.h> | ||
22 | 23 | ||
23 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qspinbox.h> | 26 | #include <qspinbox.h> |
26 | #include <qlayout.h> | 27 | #include <qlayout.h> |
27 | #include <qheader.h> | 28 | #include <qheader.h> |
28 | #include <qvbox.h> | 29 | #include <qvbox.h> |
29 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
30 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
31 | 32 | ||
32 | class ToolButton : public QToolButton { | 33 | class ToolButton : public QToolButton { |
33 | 34 | ||
34 | public: | 35 | public: |
35 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 36 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
36 | : QToolButton( parent, name ) { | 37 | : QToolButton( parent, name ) { |
37 | setPixmap( Resource::loadPixmap( icon ) ); | 38 | setPixmap( Resource::loadPixmap( icon ) ); |
38 | setAutoRaise( TRUE ); | 39 | setAutoRaise( TRUE ); |
39 | setFocusPolicy( QWidget::NoFocus ); | 40 | setFocusPolicy( QWidget::NoFocus ); |
40 | setToggleButton( t ); | 41 | setToggleButton( t ); |
41 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 42 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
42 | } | 43 | } |
43 | }; | 44 | }; |
44 | 45 | ||
45 | 46 | ||
46 | /** | 47 | /** |
47 | * The class has currently quite some duplicate code. | 48 | * The class has currently quite some duplicate code. |
48 | * By that way it would be real easy to have it as seperate app in settings tab | 49 | * By that way it would be real easy to have it as seperate app in settings tab |
49 | * | 50 | * |
50 | */ | 51 | */ |
51 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | 52 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) |
52 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { | 53 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { |
53 | 54 | ||
54 | setCaption( tr( "Today Config" ) ); | 55 | setCaption( tr( "Today Config" ) ); |
55 | 56 | ||
56 | QVBoxLayout *layout = new QVBoxLayout( this ); | 57 | QVBoxLayout *layout = new QVBoxLayout( this ); |
57 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 58 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
58 | layout->addWidget( TabWidget3 ); | 59 | layout->addWidget( TabWidget3 ); |
59 | 60 | ||
60 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 61 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
61 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | 62 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); |
62 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | 63 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); |
63 | tab2Layout->addWidget( l ); | 64 | tab2Layout->addWidget( l ); |
64 | QHBox *hbox1 = new QHBox( tab_2 ); | 65 | QHBox *hbox1 = new QHBox( tab_2 ); |
65 | m_appletListView = new QListView( hbox1 ); | 66 | m_appletListView = new QListView( hbox1 ); |
66 | m_appletListView->addColumn( "PluginList" ); | 67 | m_appletListView->addColumn( "PluginList" ); |
67 | m_appletListView->header()->hide(); | 68 | m_appletListView->header()->hide(); |
68 | m_appletListView->setSorting( -1 ); | 69 | m_appletListView->setSorting( -1 ); |
69 | QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | 70 | QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); |
70 | QVBox *vbox1 = new QVBox( hbox1 ); | 71 | QVBox *vbox1 = new QVBox( hbox1 ); |
71 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); | 72 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); |
72 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 73 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
73 | tab2Layout->addWidget( hbox1 ); | 74 | tab2Layout->addWidget( hbox1 ); |
74 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); | 75 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); |
75 | 76 | ||
76 | // Misc tab | 77 | // Misc tab |
77 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 78 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
78 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | 79 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); |
79 | 80 | ||
80 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); | 81 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); |
81 | 82 | ||
82 | tab3Layout->addWidget( m_guiMisc ); | 83 | tab3Layout->addWidget( m_guiMisc ); |
83 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); | 84 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); |
84 | 85 | ||
85 | m_applets_changed = false; | 86 | m_applets_changed = false; |
86 | 87 | ||
87 | connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); | 88 | connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); |
88 | 89 | ||
89 | readConfig(); | 90 | readConfig(); |
90 | showMaximized(); | 91 | QPEApplication::showDialog( this ); |
91 | } | 92 | } |
92 | 93 | ||
93 | 94 | ||
94 | /** | 95 | /** |
95 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 96 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
96 | * If registered against that today ist started on each resume. | 97 | * If registered against that today ist started on each resume. |
97 | */ | 98 | */ |
98 | void TodayConfig::setAutoStart() { | 99 | void TodayConfig::setAutoStart() { |
99 | Config cfg( "today" ); | 100 | Config cfg( "today" ); |
100 | cfg.setGroup( "Autostart" ); | 101 | cfg.setGroup( "Autostart" ); |
101 | if ( m_autoStart ) { | 102 | if ( m_autoStart ) { |
102 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | 103 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); |
103 | e << QString( "add" ); | 104 | e << QString( "add" ); |
104 | e << QString( "today" ); | 105 | e << QString( "today" ); |
105 | e << QString( "%1" ).arg( m_autoStartTimer ); | 106 | e << QString( "%1" ).arg( m_autoStartTimer ); |
106 | } else { | 107 | } else { |
107 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | 108 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); |
108 | e << QString( "remove" ); | 109 | e << QString( "remove" ); |
109 | e << QString( "today" ); | 110 | e << QString( "today" ); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | 113 | ||
113 | /** | 114 | /** |
114 | * Read the config part | 115 | * Read the config part |
115 | */ | 116 | */ |
116 | void TodayConfig::readConfig() { | 117 | void TodayConfig::readConfig() { |
117 | Config cfg( "today" ); | 118 | Config cfg( "today" ); |
118 | cfg.setGroup( "Autostart" ); | 119 | cfg.setGroup( "Autostart" ); |
119 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); | 120 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); |
120 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); | 121 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); |
121 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); | 122 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); |
122 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); | 123 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); |
123 | 124 | ||
124 | cfg.setGroup( "General" ); | 125 | cfg.setGroup( "General" ); |
125 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 126 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
126 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); | 127 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); |
127 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); | 128 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); |
128 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); | 129 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); |
129 | 130 | ||
130 | 131 | ||
131 | cfg.setGroup( "Plugins" ); | 132 | cfg.setGroup( "Plugins" ); |
132 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 133 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
133 | } | 134 | } |
134 | 135 | ||
135 | /** | 136 | /** |
136 | * Write the config part | 137 | * Write the config part |
137 | */ | 138 | */ |
138 | void TodayConfig::writeConfig() { | 139 | void TodayConfig::writeConfig() { |
139 | Config cfg( "today" ); | 140 | Config cfg( "today" ); |
140 | cfg.setGroup( "Plugins" ); | 141 | cfg.setGroup( "Plugins" ); |
141 | if ( m_applets_changed ) { | 142 | if ( m_applets_changed ) { |
142 | QStringList exclude; | 143 | QStringList exclude; |
143 | QStringList include; | 144 | QStringList include; |
144 | QStringList all_applets; | 145 | QStringList all_applets; |
145 | 146 | ||
146 | QListViewItemIterator list_it( m_appletListView ); | 147 | QListViewItemIterator list_it( m_appletListView ); |
147 | 148 | ||
148 | // this makes sure the names get saved in the order selected | 149 | // this makes sure the names get saved in the order selected |
149 | for ( ; list_it.current(); ++list_it ) { | 150 | for ( ; list_it.current(); ++list_it ) { |
150 | QMap <QString, QCheckListItem *>::Iterator it; | 151 | QMap <QString, QCheckListItem *>::Iterator it; |
151 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { | 152 | for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { |
152 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | 153 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { |
153 | exclude << it.key(); | 154 | exclude << it.key(); |
154 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | 155 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ |
155 | include << it.key(); | 156 | include << it.key(); |
156 | } | 157 | } |
157 | if ( list_it.current() == (*it) ) { | 158 | if ( list_it.current() == (*it) ) { |
158 | all_applets << it.key(); | 159 | all_applets << it.key(); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | } | 162 | } |
162 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 163 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
163 | cfg.writeEntry( "IncludeApplets", include, ',' ); | 164 | cfg.writeEntry( "IncludeApplets", include, ',' ); |
164 | cfg.writeEntry( "AllApplets", all_applets, ',' ); | 165 | cfg.writeEntry( "AllApplets", all_applets, ',' ); |
165 | } | 166 | } |
166 | 167 | ||
167 | cfg.setGroup( "Autostart" ); | 168 | cfg.setGroup( "Autostart" ); |
168 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); | 169 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); |
169 | cfg.writeEntry( "autostart", m_autoStart ); | 170 | cfg.writeEntry( "autostart", m_autoStart ); |
170 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); | 171 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); |
171 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); | 172 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); |
172 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); | 173 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); |
173 | 174 | ||
174 | cfg.setGroup( "General" ); | 175 | cfg.setGroup( "General" ); |
175 | cfg.writeEntry( "IconSize", m_iconSize ); | 176 | cfg.writeEntry( "IconSize", m_iconSize ); |
176 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); | 177 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); |
177 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); | 178 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); |
178 | 179 | ||
179 | // set autostart settings | 180 | // set autostart settings |
180 | setAutoStart(); | 181 | setAutoStart(); |
181 | } | 182 | } |
182 | 183 | ||
183 | 184 | ||
184 | void TodayConfig::moveSelectedUp() { | 185 | void TodayConfig::moveSelectedUp() { |
185 | QListViewItem *item = m_appletListView->selectedItem(); | 186 | QListViewItem *item = m_appletListView->selectedItem(); |
186 | if ( item && item->itemAbove() ) { | 187 | if ( item && item->itemAbove() ) { |
187 | item->itemAbove()->moveItem( item ); | 188 | item->itemAbove()->moveItem( item ); |
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
191 | 192 | ||
192 | void TodayConfig::moveSelectedDown() { | 193 | void TodayConfig::moveSelectedDown() { |
193 | QListViewItem *item = m_appletListView->selectedItem(); | 194 | QListViewItem *item = m_appletListView->selectedItem(); |
194 | if ( item && item->itemBelow() ) { | 195 | if ( item && item->itemBelow() ) { |
195 | item->moveItem( item->itemBelow() ); | 196 | item->moveItem( item->itemBelow() ); |
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
199 | 200 | ||
200 | /** | 201 | /** |
201 | * Set up the icons in the order/active tab | 202 | * Set up the icons in the order/active tab |
202 | */ | 203 | */ |
203 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | 204 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { |
204 | 205 | ||
205 | QCheckListItem *item; | 206 | QCheckListItem *item; |
206 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); | 207 | item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); |
207 | 208 | ||
208 | if ( !icon.isNull() ) { | 209 | if ( !icon.isNull() ) { |
209 | item->setPixmap( 0, icon ); | 210 | item->setPixmap( 0, icon ); |
210 | } | 211 | } |
211 | 212 | ||
212 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { | 213 | if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { |
213 | item->setOn( TRUE ); | 214 | item->setOn( TRUE ); |
214 | } | 215 | } |
215 | 216 | ||
216 | m_applets[libName] = item; | 217 | m_applets[libName] = item; |
217 | 218 | ||
218 | // kind of hack to get the first tab as default. | 219 | // kind of hack to get the first tab as default. |
219 | TabWidget3->setCurrentTab( tab_2 ); | 220 | TabWidget3->setCurrentTab( tab_2 ); |
220 | } | 221 | } |
221 | 222 | ||
222 | void TodayConfig::appletChanged() { | 223 | void TodayConfig::appletChanged() { |
223 | m_applets_changed = true; | 224 | m_applets_changed = true; |
224 | } | 225 | } |
225 | 226 | ||
226 | 227 | ||
227 | TodayConfig::~TodayConfig() { | 228 | TodayConfig::~TodayConfig() { |
228 | } | 229 | } |
229 | 230 | ||
diff --git a/core/settings/button/buttonsettings.cpp b/core/settings/button/buttonsettings.cpp index 523e295..141e0f6 100644 --- a/core/settings/button/buttonsettings.cpp +++ b/core/settings/button/buttonsettings.cpp | |||
@@ -1,255 +1,254 @@ | |||
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 <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | 31 | ||
32 | 32 | ||
33 | #include <opie/odevice.h> | 33 | #include <opie/odevice.h> |
34 | 34 | ||
35 | #include "buttonsettings.h" | 35 | #include "buttonsettings.h" |
36 | #include "buttonutils.h" | 36 | #include "buttonutils.h" |
37 | #include "remapdlg.h" | 37 | #include "remapdlg.h" |
38 | 38 | ||
39 | using namespace Opie; | 39 | using namespace Opie; |
40 | 40 | ||
41 | struct buttoninfo { | 41 | struct buttoninfo { |
42 | const ODeviceButton *m_button; | 42 | const ODeviceButton *m_button; |
43 | int m_index; | 43 | int m_index; |
44 | 44 | ||
45 | OQCopMessage m_pmsg; | 45 | OQCopMessage m_pmsg; |
46 | QLabel *m_picon; | 46 | QLabel *m_picon; |
47 | QLabel *m_plabel; | 47 | QLabel *m_plabel; |
48 | 48 | ||
49 | OQCopMessage m_hmsg; | 49 | OQCopMessage m_hmsg; |
50 | QLabel *m_hicon; | 50 | QLabel *m_hicon; |
51 | QLabel *m_hlabel; | 51 | QLabel *m_hlabel; |
52 | 52 | ||
53 | bool m_pdirty : 1; | 53 | bool m_pdirty : 1; |
54 | bool m_hdirty : 1; | 54 | bool m_hdirty : 1; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) | 58 | ButtonSettings::ButtonSettings ( QWidget *parent , const char *name, bool modal, WFlags f ) |
59 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) | 59 | : QDialog ( 0, "ButtonSettings", false, WStyle_ContextHelp ) |
60 | { | 60 | { |
61 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); | 61 | const QValueList <ODeviceButton> &buttons = ODevice::inst ( )-> buttons ( ); |
62 | (void) ButtonUtils::inst ( ); // initialise | 62 | (void) ButtonUtils::inst ( ); // initialise |
63 | 63 | ||
64 | setCaption ( tr( "Button Settings" )); | 64 | setCaption ( tr( "Button Settings" )); |
65 | 65 | ||
66 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); | 66 | QVBoxLayout *toplay = new QVBoxLayout ( this, 3, 3 ); |
67 | 67 | ||
68 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); | 68 | QLabel *l = new QLabel ( tr( "<center>Press or hold the button you want to remap.</center>" ), this ); |
69 | toplay-> addWidget ( l ); | 69 | toplay-> addWidget ( l ); |
70 | 70 | ||
71 | QGridLayout *lay = new QGridLayout ( toplay ); | 71 | QGridLayout *lay = new QGridLayout ( toplay ); |
72 | lay-> setMargin ( 0 ); | 72 | lay-> setMargin ( 0 ); |
73 | lay-> setColStretch ( 0, 0 ); | 73 | lay-> setColStretch ( 0, 0 ); |
74 | lay-> setColStretch ( 1, 0 ); | 74 | lay-> setColStretch ( 1, 0 ); |
75 | lay-> setColStretch ( 2, 0 ); | 75 | lay-> setColStretch ( 2, 0 ); |
76 | lay-> setColStretch ( 3, 10 ); | 76 | lay-> setColStretch ( 3, 10 ); |
77 | 77 | ||
78 | m_infos. setAutoDelete ( true ); | 78 | m_infos. setAutoDelete ( true ); |
79 | 79 | ||
80 | int i = 1; | 80 | int i = 1; |
81 | int index = 0; | 81 | int index = 0; |
82 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { | 82 | for ( QValueList<ODeviceButton>::ConstIterator it = buttons. begin ( ); it != buttons. end ( ); it++ ) { |
83 | if ( it != buttons. begin ( )) { | 83 | if ( it != buttons. begin ( )) { |
84 | QFrame *f = new QFrame ( this ); | 84 | QFrame *f = new QFrame ( this ); |
85 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); | 85 | f-> setFrameStyle ( QFrame::Sunken | QFrame::VLine ); |
86 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); | 86 | lay-> addMultiCellWidget ( f, i, i, 0, 3 ); |
87 | i++; | 87 | i++; |
88 | } | 88 | } |
89 | 89 | ||
90 | buttoninfo *bi = new buttoninfo ( ); | 90 | buttoninfo *bi = new buttoninfo ( ); |
91 | bi-> m_button = &(*it); | 91 | bi-> m_button = &(*it); |
92 | bi-> m_index = index++; | 92 | bi-> m_index = index++; |
93 | bi-> m_pmsg = (*it). pressedAction ( ); | 93 | bi-> m_pmsg = (*it). pressedAction ( ); |
94 | bi-> m_hmsg = (*it). heldAction ( ); | 94 | bi-> m_hmsg = (*it). heldAction ( ); |
95 | bi-> m_pdirty = false; | 95 | bi-> m_pdirty = false; |
96 | bi-> m_hdirty = false; | 96 | bi-> m_hdirty = false; |
97 | 97 | ||
98 | l = new QLabel ( this ); | 98 | l = new QLabel ( this ); |
99 | l-> setPixmap (( *it ). pixmap ( )); | 99 | l-> setPixmap (( *it ). pixmap ( )); |
100 | 100 | ||
101 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); | 101 | lay-> addMultiCellWidget ( l, i, i + 1, 0, 0 ); |
102 | 102 | ||
103 | l = new QLabel ( tr( "Press:" ), this ); | 103 | l = new QLabel ( tr( "Press:" ), this ); |
104 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); | 104 | lay-> addWidget ( l, i, 1, AlignLeft | AlignBottom ); |
105 | l = new QLabel ( tr( "Hold:" ), this ); | 105 | l = new QLabel ( tr( "Hold:" ), this ); |
106 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); | 106 | lay-> addWidget ( l, i + 1, 1, AlignLeft | AlignTop ); |
107 | 107 | ||
108 | l = new QLabel ( this ); | 108 | l = new QLabel ( this ); |
109 | l-> setFixedSize ( 16, 16 ); | 109 | l-> setFixedSize ( 16, 16 ); |
110 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); | 110 | lay-> addWidget ( l, i, 2, AlignLeft | AlignBottom ); |
111 | bi-> m_picon = l; | 111 | bi-> m_picon = l; |
112 | 112 | ||
113 | l = new QLabel ( this ); | 113 | l = new QLabel ( this ); |
114 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 114 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
115 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); | 115 | lay-> addWidget ( l, i, 3, AlignLeft | AlignBottom ); |
116 | bi-> m_plabel = l; | 116 | bi-> m_plabel = l; |
117 | 117 | ||
118 | l = new QLabel ( this ); | 118 | l = new QLabel ( this ); |
119 | l-> setFixedSize ( 16, 16 ); | 119 | l-> setFixedSize ( 16, 16 ); |
120 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); | 120 | lay-> addWidget ( l, i + 1, 2, AlignLeft | AlignTop ); |
121 | bi-> m_hicon = l; | 121 | bi-> m_hicon = l; |
122 | 122 | ||
123 | l = new QLabel ( this ); | 123 | l = new QLabel ( this ); |
124 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); | 124 | l-> setAlignment ( AlignLeft | AlignVCenter | SingleLine ); |
125 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); | 125 | lay-> addWidget ( l, i + 1, 3, AlignLeft | AlignTop ); |
126 | bi-> m_hlabel = l; | 126 | bi-> m_hlabel = l; |
127 | 127 | ||
128 | i += 2; | 128 | i += 2; |
129 | 129 | ||
130 | m_infos. append ( bi ); | 130 | m_infos. append ( bi ); |
131 | } | 131 | } |
132 | 132 | ||
133 | toplay-> addStretch ( 10 ); | 133 | toplay-> addStretch ( 10 ); |
134 | 134 | ||
135 | m_last_button = 0; | 135 | m_last_button = 0; |
136 | m_lock = false; | 136 | m_lock = false; |
137 | 137 | ||
138 | m_timer = new QTimer ( this ); | 138 | m_timer = new QTimer ( this ); |
139 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); | 139 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( keyTimeout ( ))); |
140 | 140 | ||
141 | updateLabels ( ); | 141 | updateLabels ( ); |
142 | 142 | ||
143 | QPEApplication::grabKeyboard ( ); | 143 | QPEApplication::grabKeyboard ( ); |
144 | } | 144 | } |
145 | 145 | ||
146 | ButtonSettings::~ButtonSettings ( ) | 146 | ButtonSettings::~ButtonSettings ( ) |
147 | { | 147 | { |
148 | QPEApplication::ungrabKeyboard ( ); | 148 | QPEApplication::ungrabKeyboard ( ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void ButtonSettings::updateLabels ( ) | 151 | void ButtonSettings::updateLabels ( ) |
152 | { | 152 | { |
153 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 153 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
154 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); | 154 | qCopInfo cip = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_pmsg ); |
155 | 155 | ||
156 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); | 156 | (*it)-> m_picon-> setPixmap ( cip. m_icon ); |
157 | (*it)-> m_plabel-> setText ( cip. m_name ); | 157 | (*it)-> m_plabel-> setText ( cip. m_name ); |
158 | 158 | ||
159 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); | 159 | qCopInfo cih = ButtonUtils::inst ( )-> messageToInfo ((*it)-> m_hmsg ); |
160 | 160 | ||
161 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); | 161 | (*it)-> m_hicon-> setPixmap ( cih. m_icon ); |
162 | (*it)-> m_hlabel-> setText ( cih. m_name ); | 162 | (*it)-> m_hlabel-> setText ( cih. m_name ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) | 166 | buttoninfo *ButtonSettings::buttonInfoForKeycode ( ushort key ) |
167 | { | 167 | { |
168 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 168 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
169 | if ((*it)-> m_button-> keycode ( ) == key ) | 169 | if ((*it)-> m_button-> keycode ( ) == key ) |
170 | return *it; | 170 | return *it; |
171 | } | 171 | } |
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | 174 | ||
175 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) | 175 | void ButtonSettings::keyPressEvent ( QKeyEvent *e ) |
176 | { | 176 | { |
177 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 177 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
178 | 178 | ||
179 | if ( bi && !e-> isAutoRepeat ( )) { | 179 | if ( bi && !e-> isAutoRepeat ( )) { |
180 | m_timer-> stop ( ); | 180 | m_timer-> stop ( ); |
181 | m_last_button = bi; | 181 | m_last_button = bi; |
182 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 182 | m_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
183 | } | 183 | } |
184 | else | 184 | else |
185 | QDialog::keyPressEvent ( e ); | 185 | QDialog::keyPressEvent ( e ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) | 188 | void ButtonSettings::keyReleaseEvent ( QKeyEvent *e ) |
189 | { | 189 | { |
190 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); | 190 | buttoninfo *bi = buttonInfoForKeycode ( e-> key ( )); |
191 | 191 | ||
192 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { | 192 | if ( bi && !e-> isAutoRepeat ( ) && m_timer-> isActive ( )) { |
193 | m_timer-> stop ( ); | 193 | m_timer-> stop ( ); |
194 | edit ( bi, false ); | 194 | edit ( bi, false ); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | QDialog::keyReleaseEvent ( e ); | 197 | QDialog::keyReleaseEvent ( e ); |
198 | } | 198 | } |
199 | 199 | ||
200 | void ButtonSettings::keyTimeout ( ) | 200 | void ButtonSettings::keyTimeout ( ) |
201 | { | 201 | { |
202 | if ( m_last_button ) { | 202 | if ( m_last_button ) { |
203 | edit ( m_last_button, true ); | 203 | edit ( m_last_button, true ); |
204 | m_last_button = false; | 204 | m_last_button = false; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) | 208 | void ButtonSettings::edit ( buttoninfo *bi, bool hold ) |
209 | { | 209 | { |
210 | 210 | ||
211 | if ( m_lock ) | 211 | if ( m_lock ) |
212 | return; | 212 | return; |
213 | m_lock = true; | 213 | m_lock = true; |
214 | 214 | ||
215 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); | 215 | RemapDlg *d = new RemapDlg ( bi-> m_button, hold, this ); |
216 | 216 | ||
217 | d-> showMaximized ( ); | 217 | if ( QPEApplication::execDialog ( d ) == QDialog::Accepted ) { |
218 | if ( d-> exec ( ) == QDialog::Accepted ) { | ||
219 | 218 | ||
220 | 219 | ||
221 | if ( hold ) { | 220 | if ( hold ) { |
222 | bi-> m_hmsg = d-> message ( ); | 221 | bi-> m_hmsg = d-> message ( ); |
223 | bi-> m_hdirty = true; | 222 | bi-> m_hdirty = true; |
224 | } | 223 | } |
225 | else { | 224 | else { |
226 | bi-> m_pmsg = d-> message ( ); | 225 | bi-> m_pmsg = d-> message ( ); |
227 | bi-> m_pdirty = true; | 226 | bi-> m_pdirty = true; |
228 | } | 227 | } |
229 | 228 | ||
230 | updateLabels ( ); | 229 | updateLabels ( ); |
231 | } | 230 | } |
232 | 231 | ||
233 | delete d; | 232 | delete d; |
234 | 233 | ||
235 | m_lock = false; | 234 | m_lock = false; |
236 | } | 235 | } |
237 | 236 | ||
238 | void ButtonSettings::accept ( ) | 237 | void ButtonSettings::accept ( ) |
239 | { | 238 | { |
240 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { | 239 | for ( QListIterator <buttoninfo> it ( m_infos ); *it; ++it ) { |
241 | buttoninfo *bi = *it; | 240 | buttoninfo *bi = *it; |
242 | 241 | ||
243 | if ( bi-> m_pdirty ) | 242 | if ( bi-> m_pdirty ) |
244 | ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); | 243 | ODevice::inst ( )-> remapPressedAction ( bi-> m_index, bi-> m_pmsg ); |
245 | if ( bi-> m_hdirty ) | 244 | if ( bi-> m_hdirty ) |
246 | ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); | 245 | ODevice::inst ( )-> remapHeldAction ( bi-> m_index, bi-> m_hmsg ); |
247 | } | 246 | } |
248 | QDialog::accept ( ); | 247 | QDialog::accept ( ); |
249 | } | 248 | } |
250 | 249 | ||
251 | void ButtonSettings::done ( int r ) | 250 | void ButtonSettings::done ( int r ) |
252 | { | 251 | { |
253 | QDialog::done ( r ); | 252 | QDialog::done ( r ); |
254 | close ( ); | 253 | close ( ); |
255 | } | 254 | } |
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp index a3d31a5..17a1609 100644 --- a/core/settings/launcher/tabssettings.cpp +++ b/core/settings/launcher/tabssettings.cpp | |||
@@ -1,317 +1,317 @@ | |||
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 "tabssettings.h" | 28 | #include "tabssettings.h" |
29 | 29 | ||
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/mimetype.h> | 32 | #include <qpe/mimetype.h> |
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | ||
35 | 36 | ||
36 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
37 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
39 | #include <qlabel.h> | 40 | #include <qlabel.h> |
40 | #include <qwhatsthis.h> | 41 | #include <qwhatsthis.h> |
41 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
42 | 43 | ||
43 | #include "tabdialog.h" | 44 | #include "tabdialog.h" |
44 | 45 | ||
45 | #include <stdlib.h> | 46 | #include <stdlib.h> |
46 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
47 | 48 | ||
48 | 49 | ||
49 | #define GLOBALID ".global." | 50 | #define GLOBALID ".global." |
50 | 51 | ||
51 | 52 | ||
52 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) | 53 | TabsSettings::TabsSettings ( QWidget *parent, const char *name ) |
53 | : QWidget ( parent, name ) | 54 | : QWidget ( parent, name ) |
54 | { | 55 | { |
55 | QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 ); | 56 | QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 ); |
56 | 57 | ||
57 | QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); | 58 | QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); |
58 | lay-> addMultiCellWidget ( l, 0, 0, 0, 1 ); | 59 | lay-> addMultiCellWidget ( l, 0, 0, 0, 1 ); |
59 | 60 | ||
60 | m_list = new QListBox ( this ); | 61 | m_list = new QListBox ( this ); |
61 | lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 ); | 62 | lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 ); |
62 | 63 | ||
63 | QWhatsThis::add ( m_list, tr( "foobar" )); | 64 | QWhatsThis::add ( m_list, tr( "foobar" )); |
64 | 65 | ||
65 | QPushButton *p1, *p2, *p3; | 66 | QPushButton *p1, *p2, *p3; |
66 | p1 = new QPushButton ( tr( "New" ), this ); | 67 | p1 = new QPushButton ( tr( "New" ), this ); |
67 | lay-> addWidget ( p1, 1, 1 ); | 68 | lay-> addWidget ( p1, 1, 1 ); |
68 | connect ( p1, SIGNAL( clicked ( )), this, SLOT( newClicked ( ))); | 69 | connect ( p1, SIGNAL( clicked ( )), this, SLOT( newClicked ( ))); |
69 | 70 | ||
70 | p2 = new QPushButton ( tr( "Edit" ), this ); | 71 | p2 = new QPushButton ( tr( "Edit" ), this ); |
71 | lay-> addWidget ( p2, 2, 1 ); | 72 | lay-> addWidget ( p2, 2, 1 ); |
72 | connect ( p2, SIGNAL( clicked ( )), this, SLOT( editClicked ( ))); | 73 | connect ( p2, SIGNAL( clicked ( )), this, SLOT( editClicked ( ))); |
73 | 74 | ||
74 | p3 = new QPushButton ( tr( "Delete" ), this ); | 75 | p3 = new QPushButton ( tr( "Delete" ), this ); |
75 | lay-> addWidget ( p3, 3, 1 ); | 76 | lay-> addWidget ( p3, 3, 1 ); |
76 | connect ( p3, SIGNAL( clicked ( )), this, SLOT( deleteClicked ( ))); | 77 | connect ( p3, SIGNAL( clicked ( )), this, SLOT( deleteClicked ( ))); |
77 | 78 | ||
78 | lay-> setRowStretch ( 4, 10 ); | 79 | lay-> setRowStretch ( 4, 10 ); |
79 | 80 | ||
80 | m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this ); | 81 | m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this ); |
81 | lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 ); | 82 | lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 ); |
82 | 83 | ||
83 | m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this ); | 84 | m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this ); |
84 | lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 ); | 85 | lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 ); |
85 | 86 | ||
86 | p1-> setEnabled ( false ); | 87 | p1-> setEnabled ( false ); |
87 | p3-> setEnabled ( false ); | 88 | p3-> setEnabled ( false ); |
88 | 89 | ||
89 | init ( ); | 90 | init ( ); |
90 | 91 | ||
91 | QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." )); | 92 | QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." )); |
92 | QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); | 93 | QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); |
93 | QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." )); | 94 | QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." )); |
94 | QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); | 95 | QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); |
95 | QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." )); | 96 | QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." )); |
96 | QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." )); | 97 | QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." )); |
97 | } | 98 | } |
98 | 99 | ||
99 | void TabsSettings::init ( ) | 100 | void TabsSettings::init ( ) |
100 | { | 101 | { |
101 | AppLnkSet rootFolder( MimeType::appsFolderName ( )); | 102 | AppLnkSet rootFolder( MimeType::appsFolderName ( )); |
102 | QStringList types = rootFolder. types ( ); | 103 | QStringList types = rootFolder. types ( ); |
103 | 104 | ||
104 | m_list-> insertItem ( tr( "All Tabs" )); | 105 | m_list-> insertItem ( tr( "All Tabs" )); |
105 | m_ids << GLOBALID; | 106 | m_ids << GLOBALID; |
106 | 107 | ||
107 | for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { | 108 | for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { |
108 | m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it )); | 109 | m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it )); |
109 | m_ids << *it; | 110 | m_ids << *it; |
110 | } | 111 | } |
111 | QImage img ( Resource::loadImage ( "DocsIcon" )); | 112 | QImage img ( Resource::loadImage ( "DocsIcon" )); |
112 | QPixmap pix; | 113 | QPixmap pix; |
113 | pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); | 114 | pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); |
114 | m_list-> insertItem ( pix, tr( "Documents" )); | 115 | m_list-> insertItem ( pix, tr( "Documents" )); |
115 | m_ids += "Documents"; // No tr | 116 | m_ids += "Documents"; // No tr |
116 | 117 | ||
117 | Config cfg ( "Launcher" ); | 118 | Config cfg ( "Launcher" ); |
118 | 119 | ||
119 | readTabSettings ( cfg ); | 120 | readTabSettings ( cfg ); |
120 | 121 | ||
121 | cfg. setGroup ( "GUI" ); | 122 | cfg. setGroup ( "GUI" ); |
122 | m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" ); | 123 | m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" ); |
123 | m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) ); | 124 | m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) ); |
124 | } | 125 | } |
125 | 126 | ||
126 | 127 | ||
127 | void TabsSettings::readTabSettings ( Config &cfg ) | 128 | void TabsSettings::readTabSettings ( Config &cfg ) |
128 | { | 129 | { |
129 | QString grp ( "Tab %1" ); // No tr | 130 | QString grp ( "Tab %1" ); // No tr |
130 | m_tabs. clear ( ); | 131 | m_tabs. clear ( ); |
131 | 132 | ||
132 | TabConfig global_def; | 133 | TabConfig global_def; |
133 | global_def. m_view = TabConfig::Icon; | 134 | global_def. m_view = TabConfig::Icon; |
134 | global_def. m_bg_type = TabConfig::Ruled; | 135 | global_def. m_bg_type = TabConfig::Ruled; |
135 | global_def. m_bg_image = "launcher/opie-background"; | 136 | global_def. m_bg_image = "launcher/opie-background"; |
136 | global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); | 137 | global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); |
137 | global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); | 138 | global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); |
138 | global_def. m_font_use = false; | 139 | global_def. m_font_use = false; |
139 | global_def. m_font_family = font ( ). family ( ); | 140 | global_def. m_font_family = font ( ). family ( ); |
140 | global_def. m_font_size = font ( ). pointSize ( ); | 141 | global_def. m_font_size = font ( ). pointSize ( ); |
141 | global_def. m_font_weight = 50; | 142 | global_def. m_font_weight = 50; |
142 | global_def. m_font_italic = false; | 143 | global_def. m_font_italic = false; |
143 | global_def. m_changed = false; | 144 | global_def. m_changed = false; |
144 | 145 | ||
145 | 146 | ||
146 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 147 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
147 | TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; | 148 | TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; |
148 | 149 | ||
149 | cfg. setGroup ( grp. arg ( *it )); | 150 | cfg. setGroup ( grp. arg ( *it )); |
150 | 151 | ||
151 | QString view = cfg. readEntry ( "View" ); | 152 | QString view = cfg. readEntry ( "View" ); |
152 | if ( view == "Icon" ) // No tr | 153 | if ( view == "Icon" ) // No tr |
153 | tc. m_view = TabConfig::Icon; | 154 | tc. m_view = TabConfig::Icon; |
154 | if ( view == "List" ) // No tr | 155 | if ( view == "List" ) // No tr |
155 | tc. m_view = TabConfig::List; | 156 | tc. m_view = TabConfig::List; |
156 | 157 | ||
157 | QString bgType = cfg. readEntry ( "BackgroundType" ); | 158 | QString bgType = cfg. readEntry ( "BackgroundType" ); |
158 | if ( bgType == "Image" ) | 159 | if ( bgType == "Image" ) |
159 | tc. m_bg_type = TabConfig::Image; | 160 | tc. m_bg_type = TabConfig::Image; |
160 | else if ( bgType == "SolidColor" ) | 161 | else if ( bgType == "SolidColor" ) |
161 | tc. m_bg_type = TabConfig::SolidColor; | 162 | tc. m_bg_type = TabConfig::SolidColor; |
162 | else if ( bgType == "Image" ) // No tr | 163 | else if ( bgType == "Image" ) // No tr |
163 | tc. m_bg_type = TabConfig::Image; | 164 | tc. m_bg_type = TabConfig::Image; |
164 | 165 | ||
165 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); | 166 | tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); |
166 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); | 167 | tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); |
167 | tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); | 168 | tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); |
168 | QStringList f = cfg. readListEntry ( "Font", ',' ); | 169 | QStringList f = cfg. readListEntry ( "Font", ',' ); |
169 | if ( f. count ( ) == 4 ) { | 170 | if ( f. count ( ) == 4 ) { |
170 | tc. m_font_use = true; | 171 | tc. m_font_use = true; |
171 | tc. m_font_family = f [0]; | 172 | tc. m_font_family = f [0]; |
172 | tc. m_font_size = f [1]. toInt ( ); | 173 | tc. m_font_size = f [1]. toInt ( ); |
173 | tc. m_font_weight = f [2]. toInt ( ); | 174 | tc. m_font_weight = f [2]. toInt ( ); |
174 | tc. m_font_italic = ( f [3]. toInt ( )); | 175 | tc. m_font_italic = ( f [3]. toInt ( )); |
175 | } | 176 | } |
176 | m_tabs [*it] = tc; | 177 | m_tabs [*it] = tc; |
177 | } | 178 | } |
178 | 179 | ||
179 | // if all tabs have the same config, then initialize the GLOBALID tab to these values | 180 | // if all tabs have the same config, then initialize the GLOBALID tab to these values |
180 | 181 | ||
181 | TabConfig *first = 0; | 182 | TabConfig *first = 0; |
182 | bool same = true; | 183 | bool same = true; |
183 | 184 | ||
184 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 185 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
185 | if ( *it == GLOBALID ) | 186 | if ( *it == GLOBALID ) |
186 | continue; | 187 | continue; |
187 | else if ( !first ) | 188 | else if ( !first ) |
188 | first = &m_tabs [*it]; | 189 | first = &m_tabs [*it]; |
189 | else | 190 | else |
190 | same &= ( *first == m_tabs [*it] ); | 191 | same &= ( *first == m_tabs [*it] ); |
191 | } | 192 | } |
192 | if ( same ) { | 193 | if ( same ) { |
193 | m_tabs [GLOBALID] = *first; | 194 | m_tabs [GLOBALID] = *first; |
194 | m_tabs [GLOBALID]. m_changed = true; | 195 | m_tabs [GLOBALID]. m_changed = true; |
195 | } | 196 | } |
196 | } | 197 | } |
197 | 198 | ||
198 | 199 | ||
199 | void TabsSettings::accept ( ) | 200 | void TabsSettings::accept ( ) |
200 | { | 201 | { |
201 | Config cfg ( "Launcher" ); | 202 | Config cfg ( "Launcher" ); |
202 | 203 | ||
203 | // Launcher Tab | 204 | // Launcher Tab |
204 | QString grp ( "Tab %1" ); // No tr | 205 | QString grp ( "Tab %1" ); // No tr |
205 | 206 | ||
206 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 207 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
207 | TabConfig &tc = m_tabs [*it]; | 208 | TabConfig &tc = m_tabs [*it]; |
208 | 209 | ||
209 | if ( !tc. m_changed ) | 210 | if ( !tc. m_changed ) |
210 | continue; | 211 | continue; |
211 | 212 | ||
212 | cfg. setGroup ( grp. arg ( *it )); | 213 | cfg. setGroup ( grp. arg ( *it )); |
213 | switch ( tc. m_view ) { | 214 | switch ( tc. m_view ) { |
214 | case TabConfig::Icon: | 215 | case TabConfig::Icon: |
215 | cfg.writeEntry ( "View", "Icon" ); | 216 | cfg.writeEntry ( "View", "Icon" ); |
216 | break; | 217 | break; |
217 | case TabConfig::List: | 218 | case TabConfig::List: |
218 | cfg.writeEntry ( "View", "List" ); | 219 | cfg.writeEntry ( "View", "List" ); |
219 | break; | 220 | break; |
220 | } | 221 | } |
221 | 222 | ||
222 | QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); | 223 | QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); |
223 | e << *it << tc. m_view; | 224 | e << *it << tc. m_view; |
224 | 225 | ||
225 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); | 226 | cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); |
226 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); | 227 | cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); |
227 | cfg. writeEntry ( "TextColor", tc. m_text_color ); | 228 | cfg. writeEntry ( "TextColor", tc. m_text_color ); |
228 | 229 | ||
229 | if ( tc. m_font_use ) { | 230 | if ( tc. m_font_use ) { |
230 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); | 231 | QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); |
231 | cfg. writeEntry ( "Font", f ); | 232 | cfg. writeEntry ( "Font", f ); |
232 | } | 233 | } |
233 | else | 234 | else |
234 | cfg. removeEntry ( "Font" ); | 235 | cfg. removeEntry ( "Font" ); |
235 | 236 | ||
236 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); | 237 | QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); |
237 | 238 | ||
238 | switch ( tc. m_bg_type ) { | 239 | switch ( tc. m_bg_type ) { |
239 | case TabConfig::Ruled: | 240 | case TabConfig::Ruled: |
240 | cfg.writeEntry( "BackgroundType", "Ruled" ); | 241 | cfg.writeEntry( "BackgroundType", "Ruled" ); |
241 | be << *it << tc. m_bg_type << QString(""); | 242 | be << *it << tc. m_bg_type << QString(""); |
242 | break; | 243 | break; |
243 | case TabConfig::SolidColor: | 244 | case TabConfig::SolidColor: |
244 | cfg.writeEntry( "BackgroundType", "SolidColor" ); | 245 | cfg.writeEntry( "BackgroundType", "SolidColor" ); |
245 | be << *it << tc. m_bg_type << tc. m_bg_color; | 246 | be << *it << tc. m_bg_type << tc. m_bg_color; |
246 | break; | 247 | break; |
247 | case TabConfig::Image: | 248 | case TabConfig::Image: |
248 | cfg.writeEntry( "BackgroundType", "Image" ); | 249 | cfg.writeEntry( "BackgroundType", "Image" ); |
249 | be << *it << tc. m_bg_type << tc. m_bg_image; | 250 | be << *it << tc. m_bg_type << tc. m_bg_image; |
250 | break; | 251 | break; |
251 | } | 252 | } |
252 | 253 | ||
253 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); | 254 | QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); |
254 | te << *it << tc. m_text_color; | 255 | te << *it << tc. m_text_color; |
255 | 256 | ||
256 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); | 257 | QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); |
257 | fe << *it; | 258 | fe << *it; |
258 | fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); | 259 | fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); |
259 | fe << tc. m_font_size; | 260 | fe << tc. m_font_size; |
260 | fe << tc. m_font_weight; | 261 | fe << tc. m_font_weight; |
261 | fe << ( tc. m_font_italic ? 1 : 0 ); | 262 | fe << ( tc. m_font_italic ? 1 : 0 ); |
262 | 263 | ||
263 | tc. m_changed = false; | 264 | tc. m_changed = false; |
264 | } | 265 | } |
265 | cfg. setGroup ( "GUI" ); | 266 | cfg. setGroup ( "GUI" ); |
266 | QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" ); | 267 | QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" ); |
267 | cfg. writeEntry ( "BusyType", busytype ); | 268 | cfg. writeEntry ( "BusyType", busytype ); |
268 | 269 | ||
269 | cfg. writeEntry ( "BigBusy", m_bigbusy->isChecked( ) ); | 270 | cfg. writeEntry ( "BigBusy", m_bigbusy->isChecked( ) ); |
270 | 271 | ||
271 | { | 272 | { |
272 | QCopEnvelope e ( "QPE/Launcher", "setBusyIndicatorType(QString)" ); | 273 | QCopEnvelope e ( "QPE/Launcher", "setBusyIndicatorType(QString)" ); |
273 | e << busytype; | 274 | e << busytype; |
274 | } | 275 | } |
275 | } | 276 | } |
276 | 277 | ||
277 | void TabsSettings::newClicked ( ) | 278 | void TabsSettings::newClicked ( ) |
278 | { | 279 | { |
279 | QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); | 280 | QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); |
280 | } | 281 | } |
281 | 282 | ||
282 | void TabsSettings::deleteClicked ( ) | 283 | void TabsSettings::deleteClicked ( ) |
283 | { | 284 | { |
284 | int ind = m_list-> currentItem ( ); | 285 | int ind = m_list-> currentItem ( ); |
285 | 286 | ||
286 | if ( ind < 0 ) | 287 | if ( ind < 0 ) |
287 | return; | 288 | return; |
288 | 289 | ||
289 | QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); | 290 | QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); |
290 | } | 291 | } |
291 | 292 | ||
292 | void TabsSettings::editClicked ( ) | 293 | void TabsSettings::editClicked ( ) |
293 | { | 294 | { |
294 | int ind = m_list-> currentItem ( ); | 295 | int ind = m_list-> currentItem ( ); |
295 | 296 | ||
296 | if ( ind < 0 ) | 297 | if ( ind < 0 ) |
297 | return; | 298 | return; |
298 | 299 | ||
299 | TabConfig tc = m_tabs [m_ids [ind]]; | 300 | TabConfig tc = m_tabs [m_ids [ind]]; |
300 | 301 | ||
301 | TabDialog *d = new TabDialog ( m_list-> pixmap ( ind ), m_list-> text ( ind ), tc, this, "TabDialog", true ); | 302 | TabDialog *d = new TabDialog ( m_list-> pixmap ( ind ), m_list-> text ( ind ), tc, this, "TabDialog", true ); |
302 | 303 | ||
303 | d-> showMaximized ( ); | 304 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) { |
304 | if ( d-> exec ( ) == QDialog::Accepted ) { | ||
305 | tc. m_changed = true; | 305 | tc. m_changed = true; |
306 | m_tabs [m_ids [ind]] = tc; | 306 | m_tabs [m_ids [ind]] = tc; |
307 | 307 | ||
308 | if ( m_ids [ind] == GLOBALID ) { | 308 | if ( m_ids [ind] == GLOBALID ) { |
309 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { | 309 | for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { |
310 | if ( *it != GLOBALID ) | 310 | if ( *it != GLOBALID ) |
311 | m_tabs [*it] = tc; | 311 | m_tabs [*it] = tc; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | delete d; | 316 | delete d; |
317 | } | 317 | } |
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index b21215b..60f7417 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -1,315 +1,314 @@ | |||
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 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/power.h> | 32 | #include <qpe/power.h> |
33 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 33 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
34 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
35 | #endif | 35 | #endif |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | 37 | ||
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qgroupbox.h> | 44 | #include <qgroupbox.h> |
45 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
46 | 46 | ||
47 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
48 | 48 | ||
49 | #include "sensor.h" | 49 | #include "sensor.h" |
50 | 50 | ||
51 | using namespace Opie; | 51 | using namespace Opie; |
52 | 52 | ||
53 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | 53 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) |
54 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) | 54 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) |
55 | { | 55 | { |
56 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); | 56 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); |
57 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); | 57 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); |
58 | 58 | ||
59 | // check whether to show the light sensor stuff | 59 | // check whether to show the light sensor stuff |
60 | 60 | ||
61 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { | 61 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { |
62 | auto_brightness-> hide ( ); | 62 | auto_brightness-> hide ( ); |
63 | CalibrateLightSensor-> hide ( ); | 63 | CalibrateLightSensor-> hide ( ); |
64 | auto_brightness_ac-> hide ( ); | 64 | auto_brightness_ac-> hide ( ); |
65 | CalibrateLightSensor_ac-> hide ( ); | 65 | CalibrateLightSensor_ac-> hide ( ); |
66 | } | 66 | } |
67 | 67 | ||
68 | // check whether to show the contrast stuff | 68 | // check whether to show the contrast stuff |
69 | 69 | ||
70 | if (m_cres) { | 70 | if (m_cres) { |
71 | GroupLight->setTitle(tr("Backlight && Contrast")); | 71 | GroupLight->setTitle(tr("Backlight && Contrast")); |
72 | GroupLight_ac->setTitle(GroupLight->title()); | 72 | GroupLight_ac->setTitle(GroupLight->title()); |
73 | } else { | 73 | } else { |
74 | contrast->hide(); | 74 | contrast->hide(); |
75 | contrast_ac->hide(); | 75 | contrast_ac->hide(); |
76 | } | 76 | } |
77 | 77 | ||
78 | // check whether to show the cpu frequency stuff | 78 | // check whether to show the cpu frequency stuff |
79 | 79 | ||
80 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); | 80 | QStrList freq = ODevice::inst()->allowedCpuFrequencies(); |
81 | if ( freq.count() ) { | 81 | if ( freq.count() ) { |
82 | frequency->insertStrList( freq ); | 82 | frequency->insertStrList( freq ); |
83 | frequency_ac->insertStrList( freq ); | 83 | frequency_ac->insertStrList( freq ); |
84 | } else { | 84 | } else { |
85 | frequencyLabel->hide(); | 85 | frequencyLabel->hide(); |
86 | frequency->hide(); | 86 | frequency->hide(); |
87 | frequencyLabel_ac->hide(); | 87 | frequencyLabel_ac->hide(); |
88 | frequency_ac->hide(); | 88 | frequency_ac->hide(); |
89 | } | 89 | } |
90 | 90 | ||
91 | // check whether to show the hinge action stuff | 91 | // check whether to show the hinge action stuff |
92 | 92 | ||
93 | if ( !ODevice::inst()->hasHingeSensor() ) { | 93 | if ( !ODevice::inst()->hasHingeSensor() ) { |
94 | closeHingeLabel->hide(); | 94 | closeHingeLabel->hide(); |
95 | closeHingeAction->hide(); | 95 | closeHingeAction->hide(); |
96 | closeHingeLabel_ac->hide(); | 96 | closeHingeLabel_ac->hide(); |
97 | closeHingeAction_ac->hide(); | 97 | closeHingeAction_ac->hide(); |
98 | } | 98 | } |
99 | 99 | ||
100 | Config config ( "apm" ); | 100 | Config config ( "apm" ); |
101 | config. setGroup ( "Battery" ); | 101 | config. setGroup ( "Battery" ); |
102 | 102 | ||
103 | // battery spinboxes | 103 | // battery spinboxes |
104 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); | 104 | interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); |
105 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); | 105 | interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); |
106 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); | 106 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); |
107 | 107 | ||
108 | // battery check and slider | 108 | // battery check and slider |
109 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 109 | LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
110 | 110 | ||
111 | // CPU frequency | 111 | // CPU frequency |
112 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); | 112 | frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); |
113 | 113 | ||
114 | // hinge action | 114 | // hinge action |
115 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 115 | closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
116 | 116 | ||
117 | int bright = config. readNumEntry ( "Brightness", 127 ); | 117 | int bright = config. readNumEntry ( "Brightness", 127 ); |
118 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); | 118 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); |
119 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 119 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
120 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); | 120 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); |
121 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); | 121 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); |
122 | brightness-> setValue ( bright ); | 122 | brightness-> setValue ( bright ); |
123 | 123 | ||
124 | if (m_cres) { | 124 | if (m_cres) { |
125 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 125 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
126 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); | 126 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); |
127 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); | 127 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); |
128 | contrast-> setValue ( contr ); | 128 | contrast-> setValue ( contr ); |
129 | } | 129 | } |
130 | 130 | ||
131 | // light sensor | 131 | // light sensor |
132 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 132 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
133 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); | 133 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); |
134 | 134 | ||
135 | config. setGroup ( "AC" ); | 135 | config. setGroup ( "AC" ); |
136 | 136 | ||
137 | // ac spinboxes | 137 | // ac spinboxes |
138 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); | 138 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); |
139 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); | 139 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); |
140 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); | 140 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); |
141 | 141 | ||
142 | // ac check and slider | 142 | // ac check and slider |
143 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 143 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
144 | 144 | ||
145 | // CPU frequency | 145 | // CPU frequency |
146 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); | 146 | frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); |
147 | 147 | ||
148 | // hinge action | 148 | // hinge action |
149 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); | 149 | closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); |
150 | 150 | ||
151 | bright = config. readNumEntry ( "Brightness", 255 ); | 151 | bright = config. readNumEntry ( "Brightness", 255 ); |
152 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); | 152 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
153 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); | 153 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); |
154 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); | 154 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); |
155 | brightness_ac-> setValue ( bright ); | 155 | brightness_ac-> setValue ( bright ); |
156 | 156 | ||
157 | if (m_cres) { | 157 | if (m_cres) { |
158 | contr = config. readNumEntry ( "Contrast", 127); | 158 | contr = config. readNumEntry ( "Contrast", 127); |
159 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); | 159 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
160 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); | 160 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); |
161 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); | 161 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); |
162 | contrast_ac-> setValue ( contr ); | 162 | contrast_ac-> setValue ( contr ); |
163 | } | 163 | } |
164 | 164 | ||
165 | // light sensor | 165 | // light sensor |
166 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 166 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
167 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); | 167 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); |
168 | 168 | ||
169 | // warnings | 169 | // warnings |
170 | config. setGroup ( "Warnings" ); | 170 | config. setGroup ( "Warnings" ); |
171 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); | 171 | warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); |
172 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); | 172 | lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); |
173 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); | 173 | criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); |
174 | 174 | ||
175 | m_resettimer = new QTimer ( this ); | 175 | m_resettimer = new QTimer ( this ); |
176 | connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); | 176 | connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); |
177 | 177 | ||
178 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { | 178 | if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { |
179 | tabs-> setCurrentPage ( 0 ); | 179 | tabs-> setCurrentPage ( 0 ); |
180 | } | 180 | } |
181 | else { | 181 | else { |
182 | tabs-> setCurrentPage ( 1 ); | 182 | tabs-> setCurrentPage ( 1 ); |
183 | } | 183 | } |
184 | 184 | ||
185 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 185 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
186 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 186 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
187 | if (m_cres) { | 187 | if (m_cres) { |
188 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 188 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
189 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 189 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
190 | } | 190 | } |
191 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 191 | connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
192 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); | 192 | connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); |
193 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 193 | connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
194 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); | 194 | connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); |
195 | } | 195 | } |
196 | 196 | ||
197 | LightSettings::~LightSettings ( ) | 197 | LightSettings::~LightSettings ( ) |
198 | { | 198 | { |
199 | } | 199 | } |
200 | 200 | ||
201 | void LightSettings::calibrateSensor ( ) | 201 | void LightSettings::calibrateSensor ( ) |
202 | { | 202 | { |
203 | Sensor *s = new Sensor ( m_sensordata, this ); | 203 | Sensor *s = new Sensor ( m_sensordata, this ); |
204 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 204 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); |
205 | QPEApplication::execDialog( s ); | 205 | QPEApplication::execDialog( s ); |
206 | delete s; | 206 | delete s; |
207 | } | 207 | } |
208 | 208 | ||
209 | void LightSettings::calibrateSensorAC ( ) | 209 | void LightSettings::calibrateSensorAC ( ) |
210 | { | 210 | { |
211 | Sensor *s = new Sensor ( m_sensordata_ac, this ); | 211 | Sensor *s = new Sensor ( m_sensordata_ac, this ); |
212 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); | 212 | connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); |
213 | s-> showMaximized ( ); | 213 | QPEApplication::execDialog ( s ); |
214 | s-> exec ( ); | ||
215 | delete s; | 214 | delete s; |
216 | } | 215 | } |
217 | 216 | ||
218 | void LightSettings::setBacklight ( int bright ) | 217 | void LightSettings::setBacklight ( int bright ) |
219 | { | 218 | { |
220 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); | 219 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); |
221 | e << bright; | 220 | e << bright; |
222 | 221 | ||
223 | if ( bright != -1 ) { | 222 | if ( bright != -1 ) { |
224 | m_resettimer-> stop ( ); | 223 | m_resettimer-> stop ( ); |
225 | m_resettimer-> start ( 4000, true ); | 224 | m_resettimer-> start ( 4000, true ); |
226 | } | 225 | } |
227 | } | 226 | } |
228 | 227 | ||
229 | void LightSettings::setContrast ( int contr ) | 228 | void LightSettings::setContrast ( int contr ) |
230 | { | 229 | { |
231 | if (contr == -1) contr = m_oldcontrast; | 230 | if (contr == -1) contr = m_oldcontrast; |
232 | ODevice::inst ( )-> setDisplayContrast(contr); | 231 | ODevice::inst ( )-> setDisplayContrast(contr); |
233 | } | 232 | } |
234 | 233 | ||
235 | void LightSettings::setFrequency ( int index ) | 234 | void LightSettings::setFrequency ( int index ) |
236 | { | 235 | { |
237 | qWarning("LightSettings::setFrequency(%d)", index); | 236 | qWarning("LightSettings::setFrequency(%d)", index); |
238 | ODevice::inst ( )-> setCurrentCpuFrequency(index); | 237 | ODevice::inst ( )-> setCurrentCpuFrequency(index); |
239 | } | 238 | } |
240 | 239 | ||
241 | void LightSettings::resetBacklight ( ) | 240 | void LightSettings::resetBacklight ( ) |
242 | { | 241 | { |
243 | setBacklight ( -1 ); | 242 | setBacklight ( -1 ); |
244 | setContrast ( -1 ); | 243 | setContrast ( -1 ); |
245 | } | 244 | } |
246 | 245 | ||
247 | void LightSettings::setCloseHingeAction ( int index ) | 246 | void LightSettings::setCloseHingeAction ( int index ) |
248 | { | 247 | { |
249 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); | 248 | qWarning("LightSettings::setCloseHingeStatus(%d)", index); |
250 | } | 249 | } |
251 | 250 | ||
252 | void LightSettings::accept ( ) | 251 | void LightSettings::accept ( ) |
253 | { | 252 | { |
254 | Config config ( "apm" ); | 253 | Config config ( "apm" ); |
255 | 254 | ||
256 | // bat | 255 | // bat |
257 | config. setGroup ( "Battery" ); | 256 | config. setGroup ( "Battery" ); |
258 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); | 257 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); |
259 | config. writeEntry ( "Dim", interval_dim-> value ( )); | 258 | config. writeEntry ( "Dim", interval_dim-> value ( )); |
260 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); | 259 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); |
261 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); | 260 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); |
262 | config. writeEntry ( "Brightness", brightness-> value () ); | 261 | config. writeEntry ( "Brightness", brightness-> value () ); |
263 | if (m_cres) | 262 | if (m_cres) |
264 | config. writeEntry ( "Contrast", contrast-> value () ); | 263 | config. writeEntry ( "Contrast", contrast-> value () ); |
265 | config. writeEntry ( "Freq", frequency->currentItem() ); | 264 | config. writeEntry ( "Freq", frequency->currentItem() ); |
266 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); | 265 | config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); |
267 | 266 | ||
268 | // ac | 267 | // ac |
269 | config. setGroup ( "AC" ); | 268 | config. setGroup ( "AC" ); |
270 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); | 269 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); |
271 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); | 270 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); |
272 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); | 271 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); |
273 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); | 272 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); |
274 | config. writeEntry ( "Brightness", brightness_ac-> value () ); | 273 | config. writeEntry ( "Brightness", brightness_ac-> value () ); |
275 | if (m_cres) | 274 | if (m_cres) |
276 | config. writeEntry ( "Contrast", contrast_ac-> value () ); | 275 | config. writeEntry ( "Contrast", contrast_ac-> value () ); |
277 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); | 276 | config. writeEntry ( "Freq", frequency_ac->currentItem() ); |
278 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); | 277 | config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); |
279 | 278 | ||
280 | // only make light sensor stuff appear if the unit has a sensor | 279 | // only make light sensor stuff appear if the unit has a sensor |
281 | if ( ODevice::inst ( )-> hasLightSensor ( )) { | 280 | if ( ODevice::inst ( )-> hasLightSensor ( )) { |
282 | config. setGroup ( "Battery" ); | 281 | config. setGroup ( "Battery" ); |
283 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); | 282 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); |
284 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); | 283 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); |
285 | config. setGroup ( "AC" ); | 284 | config. setGroup ( "AC" ); |
286 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); | 285 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); |
287 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); | 286 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); |
288 | } | 287 | } |
289 | 288 | ||
290 | // advanced | 289 | // advanced |
291 | config. setGroup ( "Warnings" ); | 290 | config. setGroup ( "Warnings" ); |
292 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); | 291 | config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); |
293 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); | 292 | config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); |
294 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); | 293 | config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); |
295 | config. write ( ); | 294 | config. write ( ); |
296 | 295 | ||
297 | // notify the launcher | 296 | // notify the launcher |
298 | { | 297 | { |
299 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); | 298 | QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); |
300 | } | 299 | } |
301 | { | 300 | { |
302 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); | 301 | QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); |
303 | e << -1; | 302 | e << -1; |
304 | } | 303 | } |
305 | LightSettingsBase::accept ( ); | 304 | LightSettingsBase::accept ( ); |
306 | } | 305 | } |
307 | 306 | ||
308 | void LightSettings::done ( int r ) | 307 | void LightSettings::done ( int r ) |
309 | { | 308 | { |
310 | m_resettimer-> stop ( ); | 309 | m_resettimer-> stop ( ); |
311 | resetBacklight ( ); | 310 | resetBacklight ( ); |
312 | 311 | ||
313 | LightSettingsBase::done ( r ); | 312 | LightSettingsBase::done ( r ); |
314 | close ( ); | 313 | close ( ); |
315 | } | 314 | } |
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index 7bb14cd..34f7e50 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -1,438 +1,438 @@ | |||
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 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/password.h> | 24 | #include <qpe/password.h> |
25 | #include <qpe/qpedialog.h> | 25 | #include <qpe/qpedialog.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | 27 | ||
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | 34 | ||
35 | Security::Security( QWidget* parent, const char* name, WFlags fl ) | 35 | Security::Security( QWidget* parent, const char* name, WFlags fl ) |
36 | : SecurityBase( parent, name, TRUE, WStyle_ContextHelp ) | 36 | : SecurityBase( parent, name, TRUE, WStyle_ContextHelp ) |
37 | { | 37 | { |
38 | valid=FALSE; | 38 | valid=FALSE; |
39 | Config cfg("Security"); | 39 | Config cfg("Security"); |
40 | cfg.setGroup("Passcode"); | 40 | cfg.setGroup("Passcode"); |
41 | passcode = cfg.readEntry("passcode"); | 41 | passcode = cfg.readEntry("passcode"); |
42 | passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); | 42 | passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); |
43 | cfg.setGroup("Sync"); | 43 | cfg.setGroup("Sync"); |
44 | int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 | 44 | 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); | 45 | int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); |
46 | selectNet(auth_peer,auth_peer_bits,TRUE); | 46 | selectNet(auth_peer,auth_peer_bits,TRUE); |
47 | 47 | ||
48 | connect(syncnet, SIGNAL(textChanged(const QString&)), | 48 | connect(syncnet, SIGNAL(textChanged(const QString&)), |
49 | this, SLOT(setSyncNet(const QString&))); | 49 | this, SLOT(setSyncNet(const QString&))); |
50 | 50 | ||
51 | cfg.setGroup("Sync"); | 51 | cfg.setGroup("Sync"); |
52 | QString sa = cfg.readEntry("syncapp","Qtopia"); | 52 | QString sa = cfg.readEntry("syncapp","Qtopia"); |
53 | 53 | ||
54 | for (int i=0; i<syncapp->count(); i++) { | 54 | for (int i=0; i<syncapp->count(); i++) { |
55 | if ( syncapp->text(i) == sa ) { | 55 | if ( syncapp->text(i) == sa ) { |
56 | syncapp->setCurrentItem(i); | 56 | syncapp->setCurrentItem(i); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | /* | 60 | /* |
61 | cfg.setGroup("Remote"); | 61 | cfg.setGroup("Remote"); |
62 | if ( telnetAvailable() ) | 62 | if ( telnetAvailable() ) |
63 | telnet->setChecked(cfg.readEntry("allow_telnet")); | 63 | telnet->setChecked(cfg.readEntry("allow_telnet")); |
64 | else | 64 | else |
65 | telnet->hide(); | 65 | telnet->hide(); |
66 | 66 | ||
67 | if ( sshAvailable() ) | 67 | if ( sshAvailable() ) |
68 | ssh->setChecked(cfg.readEntry("allow_ssh")); | 68 | ssh->setChecked(cfg.readEntry("allow_ssh")); |
69 | else | 69 | else |
70 | ssh->hide(); | 70 | ssh->hide(); |
71 | */ | 71 | */ |
72 | 72 | ||
73 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 73 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
74 | Config loginCfg(configFile,Config::File); | 74 | Config loginCfg(configFile,Config::File); |
75 | 75 | ||
76 | loginCfg.setGroup("General"); | 76 | loginCfg.setGroup("General"); |
77 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | 77 | autoLoginName=loginCfg.readEntry("AutoLogin",""); |
78 | 78 | ||
79 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | 79 | if (autoLoginName.stripWhiteSpace().isEmpty()) { |
80 | autoLogin=false; | 80 | autoLogin=false; |
81 | } else { | 81 | } else { |
82 | autoLogin=true; | 82 | autoLogin=true; |
83 | } | 83 | } |
84 | 84 | ||
85 | cfg.setGroup("SyncMode"); | 85 | cfg.setGroup("SyncMode"); |
86 | int mode = cfg.readNumEntry("Mode",2); // Default to Sharp | 86 | int mode = cfg.readNumEntry("Mode",2); // Default to Sharp |
87 | syncModeCombo->setCurrentItem( mode - 1 ); | 87 | syncModeCombo->setCurrentItem( mode - 1 ); |
88 | 88 | ||
89 | //since nobody knows what this is and it doesn't do anything, i'll hide it # CoreDump | 89 | //since nobody knows what this is and it doesn't do anything, i'll hide it # CoreDump |
90 | // is this work-in-progress or can it be removed? | 90 | // is this work-in-progress or can it be removed? |
91 | syncModeCombo->hide(); | 91 | syncModeCombo->hide(); |
92 | 92 | ||
93 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | 93 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); |
94 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | 94 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); |
95 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); | 95 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); |
96 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); | 96 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); |
97 | connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp())); | 97 | connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp())); |
98 | connect(restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); | 98 | connect(restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); |
99 | connect(deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); | 99 | connect(deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); |
100 | 100 | ||
101 | loadUsers(); | 101 | loadUsers(); |
102 | updateGUI(); | 102 | updateGUI(); |
103 | 103 | ||
104 | dl = new QPEDialogListener(this); | 104 | dl = new QPEDialogListener(this); |
105 | showMaximized(); | 105 | QPEApplication::showDialog( this ); |
106 | } | 106 | } |
107 | 107 | ||
108 | Security::~Security() | 108 | Security::~Security() |
109 | { | 109 | { |
110 | } | 110 | } |
111 | 111 | ||
112 | void Security::deleteListEntry() | 112 | void Security::deleteListEntry() |
113 | { | 113 | { |
114 | syncnet->removeItem(syncnet->currentItem()); | 114 | syncnet->removeItem(syncnet->currentItem()); |
115 | } | 115 | } |
116 | 116 | ||
117 | void Security::restoreDefaults() | 117 | void Security::restoreDefaults() |
118 | { | 118 | { |
119 | QMessageBox unrecbox( | 119 | QMessageBox unrecbox( |
120 | tr("Attention"), | 120 | tr("Attention"), |
121 | tr("<p>All user-defined net ranges will be lost."), | 121 | tr("<p>All user-defined net ranges will be lost."), |
122 | QMessageBox::Warning, | 122 | QMessageBox::Warning, |
123 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 123 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
124 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 124 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
125 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); | 125 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); |
126 | unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); | 126 | unrecbox.setButtonText(QMessageBox::Yes, tr("Ok")); |
127 | 127 | ||
128 | if ( unrecbox.exec() == QMessageBox::Yes) | 128 | if ( unrecbox.exec() == QMessageBox::Yes) |
129 | { | 129 | { |
130 | syncnet->clear(); | 130 | syncnet->clear(); |
131 | insertDefaultRanges(); | 131 | insertDefaultRanges(); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | void Security::insertDefaultRanges() | 135 | void Security::insertDefaultRanges() |
136 | { | 136 | { |
137 | syncnet->insertItem( tr( "192.168.129.0/24" ) ); | 137 | syncnet->insertItem( tr( "192.168.129.0/24" ) ); |
138 | syncnet->insertItem( tr( "192.168.1.0/24" ) ); | 138 | syncnet->insertItem( tr( "192.168.1.0/24" ) ); |
139 | syncnet->insertItem( tr( "192.168.0.0/16" ) ); | 139 | syncnet->insertItem( tr( "192.168.0.0/16" ) ); |
140 | syncnet->insertItem( tr( "172.16.0.0/12" ) ); | 140 | syncnet->insertItem( tr( "172.16.0.0/12" ) ); |
141 | syncnet->insertItem( tr( "10.0.0.0/8" ) ); | 141 | syncnet->insertItem( tr( "10.0.0.0/8" ) ); |
142 | syncnet->insertItem( tr( "1.0.0.0/8" ) ); | 142 | syncnet->insertItem( tr( "1.0.0.0/8" ) ); |
143 | syncnet->insertItem( tr( "Any" ) ); | 143 | syncnet->insertItem( tr( "Any" ) ); |
144 | syncnet->insertItem( tr( "None" ) ); | 144 | syncnet->insertItem( tr( "None" ) ); |
145 | } | 145 | } |
146 | 146 | ||
147 | void Security::updateGUI() | 147 | void Security::updateGUI() |
148 | { | 148 | { |
149 | bool empty = passcode.isEmpty(); | 149 | bool empty = passcode.isEmpty(); |
150 | 150 | ||
151 | changepasscode->setText( empty ? tr("Set passcode" ) | 151 | changepasscode->setText( empty ? tr("Set passcode" ) |
152 | : tr("Change passcode" ) ); | 152 | : tr("Change passcode" ) ); |
153 | passcode_poweron->setEnabled( !empty ); | 153 | passcode_poweron->setEnabled( !empty ); |
154 | clearpasscode->setEnabled( !empty ); | 154 | clearpasscode->setEnabled( !empty ); |
155 | 155 | ||
156 | autologinToggle->setChecked(autoLogin); | 156 | autologinToggle->setChecked(autoLogin); |
157 | userlist->setEnabled(autoLogin); | 157 | userlist->setEnabled(autoLogin); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | void Security::show() | 161 | void Security::show() |
162 | { | 162 | { |
163 | //valid=FALSE; | 163 | //valid=FALSE; |
164 | setEnabled(FALSE); | 164 | setEnabled(FALSE); |
165 | SecurityBase::show(); | 165 | SecurityBase::show(); |
166 | if ( passcode.isEmpty() ) { | 166 | if ( passcode.isEmpty() ) { |
167 | // could insist... | 167 | // could insist... |
168 | //changePassCode(); | 168 | //changePassCode(); |
169 | //if ( passcode.isEmpty() ) | 169 | //if ( passcode.isEmpty() ) |
170 | //reject(); | 170 | //reject(); |
171 | } else { | 171 | } else { |
172 | if (!valid) // security passcode was not asked yet, so ask now | 172 | if (!valid) // security passcode was not asked yet, so ask now |
173 | { | 173 | { |
174 | QString pc = enterPassCode(tr("Enter passcode")); | 174 | QString pc = enterPassCode(tr("Enter passcode")); |
175 | if ( pc != passcode ) { | 175 | if ( pc != passcode ) { |
176 | QMessageBox::critical(this, tr("Passcode incorrect"), | 176 | QMessageBox::critical(this, tr("Passcode incorrect"), |
177 | tr("The passcode entered is incorrect.\nAccess denied")); | 177 | tr("The passcode entered is incorrect.\nAccess denied")); |
178 | reject(); | 178 | reject(); |
179 | return; | 179 | return; |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | setEnabled(TRUE); | 183 | setEnabled(TRUE); |
184 | valid=TRUE; | 184 | valid=TRUE; |
185 | } | 185 | } |
186 | 186 | ||
187 | void Security::accept() | 187 | void Security::accept() |
188 | { | 188 | { |
189 | applySecurity(); | 189 | applySecurity(); |
190 | QDialog::accept(); | 190 | QDialog::accept(); |
191 | QCopEnvelope env("QPE/System", "securityChanged()" ); | 191 | QCopEnvelope env("QPE/System", "securityChanged()" ); |
192 | } | 192 | } |
193 | 193 | ||
194 | void Security::done(int r) | 194 | void Security::done(int r) |
195 | { | 195 | { |
196 | QDialog::done(r); | 196 | QDialog::done(r); |
197 | close(); | 197 | close(); |
198 | } | 198 | } |
199 | 199 | ||
200 | void Security::selectNet(int auth_peer,int auth_peer_bits, bool update) | 200 | void Security::selectNet(int auth_peer,int auth_peer_bits, bool update) |
201 | { | 201 | { |
202 | QString sn; | 202 | QString sn; |
203 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { | 203 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { |
204 | sn = tr("Any"); | 204 | sn = tr("Any"); |
205 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { | 205 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { |
206 | sn = tr("None"); | 206 | sn = tr("None"); |
207 | } else { | 207 | } else { |
208 | sn = | 208 | sn = |
209 | QString::number((auth_peer>>24)&0xff) + "." | 209 | QString::number((auth_peer>>24)&0xff) + "." |
210 | + QString::number((auth_peer>>16)&0xff) + "." | 210 | + QString::number((auth_peer>>16)&0xff) + "." |
211 | + QString::number((auth_peer>>8)&0xff) + "." | 211 | + QString::number((auth_peer>>8)&0xff) + "." |
212 | + QString::number((auth_peer>>0)&0xff) + "/" | 212 | + QString::number((auth_peer>>0)&0xff) + "/" |
213 | + QString::number(auth_peer_bits); | 213 | + QString::number(auth_peer_bits); |
214 | } | 214 | } |
215 | 215 | ||
216 | //insert user-defined list of netranges upon start | 216 | //insert user-defined list of netranges upon start |
217 | if (update) { | 217 | if (update) { |
218 | //User selected/active netrange first | 218 | //User selected/active netrange first |
219 | syncnet->insertItem( tr( sn ) ); | 219 | syncnet->insertItem( tr( sn ) ); |
220 | 220 | ||
221 | Config cfg("Security"); | 221 | Config cfg("Security"); |
222 | cfg.setGroup("Sync"); | 222 | cfg.setGroup("Sync"); |
223 | 223 | ||
224 | //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe | 224 | //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe |
225 | QString test = cfg.readEntry("net0",""); | 225 | QString test = cfg.readEntry("net0",""); |
226 | if (test.isEmpty()) { | 226 | if (test.isEmpty()) { |
227 | insertDefaultRanges(); | 227 | insertDefaultRanges(); |
228 | } else { | 228 | } else { |
229 | // 10 ought to be enough for everybody... :) | 229 | // 10 ought to be enough for everybody... :) |
230 | // If you need more, don't forget to edit applySecurity() as well | 230 | // If you need more, don't forget to edit applySecurity() as well |
231 | bool already_there=FALSE; | 231 | bool already_there=FALSE; |
232 | for (int i=0; i<10; i++) { | 232 | for (int i=0; i<10; i++) { |
233 | QString target, netrange; | 233 | QString target, netrange; |
234 | target.sprintf("net%d", i); | 234 | target.sprintf("net%d", i); |
235 | netrange = cfg.readEntry(target,""); | 235 | netrange = cfg.readEntry(target,""); |
236 | if (! netrange.isEmpty()){ | 236 | if (! netrange.isEmpty()){ |
237 | //make sure we have no "twin" entries | 237 | //make sure we have no "twin" entries |
238 | for (int i=0; i<syncnet->count(); i++) { | 238 | for (int i=0; i<syncnet->count(); i++) { |
239 | if ( syncnet->text(i) == netrange ) { | 239 | if ( syncnet->text(i) == netrange ) { |
240 | already_there=TRUE; | 240 | already_there=TRUE; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | if (! already_there) { | 243 | if (! already_there) { |
244 | syncnet->insertItem( tr( netrange ) ); | 244 | syncnet->insertItem( tr( netrange ) ); |
245 | } else { | 245 | } else { |
246 | already_there=FALSE; | 246 | already_there=FALSE; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | for (int i=0; i<syncnet->count(); i++) { | 253 | for (int i=0; i<syncnet->count(); i++) { |
254 | if ( syncnet->text(i).left(sn.length()) == sn ) { | 254 | if ( syncnet->text(i).left(sn.length()) == sn ) { |
255 | syncnet->setCurrentItem(i); | 255 | syncnet->setCurrentItem(i); |
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | qDebug("No match for \"%s\"",sn.latin1()); | 259 | qDebug("No match for \"%s\"",sn.latin1()); |
260 | } | 260 | } |
261 | 261 | ||
262 | void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | 262 | void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) |
263 | { | 263 | { |
264 | auth_peer=0; | 264 | auth_peer=0; |
265 | if ( sn == tr("Any") ) { | 265 | if ( sn == tr("Any") ) { |
266 | auth_peer = 0; | 266 | auth_peer = 0; |
267 | auth_peer_bits = 0; | 267 | auth_peer_bits = 0; |
268 | } else if ( sn == tr("None") ) { | 268 | } else if ( sn == tr("None") ) { |
269 | auth_peer = 0; | 269 | auth_peer = 0; |
270 | auth_peer_bits = 32; | 270 | auth_peer_bits = 32; |
271 | } else { | 271 | } else { |
272 | int x=0; | 272 | int x=0; |
273 | for (int i=0; i<4; i++) { | 273 | for (int i=0; i<4; i++) { |
274 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); | 274 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); |
275 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); | 275 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); |
276 | x = nx+1; | 276 | x = nx+1; |
277 | } | 277 | } |
278 | uint n = (uint)sn.find(' ',x)-x; | 278 | uint n = (uint)sn.find(' ',x)-x; |
279 | auth_peer_bits = sn.mid(x,n).toInt(); | 279 | auth_peer_bits = sn.mid(x,n).toInt(); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | void Security::loadUsers ( void ) | 283 | void Security::loadUsers ( void ) |
284 | { | 284 | { |
285 | QFile passwd("/etc/passwd"); | 285 | QFile passwd("/etc/passwd"); |
286 | if ( passwd.open(IO_ReadOnly) ) { | 286 | if ( passwd.open(IO_ReadOnly) ) { |
287 | QTextStream t( &passwd ); | 287 | QTextStream t( &passwd ); |
288 | QString s; | 288 | QString s; |
289 | QStringList account; | 289 | QStringList account; |
290 | while ( !t.eof() ) { | 290 | while ( !t.eof() ) { |
291 | account = QStringList::split(':',t.readLine()); | 291 | account = QStringList::split(':',t.readLine()); |
292 | 292 | ||
293 | // Hide disabled accounts | 293 | // Hide disabled accounts |
294 | if (*account.at(1)!="*") { | 294 | if (*account.at(1)!="*") { |
295 | 295 | ||
296 | userlist->insertItem(*account.at(0)); | 296 | userlist->insertItem(*account.at(0)); |
297 | // Highlight this item if it is set to autologinToggle | 297 | // Highlight this item if it is set to autologinToggle |
298 | if ( *account.at(0) == autoLoginName) | 298 | if ( *account.at(0) == autoLoginName) |
299 | userlist->setCurrentItem(userlist->count()-1); | 299 | userlist->setCurrentItem(userlist->count()-1); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | passwd.close(); | 302 | passwd.close(); |
303 | } | 303 | } |
304 | 304 | ||
305 | } | 305 | } |
306 | 306 | ||
307 | void Security::toggleAutoLogin(bool val) | 307 | void Security::toggleAutoLogin(bool val) |
308 | { | 308 | { |
309 | autoLogin=val; | 309 | autoLogin=val; |
310 | userlist->setEnabled(val); | 310 | userlist->setEnabled(val); |
311 | if (!autoLogin) | 311 | if (!autoLogin) |
312 | autoLoginName=userlist->currentText(); | 312 | autoLoginName=userlist->currentText(); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | 316 | ||
317 | 317 | ||
318 | void Security::setSyncNet(const QString& sn) | 318 | void Security::setSyncNet(const QString& sn) |
319 | { | 319 | { |
320 | int auth_peer,auth_peer_bits; | 320 | int auth_peer,auth_peer_bits; |
321 | parseNet(sn,auth_peer,auth_peer_bits); | 321 | parseNet(sn,auth_peer,auth_peer_bits); |
322 | selectNet(auth_peer,auth_peer_bits,FALSE); | 322 | selectNet(auth_peer,auth_peer_bits,FALSE); |
323 | } | 323 | } |
324 | 324 | ||
325 | void Security::applySecurity() | 325 | void Security::applySecurity() |
326 | { | 326 | { |
327 | if ( valid ) { | 327 | if ( valid ) { |
328 | Config cfg("Security"); | 328 | Config cfg("Security"); |
329 | cfg.setGroup("Passcode"); | 329 | cfg.setGroup("Passcode"); |
330 | cfg.writeEntry("passcode",passcode); | 330 | cfg.writeEntry("passcode",passcode); |
331 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); | 331 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); |
332 | cfg.setGroup("Sync"); | 332 | cfg.setGroup("Sync"); |
333 | int auth_peer=0; | 333 | int auth_peer=0; |
334 | int auth_peer_bits; | 334 | int auth_peer_bits; |
335 | QString sn = syncnet->currentText(); | 335 | QString sn = syncnet->currentText(); |
336 | parseNet(sn,auth_peer,auth_peer_bits); | 336 | parseNet(sn,auth_peer,auth_peer_bits); |
337 | 337 | ||
338 | //this is the *selected* (active) net range | 338 | //this is the *selected* (active) net range |
339 | cfg.writeEntry("auth_peer",auth_peer); | 339 | cfg.writeEntry("auth_peer",auth_peer); |
340 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); | 340 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); |
341 | 341 | ||
342 | //write back all other net ranges in *cleartext* | 342 | //write back all other net ranges in *cleartext* |
343 | for (int i=0; i<10; i++) { | 343 | for (int i=0; i<10; i++) { |
344 | QString target; | 344 | QString target; |
345 | target.sprintf("net%d", i); | 345 | target.sprintf("net%d", i); |
346 | cfg.writeEntry(target,syncnet->text(i)); | 346 | cfg.writeEntry(target,syncnet->text(i)); |
347 | } | 347 | } |
348 | 348 | ||
349 | cfg.writeEntry("syncapp",syncapp->currentText()); | 349 | cfg.writeEntry("syncapp",syncapp->currentText()); |
350 | 350 | ||
351 | /* | 351 | /* |
352 | cfg.setGroup("Remote"); | 352 | cfg.setGroup("Remote"); |
353 | if ( telnetAvailable() ) | 353 | if ( telnetAvailable() ) |
354 | cfg.writeEntry("allow_telnet",telnet->isChecked()); | 354 | cfg.writeEntry("allow_telnet",telnet->isChecked()); |
355 | if ( sshAvailable() ) | 355 | if ( sshAvailable() ) |
356 | cfg.writeEntry("allow_ssh",ssh->isChecked()); | 356 | cfg.writeEntry("allow_ssh",ssh->isChecked()); |
357 | // ### write ssh/telnet sys config files | 357 | // ### write ssh/telnet sys config files |
358 | */ | 358 | */ |
359 | 359 | ||
360 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 360 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
361 | Config loginCfg(configFile,Config::File); | 361 | Config loginCfg(configFile,Config::File); |
362 | loginCfg.setGroup("General"); | 362 | loginCfg.setGroup("General"); |
363 | 363 | ||
364 | if (autoLogin) { | 364 | if (autoLogin) { |
365 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 365 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
366 | } else { | 366 | } else { |
367 | loginCfg.removeEntry("AutoLogin"); | 367 | loginCfg.removeEntry("AutoLogin"); |
368 | } | 368 | } |
369 | 369 | ||
370 | } | 370 | } |
371 | } | 371 | } |
372 | void Security::changeSyncApp() | 372 | void Security::changeSyncApp() |
373 | { | 373 | { |
374 | // Don't say i didn't tell ya | 374 | // Don't say i didn't tell ya |
375 | if (syncapp->currentText() == "IntelliSync") { | 375 | if (syncapp->currentText() == "IntelliSync") { |
376 | QMessageBox attn( | 376 | QMessageBox attn( |
377 | tr("WARNING"), | 377 | tr("WARNING"), |
378 | tr("<p>Selecting IntelliSync here will disable the FTP password." | 378 | tr("<p>Selecting IntelliSync here will disable the FTP password." |
379 | "<p>Every machine in your netrange will be able to sync with " | 379 | "<p>Every machine in your netrange will be able to sync with " |
380 | "your Zaurus!"), | 380 | "your Zaurus!"), |
381 | QMessageBox::Warning, | 381 | QMessageBox::Warning, |
382 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 382 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
383 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 383 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
384 | attn.setButtonText(QMessageBox::Cancel, tr("Ok")); | 384 | attn.setButtonText(QMessageBox::Cancel, tr("Ok")); |
385 | attn.exec(); | 385 | attn.exec(); |
386 | } | 386 | } |
387 | updateGUI(); | 387 | updateGUI(); |
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | 391 | ||
392 | void Security::changeLoginName( int idx ) | 392 | void Security::changeLoginName( int idx ) |
393 | { | 393 | { |
394 | autoLoginName = userlist->text(idx);; | 394 | autoLoginName = userlist->text(idx);; |
395 | updateGUI(); | 395 | updateGUI(); |
396 | } | 396 | } |
397 | 397 | ||
398 | void Security::changePassCode() | 398 | void Security::changePassCode() |
399 | { | 399 | { |
400 | QString new1; | 400 | QString new1; |
401 | QString new2; | 401 | QString new2; |
402 | 402 | ||
403 | do { | 403 | do { |
404 | new1 = enterPassCode(tr("Enter new passcode")); | 404 | new1 = enterPassCode(tr("Enter new passcode")); |
405 | if ( new1.isNull() ) | 405 | if ( new1.isNull() ) |
406 | return; | 406 | return; |
407 | new2 = enterPassCode(tr("Re-enter new passcode")); | 407 | new2 = enterPassCode(tr("Re-enter new passcode")); |
408 | if ( new2.isNull() ) | 408 | if ( new2.isNull() ) |
409 | return; | 409 | return; |
410 | } while (new1 != new2); | 410 | } while (new1 != new2); |
411 | 411 | ||
412 | passcode = new1; | 412 | passcode = new1; |
413 | updateGUI(); | 413 | updateGUI(); |
414 | } | 414 | } |
415 | 415 | ||
416 | void Security::clearPassCode() | 416 | void Security::clearPassCode() |
417 | { | 417 | { |
418 | passcode = QString::null; | 418 | passcode = QString::null; |
419 | updateGUI(); | 419 | updateGUI(); |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | QString Security::enterPassCode(const QString& prompt) | 423 | QString Security::enterPassCode(const QString& prompt) |
424 | { | 424 | { |
425 | return Password::getPassword(prompt); | 425 | return Password::getPassword(prompt); |
426 | } | 426 | } |
427 | 427 | ||
428 | bool Security::telnetAvailable() const | 428 | bool Security::telnetAvailable() const |
429 | { | 429 | { |
430 | // ### not implemented | 430 | // ### not implemented |
431 | return FALSE; | 431 | return FALSE; |
432 | } | 432 | } |
433 | 433 | ||
434 | bool Security::sshAvailable() const | 434 | bool Security::sshAvailable() const |
435 | { | 435 | { |
436 | // ### not implemented | 436 | // ### not implemented |
437 | return FALSE; | 437 | return FALSE; |
438 | } | 438 | } |