From 5eb78f23ea345cf9fe3b785133e6b8bcbc68c593 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 26 Jan 2010 23:35:32 +0000 Subject: [PATCH] zooming is gone; activity switching can be done for now using the activity switcher or the keyboard shortcuts. a new activity manager will be built up from here svn path=/trunk/KDE/kdelibs/; revision=1080793 --- applet.cpp | 22 ++----- containment.cpp | 63 +++++--------------- containment.h | 3 +- paintutils.cpp | 2 - private/containment_p.h | 2 - private/desktoptoolbox.cpp | 114 +++++++++--------------------------- private/internaltoolbox.cpp | 42 +------------ private/internaltoolbox_p.h | 8 +-- 8 files changed, 53 insertions(+), 203 deletions(-) diff --git a/applet.cpp b/applet.cpp index f8dda1e8d..29de4fcd7 100644 --- a/applet.cpp +++ b/applet.cpp @@ -69,6 +69,7 @@ #include +#include "abstracttoolbox.h" #include "authorizationmanager.h" #include "authorizationrule.h" #include "configloader.h" @@ -106,7 +107,6 @@ #include "private/popupapplet_p.h" #include "private/remotedataengine_p.h" #include "private/service_p.h" -#include "private/internaltoolbox_p.h" #include "ui_publish.h" #include "config-plasma.h" @@ -394,6 +394,7 @@ void Applet::saveState(KConfigGroup &group) const if (d->script) { emit d->script->saveState(group); } + if (group.config()->name() != config().config()->name()) { // we're being saved to a different file! // let's just copy the current values in our configuration over @@ -452,8 +453,7 @@ void Applet::destroy() if (isContainment()) { d->cleanUpAndDelete(); } else { - Animation *zoomAnim = - Plasma::Animator::create(Plasma::Animator::ZoomAnimation); + Animation *zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation); connect(zoomAnim, SIGNAL(finished()), this, SLOT(appletAnimationComplete())); zoomAnim->setTargetWidget(this); zoomAnim->start(); @@ -1322,17 +1322,6 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW View* v = qobject_cast(widget->parent()); Containment* c = qobject_cast(this); - //update the view transform of the toolbox, since it ignores transforms - if (v && c && c->d->toolBox) { - InternalToolBox *toolBox = qobject_cast(c->d->toolBox.data()); - if (toolBox && toolBox->viewTransform().isScaling() && !v->transform().isScaling()) { - c->d->positionToolBox(); - } - if (toolBox && v) { - toolBox->setViewTransform(v->transform()); - } - } - if (!v || v->isWallpaperEnabled()) { // paint the wallpaper @@ -1923,7 +1912,7 @@ void AppletPrivate::updateShortcuts() //we pull them out, then read, then put them back QList names; QList qactions; - names << "zoom out" << "add sibling containment" << "configure shortcuts" << "lock widgets"; + names << "add sibling containment" << "configure shortcuts" << "lock widgets"; foreach (const QString &name, names) { QAction *a = actions->action(name); actions->takeAction(a); //FIXME this is stupid, KActionCollection needs a takeAction(QString) method @@ -2856,8 +2845,7 @@ AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent) void AppletOverlayWidget::destroy() { - Animation *zoomAnim = - Plasma::Animator::create(Plasma::Animator::ZoomAnimation); + Animation *zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation); connect(zoomAnim, SIGNAL(finished()), this, SLOT(overlayAnimationComplete())); zoomAnim->setTargetWidget(this); zoomAnim->start(); diff --git a/containment.cpp b/containment.cpp index 37d9388c4..e4e1f7c00 100644 --- a/containment.cpp +++ b/containment.cpp @@ -202,37 +202,26 @@ void Containment::init() } } - if (d->type == PanelContainment || - d->type == CustomPanelContainment) { - d->actions()->removeAction(action("zoom in")); - } else { - QAction *zoomAction = action("zoom in"); - connect(zoomAction, SIGNAL(triggered()), this, SLOT(zoomIn())); - + if (d->type != PanelContainment && d->type != CustomPanelContainment) { if (corona()) { - QAction *action = corona()->action("zoom out"); - if (action) { - d->actions()->addAction("zoom out", action); - } - action = corona()->action("add sibling containment"); - if (action) { - d->actions()->addAction("add sibling containment", action); + act = corona()->action("add sibling containment"); + if (act) { + d->actions()->addAction("add sibling containment", act); } //a stupid hack to make this one's keyboard shortcut work - action = corona()->action("configure shortcuts"); - if (action) { - d->actions()->addAction("configure shortcuts", action); + act = corona()->action("configure shortcuts"); + if (act) { + d->actions()->addAction("configure shortcuts", act); } } if (d->type == DesktopContainment && d->toolBox) { - d->toolBox.data()->addTool(this->action("add widgets")); - d->toolBox.data()->addTool(this->action("zoom in")); + d->toolBox.data()->addTool(action("add widgets")); //TODO: do we need some way to allow this be overridden? // it's always available because shells rely on this // to offer their own custom configuration as well - QAction *configureContainment = this->action("configure"); + QAction *configureContainment = action("configure"); if (configureContainment) { d->toolBox.data()->addTool(configureContainment); } @@ -311,15 +300,6 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme //no icon action->setShortcut(KShortcut("alt+d, p")); action->setData(AbstractToolBox::ControlTool); - - KAction *zoomAction = actions->addAction("zoom in"); - zoomAction->setAutoRepeat(false); - zoomAction->setText(i18n("Zoom In")); - zoomAction->setIcon(KIcon("zoom-in")); - //two shortcuts because I hate ctrl-+ but others expect it - zoomAction->setShortcuts(KShortcut("alt+d, +; alt+d, =")); - zoomAction->setData(AbstractToolBox::ControlTool); - } // helper function for sorting the list of applets @@ -382,9 +362,9 @@ void Containment::restore(KConfigGroup &group) setWallpaper(group.readEntry("wallpaperplugin", defaultWallpaper), group.readEntry("wallpaperpluginmode", defaultWallpaperMode)); - InternalToolBox *toolBox = qobject_cast(d->toolBox.data()); - if (toolBox) { - toolBox->load(group); + InternalToolBox *internalToolBox = qobject_cast(d->toolBox.data()); + if (internalToolBox) { + internalToolBox->restore(group); } KConfigGroup cfg(&group, "ActionPlugins"); @@ -2094,20 +2074,6 @@ void Containment::destroy(bool confirm) } } -void ContainmentPrivate::zoomIn() -{ - emit q->zoomRequested(q, Plasma::ZoomIn); - positionToolBox(); -} - - - -void ContainmentPrivate::zoomOut() -{ - emit q->zoomRequested(q, Plasma::ZoomOut); - positionToolBox(); -} - AbstractToolBox *ContainmentPrivate::createToolBox() { if (!toolBox) { @@ -2135,11 +2101,11 @@ AbstractToolBox *ContainmentPrivate::createToolBox() } if (toolBox) { - InternalToolBox *internalToolBox = qobject_cast(toolBox.data()); QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SIGNAL(toolBoxToggled())); QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SLOT(updateToolBoxVisibility())); + InternalToolBox *internalToolBox = qobject_cast(toolBox.data()); if (internalToolBox) { - internalToolBox->load(); + internalToolBox->restore(); positionToolBox(); } } @@ -2152,6 +2118,7 @@ void ContainmentPrivate::positionToolBox() { InternalToolBox *internalToolBox = qobject_cast(toolBox.data()); if (internalToolBox) { + internalToolBox->updateToolBox(); internalToolBox->reposition(); } } diff --git a/containment.h b/containment.h index f6b71d4c8..ccad36357 100644 --- a/containment.h +++ b/containment.h @@ -402,6 +402,7 @@ class PLASMA_EXPORT Containment : public Applet /** * Emitted when the containment requests zooming in or out one step. + * @deprecated */ void zoomRequested(Plasma::Containment *containment, Plasma::ZoomDirection direction); @@ -608,8 +609,6 @@ class PLASMA_EXPORT Containment : public Applet Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle)) Q_PRIVATE_SLOT(d, void positionToolBox()) - Q_PRIVATE_SLOT(d, void zoomIn()) - Q_PRIVATE_SLOT(d, void zoomOut()) Q_PRIVATE_SLOT(d, void requestConfiguration()) Q_PRIVATE_SLOT(d, void updateToolBoxVisibility()) Q_PRIVATE_SLOT(d, void showDropZoneDelayed()) diff --git a/paintutils.cpp b/paintutils.cpp index cf7b933c6..2fe794d4a 100644 --- a/paintutils.cpp +++ b/paintutils.cpp @@ -181,8 +181,6 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) return from; } - int value = int(0xff * amount); - QPixmap startPixmap(from); QPixmap targetPixmap(to); diff --git a/private/containment_p.h b/private/containment_p.h index ac821dd55..7de9c5704 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -85,8 +85,6 @@ public: void handleDisappeared(AppletHandle *handle); void appletDestroyed(Plasma::Applet*); void appletAppearAnimationComplete(); - void zoomIn(); - void zoomOut(); void clearDataForMimeJob(KIO::Job *job); void remoteAppletReady(Plasma::AccessAppletJob *job); void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype); diff --git a/private/desktoptoolbox.cpp b/private/desktoptoolbox.cpp index 4a4ca23b7..80ab30e49 100644 --- a/private/desktoptoolbox.cpp +++ b/private/desktoptoolbox.cpp @@ -49,51 +49,33 @@ class EmptyGraphicsItem : public QGraphicsWidget { public: EmptyGraphicsItem(QGraphicsItem *parent) - : QGraphicsWidget(parent), - m_toolbar(true) + : QGraphicsWidget(parent) { setAcceptsHoverEvents(true); m_layout = new QGraphicsLinearLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(0); m_background = new Plasma::FrameSvg(this); - setIsToolbar(false); + m_background->setImagePath("widgets/background"); + m_background->setEnabledBorders(FrameSvg::AllBorders); + m_layout->setOrientation(Qt::Vertical); + updateMargins(); } ~EmptyGraphicsItem() { } - void setIsToolbar(bool toolbar) + void updateMargins() { - if (m_toolbar == toolbar) { - return; - } - - m_toolbar = toolbar; - if (m_toolbar) { - m_background->setImagePath("widgets/toolbox"); - m_background->setEnabledBorders(FrameSvg::LeftBorder|FrameSvg::RightBorder|FrameSvg::BottomBorder); - m_layout->setOrientation(Qt::Horizontal); - } else { - m_background->setImagePath("widgets/background"); - m_background->setEnabledBorders(FrameSvg::AllBorders); - m_layout->setOrientation(Qt::Vertical); - } - qreal left, top, right, bottom; m_background->getMargins(left, top, right, bottom); setContentsMargins(left, top, right, bottom); } - bool isToolbar() const + void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *) { - return m_toolbar; - } - - void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) - { - m_background->paintFrame(p); + m_background->paintFrame(p, option->rect, option->rect); } void clearLayout() @@ -115,9 +97,7 @@ class EmptyGraphicsItem : public QGraphicsWidget } private: - bool m_toolbar; QRectF m_rect; - Plasma::FrameSvg *m_toolbarBackground; Plasma::FrameSvg *m_background; QGraphicsLinearLayout *m_layout; }; @@ -250,7 +230,7 @@ QSize DesktopToolBox::fullHeight() const void DesktopToolBox::toolTipAboutToShow() { - if (isToolbar() || isShowing()) { + if (isShowing()) { return; } @@ -316,10 +296,6 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op Q_UNUSED(option) Q_UNUSED(widget) - if (isToolbar()){ - return; - } - QPainterPath p = shape(); QPoint iconPos; @@ -507,9 +483,7 @@ QGraphicsWidget *DesktopToolBox::toolParent() void DesktopToolBox::showToolBox() { - setFlag(ItemIgnoresTransformations, isToolbar()); - - if (isShowing() && !isToolbar()) { + if (isShowing()) { return; } @@ -518,7 +492,6 @@ void DesktopToolBox::showToolBox() } d->toolBacker->setZValue(zValue() + 1); - d->toolBacker->setIsToolbar(isToolbar()); adjustToolBackerGeometry(); @@ -533,6 +506,7 @@ void DesktopToolBox::showToolBox() void DesktopToolBox::updateToolBox() { + InternalToolBox::updateToolBox(); adjustToolBackerGeometry(); } @@ -555,15 +529,6 @@ void DesktopToolBox::adjustToolBackerGeometry() } else { icon->hide(); } - - if (viewTransform().m11() != Plasma::scalingFactor(Plasma::OverviewZoom) && - (viewTransform().m11() == Plasma::scalingFactor(Plasma::DesktopZoom) || - icon->action() == d->containment->action("add sibling containment") || - icon->action() == d->containment->action("add widgets"))) { - icon->setText(icon->action()->text()); - } else { - icon->setText(QString()); - } } qreal left, top, right, bottom; @@ -609,34 +574,21 @@ void DesktopToolBox::adjustToolBackerGeometry() break; } - if (isToolbar()) { - QPointF topRight; + //kDebug() << "starting at" << x << startY; + d->toolBacker->setPos(x, y); + // now check that it actually fits within the parent's boundaries + QRectF backerRect = mapToParent(d->toolBacker->geometry()).boundingRect(); + QSizeF parentSize = parentWidget()->size(); + if (backerRect.x() < 5) { + d->toolBacker->setPos(mapFromParent(QPointF(5, 0)).x(), y); + } else if (backerRect.right() > parentSize.width() - 5) { + d->toolBacker->setPos(mapFromParent(QPointF(parentSize.width() - 5 - backerRect.width(), 0)).x(), y); + } - //could that cast ever fail? - if (d->containment) { - topRight = d->containment->geometry().bottomRight(); - } else { - topRight = boundingRect().topRight(); - } - - d->toolBacker->setPos(viewTransform().map(mapFromScene(topRight))-QPoint(d->toolBacker->size().width(), 0)); - } else { - //kDebug() << "starting at" << x << startY; - d->toolBacker->setPos(x, y); - // now check that it actually fits within the parent's boundaries - QRectF backerRect = mapToParent(d->toolBacker->geometry()).boundingRect(); - QSizeF parentSize = parentWidget()->size(); - if (backerRect.x() < 5) { - d->toolBacker->setPos(mapFromParent(QPointF(5, 0)).x(), y); - } else if (backerRect.right() > parentSize.width() - 5) { - d->toolBacker->setPos(mapFromParent(QPointF(parentSize.width() - 5 - backerRect.width(), 0)).x(), y); - } - - if (backerRect.y() < 5) { - d->toolBacker->setPos(x, mapFromParent(QPointF(0, 5)).y()); - } else if (backerRect.bottom() > parentSize.height() - 5) { - d->toolBacker->setPos(x, mapFromParent(QPointF(0, parentSize.height() - 5 - backerRect.height())).y()); - } + if (backerRect.y() < 5) { + d->toolBacker->setPos(x, mapFromParent(QPointF(0, 5)).y()); + } else if (backerRect.bottom() > parentSize.height() - 5) { + d->toolBacker->setPos(x, mapFromParent(QPointF(0, parentSize.height() - 5 - backerRect.height())).y()); } } @@ -644,7 +596,7 @@ void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { //kDebug() << event->pos() << event->scenePos() // << d->toolBacker->rect().contains(event->scenePos().toPoint()); - if (!d->hovering || isShowing() || isToolbar()) { + if (!d->hovering || isShowing()) { QGraphicsItem::hoverLeaveEvent(event); return; } @@ -656,14 +608,6 @@ void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void DesktopToolBox::hideToolBox() { - foreach (QGraphicsItem *tool, tools()) { - const int height = static_cast(tool->boundingRect().height()); - if (isToolbar()) { - tool->setPos(toolPosition(height)); - tool->hide(); - } - } - if (d->toolBacker) { Plasma::Animation *fadeAnim = Animator::create(Animator::FadeAnimation, d->toolBacker); connect(fadeAnim, SIGNAL(finished()), this, SLOT(hideToolBacker())); @@ -672,6 +616,8 @@ void DesktopToolBox::hideToolBox() fadeAnim->setProperty("targetOpacity", 0); fadeAnim->start(QAbstractAnimation::DeleteWhenStopped); } + + highlight(false); } void DesktopToolBox::hideToolBacker() @@ -727,10 +673,6 @@ qreal DesktopToolBox::highlight() void DesktopToolBox::toggle() { - if (isToolbar()) { - return; - } - setShowing(!isShowing()); } diff --git a/private/internaltoolbox.cpp b/private/internaltoolbox.cpp index 35666bee7..1059f98d9 100644 --- a/private/internaltoolbox.cpp +++ b/private/internaltoolbox.cpp @@ -50,7 +50,6 @@ public: hidden(false), showing(false), movable(false), - toolbar(false), dragging(false), userMoved(false) {} @@ -65,7 +64,6 @@ public: bool hidden : 1; bool showing : 1; bool movable : 1; - bool toolbar : 1; bool dragging : 1; bool userMoved : 1; }; @@ -263,7 +261,7 @@ QSize InternalToolBox::fullHeight() const void InternalToolBox::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if (!d->movable || (!d->dragging && boundingRect().contains(event->pos())) || isToolbar()) { + if (!d->movable || (!d->dragging && boundingRect().contains(event->pos()))) { return; } @@ -382,21 +380,6 @@ void InternalToolBox::setIsMovable(bool movable) d->movable = movable; } -bool InternalToolBox::isToolbar() const -{ - return d->toolbar; -} - -void InternalToolBox::setIsToolbar(bool toolbar) -{ - d->toolbar = toolbar; -} - -QTransform InternalToolBox::viewTransform() const -{ - return d->viewTransform; -} - void InternalToolBox::setCorner(const Corner corner) { d->corner = corner; @@ -407,25 +390,6 @@ InternalToolBox::Corner InternalToolBox::corner() const return d->corner; } -void InternalToolBox::setViewTransform(const QTransform &transform) -{ - if (d->viewTransform == transform) { - return; - } - - d->viewTransform = transform; - - if (transform.isScaling()) { - d->toolbar = true; - showToolBox(); - } else { - d->toolbar = false; - if (d->viewTransform != transform) { - hideToolBox(); - } - } -} - void InternalToolBox::save(KConfigGroup &cg) const { if (!d->movable) { @@ -451,7 +415,7 @@ void InternalToolBox::save(KConfigGroup &cg) const group.writeEntry("offset", offset); } -void InternalToolBox::load(const KConfigGroup &containmentGroup) +void InternalToolBox::restore(const KConfigGroup &containmentGroup) { if (!d->movable) { return; @@ -508,7 +472,7 @@ void InternalToolBox::reposition() { if (d->userMoved) { //FIXME: adjust for situations like changing of the available space - load(); + restore(); return; } diff --git a/private/internaltoolbox_p.h b/private/internaltoolbox_p.h index e5d47e9db..e4ff55170 100644 --- a/private/internaltoolbox_p.h +++ b/private/internaltoolbox_p.h @@ -79,14 +79,8 @@ public: bool isMovable() const; void setIsMovable(bool movable); - bool isToolbar() const; - void setIsToolbar(bool toolbar); - - QTransform viewTransform() const; - void setViewTransform(const QTransform &transform); - void save(KConfigGroup &cg) const; - void load(const KConfigGroup &containmentGroup = KConfigGroup()); + void restore(const KConfigGroup &containmentGroup = KConfigGroup()); void reposition(); virtual QSize fullWidth() const;