diff --git a/part.cpp b/part.cpp index 9a9979ec5..42d782d05 100644 --- a/part.cpp +++ b/part.cpp @@ -446,12 +446,10 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW m_pageSizeLabel = new PageSizeLabel( m_bottomBar, m_document ); bottomBarLayout->setMargin( 0 ); bottomBarLayout->setSpacing( 0 ); - bottomBarLayout->addWidget( m_pageSizeLabel->antiWidget() ); bottomBarLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); m_miniBarLogic = new MiniBarLogic( this, m_document ); m_miniBar = new MiniBar( m_bottomBar, m_miniBarLogic ); bottomBarLayout->addWidget( m_miniBar ); - bottomBarLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); bottomBarLayout->addWidget( m_pageSizeLabel ); rightLayout->addWidget( m_bottomBar ); diff --git a/ui/pagesizelabel.cpp b/ui/pagesizelabel.cpp index aa4a043b8..c91afc75a 100644 --- a/ui/pagesizelabel.cpp +++ b/ui/pagesizelabel.cpp @@ -12,9 +12,9 @@ #include "core/document.h" PageSizeLabel::PageSizeLabel( QWidget * parent, Okular::Document * document ) - : QLabel( parent ), m_document( document ), - m_antiWidget( NULL ) + : KSqueezedTextLabel( parent ), m_document( document ) { + setAlignment( Qt::AlignRight ); } PageSizeLabel::~PageSizeLabel() @@ -22,52 +22,15 @@ PageSizeLabel::~PageSizeLabel() m_document->removeObserver( this ); } -QWidget *PageSizeLabel::antiWidget() -{ - if (!m_antiWidget) - { - m_antiWidget = new QWidget(qobject_cast(parent())); - m_antiWidget->resize(0, 0); - } - return m_antiWidget; -} - -void PageSizeLabel::notifySetup( const QVector< Okular::Page * > & pageVector, int setupFlags ) -{ - // only process data when document changes - if ( !( setupFlags & Okular::DocumentObserver::DocumentChanged ) ) - return; - - // if document is closed or all pages have size hide widget - int pages = pageVector.count(); - if ( pages < 1 || m_document->allPagesSize().isValid() ) - { - hide(); - if ( m_antiWidget ) - m_antiWidget->hide(); - return; - } - else - { - show(); - if ( m_antiWidget ) - m_antiWidget->show(); - } -} - void PageSizeLabel::notifyCurrentPageChanged( int previousPage, int currentPage ) { Q_UNUSED( previousPage ) - if (isVisible()) + // if the document is opened + if ( m_document->pages() > 0 && !m_document->allPagesSize().isValid() ) { - // if the document is opened - if ( m_document->pages() > 0 ) - { - setText( m_document->pageSizeString( currentPage ) ); - m_antiWidget->setFixedSize( sizeHint() ); - } - } + setText( m_document->pageSizeString( currentPage ) ); + } } #include "pagesizelabel.moc" diff --git a/ui/pagesizelabel.h b/ui/pagesizelabel.h index d317fd65b..3c1ec8b1d 100644 --- a/ui/pagesizelabel.h +++ b/ui/pagesizelabel.h @@ -10,7 +10,7 @@ #ifndef _OKULAR_PAGESIZELABEL_H_ #define _OKULAR_PAGESIZELABEL_H_ -#include +#include #include "core/observer.h" @@ -21,7 +21,7 @@ class Document; /** * @short A widget to display page size. */ -class PageSizeLabel : public QLabel, public Okular::DocumentObserver +class PageSizeLabel : public KSqueezedTextLabel, public Okular::DocumentObserver { Q_OBJECT @@ -29,15 +29,11 @@ class PageSizeLabel : public QLabel, public Okular::DocumentObserver PageSizeLabel( QWidget *parent, Okular::Document * document ); ~PageSizeLabel(); - QWidget *antiWidget(); - // [INHERITED] from DocumentObserver - void notifySetup( const QVector< Okular::Page * > & pages, int setupFlags ); void notifyCurrentPageChanged( int previous, int current ); private: Okular::Document * m_document; - QWidget *m_antiWidget; }; #endif