mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
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:
@@ -72,7 +72,7 @@ namespace BlackGui
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->le_Color->setText(color.hex());
|
ui->le_Color->setText(color.hex());
|
||||||
ui->lbl_ColorIcon->setPixmap(CIcon(color.toIcon()));
|
ui->lbl_ColorIcon->setPixmap(color.toPixmap());
|
||||||
m_lastColor = color;
|
m_lastColor = color;
|
||||||
}
|
}
|
||||||
emit colorChanged(color);
|
emit colorChanged(color);
|
||||||
@@ -176,7 +176,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
mimeData->setColorData(QVariant::fromValue(c.toQColor()));
|
mimeData->setColorData(QVariant::fromValue(c.toQColor()));
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
drag->setPixmap(CIcon(c.toIcon()));
|
drag->setPixmap(c.toPixmap());
|
||||||
|
|
||||||
Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
|
Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
|
||||||
Q_UNUSED(dropAction);
|
Q_UNUSED(dropAction);
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
const CRgbColor rgbColor(dataCVariant.to<CRgbColor>());
|
const CRgbColor rgbColor(dataCVariant.to<CRgbColor>());
|
||||||
if (!rgbColor.isValid()) { return emptyPixmapVariant(); }
|
if (!rgbColor.isValid()) { return emptyPixmapVariant(); }
|
||||||
return CVariant::fromValue(CIcon(rgbColor.toIcon()).toPixmap());
|
return CVariant::fromValue(rgbColor.toPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
CVariant CColorFormatter::tooltipRole(const CVariant &dataCVariant) const
|
CVariant CColorFormatter::tooltipRole(const CVariant &dataCVariant) const
|
||||||
|
|||||||
@@ -37,18 +37,21 @@ namespace BlackMisc
|
|||||||
this->setQColor(color);
|
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
|
CIcons::IconIndex CRgbColor::toIcon() const
|
||||||
{
|
{
|
||||||
//if (this->isValid())
|
//if (this->isValid())
|
||||||
//{
|
//{
|
||||||
// QPixmap pixmap(QSize(16, 16));
|
// return CIcon(toPixmap(), hex());
|
||||||
// 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;
|
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QPixmap>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -108,6 +109,9 @@ namespace BlackMisc
|
|||||||
//! Representing icon
|
//! Representing icon
|
||||||
CIcons::IconIndex toIcon() const;
|
CIcons::IconIndex toIcon() const;
|
||||||
|
|
||||||
|
//! Icon as pixmap
|
||||||
|
QPixmap toPixmap() const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user