Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ui] fix status bar's message item resizing window on long string
(Fixes #17913)
  • Loading branch information
nirvn committed Jan 23, 2018
1 parent 8f1abf8 commit 7ef9355
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 15 additions & 6 deletions src/gui/qgsstatusbar.cpp
Expand Up @@ -17,7 +17,8 @@

#include "qgsstatusbar.h"
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPalette>
#include <QTimer>

QgsStatusBar::QgsStatusBar( QWidget *parent )
Expand All @@ -28,8 +29,15 @@ QgsStatusBar::QgsStatusBar( QWidget *parent )
mLayout->setContentsMargins( 2, 0, 2, 0 );
mLayout->setSpacing( 6 );

mLabel = new QLabel( QString() );
mLayout->addWidget( mLabel, 1 );
mLineEdit = new QLineEdit( QString() );
mLineEdit->setDisabled( true );
mLineEdit->setFrame( false );
mLineEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
QPalette palette;
palette.setColor( QPalette::Disabled, QPalette::Text, QPalette::WindowText );
mLineEdit->setPalette( palette );
mLineEdit->setStyleSheet( QStringLiteral( "* { background-color: rgba(0, 0, 0, 0); }" ) );
mLayout->addWidget( mLineEdit, 10 );
setLayout( mLayout );
}

Expand All @@ -54,12 +62,13 @@ void QgsStatusBar::removeWidget( QWidget *widget )

QString QgsStatusBar::currentMessage() const
{
return mLabel->text();
return mLineEdit->text();
}

void QgsStatusBar::showMessage( const QString &text, int timeout )
{
mLabel->setText( text );
mLineEdit->setText( text );
mLineEdit->setCursorPosition( 0 );
if ( timeout > 0 )
{
if ( !mTempMessageTimer )
Expand All @@ -78,5 +87,5 @@ void QgsStatusBar::showMessage( const QString &text, int timeout )

void QgsStatusBar::clearMessage()
{
mLabel->setText( QString() );
mLineEdit->setText( QString() );
}
4 changes: 2 additions & 2 deletions src/gui/qgsstatusbar.h
Expand Up @@ -23,7 +23,7 @@
#include <QWidget>

class QHBoxLayout;
class QLabel;
class QLineEdit;

/**
* \class QgsStatusBar
Expand Down Expand Up @@ -103,7 +103,7 @@ class GUI_EXPORT QgsStatusBar : public QWidget
private:

QHBoxLayout *mLayout = nullptr;
QLabel *mLabel = nullptr;
QLineEdit *mLineEdit = nullptr;
QTimer *mTempMessageTimer = nullptr;

};
Expand Down

0 comments on commit 7ef9355

Please sign in to comment.