mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Avoid include of QSize
This commit is contained in:
parent
4aacb31566
commit
84ee29cdc9
@ -46,14 +46,50 @@ using namespace caf;
|
|||||||
class caf::IconProvider::Impl
|
class caf::IconProvider::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool m_active;
|
Impl()
|
||||||
QString m_iconResourceString;
|
: m_active( false )
|
||||||
QString m_overlayResourceString;
|
, m_preferredSize( QSize( 16, 16 ) )
|
||||||
std::vector<QString> m_backgroundColorStrings;
|
{
|
||||||
QSize m_preferredSize;
|
}
|
||||||
QPixmap m_pixmap;
|
Impl( const Impl& rhs )
|
||||||
|
{
|
||||||
|
m_active = rhs.m_active;
|
||||||
|
m_iconResourceString = rhs.m_iconResourceString;
|
||||||
|
m_overlayResourceString = rhs.m_overlayResourceString;
|
||||||
|
m_backgroundColorStrings = rhs.m_backgroundColorStrings;
|
||||||
|
m_preferredSize = rhs.m_preferredSize;
|
||||||
|
if ( rhs.m_pixmap )
|
||||||
|
{
|
||||||
|
m_pixmap = std::make_unique<QPixmap>( *rhs.m_pixmap );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_active;
|
||||||
|
QString m_iconResourceString;
|
||||||
|
QString m_overlayResourceString;
|
||||||
|
std::vector<QString> m_backgroundColorStrings;
|
||||||
|
QSize m_preferredSize;
|
||||||
|
std::unique_ptr<QPixmap> m_pixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
IconProvider::IconProvider()
|
||||||
|
: m_impl( new Impl )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
IconProvider::IconProvider( const QString& iconResourceString )
|
||||||
|
: m_impl( new Impl )
|
||||||
|
{
|
||||||
|
m_impl->m_active = true;
|
||||||
|
m_impl->m_iconResourceString = iconResourceString;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -82,7 +118,7 @@ caf::IconProvider::IconProvider( const QPixmap& pixmap )
|
|||||||
: m_impl( new Impl )
|
: m_impl( new Impl )
|
||||||
{
|
{
|
||||||
m_impl->m_active = true;
|
m_impl->m_active = true;
|
||||||
m_impl->m_pixmap = pixmap;
|
m_impl->m_pixmap = std::make_unique<QPixmap>( pixmap );
|
||||||
m_impl->m_preferredSize = pixmap.size();
|
m_impl->m_preferredSize = pixmap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +138,8 @@ IconProvider::IconProvider( const IconProvider& rhs )
|
|||||||
m_impl = std::make_unique<Impl>( *rhs.m_impl );
|
m_impl = std::make_unique<Impl>( *rhs.m_impl );
|
||||||
else
|
else
|
||||||
m_impl = std::make_unique<Impl>();
|
m_impl = std::make_unique<Impl>();
|
||||||
|
|
||||||
|
copyPixmap( rhs );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -109,7 +147,12 @@ IconProvider::IconProvider( const IconProvider& rhs )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
IconProvider& IconProvider::operator=( const IconProvider& rhs )
|
IconProvider& IconProvider::operator=( const IconProvider& rhs )
|
||||||
{
|
{
|
||||||
*m_impl = *rhs.m_impl;
|
m_impl->m_active = rhs.m_impl->m_active;
|
||||||
|
m_impl->m_iconResourceString = rhs.m_impl->m_iconResourceString;
|
||||||
|
m_impl->m_overlayResourceString = rhs.m_impl->m_overlayResourceString;
|
||||||
|
m_impl->m_backgroundColorStrings = rhs.m_impl->m_backgroundColorStrings;
|
||||||
|
m_impl->m_preferredSize = rhs.m_impl->m_preferredSize;
|
||||||
|
copyPixmap( rhs );
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -129,7 +172,7 @@ bool caf::IconProvider::valid() const
|
|||||||
{
|
{
|
||||||
if ( isGuiApplication() )
|
if ( isGuiApplication() )
|
||||||
{
|
{
|
||||||
if ( !m_impl->m_pixmap.isNull() ) return true;
|
if ( m_impl->m_pixmap && !m_impl->m_pixmap->isNull() ) return true;
|
||||||
|
|
||||||
if ( backgroundColorsAreValid() )
|
if ( backgroundColorsAreValid() )
|
||||||
{
|
{
|
||||||
@ -170,7 +213,7 @@ std::unique_ptr<QIcon> IconProvider::icon( const QSize& size ) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_impl->m_pixmap.isNull() ) return std::unique_ptr<QIcon>( new QIcon( m_impl->m_pixmap ) );
|
if ( m_impl->m_pixmap ) return std::unique_ptr<QIcon>( new QIcon( *m_impl->m_pixmap ) );
|
||||||
|
|
||||||
QPixmap pixmap( size );
|
QPixmap pixmap( size );
|
||||||
|
|
||||||
@ -287,7 +330,7 @@ void IconProvider::setBackgroundColorGradient( const std::vector<QString>& color
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void caf::IconProvider::setPixmap( const QPixmap& pixmap )
|
void caf::IconProvider::setPixmap( const QPixmap& pixmap )
|
||||||
{
|
{
|
||||||
m_impl->m_pixmap = pixmap;
|
m_impl->m_pixmap.reset( new QPixmap( pixmap ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -298,6 +341,17 @@ bool caf::IconProvider::isGuiApplication()
|
|||||||
return dynamic_cast<QApplication*>( QCoreApplication::instance() ) != nullptr;
|
return dynamic_cast<QApplication*>( QCoreApplication::instance() ) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void IconProvider::copyPixmap( const IconProvider& rhs )
|
||||||
|
{
|
||||||
|
if ( rhs.m_impl->m_pixmap )
|
||||||
|
{
|
||||||
|
m_impl->m_pixmap = std::unique_ptr<QPixmap>( new QPixmap( *rhs.m_impl->m_pixmap ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -35,13 +35,13 @@
|
|||||||
//##################################################################################################
|
//##################################################################################################
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QSize>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class QIcon;
|
class QIcon;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QString;
|
class QString;
|
||||||
|
class QSize;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -52,8 +52,10 @@ namespace caf
|
|||||||
class IconProvider
|
class IconProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IconProvider( const QSize& preferredSize = QSize( 16, 16 ) );
|
IconProvider();
|
||||||
IconProvider( const QString& iconResourceString, const QSize& preferredSize = QSize( 16, 16 ) );
|
IconProvider( const QSize& preferredSize );
|
||||||
|
IconProvider( const QString& iconResourceString );
|
||||||
|
IconProvider( const QString& iconResourceString, const QSize& preferredSize );
|
||||||
IconProvider( const QPixmap& pixmap );
|
IconProvider( const QPixmap& pixmap );
|
||||||
IconProvider( const IconProvider& rhs );
|
IconProvider( const IconProvider& rhs );
|
||||||
IconProvider& operator=( const IconProvider& rhs );
|
IconProvider& operator=( const IconProvider& rhs );
|
||||||
@ -75,6 +77,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static bool isGuiApplication();
|
static bool isGuiApplication();
|
||||||
|
void copyPixmap( const IconProvider& rhs );
|
||||||
|
|
||||||
bool backgroundColorsAreValid() const;
|
bool backgroundColorsAreValid() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user