author | ibotty <ibotty> | 2002-10-13 10:49:21 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-13 10:49:21 (UTC) |
commit | 72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c (patch) (unidiff) | |
tree | 95ddc3c8ec3740d9544d6df08695a26fb52d46c9 | |
parent | b8377d9c462d7edbc92c6809503cb53a09f8fd98 (diff) | |
download | opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.zip opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.gz opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.bz2 |
does not work... but committed to get things started
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 79 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 2 |
2 files changed, 81 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index c00871f..3875a6e 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -54,8 +54,87 @@ void WidgetLayer::bell() | |||
54 | { | 54 | { |
55 | QApplication::beep(); | 55 | QApplication::beep(); |
56 | } | 56 | } |
57 | 57 | ||
58 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | ||
59 | { | ||
60 | if ( (e->type() == QEvent::Accel || | ||
61 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
62 | static_cast<QKeyEvent *>( e )->ignore(); | ||
63 | return true; | ||
64 | } | ||
65 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
66 | return FALSE; // not us | ||
67 | if ( e->type() == QEvent::Wheel) { | ||
68 | QApplication::sendEvent( m_scrollbar, e); | ||
69 | } | ||
70 | |||
71 | #ifdef FAKE_CTRL_AND_ALT | ||
72 | static bool control = FALSE; | ||
73 | static bool alt = FALSE; | ||
74 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | ||
75 | bool dele=FALSE; | ||
76 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
77 | QKeyEvent* ke = (QKeyEvent*)e; | ||
78 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
79 | switch (ke->key()) { | ||
80 | case Key_F9: // let this be "Control" | ||
81 | control = keydown; | ||
82 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
83 | dele=TRUE; | ||
84 | break; | ||
85 | case Key_F13: // let this be "Alt" | ||
86 | alt = keydown; | ||
87 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
88 | dele=TRUE; | ||
89 | break; | ||
90 | default: | ||
91 | if ( control ) { | ||
92 | int a = toupper(ke->ascii())-64; | ||
93 | if ( a >= 0 && a < ' ' ) { | ||
94 | e = new QKeyEvent(e->type(), ke->key(), | ||
95 | a, ke->state()|ControlButton, | ||
96 | QChar(a,0)); | ||
97 | dele=TRUE; | ||
98 | } | ||
99 | } | ||
100 | if ( alt ) { | ||
101 | e = new QKeyEvent(e->type(), ke->key(), | ||
102 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
103 | dele=TRUE; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | #endif | ||
108 | |||
109 | if ( e->type() == QEvent::KeyPress ) { | ||
110 | QKeyEvent* ke = (QKeyEvent*)e; | ||
111 | //actSel=0; // Key stroke implies a screen update, so Widget won't | ||
112 | // know where the current selection is. | ||
113 | |||
114 | // qDebug("key pressed is 0x%x",ke->key()); | ||
115 | |||
116 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
117 | insertText("\\"); // expose | ||
118 | } else | ||
119 | emit keyPressed( ke ); // expose | ||
120 | ke->accept(); | ||
121 | #ifdef FAKE_CTRL_AND_ALT | ||
122 | if ( dele ) delete e; | ||
123 | #endif | ||
124 | return true; // stop the event | ||
125 | } | ||
126 | if ( e->type() == QEvent::Enter ) { | ||
127 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | ||
128 | this, SLOT(onClearSelection()) ); | ||
129 | } | ||
130 | if ( e->type() == QEvent::Leave ) { | ||
131 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
132 | this, SLOT(onClearSelection()) ); | ||
133 | } | ||
134 | return QFrame::eventFilter( obj, e ); | ||
135 | } | ||
136 | |||
58 | 137 | ||
59 | /* --------------------------------- screen --------------------------------- */ | 138 | /* --------------------------------- screen --------------------------------- */ |
60 | 139 | ||
61 | 140 | ||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 067f3da..1d96bf4 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -120,8 +120,10 @@ public: | |||
120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) | 120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) |
121 | */ | 121 | */ |
122 | virtual void scroll( int value ) = 0; | 122 | virtual void scroll( int value ) = 0; |
123 | 123 | ||
124 | |||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | ||
124 | signals: | 126 | signals: |
125 | 127 | ||
126 | /** | 128 | /** |
127 | * key was pressed | 129 | * key was pressed |