2005-01-26 10:42:07 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
|
2006-02-18 12:06:52 +00:00
|
|
|
* Copyright (C) 2006 by Albert Astals Cid <aacid@kde.org> *
|
2005-01-26 10:42:07 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
// qt / kde includes
|
2006-05-27 13:36:41 +00:00
|
|
|
#include <qapplication.h>
|
2006-03-23 20:43:38 +00:00
|
|
|
#include <qevent.h>
|
2005-01-26 10:42:07 +00:00
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qlayout.h>
|
2006-03-31 11:22:29 +00:00
|
|
|
#include <QStyleOptionButton>
|
|
|
|
#include <QStylePainter>
|
2005-01-26 10:42:07 +00:00
|
|
|
#include <qvalidator.h>
|
|
|
|
#include <qpainter.h>
|
2006-07-05 11:38:51 +00:00
|
|
|
#include <kicon.h>
|
2006-03-23 20:43:38 +00:00
|
|
|
#include <kacceleratormanager.h>
|
2005-02-05 22:27:16 +00:00
|
|
|
#include <kdeversion.h>
|
2005-01-26 10:42:07 +00:00
|
|
|
|
|
|
|
// local includes
|
|
|
|
#include "core/document.h"
|
|
|
|
#include "minibar.h"
|
|
|
|
|
|
|
|
// [private widget] show progress
|
|
|
|
class ProgressWidget : public QWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressWidget( MiniBar * parent );
|
|
|
|
void setProgress( float percentage );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mouseMoveEvent( QMouseEvent * e );
|
|
|
|
void mousePressEvent( QMouseEvent * e );
|
|
|
|
void wheelEvent( QWheelEvent * e );
|
|
|
|
void paintEvent( QPaintEvent * e );
|
|
|
|
|
|
|
|
private:
|
|
|
|
MiniBar * m_miniBar;
|
|
|
|
float m_progressPercentage;
|
|
|
|
};
|
|
|
|
|
|
|
|
// [private widget] lineEdit for entering/validating page numbers
|
|
|
|
class PagesEdit : public QLineEdit
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PagesEdit( MiniBar * parent );
|
|
|
|
void setPagesNumber( int pages );
|
|
|
|
void setText( const QString & );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void focusInEvent( QFocusEvent * e );
|
|
|
|
void focusOutEvent( QFocusEvent * e );
|
|
|
|
void mousePressEvent( QMouseEvent * e );
|
|
|
|
void wheelEvent( QWheelEvent * e );
|
|
|
|
|
|
|
|
private:
|
|
|
|
MiniBar * m_miniBar;
|
|
|
|
bool m_eatClick;
|
|
|
|
QString backString;
|
|
|
|
QIntValidator * m_validator;
|
|
|
|
};
|
|
|
|
|
|
|
|
// [private widget] a flat qpushbutton that enlights on hover
|
|
|
|
class HoverButton : public QPushButton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HoverButton( QWidget * parent );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent( QPaintEvent * e );
|
2006-05-05 22:37:53 +00:00
|
|
|
void enterEvent( QEvent * e );
|
|
|
|
void leaveEvent( QEvent * e );
|
2005-01-26 10:42:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** MiniBar **/
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
MiniBar::MiniBar( QWidget * parent, Okular::Document * document )
|
2006-03-29 16:46:09 +00:00
|
|
|
: QFrame( parent ), m_document( document ),
|
2005-01-26 10:42:07 +00:00
|
|
|
m_currentPage( -1 )
|
|
|
|
{
|
2006-03-29 16:46:09 +00:00
|
|
|
setObjectName( "miniBar" );
|
2005-01-26 10:42:07 +00:00
|
|
|
// left spacer
|
|
|
|
QHBoxLayout * horLayout = new QHBoxLayout( this );
|
2006-04-01 00:01:07 +00:00
|
|
|
horLayout->setMargin( 2 );
|
2005-01-26 10:42:07 +00:00
|
|
|
QSpacerItem * spacerL = new QSpacerItem( 20, 10, QSizePolicy::Expanding );
|
|
|
|
horLayout->addItem( spacerL );
|
|
|
|
|
2006-04-13 13:07:22 +00:00
|
|
|
// central 2r by 5c grid layout that contains all components
|
|
|
|
QGridLayout * gridLayout = new QGridLayout();
|
|
|
|
gridLayout->setMargin( 2 );
|
|
|
|
gridLayout->setSpacing( 1 );
|
2005-01-26 10:42:07 +00:00
|
|
|
// top spacer 6x6 px
|
|
|
|
// QSpacerItem * spacerTop = new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed );
|
|
|
|
// gridLayout->addMultiCell( spacerTop, 0, 0, 0, 4 );
|
|
|
|
// center progress widget
|
|
|
|
m_progressWidget = new ProgressWidget( this );
|
2006-04-13 13:07:22 +00:00
|
|
|
gridLayout->addWidget( m_progressWidget, 0, 0, 1, 5 );
|
2005-01-26 10:42:07 +00:00
|
|
|
// bottom: left prev_page button
|
|
|
|
m_prevButton = new HoverButton( this );
|
2006-07-05 11:38:51 +00:00
|
|
|
m_prevButton->setIcon( KIcon( layoutDirection() == Qt::RightToLeft ? "1rightarrow" : "1leftarrow" ) );
|
2005-01-26 10:42:07 +00:00
|
|
|
gridLayout->addWidget( m_prevButton, 1, 0 );
|
|
|
|
// bottom: left lineEdit (current page box)
|
|
|
|
m_pagesEdit = new PagesEdit( this );
|
|
|
|
gridLayout->addWidget( m_pagesEdit, 1, 1 );
|
|
|
|
// bottom: central '/' label
|
|
|
|
gridLayout->addWidget( new QLabel( "/", this ), 1, 2 );
|
|
|
|
// bottom: right button
|
|
|
|
m_pagesButton = new HoverButton( this );
|
|
|
|
gridLayout->addWidget( m_pagesButton, 1, 3 );
|
|
|
|
// bottom: right next_page button
|
|
|
|
m_nextButton = new HoverButton( this );
|
2006-07-05 11:38:51 +00:00
|
|
|
m_nextButton->setIcon( KIcon( layoutDirection() == Qt::RightToLeft ? "1leftarrow" : "1rightarrow" ) );
|
2005-01-26 10:42:07 +00:00
|
|
|
gridLayout->addWidget( m_nextButton, 1, 4 );
|
|
|
|
horLayout->addLayout( gridLayout );
|
|
|
|
|
|
|
|
// right spacer
|
|
|
|
QSpacerItem * spacerR = new QSpacerItem( 20, 10, QSizePolicy::Expanding );
|
|
|
|
horLayout->addItem( spacerR );
|
|
|
|
|
|
|
|
// customize own look
|
|
|
|
setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
|
|
|
|
|
|
|
|
// connect signals from child widgets to internal handlers / signals bouncers
|
|
|
|
connect( m_pagesEdit, SIGNAL( returnPressed() ), this, SLOT( slotChangePage() ) );
|
|
|
|
connect( m_pagesButton, SIGNAL( clicked() ), this, SIGNAL( gotoPage() ) );
|
|
|
|
connect( m_prevButton, SIGNAL( clicked() ), this, SIGNAL( prevPage() ) );
|
|
|
|
connect( m_nextButton, SIGNAL( clicked() ), this, SIGNAL( nextPage() ) );
|
|
|
|
|
|
|
|
// widget starts hidden (will be shown after opening a document)
|
|
|
|
parent->hide();
|
|
|
|
}
|
|
|
|
|
2006-02-18 12:06:52 +00:00
|
|
|
MiniBar::~MiniBar()
|
|
|
|
{
|
|
|
|
m_document->removeObserver( this );
|
|
|
|
}
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
void MiniBar::notifySetup( const QVector< Okular::Page * > & pageVector, bool changed )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
|
|
|
// only process data when document changes
|
|
|
|
if ( !changed )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// if document is closed or has no pages, hide widget
|
|
|
|
int pages = pageVector.count();
|
|
|
|
if ( pages < 1 )
|
|
|
|
{
|
|
|
|
m_currentPage = -1;
|
2006-05-15 21:47:44 +00:00
|
|
|
parentWidget()->hide();
|
2005-01-26 10:42:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// resize width of widgets
|
|
|
|
int numberWidth = 10 + fontMetrics().width( QString::number( pages ) );
|
|
|
|
m_pagesEdit->setMinimumWidth( numberWidth );
|
|
|
|
m_pagesEdit->setMaximumWidth( 2 * numberWidth );
|
|
|
|
m_pagesButton->setMinimumWidth( numberWidth );
|
|
|
|
m_pagesButton->setMaximumWidth( 2 * numberWidth );
|
|
|
|
|
|
|
|
// resize height of widgets
|
2005-03-24 18:54:13 +00:00
|
|
|
int fixedHeight = fontMetrics().height() + 4;
|
|
|
|
if ( fixedHeight < 20 )
|
|
|
|
fixedHeight = 20;
|
2005-01-26 10:42:07 +00:00
|
|
|
m_pagesEdit->setFixedHeight( fixedHeight );
|
|
|
|
m_pagesButton->setFixedHeight( fixedHeight );
|
|
|
|
m_prevButton->setFixedHeight( fixedHeight );
|
|
|
|
m_nextButton->setFixedHeight( fixedHeight );
|
|
|
|
|
|
|
|
// update child widgets
|
|
|
|
m_pagesEdit->setPagesNumber( pages );
|
|
|
|
m_pagesButton->setText( QString::number( pages ) );
|
|
|
|
m_prevButton->setEnabled( false );
|
|
|
|
m_nextButton->setEnabled( false );
|
2006-05-15 21:47:44 +00:00
|
|
|
parentWidget()->show();
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
2005-02-01 18:23:55 +00:00
|
|
|
void MiniBar::notifyViewportChanged( bool /*smoothMove*/ )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
|
|
|
// get current page number
|
|
|
|
int page = m_document->viewport().pageNumber;
|
|
|
|
int pages = m_document->pages();
|
|
|
|
|
|
|
|
// if the document is opened and page is changed
|
|
|
|
if ( page != m_currentPage && pages > 0 )
|
|
|
|
{
|
|
|
|
// update percentage
|
|
|
|
m_currentPage = page;
|
|
|
|
float percentage = pages < 2 ? 1.0 : (float)page / (float)(pages - 1);
|
|
|
|
m_progressWidget->setProgress( percentage );
|
|
|
|
// update prev/next button state
|
|
|
|
m_prevButton->setEnabled( page > 0 );
|
|
|
|
m_nextButton->setEnabled( page < ( pages - 1 ) );
|
|
|
|
// update text on widgets
|
|
|
|
m_pagesEdit->setText( QString::number( page + 1 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MiniBar::resizeEvent( QResizeEvent * e )
|
|
|
|
{
|
|
|
|
// auto-hide 'prev' and 'next' buttons if not enough space
|
|
|
|
const QSize & myHint = minimumSizeHint();
|
|
|
|
bool shown = m_prevButton->isVisible() && m_nextButton->isVisible();
|
|
|
|
if ( shown && e->size().width() < myHint.width() )
|
|
|
|
{
|
|
|
|
m_prevButton->hide();
|
|
|
|
m_nextButton->hide();
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
else if ( !shown )
|
|
|
|
{
|
|
|
|
int histeresis = m_prevButton->sizeHint().width() * 2 + 2;
|
|
|
|
if ( e->size().width() > (myHint.width() + histeresis) )
|
|
|
|
{
|
|
|
|
m_prevButton->show();
|
|
|
|
m_nextButton->show();
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MiniBar::slotChangePage()
|
|
|
|
{
|
|
|
|
// get text from the lineEdit
|
|
|
|
QString pageNumber = m_pagesEdit->text();
|
|
|
|
|
|
|
|
// convert it to page number and go to that page
|
|
|
|
bool ok;
|
|
|
|
int number = pageNumber.toInt( &ok ) - 1;
|
|
|
|
if ( ok && number >= 0 && number < (int)m_document->pages() &&
|
|
|
|
number != m_currentPage )
|
|
|
|
{
|
|
|
|
m_document->setViewportPage( number );
|
|
|
|
m_pagesEdit->clearFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MiniBar::slotGotoNormalizedPage( float index )
|
|
|
|
{
|
|
|
|
// figure out page number and go to that page
|
|
|
|
int number = (int)( index * (float)m_document->pages() );
|
|
|
|
if ( number >= 0 && number < (int)m_document->pages() &&
|
|
|
|
number != m_currentPage )
|
|
|
|
m_document->setViewportPage( number );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MiniBar::slotEmitNextPage()
|
|
|
|
{
|
|
|
|
// emit signal
|
|
|
|
nextPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MiniBar::slotEmitPrevPage()
|
|
|
|
{
|
|
|
|
// emit signal
|
|
|
|
prevPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ProgressWidget **/
|
|
|
|
|
|
|
|
ProgressWidget::ProgressWidget( MiniBar * parent )
|
2006-03-29 20:43:48 +00:00
|
|
|
: QWidget( parent ),
|
2005-01-26 10:42:07 +00:00
|
|
|
m_miniBar( parent ), m_progressPercentage( -1 )
|
|
|
|
{
|
2006-03-29 20:43:48 +00:00
|
|
|
setObjectName( "progress" );
|
|
|
|
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
2005-01-26 10:42:07 +00:00
|
|
|
setFixedHeight( 4 );
|
|
|
|
setMouseTracking( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProgressWidget::setProgress( float percentage )
|
|
|
|
{
|
|
|
|
m_progressPercentage = percentage;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProgressWidget::mouseMoveEvent( QMouseEvent * e )
|
|
|
|
{
|
2006-05-27 13:52:29 +00:00
|
|
|
if ( ( QApplication::mouseButtons() & Qt::LeftButton ) && width() > 0 )
|
2006-09-20 13:58:28 +00:00
|
|
|
m_miniBar->slotGotoNormalizedPage( (float)( QApplication::isRightToLeft() ? width() - e->x() : e->x() ) / (float)width() );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProgressWidget::mousePressEvent( QMouseEvent * e )
|
|
|
|
{
|
|
|
|
if ( e->button() == Qt::LeftButton && width() > 0 )
|
2006-09-20 13:58:28 +00:00
|
|
|
m_miniBar->slotGotoNormalizedPage( (float)( QApplication::isRightToLeft() ? width() - e->x() : e->x() ) / (float)width() );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProgressWidget::wheelEvent( QWheelEvent * e )
|
|
|
|
{
|
|
|
|
if ( e->delta() > 0 )
|
|
|
|
m_miniBar->slotEmitNextPage();
|
|
|
|
else
|
|
|
|
m_miniBar->slotEmitPrevPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProgressWidget::paintEvent( QPaintEvent * e )
|
|
|
|
{
|
|
|
|
if ( m_progressPercentage < 0.0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// find out the 'fill' and the 'clear' rectangles
|
|
|
|
int w = width(),
|
|
|
|
h = height(),
|
|
|
|
l = (int)( (float)w * m_progressPercentage );
|
2006-09-20 13:58:28 +00:00
|
|
|
QRect cRect = ( QApplication::isRightToLeft() ? QRect( 0, 0, w - l, h ) : QRect( l, 0, w - l, h ) ).intersect( e->rect() );
|
|
|
|
QRect fRect = ( QApplication::isRightToLeft() ? QRect( w - l, 0, l, h ) : QRect( 0, 0, l, h ) ).intersect( e->rect() );
|
2005-01-26 10:42:07 +00:00
|
|
|
QPainter p( this );
|
2005-03-24 18:54:13 +00:00
|
|
|
|
2006-05-27 13:36:41 +00:00
|
|
|
QPalette pal = palette();
|
2005-03-24 18:54:13 +00:00
|
|
|
// paint clear rect
|
2005-01-26 10:42:07 +00:00
|
|
|
if ( cRect.isValid() )
|
2006-05-27 13:36:41 +00:00
|
|
|
p.fillRect( cRect, pal.color( QPalette::Active, QPalette::HighlightedText ) );
|
2005-03-24 18:54:13 +00:00
|
|
|
// draw a frame-like outline
|
|
|
|
//p.setPen( palette().active().mid() );
|
|
|
|
//p.drawRect( 0,0, w, h );
|
|
|
|
// paint fill rect
|
2005-01-26 10:42:07 +00:00
|
|
|
if ( fRect.isValid() )
|
2006-05-27 13:36:41 +00:00
|
|
|
p.fillRect( fRect, pal.color( QPalette::Active, QPalette::Highlight ) );
|
2005-01-26 10:42:07 +00:00
|
|
|
if ( l && l != w )
|
|
|
|
{
|
2006-05-27 13:36:41 +00:00
|
|
|
p.setPen( pal.color( QPalette::Active, QPalette::Highlight ).dark( 120 ) );
|
2006-09-20 13:58:28 +00:00
|
|
|
int delta = QApplication::isRightToLeft() ? w - l : l;
|
|
|
|
p.drawLine( delta, 0, delta, h );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** PagesEdit **/
|
|
|
|
|
|
|
|
PagesEdit::PagesEdit( MiniBar * parent )
|
|
|
|
: QLineEdit( parent ), m_miniBar( parent ), m_eatClick( false )
|
|
|
|
{
|
|
|
|
// use an integer validator
|
|
|
|
m_validator = new QIntValidator( 1, 1, this );
|
|
|
|
setValidator( m_validator );
|
|
|
|
|
|
|
|
// customize text properties
|
|
|
|
setAlignment( Qt::AlignCenter );
|
|
|
|
setMaxLength( 4 );
|
2006-05-27 13:36:41 +00:00
|
|
|
|
|
|
|
// send a focus out event
|
|
|
|
QFocusEvent fe( QEvent::FocusOut );
|
|
|
|
QApplication::sendEvent( this, &fe );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::setPagesNumber( int pages )
|
|
|
|
{
|
|
|
|
m_validator->setTop( pages );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::setText( const QString & text )
|
|
|
|
{
|
|
|
|
// store a copy of the string
|
|
|
|
backString = text;
|
|
|
|
// call default handler if hasn't focus
|
|
|
|
if ( !hasFocus() )
|
|
|
|
QLineEdit::setText( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::focusInEvent( QFocusEvent * e )
|
|
|
|
{
|
|
|
|
// select all text
|
|
|
|
selectAll();
|
2006-03-23 20:43:38 +00:00
|
|
|
if ( e->reason() == Qt::MouseFocusReason )
|
2005-01-26 10:42:07 +00:00
|
|
|
m_eatClick = true;
|
|
|
|
// change background color to the default 'edit' color
|
2006-05-27 13:36:41 +00:00
|
|
|
QPalette pal = palette();
|
|
|
|
pal.setColor( QPalette::Active, QPalette::Base, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
|
|
|
|
setPalette( pal );
|
2005-01-26 10:42:07 +00:00
|
|
|
// call default handler
|
|
|
|
QLineEdit::focusInEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::focusOutEvent( QFocusEvent * e )
|
|
|
|
{
|
|
|
|
// change background color to a dark tone
|
2006-05-27 13:36:41 +00:00
|
|
|
QPalette pal = palette();
|
|
|
|
pal.setColor( QPalette::Base, QApplication::palette().color( QPalette::Base ).dark( 102 ) );
|
|
|
|
setPalette( pal );
|
2005-01-26 10:42:07 +00:00
|
|
|
// restore text
|
|
|
|
QLineEdit::setText( backString );
|
|
|
|
// call default handler
|
|
|
|
QLineEdit::focusOutEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::mousePressEvent( QMouseEvent * e )
|
|
|
|
{
|
|
|
|
// if this click got the focus in, don't process the event
|
|
|
|
if ( !m_eatClick )
|
|
|
|
QLineEdit::mousePressEvent( e );
|
|
|
|
m_eatClick = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PagesEdit::wheelEvent( QWheelEvent * e )
|
|
|
|
{
|
|
|
|
if ( e->delta() > 0 )
|
|
|
|
m_miniBar->slotEmitNextPage();
|
|
|
|
else
|
|
|
|
m_miniBar->slotEmitPrevPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** HoverButton **/
|
|
|
|
|
|
|
|
HoverButton::HoverButton( QWidget * parent )
|
2005-11-04 11:59:51 +00:00
|
|
|
: QPushButton( parent )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
|
|
|
setMouseTracking( true );
|
|
|
|
KAcceleratorManager::setNoAccel( this );
|
|
|
|
}
|
|
|
|
|
2006-05-05 22:37:53 +00:00
|
|
|
void HoverButton::enterEvent( QEvent * e )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
2005-11-04 11:59:51 +00:00
|
|
|
update();
|
|
|
|
QPushButton::enterEvent( e );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
2006-05-05 22:37:53 +00:00
|
|
|
void HoverButton::leaveEvent( QEvent * e )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
2005-11-04 11:59:51 +00:00
|
|
|
update();
|
|
|
|
QPushButton::leaveEvent( e );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HoverButton::paintEvent( QPaintEvent * e )
|
|
|
|
{
|
2006-04-01 00:01:07 +00:00
|
|
|
if ( testAttribute( Qt::WA_UnderMouse ) && isEnabled() )
|
2005-01-26 10:42:07 +00:00
|
|
|
{
|
|
|
|
QPushButton::paintEvent( e );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-31 11:22:29 +00:00
|
|
|
QStylePainter p( this );
|
|
|
|
QStyleOptionButton opt;
|
|
|
|
opt.initFrom( this );
|
|
|
|
opt.features = QStyleOptionButton::Flat;
|
|
|
|
opt.icon = icon();
|
|
|
|
opt.iconSize = iconSize();
|
|
|
|
opt.text = text();
|
|
|
|
p.drawControl( QStyle::CE_PushButton, opt );
|
2005-01-26 10:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "minibar.moc"
|