Add components to default tooltip, fix layout

This commit is contained in:
Sebastian Kügler 2013-04-04 01:26:59 +02:00
parent f42192fb9b
commit efd12a5ec1
2 changed files with 49 additions and 8 deletions

View File

@ -19,6 +19,8 @@
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
/**
* This is a Plasma-themed tooltip. It is rendered in its own window
@ -37,6 +39,8 @@ import org.kde.plasma.core 2.0 as PlasmaCore
*/
MouseArea {
property int _s: theme.iconSizes.small / 2
hoverEnabled: true
onEntered: {
print("entere");
@ -73,19 +77,56 @@ MouseArea {
mainItem: PlasmaCore.FrameSvgItem {
id: toolTipSvg
imagePath: "widgets/tooltip"
width: childrenRect.width + 50
height: childrenRect.height + 50
width: childrenRect.width + margins.left + margins.right
height: childrenRect.height + margins.top + margins.bottom
onWidthChanged: print("XXXX ====================================== svgframe width: " + width)
onChildrenRectChanged: print("XXXX childrenRect chagned" + childrenRect.width + " " + childrenRect.height)
Item {
width: 300
height: 200
id: toolTipContentItem
x: toolTipSvg.margins.left
y: toolTipSvg.margins.top
width: childrenRect.width
height: childrenRect.height
anchors {
topMargin: parent.anchors.margins.top
leftMargin: parent.anchors.margins.left
fill: parent
//fill: parent
}
PlasmaCore.IconItem {
id: tooltipIcon
width: theme.iconSizes.desktop
height: width
source: "zanshin"
// anchors {
// left: parent.left
// verticalCenter: parent.verticalCenter
// }
}
PlasmaExtras.Heading {
id: tooltipMaintext
level: 4
text: "Emperor fish sighted"
anchors {
left: tooltipIcon.right
leftMargin: _s
//right: parent.right
top: parent.top
}
}
PlasmaComponents.Label {
id: tooltipSubtext
text: "You've come across a beautiful sea creature"
anchors {
left: tooltipIcon.right
leftMargin: _s
topMargin: _s
//right: parent.right
top: tooltipMaintext.bottom
}
}
id: toolTipContentItem
Rectangle { width: 280; height: 140; color: "orange"; }
}

View File

@ -221,7 +221,7 @@ void ToolTipWindow::setMainItem(QQuickItem *mainItem)
//resize(mainItem->width(), mainItem->height());
resize(200, 200);
resize(400, 200);
if (m_mainItem.data() != mainItem) {
if (m_mainItem) {
m_mainItem.data()->setParent(parent());