Skip to content
Permalink
Browse files

[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 7ef9355111463da4ffb84004cb4569155af3ea3f
Showing with 17 additions and 8 deletions.
  1. +15 −6 src/gui/qgsstatusbar.cpp
  2. +2 −2 src/gui/qgsstatusbar.h
@@ -17,7 +17,8 @@

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

QgsStatusBar::QgsStatusBar( QWidget *parent )
@@ -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 );
}

@@ -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 )
@@ -78,5 +87,5 @@ void QgsStatusBar::showMessage( const QString &text, int timeout )

void QgsStatusBar::clearMessage()
{
mLabel->setText( QString() );
mLineEdit->setText( QString() );
}
@@ -23,7 +23,7 @@
#include <QWidget>

class QHBoxLayout;
class QLabel;
class QLineEdit;

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

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

};

0 comments on commit 7ef9355

Please sign in to comment.
You can’t perform that action at this time.