From b3ea24bb0d906cf8b26953e22df2c918fbe63346 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 12 Apr 2005 23:20:41 +0000 Subject: [PATCH] Presentation is now a dialog child of part so that get get only 1 entry on taskbar To fix presentationwidget wanting to be always on top, even when it does not has the focus, we drop the staysontop on windowdeactivation and get it again on actiovation BUGS: 103718 svn path=/trunk/kdegraphics/kpdf/; revision=405195 --- part.cpp | 2 +- ui/presentationwidget.cpp | 13 ++++++++++--- ui/presentationwidget.h | 7 ++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/part.cpp b/part.cpp index adc4dbe23..d95fe0ada 100644 --- a/part.cpp +++ b/part.cpp @@ -742,7 +742,7 @@ void Part::slotShowProperties() void Part::slotShowPresentation() { if ( !m_presentationWidget ) - m_presentationWidget = new PresentationWidget( m_document ); + m_presentationWidget = new PresentationWidget( widget(), m_document ); } void Part::slotPrint() diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp index 04e86e0fe..2d29515e2 100644 --- a/ui/presentationwidget.cpp +++ b/ui/presentationwidget.cpp @@ -20,6 +20,7 @@ #include #include #include +#include // system includes #include @@ -46,9 +47,8 @@ struct PresentationFrame }; -PresentationWidget::PresentationWidget( KPDFDocument * doc ) - : QWidget( 0, "presentationWidget", WDestructiveClose | WStyle_NoBorder | - WStyle_StaysOnTop | WShowModal ), m_document( doc ), m_frameIndex( -1 ) +PresentationWidget::PresentationWidget( QWidget * parent, KPDFDocument * doc ) + : QDialog( parent, "presentationWidget", true, WDestructiveClose | WStyle_NoBorder), m_document( doc ), m_frameIndex( -1 ) { // set look and geometry setBackgroundMode( Qt::NoBackground ); @@ -168,6 +168,13 @@ bool PresentationWidget::canUnloadPixmap( int pageNumber ) // +bool PresentationWidget::event ( QEvent * e ) +{ + if (e -> type() == QEvent::WindowDeactivate) KWin::clearState(winId(), NET::StaysOnTop); + else if (e -> type() == QEvent::WindowActivate) KWin::setState(winId(), NET::StaysOnTop); + return QDialog::event(e); +} + void PresentationWidget::keyPressEvent( QKeyEvent * e ) { if (m_width == -1) return; diff --git a/ui/presentationwidget.h b/ui/presentationwidget.h index 48c87b355..fd59855fa 100644 --- a/ui/presentationwidget.h +++ b/ui/presentationwidget.h @@ -10,7 +10,7 @@ #ifndef _KPDF_PRESENTATIONWIDGET_H_ #define _KPDF_PRESENTATIONWIDGET_H_ -#include +#include #include #include #include @@ -29,11 +29,11 @@ class PresentationFrame; * * This is a fullscreen widget that displays */ -class PresentationWidget : public QWidget, public DocumentObserver +class PresentationWidget : public QDialog, public DocumentObserver { Q_OBJECT public: - PresentationWidget( KPDFDocument * doc ); + PresentationWidget( QWidget * parent, KPDFDocument * doc ); ~PresentationWidget(); // inherited from DocumentObserver @@ -45,6 +45,7 @@ class PresentationWidget : public QWidget, public DocumentObserver protected: // widget events + bool event( QEvent * e ); void keyPressEvent( QKeyEvent * e ); void wheelEvent( QWheelEvent * e ); void mousePressEvent( QMouseEvent * e );