Various status bar related fixes:

* Status Bar now available for Scan Popup window as well.
* Fixed #13: Eliminated modal box when sound is not available:
  Instead of modal dialog box we now show the status bar message,
  with error icon, thus making it visible but not disruptive.
* Proper handling of status bar images.
* Styling of the status bar in both modes
  (in Mani Window and in Popup Window).
This commit is contained in:
Tvangeste 2011-07-14 22:11:57 +02:00
parent 39d8772153
commit 4163bce8a2
11 changed files with 73 additions and 47 deletions

View file

@ -1225,7 +1225,8 @@ void ArticleView::resourceDownloadFinished()
} }
if ( !QDesktopServices::openUrl( QUrl::fromLocalFile( desktopOpenedTempFile ) ) ) if ( !QDesktopServices::openUrl( QUrl::fromLocalFile( desktopOpenedTempFile ) ) )
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "Failed to auto-open resource file, try opening manually: %1." ).arg( desktopOpenedTempFile ) ); QMessageBox::critical( this, tr( "GoldenDict" ),
tr( "Failed to auto-open resource file, try opening manually: %1." ).arg( desktopOpenedTempFile ) );
} }
// Ok, whatever it was, it's finished. Remove this and any other // Ok, whatever it was, it's finished. Remove this and any other
@ -1247,8 +1248,9 @@ void ArticleView::resourceDownloadFinished()
if ( resourceDownloadRequests.empty() ) if ( resourceDownloadRequests.empty() )
{ {
// No requests suceeded. emit statusBarMessage(
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "The referenced resource failed to download." ) ); tr( "WARNING: %1" ).arg( tr( "The referenced resource failed to download." ) ),
10000, QPixmap( ":/icons/error.png" ) );
} }
} }

View file

@ -178,7 +178,7 @@ signals:
/// switch focus to word input. /// switch focus to word input.
void typingEvent( QString const & text ); void typingEvent( QString const & text );
void statusBarMessage( QString const & message ); void statusBarMessage( QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap());
/// Emitted when an article becomes active, /// Emitted when an article becomes active,
/// typically in response to user actions /// typically in response to user actions

BIN
icons/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

View file

@ -10,41 +10,46 @@
#include <QEvent> #include <QEvent>
#include <QApplication> #include <QApplication>
MainStatusBar::MainStatusBar(QWidget *parent) : QWidget(parent) MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
{ {
textWidget = new QLabel(QString(), this); textWidget = new QLabel( QString(), this );
textWidget->setObjectName("text"); textWidget->setObjectName( "text" );
textWidget->setFont(QApplication::font("QStatusBar")); textWidget->setFont( QApplication::font( "QStatusBar" ) );
textWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); textWidget->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
picWidget = new QLabel(QString(), this); picWidget = new QLabel( QString(), this );
picWidget->setObjectName("icon"); picWidget->setObjectName( "icon" );
picWidget->setPixmap(QPixmap()); picWidget->setPixmap( QPixmap() );
picWidget->setScaledContents(true); picWidget->setScaledContents( true );
picWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); picWidget->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Ignored );
timer = new QTimer(this); timer = new QTimer( this );
timer->setSingleShot(true); timer->setSingleShot( true );
// layout // layout
QHBoxLayout * layout = new QHBoxLayout; QHBoxLayout * layout = new QHBoxLayout;
layout->setSpacing(0); layout->setSpacing( 0 );
layout->setSizeConstraint(QLayout::SetFixedSize); layout->setSizeConstraint( QLayout::SetFixedSize );
layout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); layout->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget(picWidget); layout->addWidget( picWidget );
layout->addWidget(textWidget); layout->addWidget( textWidget );
setLayout(layout); setLayout( layout );
parentWidget()->installEventFilter( this ); parentWidget()->installEventFilter( this );
connect( timer, SIGNAL( timeout() ), SLOT( clearMessage() ) ); connect( timer, SIGNAL( timeout() ), SLOT( clearMessage() ) );
} }
bool MainStatusBar::hasImage() const
{
return !picWidget->pixmap()->isNull();
}
void MainStatusBar::clearMessage() void MainStatusBar::clearMessage()
{ {
textWidget->setText(QString()); textWidget->setText( QString() );
picWidget->setPixmap(QPixmap()); picWidget->setPixmap( QPixmap() );
timer->stop(); timer->stop();
refresh(); refresh();
} }
@ -59,6 +64,9 @@ void MainStatusBar::showMessage(const QString & str, int timeout, const QPixmap
textWidget->setText( str ); textWidget->setText( str );
picWidget->setPixmap( pixmap ); picWidget->setPixmap( pixmap );
// reload stylesheet
setStyleSheet( styleSheet() );
if ( timeout > 0 ) if ( timeout > 0 )
{ {
timer->start( timeout ); timer->start( timeout );
@ -71,13 +79,15 @@ void MainStatusBar::refresh()
{ {
if ( !currentMessage().isEmpty() ) if ( !currentMessage().isEmpty() )
{ {
adjustSize();
if ( !picWidget->pixmap()->isNull() ) if ( !picWidget->pixmap()->isNull() )
{ {
picWidget->setFixedSize( textWidget->height(), textWidget->height() ); picWidget->setFixedSize( textWidget->height(), textWidget->height() );
} }
else else
{ {
picWidget->setFixedSize( 0, 0); picWidget->setFixedSize( 0, 0 );
} }
adjustSize(); adjustSize();
@ -98,7 +108,7 @@ void MainStatusBar::mousePressEvent ( QMouseEvent * )
clearMessage(); clearMessage();
} }
bool MainStatusBar::eventFilter(QObject *, QEvent * e) bool MainStatusBar::eventFilter( QObject *, QEvent * e )
{ {
switch ( e->type() ) { switch ( e->type() ) {
case QEvent::Resize: case QEvent::Resize:

View file

@ -12,6 +12,7 @@
class MainStatusBar : public QWidget class MainStatusBar : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool hasImage READ hasImage)
public: public:
explicit MainStatusBar(QWidget * parent); explicit MainStatusBar(QWidget * parent);
@ -36,6 +37,7 @@ private:
QTimer * timer; QTimer * timer;
bool eventFilter(QObject *obj, QEvent * event); bool eventFilter(QObject *obj, QEvent * event);
void refresh(); void refresh();
bool hasImage() const;
}; };
#endif // MAINSTATUSBAR_HH #endif // MAINSTATUSBAR_HH

View file

@ -918,8 +918,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
connect( view, SIGNAL( activeArticleChanged( const QString & ) ), connect( view, SIGNAL( activeArticleChanged( const QString & ) ),
this, SLOT( activeArticleChanged( const QString & ) ) ); this, SLOT( activeArticleChanged( const QString & ) ) );
connect( view, SIGNAL( statusBarMessage( const QString & ) ), connect( view, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ),
this, SLOT( showStatusBarMessage( const QString & ) ) ); this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
int index = cfg.preferences.newTabsOpenAfterCurrentOne ? int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count(); ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count();
@ -1056,9 +1056,9 @@ void MainWindow::pageLoaded( ArticleView * view )
updateFoundInDictsList(); updateFoundInDictsList();
} }
void MainWindow::showStatusBarMessage( const QString & message ) void MainWindow::showStatusBarMessage( QString const & message, int timeout, QPixmap const & icon )
{ {
mainStatusBar->showMessage( message, 5000 ); mainStatusBar->showMessage( message, timeout, icon );
} }
void MainWindow::tabSwitched( int ) void MainWindow::tabSwitched( int )

View file

@ -45,7 +45,7 @@ public:
public slots: public slots:
void messageFromAnotherInstanceReceived( QString const & ); void messageFromAnotherInstanceReceived( QString const & );
void showStatusBarMessage ( const QString & ); void showStatusBarMessage ( QString const &, int, QPixmap const & );
private: private:

View file

@ -14,16 +14,6 @@ ArticleView #searchText[noResults="true"]
background: #febb7d; background: #febb7d;
} }
.ScanPopup #outerFrame
{
border: 1px solid palette(dark);
}
.ScanPopup MainStatusBar #text
{
border: 1px solid palette(dark);
}
MainStatusBar #text MainStatusBar #text
{ {
border-top-right-radius: 3px; border-top-right-radius: 3px;
@ -41,3 +31,24 @@ MainStatusBar #icon
padding-left: 4px; padding-left: 4px;
padding-right: 0px; padding-right: 0px;
} }
.ScanPopup #outerFrame
{
border: 1px solid palette(dark);
}
.ScanPopup MainStatusBar #text
{
border-bottom: 1px solid palette(dark);
}
.ScanPopup MainStatusBar[hasImage="false"] #text
{
border-left: 1px solid palette(dark);
}
.ScanPopup MainStatusBar #icon
{
border-left: 1px solid palette(dark);
border-bottom: 1px solid palette(dark);
}

View file

@ -45,5 +45,6 @@
<file>icons/windows-list.png</file> <file>icons/windows-list.png</file>
<file>CREDITS.txt</file> <file>CREDITS.txt</file>
<file>icons/highlighter.png</file> <file>icons/highlighter.png</file>
<file>icons/error.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -126,8 +126,8 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( definition, SIGNAL( pageLoaded( ArticleView * ) ), connect( definition, SIGNAL( pageLoaded( ArticleView * ) ),
this, SLOT( pageLoaded( ArticleView * ) ) ); this, SLOT( pageLoaded( ArticleView * ) ) );
connect( definition, SIGNAL( statusBarMessage( const QString & ) ), connect( definition, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ),
this, SLOT( showStatusBarMessage( const QString & ) ) ); this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
connect( QApplication::clipboard(), SIGNAL( changed( QClipboard::Mode ) ), connect( QApplication::clipboard(), SIGNAL( changed( QClipboard::Mode ) ),
this, SLOT( clipboardChanged( QClipboard::Mode ) ) ); this, SLOT( clipboardChanged( QClipboard::Mode ) ) );
@ -705,9 +705,9 @@ void ScanPopup::pageLoaded( ArticleView * )
definition->playSound(); definition->playSound();
} }
void ScanPopup::showStatusBarMessage( const QString & message ) void ScanPopup::showStatusBarMessage( QString const & message, int timeout, QPixmap const & icon )
{ {
mainStatusBar->showMessage( message, 10000 ); mainStatusBar->showMessage( message, timeout, icon );
} }
void ScanPopup::escapePressed() void ScanPopup::escapePressed()

View file

@ -131,7 +131,7 @@ private slots:
void on_pronounceButton_clicked(); void on_pronounceButton_clicked();
void pinButtonClicked( bool checked ); void pinButtonClicked( bool checked );
void on_showDictionaryBar_clicked( bool checked ); void on_showDictionaryBar_clicked( bool checked );
void showStatusBarMessage ( const QString & ); void showStatusBarMessage ( QString const &, int, QPixmap const & );
void hideTimerExpired(); void hideTimerExpired();
void altModeExpired(); void altModeExpired();