mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 03:30:20 +00:00
Modify how page size label is shown on the bottom bar
Opened a file with all pages with same size and behaves exactly like Okular does Opened a file with pages with different sizes and behaves like Okular does until it stops fiting. In that moment the page bar is not centered anymore to let the text still fit and once the text doesn't fit anymore it starts getting ellided. Reviewed by Luigi BUGS: 333349 FIXED-IN: 4.13.1
This commit is contained in:
parent
49dc7dcb59
commit
e0e98658e5
2
part.cpp
2
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 );
|
||||
|
||||
|
|
|
@ -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<QWidget*>(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"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef _OKULAR_PAGESIZELABEL_H_
|
||||
#define _OKULAR_PAGESIZELABEL_H_
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <ksqueezedtextlabel.h>
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue