Commit fa67d667 authored by Albert Astals Cid's avatar Albert Astals Cid

Delay the calculation of m_width and m_height (and all its associated things)...

Delay the calculation of m_width and m_height (and all its associated things) until first time the widget is shown (paintEvent), doing KGlobalSettings::desktopGeometry(this); in PresentationWidget::PresentationWidget always returns the geometry of the first screen, so it must be done in paintEvent (for example), where the widget has already been shown and KGlobalSettings::desktopGeometry(this); returns the geometry of the correct screen.
Thanks to Olaf Bonorden for the patch testing
BUGS: 97347

svn path=/trunk/kdegraphics/kpdf/; revision=389970
parent 64bab005
......@@ -52,25 +52,11 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
{
// set look and geometry
setBackgroundMode( Qt::NoBackground );
QRect d = KGlobalSettings::desktopGeometry(this);
m_width = d.width();
m_height = d.height();
// create top toolbar
m_topBar = new KToolBar( this, "presentationBar" );
m_topBar->setIconSize( 32 );
m_topBar->setMovingEnabled( false );
m_topBar->insertButton( "1leftarrow", 2, SIGNAL( clicked() ), this, SLOT( slotPrevPage() ) );
m_topBar->insertButton( "1rightarrow", 3, SIGNAL( clicked() ), this, SLOT( slotNextPage() ) );
m_topBar->insertButton( "exit", 1, SIGNAL( clicked() ), this, SLOT( close() ) );
m_topBar->setGeometry( 0, 0, m_width, 32 + 10 );
m_topBar->alignItemRight( 1 );
m_topBar->hide();
// change topbar background color
QPalette p = m_topBar->palette();
p.setColor( QPalette::Active, QColorGroup::Button, Qt::gray );
p.setColor( QPalette::Active, QColorGroup::Background, Qt::darkGray );
m_topBar->setPalette( p );
m_width = -1;
// show widget and take control
showFullScreen();
// misc stuff
setMouseTracking( true );
......@@ -79,9 +65,6 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
m_overlayHideTimer = new QTimer( this );
connect( m_overlayHideTimer, SIGNAL( timeout() ), this, SLOT( slotHideOverlay() ) );
// show widget and take control
showFullScreen();
// handle cursor appearance as specified in configuration
if ( Settings::slidesCursor() == Settings::EnumSlidesCursor::HiddenDelay )
{
......@@ -92,13 +75,6 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
{
setCursor( KCursor::blankCursor() );
}
// register this observer in document. events will come immediately
m_document->addObserver( this );
// show summary if requested
if ( Settings::slidesShowSummary() )
generatePage();
}
PresentationWidget::~PresentationWidget()
......@@ -194,6 +170,8 @@ bool PresentationWidget::canUnloadPixmap( int pageNumber )
// <widget events>
void PresentationWidget::keyPressEvent( QKeyEvent * e )
{
if (m_width == -1) return;
if ( e->key() == Key_Left || e->key() == Key_Backspace )
slotPrevPage();
else if ( e->key() == Key_Right || e->key() == Key_Space )
......@@ -244,6 +222,8 @@ void PresentationWidget::mousePressEvent( QMouseEvent * e )
void PresentationWidget::mouseMoveEvent( QMouseEvent * e )
{
if (m_width == -1) return;
// hide a shown bar when exiting the area
if ( m_topBar->isShown() )
{
......@@ -260,6 +240,36 @@ void PresentationWidget::mouseMoveEvent( QMouseEvent * e )
void PresentationWidget::paintEvent( QPaintEvent * pe )
{
if (m_width == -1)
{
QRect d = KGlobalSettings::desktopGeometry(this);
m_width = d.width();
m_height = d.height();
// create top toolbar
m_topBar = new KToolBar( this, "presentationBar" );
m_topBar->setIconSize( 32 );
m_topBar->setMovingEnabled( false );
m_topBar->insertButton( "1leftarrow", 2, SIGNAL( clicked() ), this, SLOT( slotPrevPage() ) );
m_topBar->insertButton( "1rightarrow", 3, SIGNAL( clicked() ), this, SLOT( slotNextPage() ) );
m_topBar->insertButton( "exit", 1, SIGNAL( clicked() ), this, SLOT( close() ) );
m_topBar->setGeometry( 0, 0, m_width, 32 + 10 );
m_topBar->alignItemRight( 1 );
m_topBar->hide();
// change topbar background color
QPalette p = m_topBar->palette();
p.setColor( QPalette::Active, QColorGroup::Button, Qt::gray );
p.setColor( QPalette::Active, QColorGroup::Background, Qt::darkGray );
m_topBar->setPalette( p );
// register this observer in document. events will come immediately
m_document->addObserver( this );
// show summary if requested
if ( Settings::slidesShowSummary() )
generatePage();
}
// check painting rect consistancy
QRect r = pe->rect().intersect( geometry() );
if ( r.isNull() || m_lastRenderedPixmap.isNull() )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment