Skip to content

Commit

Permalink
Check for Qt5 when using removed class QDesktopWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Jan 7, 2024
1 parent 870bcf0 commit d38ebf6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafFontTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
#include "cafPdmUiItem.h"

#include <QApplication>

#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
#include <QDesktopWidget>
#endif

#include <cmath>

Expand Down Expand Up @@ -92,13 +95,15 @@ int FontTools::absolutePointSize( FontSize normalPointSize, RelativeSize relativ
//--------------------------------------------------------------------------------------------------
int FontTools::pointSizeToPixelSize( int pointSize )
{
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pointSize / 72.0;
return static_cast<int>( std::ceil( inches * dpi ) );
}
#endif
return pointSize;
}

Expand All @@ -115,13 +120,15 @@ int FontTools::pointSizeToPixelSize( FontSize pointSize )
//--------------------------------------------------------------------------------------------------
int FontTools::pixelSizeToPointSize( int pixelSize )
{
#if ( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
auto app = dynamic_cast<const QApplication*>( QCoreApplication::instance() );
if ( app )
{
int dpi = app->desktop()->logicalDpiX();
double inches = pixelSize / dpi;
return static_cast<int>( std::ceil( inches * 72.0 ) );
}
#endif
return pixelSize;
}

Expand Down

0 comments on commit d38ebf6

Please sign in to comment.