diff --git a/CMakeLists.txt b/CMakeLists.txt index c8635a3de..29f9bde96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,38 +212,8 @@ set(plasma_LIB_SRCS # # private/declarative/declarativenetworkaccessmanagerfactory.cpp # private/declarative/dataenginebindings.cpp -# graphicsview/private/animablegraphicswebview.cpp -# graphicsview/private/focusindicator.cpp -# graphicsview/private/nativetabbar.cpp -# graphicsview/private/style.cpp -# graphicsview/private/kineticscroll.cpp # -# widgets/label.cpp -# widgets/scrollbar.cpp -# widgets/svgwidget.cpp -# widgets/scrollwidget.cpp -# widgets/textedit.cpp -# widgets/textbrowser.cpp -# widgets/busywidget.cpp -# widgets/checkbox.cpp -# widgets/combobox.cpp # widgets/declarativewidget.cpp -# widgets/flashinglabel.cpp -# widgets/frame.cpp -# widgets/groupbox.cpp -# widgets/itembackground.cpp -# widgets/lineedit.cpp -# widgets/meter.cpp -# widgets/pushbutton.cpp -# widgets/radiobutton.cpp -# widgets/signalplotter.cpp -# widgets/slider.cpp -# widgets/spinbox.cpp -# widgets/toolbutton.cpp -# widgets/separator.cpp -# widgets/tabbar.cpp -# widgets/treeview.cpp -# widgets/webview.cpp # ) kconfig_add_kcfg_files(plasma_LIB_SRCS data/kconfigxt/libplasma-theme-global.kcfgc) @@ -342,35 +312,6 @@ install(FILES ${plasma_LIB_INCLUDES} DESTINATION ${INCLUDE_INSTALL_DIR}/plasma COMPONENT Devel) -install(FILES - widgets/checkbox.h - widgets/combobox.h - widgets/declarativewidget.h - widgets/flashinglabel.h - widgets/frame.h - widgets/groupbox.h - widgets/iconwidget.h - widgets/itembackground.h - widgets/label.h - widgets/lineedit.h - widgets/meter.h - widgets/pushbutton.h - widgets/toolbutton.h - widgets/radiobutton.h - widgets/scrollbar.h - widgets/signalplotter.h - widgets/slider.h - widgets/spinbox.h - widgets/busywidget.h - widgets/separator.h - widgets/svgwidget.h - widgets/scrollwidget.h - widgets/tabbar.h - widgets/textbrowser.h - widgets/treeview.h - widgets/textedit.h - widgets/webview.h - DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/widgets COMPONENT Devel) install(FILES scripting/appletscript.h @@ -380,13 +321,6 @@ install(FILES scripting/scriptengine.h DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/scripting COMPONENT Devel) -if(PHONON_FOUND) - install (FILES - widgets/videowidget.h - DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/widgets COMPONENT Devel) -endif(PHONON_FOUND) - - install(FILES data/servicetypes/plasma-applet.desktop data/servicetypes/plasma-applet-popupapplet.desktop diff --git a/graphicsview/private/animablegraphicswebview.cpp b/graphicsview/private/animablegraphicswebview.cpp deleted file mode 100644 index 744cd2fdb..000000000 --- a/graphicsview/private/animablegraphicswebview.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * Copyright 2010 Davide Bettio - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "animablegraphicswebview_p.h" - -#include -#include -#include -#include - -#include -#include - -using namespace Plasma; - -AnimableGraphicsWebView::AnimableGraphicsWebView(QGraphicsItem * parent) - : GraphicsWebViewBase(parent) -{ - setAcceptTouchEvents(true); - m_dragToScroll = false; -} - -void AnimableGraphicsWebView::setDragToScroll(bool enable) -{ - m_dragToScroll = enable; -} - -bool AnimableGraphicsWebView::dragToScroll() const -{ - return m_dragToScroll; -} - -QSizeF AnimableGraphicsWebView::contentsSize() const -{ - if (!page()) { - return QSizeF(); - } else { - return page()->mainFrame()->contentsSize(); - } -} - -void AnimableGraphicsWebView::setScrollPosition(const QPointF &position) -{ - if (!page()) { - return; - } else { - page()->mainFrame()->setScrollPosition(position.toPoint()); - } -} - -QPointF AnimableGraphicsWebView::scrollPosition() const -{ - if (!page() || !page()->mainFrame()) { - return QPointF(); - } else { - return page()->mainFrame()->scrollPosition(); - } -} - -qreal AnimableGraphicsWebView::zoom() const -{ - return GraphicsWebViewBase::zoomFactor(); -} - -void AnimableGraphicsWebView::setZoom(const qreal zoom) -{ - GraphicsWebViewBase::setZoomFactor(zoom); -} - -QRectF AnimableGraphicsWebView::viewportGeometry() const -{ - QRectF result; - if (!page()) { - return result; - } else { - return page()->mainFrame()->geometry(); - } -} - -void AnimableGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (!page()) { - GraphicsWebViewBase::mouseMoveEvent(event); - return; - } - - if (m_dragToScroll) { - return; - } - - QMouseEvent me(QEvent::MouseMove, event->pos().toPoint(), event->button(), - event->buttons(), event->modifiers()); - page()->event(&me); - - if (me.isAccepted()) { - event->accept(); - } -} - -void AnimableGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if (!page()) { - GraphicsWebViewBase::mousePressEvent(event); - return; - } - - m_lastScrollPosition = scrollPosition(); - setFocus(); - - QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(), - event->button(), event->buttons(), event->modifiers()); - - page()->event(&me); - if (me.isAccepted() && !m_dragToScroll) { - event->accept(); - } -} - -void AnimableGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if (!page()) { - GraphicsWebViewBase::mouseReleaseEvent(event); - return; - } - - QMouseEvent me(QEvent::MouseButtonRelease, event->pos().toPoint(), - event->button(),event->buttons(), event->modifiers()); - - if (!m_dragToScroll || (scrollPosition() - m_lastScrollPosition).manhattanLength() < QApplication::startDragDistance()) { - page()->event(&me); - } - - if (me.isAccepted() && !m_dragToScroll) { - event->accept(); - } -} - -void AnimableGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - if (!page()) { - GraphicsWebViewBase::wheelEvent(event); - return; - } - - QWheelEvent we(event->pos().toPoint(), event->delta(), event->buttons(), - event->modifiers(), event->orientation()); - page()->event(&we); - - event->setAccepted(!m_dragToScroll); -} - -qreal AnimableGraphicsWebView::scrollPositionX() const -{ - return page()->mainFrame()->scrollPosition().x(); -} - -void AnimableGraphicsWebView::setScrollPositionX(qreal position) -{ - QPointF pt(position, scrollPositionY()); - setScrollPosition(pt); -} - -qreal AnimableGraphicsWebView::scrollPositionY() const -{ - return page()->mainFrame()->scrollPosition().y(); -} - -void AnimableGraphicsWebView::setScrollPositionY(qreal position) -{ - QPointF pt(scrollPositionX(), position); - setScrollPosition(pt); -} - - -#include "moc_animablegraphicswebview_p.cpp" - diff --git a/graphicsview/private/animablegraphicswebview_p.h b/graphicsview/private/animablegraphicswebview_p.h deleted file mode 100644 index 5b199b43d..000000000 --- a/graphicsview/private/animablegraphicswebview_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * Copyright 2010 Davide Bettio - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef ANIMABLEWEBVIEW_P_H -#define ANIMABLEWEBVIEW_P_H - -#include -#include -#include -#include -#include - -#include - -#if !PLASMA_NO_KDEWEBKIT -#include -#define GraphicsWebViewBase KGraphicsWebView -#else -#include -#define GraphicsWebViewBase QGraphicsWebView -#endif - -namespace Plasma -{ - -class AnimableGraphicsWebView : public GraphicsWebViewBase -{ - Q_OBJECT - - Q_PROPERTY(qreal zoomFactor READ zoom WRITE setZoom) - Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition) - Q_PROPERTY(qreal scrollPositionX READ scrollPositionX WRITE setScrollPositionX) - Q_PROPERTY(qreal scrollPositionY READ scrollPositionY WRITE setScrollPositionY) - Q_PROPERTY(QSizeF contentsSize READ contentsSize) - Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry) - -public: - AnimableGraphicsWebView(QGraphicsItem * parent = 0); - - QPointF scrollPosition() const; - void setScrollPosition(const QPointF &position); - qreal scrollPositionX() const; - void setScrollPositionX(qreal position); - qreal scrollPositionY() const; - void setScrollPositionY(qreal position); - QSizeF contentsSize() const; - QRectF viewportGeometry() const; - void setDragToScroll(bool enable); - bool dragToScroll() const; - qreal zoom() const; - void setZoom(const qreal zoom); - -protected: - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void wheelEvent(QGraphicsSceneWheelEvent *event); - -private: - bool m_dragToScroll; - QPointF m_lastScrollPosition; -}; - -} - -#endif diff --git a/graphicsview/private/corona_p.h b/graphicsview/private/corona_p.h deleted file mode 100644 index 1012b8e36..000000000 --- a/graphicsview/private/corona_p.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2007-2011 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_CORONA_P_H -#define PLASMA_CORONA_P_H - -#include - -#include - -class KShortcutsDialog; - -namespace Plasma -{ - -class Containment; -class Corona; - -class CoronaPrivate -{ -public: - CoronaPrivate(Corona *corona); - ~CoronaPrivate(); - - void init(); - void offscreenWidgetDestroyed(QObject *); - - static bool s_positioningContainments; - - Corona *q; - QHash offscreenWidgets; - CoronaBase *coronaBase; -}; - -} - -#endif diff --git a/graphicsview/private/focusindicator.cpp b/graphicsview/private/focusindicator.cpp deleted file mode 100644 index 05f678d8a..000000000 --- a/graphicsview/private/focusindicator.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2009 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "focusindicator_p.h" - -#include -#include -#include -#include - -#include -#include - -#include - -namespace Plasma -{ - -FocusIndicator::FocusIndicator(QGraphicsWidget *parent, const QString &widget) - : QGraphicsWidget(parent), - m_parent(parent), - m_background(new Plasma::FrameSvg(this)), - m_isUnderMouse(false) -{ - m_background->setImagePath(widget); - init(parent); -} - -FocusIndicator::FocusIndicator(QGraphicsWidget *parent, FrameSvg *svg) - : QGraphicsWidget(parent), - m_parent(parent), - m_background(svg), - m_isUnderMouse(false) -{ - init(parent); -} - -void FocusIndicator::init(QGraphicsWidget *parent) -{ - setVisible(!Theme::defaultTheme()->useNativeWidgetStyle()); - setFlag(QGraphicsItem::ItemStacksBehindParent); - setAcceptsHoverEvents(true); - - m_background->setCacheAllRenderedFrames(true); - - m_fade = Animator::create(Animator::FadeAnimation, this); - m_fade->setTargetWidget(this); - m_fade->setProperty("startOpacity", 0.0); - m_fade->setProperty("targetOpacity", 1.0); - - m_hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation); - m_hoverAnimation->setProperty("duration", 250); - m_hoverAnimation->setTargetWidget(this); - - m_testPrefix = "hover"; - if (m_background->hasElementPrefix("shadow") || - m_background->hasElement("shadow")) { - m_prefix = "shadow"; - } - - parent->installEventFilter(this); - connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(syncGeometry())); -} - -FocusIndicator::~FocusIndicator() -{ - m_parent->removeEventFilter(this); - delete m_fade; -} - -void FocusIndicator::setCustomGeometry(const QRectF &geometry) -{ - if (m_customGeometry == geometry) { - return; - } - - m_customGeometry = geometry; - syncGeometry(); -} - -void FocusIndicator::setCustomPrefix(const QString &prefix) -{ - QString was = m_prefix; - if (!m_prefix.isEmpty() && !m_customPrefix.isEmpty()) { - m_prefix.remove(m_customPrefix); - } - - m_customPrefix = prefix; - - if (!m_prefix.isEmpty()) { - m_prefix.prepend(m_customPrefix); - } - - m_testPrefix = m_customPrefix % "hover"; - if (m_prefix.isEmpty()) { - m_prefix = m_customPrefix % "shadow"; - } - - if (m_prefix == was) { - return; - } - - syncGeometry(); - resizeEvent(0); -} - -bool FocusIndicator::eventFilter(QObject *watched, QEvent *event) -{ - if (Theme::defaultTheme()->useNativeWidgetStyle() || - static_cast(watched) != m_parent || !m_parent ) { - return false; - } - - if (event->type() == QEvent::GraphicsSceneHoverEnter) { - m_isUnderMouse = true; - } else if (event->type() == QEvent::GraphicsSceneHoverLeave) { - m_isUnderMouse = false; - } - - switch (event->type()) { - case QEvent::GraphicsSceneHoverEnter: - if (!m_parent->hasFocus()) { - m_prefix = m_customPrefix % "hover"; - syncGeometry(); - m_hoverAnimation->stop(); - if (m_background->hasElementPrefix(m_testPrefix)) { - m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_background->setElementPrefix(m_customPrefix % "hover"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "hover")); - } - - m_hoverAnimation->start(); - } - break; - - case QEvent::GraphicsSceneHoverLeave: - if (!m_parent->hasFocus()) { - m_prefix = m_customPrefix % "shadow"; - syncGeometry(); - m_hoverAnimation->stop(); - - if (m_background->hasElementPrefix(m_testPrefix)) { - m_background->setElementPrefix(m_customPrefix % "hover"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "hover")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow")); - } - m_hoverAnimation->start(); - } - break; - - case QEvent::GraphicsSceneResize: - syncGeometry(); - break; - - case QEvent::FocusIn: - m_prefix = m_customPrefix % "focus"; - syncGeometry(); - m_hoverAnimation->stop(); - - if (m_background->hasElementPrefix(m_customPrefix % "focus")) { - //m_background->setElementPrefix(m_customPrefix % "shadow"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_background->setElementPrefix(m_customPrefix % "focus"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_customPrefix % "focus")) { - //m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "focus")); - } - - m_hoverAnimation->start(); - break; - - case QEvent::FocusOut: - if (!m_isUnderMouse) { - m_prefix = m_customPrefix % "shadow"; - syncGeometry(); - m_hoverAnimation->stop(); - - if (m_background->hasElementPrefix(m_customPrefix % "focus")) { - m_background->setElementPrefix("focus"); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_background->setElementPrefix("shadow"); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_customPrefix % "focus")) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "focus")); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow")); - } - - m_hoverAnimation->start(); - } - break; - - default: - break; - }; - - return false; -} - -void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *) -{ - if (m_background->hasElementPrefix(m_customPrefix % "shadow")) { - m_background->setElementPrefix(m_customPrefix % "shadow"); - m_background->resizeFrame(size()); - } - - if (m_background->hasElementPrefix(m_customPrefix % "hover")) { - m_background->setElementPrefix(m_customPrefix % "hover"); - m_background->resizeFrame(size()); - } - - if (m_background->hasElementPrefix(m_customPrefix % "focus")) { - m_background->setElementPrefix(m_customPrefix % "focus"); - m_background->resizeFrame(size()); - } - - if (m_hoverAnimation->state() == QAbstractAnimation::Running) { - m_hoverAnimation->stop(); - } - - if (m_background->hasElementPrefix(m_testPrefix)) { - m_background->setElementPrefix(m_prefix); - m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap()); - m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap()); - } else if (m_background->hasElement(m_testPrefix)) { - m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_prefix)); - m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_prefix)); - } -} - -void FocusIndicator::animateVisibility(const bool visible) -{ - m_fade->setProperty("startOpacity", opacity()); - - if (visible) { - m_fade->setProperty("targetOpacity", 1.0); - } else { - m_fade->setProperty("targetOpacity", 0); - } - m_fade->start(); -} - -void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option) - Q_UNUSED(widget) - - painter->drawPixmap( - option->rect, - m_hoverAnimation->property("currentPixmap").value()); -} - -void FocusIndicator::syncGeometry() -{ - if (Theme::defaultTheme()->useNativeWidgetStyle()) { - hide(); - return; - } else if (!isVisible()) { - show(); - } - - QRectF geom; - if (!m_customGeometry.isEmpty()) { - geom = m_customGeometry; - } else { - geom = m_parent->boundingRect(); - } - - if (m_background->hasElementPrefix(m_testPrefix)) { - //always take borders from hover to make it stable - m_background->setElementPrefix(m_testPrefix); - qreal left, top, right, bottom; - m_background->getMargins(left, top, right, bottom); - m_background->setElementPrefix(m_prefix); - setGeometry(QRectF(geom.topLeft() + QPointF(-left, -top), geom.size() + QSize(left+right, top+bottom))); - } else if (m_background->hasElement(m_testPrefix)) { - QRectF elementRect = m_background->elementRect(m_testPrefix); - elementRect.moveCenter(geom.center()); - setGeometry(elementRect); - } -} - -void FocusIndicator::setFrameSvg(FrameSvg *frameSvg) -{ - if (m_background != frameSvg) { - m_background = frameSvg; - } -} - -FrameSvg *FocusIndicator::frameSvg() const -{ - return m_background; -} - -} - -#include "moc_focusindicator_p.cpp" - diff --git a/graphicsview/private/focusindicator_p.h b/graphicsview/private/focusindicator_p.h deleted file mode 100644 index 12a81d088..000000000 --- a/graphicsview/private/focusindicator_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2009 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PLASMA_FOCUSINDICATOR_P -#define PLASMA_FOCUSINDICATOR_P - -#include - -#include - -namespace Plasma -{ - class FrameSvg; - class FadeAnimation; - -class FocusIndicator : public QGraphicsWidget -{ - Q_OBJECT -public: - FocusIndicator(QGraphicsWidget *parent, const QString &widget); - FocusIndicator(QGraphicsWidget *parent, FrameSvg *svg); - ~FocusIndicator(); - - void setCustomGeometry(const QRectF &geometry); - void setCustomPrefix(const QString &prefix); - - void animateVisibility(const bool visible); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - void setFrameSvg(FrameSvg *svg); - FrameSvg *frameSvg() const; - -protected: - bool eventFilter(QObject *watched, QEvent *event); - void resizeEvent(QGraphicsSceneResizeEvent *event); - -private Q_SLOTS: - void syncGeometry(); - -private: - void init(QGraphicsWidget *parent); - QGraphicsWidget *m_parent; - Plasma::FrameSvg *m_background; - Animation *m_fade; - Animation *m_hoverAnimation; - QRectF m_customGeometry; - QString m_prefix; - QString m_customPrefix; - QString m_testPrefix; - bool m_isUnderMouse; -}; -} -#endif diff --git a/graphicsview/private/graphicsviewappletprivate.cpp b/graphicsview/private/graphicsviewappletprivate.cpp deleted file mode 100644 index 66c4a4c6e..000000000 --- a/graphicsview/private/graphicsviewappletprivate.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright 2011 by Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "graphicsviewappletprivate_p.h" - -#include -#include - -#include "kwindowsystem.h" - -#include "corona.h" -#include "dialog.h" -#include "paintutils.h" -#include "popupapplet.h" -#include "theme.h" -#include "tooltipmanager.h" -#include "widgets/busywidget.h" -#include "widgets/iconwidget.h" -#include "widgets/label.h" -#include "widgets/pushbutton.h" - -namespace Plasma -{ - -GraphicsViewAppletPrivate::GraphicsViewAppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet) - : AppletPrivate(service, info, uniqueID, applet), - messageOverlay(0), - messageOverlayProxy(0), - busyWidget(0) -{ - q->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - q->setAcceptsHoverEvents(true); - q->setFlag(QGraphicsItem::ItemIsFocusable, true); - q->setFocusPolicy(Qt::ClickFocus); - // FIXME: adding here because nothing seems to be doing it in QGraphicsView, - // but it doesn't actually work anyways =/ - q->setLayoutDirection(qApp->layoutDirection()); -} - -void GraphicsViewAppletPrivate::showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons) -{ - if (message.isEmpty()) { - destroyMessageOverlay(); - return; - } - - Corona *corona = qobject_cast(q->scene()); - QGraphicsWidget *mainWidget = new QGraphicsWidget; - - QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(mainWidget); - mainLayout->setOrientation(Qt::Vertical); - mainLayout->addStretch(); - - QGraphicsLinearLayout *messageLayout = new QGraphicsLinearLayout(); - messageLayout->setOrientation(Qt::Horizontal); - - QGraphicsLinearLayout *buttonLayout = new QGraphicsLinearLayout(); - buttonLayout->setOrientation(Qt::Horizontal); - - mainLayout->addItem(messageLayout); - mainLayout->addItem(buttonLayout); - mainLayout->addStretch(); - - IconWidget *messageIcon = new IconWidget(mainWidget); - Label *messageText = new Label(mainWidget); - messageText->nativeWidget()->setWordWrap(true); - - messageLayout->addStretch(); - messageLayout->addItem(messageIcon); - messageLayout->addItem(messageText); - messageLayout->addStretch(); - - messageIcon->setIcon(icon); - messageText->setText(message); - - buttonLayout->addStretch(); - - if (buttons & ButtonOk) { - messageOkButton = new PushButton(mainWidget); - messageOkButton.data()->setText(i18n("&OK")); - messageOkButton.data()->setIcon(KDE::icon("dialog-ok")); - buttonLayout->addItem(messageOkButton.data()); - QObject::connect(messageOkButton.data(), SIGNAL(clicked()), q, SLOT(destroyMessageOverlay())); - } - - if (buttons & ButtonYes) { - messageYesButton = new PushButton(mainWidget); - messageYesButton.data()->setText(i18n("&Yes")); - buttonLayout->addItem(messageYesButton.data()); - QObject::connect(messageYesButton.data(), SIGNAL(clicked()), q, SLOT(destroyMessageOverlay())); - } - - if (buttons & ButtonNo) { - messageNoButton = new PushButton(mainWidget); - messageNoButton.data()->setText(i18n("&No")); - buttonLayout->addItem(messageNoButton.data()); - QObject::connect(messageNoButton.data(), SIGNAL(clicked()), q, SLOT(destroyMessageOverlay())); - } - - if (buttons & ButtonCancel) { - messageCancelButton = new PushButton(mainWidget); - messageCancelButton.data()->setText(i18n("&Cancel")); - messageCancelButton.data()->setIcon(KDE::icon("dialog-cancel")); - buttonLayout->addItem(messageCancelButton.data()); - QObject::connect(messageCancelButton.data(), SIGNAL(clicked()), q, SLOT(destroyMessageOverlay())); - } - - messageCloseAction = new QAction(messageOverlay); - messageCloseAction.data()->setShortcut(Qt::Key_Escape); - mainWidget->addAction(messageCloseAction.data()); - QObject::connect(messageCloseAction.data(), SIGNAL(triggered()), q, SLOT(destroyMessageOverlay())); - - buttonLayout->addStretch(); - - mainWidget->adjustSize(); - QSizeF hint = mainWidget->preferredSize(); - if (hint.height() > q->size().height() || hint.width() > q->size().width()) { - // either a collapsed popup in h/v form factor or just too small, - // so show it in a dialog associated with ourselves - if (corona) { - corona->addOffscreenWidget(mainWidget); - } - - if (messageDialog) { - delete messageDialog.data()->graphicsWidget(); - } else { - messageDialog = new Plasma::Dialog; - } - - ToolTipManager::self()->hide(q); - KWindowSystem::setOnAllDesktops(messageDialog.data()->winId(), true); - KWindowSystem::setState(messageDialog.data()->winId(), NET::SkipTaskbar | NET::SkipPager); - messageDialog.data()->setGraphicsWidget(mainWidget); - QObject::connect(messageDialog.data(), SIGNAL(destroyed(QObject*)), mainWidget, SLOT(deleteLater())); - - // if we are going to show it in a popup, then at least make sure it can be dismissed - if (buttonLayout->count() < 1) { - PushButton *ok = new PushButton(mainWidget); - ok->setText(i18n("OK")); - ok->setIcon(KDE::icon("dialog-ok")); - buttonLayout->addItem(ok); - QObject::connect(ok, SIGNAL(clicked()), q, SLOT(destroyMessageOverlay())); - } - } else { - delete messageDialog.data(); - createMessageOverlay(); - messageOverlay->opacity = 0.8; - mainWidget->setParentItem(messageOverlay); - QGraphicsLinearLayout *l = new QGraphicsLinearLayout(messageOverlay); - l->addItem(mainWidget); - } - - if (messageDialog) { - QPoint pos = q->geometry().topLeft().toPoint(); - if (corona) { - pos = corona->popupPosition(q, messageDialog.data()->size()); - } - - messageDialog.data()->move(pos); - messageDialog.data()->animatedShow(locationToDirection(q->location())); - } else { - messageOverlay->show(); - } -} - -void GraphicsViewAppletPrivate::updateFailedToLaunch(const QString &reason) -{ - if (failed == failed) { - if (failed && !reason.isEmpty()) { - foreach (QGraphicsItem *item, q->QGraphicsItem::children()) { - Label *l = dynamic_cast