From bd0f3345a938b35ce6a12f6150373b0955b8dd12 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:24:15 -0500 Subject: Add Qt3 development HEAD version --- doc/html/biff-example.html | 198 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 doc/html/biff-example.html (limited to 'doc/html/biff-example.html') diff --git a/doc/html/biff-example.html b/doc/html/biff-example.html new file mode 100644 index 0000000..6a9fc9e --- /dev/null +++ b/doc/html/biff-example.html @@ -0,0 +1,198 @@ + + + + + +Biff (UNIX only) + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

Biff (UNIX only)

+ + +

+Biff is a simple graphical program to indicate whether there is new +mail; it looks exactly like xbiff but is much shorter. +


+

Header file: +

/****************************************************************************
+** $Id: qt/biff.h   3.3.8   edited Jan 11 14:37 $
+**
+** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
+**
+** This file is part of an example program for Qt.  This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef BIFF_H
+#define BIFF_H
+
+#include <qwidget.h>
+#include <qdatetime.h>
+#include <qpixmap.h>
+
+
+class Biff : public QWidget
+{
+    Q_OBJECT
+public:
+    Biff( QWidget *parent=0, const char *name=0 );
+
+protected:
+    void        timerEvent( QTimerEvent * );
+    void        paintEvent( QPaintEvent * );
+    void        mousePressEvent( QMouseEvent * );
+
+private:
+    QDateTime   lastModified;
+    QPixmap     hasNewMail;
+    QPixmap     noNewMail;
+    QString     mailbox;
+    bool        gotMail;
+};
+
+
+#endif // BIFF_H
+
+ +


+

biff.cpp implements this custom widget. Note in particular +how two images (hasmail_bmp_data and nomail_bmp_data, both from +bmp.cpp) are included into the executable. +

/****************************************************************************
+** $Id: qt/biff.cpp   3.3.8   edited Jan 11 14:37 $
+**
+** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
+**
+** This file is part of an example program for Qt.  This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "biff.h"
+#include <qstring.h>
+#include <qfileinfo.h>
+#include <qpainter.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "bmp.cpp"
+
+
+Biff::Biff( QWidget *parent, const char *name )
+    : QWidget( parent, name, WShowModal | WType_Dialog )
+{
+    QFileInfo fi = QString(getenv( "MAIL" ));
+    if ( !fi.exists() ) {
+        QString s( "/var/spool/mail/" );
+        s += getlogin();
+        fi.setFile( s );
+    }
+
+    if ( fi.exists() ) {
+        mailbox = fi.absFilePath();
+        startTimer( 1000 );
+    }
+
+    setMinimumSize( 48, 48 );
+    setMaximumSize( 48, 48 );
+    resize( 48, 48 );
+
+    hasNewMail.loadFromData( hasmail_bmp_data, hasmail_bmp_len );
+    noNewMail.loadFromData( nomail_bmp_data, nomail_bmp_len );
+
+    gotMail = FALSE;
+    lastModified = fi.lastModified();
+}
+
+
+void Biff::timerEvent( QTimerEvent * )
+{
+    QFileInfo fi( mailbox );
+    bool newState = ( fi.lastModified() != lastModified &&
+                      fi.lastModified() > fi.lastRead() );
+    if ( newState != gotMail ) {
+        if ( gotMail )
+            lastModified = fi.lastModified();
+        gotMail = newState;
+        repaint( FALSE );
+    }
+}
+
+
+void Biff::paintEvent( QPaintEvent * )
+{
+    if ( gotMail )
+        bitBlt( this, 0, 0, &hasNewMail );
+    else
+        bitBlt( this, 0, 0, &noNewMail );
+}
+
+
+void Biff::mousePressEvent( QMouseEvent * )
+{
+    QFileInfo fi( mailbox );
+    lastModified = fi.lastModified();
+}
+
+ +


+

Main: +

/****************************************************************************
+** $Id: qt/main.cpp   3.3.8   edited Jan 11 14:37 $
+**
+** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
+**
+** This file is part of an example program for Qt.  This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qapplication.h>
+#include "biff.h"
+
+
+int main( int argc, char ** argv )
+{
+    QApplication a( argc, argv );
+    Biff b;
+    a.setMainWidget( &b );
+    b.show();
+    return a.exec();
+}
+
+ +

See also Examples. + + +


+ +
Copyright © 2007 +TrolltechTrademarks +
Qt 3.3.8
+
+ -- cgit v1.2.3