Commit 56c10183 authored by Luigi Toscano's avatar Luigi Toscano
Browse files

Remove PageViewTopMessage, use KMessageWidget instead

Acked by Albert Astal Cid
parent 11773fdc
......@@ -43,6 +43,7 @@
#include <kfiledialog.h>
#include <kinputdialog.h>
#include <kmessagebox.h>
#include <kmessagewidget.h>
#include <knuminput.h>
#include <kio/netaccess.h>
#include <kmenu.h>
......@@ -424,11 +425,18 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
rightLayout->setSpacing( 0 );
// 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( "mail-attachment" ) );
connect( m_topMessage, SIGNAL(action()), this, SLOT(slotShowEmbeddedFiles()) );
m_topMessage = new KMessageWidget( rightContainer );
m_topMessage->setVisible( false );
m_topMessage->setWordWrap( true );
m_topMessage->setMessageType( KMessageWidget::Information );
m_topMessage->setText( i18n( "This document has embedded files. <a href=\"okular:/embeddedfiles\">Click here to see them</a> or go to File -> Embedded Files." ) );
m_topMessage->setIcon( KIcon( "mail-attachment" ) );
connect( m_topMessage, SIGNAL(linkActivated(QString)), this, SLOT(slotShowEmbeddedFiles()) );
rightLayout->addWidget( m_topMessage );
m_formsMessage = new PageViewTopMessage( rightContainer );
m_formsMessage = new KMessageWidget( rightContainer );
m_formsMessage->setVisible( false );
m_formsMessage->setWordWrap( true );
m_formsMessage->setMessageType( KMessageWidget::Information );
rightLayout->addWidget( m_formsMessage );
m_pageView = new PageView( rightContainer, m_document );
QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting
......@@ -1263,13 +1271,16 @@ bool Part::openFile()
// Warn the user that XFA forms are not supported yet (NOTE: poppler generator only)
if ( ok && m_document->metaData( "HasUnsupportedXfaForm" ).toBool() == true )
{
m_formsMessage->setup( i18n( "This document has XFA forms, which are currently <b>unsupported</b>." ), KIcon( "dialog-warning" ) );
m_formsMessage->setText( i18n( "This document has XFA forms, which are currently <b>unsupported</b>." ) );
m_formsMessage->setIcon( KIcon( "dialog-warning" ) );
m_formsMessage->setMessageType( KMessageWidget::Warning );
m_formsMessage->setVisible( true );
}
// m_pageView->toggleFormsAction() may be null on dummy mode
else if ( ok && m_pageView->toggleFormsAction() && m_pageView->toggleFormsAction()->isEnabled() )
{
m_formsMessage->setup( i18n( "This document has forms. Click on the button to interact with them, or use View -> Show Forms." ) );
m_formsMessage->setText( i18n( "This document has forms. Click on the button to interact with them, or use View -> Show Forms." ) );
m_formsMessage->setMessageType( KMessageWidget::Information );
m_formsMessage->setVisible( true );
}
else
......@@ -2678,7 +2689,8 @@ void Part::unsetDummyMode()
m_pageView->setupActions( actionCollection() );
// attach the actions of the children widgets too
m_formsMessage->setActionButton( m_pageView->toggleFormsAction() );
m_formsMessage->addAction( m_pageView->toggleFormsAction() );
m_formsMessage->setVisible( m_pageView->toggleFormsAction() != 0 );
// ensure history actions are in the correct state
updateViewActions();
......
......@@ -47,13 +47,13 @@ class KAboutData;
class KTemporaryFile;
class KAction;
class KMenu;
class KMessageWidget;
namespace KParts { class GUIActivateEvent; }
class FindBar;
class ThumbnailList;
class PageSizeLabel;
class PageView;
class PageViewTopMessage;
class PresentationWidget;
class ProgressWidget;
class SearchWidget;
......@@ -255,8 +255,8 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
Sidebar *m_sidebar;
SearchWidget *m_searchWidget;
FindBar * m_findBar;
PageViewTopMessage * m_topMessage;
PageViewTopMessage * m_formsMessage;
KMessageWidget * m_topMessage;
KMessageWidget * m_formsMessage;
QPointer<ThumbnailList> m_thumbnailList;
QPointer<PageView> m_pageView;
QPointer<TOC> m_toc;
......
......@@ -419,68 +419,6 @@ void PageViewMessage::mousePressEvent( QMouseEvent * /*e*/ )
}
/************************/
/** PageViewTopMessage */
/************************/
PageViewTopMessage::PageViewTopMessage( QWidget * parent )
: QWidget( parent )
{
setAutoFillBackground( true );
QPalette pal = palette();
KColorScheme::adjustBackground( pal, KColorScheme::NeutralBackground, QPalette::Window );
KColorScheme::adjustForeground( pal, KColorScheme::NeutralText, QPalette::Text );
setPalette( pal );
QHBoxLayout * lay = new QHBoxLayout( this );
lay->setMargin( 4 );
m_icon = new QLabel( this );
lay->addWidget( m_icon );
m_icon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
m_label = new QLabel( this );
lay->addWidget( m_label );
m_label->setWordWrap( true );
connect( m_label, SIGNAL(linkActivated(QString)), this, SIGNAL(action()) );
m_button = new QToolButton( this );
m_button->setVisible( false );
lay->addWidget( m_button );
QToolButton * closeButton = new QToolButton( this );
lay->addWidget( closeButton );
closeButton->setAutoRaise( true );
closeButton->setIcon( closeButton->style()->standardIcon( QStyle::SP_TitleBarCloseButton ) );
closeButton->setIconSize( QSize( 32, 32 ) );
closeButton->setToolTip( i18n( "Close this message" ) );
connect( closeButton, SIGNAL(clicked()), this, SLOT(hide()) );
setIconSize( 32 );
hide();
}
void PageViewTopMessage::setup( const QString & message, const KIcon& icon )
{
m_label->setText( message );
if ( icon.isNull() )
{
m_icon->setPixmap( QPixmap() );
m_icon->setVisible( false );
}
else
{
m_icon->setPixmap( icon.pixmap( m_icon->size() ) );
m_icon->setVisible( true );
}
resize( minimumSizeHint() );
}
void PageViewTopMessage::setIconSize( int size )
{
m_icon->setFixedSize( size, size );
}
void PageViewTopMessage::setActionButton( QAction * action )
{
m_button->setDefaultAction( action );
m_button->setVisible( action != 0 );
}
/*********************/
/** PageViewToolBar */
/*********************/
......
......@@ -122,32 +122,6 @@ class PageViewMessage : public QWidget
int m_lineSpacing;
};
/**
* @short A widget that displays messages in the top part of the page view.
*
* ...
*/
class PageViewTopMessage : public QWidget
{
Q_OBJECT
public:
PageViewTopMessage( QWidget * parent );
void setup( const QString & message, const KIcon& icon = KIcon() );
void setIconSize( int size );
void setActionButton( QAction * action );
signals:
void action();
private:
QLabel * m_label;
QLabel * m_icon;
QToolButton * m_button;
};
struct AnnotationToolItem
{
AnnotationToolItem()
......
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