Commit 6d1f8c89 authored by Frédéric Larue's avatar Frédéric Larue

Management of some deprecated functions for Qt's version older than 5.11.

parent 9d072589
......@@ -1098,7 +1098,11 @@ void GLViewer::displayLabel( DisplayableInterface *d )
if( fm.height() < bottomLeft.y()-topRight.y()-4 )
{
imgName = d->label();
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
imgNameWidth = fm.width( imgName );
#else
imgNameWidth = fm.horizontalAdvance( imgName );
#endif
if( imgNameWidth > topRight.x()-bottomLeft.x()-8 )
{
......@@ -1106,7 +1110,11 @@ void GLViewer::displayLabel( DisplayableInterface *d )
do
{
-- imgNameLength;
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
imgNameWidth -= fm.width( imgName.at(imgNameLength) );
#else
imgNameWidth -= fm.horizontalAdvance( imgName.at(imgNameLength) );
#endif
} while( imgNameWidth > topRight.x()-bottomLeft.x()-8 );
imgName = imgName.left( imgNameLength );
}
......@@ -1440,9 +1448,17 @@ void GLViewer::renderText( double x, double y, const QString &text, const QFont
for( auto &l : textLines )
{
if( align & Qt::AlignRight )
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
painter.drawText( x - fm.width(l), y, l );
#else
painter.drawText( x - fm.horizontalAdvance(l), y, l );
#endif
else if( align & Qt::AlignHCenter )
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
painter.drawText( x - fm.width(l)/2, y, l );
#else
painter.drawText( x - fm.horizontalAdvance(l)/2, y, l );
#endif
else
painter.drawText( x, y, l );
y += fm.lineSpacing();
......
......@@ -32,7 +32,11 @@ ThemeSettingsDialog::ThemeSettingsDialog( QWidget *parent ) : QDialog( parent )
groupName[0] = groupName[0].toUpper();
matrixLayout->addWidget( new QLabel(groupName), 0, i+1, Qt::AlignHCenter );
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int w = QApplication::fontMetrics().width( groupName ) + 10;
#else
int w = QApplication::fontMetrics().horizontalAdvance( groupName ) + 10;
#endif
if( w > buttonWidth )
buttonWidth = w;
}
......
......@@ -501,7 +501,7 @@ void UIMainWindow::newProject()
void UIMainWindow::openProject()
{
QString fileName = QFileDialog::getOpenFileName( this, tr("Loading an existing project"), "", tr("Project Files (*.")+projectFileExtension()+")" );
if( fileName == QString::null )
if( fileName.isNull() )
return;
loadProject(fileName);
......@@ -570,7 +570,7 @@ void UIMainWindow::updateCurrentProjectContent()
for( auto d : data )
{
QString typeName = d->GetTypeString();
if( !d->HasParent() && typeFilter == QString::null || typeName == typeFilter )
if( !d->HasParent() && typeFilter.isNull() || typeName == typeFilter )
treeView->addTopLevelItem( buildItemTree(d,m_CurrentViewer) );
}
......@@ -605,7 +605,7 @@ void UIMainWindow::updateTypeFilters()
for( auto d=data.begin(); d!=data.end(); ++d )
foundTypeNames.insert( (*d)->GetTypeString() );
ui->comboTypeFilter->addItem( QString::null );
ui->comboTypeFilter->addItem( QString() );
for( auto name=foundTypeNames.begin(); name!=foundTypeNames.end(); ++name )
ui->comboTypeFilter->addItem( *name );
......@@ -1194,7 +1194,7 @@ void UIMainWindow::saveCurrentProject()
tr("Project Files (*.") + projectFileExtension() + ")"
);
if( file != QString::null )
if( !file.isNull() )
{
QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
bool saveOk = project->Save( file );
......
......@@ -288,7 +288,11 @@ void GenericNodeView::recomputeWidgetRectangle()
// Specify the node width accordingly.
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int nameWidth = fm.width( m_Node->name() );
#else
int nameWidth = fm.horizontalAdvance( m_Node->name() );
#endif
m_Width = std::max( nameWidth+20, maxInputWidth+maxOutputWidth ) + 1;
// Compute the x coordinate where the node name is horizontally centered.
......
......@@ -60,7 +60,11 @@ inline UIParamFunction::UIParamFunction( const QString& id,
for( int i=0; i<BUTTON_COUNT; ++i )
{
buttons[i] = new QPushButton( buttonLabels[i] );
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int w = QFontMetrics(m_Widget->font()).width(buttons[i]->text()) + 8;
#else
int w = QFontMetrics(m_Widget->font()).horizontalAdvance(buttons[i]->text()) + 8;
#endif
buttons[i]->setMinimumWidth( w );
buttons[i]->setMaximumWidth( w );
l->addWidget( buttons[i], 1,i );
......
......@@ -23,7 +23,11 @@ FunctionGraphWidget::FunctionGraphWidget( const QString& label, QWidget *parent
for( int i=0; i<PREDEFINED_FUNC_COUNT; ++i )
m_FunctionParam[i].set( 0.0f, 0.5f, RADIUS_DEFAULT_VALUE[i], 1.0f );
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int minWidth = 8 + QFontMetrics(font()).width( m_Label );
#else
int minWidth = 8 + QFontMetrics(font()).horizontalAdvance( m_Label );
#endif
setMinimumSize( std::max(200,minWidth), 100 );
}
......@@ -102,7 +106,11 @@ void FunctionGraphWidget::paintEvent( QPaintEvent *evt )
painter.drawLine( width()-7, height()-2, width()-7, height()-4 );
QFontMetrics fm( font() );
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int labelW = fm.width( m_Label );
#else
int labelW = fm.horizontalAdvance( m_Label );
#endif
painter.setPen( QPen(QBrush(color),1.0f) );
painter.drawText( (width()-labelW)>>1, 2+fm.height(), m_Label );
......
......@@ -128,7 +128,11 @@ void GradientWidget::paintEvent( QPaintEvent *evt )
QString text = m_KeyboardInputValue.isEmpty()? QString::number(m_Stops[m_SelectedStop].value()) : m_KeyboardInputValue;
QFontMetrics fm( font() );
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
int textW = fm.width( text );
#else
int textW = fm.horizontalAdvance( text );
#endif
int textX = m_Stops[m_SelectedStop].x() + 4;
int textY = ((h+fm.height()) >> 1) - fm.descent();
......
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