Changeset View
Changeset View
Standalone View
Standalone View
src/context/popupdropper/libpud/PopupDropper.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 75 | QColor hoveredFillColor = QColor( Qt::blue ); | |||
---|---|---|---|---|---|
76 | hoveredFillColor.setAlpha( 32 ); | 76 | hoveredFillColor.setAlpha( 32 ); | ||
77 | hoveredFillBrush.setColor( hoveredFillColor ); | 77 | hoveredFillBrush.setColor( hoveredFillColor ); | ||
78 | hoveredFillBrush.setStyle( Qt::SolidPattern ); | 78 | hoveredFillBrush.setStyle( Qt::SolidPattern ); | ||
79 | scene = new QGraphicsScene( ( sa ? 0 : parent ) ); | 79 | scene = new QGraphicsScene( ( sa ? 0 : parent ) ); | ||
80 | view = new PopupDropperView( parent, scene, ( sa ? 0 : widget ) ); | 80 | view = new PopupDropperView( parent, scene, ( sa ? 0 : widget ) ); | ||
81 | //qDebug() << "on create, view size = " << view->size(); | 81 | //qDebug() << "on create, view size = " << view->size(); | ||
82 | deleteTimer.setSingleShot( true ); | 82 | deleteTimer.setSingleShot( true ); | ||
83 | fadeHideTimer.setDirection( QTimeLine::Backward ); | 83 | fadeHideTimer.setDirection( QTimeLine::Backward ); | ||
84 | connect( &fadeHideTimer, SIGNAL(frameChanged(int)), this, SLOT(fadeHideTimerFrameChanged(int)) ); | 84 | connect( &fadeHideTimer, &QTimeLine::frameChanged, this, &PopupDropperPrivate::fadeHideTimerFrameChanged ); | ||
85 | connect( &fadeShowTimer, SIGNAL(frameChanged(int)), this, SLOT(fadeShowTimerFrameChanged(int)) ); | 85 | connect( &fadeShowTimer, &QTimeLine::frameChanged, this, &PopupDropperPrivate::fadeShowTimerFrameChanged ); | ||
86 | connect( &fadeHideTimer, SIGNAL(finished()), this, SLOT(fadeHideTimerFinished()) ); | 86 | connect( &fadeHideTimer, &QTimeLine::finished, this, &PopupDropperPrivate::fadeHideTimerFinished ); | ||
87 | connect( &fadeShowTimer, SIGNAL(finished()), this, SLOT(fadeShowTimerFinished()) ); | 87 | connect( &fadeShowTimer, &QTimeLine::finished, this, &PopupDropperPrivate::fadeShowTimerFinished ); | ||
88 | connect( &deleteTimer, SIGNAL(timeout()), this, SLOT(deleteTimerFinished()) ); | 88 | connect( &deleteTimer, &QTimer::timeout, this, &PopupDropperPrivate::deleteTimerFinished ); | ||
89 | } | 89 | } | ||
90 | 90 | | |||
91 | PopupDropperPrivate::~PopupDropperPrivate() | 91 | PopupDropperPrivate::~PopupDropperPrivate() | ||
92 | { | 92 | { | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | void PopupDropperPrivate::newSceneView( PopupDropper* pud ) | 95 | void PopupDropperPrivate::newSceneView( PopupDropper* pud ) | ||
96 | { | 96 | { | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
159 | void PopupDropperPrivate::dragLeft() | 159 | void PopupDropperPrivate::dragLeft() | ||
160 | { | 160 | { | ||
161 | //qDebug() << "PopupDropperPrivate::dragLeft()"; | 161 | //qDebug() << "PopupDropperPrivate::dragLeft()"; | ||
162 | //qDebug() << "PUD to be hidden or not hidden = " << q; | 162 | //qDebug() << "PUD to be hidden or not hidden = " << q; | ||
163 | if( view->entered() && quitOnDragLeave ) | 163 | if( view->entered() && quitOnDragLeave ) | ||
164 | { | 164 | { | ||
165 | view->setAcceptDrops( false ); | 165 | view->setAcceptDrops( false ); | ||
166 | //qDebug() << "View entered, hiding"; | 166 | //qDebug() << "View entered, hiding"; | ||
167 | connect( q, SIGNAL(fadeHideFinished()), q, SLOT(subtractOverlay()) ); | 167 | connect( q, &PopupDropper::fadeHideFinished, q, &PopupDropper::subtractOverlay ); | ||
168 | q->hide(); | 168 | q->hide(); | ||
169 | } | 169 | } | ||
170 | q->updateAllOverlays(); | 170 | q->updateAllOverlays(); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | void PopupDropperPrivate::startDeleteTimer() | 173 | void PopupDropperPrivate::startDeleteTimer() | ||
174 | { | 174 | { | ||
175 | if( deleteTimeout == 0 ) | 175 | if( deleteTimeout == 0 ) | ||
176 | return; | 176 | return; | ||
177 | view->setEntered( false ); | 177 | view->setEntered( false ); | ||
178 | //qDebug() << "Starting delete timer"; | 178 | //qDebug() << "Starting delete timer"; | ||
179 | deleteTimer.start( deleteTimeout ); | 179 | deleteTimer.start( deleteTimeout ); | ||
180 | } | 180 | } | ||
181 | 181 | | |||
182 | void PopupDropperPrivate::deleteTimerFinished() //SLOT | 182 | void PopupDropperPrivate::deleteTimerFinished() //SLOT | ||
183 | { | 183 | { | ||
184 | //qDebug() << "Delete Timer Finished"; | 184 | //qDebug() << "Delete Timer Finished"; | ||
185 | if( !view->entered() && quitOnDragLeave ) | 185 | if( !view->entered() && quitOnDragLeave ) | ||
186 | { | 186 | { | ||
187 | connect( q, SIGNAL(fadeHideFinished()), q, SLOT(subtractOverlay()) ); | 187 | connect( q, &PopupDropper::fadeHideFinished, q, &PopupDropper::subtractOverlay ); | ||
188 | q->hide(); | 188 | q->hide(); | ||
189 | } | 189 | } | ||
190 | } | 190 | } | ||
191 | 191 | | |||
192 | void PopupDropperPrivate::reposItems() | 192 | void PopupDropperPrivate::reposItems() | ||
193 | { | 193 | { | ||
194 | qreal partitionsize, my_min, my_max; | 194 | qreal partitionsize, my_min, my_max; | ||
195 | //qDebug() << "allItems.size() = " << allItems.size(); | 195 | //qDebug() << "allItems.size() = " << allItems.size(); | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 303 | { | |||
315 | //qDebug() << "in PopupDropper " << this; | 315 | //qDebug() << "in PopupDropper " << this; | ||
316 | } | 316 | } | ||
317 | 317 | | |||
318 | //NOTE: just like you have to show the overlay when adding, this function does not hide the overlay; you must do that yourself | 318 | //NOTE: just like you have to show the overlay when adding, this function does not hide the overlay; you must do that yourself | ||
319 | //with hide() (which will hide just one level) | 319 | //with hide() (which will hide just one level) | ||
320 | bool PopupDropper::subtractOverlay() | 320 | bool PopupDropper::subtractOverlay() | ||
321 | { | 321 | { | ||
322 | //qDebug() << "subtractOverlay, with d pointer " << d; | 322 | //qDebug() << "subtractOverlay, with d pointer " << d; | ||
323 | disconnect( this, SLOT(subtractOverlay()) ); | 323 | disconnect( this, &PopupDropper::fadeHideFinished, this, &PopupDropper::subtractOverlay ); | ||
324 | while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) | 324 | while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) | ||
325 | { | 325 | { | ||
326 | //qDebug() << "singleshotting subtractOverlay"; | 326 | //qDebug() << "singleshotting subtractOverlay"; | ||
327 | QTimer::singleShot( 0, this, SLOT(subtractOverlay()) ); | 327 | QTimer::singleShot( 0, this, &PopupDropper::subtractOverlay ); | ||
328 | return false; | 328 | return false; | ||
329 | } | 329 | } | ||
330 | //qDebug() << "in PopupDropper " << this; | 330 | //qDebug() << "in PopupDropper " << this; | ||
331 | //qDebug() << "overlay d->overlayLevel = " << d->overlayLevel; | 331 | //qDebug() << "overlay d->overlayLevel = " << d->overlayLevel; | ||
332 | if( d->overlayLevel == 1 ) | 332 | if( d->overlayLevel == 1 ) | ||
333 | return false; | 333 | return false; | ||
334 | PopupDropper::Fading currFadeValue = d->fade; | 334 | PopupDropper::Fading currFadeValue = d->fade; | ||
335 | d->fade = PopupDropper::NoFade; | 335 | d->fade = PopupDropper::NoFade; | ||
Show All 34 Lines | 359 | { | |||
370 | foreach( PopupDropperItem* item, newD->pdiItems ) | 370 | foreach( PopupDropperItem* item, newD->pdiItems ) | ||
371 | newD->scene->removeItem( item ); | 371 | newD->scene->removeItem( item ); | ||
372 | newD->newSceneView( this ); | 372 | newD->newSceneView( this ); | ||
373 | initOverlay( d->widget, newD ); | 373 | initOverlay( d->widget, newD ); | ||
374 | PopupDropperItem* pdi = new PopupDropperItem(); | 374 | PopupDropperItem* pdi = new PopupDropperItem(); | ||
375 | 375 | | |||
376 | QAction* action = new QAction( text, this ); | 376 | QAction* action = new QAction( text, this ); | ||
377 | 377 | | |||
378 | connect( action, SIGNAL(hovered()), this, SLOT(activateSubmenu()) ); | 378 | connect( action, &QAction::hovered, this, &PopupDropper::activateSubmenu ); | ||
379 | pdi->setAction( action ); | 379 | pdi->setAction( action ); | ||
380 | pdi->setSubmenuTrigger( true ); | 380 | pdi->setSubmenuTrigger( true ); | ||
381 | pdi->setHoverIndicatorShowStyle( PopupDropperItem::OnHover ); | 381 | pdi->setHoverIndicatorShowStyle( PopupDropperItem::OnHover ); | ||
382 | d->submenuMap[action] = newD; | 382 | d->submenuMap[action] = newD; | ||
383 | delete (*pd); | 383 | delete (*pd); | ||
384 | (*pd) = 0; | 384 | (*pd) = 0; | ||
385 | foreach( PopupDropperItem* item, newD->pdiItems ) | 385 | foreach( PopupDropperItem* item, newD->pdiItems ) | ||
386 | item->setPopupDropper( this ); | 386 | item->setPopupDropper( this ); | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 488 | { | |||
496 | } | 496 | } | ||
497 | 497 | | |||
498 | //queuedHide is to make sure that fadeShowTimerFinished executes before this next hide() | 498 | //queuedHide is to make sure that fadeShowTimerFinished executes before this next hide() | ||
499 | if( d->fadeShowTimer.state() == QTimeLine::Running ) | 499 | if( d->fadeShowTimer.state() == QTimeLine::Running ) | ||
500 | { | 500 | { | ||
501 | //qDebug() << "show timer running, queueing hide"; | 501 | //qDebug() << "show timer running, queueing hide"; | ||
502 | d->fadeShowTimer.stop(); | 502 | d->fadeShowTimer.stop(); | ||
503 | d->queuedHide = true; | 503 | d->queuedHide = true; | ||
504 | QTimer::singleShot( 0, d, SLOT(fadeShowTimerFinished()) ); | 504 | QTimer::singleShot( 0, d, &PopupDropperPrivate::fadeShowTimerFinished ); | ||
505 | QTimer::singleShot( 0, this, SLOT(hide()) ); | 505 | QTimer::singleShot( 0, this, &PopupDropper::hide ); | ||
506 | return; | 506 | return; | ||
507 | } | 507 | } | ||
508 | 508 | | |||
509 | //queuedHide will be set to false from fadeShowTimerFinished...so if this came up first, | 509 | //queuedHide will be set to false from fadeShowTimerFinished...so if this came up first, | ||
510 | //then wait | 510 | //then wait | ||
511 | if( d->fadeHideTimer.state() == QTimeLine::Running || d->queuedHide ) | 511 | if( d->fadeHideTimer.state() == QTimeLine::Running || d->queuedHide ) | ||
512 | { | 512 | { | ||
513 | //qDebug() << "hide timer running or queued hide"; | 513 | //qDebug() << "hide timer running or queued hide"; | ||
514 | QTimer::singleShot( 0, this, SLOT(hide()) ); | 514 | QTimer::singleShot( 0, this, &PopupDropper::hide ); | ||
515 | return; | 515 | return; | ||
516 | } | 516 | } | ||
517 | 517 | | |||
518 | if( ( d->fade == PopupDropper::FadeOut || d->fade == PopupDropper::FadeInOut ) && d->fadeOutTime > 0 ) | 518 | if( ( d->fade == PopupDropper::FadeOut || d->fade == PopupDropper::FadeInOut ) && d->fadeOutTime > 0 ) | ||
519 | { | 519 | { | ||
520 | //qDebug() << "Starting fade out"; | 520 | //qDebug() << "Starting fade out"; | ||
521 | d->fadeHideTimer.setDuration( d->fadeOutTime ); | 521 | d->fadeHideTimer.setDuration( d->fadeOutTime ); | ||
522 | d->fadeHideTimer.setCurveShape( QTimeLine::LinearCurve ); | 522 | d->fadeHideTimer.setCurveShape( QTimeLine::LinearCurve ); | ||
523 | d->fadeHideTimer.start(); | 523 | d->fadeHideTimer.start(); | ||
524 | //qDebug() << "Timer started"; | 524 | //qDebug() << "Timer started"; | ||
525 | return; | 525 | return; | ||
526 | } | 526 | } | ||
527 | else //time is zero, or no fade | 527 | else //time is zero, or no fade | ||
528 | { | 528 | { | ||
529 | //qDebug() << "time is zero, or no fade"; | 529 | //qDebug() << "time is zero, or no fade"; | ||
530 | QTimer::singleShot( 0, d, SLOT(fadeHideTimerFinished()) ); | 530 | QTimer::singleShot( 0, d, &PopupDropperPrivate::fadeHideTimerFinished ); | ||
531 | return; | 531 | return; | ||
532 | } | 532 | } | ||
533 | } | 533 | } | ||
534 | 534 | | |||
535 | void PopupDropper::hideAllOverlays() | 535 | void PopupDropper::hideAllOverlays() | ||
536 | { | 536 | { | ||
537 | //qDebug() << "Entered hideAllOverlays"; | 537 | //qDebug() << "Entered hideAllOverlays"; | ||
538 | connect( this, SIGNAL(fadeHideFinished()), this, SLOT(slotHideAllOverlays()) ); | 538 | connect( this, &PopupDropper::fadeHideFinished, this, &PopupDropper::slotHideAllOverlays ); | ||
539 | hide(); | 539 | hide(); | ||
540 | //qDebug() << "Leaving hideAllOverlays"; | 540 | //qDebug() << "Leaving hideAllOverlays"; | ||
541 | } | 541 | } | ||
542 | 542 | | |||
543 | void PopupDropper::slotHideAllOverlays() | 543 | void PopupDropper::slotHideAllOverlays() | ||
544 | { | 544 | { | ||
545 | //qDebug() << "Entered slotHideAllOverlays()"; | 545 | //qDebug() << "Entered slotHideAllOverlays()"; | ||
546 | disconnect( this, SIGNAL(fadeHideFinished()), this, SLOT(slotHideAllOverlays()) ); | 546 | disconnect( this, &PopupDropper::fadeHideFinished, this, &PopupDropper::slotHideAllOverlays ); | ||
547 | //qDebug() << "m_viewStack.size() = " << m_viewStack.size(); | 547 | //qDebug() << "m_viewStack.size() = " << m_viewStack.size(); | ||
548 | for( int i = m_viewStack.size() - 1; i >= 0; --i ) | 548 | for( int i = m_viewStack.size() - 1; i >= 0; --i ) | ||
549 | { | 549 | { | ||
550 | PopupDropperPrivate* pdp = m_viewStack.at( i ); | 550 | PopupDropperPrivate* pdp = m_viewStack.at( i ); | ||
551 | //qDebug() << "checking pdp = " << (QObject*)pdp << ", d is " << (QObject*)d; | 551 | //qDebug() << "checking pdp = " << (QObject*)pdp << ", d is " << (QObject*)d; | ||
552 | if( pdp != d ) | 552 | if( pdp != d ) | ||
553 | pdp->view->hide(); | 553 | pdp->view->hide(); | ||
554 | } | 554 | } | ||
Show All 20 Lines | |||||
575 | { | 575 | { | ||
576 | return d->view->isHidden(); | 576 | return d->view->isHidden(); | ||
577 | } | 577 | } | ||
578 | 578 | | |||
579 | void PopupDropper::clear() | 579 | void PopupDropper::clear() | ||
580 | { | 580 | { | ||
581 | while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) | 581 | while( !isHidden() && d->fadeHideTimer.state() == QTimeLine::Running ) | ||
582 | { | 582 | { | ||
583 | QTimer::singleShot(0, this, SLOT(clear()) ); | 583 | QTimer::singleShot(0, this, &PopupDropper::clear ); | ||
584 | return; | 584 | return; | ||
585 | } | 585 | } | ||
586 | //qDebug() << "Clear happening!"; | 586 | //qDebug() << "Clear happening!"; | ||
587 | disconnect( this, SLOT(clear()) ); | 587 | // disconnect( this, 0, this, &PopupDropper::clear ); Unused at this point. | ||
588 | do | 588 | do | ||
589 | { | 589 | { | ||
590 | foreach( QGraphicsItem* item, d->allItems ) | 590 | foreach( QGraphicsItem* item, d->allItems ) | ||
591 | { | 591 | { | ||
592 | if( dynamic_cast<PopupDropperItem*>(item) ) | 592 | if( dynamic_cast<PopupDropperItem*>(item) ) | ||
593 | { | 593 | { | ||
594 | if( dynamic_cast<PopupDropperItem*>(item)->isSubmenuTrigger() ) | 594 | if( dynamic_cast<PopupDropperItem*>(item)->isSubmenuTrigger() ) | ||
595 | { | 595 | { | ||
596 | //qDebug() << "Disconnecting action"; | 596 | //qDebug() << "Disconnecting action"; | ||
597 | disconnect( dynamic_cast<PopupDropperItem*>(item)->action(), SIGNAL(hovered()), this, SLOT(activateSubmenu()) ); | 597 | disconnect( dynamic_cast<PopupDropperItem*>(item)->action(), &QAction::hovered, this, &PopupDropper::activateSubmenu ); | ||
598 | } | 598 | } | ||
599 | dynamic_cast<PopupDropperItem*>(item)->deleteLater(); | 599 | dynamic_cast<PopupDropperItem*>(item)->deleteLater(); | ||
600 | } | 600 | } | ||
601 | else | 601 | else | ||
602 | delete item; | 602 | delete item; | ||
603 | } | 603 | } | ||
604 | d->pdiItems.clear(); | 604 | d->pdiItems.clear(); | ||
605 | d->allItems.clear(); | 605 | d->allItems.clear(); | ||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |