summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-09-16 12:31:09 (UTC)
committer mickeyl <mickeyl>2003-09-16 12:31:09 (UTC)
commit81171716bb686e709f27fbbc0931740aa9d9462a (patch) (unidiff)
treea989e70496240fad7f3a87a72ee3c1a530be26eb
parent7338604c783a51c456fdf8d534f8da62e4383e03 (diff)
downloadopie-81171716bb686e709f27fbbc0931740aa9d9462a.zip
opie-81171716bb686e709f27fbbc0931740aa9d9462a.tar.gz
opie-81171716bb686e709f27fbbc0931740aa9d9462a.tar.bz2
virtual terminal applet says: "Hello"
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vtapplet/.cvsignore1
-rw-r--r--core/applets/vtapplet/config.in4
-rw-r--r--core/applets/vtapplet/vt.cpp143
-rw-r--r--core/applets/vtapplet/vt.h53
-rw-r--r--core/applets/vtapplet/vtapplet.pro13
-rw-r--r--packages1
6 files changed, 215 insertions, 0 deletions
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 @@
1 config VTAPPLET
2 boolean "VT (switch to another virtual terminal)"
3 default "y"
4 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 @@
1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3**
4** Contact me @ mickeyl@handhelds.org
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include <qpe/resource.h>
17#include <qpe/qcopenvelope_qws.h>
18
19#include <qapplication.h>
20#include <qiconset.h>
21#include <qpopupmenu.h>
22
23#include <fcntl.h>
24#include <unistd.h>
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <sys/ioctl.h>
28#include <linux/vt.h>
29
30#include "vt.h"
31
32class VTPopupMenu : public QPopupMenu
33{
34 public:
35 VTPopupMenu( QWidget * parent=0, const char * name=0 ) : QPopupMenu( parent, name ) {};
36
37 virtual void activated() { qDebug( "VTPopupMenu::activated()" ); }
38};
39
40VTApplet::VTApplet ( )
41 : QObject ( 0, "VTApplet" ), ref ( 0 )
42{
43}
44
45VTApplet::~VTApplet ( )
46{
47}
48
49int VTApplet::position ( ) const
50{
51 return 2;
52}
53
54QString VTApplet::name ( ) const
55{
56 return tr( "VT shortcut" );
57}
58
59QString VTApplet::text ( ) const
60{
61 return tr( "Terminal" );
62}
63
64/*
65QString VTApplet::tr( const char* s ) const
66{
67 return qApp->translate( "VTApplet", s, 0 );
68}
69
70QString VTApplet::tr( const char* s, const char* p ) const
71{
72 return qApp->translate( "VTApplet", s, p );
73}
74*/
75
76QIconSet VTApplet::icon ( ) const
77{
78 QPixmap pix;
79 QImage img = Resource::loadImage ( "terminal" );
80
81 if ( !img. isNull ( ))
82 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
83 return pix;
84}
85
86QPopupMenu *VTApplet::popup ( QWidget* parent ) const
87{
88 qDebug( "VTApplet::popup" );
89
90 struct vt_stat vtstat;
91 int fd = ::open("/dev/tty0", O_RDWR);
92 if ( fd == -1 ) return 0;
93 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
94
95 submenu = new VTPopupMenu( parent );
96 submenu->setCheckable( true );
97 for ( int i = 1; i < 10; ++i )
98 {
99 int id = submenu->insertItem( QString::number( i ), 500+i );
100 submenu->setItemChecked( id, id-500 == vtstat.v_active );
101 }
102 ::close( fd );
103
104 connect( submenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
105
106 return submenu;
107}
108
109
110void VTApplet::changeVT( int index )
111{
112 qDebug( "VTApplet::changeVT( %d )", index-500 );
113 int fd = ::open("/dev/tty0", O_RDWR);
114 if ( fd == -1 ) return;
115 ioctl( fd, VT_ACTIVATE, index-500 );
116}
117
118
119void VTApplet::activated()
120{
121 qDebug( "VTApplet::activated()" );
122}
123
124
125QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
126{
127 *iface = 0;
128 if ( uuid == IID_QUnknown )
129 *iface = this;
130 else if ( uuid == IID_MenuApplet )
131 *iface = this;
132
133 if ( *iface )
134 (*iface)-> addRef ( );
135 return QS_OK;
136}
137
138Q_EXPORT_INTERFACE( )
139{
140 Q_CREATE_INSTANCE( VTApplet )
141}
142
143
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 @@
1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3**
4** Contact me @ mickeyl@handhelds.org
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15#ifndef __OPIE_VTAPPLET_H__
16#define __OPIE_VTAPPLET_H__
17
18#include <qpe/menuappletinterface.h>
19#include <qobject.h>
20
21class VTApplet : public QObject, public MenuAppletInterface
22{
23
24 Q_OBJECT
25
26public:
27 VTApplet ( );
28 virtual ~VTApplet ( );
29
30 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
31 Q_REFCOUNT
32
33 virtual int position() const;
34
35 virtual QString name ( ) const;
36 virtual QIconSet icon ( ) const;
37 virtual QString text ( ) const;
38 //virtual QString tr( const char* ) const;
39 //virtual QString tr( const char*, const char* ) const;
40 virtual QPopupMenu *popup ( QWidget *parent ) const;
41
42 virtual void activated ();
43
44public slots:
45 virtual void changeVT( int index );
46
47private:
48 ulong ref;
49};
50
51static QPopupMenu* submenu;
52
53#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 @@
1TEMPLATE = lib
2CONFIG += qt warn_on release
3HEADERS = vt.h
4SOURCES = vt.cpp
5TARGET = vtapplet
6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe
10VERSION = 1.0.0
11
12include ( $(OPIEDIR)/include.pro )
13target.path = $$prefix/plugins/applets
diff --git a/packages b/packages
index f24cced..74a6111 100644
--- a/packages
+++ b/packages
@@ -137,45 +137,46 @@ CONFIG_SIMPLE noncore/tools/calc2/simple simple.pro
137 CONFIG_SINGLE singlesingle.pro 137 CONFIG_SINGLE singlesingle.pro
138 CONFIG_SNAKE noncore/games/snakesnake.pro 138 CONFIG_SNAKE noncore/games/snakesnake.pro
139 CONFIG_SOLITAIRE noncore/games/solitairesolitaire.pro 139 CONFIG_SOLITAIRE noncore/games/solitairesolitaire.pro
140 CONFIG_SOUND noncore/settings/soundsound.pro 140 CONFIG_SOUND noncore/settings/soundsound.pro
141 CONFIG_SSHKEYS noncore/settings/sshkeyssshkeys.pro 141 CONFIG_SSHKEYS noncore/settings/sshkeyssshkeys.pro
142 CONFIG_SUSPENDAPPLET core/applets/suspendappletsuspendapplet.pro 142 CONFIG_SUSPENDAPPLET core/applets/suspendappletsuspendapplet.pro
143 CONFIG_SYSINFO noncore/apps/sysinfosysinfo.pro 143 CONFIG_SYSINFO noncore/apps/sysinfosysinfo.pro
144 CONFIG_TABLEVIEWER noncore/apps/tableviewertableviewer.pro 144 CONFIG_TABLEVIEWER noncore/apps/tableviewertableviewer.pro
145 CONFIG_TABMANAGER noncore/settings/tabmanagertabmanager.pro 145 CONFIG_TABMANAGER noncore/settings/tabmanagertabmanager.pro
146 CONFIG_TABOAPP core/apps/taboapptaboapp.pro 146 CONFIG_TABOAPP core/apps/taboapptaboapp.pro
147 CONFIG_TEST libsql/testtest.pro 147 CONFIG_TEST libsql/testtest.pro
148 CONFIG_TEST noncore/apps/opie-console/testtest.pro 148 CONFIG_TEST noncore/apps/opie-console/testtest.pro
149 CONFIG_TETRIX noncore/games/tetrixtetrix.pro 149 CONFIG_TETRIX noncore/games/tetrixtetrix.pro
150 CONFIG_TEXTEDIT core/apps/textedittextedit.pro 150 CONFIG_TEXTEDIT core/apps/textedittextedit.pro
151 CONFIG_THEME noncore/styles/themetheme.pro 151 CONFIG_THEME noncore/styles/themetheme.pro
152 CONFIG_TICTAC noncore/games/tictactictac.pro 152 CONFIG_TICTAC noncore/games/tictactictac.pro
153 CONFIG_TINYKATE noncore/apps/tinykatetinykate.pro 153 CONFIG_TINYKATE noncore/apps/tinykatetinykate.pro
154 CONFIG_TODAY core/pim/todaytoday.pro 154 CONFIG_TODAY core/pim/todaytoday.pro
155CONFIG_TODAY_ADDRESSBOOK core/pim/today/plugins/addressbook addressbook.pro 155CONFIG_TODAY_ADDRESSBOOK core/pim/today/plugins/addressbook addressbook.pro
156 CONFIG_TODAY_DATEBOOK core/pim/today/plugins/datebookdatebook.pro 156 CONFIG_TODAY_DATEBOOK core/pim/today/plugins/datebookdatebook.pro
157 CONFIG_TODAY_FORTUNE noncore/todayplugins/fortunefortune.pro 157 CONFIG_TODAY_FORTUNE noncore/todayplugins/fortunefortune.pro
158 CONFIG_TODAY_MAIL core/pim/today/plugins/mailmail.pro 158 CONFIG_TODAY_MAIL core/pim/today/plugins/mailmail.pro
159 CONFIG_TODAY_STOCKTICKER noncore/todayplugins/stockticker/stocktickerstockticker.pro 159 CONFIG_TODAY_STOCKTICKER noncore/todayplugins/stockticker/stocktickerstockticker.pro
160 CONFIG_TODAY_STOCKTICKERLIB noncore/todayplugins/stockticker/stocktickerlibstocktickerlib.pro 160 CONFIG_TODAY_STOCKTICKERLIB noncore/todayplugins/stockticker/stocktickerlibstocktickerlib.pro
161 CONFIG_TODAY_TODOLIST core/pim/today/plugins/todolisttodolist.pro 161 CONFIG_TODAY_TODOLIST core/pim/today/plugins/todolisttodolist.pro
162 CONFIG_TODAY_WEATHERnoncore/todayplugins/weather weather.pro 162 CONFIG_TODAY_WEATHERnoncore/todayplugins/weather weather.pro
163 CONFIG_TODO core/pim/todotodo.pro 163 CONFIG_TODO core/pim/todotodo.pro
164 CONFIG_UBROWSER noncore/net/ubrowserubrowser.pro 164 CONFIG_UBROWSER noncore/net/ubrowserubrowser.pro
165 CONFIG_UNIKEYBOARD inputmethods/unikeyboardunikeyboard.pro 165 CONFIG_UNIKEYBOARD inputmethods/unikeyboardunikeyboard.pro
166 CONFIG_USERMANAGER noncore/settings/usermanagerusermanager.pro 166 CONFIG_USERMANAGER noncore/settings/usermanagerusermanager.pro
167 CONFIG_VMEMO core/applets/vmemovmemo.pro 167 CONFIG_VMEMO core/applets/vmemovmemo.pro
168 CONFIG_VOLUMEAPPLET core/applets/volumeappletvolumeapplet.pro 168 CONFIG_VOLUMEAPPLET core/applets/volumeappletvolumeapplet.pro
169 CONFIG_VTAPPLET core/applets/vtappletvtapplet.pro
169 CONFIG_WAVPLUGIN core/multimedia/opieplayer/wavpluginwavplugin.pro 170 CONFIG_WAVPLUGIN core/multimedia/opieplayer/wavpluginwavplugin.pro
170 CONFIG_WELLENREITER noncore/net/wellenreiterwellenreiter.pro 171 CONFIG_WELLENREITER noncore/net/wellenreiterwellenreiter.pro
171 CONFIG_WIRELESSAPPLET noncore/applets/wirelessappletwirelessapplet.pro 172 CONFIG_WIRELESSAPPLET noncore/applets/wirelessappletwirelessapplet.pro
172 CONFIG_WLAN noncore/settings/networksettings/wlanwlan.pro 173 CONFIG_WLAN noncore/settings/networksettings/wlanwlan.pro
173 CONFIG_PPP noncore/settings/networksettings/pppppp.pro 174 CONFIG_PPP noncore/settings/networksettings/pppppp.pro
174 CONFIG_WORDGAME noncore/games/wordgamewordgame.pro 175 CONFIG_WORDGAME noncore/games/wordgamewordgame.pro
175 CONFIG_ZSAFEnoncore/apps/zsafe zsafe.pro 176 CONFIG_ZSAFEnoncore/apps/zsafe zsafe.pro
176 CONFIG_MAIN_TAB_EXAMPLE examples/main-tabexample.pro 177 CONFIG_MAIN_TAB_EXAMPLE examples/main-tabexample.pro
177 CONFIG_SIMPLE_EXAMPLE examples/simpleexample.pro 178 CONFIG_SIMPLE_EXAMPLE examples/simpleexample.pro
178 CONFIG_SIMPLE_ICON examples/simple-iconexample.pro 179 CONFIG_SIMPLE_ICON examples/simple-iconexample.pro
179 CONFIG_SIMPLE_MAIN examples/simple-mainexample.pro 180 CONFIG_SIMPLE_MAIN examples/simple-mainexample.pro
180 CONFIG_SIMPLE_PIM examples/simple-pimexample.pro 181 CONFIG_SIMPLE_PIM examples/simple-pimexample.pro
181 CONFIG_APPLET_EXAMPLE examples/appletexample.pro 182 CONFIG_APPLET_EXAMPLE examples/appletexample.pro