Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Amarok
Commits
a72943f6
Commit
a72943f6
authored
Sep 21, 2011
by
Ralf Engels
Browse files
Don't use QWeakPointer just for the sake of it.
Removed the usage of weak pointers in ContextView. BUG: 258741 FIXED-IN: 2.5
parent
027340cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/context/ContextView.cpp
View file @
a72943f6
...
...
@@ -48,6 +48,9 @@ ContextView* ContextView::s_self = 0;
ContextView
::
ContextView
(
Plasma
::
Containment
*
cont
,
Plasma
::
Corona
*
corona
,
QWidget
*
parent
)
:
Plasma
::
View
(
cont
,
parent
)
,
m_curState
(
Home
)
,
m_appletExplorer
(
0
)
,
m_collapseAnimations
(
0
)
,
m_collapseGroupTimer
(
0
)
{
Q_UNUSED
(
corona
)
DEBUG_BLOCK
...
...
@@ -89,12 +92,12 @@ ContextView::ContextView( Plasma::Containment *cont, Plasma::Corona *corona, QWi
The
::
amarokUrlHandler
()
->
registerRunner
(
m_urlRunner
,
"context"
);
m_collapseAnimations
=
new
QParallelAnimationGroup
(
this
);
connect
(
m_collapseAnimations
.
data
()
,
SIGNAL
(
finished
()),
connect
(
m_collapseAnimations
,
SIGNAL
(
finished
()),
this
,
SLOT
(
slotCollapseAnimationsFinished
())
);
m_collapseGroupTimer
=
new
QTimer
(
this
);
m_collapseGroupTimer
.
data
()
->
setSingleShot
(
true
);
connect
(
m_collapseGroupTimer
.
data
()
,
SIGNAL
(
timeout
()),
SLOT
(
slotStartCollapseAnimations
())
);
m_collapseGroupTimer
->
setSingleShot
(
true
);
connect
(
m_collapseGroupTimer
,
SIGNAL
(
timeout
()),
SLOT
(
slotStartCollapseAnimations
())
);
EngineController
*
const
engine
=
The
::
engineController
();
...
...
@@ -123,6 +126,8 @@ ContextView::~ContextView()
Plasma
::
DataEngineManager
::
self
()
->
unloadEngine
(
engine
);
}
qDeleteAll
(
m_queuedAnimations
);
clear
(
m_curState
);
//this should be done to prevent a crash on exit
clearFocus
();
...
...
@@ -237,65 +242,46 @@ ContextView::addCollapseAnimation( QAbstractAnimation *anim )
return
;
}
QParallelAnimationGroup
*
group
=
m_collapseAnimations
.
data
();
if
(
group
&&
group
->
state
()
==
QAbstractAnimation
::
Running
)
if
(
m_collapseAnimations
->
state
()
==
QAbstractAnimation
::
Running
||
m_collapseGroupTimer
->
isActive
()
)
{
m_queuedAnimations
.
enqueue
(
anim
);
return
;
}
QTimer
*
timer
(
0
);
if
(
m_collapseGroupTimer
)
timer
=
m_collapseGroupTimer
.
data
();
if
(
group
&&
timer
&&
!
timer
->
isActive
()
)
{
group
->
addAnimation
(
anim
);
timer
->
start
(
0
);
}
else
{
m_queuedAnimations
.
enqueue
(
anim
);
m_collapseAnimations
->
addAnimation
(
anim
);
m_collapseGroupTimer
->
start
(
0
);
}
}
void
ContextView
::
slotCollapseAnimationsFinished
()
{
QTimer
*
timer
=
m_collapseGroupTimer
.
data
();
if
(
timer
)
timer
->
stop
();
QParallelAnimationGroup
*
group
=
m_collapseAnimations
.
data
();
if
(
group
)
group
->
clear
();
m_collapseGroupTimer
->
stop
();
m_collapseAnimations
->
clear
();
while
(
!
m_queuedAnimations
.
isEmpty
()
)
{
if
(
QWeakPointer
<
QAbstractAnimation
>
anim
=
m_queuedAnimations
.
dequeue
()
)
{
if
(
group
)
group
->
addAnimation
(
anim
.
data
()
);
}
if
(
QAbstractAnimation
*
anim
=
m_queuedAnimations
.
dequeue
()
)
m_collapseAnimations
->
addAnimation
(
anim
);
}
if
(
group
&&
(
group
->
animationCount
()
>
0
)
)
t
imer
->
start
(
0
);
if
(
m_collapseAnimations
->
animationCount
()
>
0
)
m_collapseGroupT
imer
->
start
(
0
);
}
void
ContextView
::
slotStartCollapseAnimations
()
{
QParallelAnimationGroup
*
group
=
m_collapseAnimations
.
data
();
if
(
group
&&
(
group
->
animationCount
()
>
0
)
)
group
->
start
(
QAbstractAnimation
::
KeepWhenStopped
);
if
(
m_collapseAnimations
->
animationCount
()
>
0
)
m_collapseAnimations
->
start
(
QAbstractAnimation
::
KeepWhenStopped
);
}
void
ContextView
::
hideAppletExplorer
()
{
if
(
m_appletExplorer
)
m_appletExplorer
.
data
()
->
hide
();
m_appletExplorer
->
hide
();
}
void
...
...
@@ -305,20 +291,20 @@ ContextView::showAppletExplorer()
{
Context
::
Containment
*
cont
=
qobject_cast
<
Context
::
Containment
*>
(
containment
()
);
m_appletExplorer
=
new
AppletExplorer
(
cont
);
m_appletExplorer
.
data
()
->
setContainment
(
cont
);
m_appletExplorer
.
data
()
->
setZValue
(
m_appletExplorer
.
data
()
->
zValue
()
+
1000
);
m_appletExplorer
.
data
()
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
);
m_appletExplorer
->
setContainment
(
cont
);
m_appletExplorer
->
setZValue
(
m_appletExplorer
->
zValue
()
+
1000
);
m_appletExplorer
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
);
connect
(
m_appletExplorer
.
data
()
,
SIGNAL
(
addAppletToContainment
(
QString
,
const
int
)),
connect
(
m_appletExplorer
,
SIGNAL
(
addAppletToContainment
(
QString
,
const
int
)),
cont
,
SLOT
(
addApplet
(
QString
,
const
int
))
);
connect
(
m_appletExplorer
.
data
()
,
SIGNAL
(
appletExplorerHid
()),
SIGNAL
(
appletExplorerHid
())
);
connect
(
m_appletExplorer
.
data
()
,
SIGNAL
(
geometryChanged
()),
SLOT
(
slotPositionAppletExplorer
())
);
connect
(
m_appletExplorer
,
SIGNAL
(
appletExplorerHid
()),
SIGNAL
(
appletExplorerHid
())
);
connect
(
m_appletExplorer
,
SIGNAL
(
geometryChanged
()),
SLOT
(
slotPositionAppletExplorer
())
);
qreal
height
=
m_appletExplorer
.
data
()
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
.
data
()
->
resize
(
rect
().
width
()
-
2
,
height
);
m_appletExplorer
.
data
()
->
setPos
(
0
,
rect
().
height
()
-
height
-
2
);
qreal
height
=
m_appletExplorer
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
->
resize
(
rect
().
width
()
-
2
,
height
);
m_appletExplorer
->
setPos
(
0
,
rect
().
height
()
-
height
-
2
);
}
m_appletExplorer
.
data
()
->
show
();
m_appletExplorer
->
show
();
}
void
...
...
@@ -326,8 +312,8 @@ ContextView::slotPositionAppletExplorer()
{
if
(
!
m_appletExplorer
)
return
;
qreal
height
=
m_appletExplorer
.
data
()
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
.
data
()
->
setPos
(
0
,
rect
().
height
()
-
height
-
2
);
qreal
height
=
m_appletExplorer
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
->
setPos
(
0
,
rect
().
height
()
-
height
-
2
);
}
...
...
@@ -351,9 +337,9 @@ ContextView::resizeEvent( QResizeEvent* event )
if
(
m_appletExplorer
)
{
qreal
height
=
m_appletExplorer
.
data
()
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
.
data
()
->
resize
(
rect
.
width
()
-
2
,
height
);
m_appletExplorer
.
data
()
->
setPos
(
0
,
rect
.
height
()
-
height
-
2
);
qreal
height
=
m_appletExplorer
->
effectiveSizeHint
(
Qt
::
PreferredSize
).
height
();
m_appletExplorer
->
resize
(
rect
.
width
()
-
2
,
height
);
m_appletExplorer
->
setPos
(
0
,
rect
.
height
()
-
height
-
2
);
}
}
...
...
src/context/ContextView.h
View file @
a72943f6
...
...
@@ -38,7 +38,6 @@
#include
<QMouseEvent>
#include
<QGraphicsView>
#include
<QQueue>
#include
<QWeakPointer>
class
QPixmap
;
class
ContextUrlRunner
;
...
...
@@ -91,6 +90,10 @@ public:
*/
QStringList
currentAppletNames
();
/**
Adds a collapse animation
This object will take ownership of the animation.
*/
void
addCollapseAnimation
(
QAbstractAnimation
*
anim
);
public
slots
:
...
...
@@ -129,10 +132,10 @@ private:
ContextUrlRunner
*
m_urlRunner
;
QWeakPointer
<
AppletExplorer
>
m_appletExplorer
;
QWeakPointer
<
QParallelAnimationGroup
>
m_collapseAnimations
;
QQueue
<
QWeakPointer
<
QAbstractAnimation
>
>
m_queuedAnimations
;
QWeakPointer
<
QTimer
>
m_collapseGroupTimer
;
AppletExplorer
*
m_appletExplorer
;
QParallelAnimationGroup
*
m_collapseAnimations
;
QQueue
<
QAbstractAnimation
*
>
m_queuedAnimations
;
QTimer
*
m_collapseGroupTimer
;
};
}
// Context namespace
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment