19#include "moc_qgsstatusbar.cpp"
30 mLayout =
new QHBoxLayout();
31 mLayout->setContentsMargins( 2, 0, 2, 0 );
32 mLayout->setSpacing( 6 );
34 mLineEdit =
new QLineEdit( QString() );
35 mLineEdit->setDisabled(
true );
36 mLineEdit->setFrame(
false );
37 mLineEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
38 QPalette
pal = mLineEdit->palette();
39 pal.setColor( QPalette::Disabled, QPalette::Text, palette().color( QPalette::WindowText ) );
40 mLineEdit->setPalette(
pal );
41 mLineEdit->setStyleSheet( QStringLiteral(
"* { border: 0; background-color: rgba(0, 0, 0, 0); color: %1; }" ).arg( palette().color( QPalette::WindowText ).name() ) );
42 mLayout->addWidget( mLineEdit, 10 );
51 mLayout->insertWidget( 0, widget, stretch, Qt::AlignLeft );
55 mLayout->addWidget( widget, stretch, Qt::AlignLeft );
62 mLayout->removeWidget( widget );
68 return mLineEdit->text();
73 mLineEdit->setText( text );
74 mLineEdit->setCursorPosition( 0 );
77 if ( !mTempMessageTimer )
79 mTempMessageTimer =
new QTimer(
this );
81 mTempMessageTimer->setSingleShot(
true );
83 mTempMessageTimer->start( timeout );
85 else if ( mTempMessageTimer )
87 delete mTempMessageTimer;
88 mTempMessageTimer =
nullptr;
94 mLineEdit->setText( QString() );
99 if ( mParentStatusBar )
100 QStatusBar::disconnect( mShowMessageConnection );
102 mParentStatusBar = statusBar;
104 if ( mParentStatusBar )
105 mShowMessageConnection = connect( mParentStatusBar, &QStatusBar::messageChanged,
this, [
this](
const QString &message ) {
showMessage( message ); } );
110 QWidget::changeEvent( event );
112 if ( event->type() == QEvent::FontChange )
114 mLineEdit->setFont( font() );
Anchor
Placement anchor for widgets.
@ AnchorLeft
Anchor widget to left of status bar.
@ AnchorRight
Anchor widget to right of status bar.
void clearMessage()
Removes any temporary message being shown.
void removeWidget(QWidget *widget)
Removes a widget from the status bar.
QgsStatusBar(QWidget *parent=nullptr)
Constructor for QgsStatusBar.
void changeEvent(QEvent *event) override
void addPermanentWidget(QWidget *widget, int stretch=0, Anchor anchor=AnchorRight)
Adds the given widget permanently to this status bar, reparenting the widget if it isn't already a ch...
QString currentMessage() const
Returns the current message shown in the status bar.
void setParentStatusBar(QStatusBar *statusBar)
Sets the parent status bar.
void showMessage(const QString &message, int timeout=0)
Displays the given message for the specified number of milli-seconds (timeout).