summaryrefslogtreecommitdiff
authoribotty <ibotty>2002-10-13 10:49:21 (UTC)
committer ibotty <ibotty>2002-10-13 10:49:21 (UTC)
commit72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c (patch) (side-by-side diff)
tree95ddc3c8ec3740d9544d6df08695a26fb52d46c9
parentb8377d9c462d7edbc92c6809503cb53a09f8fd98 (diff)
downloadopie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.zip
opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.gz
opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.bz2
does not work... but committed to get things started
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/widget_layer.cpp79
-rw-r--r--noncore/apps/opie-console/widget_layer.h2
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
@@ -50,16 +50,95 @@ WidgetLayer::~WidgetLayer()
/* --------------------------------- audio ---------------------------------- */
void WidgetLayer::bell()
{
QApplication::beep();
}
+bool WidgetLayer::eventFilter( QObject *obj, QEvent *e )
+{
+ if ( (e->type() == QEvent::Accel ||
+ e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
+ static_cast<QKeyEvent *>( e )->ignore();
+ return true;
+ }
+ if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
+ return FALSE; // not us
+ if ( e->type() == QEvent::Wheel) {
+ QApplication::sendEvent( m_scrollbar, e);
+ }
+
+#ifdef FAKE_CTRL_AND_ALT
+ static bool control = FALSE;
+ static bool alt = FALSE;
+// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
+ bool dele=FALSE;
+ if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
+ QKeyEvent* ke = (QKeyEvent*)e;
+ bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
+ switch (ke->key()) {
+ case Key_F9: // let this be "Control"
+ control = keydown;
+ e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
+ dele=TRUE;
+ break;
+ case Key_F13: // let this be "Alt"
+ alt = keydown;
+ e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
+ dele=TRUE;
+ break;
+ default:
+ if ( control ) {
+ int a = toupper(ke->ascii())-64;
+ if ( a >= 0 && a < ' ' ) {
+ e = new QKeyEvent(e->type(), ke->key(),
+ a, ke->state()|ControlButton,
+QChar(a,0));
+ dele=TRUE;
+ }
+ }
+ if ( alt ) {
+ e = new QKeyEvent(e->type(), ke->key(),
+ ke->ascii(), ke->state()|AltButton, ke->text());
+ dele=TRUE;
+ }
+ }
+ }
+#endif
+
+ if ( e->type() == QEvent::KeyPress ) {
+ QKeyEvent* ke = (QKeyEvent*)e;
+ //actSel=0; // Key stroke implies a screen update, so Widget won't
+ // know where the current selection is.
+
+// qDebug("key pressed is 0x%x",ke->key());
+
+ if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker
+ insertText("\\"); // expose
+ } else
+ emit keyPressed( ke ); // expose
+ ke->accept();
+#ifdef FAKE_CTRL_AND_ALT
+ if ( dele ) delete e;
+#endif
+ return true; // stop the event
+ }
+ if ( e->type() == QEvent::Enter ) {
+ QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
+ this, SLOT(onClearSelection()) );
+ }
+ if ( e->type() == QEvent::Leave ) {
+ QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
+ this, SLOT(onClearSelection()) );
+ }
+ return QFrame::eventFilter( obj, e );
+}
+
/* --------------------------------- screen --------------------------------- */
void WidgetLayer::propagateSize()
{
QArray<Character> oldimage = m_image.copy();
int oldlines = m_lines;
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
@@ -116,16 +116,18 @@ public:
virtual void setScroll( int cursor, int slines ) = 0;
/**
* scrolls (if implemented, by successor of this class)
* @param int value, how much the widget should scroll up (positive value) or down (negative value)
*/
virtual void scroll( int value ) = 0;
+
+ virtual bool eventFilter( QObject *obj, QEvent *event );
signals:
/**
* key was pressed
*/
void keyPressed( QKeyEvent *e );
/**