Commit 252de94b authored by Pino Toscano's avatar Pino Toscano

improve a bit the PageViewTopMessage api, in preparation of new future usage

svn path=/trunk/playground/graphics/okular/; revision=636493
parent 290ae2a2
......@@ -194,6 +194,7 @@ m_searchStarted(false), m_cliPresentation(false)
// KToolBar * rtb = new KToolBar( rightContainer, "mainToolBarSS" );
// rightLayout->addWidget( rtb );
m_topMessage = new PageViewTopMessage( rightContainer );
m_topMessage->setup( i18n( "This document has embedded files. <a href=\"okular:/embeddedfiles\">Click here to see them</a> or go to File -> Embedded Files." ), KIcon( "attach" ) );
connect( m_topMessage, SIGNAL( action() ), this, SLOT( slotShowEmbeddedFiles() ) );
rightLayout->addWidget( m_topMessage );
m_pageView = new PageView( rightContainer, m_document );
......@@ -643,10 +644,7 @@ bool Part::openFile()
m_showProperties->setEnabled( ok );
bool hasEmbeddedFiles = ok && m_document->embeddedFiles() && m_document->embeddedFiles()->count() > 0;
m_showEmbeddedFiles->setEnabled( hasEmbeddedFiles );
if ( hasEmbeddedFiles )
m_topMessage->display( i18n( "This document has embedded files. <a href=\"okular:/embeddedfiles\">Click here to see them</a> or go to File -> Embedded Files." ), KIcon( "attach" ) );
else
m_topMessage->hide();
m_topMessage->setVisible( hasEmbeddedFiles );
m_showPresentation->setEnabled( ok );
if ( ok )
{
......
......@@ -236,7 +236,7 @@ void PageViewMessage::mousePressEvent( QMouseEvent * /*e*/ )
/************************/
PageViewTopMessage::PageViewTopMessage( QWidget * parent )
: QWidget( parent )
: QWidget( parent ), m_button( 0 )
{
setAutoFillBackground( true );
QPalette pal = palette();
......@@ -264,7 +264,7 @@ PageViewTopMessage::PageViewTopMessage( QWidget * parent )
hide();
}
void PageViewTopMessage::display( const QString & message, const KIcon& icon )
void PageViewTopMessage::setup( const QString & message, const KIcon& icon )
{
m_label->setText( message );
resize( minimumSizeHint() );
......@@ -276,7 +276,6 @@ void PageViewTopMessage::display( const QString & message, const KIcon& icon )
{
m_icon->setPixmap( icon.pixmap( m_icon->size() ) );
}
show();
}
void PageViewTopMessage::setIconSize( int size )
......@@ -284,6 +283,21 @@ void PageViewTopMessage::setIconSize( int size )
m_icon->resize( size, size );
}
void PageViewTopMessage::setActionButton( QAction * action )
{
if ( !action )
{
delete m_button;
return;
}
if ( !m_button )
{
m_button = new QToolButton( this );
layout()->addWidget( m_button );
}
m_button->setDefaultAction( action );
}
/*********************/
/** PageViewToolBar */
......
......@@ -14,8 +14,10 @@
#include <qpixmap.h>
#include <qrect.h>
class QAction;
class QLabel;
class QTimer;
class QToolButton;
class KIcon;
namespace Okular {
......@@ -88,8 +90,9 @@ class PageViewTopMessage : public QWidget
public:
PageViewTopMessage( QWidget * parent );
void display( const QString & message, const KIcon& icon = KIcon() );
void setup( const QString & message, const KIcon& icon = KIcon() );
void setIconSize( int size );
void setActionButton( QAction * action );
signals:
void action();
......@@ -97,6 +100,7 @@ class PageViewTopMessage : public QWidget
private:
QLabel * m_label;
QLabel * m_icon;
QToolButton * m_button;
};
......
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