mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
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:
parent
39d8772153
commit
4163bce8a2
|
@ -1225,7 +1225,8 @@ void ArticleView::resourceDownloadFinished()
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -1247,8 +1248,9 @@ void ArticleView::resourceDownloadFinished()
|
|||
|
||||
if ( resourceDownloadRequests.empty() )
|
||||
{
|
||||
// No requests suceeded.
|
||||
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "The referenced resource failed to download." ) );
|
||||
emit statusBarMessage(
|
||||
tr( "WARNING: %1" ).arg( tr( "The referenced resource failed to download." ) ),
|
||||
10000, QPixmap( ":/icons/error.png" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ signals:
|
|||
/// switch focus to word input.
|
||||
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,
|
||||
/// typically in response to user actions
|
||||
|
|
BIN
icons/error.png
Normal file
BIN
icons/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 791 B |
|
@ -10,41 +10,46 @@
|
|||
#include <QEvent>
|
||||
#include <QApplication>
|
||||
|
||||
MainStatusBar::MainStatusBar(QWidget *parent) : QWidget(parent)
|
||||
MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
|
||||
{
|
||||
textWidget = new QLabel(QString(), this);
|
||||
textWidget->setObjectName("text");
|
||||
textWidget->setFont(QApplication::font("QStatusBar"));
|
||||
textWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
textWidget = new QLabel( QString(), this );
|
||||
textWidget->setObjectName( "text" );
|
||||
textWidget->setFont( QApplication::font( "QStatusBar" ) );
|
||||
textWidget->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
picWidget = new QLabel(QString(), this);
|
||||
picWidget->setObjectName("icon");
|
||||
picWidget->setPixmap(QPixmap());
|
||||
picWidget->setScaledContents(true);
|
||||
picWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
picWidget = new QLabel( QString(), this );
|
||||
picWidget->setObjectName( "icon" );
|
||||
picWidget->setPixmap( QPixmap() );
|
||||
picWidget->setScaledContents( true );
|
||||
picWidget->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Ignored );
|
||||
|
||||
timer = new QTimer(this);
|
||||
timer->setSingleShot(true);
|
||||
timer = new QTimer( this );
|
||||
timer->setSingleShot( true );
|
||||
|
||||
// layout
|
||||
QHBoxLayout * layout = new QHBoxLayout;
|
||||
layout->setSpacing(0);
|
||||
layout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
layout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(picWidget);
|
||||
layout->addWidget(textWidget);
|
||||
setLayout(layout);
|
||||
layout->setSpacing( 0 );
|
||||
layout->setSizeConstraint( QLayout::SetFixedSize );
|
||||
layout->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
layout->addWidget( picWidget );
|
||||
layout->addWidget( textWidget );
|
||||
setLayout( layout );
|
||||
|
||||
parentWidget()->installEventFilter( this );
|
||||
|
||||
connect( timer, SIGNAL( timeout() ), SLOT( clearMessage() ) );
|
||||
}
|
||||
|
||||
bool MainStatusBar::hasImage() const
|
||||
{
|
||||
return !picWidget->pixmap()->isNull();
|
||||
}
|
||||
|
||||
void MainStatusBar::clearMessage()
|
||||
{
|
||||
textWidget->setText(QString());
|
||||
picWidget->setPixmap(QPixmap());
|
||||
textWidget->setText( QString() );
|
||||
picWidget->setPixmap( QPixmap() );
|
||||
timer->stop();
|
||||
refresh();
|
||||
}
|
||||
|
@ -59,6 +64,9 @@ void MainStatusBar::showMessage(const QString & str, int timeout, const QPixmap
|
|||
textWidget->setText( str );
|
||||
picWidget->setPixmap( pixmap );
|
||||
|
||||
// reload stylesheet
|
||||
setStyleSheet( styleSheet() );
|
||||
|
||||
if ( timeout > 0 )
|
||||
{
|
||||
timer->start( timeout );
|
||||
|
@ -71,13 +79,15 @@ void MainStatusBar::refresh()
|
|||
{
|
||||
if ( !currentMessage().isEmpty() )
|
||||
{
|
||||
adjustSize();
|
||||
|
||||
if ( !picWidget->pixmap()->isNull() )
|
||||
{
|
||||
picWidget->setFixedSize( textWidget->height(), textWidget->height() );
|
||||
}
|
||||
else
|
||||
{
|
||||
picWidget->setFixedSize( 0, 0);
|
||||
picWidget->setFixedSize( 0, 0 );
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
|
@ -98,7 +108,7 @@ void MainStatusBar::mousePressEvent ( QMouseEvent * )
|
|||
clearMessage();
|
||||
}
|
||||
|
||||
bool MainStatusBar::eventFilter(QObject *, QEvent * e)
|
||||
bool MainStatusBar::eventFilter( QObject *, QEvent * e )
|
||||
{
|
||||
switch ( e->type() ) {
|
||||
case QEvent::Resize:
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
class MainStatusBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool hasImage READ hasImage)
|
||||
|
||||
public:
|
||||
explicit MainStatusBar(QWidget * parent);
|
||||
|
@ -36,6 +37,7 @@ private:
|
|||
QTimer * timer;
|
||||
bool eventFilter(QObject *obj, QEvent * event);
|
||||
void refresh();
|
||||
bool hasImage() const;
|
||||
};
|
||||
|
||||
#endif // MAINSTATUSBAR_HH
|
||||
|
|
|
@ -918,8 +918,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
|
|||
connect( view, SIGNAL( activeArticleChanged( const QString & ) ),
|
||||
this, SLOT( activeArticleChanged( const QString & ) ) );
|
||||
|
||||
connect( view, SIGNAL( statusBarMessage( const QString & ) ),
|
||||
this, SLOT( showStatusBarMessage( const QString & ) ) );
|
||||
connect( view, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ),
|
||||
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
|
||||
|
||||
int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
|
||||
ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count();
|
||||
|
@ -1056,9 +1056,9 @@ void MainWindow::pageLoaded( ArticleView * view )
|
|||
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 )
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
public slots:
|
||||
|
||||
void messageFromAnotherInstanceReceived( QString const & );
|
||||
void showStatusBarMessage ( const QString & );
|
||||
void showStatusBarMessage ( QString const &, int, QPixmap const & );
|
||||
|
||||
private:
|
||||
|
||||
|
|
31
qt-style.css
31
qt-style.css
|
@ -14,16 +14,6 @@ ArticleView #searchText[noResults="true"]
|
|||
background: #febb7d;
|
||||
}
|
||||
|
||||
.ScanPopup #outerFrame
|
||||
{
|
||||
border: 1px solid palette(dark);
|
||||
}
|
||||
|
||||
.ScanPopup MainStatusBar #text
|
||||
{
|
||||
border: 1px solid palette(dark);
|
||||
}
|
||||
|
||||
MainStatusBar #text
|
||||
{
|
||||
border-top-right-radius: 3px;
|
||||
|
@ -41,3 +31,24 @@ MainStatusBar #icon
|
|||
padding-left: 4px;
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -45,5 +45,6 @@
|
|||
<file>icons/windows-list.png</file>
|
||||
<file>CREDITS.txt</file>
|
||||
<file>icons/highlighter.png</file>
|
||||
<file>icons/error.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -126,8 +126,8 @@ ScanPopup::ScanPopup( QWidget * parent,
|
|||
connect( definition, SIGNAL( pageLoaded( ArticleView * ) ),
|
||||
this, SLOT( pageLoaded( ArticleView * ) ) );
|
||||
|
||||
connect( definition, SIGNAL( statusBarMessage( const QString & ) ),
|
||||
this, SLOT( showStatusBarMessage( const QString & ) ) );
|
||||
connect( definition, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ),
|
||||
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
|
||||
|
||||
connect( QApplication::clipboard(), SIGNAL( changed( QClipboard::Mode ) ),
|
||||
this, SLOT( clipboardChanged( QClipboard::Mode ) ) );
|
||||
|
@ -705,9 +705,9 @@ void ScanPopup::pageLoaded( ArticleView * )
|
|||
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()
|
||||
|
|
|
@ -131,7 +131,7 @@ private slots:
|
|||
void on_pronounceButton_clicked();
|
||||
void pinButtonClicked( bool checked );
|
||||
void on_showDictionaryBar_clicked( bool checked );
|
||||
void showStatusBarMessage ( const QString & );
|
||||
void showStatusBarMessage ( QString const &, int, QPixmap const & );
|
||||
|
||||
void hideTimerExpired();
|
||||
void altModeExpired();
|
||||
|
|
Loading…
Reference in a new issue