plasma-framework/declarativeimports/plasmaextracomponents/qml/App.qml

168 lines
4.8 KiB
QML
Raw Normal View History

2012-03-16 03:38:04 +01:00
/*
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library 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 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
2012-03-16 03:38:04 +01:00
import org.kde.plasma.components 0.1 as PlasmaComponents
2012-12-17 23:39:31 +01:00
/**
* This is a container for Apps. Navigation and Content area layout can vary
* depending on the available size. This class can be used as top level Item or
* inside your top-level item. It will manage context or navigation area,
* content area and toolbars in a way consistent with other apps, and adaptive
* to the device.
*
* @remark App is experimental, its API might change.
*
* Example usage:
* @code
* import QtQuick 1.1
* import org.kde.plasma.core 0.1 as PlasmaCore
* import org.kde.plasma.extras 0.1 as PlasmaExtras
*
* PlasmaExtras.App {
* id: app
* width: 800
* height: 600
*
* navigation: navigationItem
* content: contentItem
*
* Item {
* id: navigationItem
* // [...] this is the navigation area
* }
*
* Loader {
* id: contentItem
* source: "gallery/Extras.qml"
* parent: contentArea
* }
* }
* @endcode
*/
2012-03-16 03:38:04 +01:00
Item {
id: app
2012-12-17 23:39:31 +01:00
/**
* type:Item
* Navigation or Context Area.
*/
2012-03-16 03:38:04 +01:00
property alias navigation: navigationItem.children
2012-12-17 23:39:31 +01:00
/**
* type:Item
* The "main view"
*/
2012-03-16 03:38:04 +01:00
property alias content: contentItem.children
2012-12-17 23:39:31 +01:00
/**
* type:Item
* the topBar's ToolBar.tools
*/
property alias tools: topBar.tools
property alias contentArea: contentBackground
2012-03-20 02:48:40 +01:00
property int space: 20
2012-03-16 03:38:04 +01:00
property int navigationWidth: 340
property int contentWidth: app.width - navigationWidth - space*2
2012-03-16 03:38:04 +01:00
PlasmaCore.Theme { id: theme }
PlasmaComponents.ToolBar {
id: topBar
2012-03-20 02:23:11 +01:00
height: visible ? 48 : 0
//visible: tools.id != "undefined"
anchors { top: parent.top; left: parent.left; right: parent.right; }
2012-03-20 02:23:11 +01:00
//tools: PlasmaComponents.ToolBarLayout {}
onToolsChanged: {
2012-03-20 02:48:40 +01:00
// FIXME: questionable heuristics
2012-04-02 17:45:41 +02:00
height = (tools && tools.childrenRect.width > 20) ? tools.childrenRect.height + space : 0
2012-03-20 02:23:11 +01:00
}
}
2012-03-16 03:38:04 +01:00
Image {
id: contentBackground
2012-03-20 02:01:03 +01:00
anchors { left: navigationBackground.right; right: parent.right; top: topBar.bottom; bottom: parent.bottom; }
2012-03-16 03:38:04 +01:00
source: "image://appbackgrounds/standard"
fillMode: Image.Tile
asynchronous: true
//width: contentWidth
2012-03-16 03:38:04 +01:00
Item {
id: contentItem
2012-03-20 02:48:40 +01:00
//width: contentWidth - 100
2012-03-16 03:38:04 +01:00
height: app.height
2012-03-20 02:48:40 +01:00
anchors { left: parent.left; margins: space; top: parent.top; bottom: parent.bottom; right: parent.right; }
2012-03-16 03:38:04 +01:00
}
}
Image {
id: navigationBackground
anchors { left: parent.left; top: topBar.bottom; bottom: parent.bottom; }
2012-03-16 03:38:04 +01:00
source: "image://appbackgrounds/contextarea"
fillMode: Image.Tile
asynchronous: true
clip: true
width: navigationWidth + space
Behavior on width {
NumberAnimation { duration: 250; easing.type: Easing.InOutExpo; }
}
2012-03-16 03:38:04 +01:00
Item {
2012-04-02 17:45:41 +02:00
clip: true
2012-03-16 03:38:04 +01:00
id: navigationItem
anchors.fill: parent
}
}
Image {
source: "image://appbackgrounds/shadow-left"
2012-03-16 03:38:04 +01:00
fillMode: Image.Tile
anchors {
right: navigationBackground.right
top: topBar.bottom
2012-03-16 03:38:04 +01:00
bottom: parent.bottom
leftMargin: -1
}
}
Image {
source: "image://appbackgrounds/shadow-bottom"
fillMode: Image.Tile
anchors {
right: navigationBackground.right
left: navigationBackground.left
top: topBar.bottom
//bottom: parent.bottom
//leftMargin: -1
}
}
onContentChanged: {
print("content changed to ");
//content.parent = contentBackground;
//contentItem.width = contentWidth;
//contentItem.anchors.rightMargin = 100
}
2012-03-16 03:38:04 +01:00
onNavigationWidthChanged: {
navigationBackground.width = navigationWidth;
navigationItem.width = navigationWidth;
}
}