From 409a2ac82c8c3261b1c91241ae612a9d4699d827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Tue, 20 Mar 2012 02:23:11 +0100 Subject: [PATCH] basic toolbar hiding and showing --- .../plasmaextracomponents/qml/App.qml | 21 ++++++++++++++++--- declarativeimports/test/gallery/Extras.qml | 5 ++++- declarativeimports/test/gallery/Gallery.qml | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/declarativeimports/plasmaextracomponents/qml/App.qml b/declarativeimports/plasmaextracomponents/qml/App.qml index 73edbb8fa..0c371b37a 100644 --- a/declarativeimports/plasmaextracomponents/qml/App.qml +++ b/declarativeimports/plasmaextracomponents/qml/App.qml @@ -29,9 +29,12 @@ Description: This is a container for Apps. Navigation and Content area layout can vary depending on the available size. + Note that App is experimental, its API might change + Properties: Item navigation: Navigation or Context Area. Item content: The "main view" + ToolBarLayout tools: alias to the topBar's ToolBar.tools Methods: @@ -43,7 +46,6 @@ Signals: import QtQuick 1.1 import org.kde.plasma.core 0.1 as PlasmaCore import org.kde.plasma.components 0.1 as PlasmaComponents -//import org.kde.plasma.extras 0.1 as PlasmaExtras Item { id: app @@ -61,9 +63,22 @@ Item { PlasmaComponents.ToolBar { id: topBar - height: 48 + height: visible ? 48 : 0 + //visible: tools.id != "undefined" anchors { top: parent.top; left: parent.left; right: parent.right; } - tools: PlasmaComponents.ToolBarLayout {} + //tools: PlasmaComponents.ToolBarLayout {} + + onToolsChanged: { + //print("tools changed:" + typeof(tools) + " " + tools.id); + var shown; + // FIXME: Horrible hack, improve heuristics here. + if (tools.childrenRect.width > 20) { + shown = true; + } else { + shown = false; + } + visible = shown; + } } Image { diff --git a/declarativeimports/test/gallery/Extras.qml b/declarativeimports/test/gallery/Extras.qml index 73d48780c..347733b5f 100644 --- a/declarativeimports/test/gallery/Extras.qml +++ b/declarativeimports/test/gallery/Extras.qml @@ -28,7 +28,10 @@ Column { title: "Plasma Components API documentation" } - + ToolBarLayout { + id: toolbarlayout + Component.onCompleted: app.tools = toolbarlayout + } //anchors.fill: parent anchors.margins: space width: 600 diff --git a/declarativeimports/test/gallery/Gallery.qml b/declarativeimports/test/gallery/Gallery.qml index f5ef9039d..2dd72428b 100644 --- a/declarativeimports/test/gallery/Gallery.qml +++ b/declarativeimports/test/gallery/Gallery.qml @@ -24,7 +24,7 @@ import org.kde.plasma.extras 0.1 as PlasmaExtras PlasmaExtras.App { id: app width: 1000 - height: 800 + height: 600 navigationWidth: 200 property string formFactor: "tablet"