27
27
#include <QGraphicsLinearLayout>
28
28
#include <QGraphicsSceneResizeEvent>
30
#include <QParallelAnimationGroup>
31
32
#include <KIconLoader>
34
#include <Plasma/Animation>
33
35
#include <Plasma/Applet>
34
36
#include <Plasma/Containment>
35
37
#include <Plasma/IconWidget>
130
132
int rows = qMax(1, (int)m_containment->size().height() / squareSize);
131
133
const QSizeF maximumAppletSize(m_containment->size().width()/columns, m_containment->size().height()/rows);
135
QParallelAnimationGroup *group = new QParallelAnimationGroup(this);
134
138
foreach (Plasma::Applet *applet, m_applets) {
135
139
if (applet == m_currentApplet.data()) {
141
145
appletSize = appletSize.expandedTo(QSize(250, 250));
142
146
QSizeF offset(QSizeF(maximumAppletSize - appletSize)/2);
144
if ((m_containment->applets().count() - i < columns) && ((i+1)%columns != 0)) {
145
offset.rwidth() += ((i+1)%columns * maximumAppletSize.width())/2;
148
if ((m_containment->applets().count() - i < columns) &&
149
(i/columns == m_containment->applets().count()/columns) &&
150
((i+1)%columns != 0)) {
151
offset.rwidth() += ((i+1)%columns * maximumAppletSize.width())/columns;
148
applet->setGeometry((i%columns)*maximumAppletSize.width() + offset.width(), (i/columns)*maximumAppletSize.height() + offset.height(), appletSize.width(), appletSize.height());
155
const QRectF targetGeom((i%columns)*maximumAppletSize.width() + offset.width(), (i/columns)*maximumAppletSize.height() + offset.height(), appletSize.width(), appletSize.height());
156
Animation *anim = Plasma::Animator::create(Plasma::Animator::GeometryAnimation);
157
anim->setTargetWidget(applet);
158
anim->setProperty("startGeometry", applet->geometry());
159
anim->setProperty("targetGeometry", targetGeom);
160
group->addAnimation(anim);
164
group->start(QAbstractAnimation::DeleteWhenStopped);
165
connect(group, SIGNAL(finished()), this, SLOT(repositionToolBox()));
167
resize(size().width(), (ceil((qreal)m_containment->applets().count()/columns))*maximumAppletSize.height());
170
void AppletsContainer::repositionToolBox()
172
const int squareSize = 350;
173
const int columns = qMax(1, (int)m_containment->size().width() / squareSize);
174
const int rows = qMax(1, (int)m_containment->size().height() / squareSize);
175
const QSizeF maximumAppletSize(m_containment->size().width()/columns, m_containment->size().height()/rows);
152
177
int extraHeight = 0;
154
179
if (m_addWidgetsButton) {
253
278
if (m_currentApplet) {
254
279
const int margin = KIconLoader::SizeHuge;
256
m_currentApplet.data()->setGeometry(mapFromItem(m_containment, m_containment->boundingRect()).boundingRect().adjusted(margin, margin/2, -margin, -margin/2));
281
QRectF targetGeom(mapFromItem(m_containment, m_containment->boundingRect()).boundingRect().adjusted(margin, margin/2, -margin, -margin/2));
282
Animation *anim = Plasma::Animator::create(Plasma::Animator::GeometryAnimation);
283
anim->setTargetWidget(m_currentApplet.data());
284
anim->setProperty("startGeometry", m_currentApplet.data()->geometry());
285
anim->setProperty("targetGeometry", targetGeom);
286
anim->start(QAbstractAnimation::DeleteWhenStopped);
259
289
if (m_appletsOverlay) {