-rw-r--r-- | noncore/applets/autorotateapplet/autorotate.cpp | 6 | ||||
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 54 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 4 | ||||
-rw-r--r-- | noncore/applets/pyquicklaunch/pyquicklaunch.cpp | 6 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/applet/zkbwidget.cpp | 8 |
5 files changed, 39 insertions, 39 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp index 34802fb..28b631b 100644 --- a/noncore/applets/autorotateapplet/autorotate.cpp +++ b/noncore/applets/autorotateapplet/autorotate.cpp | |||
@@ -1,97 +1,97 @@ | |||
1 | /* | 1 | /* |
2 | * copyright : (c) 2003 by Greg Gilbert | 2 | * copyright : (c) 2003 by Greg Gilbert |
3 | * email : greg@treke.net | 3 | * email : greg@treke.net |
4 | * based on the cardmon applet by Max Reiss | 4 | * based on the cardmon applet by Max Reiss |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | * * | 10 | * * |
11 | *************************************************************************/ | 11 | *************************************************************************/ |
12 | 12 | ||
13 | #include "autorotate.h" | 13 | #include "autorotate.h" |
14 | 14 | ||
15 | /* OPIE */ | 15 | /* OPIE */ |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/otaskbarapplet.h> | 17 | #include <opie2/otaskbarapplet.h> |
18 | #include <opie2/oresource.h> | ||
18 | #include <qpe/applnk.h> | 19 | #include <qpe/applnk.h> |
19 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
20 | #include <qpe/resource.h> | ||
21 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
22 | 22 | ||
23 | /* QT */ | 23 | /* QT */ |
24 | #include <qpainter.h> | 24 | #include <qpainter.h> |
25 | 25 | ||
26 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) | 26 | AutoRotate::AutoRotate(QWidget * parent):QWidget(parent) |
27 | { | 27 | { |
28 | setFixedWidth( AppLnk::smallIconSize() ); | 28 | setFixedWidth( AppLnk::smallIconSize() ); |
29 | setFixedHeight( AppLnk::smallIconSize() ); | 29 | setFixedHeight( AppLnk::smallIconSize() ); |
30 | 30 | ||
31 | enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) ); | 31 | enabledPm = Opie::Core::OResource::loadImage("autorotate/rotate", Opie::Core::OResource::SmallIcon); |
32 | disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) ); | 32 | disabledPm = Opie::Core::OResource::loadImage("autorotate/norotate", Opie::Core::OResource::SmallIcon); |
33 | 33 | ||
34 | repaint(true); | 34 | repaint(true); |
35 | popupMenu = 0; | 35 | popupMenu = 0; |
36 | show(); | 36 | show(); |
37 | } | 37 | } |
38 | 38 | ||
39 | AutoRotate::~AutoRotate() | 39 | AutoRotate::~AutoRotate() |
40 | { | 40 | { |
41 | if (popupMenu) { | 41 | if (popupMenu) { |
42 | delete popupMenu; | 42 | delete popupMenu; |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | int AutoRotate::position() | 46 | int AutoRotate::position() |
47 | { | 47 | { |
48 | return 7; | 48 | return 7; |
49 | } | 49 | } |
50 | 50 | ||
51 | void AutoRotate::mousePressEvent(QMouseEvent *) | 51 | void AutoRotate::mousePressEvent(QMouseEvent *) |
52 | { | 52 | { |
53 | QPopupMenu *menu = new QPopupMenu(this); | 53 | QPopupMenu *menu = new QPopupMenu(this); |
54 | menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); | 54 | menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 ); |
55 | 55 | ||
56 | QPoint p = mapToGlobal(QPoint(0, 0)); | 56 | QPoint p = mapToGlobal(QPoint(0, 0)); |
57 | QSize s = menu->sizeHint(); | 57 | QSize s = menu->sizeHint(); |
58 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); | 58 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0); |
59 | 59 | ||
60 | if (opt==1) | 60 | if (opt==1) |
61 | { | 61 | { |
62 | setRotateEnabled( !isRotateEnabled() ); | 62 | setRotateEnabled( !isRotateEnabled() ); |
63 | repaint(true); | 63 | repaint(true); |
64 | } | 64 | } |
65 | 65 | ||
66 | delete menu; | 66 | delete menu; |
67 | } | 67 | } |
68 | 68 | ||
69 | void AutoRotate::paintEvent(QPaintEvent *) | 69 | void AutoRotate::paintEvent(QPaintEvent *) |
70 | { | 70 | { |
71 | QPainter p(this); | 71 | QPainter p(this); |
72 | p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); | 72 | p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm ); |
73 | } | 73 | } |
74 | 74 | ||
75 | void AutoRotate::setRotateEnabled(bool status) | 75 | void AutoRotate::setRotateEnabled(bool status) |
76 | { | 76 | { |
77 | Config cfg( "qpe" ); | 77 | Config cfg( "qpe" ); |
78 | cfg.setGroup( "Appearance" ); | 78 | cfg.setGroup( "Appearance" ); |
79 | cfg.writeEntry( "rotateEnabled", status ); | 79 | cfg.writeEntry( "rotateEnabled", status ); |
80 | 80 | ||
81 | } | 81 | } |
82 | bool AutoRotate::isRotateEnabled() | 82 | bool AutoRotate::isRotateEnabled() |
83 | { | 83 | { |
84 | Config cfg( "qpe" ); | 84 | Config cfg( "qpe" ); |
85 | cfg.setGroup( "Appearance" ); | 85 | cfg.setGroup( "Appearance" ); |
86 | 86 | ||
87 | bool res = cfg.readBoolEntry( "rotateEnabled" ); | 87 | bool res = cfg.readBoolEntry( "rotateEnabled" ); |
88 | 88 | ||
89 | if (res ) | 89 | if (res ) |
90 | odebug << "Enabled" << oendl; | 90 | odebug << "Enabled" << oendl; |
91 | else | 91 | else |
92 | odebug << "Disabled" << oendl; | 92 | odebug << "Disabled" << oendl; |
93 | return res; | 93 | return res; |
94 | } | 94 | } |
95 | 95 | ||
96 | EXPORT_OPIE_APPLET_v1( AutoRotate ) | 96 | EXPORT_OPIE_APPLET_v1( AutoRotate ) |
97 | 97 | ||
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index bd6ca66..10c2b34 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp | |||
@@ -1,255 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "networkapplet.h" | 31 | #include "networkapplet.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
36 | #include <opie2/oresource.h> | ||
36 | #include <opie2/otaskbarapplet.h> | 37 | #include <opie2/otaskbarapplet.h> |
37 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
38 | #include <qpe/resource.h> | 39 | #include <qpe/qpeapplication.h> |
39 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | 41 | using namespace Opie::Ui; |
41 | using namespace Opie::Net; | 42 | using namespace Opie::Net; |
42 | 43 | ||
43 | /* QT */ | 44 | /* QT */ |
44 | #include <qpainter.h> | 45 | #include <qpainter.h> |
45 | #include <qlabel.h> | 46 | #include <qlabel.h> |
46 | #include <qlayout.h> | 47 | #include <qlayout.h> |
47 | #include <qobjectlist.h> | 48 | #include <qobjectlist.h> |
48 | 49 | ||
49 | /* STD */ | 50 | /* STD */ |
50 | #include <assert.h> | 51 | #include <assert.h> |
51 | 52 | ||
52 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) | 53 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) |
53 | :QToolButton( parent, name ) | 54 | :QToolButton( parent, name ) |
54 | { | 55 | { |
55 | _iface = ONetwork::instance()->interface( name ); | 56 | _iface = ONetwork::instance()->interface( name ); |
56 | assert( _iface ); | 57 | assert( _iface ); |
57 | setToggleButton( true ); | 58 | setToggleButton( true ); |
58 | //setAutoRaise( true ); | 59 | setUsesBigPixmap( qApp->desktop()->size().width() > 330 ); |
59 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); | 60 | setOnIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ) ); |
60 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); | 61 | setOffIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) ) ); |
61 | setOn( _iface->isUp() ); | 62 | setOn( _iface->isUp() ); |
62 | //setFixedWidth( 16 ); | ||
63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); | 63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | IfaceUpDownButton::~IfaceUpDownButton() | 67 | IfaceUpDownButton::~IfaceUpDownButton() |
68 | { | 68 | { |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | void IfaceUpDownButton::clicked() | 72 | void IfaceUpDownButton::clicked() |
73 | { | 73 | { |
74 | _iface->setUp( isOn() ); | 74 | _iface->setUp( isOn() ); |
75 | setOn( _iface->isUp() ); // it might not have worked... | 75 | setOn( _iface->isUp() ); // it might not have worked... |
76 | repaint(); | 76 | repaint(); |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) | 80 | IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) |
81 | :QLineEdit( parent, name ) | 81 | :QLineEdit( parent, name ) |
82 | { | 82 | { |
83 | setFont( QFont( "fixed" ) ); | 83 | setFont( QFont( "fixed" ) ); |
84 | _iface = ONetwork::instance()->interface( name ); | 84 | _iface = ONetwork::instance()->interface( name ); |
85 | setFixedWidth( 105 ); | 85 | setFixedWidth( 105 ); |
86 | setText( _iface->ipV4Address().toString() ); | 86 | setText( _iface->ipV4Address().toString() ); |
87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); | 87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | IfaceIPAddress::~IfaceIPAddress() | 91 | IfaceIPAddress::~IfaceIPAddress() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void IfaceIPAddress::returnPressed() | 96 | void IfaceIPAddress::returnPressed() |
97 | { | 97 | { |
98 | QHostAddress a; | 98 | QHostAddress a; |
99 | a.setAddress( text() ); | 99 | a.setAddress( text() ); |
100 | QHostAddress mask; | 100 | QHostAddress mask; |
101 | mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... | 101 | mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... |
102 | _iface->setIPV4Address( a ); | 102 | _iface->setIPV4Address( a ); |
103 | _iface->setIPV4Netmask( mask ); // recover the old netmask | 103 | _iface->setIPV4Netmask( mask ); // recover the old netmask |
104 | setText( _iface->ipV4Address().toString() ); | 104 | setText( _iface->ipV4Address().toString() ); |
105 | repaint(); | 105 | repaint(); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) | 109 | NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) |
110 | :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) | 110 | :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) |
111 | { | 111 | { |
112 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 112 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
113 | l = new QVBoxLayout( this, 4, 2 ); | 113 | l = new QVBoxLayout( this, 4, 2 ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void NetworkAppletControl::build() | 117 | void NetworkAppletControl::build() |
118 | { | 118 | { |
119 | ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); | 119 | ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); |
120 | while ( it.current() ) | 120 | while ( it.current() ) |
121 | { | 121 | { |
122 | QHBoxLayout* h = new QHBoxLayout( l ); | 122 | QHBoxLayout* h = new QHBoxLayout( l ); |
123 | QLabel* symbol = new QLabel( this ); | 123 | QLabel* symbol = new QLabel( this ); |
124 | symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) ); | 124 | symbol->setPixmap( Opie::Core::OResource::loadPixmap( guessDevice( it.current() ), Opie::Core::OResource::SmallIcon ) ); |
125 | h->addWidget( symbol ); | 125 | h->addWidget( symbol ); |
126 | symbol->show(); | 126 | symbol->show(); |
127 | 127 | ||
128 | QLabel* name = new QLabel( it.current()->name(), this ); | 128 | QLabel* name = new QLabel( it.current()->name(), this ); |
129 | name->setFixedWidth( 35 ); | 129 | name->setFixedWidth( 35 ); |
130 | h->addWidget( name ); | 130 | h->addWidget( name ); |
131 | name->show(); | 131 | name->show(); |
132 | 132 | ||
133 | IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); | 133 | IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); |
134 | h->addWidget( ip ); | 134 | h->addWidget( ip ); |
135 | ip->show(); | 135 | ip->show(); |
136 | 136 | ||
137 | IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); | 137 | IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); |
138 | tb->show(); | 138 | tb->show(); |
139 | 139 | ||
140 | h->addWidget( tb ); | 140 | h->addWidget( tb ); |
141 | 141 | ||
142 | ++it; | 142 | ++it; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | NetworkAppletControl::~NetworkAppletControl() | 147 | NetworkAppletControl::~NetworkAppletControl() |
148 | { | 148 | { |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) | 152 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) |
153 | { | 153 | { |
154 | if ( iface->isWireless() ) | 154 | if ( iface->isWireless() ) |
155 | return "networksettings/wlan"; | 155 | return "networksettings/wlan"; |
156 | if ( iface->isLoopback() ) | 156 | if ( iface->isLoopback() ) |
157 | return "networksettings/lo"; | 157 | return "networksettings/lo"; |
158 | if ( QString( iface->name() ).contains( "usb" ) ) | 158 | if ( QString( iface->name() ).contains( "usb" ) ) |
159 | return "networksettings/usb"; | 159 | return "networksettings/usb"; |
160 | if ( QString( iface->name() ).contains( "ir" ) ) | 160 | if ( QString( iface->name() ).contains( "ir" ) ) |
161 | return "networksettings/irda"; | 161 | return "networksettings/irda"; |
162 | 162 | ||
163 | //TODO: Insert neat symbol and check for tunnel devices | 163 | //TODO: Insert neat symbol and check for tunnel devices |
164 | 164 | ||
165 | return "networksettings/lan"; | 165 | return "networksettings/lan"; |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void NetworkAppletControl::showEvent( QShowEvent* e ) | 170 | void NetworkAppletControl::showEvent( QShowEvent* e ) |
171 | { | 171 | { |
172 | odebug << "showEvent" << oendl; | 172 | odebug << "showEvent" << oendl; |
173 | build(); | 173 | build(); |
174 | QWidget::showEvent( e ); | 174 | QWidget::showEvent( e ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) | 178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) |
179 | { | 179 | { |
180 | odebug << "hideEvent" << oendl; | 180 | odebug << "hideEvent" << oendl; |
181 | QWidget::hideEvent( e ); | 181 | QWidget::hideEvent( e ); |
182 | 182 | ||
183 | delete l; | 183 | delete l; |
184 | 184 | ||
185 | // delete all child widgets from this frame | 185 | // delete all child widgets from this frame |
186 | QObjectList* list = const_cast<QObjectList*>( children() ); | 186 | QObjectList* list = const_cast<QObjectList*>( children() ); |
187 | QObjectListIt it(*list); | 187 | QObjectListIt it(*list); |
188 | QObject* obj; | 188 | QObject* obj; |
189 | while ( (obj=it.current()) ) | 189 | while ( (obj=it.current()) ) |
190 | { | 190 | { |
191 | ++it; | 191 | ++it; |
192 | delete obj; | 192 | delete obj; |
193 | } | 193 | } |
194 | 194 | ||
195 | list = const_cast<QObjectList*>( children() ); | 195 | list = const_cast<QObjectList*>( children() ); |
196 | if ( list ) | 196 | if ( list ) |
197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; | 197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; |
198 | 198 | ||
199 | // renew layout | 199 | // renew layout |
200 | l = new QVBoxLayout( this, 4, 2 ); | 200 | l = new QVBoxLayout( this, 4, 2 ); |
201 | resize( 0, 0 ); | 201 | resize( 0, 0 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | QSize NetworkAppletControl::sizeHint() const | 205 | QSize NetworkAppletControl::sizeHint() const |
206 | { | 206 | { |
207 | ONetwork::instance()->synchronize(); // rebuild interface database | 207 | ONetwork::instance()->synchronize(); // rebuild interface database |
208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; | 208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; |
209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); | 209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) | 213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) |
214 | :OTaskbarApplet( parent, name ) | 214 | :OTaskbarApplet( parent, name ) |
215 | { | 215 | { |
216 | setFixedHeight( AppLnk::smallIconSize() ); | 216 | setFixedHeight( AppLnk::smallIconSize() ); |
217 | setFixedWidth( AppLnk::smallIconSize() ); | 217 | setFixedWidth( AppLnk::smallIconSize() ); |
218 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); | 218 | _pixmap = Opie::Core::OResource::loadPixmap( "networkapplet/network", Opie::Core::OResource::SmallIcon ); |
219 | _control = new NetworkAppletControl( this, "control" ); | 219 | _control = new NetworkAppletControl( this, "control" ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | NetworkApplet::~NetworkApplet() | 223 | NetworkApplet::~NetworkApplet() |
224 | { | 224 | { |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | int NetworkApplet::position() | 228 | int NetworkApplet::position() |
229 | { | 229 | { |
230 | return 4; | 230 | return 4; |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | void NetworkApplet::paintEvent( QPaintEvent* ) | 234 | void NetworkApplet::paintEvent( QPaintEvent* ) |
235 | { | 235 | { |
236 | QPainter p(this); | 236 | QPainter p(this); |
237 | p.drawPixmap(0, 2, _pixmap ); | 237 | p.drawPixmap(0, 2, _pixmap ); |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void NetworkApplet::mousePressEvent( QMouseEvent* ) | 241 | void NetworkApplet::mousePressEvent( QMouseEvent* ) |
242 | { | 242 | { |
243 | if ( !_control->isVisible() ) | 243 | if ( !_control->isVisible() ) |
244 | { | 244 | { |
245 | popup( _control ); | 245 | popup( _control ); |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | _control->hide(); | 249 | _control->hide(); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | EXPORT_OPIE_APPLET_v1( NetworkApplet ) | 253 | EXPORT_OPIE_APPLET_v1( NetworkApplet ) |
254 | 254 | ||
255 | 255 | ||
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index d06672a..13f297e 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -1,219 +1,219 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org> | 2 | ** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org> |
3 | 3 | ||
4 | ** All rights reserved. | 4 | ** All rights reserved. |
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 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "notes.h" | 16 | #include "notes.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | 19 | #include <opie2/odebug.h> |
20 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
21 | #include <opie2/oresource.h> | ||
21 | #include <qpe/filemanager.h> | 22 | #include <qpe/filemanager.h> |
22 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/timestring.h> | 24 | #include <qpe/timestring.h> |
24 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
25 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
26 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
27 | #include <qpe/resource.h> | ||
28 | using namespace Opie::Core; | 28 | using namespace Opie::Core; |
29 | using namespace Opie::Ui; | 29 | using namespace Opie::Ui; |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qlistbox.h> | 33 | #include <qlistbox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qapplication.h> | 36 | #include <qapplication.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qpoint.h> | 39 | #include <qpoint.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qpixmap.h> | 44 | #include <qpixmap.h> |
45 | #include <qstring.h> | 45 | #include <qstring.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qtimer.h> | 47 | #include <qtimer.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | 51 | ||
52 | NotesControl::NotesControl( QWidget *, const char * ) | 52 | NotesControl::NotesControl( QWidget *, const char * ) |
53 | : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) | 53 | : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) |
54 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 54 | // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
55 | { | 55 | { |
56 | QDir d( QDir::homeDirPath()+"/notes"); | 56 | QDir d( QDir::homeDirPath()+"/notes"); |
57 | if( !d.exists()) { | 57 | if( !d.exists()) { |
58 | odebug << "make dir" << oendl; | 58 | odebug << "make dir" << oendl; |
59 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) | 59 | if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) |
60 | odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; | 60 | odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; |
61 | } | 61 | } |
62 | Config cfg("Notes"); | 62 | Config cfg("Notes"); |
63 | cfg.setGroup("Options"); | 63 | cfg.setGroup("Options"); |
64 | showMax = cfg.readBoolEntry("ShowMax", false); | 64 | showMax = cfg.readBoolEntry("ShowMax", false); |
65 | 65 | ||
66 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 66 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
67 | loaded=false; | 67 | loaded=false; |
68 | edited=false; | 68 | edited=false; |
69 | doPopulate=true; | 69 | doPopulate=true; |
70 | isNew=false; | 70 | isNew=false; |
71 | QVBox *vbox = new QVBox( this, "Vlayout" ); | 71 | QVBox *vbox = new QVBox( this, "Vlayout" ); |
72 | QHBox *hbox = new QHBox( this, "HLayout" ); | 72 | QHBox *hbox = new QHBox( this, "HLayout" ); |
73 | 73 | ||
74 | view = new QMultiLineEdit(vbox, "OpieNotesView"); | 74 | view = new QMultiLineEdit(vbox, "OpieNotesView"); |
75 | 75 | ||
76 | box = new QListBox(vbox, "OpieNotesBox"); | 76 | box = new QListBox(vbox, "OpieNotesBox"); |
77 | 77 | ||
78 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); | 78 | QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold); |
79 | 79 | ||
80 | box->setFixedHeight(50); | 80 | box->setFixedHeight(50); |
81 | 81 | ||
82 | vbox->setMargin( 6 ); | 82 | vbox->setMargin( 6 ); |
83 | vbox->setSpacing( 3 ); | 83 | vbox->setSpacing( 3 ); |
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
87 | setFocusPolicy(QWidget::StrongFocus); | 87 | setFocusPolicy(QWidget::StrongFocus); |
88 | 88 | ||
89 | newButton= new QPushButton( hbox, "newButton" ); | 89 | newButton= new QPushButton( hbox, "newButton" ); |
90 | newButton->setText(tr("New")); | 90 | newButton->setText(tr("New")); |
91 | 91 | ||
92 | 92 | ||
93 | saveButton= new QPushButton( hbox, "saveButton" ); | 93 | saveButton= new QPushButton( hbox, "saveButton" ); |
94 | saveButton->setText(tr("Save")); | 94 | saveButton->setText(tr("Save")); |
95 | 95 | ||
96 | 96 | ||
97 | deleteButton= new QPushButton( hbox, "deleteButton" ); | 97 | deleteButton= new QPushButton( hbox, "deleteButton" ); |
98 | deleteButton->setText(tr("Delete")); | 98 | deleteButton->setText(tr("Delete")); |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | connect( box, SIGNAL( mouseButtonPressed(int,QListBoxItem*,const QPoint&)), | 102 | connect( box, SIGNAL( mouseButtonPressed(int,QListBoxItem*,const QPoint&)), |
103 | this,SLOT( boxPressed(int,QListBoxItem*,const QPoint&)) ); | 103 | this,SLOT( boxPressed(int,QListBoxItem*,const QPoint&)) ); |
104 | 104 | ||
105 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString&))); | 105 | connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString&))); |
106 | 106 | ||
107 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); | 107 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) ); |
108 | 108 | ||
109 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); | 109 | connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) ); |
110 | 110 | ||
111 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); | 111 | connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton())); |
112 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); | 112 | connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton())); |
113 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); | 113 | connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked())); |
114 | 114 | ||
115 | populateBox(); | 115 | populateBox(); |
116 | load(); | 116 | load(); |
117 | setCaption("Notes"); | 117 | setCaption("Notes"); |
118 | // parent->setFocus(); | 118 | // parent->setFocus(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void NotesControl::slotSaveButton() { | 121 | void NotesControl::slotSaveButton() { |
122 | slotNewButton(); | 122 | slotNewButton(); |
123 | populateBox(); | 123 | populateBox(); |
124 | } | 124 | } |
125 | 125 | ||
126 | void NotesControl::slotDeleteButtonClicked() { | 126 | void NotesControl::slotDeleteButtonClicked() { |
127 | switch ( QMessageBox::warning(this,tr("Delete?") | 127 | switch ( QMessageBox::warning(this,tr("Delete?") |
128 | ,tr("Do you really want to<BR><B> delete</B> this note ?") | 128 | ,tr("Do you really want to<BR><B> delete</B> this note ?") |
129 | ,tr("Yes"),tr("No"),0,1,1) ) { | 129 | ,tr("Yes"),tr("No"),0,1,1) ) { |
130 | case 0: | 130 | case 0: |
131 | slotDeleteButton(); | 131 | slotDeleteButton(); |
132 | break; | 132 | break; |
133 | }; | 133 | }; |
134 | } | 134 | } |
135 | 135 | ||
136 | void NotesControl::slotDeleteButton() { | 136 | void NotesControl::slotDeleteButton() { |
137 | 137 | ||
138 | QString selectedText = box->currentText(); | 138 | QString selectedText = box->currentText(); |
139 | odebug << "deleting "+selectedText << oendl; | 139 | odebug << "deleting "+selectedText << oendl; |
140 | 140 | ||
141 | if( !selectedText.isEmpty()) { | 141 | if( !selectedText.isEmpty()) { |
142 | 142 | ||
143 | Config cfg("Notes"); | 143 | Config cfg("Notes"); |
144 | cfg.setGroup("Docs"); | 144 | cfg.setGroup("Docs"); |
145 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 145 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
146 | QString entryName, entryName2;; | 146 | QString entryName, entryName2;; |
147 | for ( int i = 0; i < noOfFiles; i++ ) { | 147 | for ( int i = 0; i < noOfFiles; i++ ) { |
148 | entryName.sprintf( "File%i", i + 1 ); | 148 | entryName.sprintf( "File%i", i + 1 ); |
149 | if(selectedText == cfg.readEntry( entryName )) { | 149 | if(selectedText == cfg.readEntry( entryName )) { |
150 | odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; | 150 | odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; |
151 | for ( int j = i; j < noOfFiles; j++ ) { | 151 | for ( int j = i; j < noOfFiles; j++ ) { |
152 | entryName.sprintf( "File%i", i + 1 ); | 152 | entryName.sprintf( "File%i", i + 1 ); |
153 | entryName2.sprintf( "File%i", i + 2 ); | 153 | entryName2.sprintf( "File%i", i + 2 ); |
154 | QString temp = cfg.readEntry(entryName2); | 154 | QString temp = cfg.readEntry(entryName2); |
155 | odebug << "move "+temp << oendl; | 155 | odebug << "move "+temp << oendl; |
156 | cfg.writeEntry(entryName, temp); | 156 | cfg.writeEntry(entryName, temp); |
157 | i++; | 157 | i++; |
158 | } | 158 | } |
159 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); | 159 | cfg.writeEntry("NumberOfFiles", noOfFiles-1 ); |
160 | entryName.sprintf( "File%i", noOfFiles ); | 160 | entryName.sprintf( "File%i", noOfFiles ); |
161 | cfg.removeEntry(entryName); | 161 | cfg.removeEntry(entryName); |
162 | cfg.write(); | 162 | cfg.write(); |
163 | DocLnk nf(selectedText); | 163 | DocLnk nf(selectedText); |
164 | nf.removeFiles(); | 164 | nf.removeFiles(); |
165 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; | 165 | QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; |
166 | odebug << fi << oendl; | 166 | odebug << fi << oendl; |
167 | 167 | ||
168 | QFile f( fi); | 168 | QFile f( fi); |
169 | if( !f.remove()) odebug << ".desktop file not removed" << oendl; | 169 | if( !f.remove()) odebug << ".desktop file not removed" << oendl; |
170 | 170 | ||
171 | } | 171 | } |
172 | } | 172 | } |
173 | view->clear(); | 173 | view->clear(); |
174 | 174 | ||
175 | populateBox(); | 175 | populateBox(); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | void NotesControl::slotNewButton() { | 179 | void NotesControl::slotNewButton() { |
180 | if(edited) save(); | 180 | if(edited) save(); |
181 | view->clear(); | 181 | view->clear(); |
182 | view->setFocus(); | 182 | view->setFocus(); |
183 | edited=false; | 183 | edited=false; |
184 | isNew=false; | 184 | isNew=false; |
185 | } | 185 | } |
186 | 186 | ||
187 | void NotesControl::slotBeamButton() { | 187 | void NotesControl::slotBeamButton() { |
188 | Ir ir; | 188 | Ir ir; |
189 | if(!ir.supported()){ | 189 | if(!ir.supported()){ |
190 | } else { | 190 | } else { |
191 | this->hide(); | 191 | this->hide(); |
192 | QString selectedText = box->currentText(); | 192 | QString selectedText = box->currentText(); |
193 | if( !selectedText.isEmpty()) { | 193 | if( !selectedText.isEmpty()) { |
194 | QString file = QDir::homeDirPath()+"/"+selectedText; | 194 | QString file = QDir::homeDirPath()+"/"+selectedText; |
195 | QFile f(file); | 195 | QFile f(file); |
196 | Ir *irFile = new Ir(this, "IR"); | 196 | Ir *irFile = new Ir(this, "IR"); |
197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); | 197 | connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*))); |
198 | irFile->send( file, "Note", "text/plain" ); | 198 | irFile->send( file, "Note", "text/plain" ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | void NotesControl::slotBeamFinished(Ir *) { | 203 | void NotesControl::slotBeamFinished(Ir *) { |
204 | this->show(); | 204 | this->show(); |
205 | } | 205 | } |
206 | 206 | ||
207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { | 207 | void NotesControl::boxPressed(int mouse, QListBoxItem *, const QPoint&) { |
208 | switch (mouse) { | 208 | switch (mouse) { |
209 | case 1:{ | 209 | case 1:{ |
210 | } | 210 | } |
211 | break; | 211 | break; |
212 | case 2: | 212 | case 2: |
213 | menuTimer.start( 500, TRUE ); | 213 | menuTimer.start( 500, TRUE ); |
214 | break; | 214 | break; |
215 | }; | 215 | }; |
216 | } | 216 | } |
217 | 217 | ||
218 | void NotesControl::slotBoxSelected(const QString &itemString) { | 218 | void NotesControl::slotBoxSelected(const QString &itemString) { |
219 | if(edited) { | 219 | if(edited) { |
@@ -243,244 +243,244 @@ void NotesControl::focusOutEvent ( QFocusEvent * e) { | |||
243 | save(); | 243 | save(); |
244 | else { | 244 | else { |
245 | if(!loaded) { | 245 | if(!loaded) { |
246 | populateBox(); | 246 | populateBox(); |
247 | load(); | 247 | load(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | QWidget::focusOutEvent(e); | 250 | QWidget::focusOutEvent(e); |
251 | } | 251 | } |
252 | 252 | ||
253 | void NotesControl::save() { | 253 | void NotesControl::save() { |
254 | Config cfg("Notes"); | 254 | Config cfg("Notes"); |
255 | cfg.setGroup("Docs"); | 255 | cfg.setGroup("Docs"); |
256 | if( edited) { | 256 | if( edited) { |
257 | // odebug << "is edited" << oendl; | 257 | // odebug << "is edited" << oendl; |
258 | QString rt = view->text(); | 258 | QString rt = view->text(); |
259 | if( rt.length()>1) { | 259 | if( rt.length()>1) { |
260 | QString pt = rt.simplifyWhiteSpace(); | 260 | QString pt = rt.simplifyWhiteSpace(); |
261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); | 261 | int i = pt.find( ' ', pt.find( ' ' )+2 ); |
262 | QString docname = pt; | 262 | QString docname = pt; |
263 | if ( i > 0 ) | 263 | if ( i > 0 ) |
264 | docname = pt.left(i); | 264 | docname = pt.left(i); |
265 | // remove "." at the beginning | 265 | // remove "." at the beginning |
266 | while( docname.startsWith( "." ) ) | 266 | while( docname.startsWith( "." ) ) |
267 | docname = docname.mid( 1 ); | 267 | docname = docname.mid( 1 ); |
268 | docname.replace( QRegExp("/"), "_" ); | 268 | docname.replace( QRegExp("/"), "_" ); |
269 | // cut the length. filenames longer than that don't make sense | 269 | // cut the length. filenames longer than that don't make sense |
270 | // and something goes wrong when they get too long. | 270 | // and something goes wrong when they get too long. |
271 | if ( docname.length() > 40 ) | 271 | if ( docname.length() > 40 ) |
272 | docname = docname.left(40); | 272 | docname = docname.left(40); |
273 | if ( docname.isEmpty() ) | 273 | if ( docname.isEmpty() ) |
274 | docname = "Empty Text"; | 274 | docname = "Empty Text"; |
275 | // odebug << docname << oendl; | 275 | // odebug << docname << oendl; |
276 | 276 | ||
277 | if( oldDocName != docname) { | 277 | if( oldDocName != docname) { |
278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 278 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
279 | QString entryName; | 279 | QString entryName; |
280 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 280 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
281 | cfg.writeEntry( entryName,docname ); | 281 | cfg.writeEntry( entryName,docname ); |
282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 282 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
283 | cfg.write(); | 283 | cfg.write(); |
284 | } | 284 | } |
285 | // else | 285 | // else |
286 | // odebug << "oldname equals docname" << oendl; | 286 | // odebug << "oldname equals docname" << oendl; |
287 | 287 | ||
288 | doc = new DocLnk(docname); | 288 | doc = new DocLnk(docname); |
289 | if(QFile(doc->linkFile()).exists()) | 289 | if(QFile(doc->linkFile()).exists()) |
290 | odebug << "puppie" << oendl; | 290 | odebug << "puppie" << oendl; |
291 | doc->setType("text/plain"); | 291 | doc->setType("text/plain"); |
292 | doc->setName(docname); | 292 | doc->setName(docname); |
293 | QString temp = docname.replace( QRegExp(" "), "_" ); | 293 | QString temp = docname.replace( QRegExp(" "), "_" ); |
294 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); | 294 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); |
295 | FileManager fm; | 295 | FileManager fm; |
296 | if ( !fm.saveFile( *doc, rt ) ) { | 296 | if ( !fm.saveFile( *doc, rt ) ) { |
297 | } | 297 | } |
298 | 298 | ||
299 | oldDocName=docname; | 299 | oldDocName=docname; |
300 | edited=false; | 300 | edited=false; |
301 | // odebug << "save" << oendl; | 301 | // odebug << "save" << oendl; |
302 | if (doPopulate) | 302 | if (doPopulate) |
303 | populateBox(); | 303 | populateBox(); |
304 | } | 304 | } |
305 | cfg.writeEntry( "LastDoc",oldDocName ); | 305 | cfg.writeEntry( "LastDoc",oldDocName ); |
306 | cfg.write(); | 306 | cfg.write(); |
307 | 307 | ||
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | void NotesControl::populateBox() { | 311 | void NotesControl::populateBox() { |
312 | box->clear(); | 312 | box->clear(); |
313 | // odebug << "populate" << oendl; | 313 | // odebug << "populate" << oendl; |
314 | Config cfg("Notes"); | 314 | Config cfg("Notes"); |
315 | cfg.setGroup("Docs"); | 315 | cfg.setGroup("Docs"); |
316 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 316 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
317 | QStringList list; | 317 | QStringList list; |
318 | QString entryName; | 318 | QString entryName; |
319 | for ( int i = 0; i < noOfFiles; i++ ) { | 319 | for ( int i = 0; i < noOfFiles; i++ ) { |
320 | entryName.sprintf( "File%i", i + 1 ); | 320 | entryName.sprintf( "File%i", i + 1 ); |
321 | list.append(cfg.readEntry( entryName )); | 321 | list.append(cfg.readEntry( entryName )); |
322 | } | 322 | } |
323 | list.sort(); | 323 | list.sort(); |
324 | box->insertStringList(list,-1); | 324 | box->insertStringList(list,-1); |
325 | doPopulate=false; | 325 | doPopulate=false; |
326 | update(); | 326 | update(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void NotesControl::load() { | 329 | void NotesControl::load() { |
330 | 330 | ||
331 | if(!loaded) { | 331 | if(!loaded) { |
332 | Config cfg("Notes"); | 332 | Config cfg("Notes"); |
333 | cfg.setGroup("Docs"); | 333 | cfg.setGroup("Docs"); |
334 | QString lastDoc=cfg.readEntry( "LastDoc","notes"); | 334 | QString lastDoc=cfg.readEntry( "LastDoc","notes"); |
335 | DocLnk nf; | 335 | DocLnk nf; |
336 | nf.setType("text/plain"); | 336 | nf.setType("text/plain"); |
337 | nf.setFile(lastDoc); | 337 | nf.setFile(lastDoc); |
338 | 338 | ||
339 | loadDoc(nf); | 339 | loadDoc(nf); |
340 | loaded=true; | 340 | loaded=true; |
341 | oldDocName=lastDoc; | 341 | oldDocName=lastDoc; |
342 | cfg.writeEntry( "LastDoc",oldDocName ); | 342 | cfg.writeEntry( "LastDoc",oldDocName ); |
343 | cfg.write(); | 343 | cfg.write(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | void NotesControl::load(const QString & file) { | 347 | void NotesControl::load(const QString & file) { |
348 | odebug << "loading "+file << oendl; | 348 | odebug << "loading "+file << oendl; |
349 | QString name = file; | 349 | QString name = file; |
350 | QString temp; | 350 | QString temp; |
351 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) | 351 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) |
352 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); | 352 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); |
353 | else | 353 | else |
354 | temp = name; | 354 | temp = name; |
355 | if(!loaded) { | 355 | if(!loaded) { |
356 | DocLnk nf; | 356 | DocLnk nf; |
357 | nf.setType("text/plain"); | 357 | nf.setType("text/plain"); |
358 | nf.setFile( temp); | 358 | nf.setFile( temp); |
359 | if(!temp.isEmpty()) | 359 | if(!temp.isEmpty()) |
360 | loadDoc(nf); | 360 | loadDoc(nf); |
361 | loaded=true; | 361 | loaded=true; |
362 | } | 362 | } |
363 | // view->setFocus(); | 363 | // view->setFocus(); |
364 | oldDocName=file; | 364 | oldDocName=file; |
365 | Config cfg("Notes"); | 365 | Config cfg("Notes"); |
366 | cfg.setGroup("Docs"); | 366 | cfg.setGroup("Docs"); |
367 | cfg.writeEntry( "LastDoc",oldDocName ); | 367 | cfg.writeEntry( "LastDoc",oldDocName ); |
368 | cfg.write(); | 368 | cfg.write(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void NotesControl::loadDoc( const DocLnk &f) { | 371 | void NotesControl::loadDoc( const DocLnk &f) { |
372 | FileManager fm; | 372 | FileManager fm; |
373 | QString txt; | 373 | QString txt; |
374 | if ( !fm.loadFile( f, txt ) ) { | 374 | if ( !fm.loadFile( f, txt ) ) { |
375 | odebug << "could not load file "+f.file() << oendl; | 375 | odebug << "could not load file "+f.file() << oendl; |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | view->setText(txt); | 378 | view->setText(txt); |
379 | } | 379 | } |
380 | 380 | ||
381 | void NotesControl::slotViewEdited() { | 381 | void NotesControl::slotViewEdited() { |
382 | if(loaded) { | 382 | if(loaded) { |
383 | edited=true; | 383 | edited=true; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | void NotesControl::slotShowMax() { | 388 | void NotesControl::slotShowMax() { |
389 | Config cfg("Notes"); | 389 | Config cfg("Notes"); |
390 | cfg.setGroup("Options"); | 390 | cfg.setGroup("Options"); |
391 | showMax=!showMax; | 391 | showMax=!showMax; |
392 | cfg.writeEntry("ShowMax", showMax); | 392 | cfg.writeEntry("ShowMax", showMax); |
393 | cfg.write(); | 393 | cfg.write(); |
394 | hide(); | 394 | hide(); |
395 | } | 395 | } |
396 | 396 | ||
397 | void NotesControl::slotSearch() { | 397 | void NotesControl::slotSearch() { |
398 | int boxCount = box->count(); | 398 | int boxCount = box->count(); |
399 | for(int i=0;i< boxCount;i++) { | 399 | for(int i=0;i< boxCount;i++) { |
400 | 400 | ||
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { | 404 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { |
405 | 405 | ||
406 | // switch ( e->state() ) { | 406 | // switch ( e->state() ) { |
407 | // case ControlButton: | 407 | // case ControlButton: |
408 | // if(e->key() == Key_C) { //copy | 408 | // if(e->key() == Key_C) { //copy |
409 | // odebug << "copy" << oendl; | 409 | // odebug << "copy" << oendl; |
410 | // QClipboard *cb = QApplication::clipboard(); | 410 | // QClipboard *cb = QApplication::clipboard(); |
411 | // QString text; | 411 | // QString text; |
412 | 412 | ||
413 | // // Copy text from the clipboard (paste) | 413 | // // Copy text from the clipboard (paste) |
414 | // text = cb->text(); | 414 | // text = cb->text(); |
415 | // } | 415 | // } |
416 | // if(e->key() == Key_X) { //cut | 416 | // if(e->key() == Key_X) { //cut |
417 | // } | 417 | // } |
418 | // if(e->key() == Key_V) { //paste | 418 | // if(e->key() == Key_V) { //paste |
419 | // QClipboard *cb = QApplication::clipboard(); | 419 | // QClipboard *cb = QApplication::clipboard(); |
420 | // QString text; | 420 | // QString text; |
421 | // //view | 421 | // //view |
422 | // cb->setText(); | 422 | // cb->setText(); |
423 | // } | 423 | // } |
424 | // break; | 424 | // break; |
425 | // }; | 425 | // }; |
426 | // QWidget::keyReleaseEvent(e); | 426 | // QWidget::keyReleaseEvent(e); |
427 | // } | 427 | // } |
428 | 428 | ||
429 | //=========================================================================== | 429 | //=========================================================================== |
430 | 430 | ||
431 | NotesApplet::NotesApplet( QWidget *parent, const char *name ) | 431 | NotesApplet::NotesApplet( QWidget *parent, const char *name ) |
432 | : QWidget( parent, name ) { | 432 | : QWidget( parent, name ) { |
433 | setFixedHeight( AppLnk::smallIconSize() ); | 433 | setFixedHeight( AppLnk::smallIconSize() ); |
434 | setFixedWidth( AppLnk::smallIconSize() ); | 434 | setFixedWidth( AppLnk::smallIconSize() ); |
435 | notesPixmap.convertFromImage( Resource::loadImage( "edit" ).smoothScale( height(), width() ) ); | 435 | notesPixmap = Opie::Core::OResource::loadImage( "edit", Opie::Core::OResource::SmallIcon ); |
436 | vc = new NotesControl; | 436 | vc = new NotesControl; |
437 | } | 437 | } |
438 | 438 | ||
439 | NotesApplet::~NotesApplet() { | 439 | NotesApplet::~NotesApplet() { |
440 | delete vc; | 440 | delete vc; |
441 | } | 441 | } |
442 | 442 | ||
443 | int NotesApplet::position() | 443 | int NotesApplet::position() |
444 | { | 444 | { |
445 | return 6; | 445 | return 6; |
446 | } | 446 | } |
447 | 447 | ||
448 | void NotesApplet::mousePressEvent( QMouseEvent *) { | 448 | void NotesApplet::mousePressEvent( QMouseEvent *) { |
449 | if( !vc->isHidden()) { | 449 | if( !vc->isHidden()) { |
450 | vc->doPopulate=false; | 450 | vc->doPopulate=false; |
451 | vc->save(); | 451 | vc->save(); |
452 | vc->close(); | 452 | vc->close(); |
453 | } else { | 453 | } else { |
454 | // vc = new NotesControl; | 454 | // vc = new NotesControl; |
455 | // QPoint curPos = mapToGlobal( rect().topLeft() ); | 455 | // QPoint curPos = mapToGlobal( rect().topLeft() ); |
456 | if(vc->showMax) { | 456 | if(vc->showMax) { |
457 | odebug << "show max" << oendl; | 457 | odebug << "show max" << oendl; |
458 | vc->showMaximized(); | 458 | vc->showMaximized(); |
459 | } else { | 459 | } else { |
460 | odebug << "no show max" << oendl; | 460 | odebug << "no show max" << oendl; |
461 | QWidget *wid = QPEApplication::desktop(); | 461 | QWidget *wid = QPEApplication::desktop(); |
462 | QRect rect = QApplication::desktop()->geometry(); | 462 | QRect rect = QApplication::desktop()->geometry(); |
463 | vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); | 463 | vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); |
464 | vc->move ( (rect.center()/2) - (vc->rect().center()/2)); | 464 | vc->move ( (rect.center()/2) - (vc->rect().center()/2)); |
465 | // vc->move( (( wid->width() / 2) - ( vc->width() / 2 ))-4, 28); | 465 | // vc->move( (( wid->width() / 2) - ( vc->width() / 2 ))-4, 28); |
466 | } | 466 | } |
467 | vc->show(); | 467 | vc->show(); |
468 | vc->doPopulate=true; | 468 | vc->doPopulate=true; |
469 | vc->populateBox(); | 469 | vc->populateBox(); |
470 | vc->doPopulate=false; | 470 | vc->doPopulate=false; |
471 | vc->loaded=false; | 471 | vc->loaded=false; |
472 | 472 | ||
473 | vc->load(); | 473 | vc->load(); |
474 | // this->setFocus(); | 474 | // this->setFocus(); |
475 | vc->view->setFocus(); | 475 | vc->view->setFocus(); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | void NotesApplet::paintEvent( QPaintEvent* ) { | 479 | void NotesApplet::paintEvent( QPaintEvent* ) { |
480 | QPainter p(this); | 480 | QPainter p(this); |
481 | p.drawPixmap( 0, 2, notesPixmap ); | 481 | p.drawPixmap( 0, 2, notesPixmap ); |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | EXPORT_OPIE_APPLET_v1( NotesApplet ) | 485 | EXPORT_OPIE_APPLET_v1( NotesApplet ) |
486 | 486 | ||
diff --git a/noncore/applets/pyquicklaunch/pyquicklaunch.cpp b/noncore/applets/pyquicklaunch/pyquicklaunch.cpp index bcd2f0d..45eda4e 100644 --- a/noncore/applets/pyquicklaunch/pyquicklaunch.cpp +++ b/noncore/applets/pyquicklaunch/pyquicklaunch.cpp | |||
@@ -1,155 +1,155 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@vanille.de> | 2 | ** Copyright (C) 2004 Michael 'Mickey' Lauer <mickey@vanille.de> |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "pyquicklaunch.h" | 15 | #include "pyquicklaunch.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/odebug.h> | 18 | #include <opie2/odebug.h> |
19 | #include <opie2/oresource.h> | ||
19 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
20 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
21 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/resource.h> | ||
23 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qcopchannel_qws.h> | 26 | #include <qcopchannel_qws.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | 31 | ||
32 | /* STD */ | 32 | /* STD */ |
33 | #include <pwd.h> | 33 | #include <pwd.h> |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <unistd.h> | 35 | #include <unistd.h> |
36 | 36 | ||
37 | PyQuicklaunchControl::PyQuicklaunchControl( PyQuicklaunchApplet *applet, QWidget *parent, const char *name ) | 37 | PyQuicklaunchControl::PyQuicklaunchControl( PyQuicklaunchApplet *applet, QWidget *parent, const char *name ) |
38 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) | 38 | : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) |
39 | { | 39 | { |
40 | 40 | ||
41 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 41 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
42 | setFixedSize( sizeHint() ); | 42 | setFixedSize( sizeHint() ); |
43 | setFocusPolicy( QWidget::NoFocus ); | 43 | setFocusPolicy( QWidget::NoFocus ); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | void PyQuicklaunchControl::show( bool ) | 47 | void PyQuicklaunchControl::show( bool ) |
48 | { | 48 | { |
49 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); | 49 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); |
50 | 50 | ||
51 | int w = sizeHint().width(); | 51 | int w = sizeHint().width(); |
52 | int x = curPos.x() - ( w / 2 ); | 52 | int x = curPos.x() - ( w / 2 ); |
53 | 53 | ||
54 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) | 54 | if ( ( x + w ) > QPEApplication::desktop() ->width() ) |
55 | x = QPEApplication::desktop ( ) -> width ( ) - w; | 55 | x = QPEApplication::desktop ( ) -> width ( ) - w; |
56 | 56 | ||
57 | move( x, curPos.y () - sizeHint().height () ); | 57 | move( x, curPos.y () - sizeHint().height () ); |
58 | QFrame::show(); | 58 | QFrame::show(); |
59 | } | 59 | } |
60 | 60 | ||
61 | void PyQuicklaunchControl::readConfig() | 61 | void PyQuicklaunchControl::readConfig() |
62 | { | 62 | { |
63 | Config cfg( "qpe" ); | 63 | Config cfg( "qpe" ); |
64 | cfg.setGroup( "PyQuicklaunch" ); | 64 | cfg.setGroup( "PyQuicklaunch" ); |
65 | 65 | ||
66 | // ... | 66 | // ... |
67 | } | 67 | } |
68 | 68 | ||
69 | void PyQuicklaunchControl::writeConfigEntry( const char *entry, int val ) | 69 | void PyQuicklaunchControl::writeConfigEntry( const char *entry, int val ) |
70 | { | 70 | { |
71 | Config cfg( "qpe" ); | 71 | Config cfg( "qpe" ); |
72 | cfg.setGroup( "PyQuicklaunch" ); | 72 | cfg.setGroup( "PyQuicklaunch" ); |
73 | cfg.writeEntry( entry, val ); | 73 | cfg.writeEntry( entry, val ); |
74 | } | 74 | } |
75 | 75 | ||
76 | //=========================================================================== | 76 | //=========================================================================== |
77 | 77 | ||
78 | PyQuicklaunchApplet::PyQuicklaunchApplet( QWidget *parent, const char *name ) | 78 | PyQuicklaunchApplet::PyQuicklaunchApplet( QWidget *parent, const char *name ) |
79 | : QWidget( parent, name ), online( false ) | 79 | : QWidget( parent, name ), online( false ) |
80 | { | 80 | { |
81 | setFixedHeight( 18 ); | 81 | setFixedHeight( 18 ); |
82 | setFixedWidth( 14 ); | 82 | setFixedWidth( 14 ); |
83 | status = new PyQuicklaunchControl( this, this, "Python Quicklaunch Status" ); | 83 | status = new PyQuicklaunchControl( this, this, "Python Quicklaunch Status" ); |
84 | 84 | ||
85 | _online = Resource::loadPixmap( "pyquicklaunch/online" ); | 85 | _online = Opie::Core::OResource::loadPixmap( "pyquicklaunch/online", Opie::Core::OResource::SmallIcon ); |
86 | _offline = Resource::loadPixmap( "pyquicklaunch/offline" ); | 86 | _offline = Opie::Core::OResource::loadPixmap( "pyquicklaunch/offline", Opie::Core::OResource::SmallIcon ); |
87 | 87 | ||
88 | _fifoName = QString().sprintf( "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name ); | 88 | _fifoName = QString().sprintf( "/tmp/mickeys-quicklauncher-%s", ::getpwuid( ::getuid() )->pw_name ); |
89 | odebug << "PyQuicklaunchApplet fifo name = '" << _fifoName << "'" << oendl; | 89 | odebug << "PyQuicklaunchApplet fifo name = '" << _fifoName << "'" << oendl; |
90 | _fifo.setName( _fifoName ); | 90 | _fifo.setName( _fifoName ); |
91 | 91 | ||
92 | _control = new QCopChannel( "QPE/PyLauncher", parent, "PyLauncher QCop Control Channel" ); | 92 | _control = new QCopChannel( "QPE/PyLauncher", parent, "PyLauncher QCop Control Channel" ); |
93 | connect( _control, SIGNAL(received(const QCString&,const QByteArray&)), | 93 | connect( _control, SIGNAL(received(const QCString&,const QByteArray&)), |
94 | this, SLOT(receivedMessage(const QCString&,const QByteArray&) ) ); | 94 | this, SLOT(receivedMessage(const QCString&,const QByteArray&) ) ); |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | PyQuicklaunchApplet::~PyQuicklaunchApplet() | 99 | PyQuicklaunchApplet::~PyQuicklaunchApplet() |
100 | { | 100 | { |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void PyQuicklaunchApplet::receivedMessage( const QCString& msg, const QByteArray& data ) | 104 | void PyQuicklaunchApplet::receivedMessage( const QCString& msg, const QByteArray& data ) |
105 | { | 105 | { |
106 | odebug << "receivedMessage = '" << msg << "' " << oendl; | 106 | odebug << "receivedMessage = '" << msg << "' " << oendl; |
107 | 107 | ||
108 | if ( msg == "setOnline()" ) | 108 | if ( msg == "setOnline()" ) |
109 | { | 109 | { |
110 | online = true; | 110 | online = true; |
111 | repaint( true ); | 111 | repaint( true ); |
112 | } | 112 | } |
113 | else if ( msg == "setOffline()" ) | 113 | else if ( msg == "setOffline()" ) |
114 | { | 114 | { |
115 | online = false; | 115 | online = false; |
116 | repaint( true ); | 116 | repaint( true ); |
117 | } | 117 | } |
118 | else | 118 | else |
119 | { | 119 | { |
120 | odebug << "unknown command." << oendl; | 120 | odebug << "unknown command." << oendl; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | void PyQuicklaunchApplet::timerEvent( QTimerEvent* ) | 125 | void PyQuicklaunchApplet::timerEvent( QTimerEvent* ) |
126 | { | 126 | { |
127 | bool nowOnline = _fifo.exists(); | 127 | bool nowOnline = _fifo.exists(); |
128 | if ( nowOnline != online ) | 128 | if ( nowOnline != online ) |
129 | { | 129 | { |
130 | online = nowOnline; | 130 | online = nowOnline; |
131 | repaint( true ); | 131 | repaint( true ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void PyQuicklaunchApplet::mousePressEvent( QMouseEvent * ) | 136 | void PyQuicklaunchApplet::mousePressEvent( QMouseEvent * ) |
137 | { | 137 | { |
138 | status->isVisible() ? status->hide() : status->show( true ); | 138 | status->isVisible() ? status->hide() : status->show( true ); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void PyQuicklaunchApplet::paintEvent( QPaintEvent* ) | 142 | void PyQuicklaunchApplet::paintEvent( QPaintEvent* ) |
143 | { | 143 | { |
144 | QPainter p( this ); | 144 | QPainter p( this ); |
145 | p.drawPixmap( 0, 2, online ? _online : _offline ); | 145 | p.drawPixmap( 0, 2, online ? _online : _offline ); |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | int PyQuicklaunchApplet::position() | 149 | int PyQuicklaunchApplet::position() |
150 | { | 150 | { |
151 | return 6; | 151 | return 6; |
152 | } | 152 | } |
153 | 153 | ||
154 | EXPORT_OPIE_APPLET_v1( PyQuicklaunchApplet ) | 154 | EXPORT_OPIE_APPLET_v1( PyQuicklaunchApplet ) |
155 | 155 | ||
diff --git a/noncore/applets/zkbapplet/applet/zkbwidget.cpp b/noncore/applets/zkbapplet/applet/zkbwidget.cpp index 55c08b3..324ccdc 100644 --- a/noncore/applets/zkbapplet/applet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/applet/zkbwidget.cpp | |||
@@ -1,160 +1,160 @@ | |||
1 | #include <opie2/otaskbarapplet.h> | 1 | #include <opie2/otaskbarapplet.h> |
2 | #include <opie2/okeyfilter.h> | 2 | #include <opie2/okeyfilter.h> |
3 | #include <opie2/oresource.h> | ||
3 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
4 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
5 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
6 | #include <qpe/resource.h> | 7 | //#include <stdio.h> |
7 | #include <stdio.h> | 8 | //#include <unistd.h> |
8 | #include <unistd.h> | ||
9 | #include "zkbwidget.h" | 9 | #include "zkbwidget.h" |
10 | #include "zkbcfg.h" | 10 | #include "zkbcfg.h" |
11 | 11 | ||
12 | using namespace Opie::Ui; | 12 | using namespace Opie::Ui; |
13 | 13 | ||
14 | ZkbWidget::ZkbWidget(QWidget* parent) | 14 | ZkbWidget::ZkbWidget(QWidget* parent) |
15 | :QLabel(parent),keymap(0),disabled(Resource::loadPixmap("zkb-disabled")) { | 15 | :QLabel(parent),keymap(0),disabled(Opie::Core::OResource::loadPixmap("zkb-disabled", Opie::Core::OResource::SmallIcon)) { |
16 | 16 | ||
17 | labels = new QPopupMenu(); | 17 | labels = new QPopupMenu(); |
18 | connect(labels, SIGNAL(activated(int)), this, | 18 | connect(labels, SIGNAL(activated(int)), this, |
19 | SLOT(labelChanged(int))); | 19 | SLOT(labelChanged(int))); |
20 | 20 | ||
21 | loadKeymap(); | 21 | loadKeymap(); |
22 | 22 | ||
23 | channel = new QCopChannel("QPE/zkb", this); | 23 | channel = new QCopChannel("QPE/zkb", this); |
24 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 24 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
25 | this, SLOT(signalReceived(const QCString&,const QByteArray&))); | 25 | this, SLOT(signalReceived(const QCString&,const QByteArray&))); |
26 | setFixedWidth ( AppLnk::smallIconSize() ); | 26 | setFixedWidth ( AppLnk::smallIconSize() ); |
27 | setFixedHeight ( AppLnk::smallIconSize() ); | 27 | setFixedHeight ( AppLnk::smallIconSize() ); |
28 | } | 28 | } |
29 | 29 | ||
30 | ZkbWidget::~ZkbWidget() | 30 | ZkbWidget::~ZkbWidget() |
31 | { | 31 | { |
32 | delete keymap; | 32 | delete keymap; |
33 | keymap = 0; | 33 | keymap = 0; |
34 | } | 34 | } |
35 | 35 | ||
36 | int ZkbWidget::position() | 36 | int ZkbWidget::position() |
37 | { | 37 | { |
38 | return 8; | 38 | return 8; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool ZkbWidget::loadKeymap() { | 41 | bool ZkbWidget::loadKeymap() { |
42 | ZkbConfig c(Global::applicationFileName("zkb", QString::null) ); | 42 | ZkbConfig c(Global::applicationFileName("zkb", QString::null) ); |
43 | QFontMetrics fm(font()); | 43 | QFontMetrics fm(font()); |
44 | 44 | ||
45 | delete keymap; | 45 | delete keymap; |
46 | keymap = 0; | 46 | keymap = 0; |
47 | 47 | ||
48 | Keymap* km = new Keymap(); | 48 | Keymap* km = new Keymap(); |
49 | 49 | ||
50 | if (!c.load("zkb.xml", *km, "")) { | 50 | if (!c.load("zkb.xml", *km, "")) { |
51 | delete km; | 51 | delete km; |
52 | setPixmap(disabled); | 52 | setPixmap(disabled); |
53 | return false; | 53 | return false; |
54 | } | 54 | } |
55 | 55 | ||
56 | connect(km, SIGNAL(stateChanged(const QString&)), | 56 | connect(km, SIGNAL(stateChanged(const QString&)), |
57 | this, SLOT(stateChanged(const QString&))); | 57 | this, SLOT(stateChanged(const QString&))); |
58 | 58 | ||
59 | Opie::Core::OKeyFilter::inst()->addHandler(km); | 59 | Opie::Core::OKeyFilter::inst()->addHandler(km); |
60 | 60 | ||
61 | Keymap* oldkm = keymap; | 61 | Keymap* oldkm = keymap; |
62 | keymap = km; | 62 | keymap = km; |
63 | 63 | ||
64 | if (oldkm != 0) { | 64 | if (oldkm != 0) { |
65 | delete oldkm; | 65 | delete oldkm; |
66 | } | 66 | } |
67 | 67 | ||
68 | QString ltext = keymap->getCurrentLabel(); | 68 | QString ltext = keymap->getCurrentLabel(); |
69 | if (ltext.length()==0) ltext = "??"; | 69 | if (ltext.length()==0) ltext = "??"; |
70 | setText(ltext); | 70 | setText(ltext); |
71 | 71 | ||
72 | labels->clear(); | 72 | labels->clear(); |
73 | QStringList l = keymap->listLabels(); | 73 | QStringList l = keymap->listLabels(); |
74 | labels->insertItem(disabled, 0, 0); | 74 | labels->insertItem(disabled, 0, 0); |
75 | int n = 1; | 75 | int n = 1; |
76 | w = 0; | 76 | w = 0; |
77 | for(QStringList::Iterator it = l.begin(); it != l.end(); | 77 | for(QStringList::Iterator it = l.begin(); it != l.end(); |
78 | ++it, n++) { | 78 | ++it, n++) { |
79 | 79 | ||
80 | // printf("label: %s\n", (const char*) (*it).utf8()); | 80 | // printf("label: %s\n", (const char*) (*it).utf8()); |
81 | 81 | ||
82 | labels->insertItem(*it, n, n); | 82 | labels->insertItem(*it, n, n); |
83 | int lw = fm.width(*it); | 83 | int lw = fm.width(*it); |
84 | if (lw > w) { | 84 | if (lw > w) { |
85 | w = lw; | 85 | w = lw; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | if (w == 0) { | 89 | if (w == 0) { |
90 | hide(); | 90 | hide(); |
91 | } else { | 91 | } else { |
92 | show(); | 92 | show(); |
93 | } | 93 | } |
94 | return true; | 94 | return true; |
95 | } | 95 | } |
96 | 96 | ||
97 | void ZkbWidget::stateChanged(const QString& s) { | 97 | void ZkbWidget::stateChanged(const QString& s) { |
98 | // odebug << "stateChanged: " << s.utf8() << "\n" << oendl; | 98 | // odebug << "stateChanged: " << s.utf8() << "\n" << oendl; |
99 | setText(s); | 99 | setText(s); |
100 | } | 100 | } |
101 | 101 | ||
102 | void ZkbWidget::labelChanged(int id) { | 102 | void ZkbWidget::labelChanged(int id) { |
103 | if (id == 0) { | 103 | if (id == 0) { |
104 | keymap->disable(); | 104 | keymap->disable(); |
105 | setPixmap(disabled); | 105 | setPixmap(disabled); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | 108 | ||
109 | keymap->enable(); | 109 | keymap->enable(); |
110 | 110 | ||
111 | QStringList l = keymap->listLabels(); | 111 | QStringList l = keymap->listLabels(); |
112 | QString lbl = l[id-1]; | 112 | QString lbl = l[id-1]; |
113 | 113 | ||
114 | // printf("labelChanged: %s\n", (const char*) lbl.utf8()); | 114 | // printf("labelChanged: %s\n", (const char*) lbl.utf8()); |
115 | State* state = keymap->getStateByLabel(lbl); | 115 | State* state = keymap->getStateByLabel(lbl); |
116 | if (state != 0) { | 116 | if (state != 0) { |
117 | keymap->setCurrentState(state); | 117 | keymap->setCurrentState(state); |
118 | setText(lbl); | 118 | setText(lbl); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { | 122 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { |
123 | QSize sh = labels->sizeHint(); | 123 | QSize sh = labels->sizeHint(); |
124 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); | 124 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); |
125 | labels->exec(p); | 125 | labels->exec(p); |
126 | } | 126 | } |
127 | 127 | ||
128 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { | 128 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { |
129 | QDataStream stream(data, IO_ReadOnly); | 129 | QDataStream stream(data, IO_ReadOnly); |
130 | 130 | ||
131 | if (msg == "enable()") { | 131 | if (msg == "enable()") { |
132 | keymap->enable(); | 132 | keymap->enable(); |
133 | } else if (msg == "disable()") { | 133 | } else if (msg == "disable()") { |
134 | keymap->disable(); | 134 | keymap->disable(); |
135 | } else if (msg == "reload()") { | 135 | } else if (msg == "reload()") { |
136 | QCopEnvelope("QPE/System", "busy()"); | 136 | QCopEnvelope("QPE/System", "busy()"); |
137 | QTimer::singleShot(0, this, SLOT(reload())); | 137 | QTimer::singleShot(0, this, SLOT(reload())); |
138 | } else if (msg == "switch(QString)") { | 138 | } else if (msg == "switch(QString)") { |
139 | QString lbl; | 139 | QString lbl; |
140 | stream >> lbl; | 140 | stream >> lbl; |
141 | 141 | ||
142 | if (keymap != 0) { | 142 | if (keymap != 0) { |
143 | State* state = keymap->getStateByLabel(lbl); | 143 | State* state = keymap->getStateByLabel(lbl); |
144 | if (state != 0) { | 144 | if (state != 0) { |
145 | keymap->setCurrentState(state); | 145 | keymap->setCurrentState(state); |
146 | setText(lbl); | 146 | setText(lbl); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } else if (msg == "debug(QString)") { | 149 | } else if (msg == "debug(QString)") { |
150 | QString flag; | 150 | QString flag; |
151 | stream >> flag; | 151 | stream >> flag; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | void ZkbWidget::reload() { | 155 | void ZkbWidget::reload() { |
156 | loadKeymap(); | 156 | loadKeymap(); |
157 | QCopEnvelope("QPE/System", "notBusy()"); | 157 | QCopEnvelope("QPE/System", "notBusy()"); |
158 | } | 158 | } |
159 | 159 | ||
160 | EXPORT_OPIE_APPLET_v1( ZkbWidget ) | 160 | EXPORT_OPIE_APPLET_v1( ZkbWidget ) |