/*
* Copyright 2012-2015 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
/*!
\qmltype MainView
\inqmlmodule Lomiri.Components 1.2
\ingroup lomiri
\brief MainView is the root Item that should be used for all applications.
It automatically adds a header and toolbar for its contents and can
rotate its content based on the device orientation.
The simplest way to use a MainView is to include a single \l Page object
inside the MainView:
\qml
import QtQuick 2.4
import Lomiri.Components 1.2
MainView {
width: units.gu(48)
height: units.gu(60)
Page {
title: "Simple page"
Button {
anchors.centerIn: parent
text: "Push me"
width: units.gu(15)
onClicked: print("Click!")
}
}
}
\endqml
It is not required to set the anchors of the \l Page as it will automatically fill its parent.
The MainView has a header that automatically shows the title of the \l Page.
Do not include multiple Pages directly inside the MainView, but use \l Tabs
or \l PageStack inside MainView to navigate between several Pages.
For the MainView to automatically rotate its content following the orientation
of the device, set the \l automaticOrientation property to true.
If the \l Page inside the MainView includes a Flickable with enough contents for scrolling,
the header will automatically hide and show when the user scrolls up or down:
\qml
import QtQuick 2.4
import Lomiri.Components 1.2
MainView {
width: units.gu(48)
height: units.gu(60)
Page {
title: "Page with Flickable"
Flickable {
anchors.fill: parent
contentHeight: column.height
Column {
id: column
Repeater {
model: 100
Label {
text: "line "+index
}
}
}
}
}
}
\endqml
The same header behavior is automatic when using a ListView instead of a Flickable in the above
example.
The examples above show how to include a single \l Page inside a MainView, but more
advanced application structures are possible using \l PageStack and \l Tabs.
*/
/*!
\qmlproperty string MainView::applicationName
The property holds the application's name, which must be the same as the
desktop file's name.
The name also sets the name of the QCoreApplication and defaults for data
and cache folders that work on the desktop and under confinement, as well as
the default gettext domain.
C++ code that writes files may use QStandardPaths::writableLocation with
QStandardPaths::DataLocation or QStandardPaths::CacheLocation.
*/
/*!
\qmlproperty bool MainView::anchorToKeyboard
The property holds if the application should automatically resize the
contents when the input method appears
The default value is false.
*/
/*!
\qmlproperty color MainView::headerColor
Color of the header's background.
\sa backgroundColor, footerColor
*/
/*!
\qmlproperty color MainView::backgroundColor
Color of the background.
The background is usually a single color. However if \l headerColor
or \l footerColor are set then a gradient of colors will be drawn.
For example, in order for the MainView to draw a color gradient beneath
the content:
\qml
import QtQuick 2.4
import Lomiri.Components 1.2
MainView {
width: units.gu(40)
height: units.gu(60)
headerColor: "#343C60"
backgroundColor: "#6A69A2"
footerColor: "#8896D5"
}
\endqml
\sa footerColor, headerColor
*/
/*!
\qmlproperty color MainView::footerColor
Color of the footer's background.
\sa backgroundColor, headerColor
*/
/*!
\qmlproperty bool MainView::active
MainView is active by default.
*/
/*!
\qmlproperty bool MainView::automaticOrientation
Sets whether the application will be automatically rotating when the
device is.
The default value is false.
*/
/*!
\deprecated
\qmlproperty bool MainView::useDeprecatedToolbar
Setting this option will enable the old toolbar, and disable the new features
that are being added to the new header. Unsetting it removes the toolbar and
enables developers to have a sneak peek at the new features that are coming to
the header, even before all the required functionality is implemented.
Default value up to version 1.1: true.
NOT AVAILABLE in version 1.2 where the deprecated toolbar is not supported.
*/
/*!
\qmlproperty list MainView::actions
A global list of actions that will be available to the system (including HUD)
as long as the application is running. For actions that are not always available to the
system, but only when a certain \l Page is active, see the actions property of \l Page.
*/
/*!
\qmlproperty ActionManager MainView::actionManager
\readonly
The ActionManager that supervises the global and local ActionContexts.
The \l actions property should be used preferably since it covers most
use cases. The ActionManager is accessible to have a more refined control
over the actions, e.g. if one wants to add/remove actions dynamically, create
specific action contexts, etc.
*/