mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +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:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user