summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/biff/Biff.java
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtjava/javalib/examples/biff/Biff.java
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtjava/javalib/examples/biff/Biff.java')
-rw-r--r--qtjava/javalib/examples/biff/Biff.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/qtjava/javalib/examples/biff/Biff.java b/qtjava/javalib/examples/biff/Biff.java
new file mode 100644
index 00000000..b3107da4
--- /dev/null
+++ b/qtjava/javalib/examples/biff/Biff.java
@@ -0,0 +1,80 @@
+/***************************************************************************
+* $Id$
+**
+* Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+* This file is part of an example program for Qt. This example
+* program may be used, distributed and modified without limitation.
+**
+****************************************************************************/
+import org.kde.qt.*;
+import java.util.Calendar;
+
+class Biff extends QWidget
+{
+private Calendar lastModified;
+private QPixmap hasNewMail = new QPixmap();
+private QPixmap noNewMail = new QPixmap();
+private String mailbox;
+private boolean gotMail;
+
+public Biff( )
+{
+ this(null, null);
+}
+public Biff( QWidget parent, String name )
+{
+ super( parent, name, WType_Modal );
+// QFileInfo fi = new QFileInfo(System.getProperty("MAIL"));
+ QFileInfo fi = new QFileInfo("");
+ if ( !fi.exists() ) {
+ String s = "/var/spool/mail/";
+ s += System.getProperty("user.name");
+ fi.setFile( s );
+ }
+ if ( fi.exists() ) {
+ mailbox = fi.absFilePath();
+ startTimer( 1000 );
+ }
+
+ setMinimumSize( 48, 48 );
+ setMaximumSize( 48, 48 );
+ resize( 48, 48 );
+
+ hasNewMail.loadFromData( bmp.hasmail_bmp_data );
+ noNewMail.loadFromData( bmp.nomail_bmp_data );
+
+ gotMail = false;
+ lastModified = fi.lastModified();
+}
+
+
+protected void timerEvent( QTimerEvent event )
+{
+ QFileInfo fi = new QFileInfo( mailbox );
+ boolean newState = ( fi.lastModified() != lastModified &&
+ fi.lastModified().after( fi.lastRead() ) );
+ if ( newState != gotMail ) {
+ if ( gotMail )
+ lastModified = fi.lastModified();
+ gotMail = newState;
+ repaint( false );
+ }
+}
+
+
+protected void paintEvent( QPaintEvent event )
+{
+ if ( gotMail )
+ bitBlt( this, 0, 0, hasNewMail );
+ else
+ bitBlt( this, 0, 0, noNewMail );
+}
+
+
+protected void mousePressEvent( QMouseEvent event )
+{
+ QFileInfo fi = new QFileInfo( mailbox );
+ lastModified = fi.lastModified();
+}
+}