Skip to content

Commit

Permalink
[Documentation] Add or improve documentation for many classes
Browse files Browse the repository at this point in the history
- Document the following classes:
  * Action
  * ActionButton
  * ApplicationWindow
  * AppTheme
- Fix lint errors for awesome.js
  • Loading branch information
iBelieve committed Apr 22, 2015
1 parent e895591 commit 34ce227
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 112 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Material Design implemented in QtQuick

[![Join the chat at https://gitter.im/papyros/qml-material](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/papyros/qml-material?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![License](https://img.shields.io/badge/license-LGPLv3%2B-blue.svg)](https://img.shields.io/badge/license-LGPL%203%2B-blue.svg)
[![License](https://img.shields.io/badge/license-LGPLv2.1%2B-blue.svg)](https://img.shields.io/badge/license-LGPL%203%2B-blue.svg)
[![GitHub release](https://img.shields.io/github/release/papyros/qml-material.svg)](https://github.com/papyros/qml-material)
[![Build Status](https://travis-ci.org/papyros/qml-material.svg?branch=develop)](https://travis-ci.org/papyros/qml-material)
[![GitHub issues](https://img.shields.io/github/issues/papyros/qml-material.svg)](https://github.com/papyros/qml-material/issues)
Expand All @@ -30,4 +30,4 @@ Now checkout out the `examples` folder to see how to use Material Design from Qt

### Licensing

QML Material is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
QML Material is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
10 changes: 10 additions & 0 deletions demo/SubPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ Page {
"Inbox"
]

actionBar {
customContent: TextField {
placeholderText: "Custom action bar content..."

anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}

// TabView is simply a customized ListView
// You can use any model/delegate for the tab contents,
// but a VisualItemModel works well
Expand Down
Binary file added documentation/images/buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion documentation/material.qdocconf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ description = Material Design for QtQuick Documentation
sourcedirs = ./
sourcedirs += ../modules/Material/
sourcedirs += ../modules/Material/ListItems
sourcedirs += ../modules/Material/Transitions
exampledirs += snippets
imagedirs = images
sources.fileextensions = "*.qml *.qdoc *.cpp"
Expand Down
46 changes: 26 additions & 20 deletions modules/Material/Action.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* QML Material - An application framework implementing Material Design.
* Copyright (C) 2014 Michael Spencer
* Copyright (C) 2014-2015 Michael Spencer <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand All @@ -23,49 +23,55 @@
\ingroup material
\brief Represents an action shown in an action bar, context menu, or list.
One of the most common uses of actions is displaying actions in the action bar of a page
using the \l Page::actions property. See the example for \l Page for more details.
*/
QtObject {
id: action

/*!
The text displayed for the action.
*/
property string name
/*!
Set to \c false to disable the action.
*/
property bool enabled: true

/*!
Set to \c true to display a divider between this action and the next action. Used in lists
or context menus.
*/
property bool hasDividerAfter

/*!
The icon displayed for the action. This can be a Material Design icon or an icon from
FontAwesome. See \l Icon from more details.
*/
property string iconName

/*!
A string representation of a keybinding, for example, "Ctrl+Shift+A" or "Alt+T".
*/
property string keybinding

/*!
The text displayed for the action.
*/
property string name

/*!
A short summary of the action, which may be displayed depending on the UI showing the
action. For example, a list of actions could display the summary as the secondary line of
text.
*/
property string summary

/*!
Set to \c true to display a divider between this action and the next action. Used in lists
or context menus.
*/
property bool hasDividerAfter

/*!
Set to \c false to hide the action in the UI.
*/
property bool visible: true

/*!
Set to \c false to disable the action.
Called when the UI representing the action is triggered. \c caller contains the UI element
that triggered the action.
*/
property bool enabled: true

property string keybinding

/*!
Called when the UI representing the action is triggered. \c caller contains the UI element
that triggered the action.
*/
signal triggered(var caller)
}
126 changes: 86 additions & 40 deletions modules/Material/ActionBar.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* QML Material - An application framework implementing Material Design.
* Copyright (C) 2014-2015 Michael Spencer <[email protected]>
* 2015 Ricardo Vieira <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand All @@ -27,9 +28,13 @@ import Material.ListItems 0.1 as ListItem
\brief An action bar holds the title and actions displayed in the application toolbar.
The reason this exists separately from \l Toolbar is for animation purposes. Each page contains
its own \c ActionBar, and when the application transitions between pages, the toolbar animates
the transition between action bars.
The reason this exists separately from \l Toolbar is for animation purposes.
Each page contains its own \c ActionBar, and when the application transitions
between pages, the toolbar animates the transition between action bars.
Normally, you don't need to manually create an instance of this class, and just
use the instance provided by the page. See the example in the \l Page documentation
for more details.
*/
Item {
id: actionBar
Expand All @@ -43,46 +48,89 @@ Item {
right: parent.right
}

property bool hidden: false
/*!
A list of actions to show in the action bar. These actions will be shown
anchored to the right, and will overflow if there are more than the
maximum number of actions as defined in \l maxActionCount.
When used with a page, the actions will be set to the page's \l Page::actions
property, so set that instead of changing this directly.
*/
property list<Action> actions

/*!
\internal
The page holding this \c ActionBar
The back action to display to the left of the title in the action bar.
When used with a page, this will pick up the page's back action, which
by default is a back arrow when there is a page behind the current page
on the page stack. However, you can customize this, for example, to show
a navigation drawer at the root of your app.
When using an action bar in a page, set the \l Page::backAction instead of
directly setting this property.
*/
property Item page
property Action backAction

/*!
The maximum number of actions that can be displayed before they spill over into a drop-down
menu. By default this inherits from the global \l Toolbar::maxActionCount.
*/
property int maxActionCount: toolbar ? toolbar.maxActionCount : 3
/*!
The background color for the toolbar when the action bar's page is active.
By default this is the primary color defined in \l Theme::primaryColor
*/
property color backgroundColor: Theme.primaryColor

property Item toolbar
/*!
\qmlproperty Item customContent
/*!
\internal
The action bar in the toolbar will only be shown if the page is not card-style. In that case,
there is a separate action bar in the card.
*/
property bool showContents: page != undefined && !page.cardStyle
A custom view to show instead of the title in the action bar.
*/
property alias customContent: customContentView.data

/*!
The background color for the toolbar when the action bar's page is active. By default this is
the primary color defined in \l Theme::primaryColor
*/
property color backgroundColor: Theme.primaryColor
/*!
\qmlproperty Item extendedContent
A custom view to show under the row containing the title and actions.
Causes the action bar to be extend in height to contain this view.
*/
property alias extendedContent: extendedContentView.data

/*!
The elevation of the action bar. Set to 0 if you want have a header or some
other view below the action bar that you want to appear as part of the action bar.
*/
property int elevation: 2

property alias title: label.text
/*!
\internal
The height of the extended content view.
*/
readonly property int extendedHeight: extendedContentView.childrenRect.height

property Action backAction: page ? page.backAction : undefined
/*!
Set to true to hide the action bar. This is used when displaying an
action bar in a toolbar through the use of a page and the page stack.
If you are using an action bar for custom purposes, set the opacity or visibility
instead.
*/
property bool hidden: false

property alias customContent: customContentView.data
/*!
The maximum number of actions that can be displayed before they spill over
into a drop-down menu. When using an action bar with a page, this inherits
from the global \l Toolbar::maxActionCount. If you are using an action bar
for custom purposes outside of a toolbar, this defaults to \c 3.
*/
property int maxActionCount: toolbar ? toolbar.maxActionCount : 3

property alias extendedContent: extendedContentView.data
/*!
The title displayed in the action bar. When used in a page, the title will
be set to the title of the page, so set the \l Page::title property instead
of changing this directly.
*/
property string title

readonly property int extendedHeight: extendedContentView.childrenRect.height
/*!
\internal
The toolbar containing this action bar.
*/
property Item toolbar

IconButton {
id: leftItem
Expand All @@ -100,16 +148,15 @@ Item {
color: Theme.lightDark(actionBar.backgroundColor, Theme.light.iconColor,
Theme.dark.iconColor)
size: units.dp(24)
action: page.backAction
action: backAction

opacity: show ? enabled ? 1 : 0.3 : 0

Behavior on opacity {
NumberAnimation { duration: 200 }
}

property bool show: backAction && backAction.visible &&
(!page || !page.cardStyle || !showContents)
property bool show: backAction && backAction.visible
}

Label {
Expand All @@ -129,7 +176,7 @@ Item {

visible: customContentView.children.length == 0

text: showContents ? page.title : ""
text: actionBar.title
style: "title"
color: Theme.lightDark(actionBar.backgroundColor, Theme.light.textColor,
Theme.dark.textColor)
Expand All @@ -148,14 +195,13 @@ Item {
spacing: units.dp(24)

Repeater {
model: !showContents ? []
: page.actions.length > maxActionCount
? maxActionCount - 1 : page.actions.length
model: actions.length > maxActionCount ? maxActionCount - 1
: actions.length

delegate: IconButton {
id: iconAction

action: page.actions[index]
action: actions[index]

color: Theme.lightDark(actionBar.backgroundColor, Theme.light.iconColor,
Theme.dark.iconColor)
Expand All @@ -171,7 +217,7 @@ Item {
size: units.dp(27)
color: Theme.lightDark(actionBar.backgroundColor, Theme.light.iconColor,
Theme.dark.iconColor)
visible: showContents && page && page.actions.length > maxActionCount
visible: actions.length > maxActionCount
anchors.verticalCenter: parent.verticalCenter

onClicked: overflowMenu.open(overflowButton, units.dp(4), units.dp(-4))
Expand Down Expand Up @@ -211,12 +257,12 @@ Item {
anchors.centerIn: parent

Repeater {
model: page.actions.length - (maxActionCount - 1)
model: actions.length - (maxActionCount - 1)

ListItem.Standard {
id: listItem

property Action actionItem: page.actions[index + maxActionCount - 1]
property Action actionItem: actions[index + maxActionCount - 1]

text: actionItem.name
iconName: actionItem.iconName
Expand Down
31 changes: 29 additions & 2 deletions modules/Material/ActionButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,43 @@ import QtQuick.Controls.Styles 1.2 as ControlStyles
import Material 0.1
import QtGraphicalEffects 1.0

/*!
\qmltype ActionBar
\inqmlmodule Material 0.1
\ingroup material
\brief A floating action button.
An \l ActionButton is a floating action button that provides a primary action
on the current page.
*/
Controls.Button {
id: button

/*!
The color of the action button. By default, this is the accent color of your
app as defined by \l Theme::accentColor.
*/
property color backgroundColor: Theme.accentColor


/*!
\internal
The elevation of the icon. This will be higher for a white background color.
*/
property int elevation: backgroundColor == "white" ? 0 : 1
/*!
The color of the icon displayed on the action button. By default, this is
automatically selected based on the \l backgroundColor.
*/
property color iconColor: Theme.lightDark(button.backgroundColor,
Theme.light.iconColor,
Theme.dark.iconColor)

property int elevation: backgroundColor == "white" ? 0 : 1

/*!
The name of the icon to display in the action button, selected from the Material
Design icon collection by Google.
*/
property string iconName

style: ControlStyles.ButtonStyle {
Expand Down
Loading

0 comments on commit 34ce227

Please sign in to comment.