author | harlekin <harlekin> | 2002-06-22 22:25:56 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-22 22:25:56 (UTC) |
commit | b6f6bab5e56f352a4f71dadb40530d6cdcaea3cc (patch) (unidiff) | |
tree | b58cfac35b73d8a85944b42aad3344dee0a979a2 | |
parent | dc0bab1611d87c39d3729aa05d8b01f639120052 (diff) | |
download | opie-b6f6bab5e56f352a4f71dadb40530d6cdcaea3cc.zip opie-b6f6bab5e56f352a4f71dadb40530d6cdcaea3cc.tar.gz opie-b6f6bab5e56f352a4f71dadb40530d6cdcaea3cc.tar.bz2 |
nicer card inserted popup + cleanups
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 45 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.h | 7 |
2 files changed, 40 insertions, 12 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index ac2aea2..3dd9f54 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -26,5 +26,5 @@ | |||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qpopupmenu.h> | ||
28 | #include <qfile.h> | 27 | #include <qfile.h> |
29 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qtimer.h> | ||
30 | 30 | ||
@@ -56,2 +56,4 @@ CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), | |||
56 | repaint(FALSE); | 56 | repaint(FALSE); |
57 | popUpMenu = 0; | ||
58 | popUpMenuTimer = 0; | ||
57 | } | 59 | } |
@@ -61,2 +63,28 @@ CardMonitor::~CardMonitor() { | |||
61 | 63 | ||
64 | void CardMonitor::popUp(QString message) { | ||
65 | if ( ! popUpMenu ) { | ||
66 | popUpMenu = new QPopupMenu(); | ||
67 | } | ||
68 | popUpMenu->clear(); | ||
69 | popUpMenu->insertItem( message, 0 ); | ||
70 | |||
71 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | ||
72 | QSize s = popUpMenu->sizeHint ( ); | ||
73 | popUpMenu->popup( QPoint ( | ||
74 | p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | ||
75 | p. y ( ) - s. height ( ) ), 0); | ||
76 | |||
77 | if ( ! popUpMenuTimer ) { | ||
78 | popUpMenuTimer = new QTimer( this ); | ||
79 | connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) ); | ||
80 | } | ||
81 | timerEvent(0); | ||
82 | popUpMenuTimer->start( 2000 ); | ||
83 | } | ||
84 | |||
85 | void CardMonitor::popUpTimeout() { | ||
86 | popUpMenu->hide(); | ||
87 | popUpMenuTimer->stop(); | ||
88 | } | ||
89 | |||
62 | void CardMonitor::mousePressEvent( QMouseEvent * ) { | 90 | void CardMonitor::mousePressEvent( QMouseEvent * ) { |
@@ -90,4 +118,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
90 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); | 118 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); |
91 | QMessageBox::warning( this, tr("CardMonitor"), tr("CF/PCMCIA card eject failed!"), | 119 | popUp( tr("CF/PCMCIA card eject failed!")); |
92 | tr("&OK") ); | ||
93 | } | 120 | } |
@@ -98,4 +125,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
98 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); | 125 | qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); |
99 | QMessageBox::warning( this, tr("CardMonitor"), tr("SD/MMC card eject failed!"), | 126 | popUp( tr("SD/MMC card eject failed!")); |
100 | tr("&OK") ); | ||
101 | } | 127 | } |
@@ -106,4 +132,3 @@ void CardMonitor::mousePressEvent( QMouseEvent * ) { | |||
106 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); | 132 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); |
107 | QMessageBox::warning( this, tr("CardMonitor"), tr("CF/PCMCIA card eject failed!"), | 133 | popUp( tr("CF/PCMCIA card eject failed!")); |
108 | tr("&OK") ); | ||
109 | } | 134 | } |
@@ -203,4 +228,3 @@ bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) { | |||
203 | } | 228 | } |
204 | QMessageBox::warning( this, tr("CardMonitor"), text, | 229 | popUp( text ); |
205 | tr("&OK") ); | ||
206 | } | 230 | } |
@@ -235,4 +259,3 @@ bool CardMonitor::getStatusSd( int showPopUp = FALSE ) { | |||
235 | else { text += "SD Removed"; } | 259 | else { text += "SD Removed"; } |
236 | QMessageBox::warning( this, tr("CardMonitor"), text, | 260 | popUp( text ); |
237 | tr("&OK") ); | ||
238 | } | 261 | } |
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h index f9e3819..34b8d95 100644 --- a/core/applets/cardmon/cardmon.h +++ b/core/applets/cardmon/cardmon.h | |||
@@ -23,2 +23,4 @@ | |||
23 | #include <qpixmap.h> | 23 | #include <qpixmap.h> |
24 | #include <qpopupmenu.h> | ||
25 | #include <qtimer.h> | ||
24 | 26 | ||
@@ -34,2 +36,3 @@ private slots: | |||
34 | void cardMessage( const QCString &msg, const QByteArray & ); | 36 | void cardMessage( const QCString &msg, const QByteArray & ); |
37 | void popUpTimeout(); | ||
35 | 38 | ||
@@ -40,2 +43,4 @@ private: | |||
40 | QPixmap pm; | 43 | QPixmap pm; |
44 | QPopupMenu *popUpMenu; | ||
45 | QTimer *popUpMenuTimer; | ||
41 | // pcmcia socket 0 | 46 | // pcmcia socket 0 |
@@ -48,3 +53,3 @@ private: | |||
48 | void iconShow(); | 53 | void iconShow(); |
49 | 54 | void popUp(QString message); | |
50 | }; | 55 | }; |