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/clockapplet') 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()" -- cgit v0.9.0.2