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