summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/autorotateapplet/autorotate.cpp11
-rw-r--r--noncore/applets/autorotateapplet/autorotate.h3
-rw-r--r--noncore/applets/autorotateapplet/autorotateapplet.pro16
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.cpp42
-rw-r--r--noncore/applets/autorotateapplet/autorotateimpl.h18
-rw-r--r--noncore/applets/memoryapplet/memoryapplet.pro4
-rw-r--r--noncore/applets/memoryapplet/memoryappletimpl.cpp65
-rw-r--r--noncore/applets/memoryapplet/memoryappletimpl.h43
-rw-r--r--noncore/applets/memoryapplet/memorymeter.cpp14
-rw-r--r--noncore/applets/memoryapplet/memorymeter.h1
-rw-r--r--noncore/applets/notesapplet/notes.cpp10
-rw-r--r--noncore/applets/notesapplet/notes.h1
-rw-r--r--noncore/applets/notesapplet/notesapplet.pro8
-rw-r--r--noncore/applets/notesapplet/notesappletimpl.cpp53
-rw-r--r--noncore/applets/notesapplet/notesappletimpl.h35
-rw-r--r--noncore/applets/zkbapplet/.cvsignore6
-rw-r--r--noncore/applets/zkbapplet/zkbapplet.cpp49
-rw-r--r--noncore/applets/zkbapplet/zkbapplet.h23
-rw-r--r--noncore/applets/zkbapplet/zkbapplet.pro6
-rw-r--r--noncore/applets/zkbapplet/zkbwidget.cpp12
-rw-r--r--noncore/applets/zkbapplet/zkbwidget.h1
21 files changed, 67 insertions, 354 deletions
diff --git a/noncore/applets/autorotateapplet/autorotate.cpp b/noncore/applets/autorotateapplet/autorotate.cpp
index 5152904..94be0ae 100644
--- a/noncore/applets/autorotateapplet/autorotate.cpp
+++ b/noncore/applets/autorotateapplet/autorotate.cpp
@@ -1,90 +1,101 @@
/*
* copyright : (c) 2003 by Greg Gilbert
* email : greg@treke.net
* based on the cardmon applet by Max Reiss
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************/
#include "autorotate.h"
/* OPIE */
#include <opie2/odevice.h>
+#include <opie2/otaskbarapplet.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/resource.h>
/* QT */
#include <qpainter.h>
using namespace Opie;
AutoRotate::AutoRotate(QWidget * parent):QWidget(parent)
{
setFixedWidth( AppLnk::smallIconSize() );
setFixedHeight( AppLnk::smallIconSize() );
enabledPm.convertFromImage( Resource::loadImage("autorotate/rotate").smoothScale( height(), width() ) );
disabledPm.convertFromImage( Resource::loadImage("autorotate/norotate").smoothScale( height(), width() ) );
repaint(true);
popupMenu = 0;
show();
}
AutoRotate::~AutoRotate()
{
if (popupMenu) {
delete popupMenu;
}
}
+int AutoRotate::position()
+{
+ return 7;
+}
+
void AutoRotate::mousePressEvent(QMouseEvent *)
{
QPopupMenu *menu = new QPopupMenu(this);
menu->insertItem( isRotateEnabled()? "Disable Rotation" : "Enable Rotation" ,1 );
QPoint p = mapToGlobal(QPoint(0, 0));
QSize s = menu->sizeHint();
int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), p.y() - s.height()), 0);
if (opt==1)
{
setRotateEnabled( !isRotateEnabled() );
repaint(true);
}
delete menu;
}
void AutoRotate::paintEvent(QPaintEvent *)
{
QPainter p(this);
p.drawPixmap( 0, 0, isRotateEnabled()? enabledPm : disabledPm );
}
void AutoRotate::setRotateEnabled(bool status)
{
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
cfg.writeEntry( "rotateEnabled", status );
}
bool AutoRotate::isRotateEnabled()
{
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
bool res = cfg.readBoolEntry( "rotateEnabled" );
if (res )
qDebug("Enabled");
else
qDebug("Disabled");
return res;
}
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<AutoRotate> );
+}
+
diff --git a/noncore/applets/autorotateapplet/autorotate.h b/noncore/applets/autorotateapplet/autorotate.h
index e05e7a0..ef322a6 100644
--- a/noncore/applets/autorotateapplet/autorotate.h
+++ b/noncore/applets/autorotateapplet/autorotate.h
@@ -1,41 +1,40 @@
/*
* copyright : (c) 2003 by Greg Gilbert
* email : greg@treke.net
* based on the cardmon applet by Max Reiss
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************/
#ifndef AUTOROTATE_H
#define AUTOROTATE_H
#include <qwidget.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
class AutoRotate : public QWidget {
Q_OBJECT
public:
AutoRotate( QWidget *parent = 0 );
~AutoRotate();
-
-private slots:
+ static int position();
protected:
void paintEvent( QPaintEvent* );
void mousePressEvent( QMouseEvent * );
private:
bool isRotateEnabled();
void setRotateEnabled(bool);
QPixmap enabledPm;
QPixmap disabledPm;
void iconShow();
QPopupMenu *popupMenu;
};
#endif
diff --git a/noncore/applets/autorotateapplet/autorotateapplet.pro b/noncore/applets/autorotateapplet/autorotateapplet.pro
index 0ccbeba..465b165 100644
--- a/noncore/applets/autorotateapplet/autorotateapplet.pro
+++ b/noncore/applets/autorotateapplet/autorotateapplet.pro
@@ -1,13 +1,13 @@
-TEMPLATE = lib
+TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = autorotate.h autorotateimpl.h
-SOURCES = autorotate.cpp autorotateimpl.cpp
+HEADERS = autorotate.h
+SOURCES = autorotate.cpp
TARGET = autorotateapplet
-DESTDIR = $(OPIEDIR)/plugins/applets
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include ../launcher
-LIBS += -lqpe -lopiecore2
-VERSION = 1.0.0
+DESTDIR = $(OPIEDIR)/plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include ../launcher
+LIBS += -lqpe -lopiecore2
+VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
target.path = $$prefix/plugins/applets
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.cpp b/noncore/applets/autorotateapplet/autorotateimpl.cpp
deleted file mode 100644
index 305ac50..0000000
--- a/noncore/applets/autorotateapplet/autorotateimpl.cpp
+++ b/dev/null
@@ -1,42 +0,0 @@
-#include "autorotate.h"
-#include "autorotateimpl.h"
-
-
-AutoRotateImpl::AutoRotateImpl()
- : autoRotate(0){
- qDebug ("here");
-}
-
-AutoRotateImpl::~AutoRotateImpl() {
- delete autoRotate;
-}
-
-QWidget *AutoRotateImpl::applet( QWidget *parent ) {
- if ( !autoRotate ) {
- autoRotate = new AutoRotate( parent );
- }
- return autoRotate;
-}
-
-int AutoRotateImpl::position() const {
- return 7;
-}
-
-QRESULT AutoRotateImpl::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( AutoRotateImpl )
-}
diff --git a/noncore/applets/autorotateapplet/autorotateimpl.h b/noncore/applets/autorotateapplet/autorotateimpl.h
deleted file mode 100644
index fde23a9..0000000
--- a/noncore/applets/autorotateapplet/autorotateimpl.h
+++ b/dev/null
@@ -1,18 +0,0 @@
-#include <qpe/taskbarappletinterface.h>
-
-class AutoRotate;
-
-class AutoRotateImpl : public TaskbarAppletInterface {
-public:
- AutoRotateImpl();
- virtual ~AutoRotateImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- AutoRotate *autoRotate;
-};
diff --git a/noncore/applets/memoryapplet/memoryapplet.pro b/noncore/applets/memoryapplet/memoryapplet.pro
index 6031386..3cd7839 100644
--- a/noncore/applets/memoryapplet/memoryapplet.pro
+++ b/noncore/applets/memoryapplet/memoryapplet.pro
@@ -1,24 +1,22 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
HEADERS = ../../settings/sysinfo/graph.h \
../../settings/sysinfo/load.h \
../../settings/sysinfo/memory.h \
- memoryappletimpl.h \
memorymeter.h \
memorystatus.h \
swapfile.h
SOURCES = ../../settings/sysinfo/graph.cpp \
../../settings/sysinfo/load.cpp \
../../settings/sysinfo/memory.cpp \
- memoryappletimpl.cpp \
memorymeter.cpp \
memorystatus.cpp \
swapfile.cpp
TARGET = memoryapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += ../$(OPIEDIR)/include
VERSION = 1.0.0
-LIBS += -lqpe -lopieui2
+LIBS += -lqpe -lopiecore2 -lopieui2
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/applets/memoryapplet/memoryappletimpl.cpp b/noncore/applets/memoryapplet/memoryappletimpl.cpp
deleted file mode 100644
index a117e7f..0000000
--- a/noncore/applets/memoryapplet/memoryappletimpl.cpp
+++ b/dev/null
@@ -1,65 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
-**
-** This file is part of the 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 "memorymeter.h"
-#include "memoryappletimpl.h"
-
-MemoryAppletImpl::MemoryAppletImpl()
- : memory(0)
-{
-}
-
-MemoryAppletImpl::~MemoryAppletImpl()
-{
- delete memory;
-}
-
-QWidget *MemoryAppletImpl::applet( QWidget *parent )
-{
- if ( !memory )
- memory = new MemoryMeter( parent );
-
- return memory;
-}
-
-int MemoryAppletImpl::position() const
-{
- return 8;
-}
-
-QRESULT MemoryAppletImpl::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;
-
- (*iface)->addRef();
-
- return QS_OK;
-}
-
-Q_EXPORT_INTERFACE()
-{
- Q_CREATE_INSTANCE( MemoryAppletImpl )
-}
-
diff --git a/noncore/applets/memoryapplet/memoryappletimpl.h b/noncore/applets/memoryapplet/memoryappletimpl.h
deleted file mode 100644
index 2db7dbe..0000000
--- a/noncore/applets/memoryapplet/memoryappletimpl.h
+++ b/dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
-**
-** This file is part of the 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 MEMORYAPPLETIMPL_H
-#define MEMORYAPPLETIMPL_H
-
-#include <qtopia/taskbarappletinterface.h>
-
-class MemoryMeter;
-
-class /*QTOPIA_PLUGIN_EXPORT*/ MemoryAppletImpl : public TaskbarAppletInterface
-{
-public:
- MemoryAppletImpl();
- virtual ~MemoryAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- MemoryMeter *memory;
-};
-
-#endif
diff --git a/noncore/applets/memoryapplet/memorymeter.cpp b/noncore/applets/memoryapplet/memorymeter.cpp
index 54b5c52..9299f49 100644
--- a/noncore/applets/memoryapplet/memorymeter.cpp
+++ b/noncore/applets/memoryapplet/memorymeter.cpp
@@ -1,239 +1,247 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the 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 "memorymeter.h"
#include "memorystatus.h"
+#include <opie2/otaskbarapplet.h>
#include <qtopia/power.h>
#include <qtopia/config.h>
-
-#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
#include <qtopia/qcopenvelope_qws.h>
-#endif
#include <qpainter.h>
#include <qtimer.h>
#include <qapplication.h>
#include <qtopia/applnk.h>
MemoryMeter::MemoryMeter( QWidget *parent )
: QWidget( parent ), memoryView(0)
{
bvsz = QSize();
if ( qApp->desktop()->height() >= 300 )
{
memoryView = new MemoryStatus( 0, WStyle_StaysOnTop | WType_Popup );
memoryView->setFrameStyle( QFrame::Panel | QFrame::Raised );
}
else
{
memoryView = new MemoryStatus( 0 );
memoryView->showMaximized();
}
Config config("MemoryPlugin");
config.setGroup("Warning levels");
low = config.readNumEntry("low", 40);
critical = config.readNumEntry("critical", 20);
startTimer( 10000 );
setFixedWidth(10);
setFixedHeight(AppLnk::smallIconSize());
usageTimer = new QTimer( this );
connect( usageTimer, SIGNAL(timeout()), this, SLOT(usageTimeout()) );
timerEvent(0);
}
MemoryMeter::~MemoryMeter()
{
delete (QWidget *) memoryView;
}
+int MemoryMeter::position()
+{
+ return 7;
+}
+
QSize MemoryMeter::sizeHint() const
{
return QSize(10, AppLnk::smallIconSize());
}
bool MemoryMeter::updateMemoryViewGeometry()
{
if (memoryView != 0)
{
QSize sz = memoryView->sizeHint();
if ( sz != bvsz )
{
bvsz = sz;
QRect r(memoryView->pos(), memoryView->sizeHint());
if ( qApp->desktop()->height() >= 300 )
{
QPoint curPos = mapToGlobal( rect().topLeft() );
int lp = qApp->desktop()->width() - memoryView->sizeHint().width();
r.moveTopLeft( QPoint(lp, curPos.y() - memoryView->sizeHint().height()-1) );
}
memoryView->setGeometry(r);
return TRUE;
}
return FALSE;
}
return FALSE;
}
void MemoryMeter::mousePressEvent( QMouseEvent *)
{
if ( memoryView->isVisible() )
{
memoryView->hide();
}
else
{
bvsz = QSize();
updateMemoryViewGeometry();
memoryView->raise();
memoryView->show();
}
}
void MemoryMeter::timerEvent( QTimerEvent * )
{
if (memoryView != 0)
{
// read memory status
percent = (memoryView->percent());
usageTimer->start( 1000 );
}
}
void MemoryMeter::usageTimeout()
{
if (memoryView != 0)
{
percent = (memoryView->percent());
if (updateMemoryViewGeometry() && memoryView->isVisible())
{
memoryView->hide();
memoryView->show();
}
repaint(FALSE);
}
}
void MemoryMeter::paintEvent( QPaintEvent* )
{
QPainter p(this);
QColor c;
QColor darkc;
QColor lightc;
if (percent > low)
c = green;
else if (percent > critical)
c = yellow.dark(110);
else
c = red;
darkc = c.dark(120);
lightc = c.light(160);
//
// To simulate a 3-d memory, we use 4 bands of colour. From left
// to right, these are: medium, light, medium, dark. To avoid
// hardcoding values for band "width", figure everything out on the run.
//
int batt_width; // width of each band
int batt_height; // memory height (not including terminal)
int used_height; // used amount of memory (scanlines)
int batt_yoffset; // top of terminal
int batt_xoffset; // left edge of core
int band_width; // width of colour band
int w = QMIN(height(), width());
band_width = (w-2) / 4;
if ( band_width < 1 )
band_width = 1;
batt_width = 4 * band_width + 2; // +2 for 1 pixel border on both sides
batt_height = height()-2;
batt_xoffset = (width() - batt_width) / 2;
batt_yoffset = (height() - batt_height) / 2;
//
// Memory border. +1 to make space for the terminal at row 0.
//
p.setPen(QColor(80, 80, 80));
p.drawRect(batt_xoffset, batt_yoffset + 1, batt_width, batt_height);
//
// Draw terminal. +1 to take into account the left border.
//
//p.drawLine(batt_xoffset + band_width + 1, batt_yoffset, batt_xoffset + 3 * band_width, batt_yoffset);
batt_height -= 2; // -2 because we don't want to include border
batt_yoffset += 2; // +2 to account for border and terminal
batt_xoffset++;
//
// 100 - percent, since percent is amount remaining, and we draw
// reverse to this.
//
used_height = percent * batt_height / 100;
if (used_height < 0)
used_height = 0;
//
// Drained section.
//
if (used_height != 0)
{
p.setPen(NoPen);
p.setBrush(gray);
p.drawRect(batt_xoffset, batt_yoffset, band_width, used_height);
p.drawRect(batt_xoffset + 2 * band_width, batt_yoffset, band_width, used_height);
p.setBrush(gray/*.light(130)*/);
p.drawRect(batt_xoffset + band_width, batt_yoffset, band_width, used_height);
p.setBrush(gray/*.dark(120)*/);
p.drawRect(batt_xoffset + 3 * band_width, batt_yoffset, band_width, used_height);
}
//
// Unused section.
//
if ( batt_height - used_height > 0 )
{
int unused_offset = used_height + batt_yoffset;
int unused_height = batt_height - used_height;
p.setPen(NoPen);
p.setBrush(c);
p.drawRect(batt_xoffset, unused_offset, band_width, unused_height);
p.drawRect(batt_xoffset + 2 * band_width, unused_offset, band_width, unused_height);
p.setBrush(lightc);
p.drawRect(batt_xoffset + band_width, unused_offset, band_width, unused_height);
p.setBrush(darkc);
p.drawRect(batt_xoffset + 3 * band_width, unused_offset, band_width, unused_height);
}
}
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<MemoryMeter> );
+}
+
diff --git a/noncore/applets/memoryapplet/memorymeter.h b/noncore/applets/memoryapplet/memorymeter.h
index 0f3cb0b..ed541f0 100644
--- a/noncore/applets/memoryapplet/memorymeter.h
+++ b/noncore/applets/memoryapplet/memorymeter.h
@@ -1,53 +1,54 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the 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 MEMORY_H
#define MEMORY_H
#include <qwidget.h>
class MemoryStatus;
class QTimer;
class MemoryMeter : public QWidget
{
Q_OBJECT
public:
MemoryMeter( QWidget *parent = 0 );
~MemoryMeter();
+ static int position();
QSize sizeHint() const;
MemoryStatus* memoryView;
protected:
void timerEvent( QTimerEvent * );
void paintEvent( QPaintEvent* );
void mousePressEvent( QMouseEvent * );
protected slots:
void usageTimeout();
protected:
QTimer *usageTimer;
int percent, low, critical;
QSize bvsz;
bool updateMemoryViewGeometry();
};
#endif
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index 7b8bdd9..1142028 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -1,213 +1,214 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter <llornkcor@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.
**
**********************************************************************/
#include "notes.h"
#include <qapplication.h>
#include <stdlib.h>
#include <qstringlist.h>
+#include <opie2/otaskbarapplet.h>
#include <qpe/filemanager.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qpe/applnk.h>
#include <qpe/ir.h>
#include <qpe/config.h>
// #include <qsocket.h>
// #include <qclipboard.h>
#include <qmultilineedit.h>
#include <qlistbox.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
#include <qdir.h>
#include <qfile.h>
#include <qpoint.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qtimer.h>
/* XPM */
static char * notes_xpm[] = {
"16 16 11 1",
" c None",
". c #000000",
"+ c #7F7F7F",
"@ c #BFBFBF",
"# c #BFC1FF",
"$ c #FF0000",
"% c #FFFFFF",
"& c #00037F",
"* c #0006FF",
"= c #0005BF",
"- c #7F0000",
" .. ",
" .. ",
" ... ",
" .+ ",
" .@. ",
" . .+ ",
" ..#.@. ",
" ..###.+.. ",
" ..###$...##.. ",
"..###$$$%+$$##&.",
".*=####$-###&=&.",
".=**=###==&=&=..",
" ..=**=#&=&=.. ",
" ..=*=&=.. ",
" ..=.. ",
" . "};
NotesControl::NotesControl( QWidget *, const char * )
: QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop )
// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
QDir d( QDir::homeDirPath()+"/notes");
if( !d.exists()) {
qDebug("make dir");
if(!d.mkdir( QDir::homeDirPath()+"/notes", true))
qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed");
}
Config cfg("Notes");
cfg.setGroup("Options");
showMax = cfg.readBoolEntry("ShowMax", false);
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
loaded=false;
edited=false;
doPopulate=true;
isNew=false;
QVBox *vbox = new QVBox( this, "Vlayout" );
QHBox *hbox = new QHBox( this, "HLayout" );
view = new QMultiLineEdit(vbox, "OpieNotesView");
box = new QListBox(vbox, "OpieNotesBox");
QPEApplication::setStylusOperation( box->viewport(),QPEApplication::RightOnHold);
box->setFixedHeight(50);
vbox->setMargin( 6 );
vbox->setSpacing( 3 );
setFocusPolicy(QWidget::StrongFocus);
newButton= new QPushButton( hbox, "newButton" );
newButton->setText(tr("New"));
saveButton= new QPushButton( hbox, "saveButton" );
saveButton->setText(tr("Save"));
deleteButton= new QPushButton( hbox, "deleteButton" );
deleteButton->setText(tr("Delete"));
connect( box, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint&)),
this,SLOT( boxPressed(int, QListBoxItem *, const QPoint&)) );
connect(box, SIGNAL(highlighted(const QString&)), this, SLOT(slotBoxSelected(const QString &)));
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMenu() ) );
connect(view,SIGNAL( textChanged() ), this, SLOT(slotViewEdited() ) );
connect(newButton, SIGNAL(clicked()), this, SLOT(slotNewButton()));
connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveButton()));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(slotDeleteButtonClicked()));
populateBox();
load();
setCaption("Notes");
// parent->setFocus();
}
void NotesControl::slotSaveButton() {
slotNewButton();
populateBox();
}
void NotesControl::slotDeleteButtonClicked() {
switch ( QMessageBox::warning(this,tr("Delete?")
,tr("Do you really want to<BR><B> delete</B> this note ?")
,tr("Yes"),tr("No"),0,1,1) ) {
case 0:
slotDeleteButton();
break;
};
}
void NotesControl::slotDeleteButton() {
QString selectedText = box->currentText();
qDebug("deleting "+selectedText);
if( !selectedText.isEmpty()) {
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName, entryName2;;
for ( int i = 0; i < noOfFiles; i++ ) {
entryName.sprintf( "File%i", i + 1 );
if(selectedText == cfg.readEntry( entryName )) {
qDebug("removing %s, %d", selectedText.latin1(), i);
for ( int j = i; j < noOfFiles; j++ ) {
entryName.sprintf( "File%i", i + 1 );
entryName2.sprintf( "File%i", i + 2 );
QString temp = cfg.readEntry(entryName2);
qDebug("move "+temp);
cfg.writeEntry(entryName, temp);
i++;
}
cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
entryName.sprintf( "File%i", noOfFiles );
cfg.removeEntry(entryName);
cfg.write();
DocLnk nf(selectedText);
nf.removeFiles();
QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop";
qDebug(fi);
QFile f( fi);
if( !f.remove()) qDebug(".desktop file not removed");
}
}
view->clear();
populateBox();
}
}
void NotesControl::slotNewButton() {
if(edited) save();
view->clear();
view->setFocus();
edited=false;
isNew=false;
}
@@ -277,228 +278,237 @@ void NotesControl::focusOutEvent ( QFocusEvent * e) {
QWidget::focusOutEvent(e);
}
void NotesControl::save() {
Config cfg("Notes");
cfg.setGroup("Docs");
if( edited) {
// qDebug("is edited");
QString rt = view->text();
if( rt.length()>1) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ', pt.find( ' ' )+2 );
QString docname = pt;
if ( i > 0 )
docname = pt.left(i);
// remove "." at the beginning
while( docname.startsWith( "." ) )
docname = docname.mid( 1 );
docname.replace( QRegExp("/"), "_" );
// cut the length. filenames longer than that don't make sense
// and something goes wrong when they get too long.
if ( docname.length() > 40 )
docname = docname.left(40);
if ( docname.isEmpty() )
docname = "Empty Text";
// qDebug(docname);
if( oldDocName != docname) {
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
cfg.writeEntry( entryName,docname );
cfg.writeEntry("NumberOfFiles", noOfFiles+1 );
cfg.write();
}
// else
// qDebug("oldname equals docname");
doc = new DocLnk(docname);
if(QFile(doc->linkFile()).exists())
qDebug("puppie");
doc->setType("text/plain");
doc->setName(docname);
QString temp = docname.replace( QRegExp(" "), "_" );
doc->setFile( QDir::homeDirPath()+"/notes/"+temp);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
oldDocName=docname;
edited=false;
// qDebug("save");
if (doPopulate)
populateBox();
}
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::populateBox() {
box->clear();
// qDebug("populate");
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QStringList list;
QString entryName;
for ( int i = 0; i < noOfFiles; i++ ) {
entryName.sprintf( "File%i", i + 1 );
list.append(cfg.readEntry( entryName ));
}
list.sort();
box->insertStringList(list,-1);
doPopulate=false;
update();
}
void NotesControl::load() {
if(!loaded) {
Config cfg("Notes");
cfg.setGroup("Docs");
QString lastDoc=cfg.readEntry( "LastDoc","notes");
DocLnk nf;
nf.setType("text/plain");
nf.setFile(lastDoc);
loadDoc(nf);
loaded=true;
oldDocName=lastDoc;
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::load(const QString & file) {
qDebug("loading "+file);
QString name = file;
QString temp;
if( !QFile( QDir::homeDirPath()+"/"+file).exists() )
temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" );
else
temp = name;
if(!loaded) {
DocLnk nf;
nf.setType("text/plain");
nf.setFile( temp);
if(!temp.isEmpty())
loadDoc(nf);
loaded=true;
}
// view->setFocus();
oldDocName=file;
Config cfg("Notes");
cfg.setGroup("Docs");
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
void NotesControl::loadDoc( const DocLnk &f) {
FileManager fm;
QString txt;
if ( !fm.loadFile( f, txt ) ) {
qDebug("could not load file "+f.file());
return;
}
view->setText(txt);
}
void NotesControl::slotViewEdited() {
if(loaded) {
edited=true;
}
}
void NotesControl::slotShowMax() {
Config cfg("Notes");
cfg.setGroup("Options");
showMax=!showMax;
cfg.writeEntry("ShowMax", showMax);
cfg.write();
hide();
}
void NotesControl::slotSearch() {
int boxCount = box->count();
for(int i=0;i< boxCount;i++) {
}
}
// void NotesControl::keyReleaseEvent( QKeyEvent *e) {
// switch ( e->state() ) {
// case ControlButton:
// if(e->key() == Key_C) { //copy
// qDebug("copy");
// QClipboard *cb = QApplication::clipboard();
// QString text;
// // Copy text from the clipboard (paste)
// text = cb->text();
// }
// if(e->key() == Key_X) { //cut
// }
// if(e->key() == Key_V) { //paste
// QClipboard *cb = QApplication::clipboard();
// QString text;
// //view
// cb->setText();
// }
// break;
// };
// QWidget::keyReleaseEvent(e);
// }
//===========================================================================
NotesApplet::NotesApplet( QWidget *parent, const char *name )
: QWidget( parent, name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
vc = new NotesControl;
}
NotesApplet::~NotesApplet() {
delete vc;
}
+int NotesApplet::position()
+{
+ return 6;
+}
+
void NotesApplet::mousePressEvent( QMouseEvent *) {
if( !vc->isHidden()) {
vc->doPopulate=false;
vc->save();
vc->close();
} else {
// vc = new NotesControl;
// QPoint curPos = mapToGlobal( rect().topLeft() );
if(vc->showMax) {
qDebug("show max");
vc->showMaximized();
} else {
qDebug("no show max");
QWidget *wid = QPEApplication::desktop();
QRect rect = QApplication::desktop()->geometry();
vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180);
vc->move ( (rect.center()/2) - (vc->rect().center()/2));
// vc->move( (( wid->width() / 2) - ( vc->width() / 2 ))-4, 28);
}
vc->show();
vc->doPopulate=true;
vc->populateBox();
vc->doPopulate=false;
vc->loaded=false;
vc->load();
// this->setFocus();
vc->view->setFocus();
}
}
void NotesApplet::paintEvent( QPaintEvent* ) {
QPainter p(this);
p.drawPixmap( 0, 1, ( const char** ) notes_xpm );
}
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NotesApplet> );
+}
diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h
index 08253cb..ed1f98c 100644
--- a/noncore/applets/notesapplet/notes.h
+++ b/noncore/applets/notesapplet/notes.h
@@ -1,93 +1,94 @@
/**********************************************************************
** 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 __NOTES_APPLET_H__
#define __NOTES_APPLET_H__
#include <qwidget.h>
#include <qvbox.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include <qtimer.h>
#include <qpe/filemanager.h>
#include <qpe/ir.h>
#include <qstring.h>
class QComboBox;
class QCheckBox;
class QSpinBox;
class QPushButton;
class QMultiLineEdit;
class QListBox;
class QListBoxItem;
class NotesControl : public QVBox {
Q_OBJECT
public:
NotesControl( QWidget *parent=0, const char *name=0 );
QPixmap notes;
QMultiLineEdit *view;
QListBox *box;
QPushButton *saveButton, *deleteButton, *newButton;
QString FileNamePath;
bool loaded, edited, doPopulate, isNew;
bool showMax;
void save();
void populateBox();
void load();
private:
QTimer menuTimer;
DocLnk *doc;
QString oldDocName;
void focusOutEvent( QFocusEvent * );
void load(const QString&);
private slots:
void slotSearch();
void slotShowMax();
void slotBeamButton();
void slotBeamFinished( Ir*);
void slotDeleteButton();
void slotSaveButton();
void slotDeleteButtonClicked();
void slotNewButton();
void boxPressed(int, QListBoxItem *, const QPoint&);
void showMenu();
void loadDoc( const DocLnk &);
void slotViewEdited();
void slotBoxSelected(const QString &);
// void keyReleaseEvent( QKeyEvent *);
};
class NotesApplet : public QWidget {
Q_OBJECT
public:
NotesApplet( QWidget *parent = 0, const char *name=0 );
~NotesApplet();
+ static int position();
NotesControl *vc;
public slots:
private:
void mousePressEvent( QMouseEvent * );
void paintEvent( QPaintEvent* );
private:
QPixmap notesPixmap;
private slots:
};
#endif // __NOTES_APPLET_H__
diff --git a/noncore/applets/notesapplet/notesapplet.pro b/noncore/applets/notesapplet/notesapplet.pro
index 3075948..38ba184 100644
--- a/noncore/applets/notesapplet/notesapplet.pro
+++ b/noncore/applets/notesapplet/notesapplet.pro
@@ -1,16 +1,12 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = notes.h notesappletimpl.h
-SOURCES = notes.cpp notesappletimpl.cpp
+HEADERS = notes.h
+SOURCES = notes.cpp
TARGET = notesapplet
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 )
diff --git a/noncore/applets/notesapplet/notesappletimpl.cpp b/noncore/applets/notesapplet/notesappletimpl.cpp
deleted file mode 100644
index 8a9da7f..0000000
--- a/noncore/applets/notesapplet/notesappletimpl.cpp
+++ b/dev/null
@@ -1,53 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org>
-**
-**
-** 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.
-**
-**
-**********************************************************************/
-#include "notes.h"
-#include "notesappletimpl.h"
-
-
-NotesAppletImpl::NotesAppletImpl()
- : notes(0){
-}
-
-NotesAppletImpl::~NotesAppletImpl() {
- // not needed though cause we should have a valid parent
- delete notes;
-}
-
-QWidget *NotesAppletImpl::applet( QWidget *parent ) {
- if ( !notes )
- notes = new NotesApplet( parent );
- return notes;
-}
-
-int NotesAppletImpl::position() const {
- return 6;
-}
-
-QRESULT NotesAppletImpl::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( NotesAppletImpl )
-}
-
-
diff --git a/noncore/applets/notesapplet/notesappletimpl.h b/noncore/applets/notesapplet/notesappletimpl.h
deleted file mode 100644
index a87118c..0000000
--- a/noncore/applets/notesapplet/notesappletimpl.h
+++ b/dev/null
@@ -1,35 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2002 L.J. Potter <llornkcor@handhelds.org>
-**
-**
-** 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.
-**
-**
-**********************************************************************/
-#ifndef NOTESAPPLETIMPL_H
-#define NOTESAPPLETIMPL_H
-
-#include <qpe/taskbarappletinterface.h>
-
-class NotesApplet;
-
-class NotesAppletImpl : public TaskbarAppletInterface
-{
-public:
- NotesAppletImpl();
- virtual ~NotesAppletImpl();
-
- QRESULT queryInterface( const QUuid&, QUnknownInterface** );
- Q_REFCOUNT
-
- virtual QWidget *applet( QWidget *parent );
- virtual int position() const;
-
-private:
- NotesApplet *notes;
-};
-
-#endif
diff --git a/noncore/applets/zkbapplet/.cvsignore b/noncore/applets/zkbapplet/.cvsignore
new file mode 100644
index 0000000..0f79c04
--- a/dev/null
+++ b/noncore/applets/zkbapplet/.cvsignore
@@ -0,0 +1,6 @@
+Makefile*
+advancedconfigbase.cpp
+advancedconfigbase.h
+moc_*
+.moc
+.obj
diff --git a/noncore/applets/zkbapplet/zkbapplet.cpp b/noncore/applets/zkbapplet/zkbapplet.cpp
deleted file mode 100644
index 6c71568..0000000
--- a/noncore/applets/zkbapplet/zkbapplet.cpp
+++ b/dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <qlabel.h>
-#include <qbutton.h>
-#include <qwindowsystem_qws.h>
-#include "zkbapplet.h"
-#include "zkbwidget.h"
-
-
-ZkbApplet::ZkbApplet() : app(0){
-}
-
-ZkbApplet::~ZkbApplet()
-{
- if (app) delete app;
-}
-
-QWidget* ZkbApplet::applet(QWidget* parent) {
- if (app == 0) {
- app = new ZkbWidget(parent);
- }
-
- return app;
-}
-
-int ZkbApplet::position() const {
- return 8;
-}
-
-QRESULT ZkbApplet::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(ZkbApplet)
-}
diff --git a/noncore/applets/zkbapplet/zkbapplet.h b/noncore/applets/zkbapplet/zkbapplet.h
deleted file mode 100644
index fcf03b5..0000000
--- a/noncore/applets/zkbapplet/zkbapplet.h
+++ b/dev/null
@@ -1,23 +0,0 @@
-#include "qpe/taskbarappletinterface.h"
-
-#ifndef ZKBAPPLET_H
-#define ZKBAPPLET_H
-
-class ZkbWidget;
-
-class ZkbApplet : public TaskbarAppletInterface {
-public:
- ZkbApplet();
- virtual ~ZkbApplet();
-
- QRESULT queryInterface(const QUuid&, QUnknownInterface**);
- Q_REFCOUNT
-
- virtual QWidget* applet(QWidget*);
- virtual int position() const;
-
-protected:
- ZkbWidget* app;
-};
-
-#endif
diff --git a/noncore/applets/zkbapplet/zkbapplet.pro b/noncore/applets/zkbapplet/zkbapplet.pro
index 22615d0..8cc1b58 100644
--- a/noncore/applets/zkbapplet/zkbapplet.pro
+++ b/noncore/applets/zkbapplet/zkbapplet.pro
@@ -1,22 +1,20 @@
TEMPLATE = lib
CONFIG += qt plugin warn_on release
-HEADERS = zkbapplet.h\
- zkbwidget.h \
+HEADERS = zkbwidget.h \
../../apps/keyz-cfg/zkbcfg.h \
../../apps/keyz-cfg/zkbnames.h \
../../apps/keyz-cfg/zkbxml.h \
../../apps/keyz-cfg/zkb.h
-SOURCES = zkbapplet.cpp \
- zkbwidget.cpp \
+SOURCES = zkbwidget.cpp \
../../apps/keyz-cfg/zkbcfg.cpp \
../../apps/keyz-cfg/zkbnames.cpp \
../../apps/keyz-cfg/zkbxml.cpp \
../../apps/keyz-cfg/zkb.cpp
TARGET = zkbapplet
DESTDIR = $(OPIEDIR)/plugins/applets
INCLUDEPATH += $(OPIEDIR)/include ../../apps/keyz-cfg
DEPENDPATH += ../$(OPIEDIR)/include
VERSION = 0.6.0
LIBS += -lqpe
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/applets/zkbapplet/zkbwidget.cpp b/noncore/applets/zkbapplet/zkbwidget.cpp
index 05a76e7..0b5ab78 100644
--- a/noncore/applets/zkbapplet/zkbwidget.cpp
+++ b/noncore/applets/zkbapplet/zkbwidget.cpp
@@ -1,150 +1,162 @@
+#include <opie2/otaskbarapplet.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <stdio.h>
#include <unistd.h>
#include "zkbwidget.h"
#include "zkbcfg.h"
ZkbWidget::ZkbWidget(QWidget* parent):QLabel(parent),keymap(0),
disabled(Resource::loadPixmap("zkb-disabled")) {
labels = new QPopupMenu();
connect(labels, SIGNAL(activated(int)), this,
SLOT(labelChanged(int)));
loadKeymap();
channel = new QCopChannel("QPE/zkb", this);
connect(channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(signalReceived(const QCString&, const QByteArray&)));
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize() );
}
ZkbWidget::~ZkbWidget() {
}
+int ZkbWidget::position()
+{
+ return 8;
+}
+
bool ZkbWidget::loadKeymap() {
ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb");
QFontMetrics fm(font());
if (keymap != 0) {
delete keymap;
keymap = 0;
}
Keymap* km = new Keymap();
if (!c.load("zkb.xml", *km, "")) {
delete km;
setPixmap(disabled);
return false;
}
connect(km, SIGNAL(stateChanged(const QString&)),
this, SLOT(stateChanged(const QString&)));
qwsServer->setKeyboardFilter(km);
Keymap* oldkm = keymap;
keymap = km;
if (oldkm != 0) {
delete oldkm;
}
setText(keymap->getCurrentLabel());
labels->clear();
QStringList l = keymap->listLabels();
labels->insertItem(disabled, 0, 0);
int n = 1;
w = 0;
for(QStringList::Iterator it = l.begin(); it != l.end();
++it, n++) {
// printf("label: %s\n", (const char*) (*it).utf8());
labels->insertItem(*it, n, n);
int lw = fm.width(*it);
if (lw > w) {
w = lw;
}
}
if (w == 0) {
hide();
} else {
show();
}
return true;
}
QSize ZkbWidget::sizeHint() const {
return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize());
}
void ZkbWidget::stateChanged(const QString& s) {
// qDebug("stateChanged: %s\n", (const char*) s.utf8());
setText(s);
}
void ZkbWidget::labelChanged(int id) {
if (id == 0) {
keymap->disable();
setPixmap(disabled);
return;
}
keymap->enable();
QStringList l = keymap->listLabels();
QString lbl = l[id-1];
// printf("labelChanged: %s\n", (const char*) lbl.utf8());
State* state = keymap->getStateByLabel(lbl);
if (state != 0) {
keymap->setCurrentState(state);
setText(lbl);
}
}
void ZkbWidget::mouseReleaseEvent(QMouseEvent*) {
QSize sh = labels->sizeHint();
QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height()));
labels->exec(p);
}
void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) {
QDataStream stream(data, IO_ReadOnly);
if (msg == "enable()") {
keymap->enable();
} else if (msg == "disable()") {
keymap->disable();
} else if (msg == "reload()") {
QCopEnvelope("QPE/System", "busy()");
QTimer::singleShot(0, this, SLOT(reload()));
} else if (msg == "switch(QString)") {
QString lbl;
stream >> lbl;
if (keymap != 0) {
State* state = keymap->getStateByLabel(lbl);
if (state != 0) {
keymap->setCurrentState(state);
setText(lbl);
}
}
} else if (msg == "debug(QString)") {
QString flag;
stream >> flag;
}
}
void ZkbWidget::reload() {
loadKeymap();
QCopEnvelope("QPE/System", "notBusy()");
}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ZkbWidget> );
+}
+
diff --git a/noncore/applets/zkbapplet/zkbwidget.h b/noncore/applets/zkbapplet/zkbwidget.h
index a943563..7c67794 100644
--- a/noncore/applets/zkbapplet/zkbwidget.h
+++ b/noncore/applets/zkbapplet/zkbwidget.h
@@ -1,38 +1,39 @@
#ifndef ZKBWIDGET_H
#define ZKBWIDGET_H
#include <qwidget.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qpixmap.h>
#include <qcopchannel_qws.h>
#include "zkb.h"
class ZkbWidget : public QLabel {
Q_OBJECT
public:
ZkbWidget(QWidget* parent);
~ZkbWidget();
+ static int position();
QSize sizeHint() const;
protected:
QLabel* label;
Keymap* keymap;
QPopupMenu* labels;
QCopChannel* channel;
int w, h;
QPixmap disabled;
bool loadKeymap();
void mouseReleaseEvent(QMouseEvent*);
protected slots:
void stateChanged(const QString&);
void labelChanged(int id);
void signalReceived(const QCString& msg, const QByteArray& data);
void reload();
};
#endif