From 81171716bb686e709f27fbbc0931740aa9d9462a Mon Sep 17 00:00:00 2001 From: mickeyl Date: Tue, 16 Sep 2003 12:31:09 +0000 Subject: virtual terminal applet says: "Hello" --- diff --git a/core/applets/vtapplet/.cvsignore b/core/applets/vtapplet/.cvsignore new file mode 100644 index 0000000..c55c0bc --- a/dev/null +++ b/core/applets/vtapplet/.cvsignore @@ -0,0 +1 @@ +Makefile* diff --git a/core/applets/vtapplet/config.in b/core/applets/vtapplet/config.in new file mode 100644 index 0000000..85692a5 --- a/dev/null +++ b/core/applets/vtapplet/config.in @@ -0,0 +1,4 @@ + config VTAPPLET + boolean "VT (switch to another virtual terminal)" + default "y" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp new file mode 100644 index 0000000..6200447 --- a/dev/null +++ b/core/applets/vtapplet/vt.cpp @@ -0,0 +1,143 @@ +/********************************************************************** +** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. +** +** Contact me @ mickeyl@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. +** +** 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 +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "vt.h" + +class VTPopupMenu : public QPopupMenu +{ + public: + VTPopupMenu( QWidget * parent=0, const char * name=0 ) : QPopupMenu( parent, name ) {}; + + virtual void activated() { qDebug( "VTPopupMenu::activated()" ); } +}; + +VTApplet::VTApplet ( ) + : QObject ( 0, "VTApplet" ), ref ( 0 ) +{ +} + +VTApplet::~VTApplet ( ) +{ +} + +int VTApplet::position ( ) const +{ + return 2; +} + +QString VTApplet::name ( ) const +{ + return tr( "VT shortcut" ); +} + +QString VTApplet::text ( ) const +{ + return tr( "Terminal" ); +} + +/* +QString VTApplet::tr( const char* s ) const +{ + return qApp->translate( "VTApplet", s, 0 ); +} + +QString VTApplet::tr( const char* s, const char* p ) const +{ + return qApp->translate( "VTApplet", s, p ); +} +*/ + +QIconSet VTApplet::icon ( ) const +{ + QPixmap pix; + QImage img = Resource::loadImage ( "terminal" ); + + if ( !img. isNull ( )) + pix. convertFromImage ( img. smoothScale ( 14, 14 )); + return pix; +} + +QPopupMenu *VTApplet::popup ( QWidget* parent ) const +{ + qDebug( "VTApplet::popup" ); + + struct vt_stat vtstat; + int fd = ::open("/dev/tty0", O_RDWR); + if ( fd == -1 ) return 0; + if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; + + submenu = new VTPopupMenu( parent ); + submenu->setCheckable( true ); + for ( int i = 1; i < 10; ++i ) + { + int id = submenu->insertItem( QString::number( i ), 500+i ); + submenu->setItemChecked( id, id-500 == vtstat.v_active ); + } + ::close( fd ); + + connect( submenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); + + return submenu; +} + + +void VTApplet::changeVT( int index ) +{ + qDebug( "VTApplet::changeVT( %d )", index-500 ); + int fd = ::open("/dev/tty0", O_RDWR); + if ( fd == -1 ) return; + ioctl( fd, VT_ACTIVATE, index-500 ); +} + + +void VTApplet::activated() +{ + qDebug( "VTApplet::activated()" ); +} + + +QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_MenuApplet ) + *iface = this; + + if ( *iface ) + (*iface)-> addRef ( ); + return QS_OK; +} + +Q_EXPORT_INTERFACE( ) +{ + Q_CREATE_INSTANCE( VTApplet ) +} + + diff --git a/core/applets/vtapplet/vt.h b/core/applets/vtapplet/vt.h new file mode 100644 index 0000000..2df9791 --- a/dev/null +++ b/core/applets/vtapplet/vt.h @@ -0,0 +1,53 @@ +/********************************************************************** +** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. +** +** Contact me @ mickeyl@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. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ +#ifndef __OPIE_VTAPPLET_H__ +#define __OPIE_VTAPPLET_H__ + +#include +#include + +class VTApplet : public QObject, public MenuAppletInterface +{ + + Q_OBJECT + +public: + VTApplet ( ); + virtual ~VTApplet ( ); + + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT + + virtual int position() const; + + virtual QString name ( ) const; + virtual QIconSet icon ( ) const; + virtual QString text ( ) const; + //virtual QString tr( const char* ) const; + //virtual QString tr( const char*, const char* ) const; + virtual QPopupMenu *popup ( QWidget *parent ) const; + + virtual void activated (); + +public slots: + virtual void changeVT( int index ); + +private: + ulong ref; +}; + +static QPopupMenu* submenu; + +#endif diff --git a/core/applets/vtapplet/vtapplet.pro b/core/applets/vtapplet/vtapplet.pro new file mode 100644 index 0000000..3899e75 --- a/dev/null +++ b/core/applets/vtapplet/vtapplet.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +HEADERS = vt.h +SOURCES = vt.cpp +TARGET = vtapplet +DESTDIR = $(OPIEDIR)/plugins/applets +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe +VERSION = 1.0.0 + +include ( $(OPIEDIR)/include.pro ) +target.path = $$prefix/plugins/applets diff --git a/packages b/packages index f24cced..74a6111 100644 --- a/packages +++ b/packages @@ -166,6 +166,7 @@ CONFIG_UNIKEYBOARD inputmethods/unikeyboard unikeyboard.pro CONFIG_USERMANAGER noncore/settings/usermanager usermanager.pro CONFIG_VMEMO core/applets/vmemo vmemo.pro CONFIG_VOLUMEAPPLET core/applets/volumeapplet volumeapplet.pro +CONFIG_VTAPPLET core/applets/vtapplet vtapplet.pro CONFIG_WAVPLUGIN core/multimedia/opieplayer/wavplugin wavplugin.pro CONFIG_WELLENREITER noncore/net/wellenreiter wellenreiter.pro CONFIG_WIRELESSAPPLET noncore/applets/wirelessapplet wirelessapplet.pro -- cgit v0.9.0.2