summaryrefslogtreecommitdiff
path: root/core/applets/vtapplet/vt.cpp
authorschurig <schurig>2004-09-10 12:18:17 (UTC)
committer schurig <schurig>2004-09-10 12:18:17 (UTC)
commit9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (patch) (unidiff)
tree53927c6a19c69d54bb3d0e092ac57180bcb60222 /core/applets/vtapplet/vt.cpp
parented70ec4945c7816ec6e899207ec8b99e20e10da5 (diff)
downloadopie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.zip
opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.gz
opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.bz2
added support for DEVFS
Diffstat (limited to 'core/applets/vtapplet/vt.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vtapplet/vt.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index aec63c3..7832ee0 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -35,121 +35,129 @@ VTApplet::VTApplet ( )
35} 35}
36 36
37VTApplet::~VTApplet ( ) 37VTApplet::~VTApplet ( )
38{ 38{
39} 39}
40 40
41int VTApplet::position ( ) const 41int VTApplet::position ( ) const
42{ 42{
43 return 2; 43 return 2;
44} 44}
45 45
46QString VTApplet::name ( ) const 46QString VTApplet::name ( ) const
47{ 47{
48 return tr( "VT shortcut" ); 48 return tr( "VT shortcut" );
49} 49}
50 50
51QString VTApplet::text ( ) const 51QString VTApplet::text ( ) const
52{ 52{
53 return tr( "Terminal" ); 53 return tr( "Terminal" );
54} 54}
55 55
56/* 56/*
57QString VTApplet::tr( const char* s ) const 57QString VTApplet::tr( const char* s ) const
58{ 58{
59 return qApp->translate( "VTApplet", s, 0 ); 59 return qApp->translate( "VTApplet", s, 0 );
60} 60}
61 61
62QString VTApplet::tr( const char* s, const char* p ) const 62QString VTApplet::tr( const char* s, const char* p ) const
63{ 63{
64 return qApp->translate( "VTApplet", s, p ); 64 return qApp->translate( "VTApplet", s, p );
65} 65}
66*/ 66*/
67 67
68QIconSet VTApplet::icon ( ) const 68QIconSet VTApplet::icon ( ) const
69{ 69{
70 QPixmap pix; 70 QPixmap pix;
71 QImage img = Resource::loadImage ( "terminal" ); 71 QImage img = Resource::loadImage ( "terminal" );
72 72
73 if ( !img. isNull ( )) 73 if ( !img. isNull ( ))
74 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 74 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
75 return pix; 75 return pix;
76} 76}
77 77
78QPopupMenu *VTApplet::popup ( QWidget* parent ) const 78QPopupMenu *VTApplet::popup ( QWidget* parent ) const
79{ 79{
80 odebug << "VTApplet::popup" << oendl; 80 odebug << "VTApplet::popup" << oendl;
81 81
82 struct vt_stat vtstat; 82 struct vt_stat vtstat;
83#ifdef QT_QWS_DEVFS
84 int fd = ::open( "/dev/vc/0", O_RDWR );
85#else
83 int fd = ::open( "/dev/tty0", O_RDWR ); 86 int fd = ::open( "/dev/tty0", O_RDWR );
87#endif
84 if ( fd == -1 ) return 0; 88 if ( fd == -1 ) return 0;
85 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; 89 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
86 90
87 m_subMenu = new QPopupMenu( parent ); 91 m_subMenu = new QPopupMenu( parent );
88 m_subMenu->setCheckable( true ); 92 m_subMenu->setCheckable( true );
89 for ( int i = 1; i < 10; ++i ) 93 for ( int i = 1; i < 10; ++i )
90 { 94 {
91 int id = m_subMenu->insertItem( QString::number( i ), 500+i ); 95 int id = m_subMenu->insertItem( QString::number( i ), 500+i );
92 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); 96 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active );
93 } 97 }
94 ::close( fd ); 98 ::close( fd );
95 99
96 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); 100 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
97 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); 101 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
98 102
99 return m_subMenu; 103 return m_subMenu;
100} 104}
101 105
102 106
103void VTApplet::changeVT( int index ) 107void VTApplet::changeVT( int index )
104{ 108{
105 //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; 109 //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl;
106 110
111#ifdef QT_QWS_DEVFS
112 int fd = ::open("/dev/vc/0", O_RDWR);
113#else
107 int fd = ::open("/dev/tty0", O_RDWR); 114 int fd = ::open("/dev/tty0", O_RDWR);
115#endif
108 if ( fd == -1 ) return; 116 if ( fd == -1 ) return;
109 ioctl( fd, VT_ACTIVATE, index-500 ); 117 ioctl( fd, VT_ACTIVATE, index-500 );
110} 118}
111 119
112 120
113void VTApplet::updateMenu() 121void VTApplet::updateMenu()
114{ 122{
115 //odebug << "VTApplet::updateMenu()" << oendl; 123 //odebug << "VTApplet::updateMenu()" << oendl;
116 124
117 int fd = ::open( "/dev/console", O_RDONLY ); 125 int fd = ::open( "/dev/console", O_RDONLY );
118 if ( fd == -1 ) return; 126 if ( fd == -1 ) return;
119 127
120 for ( int i = 1; i < 10; ++i ) 128 for ( int i = 1; i < 10; ++i )
121 { 129 {
122 int result = ioctl( fd, VT_DISALLOCATE, i ); 130 int result = ioctl( fd, VT_DISALLOCATE, i );
123 131
124 /* 132 /*
125 if ( result == -1 ) 133 if ( result == -1 )
126 odebug << "VT " << i << " disallocated == free" << oendl; 134 odebug << "VT " << i << " disallocated == free" << oendl;
127 else 135 else
128 odebug << "VT " << i << " _not_ disallocated == busy" << oendl; 136 odebug << "VT " << i << " _not_ disallocated == busy" << oendl;
129 */ 137 */
130 138
131 m_subMenu->setItemEnabled( 500+i, result == -1 ); 139 m_subMenu->setItemEnabled( 500+i, result == -1 );
132 } 140 }
133 141
134 ::close( fd ); 142 ::close( fd );
135} 143}
136 144
137 145
138void VTApplet::activated() 146void VTApplet::activated()
139{ 147{
140 odebug << "VTApplet::activated()" << oendl; 148 odebug << "VTApplet::activated()" << oendl;
141} 149}
142 150
143 151
144QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 152QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
145{ 153{
146 *iface = 0; 154 *iface = 0;
147 if ( uuid == IID_QUnknown ) 155 if ( uuid == IID_QUnknown )
148 *iface = this; 156 *iface = this;
149 else if ( uuid == IID_MenuApplet ) 157 else if ( uuid == IID_MenuApplet )
150 *iface = this; 158 *iface = this;
151 else 159 else
152 return QS_FALSE; 160 return QS_FALSE;
153 161
154 if ( *iface ) 162 if ( *iface )
155 (*iface)-> addRef ( ); 163 (*iface)-> addRef ( );