10#include <QDragEnterEvent>
11#include <QDragLeaveEvent>
12#include <QDragMoveEvent>
25#include "ui_colorselector.h"
48 completer->setMaxVisibleItems(10);
50 ui->le_Color->setCompleter(completer);
58 if (color == m_lastColor)
69 ui->le_Color->setText(color.
hex());
70 ui->lbl_ColorIcon->setPixmap(color.
toPixmap());
86 ui->le_Color->setReadOnly(readOnly);
87 ui->tb_ColorDialog->setVisible(!readOnly);
93 ui->le_Color->clear();
94 ui->lbl_ColorIcon->setPixmap(
QPixmap());
104 event->acceptProposedAction();
113 event->acceptProposedAction();
124 const QMimeData *mime =
event->mimeData();
132 const auto color = qvariant_cast<QColor>(
event->mimeData()->colorData());
133 if (!color.isValid())
156 if (!qColor.isValid())
196 auto *drag =
new QDrag(
this);
200 drag->setMimeData(mimeData);
204 Q_UNUSED(dropAction);
207 void CColorSelector::colorDialog()
222 void CColorSelector::onReturnPressed()
231 void CColorSelector::setColorByName(
const QString &colorName)
237 const CRgbColor c(colorName,
true);
244 void CColorSelector::resetToLastValidColor()
246 if (!m_lastColor.isValid())
static swift::misc::CVariant fromSwiftDragAndDropData(const QMimeData *mime)
From text dropped.
static bool hasSwiftVariantMimeType(const QMimeData *mime)
Mime data with swift type.
void setReadOnly(bool readOnly)
Read only.
void colorChanged(const swift::misc::CRgbColor &color)
Color has been changed.
void mousePressEvent(QMouseEvent *event)
For dragging the color.
~CColorSelector()
Destructor.
void dropEvent(QDropEvent *event)
void dragEnterEvent(QDragEnterEvent *event)
void dragLeaveEvent(QDragLeaveEvent *event)
swift::misc::CRgbColor getColor() const
Selected color.
CColorSelector(QWidget *parent=nullptr)
Constructor.
void dragMoveEvent(QDragMoveEvent *event)
void setColor(const swift::misc::CRgbColor &color)
Color.
static const QPixmap & color16()
Color.
QString hex(bool withHash=false) const
Hex value.
QPixmap toPixmap() const
Icon as pixmap.
QColor toQColor() const
To QColor.
bool isValid() const
Valid?
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
T value() const
Return the value converted to the type T.
bool isValid() const
True if this variant is valid.
bool canConvert(int typeId) const
True if this variant can be converted to the type with the given metatype ID.
High level reusable GUI components.
Free functions in swift::misc.
bool isValid() const const
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options)
void activated(const QModelIndex &index)
QFrame(QWidget *parent, Qt::WindowFlags f)
virtual bool event(QEvent *e) override
bool hasColor() const const
bool hasText() const const
void setColorData(const QVariant &color)
QString text() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QVariant fromValue(T &&value)