Changeset View
Changeset View
Standalone View
Standalone View
effects/colorpicker/colorpicker.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | ColorPickerEffect::~ColorPickerEffect() = default; | 62 | ColorPickerEffect::~ColorPickerEffect() = default; | ||
63 | 63 | | |||
64 | void ColorPickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | 64 | void ColorPickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | ||
65 | { | 65 | { | ||
66 | m_cachedOutputGeometry = data.outputGeometry(); | 66 | m_cachedOutputGeometry = data.outputGeometry(); | ||
67 | effects->paintScreen(mask, region, data); | 67 | effects->paintScreen(mask, region, data); | ||
68 | | ||||
69 | if (m_infoFrame) { | | |||
70 | m_infoFrame->render(region); | | |||
71 | } | | |||
72 | } | 68 | } | ||
73 | 69 | | |||
74 | void ColorPickerEffect::postPaintScreen() | 70 | void ColorPickerEffect::postPaintScreen() | ||
75 | { | 71 | { | ||
76 | effects->postPaintScreen(); | 72 | effects->postPaintScreen(); | ||
77 | 73 | | |||
78 | if (m_scheduledPosition != QPoint(-1, -1) && (m_cachedOutputGeometry.isEmpty() || m_cachedOutputGeometry.contains(m_scheduledPosition))) { | 74 | if (m_scheduledPosition != QPoint(-1, -1) && (m_cachedOutputGeometry.isEmpty() || m_cachedOutputGeometry.contains(m_scheduledPosition))) { | ||
79 | uint8_t data[3]; | 75 | uint8_t data[3]; | ||
Show All 31 Lines | 98 | [this] (const QPoint &p) { | |||
111 | } | 107 | } | ||
112 | } | 108 | } | ||
113 | ); | 109 | ); | ||
114 | return QColor(); | 110 | return QColor(); | ||
115 | } | 111 | } | ||
116 | 112 | | |||
117 | void ColorPickerEffect::showInfoMessage() | 113 | void ColorPickerEffect::showInfoMessage() | ||
118 | { | 114 | { | ||
119 | if (!m_infoFrame.isNull()) { | 115 | effects->showOnScreenMessage(i18n("Select a position for color picking with left click or enter.\nEscape or right click to cancel."), QStringLiteral("color-picker")); | ||
120 | return; | | |||
121 | } | | |||
122 | // TODO: turn the info message into a system wide service which performs hiding on mouse over | | |||
123 | m_infoFrame.reset(effects->effectFrame(EffectFrameStyled, false)); | | |||
124 | QFont font; | | |||
125 | font.setBold(true); | | |||
126 | m_infoFrame->setFont(font); | | |||
127 | QRect area = effects->clientArea(ScreenArea, effects->activeScreen(), effects->currentDesktop()); | | |||
128 | m_infoFrame->setPosition(QPoint(area.x() + area.width() / 2, area.y() + area.height() / 3)); | | |||
129 | m_infoFrame->setText(i18n("Select a position for color picking with left click or enter.\nEscape or right click to cancel.")); | | |||
130 | effects->addRepaintFull(); | | |||
131 | } | 116 | } | ||
132 | 117 | | |||
133 | void ColorPickerEffect::hideInfoMessage() | 118 | void ColorPickerEffect::hideInfoMessage() | ||
134 | { | 119 | { | ||
135 | m_infoFrame.reset(); | 120 | effects->hideOnScreenMessage(); | ||
136 | } | 121 | } | ||
137 | 122 | | |||
138 | bool ColorPickerEffect::isActive() const | 123 | bool ColorPickerEffect::isActive() const | ||
139 | { | 124 | { | ||
140 | return m_picking && ((m_scheduledPosition != QPoint(-1, -1)) || !m_infoFrame.isNull()) && !effects->isScreenLocked(); | 125 | return m_picking && ((m_scheduledPosition != QPoint(-1, -1))) && !effects->isScreenLocked(); | ||
141 | } | 126 | } | ||
142 | 127 | | |||
143 | } // namespace | 128 | } // namespace |