Changeset View
Changeset View
Standalone View
Standalone View
tools/kpToolColorPicker.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
43 | 43 | | |||
44 | kpToolColorPicker::kpToolColorPicker (kpToolEnvironment *environ, QObject *parent) | 44 | kpToolColorPicker::kpToolColorPicker (kpToolEnvironment *environ, QObject *parent) | ||
45 | : kpTool (i18n ("Color Picker"), i18n ("Lets you select a color from the image"), | 45 | : kpTool (i18n ("Color Picker"), i18n ("Lets you select a color from the image"), | ||
46 | Qt::Key_C, | 46 | Qt::Key_C, | ||
47 | environ, parent, "tool_color_picker") | 47 | environ, parent, "tool_color_picker") | ||
48 | { | 48 | { | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | kpToolColorPicker::~kpToolColorPicker () | 51 | kpToolColorPicker::~kpToolColorPicker () = default; | ||
52 | { | | |||
53 | } | | |||
54 | 52 | | |||
55 | 53 | | |||
56 | // private | 54 | // private | ||
57 | kpColor kpToolColorPicker::colorAtPixel (const QPoint &p) | 55 | kpColor kpToolColorPicker::colorAtPixel (const QPoint &p) | ||
58 | { | 56 | { | ||
59 | qCDebug(kpLogTools) << "kpToolColorPicker::colorAtPixel" << p; | 57 | qCDebug(kpLogTools) << "kpToolColorPicker::colorAtPixel" << p; | ||
60 | 58 | | |||
61 | return kpPixmapFX::getColorAtPixel (document ()->image (), p); | 59 | return kpPixmapFX::getColorAtPixel (document ()->image (), p); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
117 | 115 | | |||
118 | // public virtual [base kpTool] | 116 | // public virtual [base kpTool] | ||
119 | void kpToolColorPicker::endDraw (const QPoint &thisPoint, const QRect &) | 117 | void kpToolColorPicker::endDraw (const QPoint &thisPoint, const QRect &) | ||
120 | { | 118 | { | ||
121 | const kpColor color = colorAtPixel (thisPoint); | 119 | const kpColor color = colorAtPixel (thisPoint); | ||
122 | 120 | | |||
123 | if (color.isValid ()) | 121 | if (color.isValid ()) | ||
124 | { | 122 | { | ||
125 | kpToolColorPickerCommand *cmd = | 123 | auto *cmd = new kpToolColorPickerCommand ( mouseButton (), color, m_oldColor, | ||
126 | new kpToolColorPickerCommand ( | | |||
127 | mouseButton (), | | |||
128 | color, m_oldColor, | | |||
129 | environ ()->commandEnvironment ()); | 124 | environ ()->commandEnvironment ()); | ||
130 | 125 | | |||
131 | environ ()->commandHistory ()->addCommand (cmd, false/*no exec*/); | 126 | environ ()->commandHistory ()->addCommand (cmd, false/*no exec*/); | ||
132 | setUserMessage (haventBegunDrawUserMessage ()); | 127 | setUserMessage (haventBegunDrawUserMessage ()); | ||
133 | } | 128 | } | ||
134 | else | 129 | else | ||
135 | { | 130 | { | ||
136 | cancelShape (); | 131 | cancelShape (); | ||
137 | } | 132 | } | ||
138 | } | 133 | } | ||
139 | 134 | | |||
140 | 135 | |