primitive support for popups.
is now using the horrible Window elements, when Dialog will be portedit will look definitely less broken
This commit is contained in:
parent
95c82d3e82
commit
1263ada92a
@ -372,6 +372,65 @@ QStringList AppletInterface::downloadedFiles() const
|
|||||||
return dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable);
|
return dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||||
|
{
|
||||||
|
Q_UNUSED(oldGeometry)
|
||||||
|
|
||||||
|
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
||||||
|
|
||||||
|
if (!m_uiObject || qobject_cast<ContainmentInterface *>(this)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: completely arbitrary for now
|
||||||
|
if (newGeometry.width() < 100 || newGeometry.height() < 100) {
|
||||||
|
//we are already an icon: nothing to do
|
||||||
|
if (m_compactUiObject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QQmlComponent *component = new QQmlComponent(m_appletScriptEngine->engine(), this);
|
||||||
|
component->loadUrl(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "CompactApplet.qml")));
|
||||||
|
m_compactUiObject = component->create();
|
||||||
|
|
||||||
|
if (m_compactUiObject) {
|
||||||
|
//for memory management
|
||||||
|
component->setParent(m_compactUiObject.data());
|
||||||
|
|
||||||
|
//replace the full applet with the collapsed view
|
||||||
|
m_compactUiObject.data()->setProperty("visible", true);
|
||||||
|
m_compactUiObject.data()->setProperty("parent", QVariant::fromValue(this));
|
||||||
|
//set anchors
|
||||||
|
QQmlExpression expr(m_appletScriptEngine->engine()->rootContext(), m_compactUiObject.data(), "parent");
|
||||||
|
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
|
||||||
|
prop.write(expr.evaluate());
|
||||||
|
|
||||||
|
m_uiObject.data()->setProperty("parent", QVariant::fromValue(m_compactUiObject.data()));
|
||||||
|
m_compactUiObject.data()->setProperty("applet", QVariant::fromValue(m_uiObject.data()));
|
||||||
|
|
||||||
|
//failed to create UI, don't do anything
|
||||||
|
} else {
|
||||||
|
qWarning() << component->errors();
|
||||||
|
delete component;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//we are already expanded: nothing to do
|
||||||
|
if (!m_compactUiObject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_uiObject.data()->setProperty("parent", QVariant::fromValue(this));
|
||||||
|
m_compactUiObject.data()->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////// ContainmentInterface
|
///////////// ContainmentInterface
|
||||||
|
|
||||||
@ -463,6 +522,7 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPoi
|
|||||||
if (applet && contGraphicObject && appletGraphicObject) {
|
if (applet && contGraphicObject && appletGraphicObject) {
|
||||||
appletGraphicObject->setProperty("visible", false);
|
appletGraphicObject->setProperty("visible", false);
|
||||||
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
appletGraphicObject->setProperty("parent", QVariant::fromValue(contGraphicObject));
|
||||||
|
|
||||||
//if an appletGraphicObject is not set, we have to display some error message
|
//if an appletGraphicObject is not set, we have to display some error message
|
||||||
} else if (applet && contGraphicObject) {
|
} else if (applet && contGraphicObject) {
|
||||||
QQmlComponent *component = new QQmlComponent(m_appletScriptEngine->engine(), applet);
|
QQmlComponent *component = new QQmlComponent(m_appletScriptEngine->engine(), applet);
|
||||||
|
@ -215,6 +215,8 @@ Q_SIGNALS:
|
|||||||
void busyChanged();
|
void busyChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
|
||||||
|
|
||||||
DeclarativeAppletScript *m_appletScriptEngine;
|
DeclarativeAppletScript *m_appletScriptEngine;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -226,6 +228,7 @@ private:
|
|||||||
|
|
||||||
//UI-specific members ------------------
|
//UI-specific members ------------------
|
||||||
QWeakPointer<QObject> m_uiObject;
|
QWeakPointer<QObject> m_uiObject;
|
||||||
|
QWeakPointer<QObject> m_compactUiObject;
|
||||||
|
|
||||||
Plasma::BackgroundHints m_backgroundHints;
|
Plasma::BackgroundHints m_backgroundHints;
|
||||||
bool m_busy : 1;
|
bool m_busy : 1;
|
||||||
|
51
shell/qmlpackages/desktop/contents/ui/CompactApplet.qml
Normal file
51
shell/qmlpackages/desktop/contents/ui/CompactApplet.qml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Window 2.0
|
||||||
|
|
||||||
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
color: "darkgreen"
|
||||||
|
|
||||||
|
property Item applet
|
||||||
|
|
||||||
|
|
||||||
|
onAppletChanged: applet.parent = appletParent
|
||||||
|
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: popupWindow.visible = !popupWindow.visible
|
||||||
|
}
|
||||||
|
|
||||||
|
Window {
|
||||||
|
id: popupWindow
|
||||||
|
visible: false
|
||||||
|
width: 200
|
||||||
|
height: 200
|
||||||
|
Item {
|
||||||
|
id: appletParent
|
||||||
|
width: applet.implicitWidth
|
||||||
|
height: applet.implicitHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -53,23 +53,26 @@ Rectangle {
|
|||||||
id: frame
|
id: frame
|
||||||
x: 50
|
x: 50
|
||||||
y: 50
|
y: 50
|
||||||
width: 150
|
width: 200
|
||||||
height: 150
|
height: 200
|
||||||
|
|
||||||
property alias applet: appletContainer.children
|
property alias applet: appletContainer.children
|
||||||
property int small: 100
|
property int small: 100
|
||||||
property int large: parent.width - width - 150
|
property int large: root.width /2
|
||||||
imagePath: applet[0].backgroundHints == 0 ? "" : "widgets/background"
|
imagePath: applet[0].backgroundHints == 0 ? "" : "widgets/background"
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
drag.target: parent
|
drag.target: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var s = (frame.x == frame.large) ? frame.small : frame.large;
|
var s = (frame.width == frame.large) ? frame.small : frame.large;
|
||||||
frame.x = s
|
frame.x = s
|
||||||
frame.height = s
|
frame.height = s
|
||||||
|
frame.width = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
||||||
//Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
//Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } }
|
||||||
|
Behavior on width { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
|
||||||
Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
|
Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
Loading…
Reference in New Issue
Block a user