From 15318cad33835e4e2dc620d033e43cd930676cdd Mon Sep 17 00:00:00 2001 From: kergoth Date: Fri, 25 Jan 2002 22:14:26 +0000 Subject: Initial revision --- (limited to 'core/applets') diff --git a/core/applets/batteryapplet/.cvsignore b/core/applets/batteryapplet/.cvsignore new file mode 100644 index 0000000..edfa921 --- a/dev/null +++ b/core/applets/batteryapplet/.cvsignore @@ -0,0 +1,3 @@ +moc_* +*.moc +Makefile diff --git a/core/applets/batteryapplet/Makefile.in b/core/applets/batteryapplet/Makefile.in new file mode 100644 index 0000000..0493fd6 --- a/dev/null +++ b/core/applets/batteryapplet/Makefile.in @@ -0,0 +1,122 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../plugins/applets/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = batteryapplet +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = battery.h \ + batterystatus.h \ + batteryappletimpl.h +SOURCES = battery.cpp \ + batterystatus.cpp \ + batteryappletimpl.cpp +OBJECTS = battery.o \ + batterystatus.o \ + batteryappletimpl.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_battery.cpp +OBJMOC = moc_battery.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(SYSCONF_LINK_TARGET) + +$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK_LIB) + +moc: $(SRCMOC) + +tmake: + tmake batteryapplet.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +battery.o: battery.cpp \ + battery.h \ + batterystatus.h + +batterystatus.o: batterystatus.cpp \ + batterystatus.h + +batteryappletimpl.o: batteryappletimpl.cpp \ + battery.h \ + batteryappletimpl.h + +moc_battery.o: moc_battery.cpp \ + battery.h + +moc_battery.cpp: battery.h + $(MOC) battery.h -o moc_battery.cpp + + diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp new file mode 100644 index 0000000..3d254fc --- a/dev/null +++ b/core/applets/batteryapplet/battery.cpp @@ -0,0 +1,152 @@ +/********************************************************************** +** 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 "battery.h" +#include "batterystatus.h" + +#include + +#include +#include + + +BatteryMeter::BatteryMeter( QWidget *parent = 0 ) + : QWidget( parent ), charging(false) +{ + ps = new PowerStatus; + startTimer( 10000 ); + setFixedHeight(12); + chargeTimer = new QTimer( this ); + connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); + timerEvent(0); +} + +BatteryMeter::~BatteryMeter() +{ + delete ps; +} + +QSize BatteryMeter::sizeHint() const +{ + return QSize(10,12); +} + +void BatteryMeter::mouseReleaseEvent( QMouseEvent *) +{ + if ( batteryView && batteryView->isVisible() ) { + delete (QWidget *) batteryView; + } else { + if ( !batteryView ) + batteryView = new BatteryStatus( ps ); + batteryView->showMaximized(); + batteryView->raise(); + batteryView->show(); + } +} + +void BatteryMeter::timerEvent( QTimerEvent * ) +{ + PowerStatus prev = *ps; + + *ps = PowerStatusManager::readStatus(); + + if ( prev != *ps ) { + percent = ps->batteryPercentRemaining(); + if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { + percent = 0; + charging = true; + chargeTimer->start( 500 ); + } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { + charging = false; + chargeTimer->stop(); + if ( batteryView ) + batteryView->updatePercent( percent ); + } + repaint(FALSE); + if ( batteryView ) + batteryView->repaint(); + } +} + +void BatteryMeter::chargeTimeout() +{ + percent += 20; + if ( percent > 100 ) + percent = 0; + + repaint(FALSE); + if ( batteryView ) + batteryView->updatePercent( percent ); +} + +void BatteryMeter::paintEvent( QPaintEvent* ) +{ + QPainter p(this); + + QColor c; + QColor darkc; + QColor lightc; + if ( ps->acStatus() == PowerStatus::Offline ) { + c = blue.light(120); + darkc = c.dark(120); + lightc = c.light(140); + } else if ( ps->acStatus() == PowerStatus::Online ) { + c = green.dark(130); + darkc = c.dark(120); + lightc = c.light(180); + } else { + c = red; + darkc = c.dark(120); + lightc = c.light(160); + } + + int w = 6; + int h = height()-3; + int pix = (percent * h) / 100; + int y2 = height() - 2; + int y = y2 - pix; + int x1 = (width() - w) / 2; + + p.setPen(QColor(80,80,80)); + p.drawLine(x1+w/4,0,x1+w/4+w/2,0); + p.drawRect(x1,1,w,height()-1); + p.setBrush(c); + + int extra = ((percent * h) % 100)/(100/4); + +#define Y(i) ((i<=extra)?y-1:y) +#define DRAWUPPER(i) if ( Y(i) >= 2 ) p.drawLine(i+x1,2,i+x1,Y(i)); + p.setPen( gray ); + DRAWUPPER(1); + DRAWUPPER(3); + p.setPen( gray.light(130) ); + DRAWUPPER(2); + p.setPen( gray.dark(120) ); + DRAWUPPER(4); + +#define DRAW(i) { if ( Y(i) < y2 ) p.drawLine(i+x1,Y(i)+1,i+x1,y2); } + p.setPen( c ); + DRAW(1); + DRAW(3); + p.setPen( lightc ); + DRAW(2); + p.setPen(darkc); + DRAW(4); +} + diff --git a/core/applets/batteryapplet/battery.h b/core/applets/batteryapplet/battery.h new file mode 100644 index 0000000..d4807b0 --- a/dev/null +++ b/core/applets/batteryapplet/battery.h @@ -0,0 +1,55 @@ +/********************************************************************** +** 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 BATTERY_H +#define BATTERY_H + +#include +#include + +class PowerStatus; +class BatteryStatus; +class QTimer; + +class BatteryMeter : public QWidget +{ + Q_OBJECT +public: + BatteryMeter( QWidget *parent = 0 ); + ~BatteryMeter(); + + QSize sizeHint() const; + +protected: + void timerEvent( QTimerEvent * ); + void paintEvent( QPaintEvent* ); + void mouseReleaseEvent( QMouseEvent * ); + +protected slots: + void chargeTimeout(); + +protected: + QGuardedPtr batteryView; + PowerStatus *ps; + QTimer *chargeTimer; + int percent; + bool charging; +}; + +#endif diff --git a/core/applets/batteryapplet/batteryapplet.pro b/core/applets/batteryapplet/batteryapplet.pro new file mode 100644 index 0000000..fa0fca8 --- a/dev/null +++ b/core/applets/batteryapplet/batteryapplet.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = battery.h batterystatus.h batteryappletimpl.h +SOURCES = battery.cpp batterystatus.cpp batteryappletimpl.cpp +TARGET = batteryapplet +DESTDIR = ../../plugins/applets +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include .. +LIBS += -lqpe +VERSION = 1.0.0 + +TRANSLATIONS += ../../i18n/de/libbatteryapplet.ts diff --git a/core/applets/batteryapplet/batteryappletimpl.cpp b/core/applets/batteryapplet/batteryappletimpl.cpp new file mode 100644 index 0000000..3f3079a --- a/dev/null +++ b/core/applets/batteryapplet/batteryappletimpl.cpp @@ -0,0 +1,63 @@ +/********************************************************************** +** 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 "battery.h" +#include "batteryappletimpl.h" + + +BatteryAppletImpl::BatteryAppletImpl() + : battery(0), ref(0) +{ +} + +BatteryAppletImpl::~BatteryAppletImpl() +{ + delete battery; +} + +QWidget *BatteryAppletImpl::applet( QWidget *parent ) +{ + if ( !battery ) + battery = new BatteryMeter( parent ); + return battery; +} + +int BatteryAppletImpl::position() const +{ + return 8; +} + +QRESULT BatteryAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_TaskbarApplet ) + *iface = this; + + if ( *iface ) + (*iface)->addRef(); + return QS_OK; +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( BatteryAppletImpl ) +} + diff --git a/core/applets/batteryapplet/batteryappletimpl.h b/core/applets/batteryapplet/batteryappletimpl.h new file mode 100644 index 0000000..94f49db --- a/dev/null +++ b/core/applets/batteryapplet/batteryappletimpl.h @@ -0,0 +1,44 @@ +/********************************************************************** +** 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 BATTERYAPPLETIMPL_H +#define BATTERYAPPLETIMPL_H + +#include + +class BatteryMeter; + +class BatteryAppletImpl : public TaskbarAppletInterface +{ +public: + BatteryAppletImpl(); + virtual ~BatteryAppletImpl(); + + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT + + virtual QWidget *applet( QWidget *parent ); + virtual int position() const; + +private: + BatteryMeter *battery; + ulong ref; +}; + +#endif diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp new file mode 100644 index 0000000..d18b6c9 --- a/dev/null +++ b/core/applets/batteryapplet/batterystatus.cpp @@ -0,0 +1,140 @@ +/********************************************************************** +** 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 "batterystatus.h" + +#include + +#include +#include +#include + + +BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) + : QWidget( parent, 0, WDestructiveClose), ps(p) +{ + setCaption( tr("Battery Status") ); + QPushButton *pb = new QPushButton( tr("Close"), this ); + pb->move( 70, 220 ); + pb->show(); + connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); + percent = ps->batteryPercentRemaining(); + show(); +} + +BatteryStatus::~BatteryStatus() +{ +} + +void BatteryStatus::updatePercent( int pc ) +{ + percent = pc; + repaint(FALSE); +} + +void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) +{ + int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; + topgrad.hsv( &h1, &s1, &v1 ); + botgrad.hsv( &h2, &s2, &v2 ); + for ( int j = 0; j < hy-2; j++ ) { + p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), + v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); + p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); + } + for ( int j = 0; j < hh; j++ ) { + p->setPen( highlight ); + p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); + } + for ( int j = 0; j < ng-hy-hh; j++ ) { + p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), + v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); + p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); + } +} + +void BatteryStatus::paintEvent( QPaintEvent * ) +{ + QPainter p(this); + QString text; + if ( ps->batteryStatus() == PowerStatus::Charging ) { + text = tr("Charging"); + } else if ( ps->batteryPercentAccurate() ) { + text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); + } else { + text = tr("Battery status: "); + switch ( ps->batteryStatus() ) { + case PowerStatus::High: + text += tr("Good"); + break; + case PowerStatus::Low: + text += tr("Low"); + break; + case PowerStatus::VeryLow: + text += tr("Very Low"); + break; + case PowerStatus::Critical: + text += tr("Critical"); + break; + default: // NotPresent, etc. + text += tr("Unknown"); + } + } + p.drawText( 10, 120, text ); + if ( ps->acStatus() == PowerStatus::Backup ) + p.drawText( 10, 150, tr("On backup power") ); + else if ( ps->acStatus() == PowerStatus::Online ) + p.drawText( 10, 150, tr("Power on-line") ); + else if ( ps->acStatus() == PowerStatus::Offline ) + p.drawText( 10, 150, tr("External power disconnected") ); + + if ( ps->batteryTimeRemaining() >= 0 ) { + text.sprintf( tr("Battery time remaining") + ": %im %02is", + ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); + p.drawText( 10, 180, text ); + } + + QColor c; + QColor darkc; + QColor lightc; + if ( ps->acStatus() == PowerStatus::Offline ) { + c = blue.light(120); + darkc = c.dark(280); + lightc = c.light(145); + } else if ( ps->acStatus() == PowerStatus::Online ) { + c = green.dark(130); + darkc = c.dark(200); + lightc = c.light(220); + } else { + c = red; + darkc = c.dark(280); + lightc = c.light(140); + } + if ( percent < 0 ) + return; + + int percent2 = percent * 2; + p.setPen( black ); + qDrawShadePanel( &p, 9, 30, 204, 39, colorGroup(), TRUE, 1, NULL); + qDrawShadePanel( &p, 212, 37, 12, 24, colorGroup(), TRUE, 1, NULL); + drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); + drawSegment( &p, QRect( 11 + percent2, 30, 200 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); + drawSegment( &p, QRect( 212, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); +} + diff --git a/core/applets/batteryapplet/batterystatus.h b/core/applets/batteryapplet/batterystatus.h new file mode 100644 index 0000000..85b2c4d --- a/dev/null +++ b/core/applets/batteryapplet/batterystatus.h @@ -0,0 +1,45 @@ +/********************************************************************** +** 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 BATTERY_STATUS_H +#define BATTERY_STATUS_H + +#include + +class PowerStatus; + +class BatteryStatus : public QWidget +{ +public: + BatteryStatus( const PowerStatus *s, QWidget *parent=0 ); + ~BatteryStatus(); + + void updatePercent( int ); + +protected: + void drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ); + void paintEvent( QPaintEvent *pe ); + +private: + const PowerStatus *ps; + int percent; +}; + +#endif + diff --git a/core/applets/batteryapplet/qpe-batteryapplet.control b/core/applets/batteryapplet/qpe-batteryapplet.control new file mode 100644 index 0000000..83d0b8b --- a/dev/null +++ b/core/applets/batteryapplet/qpe-batteryapplet.control @@ -0,0 +1,9 @@ +Files: plugins/applets/libbatteryapplet.so* +Priority: optional +Section: qpe/taskbar +Maintainer: Warwick Allison +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Battery Monitor applet + Battery Monitor applet for the Qtopia environment taskbar. diff --git a/core/applets/batteryapplet/qpe-batteryapplet.postinst b/core/applets/batteryapplet/qpe-batteryapplet.postinst new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/batteryapplet/qpe-batteryapplet.postinst @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/batteryapplet/qpe-batteryapplet.postrm b/core/applets/batteryapplet/qpe-batteryapplet.postrm new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/batteryapplet/qpe-batteryapplet.postrm @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/clipboardapplet/Makefile.in b/core/applets/clipboardapplet/Makefile.in new file mode 100644 index 0000000..2ddeb42 --- a/dev/null +++ b/core/applets/clipboardapplet/Makefile.in @@ -0,0 +1,115 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../plugins/applets/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = clipboardapplet +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = clipboard.h \ + clipboardappletimpl.h +SOURCES = clipboard.cpp \ + clipboardappletimpl.cpp +OBJECTS = clipboard.o \ + clipboardappletimpl.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_clipboard.cpp +OBJMOC = moc_clipboard.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(SYSCONF_LINK_TARGET) + +$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK_LIB) + +moc: $(SRCMOC) + +tmake: + tmake clipboardapplet.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +clipboard.o: clipboard.cpp \ + clipboard.h + +clipboardappletimpl.o: clipboardappletimpl.cpp \ + clipboard.h \ + clipboardappletimpl.h + +moc_clipboard.o: moc_clipboard.cpp \ + clipboard.h + +moc_clipboard.cpp: clipboard.h + $(MOC) clipboard.h -o moc_clipboard.cpp + + diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp new file mode 100644 index 0000000..57beffc --- a/dev/null +++ b/core/applets/clipboardapplet/clipboard.cpp @@ -0,0 +1,80 @@ +/********************************************************************** +** 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 + +#include +#include +#include + + +//=========================================================================== + +ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + setFixedWidth( 14 ); + clipboardPixmap = Resource::loadPixmap( "clipboard" ); + menu = 0; +} + +ClipboardApplet::~ClipboardApplet() +{ +} + +void ClipboardApplet::mousePressEvent( QMouseEvent *) +{ + if ( !menu ) { + menu = new QPopupMenu(this); + menu->insertItem(tr("Cut")); + menu->insertItem(tr("Copy")); + menu->insertItem(tr("Paste")); + connect(menu, SIGNAL(selected(int)), this, SLOT(action(int))); + } + menu->popup(mapToGlobal(QPoint(0,0))); +} + +void ClipboardApplet::action(int i) +{ + ushort unicode=0; + int scan=0; + + if ( i == 0 ) + { unicode='X'-'@'; scan=Key_X; } // Cut + else if ( i == 1 ) + { unicode='C'-'@'; scan=Key_C; } // Copy + else if ( i == 2 ) + { unicode='V'-'@'; scan=Key_V; } // Paste + + if ( scan ) { + qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); + qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); + } +} + +void ClipboardApplet::paintEvent( QPaintEvent* ) +{ + QPainter p(this); + p.drawPixmap( 0, 1, clipboardPixmap ); +} + + diff --git a/core/applets/clipboardapplet/clipboard.h b/core/applets/clipboardapplet/clipboard.h new file mode 100644 index 0000000..9dd59ed --- a/dev/null +++ b/core/applets/clipboardapplet/clipboard.h @@ -0,0 +1,47 @@ +/********************************************************************** +** 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 +#include + +class ClipboardApplet : public QWidget +{ + Q_OBJECT +public: + ClipboardApplet( QWidget *parent = 0, const char *name=0 ); + ~ClipboardApplet(); + +protected: + void mousePressEvent( QMouseEvent *); + void paintEvent( QPaintEvent* ); + +private slots: + void action(int); + +private: + QPopupMenu* menu; + QPixmap clipboardPixmap; +}; + + +#endif // __CLIPBOARD_APPLET_H__ + diff --git a/core/applets/clipboardapplet/clipboardapplet.pro b/core/applets/clipboardapplet/clipboardapplet.pro new file mode 100644 index 0000000..b0624ef --- a/dev/null +++ b/core/applets/clipboardapplet/clipboardapplet.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = clipboard.h clipboardappletimpl.h +SOURCES = clipboard.cpp clipboardappletimpl.cpp +TARGET = clipboardapplet +DESTDIR = ../../plugins/applets +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include +LIBS += -lqpe +VERSION = 1.0.0 diff --git a/core/applets/clipboardapplet/clipboardappletimpl.cpp b/core/applets/clipboardapplet/clipboardappletimpl.cpp new file mode 100644 index 0000000..8080690 --- a/dev/null +++ b/core/applets/clipboardapplet/clipboardappletimpl.cpp @@ -0,0 +1,64 @@ +/********************************************************************** +** 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), ref(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; + + 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 new file mode 100644 index 0000000..0426109 --- a/dev/null +++ b/core/applets/clipboardapplet/clipboardappletimpl.h @@ -0,0 +1,44 @@ +/********************************************************************** +** 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 + +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; + ulong ref; +}; + +#endif diff --git a/core/applets/clipboardapplet/qpe-clipboardapplet.control b/core/applets/clipboardapplet/qpe-clipboardapplet.control new file mode 100644 index 0000000..26cbc55 --- a/dev/null +++ b/core/applets/clipboardapplet/qpe-clipboardapplet.control @@ -0,0 +1,9 @@ +Files: plugins/applets/libclipboardapplet.so* +Priority: optional +Section: qpe/taskbar +Maintainer: Warwick Allison +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Clipboard applet + Clipboard applet for the Qtopia environment taskbar. diff --git a/core/applets/clipboardapplet/qpe-clipboardapplet.postinst b/core/applets/clipboardapplet/qpe-clipboardapplet.postinst new file mode 100644 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/clipboardapplet/qpe-clipboardapplet.postinst @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/clipboardapplet/qpe-clipboardapplet.postrm b/core/applets/clipboardapplet/qpe-clipboardapplet.postrm new file mode 100644 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/clipboardapplet/qpe-clipboardapplet.postrm @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/clockapplet/.cvsignore b/core/applets/clockapplet/.cvsignore new file mode 100644 index 0000000..edfa921 --- a/dev/null +++ b/core/applets/clockapplet/.cvsignore @@ -0,0 +1,3 @@ +moc_* +*.moc +Makefile diff --git a/core/applets/clockapplet/Makefile.in b/core/applets/clockapplet/Makefile.in new file mode 100644 index 0000000..fcf737e --- a/dev/null +++ b/core/applets/clockapplet/Makefile.in @@ -0,0 +1,115 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../plugins/applets/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = clockapplet +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = clock.h \ + clockappletimpl.h +SOURCES = clock.cpp \ + clockappletimpl.cpp +OBJECTS = clock.o \ + clockappletimpl.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_clock.cpp +OBJMOC = moc_clock.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(SYSCONF_LINK_TARGET) + +$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK_LIB) + +moc: $(SRCMOC) + +tmake: + tmake clockapplet.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +clock.o: clock.cpp \ + clock.h + +clockappletimpl.o: clockappletimpl.cpp \ + clock.h \ + clockappletimpl.h + +moc_clock.o: moc_clock.cpp \ + clock.h + +moc_clock.cpp: clock.h + $(MOC) clock.h -o moc_clock.cpp + + diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp new file mode 100644 index 0000000..178dcbe --- a/dev/null +++ b/core/applets/clockapplet/clock.cpp @@ -0,0 +1,97 @@ +/********************************************************************** +** 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +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", 10, QFont::Normal ) ); + connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); + connect( qApp, SIGNAL( clockChanged( bool ) ), + this, SLOT( slotClockChanged( bool ) ) ); + Config config( "qpe" ); + config.setGroup( "Time" ); + ampmFormat = config.readBoolEntry( "AMPM", TRUE ); + timerId = 0; + timerEvent( 0 ); + show(); +} + +void LauncherClock::mouseReleaseEvent( QMouseEvent * ) +{ + Global::execute( "systemtime" ); +} + + +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%c%02d %s", hour, ':', tm.minute(), (tm.hour() >= 12) ? "PM" : "AM" ); + } else + s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); + setText( s ); +} + +void LauncherClock::slotClockChanged( bool pm ) +{ + ampmFormat = pm; + updateTime(); +} diff --git a/core/applets/clockapplet/clock.h b/core/applets/clockapplet/clock.h new file mode 100644 index 0000000..9670d90 --- a/dev/null +++ b/core/applets/clockapplet/clock.h @@ -0,0 +1,46 @@ +/********************************************************************** +** 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 +#include + +class LauncherClock : public QLabel +{ + Q_OBJECT +public: + LauncherClock( QWidget *parent ); + +protected slots: + void updateTime( void ); + void slotClockChanged( bool pm ); + +protected: + void mouseReleaseEvent( QMouseEvent * ); + void timerEvent( QTimerEvent * ); + void changeTime( void ); + bool ampmFormat; + int timerId; +}; + + +#endif // __LAUNCHER_CLOCK_H__ diff --git a/core/applets/clockapplet/clockapplet.pro b/core/applets/clockapplet/clockapplet.pro new file mode 100644 index 0000000..29a4e8b --- a/dev/null +++ b/core/applets/clockapplet/clockapplet.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = clock.h clockappletimpl.h +SOURCES = clock.cpp clockappletimpl.cpp +TARGET = clockapplet +DESTDIR = ../../plugins/applets +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include .. +LIBS += -lqpe +VERSION = 1.0.0 + +TRANSLATIONS += ../../i18n/de/libclockapplet.ts diff --git a/core/applets/clockapplet/clockappletimpl.cpp b/core/applets/clockapplet/clockappletimpl.cpp new file mode 100644 index 0000000..8bf1baf --- a/dev/null +++ b/core/applets/clockapplet/clockappletimpl.cpp @@ -0,0 +1,65 @@ +/********************************************************************** +** 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), ref(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; + + 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 new file mode 100644 index 0000000..0c0912e --- a/dev/null +++ b/core/applets/clockapplet/clockappletimpl.h @@ -0,0 +1,46 @@ +/********************************************************************** +** 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 + +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; + ulong ref; +}; + +#endif diff --git a/core/applets/clockapplet/qpe-clockapplet.control b/core/applets/clockapplet/qpe-clockapplet.control new file mode 100644 index 0000000..9532ca8 --- a/dev/null +++ b/core/applets/clockapplet/qpe-clockapplet.control @@ -0,0 +1,9 @@ +Files: plugins/applets/libclockapplet.so* +Priority: optional +Section: qpe/taskbar +Maintainer: Warwick Allison +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Clock applet + Clock applet for the Qtopia environment taskbar. diff --git a/core/applets/clockapplet/qpe-clockapplet.postinst b/core/applets/clockapplet/qpe-clockapplet.postinst new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/clockapplet/qpe-clockapplet.postinst @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/clockapplet/qpe-clockapplet.postrm b/core/applets/clockapplet/qpe-clockapplet.postrm new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/clockapplet/qpe-clockapplet.postrm @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/volumeapplet/.cvsignore b/core/applets/volumeapplet/.cvsignore new file mode 100644 index 0000000..edfa921 --- a/dev/null +++ b/core/applets/volumeapplet/.cvsignore @@ -0,0 +1,3 @@ +moc_* +*.moc +Makefile diff --git a/core/applets/volumeapplet/Makefile.in b/core/applets/volumeapplet/Makefile.in new file mode 100644 index 0000000..7020cb7 --- a/dev/null +++ b/core/applets/volumeapplet/Makefile.in @@ -0,0 +1,115 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) +INCPATH = -I$(QPEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = ../../plugins/applets/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = volumeapplet +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = volume.h \ + volumeappletimpl.h +SOURCES = volume.cpp \ + volumeappletimpl.cpp +OBJECTS = volume.o \ + volumeappletimpl.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_volume.cpp +OBJMOC = moc_volume.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(SYSCONF_LINK_TARGET) + +$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK_LIB) + +moc: $(SRCMOC) + +tmake: + tmake volumeapplet.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +volume.o: volume.cpp \ + volume.h + +volumeappletimpl.o: volumeappletimpl.cpp \ + volume.h \ + volumeappletimpl.h + +moc_volume.o: moc_volume.cpp \ + volume.h + +moc_volume.cpp: volume.h + $(MOC) volume.h -o moc_volume.cpp + + diff --git a/core/applets/volumeapplet/qpe-volumeapplet.control b/core/applets/volumeapplet/qpe-volumeapplet.control new file mode 100644 index 0000000..a80262a --- a/dev/null +++ b/core/applets/volumeapplet/qpe-volumeapplet.control @@ -0,0 +1,9 @@ +Files: plugins/applets/libvolumeapplet.so* +Priority: optional +Section: qpe/taskbar +Maintainer: Warwick Allison +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qpe-base ($QPE_VERSION) +Description: Volume applet + Volume applet for the Qtopia environment taskbar. diff --git a/core/applets/volumeapplet/qpe-volumeapplet.postinst b/core/applets/volumeapplet/qpe-volumeapplet.postinst new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/volumeapplet/qpe-volumeapplet.postinst @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/volumeapplet/qpe-volumeapplet.postrm b/core/applets/volumeapplet/qpe-volumeapplet.postrm new file mode 100755 index 0000000..ba76ffa --- a/dev/null +++ b/core/applets/volumeapplet/qpe-volumeapplet.postrm @@ -0,0 +1,2 @@ +#!/bin/sh +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadApplets()" diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp new file mode 100644 index 0000000..35dbf22 --- a/dev/null +++ b/core/applets/volumeapplet/volume.cpp @@ -0,0 +1,199 @@ +/********************************************************************** +** 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 +#include +#include +#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) +#include +#endif + +#include +#include +#include +#include +#include +#include + + +VolumeControl::VolumeControl( QWidget *parent, const char *name ) + : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) +{ + setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); + + QVBoxLayout *vbox = new QVBoxLayout( this ); + slider = new QSlider( this ); + muteBox = new QCheckBox( tr("Mute"), this ); + slider->setRange( 0, 100 ); + slider->setTickmarks( QSlider::Both ); + slider->setTickInterval( 20 ); + slider->setFocusPolicy( QWidget::NoFocus ); + muteBox->setFocusPolicy( QWidget::NoFocus ); + vbox->setMargin( 6 ); + vbox->setSpacing( 3 ); + vbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); + vbox->addWidget( muteBox ); + setFixedHeight( 100 ); + setFixedWidth( sizeHint().width() ); + setFocusPolicy(QWidget::NoFocus); +} + +void VolumeControl::keyPressEvent( QKeyEvent *e) +{ + switch(e->key()) { + case Key_Up: + slider->subtractStep(); + break; + case Key_Down: + slider->addStep(); + break; + case Key_Space: + muteBox->toggle(); + break; + case Key_Escape: + close(); + break; + } +} + +//=========================================================================== + +VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + setFixedHeight( 18 ); + setFixedWidth( 14 ); + volumePixmap = Resource::loadPixmap( "volume" ); + muted = FALSE; // ### read from pref + volumePercent = 50; // ### read from pref + connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); + writeSystemVolume(); +} + +VolumeApplet::~VolumeApplet() +{ +} + +void VolumeApplet::mousePressEvent( QMouseEvent *) +{ + // Create a small volume control window to adjust the volume with + VolumeControl *vc = new VolumeControl; + vc->slider->setValue( 100 - volumePercent ); + vc->muteBox->setChecked( muted ); + connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); + connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); + QPoint curPos = mapToGlobal( rect().topLeft() ); + vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 ); + vc->show(); +} + +void VolumeApplet::volumeChanged( bool nowMuted ) +{ + int previousVolume = volumePercent; + + if ( !nowMuted ) + readSystemVolume(); + + // Handle case where muting it toggled + if ( muted != nowMuted ) { + muted = nowMuted; + repaint( TRUE ); + return; + } + + // Avoid over repainting + if ( previousVolume != volumePercent ) + repaint( 2, height() - 3, width() - 4, 2, FALSE ); +} + + +void VolumeApplet::mute( bool toggled ) +{ + muted = toggled; + // clear if removing mute + repaint( !toggled ); + writeSystemVolume(); +} + + +void VolumeApplet::sliderMoved( int percent ) +{ + setVolume( 100 - percent ); +} + + +void VolumeApplet::readSystemVolume() +{ + Config cfg("Sound"); + cfg.setGroup("System"); + volumePercent = cfg.readNumEntry("Volume"); +} + + +void VolumeApplet::setVolume( int percent ) +{ + // clamp volume percent to be between 0 and 100 + volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); + // repaint just the little volume rectangle + repaint( 2, height() - 3, width() - 4, 2, FALSE ); + writeSystemVolume(); +} + + +void VolumeApplet::writeSystemVolume() +{ + { + Config cfg("Sound"); + cfg.setGroup("System"); + cfg.writeEntry("Volume",volumePercent); + } +#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) + // Send notification that the volume has changed + QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; +#endif +} + + +void VolumeApplet::paintEvent( QPaintEvent* ) +{ + QPainter p(this); + + if (volumePixmap.isNull()) + volumePixmap = Resource::loadPixmap( "volume" ); + p.drawPixmap( 0, 1, volumePixmap ); + p.setPen( darkGray ); + p.drawRect( 1, height() - 4, width() - 2, 4 ); + + int pixelsWide = volumePercent * (width() - 4) / 100; + p.fillRect( 2, height() - 3, pixelsWide, 2, red ); + p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); + + if ( muted ) { + 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 ); + } +} + + diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h new file mode 100644 index 0000000..5704cad --- a/dev/null +++ b/core/applets/volumeapplet/volume.h @@ -0,0 +1,75 @@ +/********************************************************************** +** 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 __VOLUME_APPLET_H__ +#define __VOLUME_APPLET_H__ + + +#include +#include +#include +#include + +class QSlider; +class QCheckBox; + +class VolumeControl : public QFrame +{ + Q_OBJECT +public: + VolumeControl( QWidget *parent=0, const char *name=0 ); + +public: + QSlider *slider; + QCheckBox *muteBox; + +private: + void keyPressEvent( QKeyEvent * ); +}; + +class VolumeApplet : public QWidget +{ + Q_OBJECT +public: + VolumeApplet( QWidget *parent = 0, const char *name=0 ); + ~VolumeApplet(); + bool isMute( ) { return muted; } + int percent( ) { return volumePercent; } + +public slots: + void volumeChanged( bool muted ); + void setVolume( int percent ); + void sliderMoved( int percent ); + void mute( bool ); + +private: + void readSystemVolume(); + void writeSystemVolume(); + void mousePressEvent( QMouseEvent * ); + void paintEvent( QPaintEvent* ); + +private: + int volumePercent; + bool muted; + QPixmap volumePixmap; +}; + + +#endif // __VOLUME_APPLET_H__ + diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro new file mode 100644 index 0000000..a33cf81 --- a/dev/null +++ b/core/applets/volumeapplet/volumeapplet.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = volume.h volumeappletimpl.h +SOURCES = volume.cpp volumeappletimpl.cpp +TARGET = volumeapplet +DESTDIR = ../../plugins/applets +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += ../$(QPEDIR)/include +LIBS += -lqpe +VERSION = 1.0.0 + +TRANSLATIONS += ../../i18n/de/libvolumeapplet.ts diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp new file mode 100644 index 0000000..676ab61 --- a/dev/null +++ b/core/applets/volumeapplet/volumeappletimpl.cpp @@ -0,0 +1,64 @@ +/********************************************************************** +** 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), ref(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; + + 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 new file mode 100644 index 0000000..9b2952a --- a/dev/null +++ b/core/applets/volumeapplet/volumeappletimpl.h @@ -0,0 +1,44 @@ +/********************************************************************** +** 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 + +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; + ulong ref; +}; + +#endif -- cgit v0.9.0.2