summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-01 19:19:37 (UTC)
committer mickeyl <mickeyl>2004-03-01 19:19:37 (UTC)
commitddc3d749af5f7afebf69488b79641771fe246b5b (patch) (side-by-side diff)
tree8ea8614906c568e4677493ef09040724d60dd2d4
parentfb0981f47e529f9d1dd77fa005ffa3c3ecedff67 (diff)
downloadopie-ddc3d749af5f7afebf69488b79641771fe246b5b.zip
opie-ddc3d749af5f7afebf69488b79641771fe246b5b.tar.gz
opie-ddc3d749af5f7afebf69488b79641771fe246b5b.tar.bz2
remove duplicated boiler plate code in favour of the OTaskbarApplet template
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp11
-rw-r--r--core/applets/clipboardapplet/clipboard.h1
-rw-r--r--core/applets/clipboardapplet/clipboardapplet.pro4
-rw-r--r--core/applets/clipboardapplet/clipboardappletimpl.cpp66
-rw-r--r--core/applets/clipboardapplet/clipboardappletimpl.h43
-rw-r--r--core/applets/clockapplet/clock.cpp12
-rw-r--r--core/applets/clockapplet/clock.h1
-rw-r--r--core/applets/clockapplet/clockapplet.pro4
-rw-r--r--core/applets/clockapplet/clockappletimpl.cpp67
-rw-r--r--core/applets/clockapplet/clockappletimpl.h45
-rw-r--r--core/applets/irdaapplet/irda.cpp17
-rw-r--r--core/applets/irdaapplet/irda.h1
-rw-r--r--core/applets/irdaapplet/irdaapplet.pro14
-rw-r--r--core/applets/irdaapplet/irdaappletimpl.cpp66
-rw-r--r--core/applets/irdaapplet/irdaappletimpl.h45
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp25
-rw-r--r--core/applets/screenshotapplet/screenshot.h1
-rw-r--r--core/applets/screenshotapplet/screenshotapplet.pro6
-rw-r--r--core/applets/screenshotapplet/screenshotappletimpl.cpp66
-rw-r--r--core/applets/screenshotapplet/screenshotappletimpl.h43
-rw-r--r--core/applets/vmemo/vmemo.cpp12
-rw-r--r--core/applets/vmemo/vmemo.h1
-rw-r--r--core/applets/vmemo/vmemo.pro4
-rw-r--r--core/applets/vmemo/vmemoimpl.cpp61
-rw-r--r--core/applets/vmemo/vmemoimpl.h40
-rw-r--r--core/applets/volumeapplet/volume.cpp20
-rw-r--r--core/applets/volumeapplet/volume.h1
-rw-r--r--core/applets/volumeapplet/volumeapplet.pro4
-rw-r--r--core/applets/volumeapplet/volumeappletimpl.cpp65
-rw-r--r--core/applets/volumeapplet/volumeappletimpl.h43
-rw-r--r--core/obex/obex.pro6
31 files changed, 107 insertions, 688 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index bb0db9b..34d151e 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,178 +1,189 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "clipboard.h"
+#include <opie2/otaskbarapplet.h>
#include <qpe/resource.h>
#include <qpe/applnk.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qwindowsystem_qws.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qtimer.h>
//===========================================================================
ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
{
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize() );
QImage img = Resource::loadImage( "paste");
img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
m_clipboardPixmap.convertFromImage( img );
m_timer = new QTimer ( this );
connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
m_menu = 0;
m_dirty = true;
m_lasttext = QString::null;
m_timer-> start ( 0, true );
}
ClipboardApplet::~ClipboardApplet ( )
{
}
+int ClipboardApplet::position()
+{
+ return 6;
+}
+
void ClipboardApplet::shutdown ( )
{
// the timer has to be stopped, or Qt/E will hang on quit()
// see launcher/desktop.cpp
m_timer-> stop ( );
}
void ClipboardApplet::mousePressEvent ( QMouseEvent *)
{
if ( m_dirty ) {
delete m_menu;
m_menu = new QPopupMenu ( this );
m_menu-> setCheckable ( true );
if ( m_history. count ( )) {
for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
QString str = m_history [i];
if ( str. length ( ) > 20 )
str = str. left ( 20 ) + "...";
m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
m_menu-> setItemChecked ( i, false );
}
m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
m_menu-> insertSeparator ( );
}
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
m_dirty = false;
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
QSize s = m_menu-> sizeHint ( );
m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
}
void ClipboardApplet::action(int id)
{
ushort unicode = 0;
int scan = 0;
switch ( id ) {
case 100:
unicode = 'X' - '@';
scan = Key_X; // Cut
break;
case 101:
unicode = 'C' - '@';
scan = Key_C; // Copy
break;
case 102:
unicode = 'V' - '@';
scan = Key_V; // Paste
break;
default:
if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
QApplication::clipboard ( )-> setText ( m_history [id] );
for ( uint i = 0; i < m_history. count ( ); i++ )
m_menu-> setItemChecked ( i, i == uint( id ));
unicode = 'V' - '@';
scan = Key_V;
}
break;
}
if ( scan ) {
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
}
}
void ClipboardApplet::paintEvent ( QPaintEvent* )
{
QPainter p ( this );
/* center the height but our pixmap is as big as the height ;)*/
p. drawPixmap( 0, 0,
m_clipboardPixmap );
}
void ClipboardApplet::newData ( )
{
static bool excllock = false;
if ( excllock )
return;
else
excllock = true;
m_timer-> stop ( );
QCString type = "plain";
QString txt = QApplication::clipboard ( )-> text ( type );
if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
m_history. append ( txt );
if ( m_history. count ( ) > 5 )
m_history. remove ( m_history. begin ( ));
m_dirty = true;
}
m_timer-> start ( 1500, true );
excllock = false;
}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> );
+}
diff --git a/core/applets/clipboardapplet/clipboard.h b/core/applets/clipboardapplet/clipboard.h
index ec87d39..bbda0ff 100644
--- a/core/applets/clipboardapplet/clipboard.h
+++ b/core/applets/clipboardapplet/clipboard.h
@@ -1,57 +1,58 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef __CLIPBOARD_APPLET_H__
#define __CLIPBOARD_APPLET_H__
#include <qwidget.h>
#include <qpixmap.h>
#include <qstringlist.h>
class QTimer;
class ClipboardApplet : public QWidget
{
Q_OBJECT
public:
ClipboardApplet ( QWidget *parent = 0, const char *name=0 );
~ClipboardApplet ( );
+ static int position();
protected:
void mousePressEvent ( QMouseEvent *);
void paintEvent ( QPaintEvent* );
private slots:
void action ( int );
void newData ( );
void shutdown ( );
private:
QPopupMenu * m_menu;
QStringList m_history;
bool m_dirty;
QString m_lasttext;
QTimer * m_timer;
QPixmap m_clipboardPixmap;
};
#endif // __CLIPBOARD_APPLET_H__
diff --git a/core/applets/clipboardapplet/clipboardapplet.pro b/core/applets/clipboardapplet/clipboardapplet.pro
index f6842a2..74cf48c 100644
--- a/core/applets/clipboardapplet/clipboardapplet.pro
+++ b/core/applets/clipboardapplet/clipboardapplet.pro
@@ -1,13 +1,13 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = clipboard.h clipboardappletimpl.h
-SOURCES = clipboard.cpp clipboardappletimpl.cpp
+HEADERS = clipboard.h
+SOURCES = clipboard.cpp
TARGET = clipboardapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/clipboardapplet/clipboardappletimpl.cpp b/core/applets/clipboardapplet/clipboardappletimpl.cpp
deleted file mode 100644
index f454529..0000000
--- a/core/applets/clipboardapplet/clipboardappletimpl.cpp
+++ b/dev/null
@@ -1,66 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#include "clipboard.h"
-#include "clipboardappletimpl.h"
-
-
-ClipboardAppletImpl::ClipboardAppletImpl()
- : clipboard(0)
-{
-}
-
-ClipboardAppletImpl::~ClipboardAppletImpl()
-{
- delete clipboard;
-}
-
-QWidget *ClipboardAppletImpl::applet( QWidget *parent )
-{
- if ( !clipboard )
- clipboard = new ClipboardApplet( parent );
- return clipboard;
-}
-
-int ClipboardAppletImpl::position() const
-{
- return 6;
-}
-
-QRESULT ClipboardAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( ClipboardAppletImpl )
-}
-
-
diff --git a/core/applets/clipboardapplet/clipboardappletimpl.h b/core/applets/clipboardapplet/clipboardappletimpl.h
deleted file mode 100644
index 497360c..0000000
--- a/core/applets/clipboardapplet/clipboardappletimpl.h
+++ b/dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef CLIPBOARDAPPLETIMPL_H
-#define CLIPBOARDAPPLETIMPL_H
-
-#include <qpe/taskbarappletinterface.h>
-
-class ClipboardApplet;
-
-class ClipboardAppletImpl : public TaskbarAppletInterface
-{
-public:
- ClipboardAppletImpl();
- virtual ~ClipboardAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- ClipboardApplet *clipboard;
-};
-
-#endif
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp
index aadd9b6..9fead03 100644
--- a/core/applets/clockapplet/clock.cpp
+++ b/core/applets/clockapplet/clock.cpp
@@ -1,109 +1,121 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "clock.h"
+#include <opie2/otaskbarapplet.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent )
{
// If you want a sunken border around the clock do this:
// setFrameStyle( QFrame::Panel | QFrame::Sunken );
//setFont( QFont( "Helvetica", , QFont::Normal ) );
connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) );
connect( qApp, SIGNAL( clockChanged( bool ) ),
this, SLOT( slotClockChanged( bool ) ) );
readConfig();
timerId = 0;
timerEvent( 0 );
show();
}
+int LauncherClock::position()
+{
+ return 10;
+}
+
void LauncherClock::readConfig() {
Config config( "qpe" );
config.setGroup( "Time" );
ampmFormat = config.readBoolEntry( "AMPM", TRUE );
config.setGroup( "Date" );
format = config.readNumEntry("ClockApplet",0);
}
void LauncherClock::mouseReleaseEvent( QMouseEvent * )
{
QCString setTimeApp;
setTimeApp="systemtime";
QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()");
}
void LauncherClock::timerEvent( QTimerEvent *e )
{
if ( !e || e->timerId() == timerId ) {
killTimer( timerId );
changeTime();
QTime t = QTime::currentTime();
int ms = (60 - t.second())*1000 - t.msec();
timerId = startTimer( ms );
} else {
QLabel::timerEvent( e );
}
}
void LauncherClock::updateTime( void )
{
changeTime();
}
void LauncherClock::changeTime( void )
{
QTime tm = QDateTime::currentDateTime().time();
QString s;
if( ampmFormat ) {
int hour = tm.hour();
if (hour == 0)
hour = 12;
if (hour > 12)
hour -= 12;
s.sprintf( "%2d:%02d %s", hour, tm.minute(),
(tm.hour() >= 12) ? "PM" : "AM" );
} else
s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
if (format==1) {
QDate dm = QDate::currentDate();
QString d;
d.sprintf("%d/%d ", dm.day(), dm.month());
setText( d+s );
} else if (format==2) {
QDate dm = QDate::currentDate();
QString d;
d.sprintf("%d/%d ", dm.month(), dm.day());
setText( d+s );
} else {
setText( s );
}
}
void LauncherClock::slotClockChanged( bool pm )
{
readConfig();
updateTime();
}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> );
+}
+
diff --git a/core/applets/clockapplet/clock.h b/core/applets/clockapplet/clock.h
index caa0c5f..996fb56 100644
--- a/core/applets/clockapplet/clock.h
+++ b/core/applets/clockapplet/clock.h
@@ -1,48 +1,49 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef __LAUNCHER_CLOCK_H__
#define __LAUNCHER_CLOCK_H__
#include <qlabel.h>
#include <qdatetime.h>
class LauncherClock : public QLabel
{
Q_OBJECT
public:
LauncherClock( QWidget *parent );
+ static int position();
protected slots:
void updateTime( void );
void slotClockChanged( bool pm );
protected:
void mouseReleaseEvent( QMouseEvent * );
void timerEvent( QTimerEvent * );
void changeTime( void );
void readConfig();
bool ampmFormat;
int timerId;
int format;
};
#endif // __LAUNCHER_CLOCK_H__
diff --git a/core/applets/clockapplet/clockapplet.pro b/core/applets/clockapplet/clockapplet.pro
index 057e332..8ce3f6f 100644
--- a/core/applets/clockapplet/clockapplet.pro
+++ b/core/applets/clockapplet/clockapplet.pro
@@ -1,13 +1,13 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = clock.h clockappletimpl.h
-SOURCES = clock.cpp clockappletimpl.cpp
+HEADERS = clock.h
+SOURCES = clock.cpp
TARGET = clockapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include ..
LIBS += -lqpe
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/clockapplet/clockappletimpl.cpp b/core/applets/clockapplet/clockappletimpl.cpp
deleted file mode 100644
index 7481f19..0000000
--- a/core/applets/clockapplet/clockappletimpl.cpp
+++ b/dev/null
@@ -1,67 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#include "clock.h"
-#include "clockappletimpl.h"
-
-
-ClockAppletImpl::ClockAppletImpl()
- : clock(0)
-{
-}
-
-ClockAppletImpl::~ClockAppletImpl()
-{
- delete clock;
-}
-
-QWidget *ClockAppletImpl::applet( QWidget *parent )
-{
- if ( !clock )
- clock = new LauncherClock( parent );
- return clock;
-}
-
-int ClockAppletImpl::position() const
-{
- return 10;
-}
-
-#ifndef QT_NO_COMPONENT
-QRESULT ClockAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( ClockAppletImpl )
-}
-#endif
-
diff --git a/core/applets/clockapplet/clockappletimpl.h b/core/applets/clockapplet/clockappletimpl.h
deleted file mode 100644
index 1f9c8f0..0000000
--- a/core/applets/clockapplet/clockappletimpl.h
+++ b/dev/null
@@ -1,45 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef CLOCKAPPLETIMPL_H
-#define CLOCKAPPLETIMPL_H
-
-#include <qpe/taskbarappletinterface.h>
-
-class LauncherClock;
-
-class ClockAppletImpl : public TaskbarAppletInterface
-{
-public:
- ClockAppletImpl();
- virtual ~ClockAppletImpl();
-
-#ifndef QT_NO_COMPONENT
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-#endif
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- LauncherClock *clock;
-};
-
-#endif
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index a47f33d..afc0592 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -1,158 +1,166 @@
/**********************************************************************
** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org>
** Max Reiss <harlekin@handhelds.org> [trivial stuff]
** Robert Griebl <sandman@handhelds.org>
** Holger Freyther <zecke@handhelds.org> QCOP Interface
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
+#include "irda.h"
+/* OPIE */
+#include <opie2/otaskbarapplet.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
+/* QT */
#include <qpainter.h>
#include <qfile.h>
#include <qtimer.h>
#include <qtextstream.h>
+/* STD */
#include <unistd.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include "irda.h"
-
//===========================================================================
IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
: QWidget ( parent, name )
{
setFixedHeight ( 18 );
setFixedWidth ( 14 );
m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP );
m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" );
m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" );
m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" );
m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" );
m_irda_active = false;
m_irda_discovery_active = false;
m_receive_active = false;
m_receive_state_changed = false;
m_popup = 0;
m_wasOn = false;
m_wasDiscover = false;
QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) );
}
+int IrdaApplet::position()
+{
+ return 6;
+}
+
void IrdaApplet::show()
{
QWidget::show ( );
startTimer ( 2000 );
}
IrdaApplet::~IrdaApplet()
{
if ( m_sockfd >= 0 )
::close ( m_sockfd );
}
void IrdaApplet::popup ( QString message, QString icon )
{
if ( !m_popup )
m_popup = new QPopupMenu ( this );
m_popup-> clear ( );
if ( icon. isEmpty ( ))
m_popup-> insertItem ( message, 0 );
else
m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 );
QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
QSize s = m_popup-> sizeHint ( );
m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
p. y ( ) - s. height ( )));
QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( )));
}
void IrdaApplet::popupTimeout ( )
{
m_popup-> hide ( );
}
bool IrdaApplet::checkIrdaStatus ( )
{
struct ifreq ifr;
strcpy ( ifr. ifr_name, "irda0" );
if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
return false;
return ( ifr. ifr_flags & IFF_UP );
}
bool IrdaApplet::setIrdaStatus ( bool b )
{
struct ifreq ifr;
strcpy ( ifr. ifr_name, "irda0" );
if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
return false;
if ( b ) {
ifr. ifr_flags |= IFF_UP;
}
else {
setIrdaDiscoveryStatus ( 0 );
setIrdaReceiveStatus ( 0 );
ifr. ifr_flags &= ~IFF_UP;
}
if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
return false;
return true;
}
bool IrdaApplet::checkIrdaDiscoveryStatus ( )
{
QFile discovery ( "/proc/sys/net/irda/discovery" );
QString streamIn = "0";
if ( discovery. open ( IO_ReadOnly )) {
QTextStream stream ( &discovery );
streamIn = stream. read ( );
}
return streamIn. toInt ( ) > 0;
}
bool IrdaApplet::setIrdaDiscoveryStatus ( bool d )
{
QFile discovery ( "/proc/sys/net/irda/discovery" );
if ( discovery. open ( IO_WriteOnly | IO_Raw )) {
discovery.putch ( d ? '1' : '0' );
return true;
}
return false;
}
@@ -257,96 +265,101 @@ void IrdaApplet::mousePressEvent ( QMouseEvent * )
if ( m_irda_active ) {
menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 );
menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 );
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
QSize s = menu-> sizeHint ( );
p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ));
switch ( menu-> exec ( p )) {
case 0:
setIrdaStatus ( !m_irda_active );
timerEvent ( 0 );
break;
case 1:
setIrdaDiscoveryStatus ( !m_irda_discovery_active );
timerEvent ( 0 );
break;
case 2:
setIrdaReceiveStatus ( !m_receive_active );
timerEvent( 0 );
break;
}
delete menu;
}
void IrdaApplet::timerEvent ( QTimerEvent * )
{
bool oldactive = m_irda_active;
bool olddiscovery = m_irda_discovery_active;
bool receiveUpdate = false;
if ( m_receive_state_changed ) {
receiveUpdate = true;
m_receive_state_changed = false;
}
m_irda_active = checkIrdaStatus ( );
m_irda_discovery_active = checkIrdaDiscoveryStatus ( );
if ( m_irda_discovery_active )
showDiscovered ( );
if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate )
update ( );
}
void IrdaApplet::paintEvent ( QPaintEvent * )
{
QPainter p ( this );
p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap );
if ( m_irda_discovery_active )
p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap );
if ( m_receive_active )
p. drawPixmap( 0, 1, m_receiveActivePixmap );
}
/*
* We know 3 calls
* a) enable
* b) disable
* a and b will temp enable the IrDa device and disable will disable it again if it wasn't on
* c) listDevices: We will return a list of known devices
*/
void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) {
if ( str == "enableIrda()") {
m_wasOn = checkIrdaStatus();
m_wasDiscover = checkIrdaDiscoveryStatus();
if (!m_wasOn) {
setIrdaStatus( true );
}
if ( !m_wasDiscover ) {
setIrdaDiscoveryStatus ( true );
}
} else if ( str == "disableIrda()") {
if (!m_wasOn) {
setIrdaStatus( false );
}
if ( !m_wasDiscover ) {
setIrdaDiscoveryStatus ( false );
}
} else if ( str == "listDevices()") {
QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)");
QStringList list;
QMap<QString, QString>::Iterator it;
for (it = m_devices.begin(); it != m_devices.end(); ++it )
list << (*it);
e << list;
}
}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<IrdaApplet> );
+}
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h
index ec1d32c..f713bbe 100644
--- a/core/applets/irdaapplet/irda.h
+++ b/core/applets/irdaapplet/irda.h
@@ -1,76 +1,77 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com,
** Robert Griebl sandman@handhelds.org
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef __OPIE_IRDA_APPLET_H__
#define __OPIE_IRDA_APPLET_H__
#include <qwidget.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
#include <qmap.h>
class IrdaApplet : public QWidget
{
Q_OBJECT
public:
IrdaApplet( QWidget *parent = 0, const char *name = 0 );
~IrdaApplet();
+ static int position();
virtual void show ( );
protected:
virtual void timerEvent ( QTimerEvent * );
virtual void mousePressEvent ( QMouseEvent * );
virtual void paintEvent ( QPaintEvent* );
private slots:
void popupTimeout ( );
void slotMessage( const QCString& , const QByteArray& );
private:
void popup( QString message, QString icon = QString::null );
bool checkIrdaStatus ( );
bool setIrdaStatus ( bool );
bool checkIrdaDiscoveryStatus ();
bool setIrdaDiscoveryStatus ( bool );
bool setIrdaReceiveStatus ( bool );
void showDiscovered();
private:
QPixmap m_irdaOnPixmap;
QPixmap m_irdaOffPixmap;
QPixmap m_irdaDiscoveryOnPixmap;
QPixmap m_receiveActivePixmap;
bool m_irda_active;
bool m_irda_discovery_active;
bool m_receive_active;
bool m_receive_state_changed;
QPopupMenu *m_popup;
int m_sockfd;
QMap <QString, QString> m_devices;
bool m_wasOn; // if IrDa was enabled
bool m_wasDiscover;
};
#endif // __OPIE_IRDA_APPLET_H__
diff --git a/core/applets/irdaapplet/irdaapplet.pro b/core/applets/irdaapplet/irdaapplet.pro
index 4e94dfb..31e8691 100644
--- a/core/applets/irdaapplet/irdaapplet.pro
+++ b/core/applets/irdaapplet/irdaapplet.pro
@@ -1,13 +1,13 @@
-TEMPLATE = lib
-CONFIG += qt plugin warn_on release
-HEADERS = irda.h irdaappletimpl.h
-SOURCES = irda.cpp irdaappletimpl.cpp
-TARGET = irdaapplet
-DESTDIR = $(OPIEDIR)/plugins/applets
-INCLUDEPATH += $(OPIEDIR)/include
+TEMPLATE = lib
+CONFIG += qt plugin warn_on release
+HEADERS = irda.h
+SOURCES = irda.cpp
+TARGET = irdaapplet
+DESTDIR = $(OPIEDIR)/plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/irdaapplet/irdaappletimpl.cpp b/core/applets/irdaapplet/irdaappletimpl.cpp
deleted file mode 100644
index 33d98af..0000000
--- a/core/applets/irdaapplet/irdaappletimpl.cpp
+++ b/dev/null
@@ -1,66 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#include "irda.h"
-#include "irdaappletimpl.h"
-
-
-IrdaAppletImpl::IrdaAppletImpl()
- : irda(0)
-{
-}
-
-IrdaAppletImpl::~IrdaAppletImpl()
-{
- delete irda;
-}
-
-QWidget *IrdaAppletImpl::applet( QWidget *parent )
-{
- if ( !irda )
- irda = new IrdaApplet( parent );
- return irda;
-}
-
-int IrdaAppletImpl::position() const
-{
- return 6;
-}
-
-QRESULT IrdaAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( IrdaAppletImpl )
-}
-
-
diff --git a/core/applets/irdaapplet/irdaappletimpl.h b/core/applets/irdaapplet/irdaappletimpl.h
deleted file mode 100644
index 024cc06..0000000
--- a/core/applets/irdaapplet/irdaappletimpl.h
+++ b/dev/null
@@ -1,45 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef IRDAAPPLETIMPL_H
-#define IRDAAPPLETIMPL_H
-
-#include <qwidget.h>
-
-#include <qpe/taskbarappletinterface.h>
-
-class IrdaApplet;
-
-class IrdaAppletImpl : public TaskbarAppletInterface
-{
-public:
- IrdaAppletImpl();
- virtual ~IrdaAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- IrdaApplet *irda;
-};
-
-#endif
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 56a031c..5d6bce4 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -1,132 +1,135 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "screenshot.h"
#include "inputDialog.h"
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-
+/* OPIE */
+#include <opie2/otaskbarapplet.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
+/* QT */
#include <qlineedit.h>
#include <qdir.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qcheckbox.h>
#include <qmessagebox.h>
+/* STD */
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <unistd.h>
/* XPM */
static char * snapshot_xpm[] = {
"32 32 177 2",
" c None",
". c #042045",
"+ c #0D2B47",
"@ c #0E325E",
"# c #0D2E50",
"$ c #0A1C32",
"% c #0F3A69",
"& c #164680",
"* c #165EAE",
"= c #134D89",
"- c #0A3A6E",
"; c #031024",
"> c #031B36",
", c #1A5EA3",
"' c #1862B1",
") c #1866B9",
"! c #0F5AAC",
"~ c #0F56A8",
"{ c #0C4C96",
"] c #030918",
"^ c #060206",
"/ c #20242C",
"( c #3E3B3B",
"_ c #186ABD",
": c #115EB3",
"< c #082644",
"[ c #222C38",
"} c #5A5859",
"| c #091921",
"1 c #1E7EDE",
"2 c #1A7ADA",
"3 c #1970CD",
"4 c #1758A1",
"5 c #0E529A",
"6 c #094388",
"7 c #22364E",
"8 c #384454",
"9 c #04162C",
"0 c #123451",
"a c #3296B4",
"b c #298AB1",
"c c #2484AC",
"d c #033D86",
"e c #033677",
"f c #072C58",
"g c #525862",
"h c #5E5E5E",
"i c #23492A",
"j c #4FBD3F",
"k c #50B24C",
"l c #51C72E",
"m c #42C64A",
"n c #2686CA",
"o c #0B52A4",
"p c #054A9A",
"q c #053B7C",
"r c #2B2325",
"s c #6E7070",
"t c #0D240E",
"u c #1E423E",
"v c #468ABE",
"w c #6A8AC2",
"x c #7EAA8E",
"y c #84BE4E",
"z c #65C639",
"A c #064EA0",
"B c #0A4DA0",
"C c #4E5242",
"D c #62362E",
"E c #721A1A",
"F c #6E0A0A",
"G c #3E0E0E",
"H c #6AB85E",
"I c #7E8ECA",
"J c #929CD4",
"K c #9EAECA",
"L c #9EBEAE",
"M c #8EC26A",
"N c #32A276",
"O c #20518C",
"P c #46566E",
"Q c #614A51",
"R c #AE2A26",
"S c #C41C1A",
"T c #CE0A0A",
"U c #A60606",
"V c #921616",
"W c #863735",
"X c #866A66",
"Y c #9E9EA2",
"Z c #1E5212",
"` c #7EC652",
@@ -404,127 +407,137 @@ void ScreenshotControl::performGrab()
if (buttonPushed == 1) {
qDebug("grabbing screen");
grabTimer->stop();
show();
qApp->processEvents();
savePixmap();
} else {
grabTimer->stop();
struct sockaddr_in raddr;
struct hostent *rhost_info;
int sock = -1;
bool ok = false;
QString displayEnv = getenv("QWS_DISPLAY");
qDebug(displayEnv);
if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) {
if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) {
::memset ( &raddr, 0, sizeof (struct sockaddr_in));
::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length );
raddr. sin_family = rhost_info-> h_addrtype;
raddr. sin_port = htons ( SCAP_port );
if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) {
if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) {
QString header;
QPixmap pix;
QString SCAP_model="";
#warning FIXME: model string should be filled with actual device model
if( snapshot.width() > 320)
SCAP_model ="Corgi";
if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!!
pix = snapshot.xForm(QWMatrix().rotate(90));
} else
pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) );
QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it
header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user
"Content-length: %3\n" // 3: content length
"Content-Type: image/png\n"
"Host: %4\n" // 4: scap host
"\n";
header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname );
qDebug(header);
if ( !pix.isNull() ) {
const char *ascii = header.latin1( );
uint ascii_len = ::strlen( ascii );
::write ( sock, ascii, ascii_len );
::write ( sock, img.bits(), img.numBytes() );
ok = true;
}
}
::close ( sock );
}
}
if ( ok ) {
QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname ));
} else {
QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname ));
}
} else {
QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable."));
}
}
}
//===========================================================================
ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
: QWidget( parent, name )
{
setFixedWidth( AppLnk::smallIconSize());
QImage img = (const char **)snapshot_xpm;
img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize());
m_icon.convertFromImage(img);
}
ScreenshotApplet::~ScreenshotApplet()
{
}
+int ScreenshotApplet::position()
+{
+ return 6;
+}
+
void ScreenshotApplet::mousePressEvent( QMouseEvent *)
{
ScreenshotControl *sc = new ScreenshotControl ( );
QPoint curPos = mapToGlobal ( QPoint ( 0, 0 ));
// windowPosX is the windows position centered above the applets icon.
// If the icon is near the edge of the screen, the window would leave the visible area
// so we check the position against the screen width and correct the difference if needed
int screenWidth = qApp->desktop()->width();
int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ;
int ZwindowPosX, XwindowPosX;
// the window would be placed beyond the screen wich doesn't look tooo good
if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) {
XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth;
ZwindowPosX = windowPosX - XwindowPosX - 1;
} else {
ZwindowPosX = windowPosX;
}
sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) );
sc-> show ( );
}
void ScreenshotApplet::paintEvent( QPaintEvent* )
{
QPainter p ( this );
p.drawPixmap( 0,0, m_icon );
}
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ScreenshotApplet> );
+}
+
diff --git a/core/applets/screenshotapplet/screenshot.h b/core/applets/screenshotapplet/screenshot.h
index 74cc5e6..b753583 100644
--- a/core/applets/screenshotapplet/screenshot.h
+++ b/core/applets/screenshotapplet/screenshot.h
@@ -1,70 +1,71 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef __SCREENSHOT_APPLET_H__
#define __SCREENSHOT_APPLET_H__
#include <qwidget.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include <qtimer.h>
class QComboBox;
class QCheckBox;
class QSpinBox;
class QPushButton;
//class QImage;
class ScreenshotControl : public QFrame
{
Q_OBJECT
public:
ScreenshotControl( QWidget *parent=0, const char *name=0 );
private:
QPushButton *grabItButton, *scapButton;
QPixmap snapshot;
QTimer* grabTimer;
QCheckBox *saveNamedCheck;
QString FileNamePath;
bool setFileName;
QSpinBox *delaySpin;
int buttonPushed;
private slots:
void slotGrab();
void slotScap();
void savePixmap();
void performGrab();
};
class ScreenshotApplet : public QWidget {
public:
ScreenshotApplet( QWidget *parent = 0, const char *name=0 );
~ScreenshotApplet();
+ static int position();
protected:
void mousePressEvent( QMouseEvent * );
void paintEvent( QPaintEvent* );
private:
QPixmap m_icon;
};
#endif // __SCREENSHOT_APPLET_H__
diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro
index 45a5759..c7fcc3e 100644
--- a/core/applets/screenshotapplet/screenshotapplet.pro
+++ b/core/applets/screenshotapplet/screenshotapplet.pro
@@ -1,15 +1,13 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = screenshot.h inputDialog.h screenshotappletimpl.h
-SOURCES = screenshot.cpp inputDialog.cpp screenshotappletimpl.cpp
+HEADERS = screenshot.h inputDialog.h
+SOURCES = screenshot.cpp inputDialog.cpp
TARGET = screenshotapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
-MOC_DIR=opieobj
-OBJECTS_DIR=opieobj
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.cpp b/core/applets/screenshotapplet/screenshotappletimpl.cpp
deleted file mode 100644
index e99ecb0..0000000
--- a/core/applets/screenshotapplet/screenshotappletimpl.cpp
+++ b/dev/null
@@ -1,66 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#include "screenshot.h"
-#include "screenshotappletimpl.h"
-
-
-ScreenshotAppletImpl::ScreenshotAppletImpl()
- : screenshot(0)
-{
-}
-
-ScreenshotAppletImpl::~ScreenshotAppletImpl()
-{
- delete screenshot;
-}
-
-QWidget *ScreenshotAppletImpl::applet( QWidget *parent )
-{
- if ( !screenshot )
- screenshot = new ScreenshotApplet( parent );
- return screenshot;
-}
-
-int ScreenshotAppletImpl::position() const
-{
- return 6;
-}
-
-QRESULT ScreenshotAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( ScreenshotAppletImpl )
-}
-
-
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.h b/core/applets/screenshotapplet/screenshotappletimpl.h
deleted file mode 100644
index 988a34c..0000000
--- a/core/applets/screenshotapplet/screenshotappletimpl.h
+++ b/dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef SCREENSHOTAPPLETIMPL_H
-#define SCREENSHOTAPPLETIMPL_H
-
-#include <qpe/taskbarappletinterface.h>
-
-class ScreenshotApplet;
-
-class ScreenshotAppletImpl : public TaskbarAppletInterface
-{
-public:
- ScreenshotAppletImpl();
- virtual ~ScreenshotAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- ScreenshotApplet *screenshot;
-};
-
-#endif
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index fe8ebfd..563d110 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -1,335 +1,341 @@
/************************************************************************************
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
************************************************************************************/
// copyright 2002 Jeremy Cowgar <jc@cowgar.com>
// copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com>
extern "C" {
#include "adpcm.h"
}
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include <errno.h>
typedef struct _waveheader {
u_long main_chunk; /* 'RIFF' */
u_long length; /* filelen */
u_long chunk_type; /* 'WAVE' */
u_long sub_chunk; /* 'fmt ' */
u_long sc_len; /* length of sub_chunk, =16
(chunckSize) format len */
u_short format; /* should be 1 for PCM-code (formatTag) */
u_short modus; /* 1 Mono, 2 Stereo (channels) */
u_long sample_fq; /* samples per second (samplesPerSecond) */
u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */
u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */
u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */
u_long data_chunk; /* 'data' */
u_long data_length;/* samplecount */
} WaveHeader;
#define RIFF 0x46464952
#define WAVE 0x45564157
#define FMT 0x20746D66
#define DATA 0x61746164
#define PCM_CODE 1
#define WAVE_MONO 1
#define WAVE_STEREO 2
struct adpcm_state encoder_state;
//struct adpcm_state decoder_state;
#define WAVE_FORMAT_DVI_ADPCM (0x0011)
#define WAVE_FORMAT_PCM (0x0001)
#include "vmemo.h"
+#include <opie2/otaskbarapplet.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpainter.h>
#include <qmessagebox.h>
int seq = 0;
/* XPM */
static char * vmemo_xpm[] = {
"16 16 102 2",
" c None",
". c #60636A",
"+ c #6E6E72",
"@ c #68696E",
"# c #4D525C",
"$ c #6B6C70",
"% c #E3E3E8",
"& c #EEEEF2",
"* c #EAEAEF",
"= c #CACAD0",
"- c #474A51",
"; c #171819",
"> c #9B9B9F",
", c #EBEBF0",
"' c #F4F4F7",
") c #F1F1F5",
"! c #DEDEE4",
"~ c #57575C",
"{ c #010101",
"] c #A2A2A6",
"^ c #747477",
"/ c #B5B5B8",
"( c #AEAEB2",
"_ c #69696D",
": c #525256",
"< c #181C24",
"[ c #97979B",
"} c #A7A7AC",
"| c #B0B0B4",
"1 c #C8C8D1",
"2 c #75757B",
"3 c #46464A",
"4 c #494A4F",
"5 c #323234",
"6 c #909095",
"7 c #39393B",
"8 c #757578",
"9 c #87878E",
"0 c #222224",
"a c #414144",
"b c #6A6A6E",
"c c #020C16",
"d c #6B6B6F",
"e c #68686D",
"f c #5B5B60",
"g c #8A8A8F",
"h c #6B6B6E",
"i c #ADADB2",
"j c #828289",
"k c #3E3E41",
"l c #CFCFD7",
"m c #4C4C50",
"n c #000000",
"o c #66666A",
"p c #505054",
"q c #838388",
"r c #A1A1A7",
"s c #A9A9AE",
"t c #A8A8B0",
"u c #5E5E63",
"v c #3A3A3E",
"w c #BDBDC6",
"x c #59595E",
"y c #76767C",
"z c #373738",
"A c #717174",
"B c #727278",
"C c #1C1C1E",
"D c #3C3C3F",
"E c #ADADB6",
"F c #54555A",
"G c #8B8C94",
"H c #5A5A5F",
"I c #BBBBC3",
"J c #C4C4CB",
"K c #909098",
"L c #737379",
"M c #343437",
"N c #8F8F98",
"O c #000407",
"P c #2D3137",
"Q c #B0B1BC",
"R c #3B3C40",
"S c #6E6E74",
"T c #95959C",
"U c #74747A",
"V c #1D1D1E",
"W c #91929A",
"X c #42444A",
"Y c #22282E",
"Z c #B0B2BC",
"` c #898A90",
" . c #65656A",
".. c #999AA2",
"+. c #52535A",
"@. c #151B21",
"#. c #515257",
"$. c #B5B5BE",
"%. c #616167",
"&. c #1A1D22",
"*. c #000713",
"=. c #1F1F21",
" ",
" . + @ # ",
" $ % & * = - ",
" ; > , ' ) ! ~ ",
" { ] ^ / ( _ : ",
" < [ } | 1 2 3 ",
" 4 5 6 7 8 9 0 a b c ",
" d e f g h i j 3 k l m n ",
" o p q r s t u v w n ",
" o x y z A B C D E n ",
" F G H I J K L M N O ",
" P Q R S T U V W X ",
" Y Z ` b ...+. ",
" @.#.$.%.&. ",
" *.B =. ",
" n n n n n n n n n "};
VMemo::VMemo( QWidget *parent, const char *_name )
: QWidget( parent, _name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
t_timer = new QTimer( this );
connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
qDebug("toggleKey %d", toggleKey);
if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
systemZaurus=TRUE;
else
systemZaurus=FALSE;
myChannel = new QCopChannel( "QPE/VMemo", this );
connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
if( toggleKey != -1 ) {
// keyRegister(key, channel, message)
QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)");
// e << 4096; // Key_Escape
// e << Key_F5; //4148
e << toggleKey;
e << QString("QPE/VMemo");
e << QString("toggleRecord()");
}
if(toggleKey == 1)
usingIcon=TRUE;
else
usingIcon=FALSE;
if( vmCfg.readNumEntry("hideIcon",0) == 1)
hide();
recording = FALSE;
// }
}
VMemo::~VMemo() {
}
+int VMemo::position()
+{
+ return 6;
+}
+
void VMemo::receive( const QCString &msg, const QByteArray &data ) {
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
if (msg == "toggleRecord()") {
if (recording) {
fromToggle = TRUE;
stopRecording();
} else {
fromToggle = TRUE;
startRecording();
}
}
}
void VMemo::paintEvent( QPaintEvent* ) {
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
void VMemo::mousePressEvent( QMouseEvent * me) {
/* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
mousePressEvent and mouseReleaseEvent with a NULL parameter. */
// if (!systemZaurus && me != NULL)
// return;
// }
if(!recording)
startRecording();
else
stopRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * ) {
}
bool VMemo::startRecording() {
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert",1);
if(useAlerts) {
msgLabel = new QLabel( 0, "alertLabel" );
msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
msgLabel->show();
}
qDebug("Start recording engines");
recording = TRUE;
if (openDSP() == -1) {
recording = FALSE;
return FALSE;
}
config.setGroup("Defaults");
date = TimeString::dateString( QDateTime::currentDateTime(),false,true);
date.replace(QRegExp("'"),"");
date.replace(QRegExp(" "),"_");
date.replace(QRegExp(":"),".");
date.replace(QRegExp(","),"");
QString fName;
config.setGroup( "System" );
fName = QPEApplication::documentDir() ;
fileName = config.readEntry("RecLocation", fName);
int s;
s=fileName.find(':');
if(s)
fileName=fileName.right(fileName.length()-s-2);
qDebug("pathname will be "+fileName);
if( fileName.left(1).find('/') == -1)
fileName="/"+fileName;
if( fileName.right(1).find('/') == -1)
fileName+="/";
fName = "vm_"+ date+ ".wav";
fileName+=fName;
qDebug("filename is "+fileName);
// open tmp file here
char *pointer;
pointer=tmpnam(NULL);
qDebug("Opening tmp file %s",pointer);
if(openWAV(pointer ) == -1) {
QString err("Could not open the temp file\n");
err += fileName;
QMessageBox::critical(0, "vmemo", err, "Abort");
::close(dsp);
return FALSE;
@@ -538,96 +544,102 @@ bool VMemo::record() {
qApp->processEvents();
}
// qDebug("file has length of %d lasting %d seconds",
// length, (( length / speed) / channels) / 2 );
// }
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
value = length+36;
lseek(wav, 4, SEEK_SET);
write(wav, &value, 4);
lseek(wav, 40, SEEK_SET);
write(wav, &length, 4);
track.close();
qDebug("Track closed");
if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
::close(dsp);
Config cfgO("OpieRec");
cfgO.setGroup("Sounds");
int nFiles = cfgO.readNumEntry( "NumberofFiles",0);
QString currentFileName = fileName;
QString currentFile = "vm_"+ date;
float numberOfRecordedSeconds=(float) length / (float)speed * (float)2;
cfgO.writeEntry( "NumberofFiles", nFiles + 1);
cfgO.writeEntry( QString::number( nFiles + 1), currentFile);
cfgO.writeEntry( currentFile, currentFileName);
QString time;
time.sprintf("%.2f", numberOfRecordedSeconds);
cfgO.writeEntry( currentFileName, time );
// qDebug("writing config numberOfRecordedSeconds "+time);
cfgO.write();
qDebug("done recording "+fileName);
Config cfg("qpe");
cfg.setGroup("Volume");
QString foo = cfg.readEntry("Mute","TRUE");
if(foo.find("TRUE",0,TRUE) != -1)
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
return TRUE;
}
int VMemo::setToggleButton(int tog) {
for( int i=0; i < 10;i++) {
switch (tog) {
case 0:
return -1;
break;
case 1:
return 0;
break;
case 2:
return Key_F24; //was Escape
break;
case 3:
return Key_Space;
break;
case 4:
return Key_F12;
break;
case 5:
return Key_F9;
break;
case 6:
return Key_F10;
break;
case 7:
return Key_F11;
break;
case 8:
return Key_F13;
break;
};
}
return -1;
}
void VMemo::timerBreak() {
//stop
stopRecording();
QMessageBox::message("Vmemo","Vmemo recording has ended");
}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VMemo> );
+}
+
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 31d0a25..1bd735f 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -1,64 +1,65 @@
/**************************************************************************************94x78**
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
*********************************************************************************************/
/*
* $Id$
*/
#ifndef __VMEMO_H__
#define __VMEMO_H__
#include <qwidget.h>
#include <qpixmap.h>
#include <qpe/applnk.h>
#include <qfile.h>
#include <qpe/qcopenvelope_qws.h>
#include <qlabel.h>
#include <qtimer.h>
class VMemo : public QWidget
{
Q_OBJECT
public:
VMemo( QWidget *parent, const char *name = NULL);
~VMemo();
+ static int position();
QFile track;
int length;
QString fileName, errorMsg, date;
QLabel* msgLabel;
QTimer *t_timer;
bool usingIcon, useADPCM;
public slots:
bool record();
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void receive( const QCString &msg, const QByteArray &data );
bool startRecording();
void stopRecording();
void timerBreak();
private:
bool useAlerts;
void paintEvent( QPaintEvent* );
int setToggleButton(int);
int openDSP();
int openWAV(const char *filename);
bool fromToggle;
QPixmap vmemoPixmap;
QCopChannel *myChannel;
bool systemZaurus;
int dsp, wav, rate, speed, channels, format, resolution;
bool recording;
};
#endif // __VMEMO_H__
diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro
index f83a53f..2deedfd 100644
--- a/core/applets/vmemo/vmemo.pro
+++ b/core/applets/vmemo/vmemo.pro
@@ -1,13 +1,13 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = vmemo.h vmemoimpl.h adpcm.h
-SOURCES = vmemo.cpp vmemoimpl.cpp adpcm.c
+HEADERS = vmemo.h adpcm.h
+SOURCES = vmemo.cpp adpcm.c
TARGET = vmemoapplet
DESTDIR =$(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/vmemo/vmemoimpl.cpp b/core/applets/vmemo/vmemoimpl.cpp
deleted file mode 100644
index 7779b83..0000000
--- a/core/applets/vmemo/vmemoimpl.cpp
+++ b/dev/null
@@ -1,61 +0,0 @@
-/**************************************************************************************94x78**
- **
- ** This file may be distributed and/or modified under the terms of the
- ** GNU General Public License version 2 as published by the Free Software
- ** Foundation and appearing in the file LICENSE.GPL included in the
- ** packaging of this file.
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- *********************************************************************************************/
-
-/*
- * $Id$
- */
-
-#include "vmemo.h"
-#include "vmemoimpl.h"
-
-
-VMemoAppletImpl::VMemoAppletImpl()
- : vmemo(0)
-{
-}
-
-VMemoAppletImpl::~VMemoAppletImpl()
-{
- delete vmemo;
-}
-
-QWidget *VMemoAppletImpl::applet( QWidget *parent )
-{
- if ( !vmemo )
- vmemo = new VMemo( parent );
- return vmemo;
-}
-
-int VMemoAppletImpl::position() const
-{
- return 6;
-}
-
-QRESULT VMemoAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( VMemoAppletImpl )
- }
diff --git a/core/applets/vmemo/vmemoimpl.h b/core/applets/vmemo/vmemoimpl.h
deleted file mode 100644
index 985138b..0000000
--- a/core/applets/vmemo/vmemoimpl.h
+++ b/dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************************94x78**
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-*********************************************************************************************/
-
-/*
- * $Id$
- */
-
-#ifndef __VMEMOIMPLAPPLETIMPL_H__
-#define __VMEMOIMPLAPPLETIMPL_H__
-
-#include <qpe/taskbarappletinterface.h>
-
-class VMemo;
-
-class VMemoAppletImpl : public TaskbarAppletInterface
-{
-public:
- VMemoAppletImpl();
- virtual ~VMemoAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- VMemo *vmemo;
-};
-
-#endif
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index c736437..8fd88f6 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,140 +1,136 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
-#include <stdio.h>
-
#include "volume.h"
+#include "oledbox.h"
+#include <opie2/odevice.h>
+#include <opie2/otaskbarapplet.h>
#include <qpe/resource.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
-#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
-#endif
#include <qpainter.h>
#include <qcheckbox.h>
#include <qslider.h>
#include <qlayout.h>
#include <qvbox.h>
#include <qlabel.h>
-
#include <qpushbutton.h>
#include <qtimer.h>
-#include <opie/odevice.h>
-
-#include "oledbox.h"
+#include <stdio.h>
using namespace Opie;
#define RATE_TIMER_INTERVAL 100
// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
/* XPM */
static const char * vol_xpm[] = {
"20 20 3 1",
" c None",
". c #0000FF",
"+ c #000000",
" ",
" . ",
" . . . . ",
" . . . . . . ",
" . . . . . . . ",
" . . ..... . . ",
" . ... ..... ... ",
" ........... .... ",
" ................. ",
"++++++++++++++++++++",
" .................. ",
" . ............. . ",
" . ..... ....... ",
" . ... ..... . ",
" . ... ..... . ",
" . ... ..... ",
" . . . . . ",
" . . . ",
" . . . ",
" "};
/* XPM */
static const char * mic_xpm[] = {
"20 20 21 1",
" c None",
". c #000000",
"+ c #EEEEEE",
"@ c #B4B6B4",
"# c #8B8D8B",
"$ c #D5D6D5",
"% c #E6E6E6",
"& c #9C9D9C",
"* c #6A696A",
"= c #E6E2E6",
"- c #F6F2F6",
"; c #CDC6CD",
"> c #737573",
", c #4A484A",
"' c #DEDEDE",
") c #F6EEF6",
"! c #414041",
"~ c #202020",
"{ c #ACAEAC",
"] c #838583",
"^ c #6A656A",
" ",
" .... ",
" .+@+#. ",
" ..$%&%*. ",
" .=-.;=>=,. ",
" .'+).&+!+. ",
" .+;+;.~+~. ",
" ..%{%,.... ",
" ..&=>=~.. ",
" .+..]^,.. ",
" .+....... ",
" .%... ",
" .=... ",
" .+... ",
" .+... ",
" .... ",
" .... ",
" .. ",
" . ",
". "};
static const char * bass_xpm[] = {
"20 20 3 1",
" c None",
". c #000000",
"+ c #0000FF",
" ",
" ",
" ",
"..... +++ ......",
" +++++++ ",
" ++ ++ ",
"... ++ ... ++ ++ .",
" +++ ++ ++ ",
" ++++ ++ ",
"... ++++ .. ++ .....",
" ++ ++ ",
@@ -644,136 +640,144 @@ void VolumeControl::micMoved ( int percent )
{
m_mic_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
}
void VolumeControl::alarmMoved ( int percent )
{
m_alarm_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
}
void VolumeControl::bassMoved ( int percent )
{
m_bass_percent = 100 - percent;
// clamp bass percent to be between 0 and 100
m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
}
void VolumeControl::trebleMoved ( int percent )
{
m_treble_percent = 100 - percent;
// clamp treble percent to be between 0 and 100
m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
}
void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
{
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
cfg. writeEntry ( entry, val );
// cfg. write ( );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
switch ( upd ) {
case UPD_Vol: {
QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
break;
}
case UPD_Mic: {
QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
break;
}
case UPD_Bass: {
QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
break;
}
case UPD_Treble: {
QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
break;
}
case UPD_None:
break;
}
#endif
}
//===========================================================================
VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
: QWidget( parent, name )
{
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize()+4 );
m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
}
VolumeApplet::~VolumeApplet()
{
delete m_pixmap;
}
+int VolumeApplet::position()
+{
+ return 6;
+}
void VolumeApplet::mousePressEvent ( QMouseEvent * )
{
if ( m_dialog-> isVisible ( ))
m_dialog-> hide ( );
else
m_dialog-> show ( true );
}
void VolumeApplet::redraw ( bool all )
{
if ( all )
repaint ( true );
else
repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
}
void VolumeApplet::paintEvent ( QPaintEvent * )
{
QPainter p ( this );
p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
p. setPen ( darkGray );
p. drawRect ( 1, height() - 4, width() - 2, 4 );
int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
if ( m_dialog-> volMuted ( )) {
p. setPen ( red );
p. drawLine ( 1, 2, width() - 2, height() - 5 );
p. drawLine ( 1, 3, width() - 2, height() - 4 );
p. drawLine ( width() - 2, 2, 1, height() - 5 );
p. drawLine ( width() - 2, 3, 1, height() - 4 );
}
}
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VolumeApplet> );
+}
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h
index d2345b5..454a688 100644
--- a/core/applets/volumeapplet/volume.h
+++ b/core/applets/volumeapplet/volume.h
@@ -24,111 +24,112 @@
#include <qframe.h>
class QPixmap;
class QTimer;
class QSlider;
class QCheckBox;
class QButton;
class OLedBox;
class VolumeApplet;
class VolumeControl : public QFrame {
Q_OBJECT
public:
VolumeControl ( VolumeApplet *icon, bool showMic = false, QWidget *parent=0, const char *name=0 );
bool volMuted ( ) const;
int volPercent ( ) const;
virtual void show ( bool showmic );
protected:
virtual void keyPressEvent ( QKeyEvent * e );
protected slots:
void volumeChanged ( bool muted );
void micChanged ( bool muted );
private slots:
void volMoved ( int percent );
void micMoved ( int percent );
void alarmMoved ( int percent );
void bassMoved( int percent );
void trebleMoved( int percent );
void volMuteToggled ( bool );
void micMuteToggled ( bool );
void alarmSoundToggled ( bool );
void keyClickToggled ( bool );
void screenTapToggled ( bool );
void buttonChanged ( );
void rateTimerDone ( );
private:
void readConfig ( bool force = false );
enum eUpdate {
UPD_None,
UPD_Vol,
UPD_Mic,
UPD_Bass,
UPD_Treble
};
void writeConfigEntry ( const char *entry, int val, eUpdate upd );
private:
QSlider *volSlider;
QSlider *bassSlider;
QSlider *trebleSlider;
QSlider *micSlider;
QSlider *alarmSlider;
OLedBox *volLed;
OLedBox *micLed;
OLedBox *alarmLed;
QCheckBox *alarmBox;
QCheckBox *tapBox;
QCheckBox *keyBox;
QPushButton *upButton;
QPushButton *downButton;
QTimer *rateTimer;
int m_vol_percent;
int m_mic_percent;
int m_alarm_percent;
int m_bass_percent;
int m_treble_percent;
bool m_vol_muted;
bool m_mic_muted;
bool m_snd_alarm;
bool m_snd_touch;
bool m_snd_key;
VolumeApplet *m_icon;
};
class VolumeApplet : public QWidget {
Q_OBJECT
public:
VolumeApplet ( QWidget *parent = 0, const char *name=0 );
~VolumeApplet ( );
+ static int position();
void redraw ( bool all = true );
protected:
virtual void mousePressEvent ( QMouseEvent * );
virtual void paintEvent ( QPaintEvent* );
private:
QPixmap * m_pixmap;
VolumeControl *m_dialog;
};
#endif // __VOLUME_APPLET_H__
diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro
index 92c6b0a..b14956e 100644
--- a/core/applets/volumeapplet/volumeapplet.pro
+++ b/core/applets/volumeapplet/volumeapplet.pro
@@ -1,13 +1,13 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = volume.h volumeappletimpl.h oledbox.h
-SOURCES = volume.cpp volumeappletimpl.cpp oledbox.cpp
+HEADERS = volume.h oledbox.h
+SOURCES = volume.cpp oledbox.cpp
TARGET = volumeapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include
LIBS += -lqpe
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp
deleted file mode 100644
index 9c7dea3..0000000
--- a/core/applets/volumeapplet/volumeappletimpl.cpp
+++ b/dev/null
@@ -1,65 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#include "volume.h"
-#include "volumeappletimpl.h"
-
-VolumeAppletImpl::VolumeAppletImpl()
- : volume(0)
-{
-}
-
-VolumeAppletImpl::~VolumeAppletImpl()
-{
- delete volume;
-}
-
-QWidget *VolumeAppletImpl::applet( QWidget *parent )
-{
- if ( !volume )
- volume = new VolumeApplet( parent );
- return volume;
-}
-
-int VolumeAppletImpl::position() const
-{
- return 6;
-}
-
-QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
-{
- *iface = 0;
- if ( uuid == IID_QUnknown )
- *iface = this;
- else if ( uuid == IID_TaskbarApplet )
- *iface = this;
- else
- return QS_FALSE;
-
- if ( *iface )
- (*iface)->addRef();
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( VolumeAppletImpl )
-}
-
-
diff --git a/core/applets/volumeapplet/volumeappletimpl.h b/core/applets/volumeapplet/volumeappletimpl.h
deleted file mode 100644
index a9221c6..0000000
--- a/core/applets/volumeapplet/volumeappletimpl.h
+++ b/dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-#ifndef VOLUMEAPPLETIMPL_H
-#define VOLUMEAPPLETIMPL_H
-
-#include <qpe/taskbarappletinterface.h>
-
-class VolumeApplet;
-
-class VolumeAppletImpl : public TaskbarAppletInterface
-{
-public:
- VolumeAppletImpl();
- virtual ~VolumeAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- VolumeApplet *volume;
-};
-
-#endif
diff --git a/core/obex/obex.pro b/core/obex/obex.pro
index 6f0e6d1..a296b2c 100644
--- a/core/obex/obex.pro
+++ b/core/obex/obex.pro
@@ -1,13 +1,13 @@
TEMPLATE = lib
CONFIG += qt warn_on release
-HEADERS = obex.h obeximpl.h obexhandler.h obexsend.h receiver.h
-SOURCES = obex.cc obeximpl.cpp obexsend.cpp obexhandler.cpp receiver.cpp
+HEADERS = obex.h obexhandler.h obexsend.h receiver.h
+SOURCES = obex.cc obexsend.cpp obexhandler.cpp receiver.cpp
TARGET = opieobex
DESTDIR = $(OPIEDIR)/plugins/obex
INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher
DEPENDPATH += ../$(OPIEDIR)/include
-LIBS += -lqpe -lopie
+LIBS += -lqpe -lopiecore2
VERSION = 0.0.2
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets