Issue #77 Convert CRgbColor to QPixmap directly

Converting via CIcon was disabled in order to break cyclic a dependency,
but in these cases a direct conversion had always been possible anyway.
This commit is contained in:
Mat Sutcliffe
2021-08-31 19:03:55 +01:00
parent 6b8eaf1ca2
commit a418add1f3
4 changed files with 18 additions and 11 deletions

View File

@@ -37,18 +37,21 @@ namespace BlackMisc
this->setQColor(color);
}
QPixmap CRgbColor::toPixmap() const
{
QPixmap pixmap(QSize(16, 16));
QPainter p(&pixmap);
p.setBackground(QBrush(this->toQColor()));
p.setBrush(this->toQColor());
p.drawRect(0, 0, 16, 16);
return pixmap;
}
CIcons::IconIndex CRgbColor::toIcon() const
{
//if (this->isValid())
//{
// QPixmap pixmap(QSize(16, 16));
// QPainter p(&pixmap);
// QBrush brush(this->toQColor());
// p.setBackground(brush);
// p.setBrush(this->toQColor());
// p.drawRect(0, 0, 16, 16);
// CIcon icon(pixmap, hex());
// return icon;
// return CIcon(toPixmap(), hex());
//}
//else
{

View File

@@ -17,6 +17,7 @@
#include "blackmisc/valueobject.h"
#include <QColor>
#include <QPixmap>
#include <QMetaType>
#include <QString>
#include <tuple>
@@ -108,6 +109,9 @@ namespace BlackMisc
//! Representing icon
CIcons::IconIndex toIcon() const;
//! Icon as pixmap
QPixmap toPixmap() const;
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;