22#include "cursoredit.h"
24#include "KPropertyCoreUtils_p.h"
25#include "KPropertyListData.h"
26#include "KPropertyUtils_p.h"
28#include "xpm/blank_cursor.xpm"
29#include "xpm/arrow_cursor.xpm"
30#include "xpm/bdiag_cursor.xpm"
31#include "xpm/busy_cursor.xpm"
32#include "xpm/closedhand_cursor.xpm"
33#include "xpm/cross_cursor.xpm"
34#include "xpm/fdiag_cursor.xpm"
35#include "xpm/forbidden_cursor.xpm"
36#include "xpm/hand_cursor.xpm"
37#include "xpm/ibeam_cursor.xpm"
38#include "xpm/openhand_cursor.xpm"
39#include "xpm/sizeall_cursor.xpm"
40#include "xpm/sizehor_cursor.xpm"
41#include "xpm/sizever_cursor.xpm"
42#include "xpm/splith_cursor.xpm"
43#include "xpm/splitv_cursor.xpm"
44#include "xpm/uparrow_cursor.xpm"
45#include "xpm/wait_cursor.xpm"
46#include "xpm/whatsthis_cursor.xpm"
68 if (shape.toInt() == _shape)
75 QPixmap pixmapForIndex(
int index,
const QPalette& pal,
bool transparentBackground =
false)
const
77 if (index < 0 || index > 18)
80 if (transparentBackground)
87 p.drawPixmap(0, 2, xpm);
118 strings <<
QObject::tr(
"No cursor",
"Mouse Cursor Shape")
123 <<
QObject::tr(
"Text cursor",
"Mouse Cursor Shape")
124 <<
QObject::tr(
"Size vertical",
"Mouse Cursor Shape")
125 <<
QObject::tr(
"Size horizontal",
"Mouse Cursor Shape")
127 <<
QObject::tr(
"Size backslash",
"Mouse Cursor Shape")
129 <<
QObject::tr(
"Split vertical",
"Mouse Cursor Shape")
130 <<
QObject::tr(
"Split horizontal",
"Mouse Cursor Shape")
131 <<
QObject::tr(
"Pointing hand",
"Mouse Cursor Shape")
133 <<
QObject::tr(
"What's this?",
"Mouse Cursor Shape")
136 <<
QObject::tr(
"Closed hand",
"Mouse Cursor Shape");
139 static const char *
const *
const m_xpms[];
142const char *
const *
const CursorListData::m_xpms[] =
158 forbidden_cursor_xpm,
159 whatsthis_cursor_xpm,
162 closedhand_cursor_xpm
165Q_GLOBAL_STATIC(CursorListData, s_cursorListData)
169class CursorIconProvider :
public KPropertyComboBoxEditorIconProviderInterface
172 explicit CursorIconProvider(
QWidget* parent) : m_parent(parent) {}
173 QIcon icon(
int index)
const override
175 return s_cursorListData->pixmapForIndex(index, m_parent->
palette());
177 KPropertyComboBoxEditorIconProviderInterface *clone()
const override
179 return new CursorIconProvider(m_parent);
186static KPropertyComboBoxEditorOptions initComboBoxOptions(
QWidget* parent)
188 KPropertyComboBoxEditorOptions options;
189 options.iconProvider =
new CursorIconProvider(parent);
193class Q_DECL_HIDDEN KPropertyCursorEditor::Private
201KPropertyCursorEditor::KPropertyCursorEditor(
QWidget *parent)
202 : KPropertyComboBoxEditor(*s_cursorListData, initComboBoxOptions( this ), parent),
208 if (!KPropertyUtilsPrivate::gridLineColor(
this).
isValid()) {
217 padding-top: %2px; padding-left: %3px; }").
arg(KPropertyComboBoxEditor::borderSheet(
this))
218 .
arg(paddingTop).
arg(paddingLeft);
219 setStyleSheet(styleSheet);
222KPropertyCursorEditor::~KPropertyCursorEditor()
227QCursor KPropertyCursorEditor::cursorValue()
const
232void KPropertyCursorEditor::setCursorValue(
const QCursor &value)
234 KPropertyComboBoxEditor::setValue( (
int)(value.
shape()) );
239KPropertyCursorDelegate::KPropertyCursorDelegate()
241 options()->setBordersVisible(
true);
244QWidget * KPropertyCursorDelegate::createEditor(
int type,
QWidget *parent,
250 return new KPropertyCursorEditor(parent);
253void KPropertyCursorDelegate::paint(
QPainter * painter,
256 const KPropertyUtilsPrivate::PainterSaver saver(painter);
258 int pmSize = (option.rect.height() >= 32) ? 32 : 16;
259 const QPixmap pm( s_cursorListData->pixmapForIndex(comboIndex, option.palette)
263 QRect r(option.rect);
264 r.setLeft(7 + r.left() + 1 + pm.width());
272 return KPropertyUtils::keyForEnumValue(
"CursorShape", shape);
274 const int comboIndex = s_cursorListData->shapeToIndex(shape);
275 return s_cursorListData->names().value(comboIndex).toString();
const KPropertyEditorCreatorOptions * options() const
Options for editor creating.
A data container for properties of list type.
QVariantList keys() const
A list containing all possible keys for a property.
bool isValid(QStringView ifopt)
Qt::CursorShape shape() const const
Language language() const const
QVariant data(int role) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
void drawPixmap(const QPoint &point, const QPixmap &pixmap)
void drawText(const QPoint &position, const QString &text)
const QColor & color(ColorGroup group, ColorRole role) const const
QString arg(Args &&... args) const const
QString fromLatin1(QByteArrayView str)