summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/widget_layer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/widget_layer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp
index 96dda1c..ab25919 100644
--- a/noncore/apps/opie-console/widget_layer.cpp
+++ b/noncore/apps/opie-console/widget_layer.cpp
@@ -30,137 +30,137 @@ WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *na
30 m_lines = 1; 30 m_lines = 1;
31 m_columns = 1; 31 m_columns = 1;
32 m_resizing = false; 32 m_resizing = false;
33 33
34 // just for demonstrating 34 // just for demonstrating
35 //m_image = QArray<Character>( m_lines * m_columns ); 35 //m_image = QArray<Character>( m_lines * m_columns );
36 m_image = QArray<Character>( 1 ); 36 m_image = QArray<Character>( 1 );
37 37
38 // we need to install an event filter, 38 // we need to install an event filter,
39 // to emit keypresses. 39 // to emit keypresses.
40 qApp->installEventFilter( this ); 40 qApp->installEventFilter( this );
41 41
42} 42}
43 43
44 44
45WidgetLayer::~WidgetLayer() 45WidgetLayer::~WidgetLayer()
46{ 46{
47 // clean up 47 // clean up
48 delete m_image; 48 delete m_image;
49} 49}
50 50
51 51
52QSize WidgetLayer::sizeHint() 52QSize WidgetLayer::sizeHint()
53{ 53{
54 return size(); 54 return size();
55} 55}
56 56
57 57
58/* --------------------------------- audio ---------------------------------- */ 58/* --------------------------------- audio ---------------------------------- */
59 59
60void WidgetLayer::bell() 60void WidgetLayer::bell()
61{ 61{
62 QApplication::beep(); 62 QApplication::beep();
63} 63}
64 64
65bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) 65bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
66{ 66{
67 if ( (e->type() == QEvent::Accel || 67 if ( (e->type() == QEvent::Accel ||
68 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 68 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
69 static_cast<QKeyEvent *>( e )->ignore(); 69 static_cast<QKeyEvent *>( e )->ignore();
70 return true; 70 return true;
71 } 71 }
72 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 72 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
73 return false; // not us 73 return false; // not us
74 74
75#ifdef FAKE_CTRL_AND_ALT 75#ifdef FAKE_CTRL_AND_ALT
76 static bool control = false; 76 static bool control = false;
77 static bool alt = false; 77 static bool alt = false;
78// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 78// odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl;
79 bool dele = false; 79 bool dele = false;
80 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 80 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
81 QKeyEvent* ke = (QKeyEvent*)e; 81 QKeyEvent* ke = (QKeyEvent*)e;
82 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 82 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
83 switch (ke->key()) { 83 switch (ke->key()) {
84 case Key_F9: // let this be "Control" 84 case Key_F9: // let this be "Control"
85 control = keydown; 85 control = keydown;
86 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 86 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
87 dele=TRUE; 87 dele=TRUE;
88 break; 88 break;
89 case Key_F13: // let this be "Alt" 89 case Key_F13: // let this be "Alt"
90 alt = keydown; 90 alt = keydown;
91 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 91 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
92 dele=TRUE; 92 dele=TRUE;
93 break; 93 break;
94 default: 94 default:
95 if ( control ) { 95 if ( control ) {
96 int a = toupper(ke->ascii())-64; 96 int a = toupper(ke->ascii())-64;
97 if ( a >= 0 && a < ' ' ) { 97 if ( a >= 0 && a < ' ' ) {
98 e = new QKeyEvent(e->type(), ke->key(), 98 e = new QKeyEvent(e->type(), ke->key(),
99 a, ke->state()|ControlButton, 99 a, ke->state()|ControlButton,
100QChar(a,0)); 100QChar(a,0));
101 dele=TRUE; 101 dele=TRUE;
102 } 102 }
103 } 103 }
104 if ( alt ) { 104 if ( alt ) {
105 e = new QKeyEvent(e->type(), ke->key(), 105 e = new QKeyEvent(e->type(), ke->key(),
106 ke->ascii(), ke->state()|AltButton, ke->text()); 106 ke->ascii(), ke->state()|AltButton, ke->text());
107 dele=TRUE; 107 dele=TRUE;
108 } 108 }
109 } 109 }
110 } 110 }
111#endif 111#endif
112 112
113 if ( e->type() == QEvent::KeyPress ) { 113 if ( e->type() == QEvent::KeyPress ) {
114 QKeyEvent* ke = (QKeyEvent*)e; 114 QKeyEvent* ke = (QKeyEvent*)e;
115 //actSel=0; // Key stroke implies a screen update, so Widget won't 115 //actSel=0; // Key stroke implies a screen update, so Widget won't
116 // know where the current selection is. 116 // know where the current selection is.
117 117
118// qDebug("key pressed is 0x%x",ke->key()); 118// odebug << "key pressed is 0x" << ke->key() << "" << oendl;
119 119
120 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker 120 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
121 insertText("\\"); // expose 121 insertText("\\"); // expose
122 } else 122 } else
123 emit keyPressed( ke ); // expose 123 emit keyPressed( ke ); // expose
124 ke->accept(); 124 ke->accept();
125#ifdef FAKE_CTRL_AND_ALT 125#ifdef FAKE_CTRL_AND_ALT
126 if ( dele ) delete e; 126 if ( dele ) delete e;
127#endif 127#endif
128 return true; // stop the event 128 return true; // stop the event
129 } 129 }
130 return QFrame::eventFilter( obj, e ); 130 return QFrame::eventFilter( obj, e );
131} 131}
132 132
133 133
134/* --------------------------------- screen --------------------------------- */ 134/* --------------------------------- screen --------------------------------- */
135 135
136 136
137void WidgetLayer::propagateSize() 137void WidgetLayer::propagateSize()
138{ 138{
139 QArray<Character> oldimage = m_image.copy(); 139 QArray<Character> oldimage = m_image.copy();
140 int oldlines = m_lines; 140 int oldlines = m_lines;
141 int oldcolumns = m_columns; 141 int oldcolumns = m_columns;
142 142
143 makeImage(); 143 makeImage();
144 144
145 // copy old image, to reduce flicker 145 // copy old image, to reduce flicker
146 if ( ! oldimage.isEmpty() ) 146 if ( ! oldimage.isEmpty() )
147 { 147 {
148 int lins = QMIN( oldlines, m_lines ); 148 int lins = QMIN( oldlines, m_lines );
149 int cols = QMIN( oldcolumns, m_columns ); 149 int cols = QMIN( oldcolumns, m_columns );
150 for ( int lin = 0; lin < lins; ++lin ) 150 for ( int lin = 0; lin < lins; ++lin )
151 { 151 {
152 memcpy( (void*) &m_image[m_columns*lin], 152 memcpy( (void*) &m_image[m_columns*lin],
153 (void*) &oldimage[oldcolumns*lin], 153 (void*) &oldimage[oldcolumns*lin],
154 cols*sizeof( Character ) ); 154 cols*sizeof( Character ) );
155 } 155 }
156 } 156 }
157 else 157 else
158 clearImage(); 158 clearImage();
159 159
160 delete oldimage; 160 delete oldimage;
161 161
162 m_resizing = true; 162 m_resizing = true;
163 emit imageSizeChanged( m_lines, m_columns ); 163 emit imageSizeChanged( m_lines, m_columns );
164 m_resizing = false; 164 m_resizing = false;
165} 165}
166 166