Changeset View
Changeset View
Standalone View
Standalone View
effects/flipswitch/flipswitch.cpp
Show All 39 Lines | |||||
40 | FlipSwitchEffect::FlipSwitchEffect() | 40 | FlipSwitchEffect::FlipSwitchEffect() | ||
41 | : m_selectedWindow(nullptr) | 41 | : m_selectedWindow(nullptr) | ||
42 | , m_currentAnimationShape(QTimeLine::EaseInOutCurve) | 42 | , m_currentAnimationShape(QTimeLine::EaseInOutCurve) | ||
43 | , m_active(false) | 43 | , m_active(false) | ||
44 | , m_start(false) | 44 | , m_start(false) | ||
45 | , m_stop(false) | 45 | , m_stop(false) | ||
46 | , m_animation(false) | 46 | , m_animation(false) | ||
47 | , m_hasKeyboardGrab(false) | 47 | , m_hasKeyboardGrab(false) | ||
48 | , m_captionFrame(NULL) | 48 | , m_captionFrame(nullptr) | ||
49 | { | 49 | { | ||
50 | initConfig<FlipSwitchConfig>(); | 50 | initConfig<FlipSwitchConfig>(); | ||
51 | reconfigure(ReconfigureAll); | 51 | reconfigure(ReconfigureAll); | ||
52 | 52 | | |||
53 | // Caption frame | 53 | // Caption frame | ||
54 | m_captionFont.setBold(true); | 54 | m_captionFont.setBold(true); | ||
55 | m_captionFont.setPointSize(m_captionFont.pointSize() * 2); | 55 | m_captionFont.setPointSize(m_captionFont.pointSize() * 2); | ||
56 | 56 | | |||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 145 | foreach (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach | |||
148 | else | 148 | else | ||
149 | index--; | 149 | index--; | ||
150 | if (index < 0) | 150 | if (index < 0) | ||
151 | index = tempList.count() + index; | 151 | index = tempList.count() + index; | ||
152 | if (index >= tempList.count()) | 152 | if (index >= tempList.count()) | ||
153 | index = index % tempList.count(); | 153 | index = index % tempList.count(); | ||
154 | } | 154 | } | ||
155 | tabIndex = index; | 155 | tabIndex = index; | ||
156 | EffectWindow* w = NULL; | 156 | EffectWindow* w = nullptr; | ||
157 | if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) { | 157 | if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) { | ||
158 | index--; | 158 | index--; | ||
159 | if (index < 0) | 159 | if (index < 0) | ||
160 | index = tempList.count() + index; | 160 | index = tempList.count() + index; | ||
161 | w = tempList.at(index); | 161 | w = tempList.at(index); | ||
162 | } | 162 | } | ||
163 | for (int i = index - 1; i >= 0; i--) | 163 | for (int i = index - 1; i >= 0; i--) | ||
164 | m_flipOrderedWindows.append(tempList.at(i)); | 164 | m_flipOrderedWindows.append(tempList.at(i)); | ||
Show All 10 Lines | 172 | foreach (SwitchingDirection direction, m_scheduledDirections) { // krazy:exclude=foreach | |||
175 | else | 175 | else | ||
176 | index--; | 176 | index--; | ||
177 | if (index < 0) | 177 | if (index < 0) | ||
178 | index = tempList.count() - 1; | 178 | index = tempList.count() - 1; | ||
179 | if (index >= tempList.count()) | 179 | if (index >= tempList.count()) | ||
180 | index = 0; | 180 | index = 0; | ||
181 | } | 181 | } | ||
182 | tabIndex = index; | 182 | tabIndex = index; | ||
183 | EffectWindow* w = NULL; | 183 | EffectWindow* w = nullptr; | ||
184 | if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) { | 184 | if (!m_scheduledDirections.isEmpty() && m_scheduledDirections.head() == DirectionBackward) { | ||
185 | index++; | 185 | index++; | ||
186 | if (index >= tempList.count()) | 186 | if (index >= tempList.count()) | ||
187 | index = 0; | 187 | index = 0; | ||
188 | } | 188 | } | ||
189 | // sort from stacking order | 189 | // sort from stacking order | ||
190 | for (int i = index + 1; i < tempList.count(); i++) | 190 | for (int i = index + 1; i < tempList.count(); i++) | ||
191 | m_flipOrderedWindows.append(tempList.at(i)); | 191 | m_flipOrderedWindows.append(tempList.at(i)); | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 317 | if (!m_scheduledDirections.isEmpty()) { | |||
326 | } | 326 | } | ||
327 | } | 327 | } | ||
328 | effects->addRepaintFull(); | 328 | effects->addRepaintFull(); | ||
329 | } | 329 | } | ||
330 | if (m_stop && m_startStopTimeLine.currentValue() == 0.0f) { | 330 | if (m_stop && m_startStopTimeLine.currentValue() == 0.0f) { | ||
331 | m_stop = false; | 331 | m_stop = false; | ||
332 | m_active = false; | 332 | m_active = false; | ||
333 | m_captionFrame->free(); | 333 | m_captionFrame->free(); | ||
334 | effects->setActiveFullScreenEffect(0); | 334 | effects->setActiveFullScreenEffect(nullptr); | ||
335 | effects->addRepaintFull(); | 335 | effects->addRepaintFull(); | ||
336 | qDeleteAll(m_windows); | 336 | qDeleteAll(m_windows); | ||
337 | m_windows.clear(); | 337 | m_windows.clear(); | ||
338 | } | 338 | } | ||
339 | if (m_animation && m_timeLine.currentValue() == 1.0f) { | 339 | if (m_animation && m_timeLine.currentValue() == 1.0f) { | ||
340 | m_timeLine.setCurrentTime(0); | 340 | m_timeLine.setCurrentTime(0); | ||
341 | m_scheduledDirections.dequeue(); | 341 | m_scheduledDirections.dequeue(); | ||
342 | if (m_scheduledDirections.isEmpty()) { | 342 | if (m_scheduledDirections.isEmpty()) { | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
434 | } | 434 | } | ||
435 | 435 | | |||
436 | void FlipSwitchEffect::slotTabBoxUpdated() | 436 | void FlipSwitchEffect::slotTabBoxUpdated() | ||
437 | { | 437 | { | ||
438 | if (m_active && !m_stop) { | 438 | if (m_active && !m_stop) { | ||
439 | if (!effects->currentTabBoxWindowList().isEmpty()) { | 439 | if (!effects->currentTabBoxWindowList().isEmpty()) { | ||
440 | // determine the switch direction | 440 | // determine the switch direction | ||
441 | if (m_selectedWindow != effects->currentTabBoxWindow()) { | 441 | if (m_selectedWindow != effects->currentTabBoxWindow()) { | ||
442 | if (m_selectedWindow != NULL) { | 442 | if (m_selectedWindow != nullptr) { | ||
443 | int old_index = effects->currentTabBoxWindowList().indexOf(m_selectedWindow); | 443 | int old_index = effects->currentTabBoxWindowList().indexOf(m_selectedWindow); | ||
444 | int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow()); | 444 | int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow()); | ||
445 | SwitchingDirection new_direction; | 445 | SwitchingDirection new_direction; | ||
446 | int distance = new_index - old_index; | 446 | int distance = new_index - old_index; | ||
447 | if (distance > 0) | 447 | if (distance > 0) | ||
448 | new_direction = DirectionForward; | 448 | new_direction = DirectionForward; | ||
449 | if (distance < 0) | 449 | if (distance < 0) | ||
450 | new_direction = DirectionBackward; | 450 | new_direction = DirectionBackward; | ||
Show All 31 Lines | 481 | { | |||
482 | if (m_active && isSelectableWindow(w)) { | 482 | if (m_active && isSelectableWindow(w)) { | ||
483 | m_windows[ w ] = new ItemInfo; | 483 | m_windows[ w ] = new ItemInfo; | ||
484 | } | 484 | } | ||
485 | } | 485 | } | ||
486 | 486 | | |||
487 | void FlipSwitchEffect::slotWindowClosed(EffectWindow* w) | 487 | void FlipSwitchEffect::slotWindowClosed(EffectWindow* w) | ||
488 | { | 488 | { | ||
489 | if (m_selectedWindow == w) | 489 | if (m_selectedWindow == w) | ||
490 | m_selectedWindow = 0; | 490 | m_selectedWindow = nullptr; | ||
491 | if (m_active) { | 491 | if (m_active) { | ||
492 | QHash< const EffectWindow*, ItemInfo* >::iterator it = m_windows.find(w); | 492 | QHash< const EffectWindow*, ItemInfo* >::iterator it = m_windows.find(w); | ||
493 | if (it != m_windows.end()) { | 493 | if (it != m_windows.end()) { | ||
494 | delete *it; | 494 | delete *it; | ||
495 | m_windows.erase(it); | 495 | m_windows.erase(it); | ||
496 | } | 496 | } | ||
497 | } | 497 | } | ||
498 | } | 498 | } | ||
▲ Show 20 Lines • Show All 494 Lines • Show Last 20 Lines |