Commit 5c30e20f authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #243] title text now visible unscaled as long as possible

parent 41f0f1e7
......@@ -32,7 +32,6 @@
#include <QtGui/QToolButton>
#include <QtGui/QToolBar>
#include "guiElements/WScaleLabel.h"
#include "WQt4Gui.h"
#include "WMainWindow.h"
......@@ -235,7 +234,7 @@ WQtGLDockWidgetTitle::WQtGLDockWidgetTitle( WQtGLDockWidget* parent, const QStri
void WQtGLDockWidgetTitle::resizeEvent( QResizeEvent* event )
{
int required = m_title->minimumSizeHint().width() + m_tools->sizeHint().width() + m_closeBtn->sizeHint().width();
int required = m_title->calculateSize( m_title->text().length() ) + m_tools->sizeHint().width() + m_closeBtn->sizeHint().width();
if( event->size().width() < required )
{
m_tools->setHidden( true );
......
......@@ -35,6 +35,8 @@
#include "core/graphicsEngine/WGECamera.h"
#include "guiElements/WScaleLabel.h"
#include "WQtGLWidget.h"
/**
......@@ -198,7 +200,7 @@ private:
/**
* Title label
*/
QLabel* m_title;
WScaleLabel* m_title;
/**
* Close button
......
......@@ -76,14 +76,17 @@ void WScaleLabel::resizeEvent( QResizeEvent* /*event*/ )
QSize WScaleLabel::sizeHint() const
{
return QSize( fontMetrics().width( m_orgText ) + 2 * margin() + m_additionalWidth,
QLabel::sizeHint().height() );
return QSize( calculateSize( m_orgText.length() ), QLabel::sizeHint().height() );
}
QSize WScaleLabel::minimumSizeHint() const
{
return QSize( fontMetrics().width( m_orgText.left( m_minLength ) + tr( ".." ) ) + 2 * margin() + m_additionalWidth,
QLabel::minimumSizeHint().height() );
return QSize( calculateSize( m_minLength ),QLabel::minimumSizeHint().height() );
}
size_t WScaleLabel::calculateSize( size_t chars ) const
{
return fontMetrics().width( m_orgText.left( chars ) + tr( ".." ) ) + 2 * margin() + m_additionalWidth;
}
void WScaleLabel::setText( const QString &text )
......
......@@ -111,6 +111,15 @@ public:
* \return the number of chars visible all the time
*/
virtual size_t getMinimalLength() const;
/**
* Calculate the size that is needed for the given number of chars.
*
* \param chars number of chars
*
* \return the size in pixels
*/
virtual size_t calculateSize( size_t chars ) const;
protected:
/**
* custom implementation of the resize event
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment