mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
Merge pull request #920 from xiaoyifang/fix/status-2
fix: possible crash when show()
This commit is contained in:
commit
759246a86f
|
@ -26,7 +26,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
|
||||||
timer->setSingleShot( true );
|
timer->setSingleShot( true );
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
QHBoxLayout * layout = new QHBoxLayout;
|
const auto 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 );
|
||||||
|
@ -40,9 +40,6 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
|
||||||
connect( timer, &QTimer::timeout, this, &MainStatusBar::clearMessage );
|
connect( timer, &QTimer::timeout, this, &MainStatusBar::clearMessage );
|
||||||
|
|
||||||
setAutoFillBackground( true );
|
setAutoFillBackground( true );
|
||||||
|
|
||||||
if ( parent )
|
|
||||||
move( 0, parent->height() - height() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainStatusBar::clearMessage()
|
void MainStatusBar::clearMessage()
|
||||||
|
@ -51,7 +48,6 @@ void MainStatusBar::clearMessage()
|
||||||
textWidget->setText( backgroungMessage );
|
textWidget->setText( backgroungMessage );
|
||||||
picWidget->setPixmap( QPixmap() );
|
picWidget->setPixmap( QPixmap() );
|
||||||
timer->stop();
|
timer->stop();
|
||||||
hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainStatusBar::currentMessage() const
|
QString MainStatusBar::currentMessage() const
|
||||||
|
@ -65,8 +61,6 @@ void MainStatusBar::setBackgroundMessage(const QString & bkg_message )
|
||||||
if( message.isEmpty() )
|
if( message.isEmpty() )
|
||||||
{
|
{
|
||||||
textWidget->setText( backgroungMessage );
|
textWidget->setText( backgroungMessage );
|
||||||
raise();
|
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +79,10 @@ void MainStatusBar::showMessage( const QString & str, int timeout, const QPixmap
|
||||||
if ( timeout > 0 ) {
|
if ( timeout > 0 ) {
|
||||||
timer->start( timeout );
|
timer->start( timeout );
|
||||||
}
|
}
|
||||||
raise();
|
|
||||||
show();
|
if ( parentWidget() ) {
|
||||||
|
move( 0, parentWidget()->height() - height() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainStatusBar::mousePressEvent ( QMouseEvent * )
|
void MainStatusBar::mousePressEvent ( QMouseEvent * )
|
||||||
|
|
Loading…
Reference in a new issue