summaryrefslogtreecommitdiffstats
path: root/src/komposedesktopwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/komposedesktopwidget.cpp')
-rw-r--r--src/komposedesktopwidget.cpp68
1 files changed, 48 insertions, 20 deletions
diff --git a/src/komposedesktopwidget.cpp b/src/komposedesktopwidget.cpp
index 4c1bbde..0f3c567 100644
--- a/src/komposedesktopwidget.cpp
+++ b/src/komposedesktopwidget.cpp
@@ -31,6 +31,7 @@
#include <tqpainter.h>
#include <tqapplication.h>
#include <tqdragobject.h>
+#include <tqobjectlist.h>
#include <tqtooltip.h>
#include <tdelocale.h>
@@ -109,48 +110,75 @@ void KomposeDesktopWidget::initFonts()
// return (double)deskRect.width() / (double)deskRect.height();
// }
+void KomposeDesktopWidget::setHighlight()
+{
+ highlight = true;
+ repaint();
+}
+
+void KomposeDesktopWidget::clearHighlight()
+{
+ highlight = false;
+ repaint();
+}
+
+void KomposeDesktopWidget::setInactive()
+{
+ if( hasFocus() )
+ clearFocus();
+}
+
+void KomposeDesktopWidget::setActive()
+{
+ // Focus first window (if there is one)
+ const TQObjectList *lst = children();
+
+ if ( lst )
+ {
+ TQObjectListIterator it( *lst );
+ TQWidget *widget;
+ while ( (widget = (TQWidget*)it.current() ) )
+ {
+ if (widget->inherits("KomposeTaskWidget"))
+ {
+ widget->setFocus();
+ break;
+ }
+ ++it;
+ }
+ }
+
+ emit activated(this);
+}
void KomposeDesktopWidget::leaveEvent ( TQEvent * )
{
- // Unset highlight if cursor moves out of our rect
+ unsetCursor();
+
+ // Mark desktop as inactive if cursor moves out of our rect
// but not if it enters a child widget
TQRect deskRect;
deskRect.setTopLeft(mapToGlobal( TQPoint(0,0) ));
deskRect.setWidth(width());
deskRect.setHeight(height());
if ( !deskRect.contains( TQCursor::pos() ) )
- highlight = false;
-
- unsetCursor();
- repaint();
+ setInactive();
}
void KomposeDesktopWidget::enterEvent ( TQEvent * )
{
- setFocus();
setCursor( KCursor::handCursor() );
- highlight = true;
- repaint();
+ setActive();
}
void KomposeDesktopWidget::focusInEvent ( TQFocusEvent * )
{
- highlight = true;
- repaint();
+ setActive();
}
void KomposeDesktopWidget::focusOutEvent ( TQFocusEvent * )
{
- // Unset highlight if cursor moves out of our rect
- // but not if it enters a child widget
- TQRect deskRect;
- deskRect.setTopLeft(mapToGlobal( TQPoint(0,0) ));
- deskRect.setWidth(width());
- deskRect.setHeight(height());
- if ( !deskRect.contains( TQCursor::pos() ) )
- highlight = false;
-
- repaint();
+ setInactive();
}
void KomposeDesktopWidget::mouseReleaseEvent ( TQMouseEvent * e )