diff options
Diffstat (limited to 'src/komposefullscreenwidget.cpp')
-rw-r--r-- | src/komposefullscreenwidget.cpp | 115 |
1 files changed, 113 insertions, 2 deletions
diff --git a/src/komposefullscreenwidget.cpp b/src/komposefullscreenwidget.cpp index 4fdda7f..f54c633 100644 --- a/src/komposefullscreenwidget.cpp +++ b/src/komposefullscreenwidget.cpp @@ -33,6 +33,7 @@ #include <kdebug.h> #include <krootpixmap.h> +static bool controlHold = false; // is the control key pressed KomposeFullscreenWidget::KomposeFullscreenWidget( int displayType, KomposeLayout *l ) : KomposeTaskContainerWidget( -1, 0, l ), @@ -160,7 +161,8 @@ void KomposeFullscreenWidget::createDesktopWidgets() //int col = i % 2; //kdDebug() << "rc %d %d", row, col); KomposeDesktopWidget *desktop = new KomposeDesktopWidget(i, this ); - connect(desktop, SIGNAL(contentsChanged()), layout, SLOT(arrangeLayout()) ); + connect( desktop, SIGNAL(contentsChanged()), layout, SLOT(arrangeLayout()) ); + connect( desktop, SIGNAL(activated(KomposeDesktopWidget*)), this, SLOT(desktopChanged(KomposeDesktopWidget*)) ); desktop->show(); } } @@ -190,7 +192,16 @@ void KomposeFullscreenWidget::mousePressEvent ( TQMouseEvent * e ) } } -void KomposeFullscreenWidget::keyReleaseEvent ( TQKeyEvent * e ) +void KomposeFullscreenWidget::keyPressEvent( TQKeyEvent *e ) +{ + if ( e->key() == TQt::Key_Control ) + { + controlHold = true; + e->accept(); + } +} + +void KomposeFullscreenWidget::keyReleaseEvent ( TQKeyEvent *e ) { if ( e->key() == TQt::Key_Escape ) { @@ -198,14 +209,114 @@ void KomposeFullscreenWidget::keyReleaseEvent ( TQKeyEvent * e ) KomposeViewManager::instance()->closeCurrentView(); e->accept(); } + + else if ( e->key() == TQt::Key_Control ) + { + controlHold = false; + e->accept(); + return; + } + + // Movement keys + else if ( e->key() == TQt::Key_Right || e->key() == TQt::Key_D || e->key() == TQt::Key_H || + e->key() == TQt::Key_Left || e->key() == TQt::Key_A || e->key() == TQt::Key_J || + e->key() == TQt::Key_Up || e->key() == TQt::Key_W || e->key() == TQt::Key_K || + e->key() == TQt::Key_Down || e->key() == TQt::Key_S || e->key() == TQt::Key_L ) + { + // Map keys to directions + int direction = DLAYOUT_RIGHT; + switch( e->key() ) + { + case TQt::Key_Right: + direction = DLAYOUT_RIGHT; + break; + case TQt::Key_D: + direction = DLAYOUT_RIGHT; + break; + case TQt::Key_L: + direction = DLAYOUT_RIGHT; + break; + case TQt::Key_Left: + direction = DLAYOUT_LEFT; + break; + case TQt::Key_A: + direction = DLAYOUT_LEFT; + break; + case TQt::Key_H: + direction = DLAYOUT_LEFT; + break; + case TQt::Key_Up: + direction = DLAYOUT_TOP; + break; + case TQt::Key_W: + direction = DLAYOUT_TOP; + break; + case TQt::Key_K: + direction = DLAYOUT_TOP; + break; + case TQt::Key_Down: + direction = DLAYOUT_BOTTOM; + break; + case TQt::Key_S: + direction = DLAYOUT_BOTTOM; + break; + case TQt::Key_J: + direction = DLAYOUT_BOTTOM; + break; + } + + focusNeighbourDesk( direction ); + e->accept(); + return; + } + else { kdDebug() << "KomposeFullscreenWidget::keyReleaseEvent - ignored..." << endl; e->ignore(); } + KomposeTaskContainerWidget::keyReleaseEvent(e); } +bool KomposeFullscreenWidget::focusNeighbourDesk( int direction ) +{ + bool successfull = false; + KomposeWidget *widget; + if ( ( widget = layout->getNeighbour( dynamic_cast<KomposeWidget*>(current), direction, WLAYOUT_BOTH ) ) != 0 ) + { + kdDebug() << "KomposeFullscreenWidget::keyReleaseEvent - Focussing " << widget->className() << endl; + dynamic_cast<KomposeDesktopWidget*>(widget)->setActive(); + successfull = true; + } + + return successfull; +} + +void KomposeFullscreenWidget::desktopChanged( KomposeDesktopWidget* desk ) +{ + kdDebug() << "KomposeFullscreenWidget: desktopChanged" << endl; + // Remove highlight from all other desks + const TQObjectList *lst = children(); + + if( lst ) + { + TQObjectListIterator it( *lst ); + TQWidget *widget; + while ( (widget = (TQWidget*)it.current() ) ) + { + if ( widget->inherits("KomposeDesktopWidget") ) + { + dynamic_cast<KomposeDesktopWidget*>(widget)->clearHighlight(); + } + ++it; + } + } + + desk->setHighlight(); + current = desk; +} + int KomposeFullscreenWidget::getHeightForWidth ( int w ) const { return (int)(((double)w / (double)width()) * (double)height()); |