Support resizing of applet while handle is visible.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=740406
This commit is contained in:
parent
17ab44405d
commit
a166f48ccc
@ -50,32 +50,9 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet)
|
|||||||
{
|
{
|
||||||
KColorScheme colors(QPalette::Active, KColorScheme::View, Theme::self()->colors());
|
KColorScheme colors(QPalette::Active, KColorScheme::View, Theme::self()->colors());
|
||||||
m_gradientColor = colors.background(KColorScheme::NormalBackground).color();
|
m_gradientColor = colors.background(KColorScheme::NormalBackground).color();
|
||||||
|
|
||||||
m_originalMatrix = m_applet->transform();
|
m_originalMatrix = m_applet->transform();
|
||||||
m_rect = m_applet->boundingRect();
|
|
||||||
m_rect = m_applet->mapToParent(m_rect).boundingRect();
|
|
||||||
|
|
||||||
const int requiredHeight = (HANDLE_WIDTH * 2) + m_applet->hasConfigurationInterface()
|
|
||||||
? ((ICON_SIZE + ICON_MARGIN) * 4)
|
|
||||||
: ((ICON_SIZE + ICON_MARGIN) * 3)
|
|
||||||
+ ICON_MARGIN; // that last margin is blank space before the close button
|
|
||||||
if (m_rect.height() < requiredHeight) {
|
|
||||||
float delta = requiredHeight - m_rect.height();
|
|
||||||
delta = delta/2.0;
|
|
||||||
if (delta > 0.0) {
|
|
||||||
m_rect.adjust(0.0, -delta, 0.0, delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rect.adjust(-HANDLE_WIDTH, -HANDLE_WIDTH, HANDLE_WIDTH, HANDLE_WIDTH);
|
|
||||||
|
|
||||||
if (m_applet->pos().x() <= ((HANDLE_WIDTH * 2) + ICON_SIZE)) {
|
|
||||||
m_rect.adjust(0.0, 0.0, ICON_SIZE, 0.0);
|
|
||||||
m_buttonsOnRight = true;
|
|
||||||
} else {
|
|
||||||
m_rect.adjust(- ICON_SIZE, 0.0, 0.0, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
calculateSize();
|
||||||
m_applet->setParentItem(this);
|
m_applet->setParentItem(this);
|
||||||
connect(m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed()));
|
connect(m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed()));
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
@ -332,6 +309,13 @@ void AppletHandle::appletDestroyed()
|
|||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletHandle::appletResized()
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
calculateSize();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void AppletHandle::startFading(FadeType anim)
|
void AppletHandle::startFading(FadeType anim)
|
||||||
{
|
{
|
||||||
if (m_animId!=0) {
|
if (m_animId!=0) {
|
||||||
@ -358,6 +342,33 @@ void AppletHandle::forceDisappear()
|
|||||||
startFading(FadeOut);
|
startFading(FadeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletHandle::calculateSize()
|
||||||
|
{
|
||||||
|
m_rect = m_applet->boundingRect();
|
||||||
|
m_rect = m_applet->mapToParent(m_rect).boundingRect();
|
||||||
|
|
||||||
|
const int requiredHeight = (HANDLE_WIDTH * 2) + m_applet->hasConfigurationInterface()
|
||||||
|
? ((ICON_SIZE + ICON_MARGIN) * 4)
|
||||||
|
: ((ICON_SIZE + ICON_MARGIN) * 3)
|
||||||
|
+ ICON_MARGIN; // that last margin is blank space before the close button
|
||||||
|
if (m_rect.height() < requiredHeight) {
|
||||||
|
float delta = requiredHeight - m_rect.height();
|
||||||
|
delta = delta/2.0;
|
||||||
|
if (delta > 0.0) {
|
||||||
|
m_rect.adjust(0.0, -delta, 0.0, delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rect.adjust(-HANDLE_WIDTH, -HANDLE_WIDTH, HANDLE_WIDTH, HANDLE_WIDTH);
|
||||||
|
|
||||||
|
if (m_applet->pos().x() <= ((HANDLE_WIDTH * 2) + ICON_SIZE)) {
|
||||||
|
m_rect.adjust(0.0, 0.0, ICON_SIZE, 0.0);
|
||||||
|
m_buttonsOnRight = true;
|
||||||
|
} else {
|
||||||
|
m_rect.adjust(- ICON_SIZE, 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "applethandle_p.moc"
|
#include "applethandle_p.moc"
|
||||||
|
@ -59,6 +59,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void fadeAnimation(qreal progress);
|
void fadeAnimation(qreal progress);
|
||||||
void appletDestroyed();
|
void appletDestroyed();
|
||||||
|
void appletResized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int HANDLE_WIDTH = 5;
|
static const int HANDLE_WIDTH = 5;
|
||||||
@ -67,6 +68,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
|
|
||||||
void startFading(FadeType anim);
|
void startFading(FadeType anim);
|
||||||
void forceDisappear();
|
void forceDisappear();
|
||||||
|
void calculateSize();
|
||||||
ButtonType mapToButton(const QPointF &point) const;
|
ButtonType mapToButton(const QPointF &point) const;
|
||||||
|
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
|
@ -613,6 +613,8 @@ bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
|||||||
d->handles[applet] = handle;
|
d->handles[applet] = handle;
|
||||||
connect(handle, SIGNAL(disappearDone(AppletHandle*)),
|
connect(handle, SIGNAL(disappearDone(AppletHandle*)),
|
||||||
this, SLOT(handleDisappeared(AppletHandle*)));
|
this, SLOT(handleDisappeared(AppletHandle*)));
|
||||||
|
connect(applet, SIGNAL(geometryChanged()),
|
||||||
|
handle, SLOT(appletResized()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user