summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-14 12:14:02 (UTC)
committer alwin <alwin>2004-03-14 12:14:02 (UTC)
commitb329ada89fda307618f2d6161c249f46cae3e029 (patch) (unidiff)
treed3e1c2f6ded77f327a47c4fe4ac23ecce2ecdc34
parent3e260630413b00d145f48b5ede85530743fd095e (diff)
downloadopie-b329ada89fda307618f2d6161c249f46cae3e029.zip
opie-b329ada89fda307618f2d6161c249f46cae3e029.tar.gz
opie-b329ada89fda307618f2d6161c249f46cae3e029.tar.bz2
namespace fix
Must reviewed 'cause it uses stuff from Private namespace!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index e8072c6..6090b68 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -1,112 +1,115 @@
1/* 1/*
2* cardmon.cpp 2* cardmon.cpp
3* 3*
4* --------------------- 4* ---------------------
5* 5*
6* copyright : (c) 2002 by Maximilian Reiss 6* copyright : (c) 2002 by Maximilian Reiss
7* email : max.reiss@gmx.de 7* email : max.reiss@gmx.de
8* based on two apps by Devin Butterfield 8* based on two apps by Devin Butterfield
9*/ 9*/
10/*************************************************************************** 10/***************************************************************************
11 * * 11 * *
12 * This program is free software; you can redistribute it and/or modify * 12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by * 13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or * 14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. * 15 * (at your option) any later version. *
16 * * 16 * *
17 ***************************************************************************/ 17 ***************************************************************************/
18 18
19#include "cardmon.h" 19#include "cardmon.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <opie2/odevice.h> 22#include <opie2/odevice.h>
23#include <opie2/otaskbarapplet.h> 23#include <opie2/otaskbarapplet.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26 26
27/* QT */ 27/* QT */
28#include <qcopchannel_qws.h> 28#include <qcopchannel_qws.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qsound.h> 32#include <qsound.h>
33#include <qtimer.h> 33#include <qtimer.h>
34 34
35/* STD */ 35/* STD */
36#include <stdio.h> 36#include <stdio.h>
37#include <unistd.h> 37#include <unistd.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <string.h> 39#include <string.h>
40#include <fcntl.h> 40#include <fcntl.h>
41 41
42#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 42#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
43#include <sys/vfs.h> 43#include <sys/vfs.h>
44#include <mntent.h> 44#include <mntent.h>
45#endif 45#endif
46 46
47using namespace Opie; 47using namespace Opie;
48 48
49using namespace Opie::Ui;
50using namespace Opie::Core;
51
49CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), 52CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ),
50 pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) 53 pm( Resource::loadPixmap( "cardmon/pcmcia" ) )
51{ 54{
52 55
53 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); 56 QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
54 connect( pcmciaChannel, 57 connect( pcmciaChannel,
55 SIGNAL( received(const QCString&,const QByteArray&) ), this, 58 SIGNAL( received(const QCString&,const QByteArray&) ), this,
56 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 59 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
57 60
58 QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); 61 QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this );
59 connect( sdChannel, 62 connect( sdChannel,
60 SIGNAL( received(const QCString&,const QByteArray&) ), this, 63 SIGNAL( received(const QCString&,const QByteArray&) ), this,
61 SLOT( cardMessage(const QCString&,const QByteArray&) ) ); 64 SLOT( cardMessage(const QCString&,const QByteArray&) ) );
62 65
63 cardInPcmcia0 = FALSE; 66 cardInPcmcia0 = FALSE;
64 cardInPcmcia1 = FALSE; 67 cardInPcmcia1 = FALSE;
65 cardInSd = FALSE; 68 cardInSd = FALSE;
66 69
67 setFocusPolicy( NoFocus ); 70 setFocusPolicy( NoFocus );
68 71
69 setFixedWidth ( AppLnk::smallIconSize() ); 72 setFixedWidth ( AppLnk::smallIconSize() );
70 setFixedHeight ( AppLnk::smallIconSize() ); 73 setFixedHeight ( AppLnk::smallIconSize() );
71 74
72 getStatusPcmcia( TRUE ); 75 getStatusPcmcia( TRUE );
73 getStatusSd( TRUE ); 76 getStatusSd( TRUE );
74 repaint( FALSE ); 77 repaint( FALSE );
75 popupMenu = 0; 78 popupMenu = 0;
76} 79}
77 80
78CardMonitor::~CardMonitor() 81CardMonitor::~CardMonitor()
79{ 82{
80 if ( popupMenu ) 83 if ( popupMenu )
81 { 84 {
82 delete popupMenu; 85 delete popupMenu;
83 } 86 }
84} 87}
85 88
86void CardMonitor::popUp( QString message, QString icon ) 89void CardMonitor::popUp( QString message, QString icon )
87{ 90{
88 if ( !popupMenu ) 91 if ( !popupMenu )
89 { 92 {
90 popupMenu = new QPopupMenu( this ); 93 popupMenu = new QPopupMenu( this );
91 } 94 }
92 95
93 popupMenu->clear(); 96 popupMenu->clear();
94 if ( icon.isEmpty() ) 97 if ( icon.isEmpty() )
95 { 98 {
96 popupMenu->insertItem( message, 0 ); 99 popupMenu->insertItem( message, 0 );
97 } 100 }
98 else 101 else
99 { 102 {
100 popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), 103 popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ),
101 message, 0 ); 104 message, 0 );
102 } 105 }
103 106
104 QPoint p = mapToGlobal( QPoint( 0, 0 ) ); 107 QPoint p = mapToGlobal( QPoint( 0, 0 ) );
105 QSize s = popupMenu->sizeHint(); 108 QSize s = popupMenu->sizeHint();
106 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), 109 popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
107 p.y() - s.height() ), 0 ); 110 p.y() - s.height() ), 0 );
108 111
109 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); 112 QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
110} 113}
111 114
112void CardMonitor::popupTimeout() 115void CardMonitor::popupTimeout()
@@ -357,67 +360,67 @@ bool CardMonitor::getStatusSd( int showPopUp )
357 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" 360 if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd"
358 || fs.left( 9 ) == "/dev/mmcd" ) 361 || fs.left( 9 ) == "/dev/mmcd" )
359 { 362 {
360 cardInSd = TRUE; 363 cardInSd = TRUE;
361 show(); 364 show();
362 } 365 }
363 // else { 366 // else {
364 // cardInSd = FALSE; 367 // cardInSd = FALSE;
365 // } 368 // }
366 } 369 }
367 endmntent( mntfp ); 370 endmntent( mntfp );
368 } 371 }
369 372
370 if ( !showPopUp && cardWas != cardInSd ) 373 if ( !showPopUp && cardWas != cardInSd )
371 { 374 {
372 QString text = QString::null; 375 QString text = QString::null;
373 QString what = QString::null; 376 QString what = QString::null;
374 if ( cardInSd ) 377 if ( cardInSd )
375 { 378 {
376 text += "New card: SD/MMC"; 379 text += "New card: SD/MMC";
377 what = "on"; 380 what = "on";
378 } 381 }
379 else 382 else
380 { 383 {
381 text += "Ejected: SD/MMC"; 384 text += "Ejected: SD/MMC";
382 what = "off"; 385 what = "off";
383 } 386 }
384 //qDebug("TEXT: " + text ); 387 //qDebug("TEXT: " + text );
385#ifndef QT_NO_SOUND 388#ifndef QT_NO_SOUND
386 QSound::play( Resource::findSound( "cardmon/card" + what ) ); 389 QSound::play( Resource::findSound( "cardmon/card" + what ) );
387#endif 390#endif
388 popUp( text, "cardmon/ide" );// XX add SD pic 391 popUp( text, "cardmon/ide" );// XX add SD pic
389 } 392 }
390#else 393#else
391#error "Not on Linux" 394#error "Not on Linux"
392#endif 395#endif
393 repaint( FALSE ); 396 repaint( FALSE );
394 return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); 397 return ( ( cardWas == cardInSd ) ? FALSE : TRUE );
395} 398}
396 399
397void CardMonitor::paintEvent( QPaintEvent * ) 400void CardMonitor::paintEvent( QPaintEvent * )
398{ 401{
399 402
400 QPainter p( this ); 403 QPainter p( this );
401 404
402 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) 405 if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd )
403 { 406 {
404 p.drawPixmap( 0, 0, pm ); 407 p.drawPixmap( 0, 0, pm );
405 show(); 408 show();
406 } 409 }
407 else 410 else
408 { 411 {
409 //p.eraseRect(rect()); 412 //p.eraseRect(rect());
410 hide(); 413 hide();
411 } 414 }
412} 415}
413 416
414int CardMonitor::position() 417int CardMonitor::position()
415{ 418{
416 return 7; 419 return 7;
417} 420}
418 421
419Q_EXPORT_INTERFACE() 422Q_EXPORT_INTERFACE()
420{ 423{
421 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<CardMonitor> ); 424 Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<CardMonitor> );
422} 425}
423 426