Changeset View
Changeset View
Standalone View
Standalone View
widgets/colorSimilarity/kpColorSimilarityToolBarItem.cpp
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Line(s) | |||||
138 | //--------------------------------------------------------------------- | 138 | //--------------------------------------------------------------------- | ||
139 | 139 | | |||
140 | // private slot: | 140 | // private slot: | ||
141 | void kpColorSimilarityToolBarItem::slotFlashTimerTimeout () | 141 | void kpColorSimilarityToolBarItem::slotFlashTimerTimeout () | ||
142 | { | 142 | { | ||
143 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::slotFlashTimerTimeout()" | 143 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::slotFlashTimerTimeout()" | ||
144 | << " highlight=" << m_flashHighlight; | 144 | << " highlight=" << m_flashHighlight; | ||
145 | int newHigh = m_flashHighlight - 20; | 145 | int newHigh = m_flashHighlight - 20; | ||
146 | if (newHigh < 0) | 146 | if (newHigh < 0) { | ||
147 | newHigh = 0; | 147 | newHigh = 0; | ||
148 | } | ||||
148 | 149 | | |||
149 | m_flashHighlight = newHigh; | 150 | m_flashHighlight = newHigh; | ||
150 | 151 | | |||
151 | updateIcon (); | 152 | updateIcon (); | ||
152 | 153 | | |||
153 | if (newHigh == 0) | 154 | if (newHigh == 0) { | ||
154 | m_flashTimer->stop (); | 155 | m_flashTimer->stop (); | ||
155 | } | 156 | } | ||
157 | } | ||||
156 | 158 | | |||
157 | //--------------------------------------------------------------------- | 159 | //--------------------------------------------------------------------- | ||
158 | 160 | | |||
159 | // public | 161 | // public | ||
160 | void kpColorSimilarityToolBarItem::flash () | 162 | void kpColorSimilarityToolBarItem::flash () | ||
161 | { | 163 | { | ||
162 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::flash()"; | 164 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::flash()"; | ||
163 | if (isSuppressingFlash ()) | 165 | if (isSuppressingFlash ()) { | ||
164 | return; | 166 | return; | ||
167 | } | ||||
165 | 168 | | |||
166 | if (m_flashHighlight == 255) | 169 | if (m_flashHighlight == 255) | ||
167 | { | 170 | { | ||
168 | qCDebug(kpLogWidgets) << "\tNOP"; | 171 | qCDebug(kpLogWidgets) << "\tNOP"; | ||
169 | } | 172 | } | ||
170 | else | 173 | else | ||
171 | { | 174 | { | ||
172 | m_flashHighlight = 255; | 175 | m_flashHighlight = 255; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
232 | // 1. setColorSimilarityInternal() called by the ctor | 235 | // 1. setColorSimilarityInternal() called by the ctor | ||
233 | // 2. resizeEvent() when it's first shown() | 236 | // 2. resizeEvent() when it's first shown() | ||
234 | // | 237 | // | ||
235 | // We could get rid of the first and save a few milliseconds. | 238 | // We could get rid of the first and save a few milliseconds. | ||
236 | void kpColorSimilarityToolBarItem::updateIcon () | 239 | void kpColorSimilarityToolBarItem::updateIcon () | ||
237 | { | 240 | { | ||
238 | const int side = width () * 6 / 8; | 241 | const int side = width () * 6 / 8; | ||
239 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::updateIcon() width=" << width () | 242 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::updateIcon() width=" << width () | ||
240 | << " side=" << side << endl; | 243 | << " side=" << side; | ||
241 | 244 | | |||
242 | QPixmap icon(side, side); | 245 | QPixmap icon(side, side); | ||
243 | icon.fill(Qt::transparent); | 246 | icon.fill(Qt::transparent); | ||
244 | 247 | | |||
245 | kpColorSimilarityCubeRenderer::Paint (&icon, | 248 | kpColorSimilarityCubeRenderer::Paint (&icon, | ||
246 | 0/*x*/, 0/*y*/, side, | 249 | 0/*x*/, 0/*y*/, side, | ||
247 | colorSimilarity (), m_flashHighlight); | 250 | colorSimilarity (), m_flashHighlight); | ||
248 | 251 | | |||
249 | setIconSize(QSize(side, side)); | 252 | setIconSize(QSize(side, side)); | ||
250 | setIcon(icon); | 253 | setIcon(icon); | ||
251 | } | 254 | } | ||
252 | 255 | | |||
253 | //--------------------------------------------------------------------- | 256 | //--------------------------------------------------------------------- | ||
254 | 257 | | |||
255 | // private virtual [base QWidget] | 258 | // private virtual [base QWidget] | ||
256 | void kpColorSimilarityToolBarItem::resizeEvent (QResizeEvent *e) | 259 | void kpColorSimilarityToolBarItem::resizeEvent (QResizeEvent *e) | ||
257 | { | 260 | { | ||
258 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::resizeEvent() size=" << size () | 261 | qCDebug(kpLogWidgets) << "kpColorSimilarityToolBarItem::resizeEvent() size=" << size () | ||
259 | << " oldSize=" << e->oldSize () << endl; | 262 | << " oldSize=" << e->oldSize (); | ||
260 | QToolButton::resizeEvent (e); | 263 | QToolButton::resizeEvent (e); | ||
261 | 264 | | |||
262 | updateIcon (); | 265 | updateIcon (); | ||
263 | } | 266 | } |