forked from papyros/qml-material
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Documentation] Add or improve documentation for many classes
- Document the following classes: * Action * ActionButton * ApplicationWindow * AppTheme - Fix lint errors for awesome.js
- Loading branch information
Showing
11 changed files
with
438 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 { | ||
|
@@ -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) | ||
|
@@ -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) | ||
|
@@ -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)) | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.