fully working
This commit is contained in:
parent
6d9f9afcad
commit
f30b2da11b
@ -33,6 +33,8 @@ FullScreenSheet::FullScreenSheet(QDeclarativeItem *parent)
|
||||
view()->setGeometry(QApplication::desktop()->availableGeometry());
|
||||
|
||||
if (mainItem()) {
|
||||
connect(mainItem(), SIGNAL(titleChanged()),
|
||||
this, SIGNAL(titleChanged()));
|
||||
connect(mainItem(), SIGNAL(acceptButtonChanged()),
|
||||
this, SIGNAL(acceptButtonChanged()));
|
||||
connect(mainItem(), SIGNAL(rejectButtonChanged()),
|
||||
@ -48,32 +50,48 @@ FullScreenSheet::~FullScreenSheet()
|
||||
{
|
||||
}
|
||||
|
||||
QGraphicsObject *FullScreenSheet::acceptButton() const
|
||||
QString FullScreenSheet::title() const
|
||||
{
|
||||
if (mainItem()) {
|
||||
return mainItem()->property("acceptButton").value<QGraphicsObject *>();
|
||||
return mainItem()->property("title").toString();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenSheet::setAcceptButton(QGraphicsObject *button)
|
||||
void FullScreenSheet::setTitle(const QString &text)
|
||||
{
|
||||
if (mainItem()) {
|
||||
mainItem()->setProperty("title", QVariant::fromValue(text));
|
||||
}
|
||||
}
|
||||
|
||||
QDeclarativeItem *FullScreenSheet::acceptButton() const
|
||||
{
|
||||
if (mainItem()) {
|
||||
return mainItem()->property("acceptButton").value<QDeclarativeItem *>();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenSheet::setAcceptButton(QDeclarativeItem *button)
|
||||
{
|
||||
if (mainItem()) {
|
||||
mainItem()->setProperty("acceptButton", QVariant::fromValue(button));
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsObject *FullScreenSheet::rejectButton() const
|
||||
QDeclarativeItem *FullScreenSheet::rejectButton() const
|
||||
{
|
||||
if (mainItem()) {
|
||||
return mainItem()->property("rejectButton").value<QGraphicsObject *>();
|
||||
return mainItem()->property("rejectButton").value<QDeclarativeItem *>();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenSheet::setRejectButton(QGraphicsObject *button)
|
||||
void FullScreenSheet::setRejectButton(QDeclarativeItem *button)
|
||||
{
|
||||
if (mainItem()) {
|
||||
mainItem()->setProperty("rejectButton", QVariant::fromValue(button));
|
||||
@ -112,5 +130,14 @@ void FullScreenSheet::setRejectButtonText(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenSheet::open()
|
||||
{
|
||||
if (mainItem()) {
|
||||
view()->setGeometry(QApplication::desktop()->availableGeometry());
|
||||
QMetaObject::invokeMethod(mainItem(), "open");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "fullscreensheet.moc"
|
||||
|
||||
|
@ -24,8 +24,10 @@
|
||||
class FullScreenSheet : public FullScreenWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QGraphicsObject *acceptButton READ acceptButton WRITE setAcceptButton NOTIFY acceptButtonChanged)
|
||||
Q_PROPERTY(QGraphicsObject *rejectButton READ rejectButton WRITE setRejectButton NOTIFY rejectButtonChanged)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
|
||||
|
||||
Q_PROPERTY(QDeclarativeItem *acceptButton READ acceptButton WRITE setAcceptButton NOTIFY acceptButtonChanged)
|
||||
Q_PROPERTY(QDeclarativeItem *rejectButton READ rejectButton WRITE setRejectButton NOTIFY rejectButtonChanged)
|
||||
|
||||
Q_PROPERTY(QString acceptButtonText READ acceptButtonText WRITE setAcceptButtonText NOTIFY acceptButtonTextChanged)
|
||||
Q_PROPERTY(QString rejectButtonText READ rejectButtonText WRITE setRejectButtonText NOTIFY rejectButtonTextChanged)
|
||||
@ -34,11 +36,14 @@ public:
|
||||
FullScreenSheet(QDeclarativeItem *parent = 0);
|
||||
~FullScreenSheet();
|
||||
|
||||
QGraphicsObject *acceptButton() const;
|
||||
void setAcceptButton(QGraphicsObject *button);
|
||||
QString title() const;
|
||||
void setTitle(const QString &text);
|
||||
|
||||
QGraphicsObject *rejectButton() const;
|
||||
void setRejectButton(QGraphicsObject *button);
|
||||
QDeclarativeItem *acceptButton() const;
|
||||
void setAcceptButton(QDeclarativeItem *button);
|
||||
|
||||
QDeclarativeItem *rejectButton() const;
|
||||
void setRejectButton(QDeclarativeItem *button);
|
||||
|
||||
QString acceptButtonText() const;
|
||||
void setAcceptButtonText(const QString &text);
|
||||
@ -46,7 +51,10 @@ public:
|
||||
QString rejectButtonText() const;
|
||||
void setRejectButtonText(const QString &text);
|
||||
|
||||
Q_INVOKABLE void open();
|
||||
|
||||
Q_SIGNALS:
|
||||
void titleChanged();
|
||||
void acceptButtonChanged();
|
||||
void rejectButtonChanged();
|
||||
void acceptButtonTextChanged();
|
||||
|
@ -55,10 +55,14 @@ EngineBookKeeping *EngineBookKeeping::self()
|
||||
}
|
||||
|
||||
QDeclarativeEngine *EngineBookKeeping::engineFor(QObject *item) const
|
||||
{return m_engines.values().first();
|
||||
{
|
||||
//for components creation, any engine will do, as long is valid
|
||||
return m_engines.values().first();
|
||||
/*
|
||||
foreach (QDeclarativeEngine *engine, m_engines) {
|
||||
QObject *root = engine->rootContext()->contextObject();
|
||||
QObject *candidate = item;
|
||||
|
||||
while (candidate) {
|
||||
if (candidate == root) {
|
||||
return engine;
|
||||
@ -66,14 +70,20 @@ QDeclarativeEngine *EngineBookKeeping::engineFor(QObject *item) const
|
||||
candidate = candidate->parent();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
void EngineBookKeeping::insertEngine(QDeclarativeEngine *engine)
|
||||
{
|
||||
connect(engine, SIGNAL(destroyed(QObject *)), this, SLOT(engineDestroyed(QObject *deleted)));
|
||||
m_engines.insert(engine);
|
||||
}
|
||||
|
||||
void EngineBookKeeping::engineDestroyed(QObject *deleted)
|
||||
{
|
||||
m_engines.remove(static_cast<QDeclarativeEngine *>(deleted));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PlasmaComponentsPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
|
||||
|
@ -27,8 +27,10 @@ class QDeclarativeEngine;
|
||||
class QDeclarativeItem;
|
||||
class PlasmaComponentsPlugin;
|
||||
|
||||
class EngineBookKeeping
|
||||
class EngineBookKeeping : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EngineBookKeeping();
|
||||
static EngineBookKeeping *self();
|
||||
@ -36,6 +38,9 @@ public:
|
||||
void insertEngine(QDeclarativeEngine *engine);
|
||||
QDeclarativeEngine *engineFor(QObject *item) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void engineDestroyed(QObject *deleted);
|
||||
|
||||
private:
|
||||
QSet <QDeclarativeEngine*> m_engines;
|
||||
};
|
||||
|
@ -47,11 +47,11 @@ import "." 0.1
|
||||
|
||||
Item {
|
||||
id: root
|
||||
width: 600
|
||||
height: 200
|
||||
width: 800
|
||||
height: 600
|
||||
onHeightChanged:print(height)
|
||||
|
||||
property alias title: titleBar.children
|
||||
property alias title: titleLabel.text
|
||||
property alias content: contentItem.children
|
||||
// property alias visualParent: dialog.visualParent
|
||||
property int status: DialogStatus.Closed
|
||||
@ -139,14 +139,44 @@ Item {
|
||||
Keys.onPressed: event.accepted = true
|
||||
Keys.onReleased: event.accepted = true
|
||||
|
||||
Item {
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: titleBar
|
||||
imagePath: "widgets/extender-dragger"
|
||||
prefix: "root"
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
//FIXME: +5 because of Plasma::Dialog margins
|
||||
height: titleLabel.paintedHeight + margins.top + margins.bottom
|
||||
|
||||
height: childrenRect.height
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
Column {
|
||||
id: titleLayoutHelper // needed to make the text mirror correctly
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
leftMargin: parent.margins.left
|
||||
rightMargin: parent.margins.right
|
||||
topMargin: parent.margins.top
|
||||
bottomMargin: parent.margins.bottom
|
||||
}
|
||||
|
||||
Label {
|
||||
id: titleLabel
|
||||
elide: Text.ElideRight
|
||||
height: paintedHeight
|
||||
font.pointSize: theme.defaultFont.pointSize * 1.1
|
||||
font.weight: Font.Bold
|
||||
style: Text.Raised
|
||||
styleColor: Qt.rgba(1,1,1,0.8)
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ import "." 0.1
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property alias title: titleBar.children
|
||||
property alias title: titleLabel.text
|
||||
property alias content: contentItem.children
|
||||
// property alias visualParent: dialog.visualParent
|
||||
property int status: DialogStatus.Closed
|
||||
@ -160,6 +160,7 @@ Item {
|
||||
PlasmaCore.Dialog {
|
||||
id: dialog
|
||||
windowFlags: Qt.Dialog
|
||||
location: 4 //FIXME: replace with BottomEdge when we have an enum reachable from everywhere in core
|
||||
|
||||
|
||||
//onFaderClicked: root.clickedOutside()
|
||||
@ -178,20 +179,50 @@ Item {
|
||||
mainItem: Item {
|
||||
id: mainItem
|
||||
width: theme.defaultFont.mSize.width * 40
|
||||
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonsRow.childrenRect.height + 8
|
||||
height: Math.max(titleBar.childrenRect.height + contentItem.childrenRect.height + buttonsRow.childrenRect.height + 8, theme.defaultFont.mSize.height * 25)
|
||||
|
||||
// Consume all key events that are not processed by children
|
||||
Keys.onPressed: event.accepted = true
|
||||
Keys.onReleased: event.accepted = true
|
||||
|
||||
Item {
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: titleBar
|
||||
imagePath: "widgets/extender-dragger"
|
||||
prefix: "root"
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
//FIXME: +5 because of Plasma::Dialog margins
|
||||
height: titleLabel.paintedHeight + margins.top + margins.bottom
|
||||
|
||||
height: childrenRect.height
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
Column {
|
||||
id: titleLayoutHelper // needed to make the text mirror correctly
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
leftMargin: parent.margins.left
|
||||
rightMargin: parent.margins.right
|
||||
topMargin: parent.margins.top
|
||||
bottomMargin: parent.margins.bottom
|
||||
}
|
||||
|
||||
Label {
|
||||
id: titleLabel
|
||||
elide: Text.ElideRight
|
||||
height: paintedHeight
|
||||
font.pointSize: theme.defaultFont.pointSize * 1.1
|
||||
font.weight: Font.Bold
|
||||
style: Text.Raised
|
||||
styleColor: Qt.rgba(1,1,1,0.8)
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ ScrollBar 0.1 ScrollBar.qml
|
||||
SectionScroller 0.1 SectionScroller.qml
|
||||
SelectionDialog 0.1 SelectionDialog.qml
|
||||
Slider 0.1 Slider.qml
|
||||
Sheet 0.1 Sheet.qml
|
||||
Switch 0.1 Switch.qml
|
||||
TabBar 0.1 TabBar.qml
|
||||
TabButton 0.1 TabButton.qml
|
||||
|
Loading…
x
Reference in New Issue
Block a user