diff --git a/declarativeimports/plasmacomponents/fullscreendialog.cpp b/declarativeimports/plasmacomponents/fullscreendialog.cpp index 8a2f36ca4..9a4325f92 100644 --- a/declarativeimports/plasmacomponents/fullscreendialog.cpp +++ b/declarativeimports/plasmacomponents/fullscreendialog.cpp @@ -21,6 +21,7 @@ #include "../core/declarativeitemcontainer_p.h" #include "plasmacomponentsplugin.h" +#include #include #include #include @@ -29,16 +30,57 @@ #include #include #include -#include +#include #include #include #include +#include uint FullScreenDialog::s_numItems = 0; +class Background : public QWidget +{ +public: + Background(FullScreenDialog *dialog) + : QWidget( 0L ), + m_dialog(dialog) + { + setAttribute( Qt::WA_NoSystemBackground ); + setAttribute( Qt::WA_TranslucentBackground ); + + setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint); + KWindowSystem::setOnAllDesktops(winId(), true); + unsigned long state = NET::Sticky | NET::StaysOnTop | NET::KeepAbove | NET::SkipTaskbar | NET::SkipPager | NET::MaxVert | NET::MaxHoriz; + KWindowSystem::setState(effectiveWinId(), state); + } + + ~Background() + {} + + void paintEvent( QPaintEvent *e ) + { + QPainter painter( this ); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(e->rect(), QColor(0, 0, 0, 80)); + } + + void mousePressEvent(QMouseEvent *event) + { + event->accept(); + } + + void mouseReleaseEvent(QMouseEvent *event) + { + m_dialog->close(); + } + +private: + FullScreenDialog *m_dialog; +}; + FullScreenDialog::FullScreenDialog(QDeclarativeItem *parent) : QDeclarativeItem(parent), m_declarativeItemContainer(0) @@ -53,10 +95,10 @@ FullScreenDialog::FullScreenDialog(QDeclarativeItem *parent) m_view->setAttribute(Qt::WA_NoSystemBackground); m_view->viewport()->setAttribute(Qt::WA_NoSystemBackground); m_view->setCacheMode(QGraphicsView::CacheNone); - m_view->setWindowFlags(m_view->windowFlags() | Qt::FramelessWindowHint | Qt::CustomizeWindowHint); + m_view->setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint); m_view->setFrameShape(QFrame::NoFrame); KWindowSystem::setOnAllDesktops(m_view->winId(), true); - unsigned long state = NET::Sticky | NET::StaysOnTop | NET::KeepAbove | NET::SkipTaskbar | NET::SkipPager | NET::MaxVert | NET::MaxHoriz; + unsigned long state = NET::Sticky | NET::StaysOnTop | NET::KeepAbove | NET::SkipTaskbar | NET::SkipPager; KWindowSystem::setState(m_view->effectiveWinId(), state); //Try to figure out the path of the dialog component @@ -102,6 +144,8 @@ FullScreenDialog::FullScreenDialog(QDeclarativeItem *parent) connect(m_rootObject.data(), SIGNAL(rejected()), this, SIGNAL(rejected())); connect(m_rootObject.data(), SIGNAL(clickedOutside()), this, SIGNAL(clickedOutside())); } + + m_background = new Background(this); } FullScreenDialog::~FullScreenDialog() @@ -183,15 +227,16 @@ void FullScreenDialog::syncMainItem() if (m_declarativeItemContainer) { - m_declarativeItemContainer->resize(m_view->size()); + m_view->resize(m_declarativeItemContainer->size().toSize()); m_view->setSceneRect(m_declarativeItemContainer->geometry()); } else { - m_mainItem.data()->setProperty("width", m_view->size().width()); - m_mainItem.data()->setProperty("height", m_view->size().height()); QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()), QSizeF(m_mainItem.data()->boundingRect().size())); + m_view->resize(itemGeometry.size().toSize()); m_view->setSceneRect(itemGeometry); } + + m_view->move(QApplication::desktop()->availableGeometry().center() - QPoint(m_view->width()/2, m_view->height()/2)); } bool FullScreenDialog::isVisible() const @@ -202,11 +247,9 @@ bool FullScreenDialog::isVisible() const void FullScreenDialog::setVisible(const bool visible) { if (m_view->isVisible() != visible) { + m_background->setVisible(visible); m_view->setVisible(visible); if (visible) { - unsigned long state = NET::Sticky | NET::StaysOnTop | NET::KeepAbove | NET::SkipTaskbar | NET::SkipPager | NET::MaxVert | NET::MaxHoriz; - m_view->setVisible(visible); - KWindowSystem::setState(m_view->effectiveWinId(), state); m_view->raise(); } } @@ -292,9 +335,13 @@ void FullScreenDialog::close() bool FullScreenDialog::eventFilter(QObject *watched, QEvent *event) { - if (watched == m_view && - (event->type() == QEvent::Resize || event->type() == QEvent::Move)) { + if (watched == m_mainItem.data() && + (event->type() == QEvent::GraphicsSceneResize)) { syncMainItem(); + } else if (watched == m_view && event->type() == QEvent::Show) { + Plasma::WindowEffects::slideWindow(m_view->winId(), Plasma::BottomEdge, 0); + } else if (watched == m_view && event->type() == QEvent::Hide) { + Plasma::WindowEffects::slideWindow(m_view->winId(), Plasma::BottomEdge, 0); } return false; } diff --git a/declarativeimports/plasmacomponents/fullscreendialog.h b/declarativeimports/plasmacomponents/fullscreendialog.h index da79fe6a3..88d9a9061 100644 --- a/declarativeimports/plasmacomponents/fullscreendialog.h +++ b/declarativeimports/plasmacomponents/fullscreendialog.h @@ -32,6 +32,7 @@ class QGraphicsObject; class QGraphicsView; class QGraphicsScene; class DeclarativeItemContainer; +class Background; class FullScreenDialog : public QDeclarativeItem { @@ -86,6 +87,7 @@ private: QGraphicsScene *m_scene; QWeakPointer m_rootObject; static uint s_numItems; + Background *m_background; //those only used in case of error, to not make plasma crash QList m_dummyTitleElements; diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml index e9af7b8cf..9e9fc8d90 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml @@ -47,6 +47,8 @@ import "." 0.1 Item { id: root + width: dialog.width + height: dialog.height property alias title: titleBar.children property alias content: contentItem.children @@ -91,12 +93,7 @@ Item { dialog.state = "closed" } - Rectangle { - id: fader - property double alpha: 0 - color: Qt.rgba(0.0, 0.0, 0.0, alpha) - anchors.fill: parent - } + MouseArea { anchors.fill: parent onClicked: { @@ -120,10 +117,6 @@ Item { state: "closed" - transform: Translate { - id: dialogTransform - y: root.height - dialog.y - } //state: "Hidden" Item { @@ -183,65 +176,18 @@ Item { State { name: "closed" PropertyChanges { - target: dialogTransform - y: root.height - dialog.y - } - PropertyChanges { - target: fader - alpha: 0 + target: root + status: DialogStatus.Closed } }, State { name: "" PropertyChanges { - target: dialogTransform - y: 0 - } - PropertyChanges { - target: fader - alpha: 0.6 + target: root + status: DialogStatus.Open } } ] - transitions: [ - // Transition between open and closed states. - Transition { - from: "" - to: "closed" - reversible: false - SequentialAnimation { - ScriptAction { - script: root.status = DialogStatus.Closing - } - PropertyAnimation { - properties: "y, alpha" - easing.type: Easing.InOutQuad - duration: 250 - } - ScriptAction { - script: root.status = DialogStatus.Closed - } - } - }, - Transition { - from: "closed" - to: "" - reversible: false - SequentialAnimation { - ScriptAction { - script: root.status = DialogStatus.Opening - } - PropertyAnimation { - properties: "y, alpha" - easing.type: Easing.InOutQuad - duration: 250 - } - ScriptAction { - script: root.status = DialogStatus.Open - } - } - } - ] } }