Source

Target

Commits (7)
Showing with 133 additions and 99 deletions
......@@ -76,7 +76,7 @@ ApplicationWindow {
shortcut: "Ctrl+O"
iconSource: "images/document-open.png"
onTriggered: fileDialog.open()
tooltip: "open an image"
tooltip: "Open an image"
}
Action {
......@@ -168,7 +168,7 @@ ApplicationWindow {
ToolButton { action: openAction }
ToolButton {
iconSource: "images/document-save-as.png"
tooltip: "(Pretend to) save as..."
tooltip: "(Pretend to) Save as..."
}
Item { Layout.fillWidth: true }
CheckBox {
......
......@@ -72,20 +72,6 @@ BasicButton {
*/
property bool isDefault: false
/*! This property holds the text shown on the button. If the button has no
text, the \l text property will be an empty string.
The default value is the empty string.
*/
property string text
/*! This property holds the icon shown on the button. If the button has no
icon, the \l iconSource property will be an empty string.
The default value is the empty string.
*/
property url iconSource
/*! Assign a \l Menu to this property to get a pull-down menu button.
The default value is \c null.
......@@ -115,6 +101,14 @@ BasicButton {
value: button
}
Binding {
target: button
property: "tooltip"
// We don't want a tooltip if it's the same as the button text
when: !!text && !(action && (!!action.tooltip || action.tooltip === text))
value: ""
}
Connections {
target: __behavior
onEffectivePressedChanged: {
......
......@@ -86,8 +86,9 @@ import QtQuick.Controls.Styles 1.0
FocusScope {
id: root
implicitWidth: 200
implicitHeight: 100
implicitWidth: 240
implicitHeight: 150
/*!
This property tells the ScrollView if it should render
......
......@@ -130,12 +130,12 @@ Item {
child item. Inside the delegate the following properties are available:
\table
\li readonly property bool styleData.index - Specifies the index of the splitter handle. The handle
\row \li readonly property bool styleData.index \li Specifies the index of the splitter handle. The handle
between the first and the second item will get index 0,
the next handle index 1 etc.
\li readonly property bool styleData.hovered - The handle is being hovered.
\li readonly property bool styleData.pressed - The handle is being pressed.
\li readonly property bool styleData.resizing - The handle is being dragged.
\row \li readonly property bool styleData.hovered \li The handle is being hovered.
\row \li readonly property bool styleData.pressed \li The handle is being pressed.
\row \li readonly property bool styleData.resizing \li The handle is being dragged.
\endtable
*/
......
......@@ -79,7 +79,7 @@ Item {
Accessible.role: Accessible.StatusBar
width: parent ? parent.width : implicitWidth
implicitWidth: loader.item ? loader.item.implicitWidth : 200
implicitWidth: container.leftMargin + container.rightMargin + container.calcWidth()
implicitHeight: Math.max(container.topMargin + container.bottomMargin + container.calcHeight(),
loader.item ? loader.item.implicitHeight : 19)
......@@ -134,6 +134,10 @@ Item {
property int rightMargin: __style ? __style.padding.right : 0
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
function calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +
(layoutItem.anchors.fill ? layoutItem.anchors.leftMargin +
layoutItem.anchors.rightMargin : 0) :
loader.item ? loader.item.implicitWidth: 0) }
function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
(layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
layoutItem.anchors.bottomMargin : 0) : loader.item ? loader.item.implicitHeight : 0) }
......
......@@ -55,7 +55,8 @@ import QtQuick.Controls.Private 1.0
FocusScope {
id: root
implicitWidth: 150
implicitWidth: 240
implicitHeight: 150
/*! The current tab index */
......@@ -198,7 +199,7 @@ FocusScope {
anchors.fill: parent
anchors.margins: (frameVisible ? frameWidth : 0)
anchors.topMargin: anchors.margins + (style =="mac" ? 6 : 0)
anchors.bottomMargin: anchors.margins + (style =="mac" ? 6 : 0)
anchors.bottomMargin: anchors.margins
property int frameWidth
property string style
......
......@@ -65,8 +65,7 @@ import QtQuick.Controls.Styles 1.0
\endcode
You provide title and size of a column header
by adding a \l TableViewColumn to the default \l header property
as demonstrated below.
by adding a \l TableViewColumn as demonstrated below.
\code
TableView {
......@@ -259,7 +258,7 @@ ScrollView {
Depending on how the model is populated, the model may not be ready when
TableView Component.onCompleted is called. In that case you may need to
delay the call to positionViewAtRow by using a \l {Timer}.
delay the call to positionViewAtRow by using a \l {QtQml::Timer}{Timer}.
\note This method should only be called after the component has completed.
*/
......@@ -303,7 +302,12 @@ ScrollView {
if (typeof column['createObject'] === 'function')
object = column.createObject(root)
else if (object.__view) {
console.warn("TableView::insertColumn(): you cannot add a column to multiple views")
return null
}
if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) {
object.__view = root
columnModel.insert(index, {columnItem: object})
return object
}
......@@ -355,8 +359,8 @@ ScrollView {
Accessible.role: Accessible.Table
width: 200
height: 200
implicitWidth: 200
implicitHeight: 150
frameVisible: true
__scrollBarTopMargin: Qt.platform.os === "mac" ? headerrow.height : 0
......@@ -616,7 +620,7 @@ ScrollView {
delegate: Item {
z:-index
width: modelData.width
width: columnCount == 1 ? viewport.width + __verticalScrollBar.width : modelData.width
visible: modelData.visible
height: headerVisible ? headerStyle.height : 0
......@@ -655,7 +659,7 @@ ScrollView {
// NOTE: the direction is different from the master branch
// so this indicates that I am using an invalid assumption on item ordering
onPositionChanged: {
if (pressed) { // only do this while dragging
if (pressed && columnCount > 1) { // only do this while dragging
for (var h = columnCount-1 ; h >= 0 ; --h) {
if (drag.target.x > headerrow.children[h].x) {
repeater.targetIndex = h
......@@ -680,7 +684,7 @@ ScrollView {
}
drag.maximumX: 1000
drag.minimumX: -1000
drag.target: draghandle
drag.target: columnCount > 1 ? draghandle : null
}
Loader {
......@@ -708,6 +712,7 @@ ScrollView {
anchors.rightMargin: -width/2
width: 16 ; height: parent.height
anchors.right: parent.right
enabled: columnCount > 1
onPositionChanged: {
var newHeaderWidth = modelData.width + (mouseX - offset)
modelData.width = Math.max(minimumSize, newHeaderWidth)
......@@ -728,7 +733,7 @@ ScrollView {
modelData.width = minWidth
}
onPressedChanged: if (pressed) offset=mouseX
cursorShape: Qt.SplitHCursor
cursorShape: enabled ? Qt.SplitHCursor : Qt.ArrowCursor
}
}
}
......
......@@ -49,6 +49,10 @@ import QtQuick 2.1
*/
QtObject {
/*! \internal */
property Item __view: null
/*! The title text of the column. */
property string title
......@@ -56,8 +60,10 @@ QtObject {
property string role
/*! The current width of the column
The default value depends on platform. */
property int width: 160
The default value depends on platform. If only one
column is defined, the width expands to the viewport.
*/
property int width: (__view && __view.columnCount === 1) ? __view.viewport.width : 160
/*! The visible status of the column. */
property bool visible: true
......
......@@ -611,9 +611,6 @@ ScrollView {
/*! \internal */
property int __documentMargin: 4
width: 280
height: 120
frameVisible: true
activeFocusOnTab: true
......
......@@ -83,7 +83,7 @@ Item {
Accessible.role: Accessible.ToolBar
width: parent ? parent.width : implicitWidth
implicitWidth: loader.item ? loader.item.implicitWidth : 200
implicitWidth: container.leftMargin + container.rightMargin + container.calcWidth()
implicitHeight: container.topMargin + container.bottomMargin + container.calcHeight()
/*! \internal */
......@@ -137,6 +137,10 @@ Item {
property int rightMargin: __style ? __style.padding.right : 0
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
function calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +
(layoutItem.anchors.fill ? layoutItem.anchors.leftMargin +
layoutItem.anchors.rightMargin : 0) :
loader.item ? loader.item.implicitWidth : 0) }
function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) +
(layoutItem.anchors.fill ? layoutItem.anchors.topMargin +
layoutItem.anchors.bottomMargin : 0) :
......
......@@ -46,7 +46,7 @@ import QtQuick.Controls.Private 1.0
\qmltype ToolButton
\inqmlmodule QtQuick.Controls 1.0
\since QtQtuick.Controls 1.0
\ingroup applicationwindow
\ingroup controls
\brief Provides a button type that is typically used within a ToolBar.
ToolButton is functionally similar to \l Button, but can provide a look that is more
......@@ -62,18 +62,6 @@ import QtQuick.Controls.Private 1.0
BasicButton {
id: button
/*! The image label source as file name or resource. */
property url iconSource
/*! The image label source as theme name.
When an icon from the platform icon theme is found, this takes
precedence over iconSource.
*/
property url iconName
/*! The label text. */
property string text
activeFocusOnTab: true
Accessible.name: text
......
......@@ -18,18 +18,13 @@ qhp.QtQuickControls.filterAttributes = qtcontrols $QT_VERSION qtrefdoc
qhp.QtQuickControls.customFilters.Qt.name = QtQuickControls $QT_VERSION
qhp.QtQuickControls.customFilters.Qt.filterAttributes = qtquickcontrols $QT_VERSION
qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes styleqmltypes
qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.title = QML Types
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.indexTitle = Qt Quick Controls QML Types
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.selectors = class fake:qmlclass
qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.sortPages = true
qhp.QtQuickControls.subprojects.styleqmltypes.title = Styles QML Types
qhp.QtQuickControls.subprojects.styleqmltypes.indexTitle = Qt Quick Controls Styles QML Types
qhp.QtQuickControls.subprojects.styleqmltypes.selectors = class fake:qmlclass
qhp.QtQuickControls.subprojects.styleqmltypes.sortPages = true
depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts
depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts qtquickcontrolsstyles
exampledirs += ../../../examples/quick/controls
......@@ -37,21 +32,15 @@ exampledirs += ../../../examples/quick/controls
examplesinstallpath = quick/controls
headerdirs += ../
headerdirs += ../ ../../styles/Base
sourcedirs += ../
sourcedirs += ../ ../../styles/Base
sources += ../../private/qstyleitem.cpp \
../../private/AbstractCheckable.qml \
sources += ../../private/AbstractCheckable.qml \
../../private/BasicButton.qml \
../../private/FocusFrame.qml \
../../private/ModalPopupBehavior.qml \
../../private/ScrollBar.qml \
../../private/TabBar.qml \
../../private/Control.qml \
../../private/Style.qml \
../../private/qquickabstractstyle.h \
../../private/qquickabstractstyle.cpp
imagedirs += images
......@@ -84,7 +84,12 @@
\section2 Styles
\list
\li \l {Qt Quick Controls Styles QML Types}
\li \l {Qt Quick Controls Styles}
\endlist
\section2 Styles
\list
\li \l {Qt Quick Layouts}
\endlist
*/
......@@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE
Whether the action is enabled, and can be triggered. Defaults to \c true.
\sa tigger(), triggered()
\sa trigger(), triggered
*/
/*!
......@@ -140,7 +140,7 @@ QT_BEGIN_NAMESPACE
If the action is \l checkable, this property reflects its checked state. Defaults to \c false.
Its value is also false while \l checkable is false.
\sa toggled(), exclusiveGroup
\sa toggled, exclusiveGroup
*/
/*!
......@@ -169,14 +169,14 @@ QT_BEGIN_NAMESPACE
/*! \qmlmethod Action::trigger()
Will emit the \l triggered() signal if the action is enabled. Will also emit the
\l toggled() signal if it is checkable.
Will emit the \l triggered signal if the action is enabled. Will also emit the
\l toggled signal if it is checkable.
*/
/*! \qmlsignal Action::toggled(checked)
Emitted whenever a action's \l checked property changes.
This usually happens at the same time as \l triggered().
This usually happens at the same time as \l triggered.
*/
QQuickAction::QQuickAction(QObject *parent)
......
......@@ -57,11 +57,11 @@ class QQuickAction : public QObject
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged RESET resetText)
Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged RESET resetIconSource)
Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged)
Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged)
Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged RESET resetTooltip)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
......@@ -76,6 +76,7 @@ public:
~QQuickAction();
QString text() const { return m_text; }
void resetText() { setText(QString()); }
void setText(const QString &text);
QString shortcut() const;
......@@ -87,9 +88,11 @@ public:
void setIconName(const QString &iconName);
QUrl iconSource() const { return m_iconSource; }
void resetIconSource() { setIconSource(QString()); }
void setIconSource(const QUrl &iconSource);
QString tooltip() const { return m_tooltip; }
void resetTooltip() { setTooltip(QString()); }
void setTooltip(const QString &tooltip);
bool isEnabled() const { return m_enabled; }
......
......@@ -97,9 +97,9 @@ static bool isChecked(const QObject *o)
}
\endcode
Several controls already support \l ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton.
Several controls already support ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton.
Since \l ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup
Since ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup
property for other objects.
\code
......@@ -131,9 +131,9 @@ static bool isChecked(const QObject *o)
\section1 Adding support to ExclusiveGroup
It is possible to add support for \l ExclusiveGroup for an object, or control. It should have a \c checked
It is possible to add support for ExclusiveGroup for an object, or control. It should have a \c checked
property, and either a \c checkedChanged, \c toggled(), or \c toggled(bool) signal. It also needs
to be bound with \l ExclusiveGroup::bindCheckable(object) when its \l ExclusiveGroup ty[ped property is set.
to be bound with \l ExclusiveGroup::bindCheckable() when its ExclusiveGroup ty[ped property is set.
\code
Item {
......@@ -149,13 +149,13 @@ static bool isChecked(const QObject *o)
}
\endcode
The example above shows the minimum necessary to add \l ExclusiveGroup support to any item.
The example above shows the minimum necessary to add ExclusiveGroup support to any item.
*/
/*!
\qmlproperty object ExclusiveGroup::current
The currently selected object. Defaults to the first checked object bound to the \l ExclusiveGroup.
The currently selected object. Defaults to the first checked object bound to the ExclusiveGroup.
If there is none, then it defaults to \c null.
*/
......@@ -166,7 +166,7 @@ static bool isChecked(const QObject *o)
You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
\sa ExclusiveGroup::unbindCheckable(object)
\sa ExclusiveGroup::unbindCheckable()
*/
/*!
......@@ -176,7 +176,7 @@ static bool isChecked(const QObject *o)
You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
\sa ExclusiveGroup::bindCheckable(object)
\sa ExclusiveGroup::bindCheckable()
*/
QQuickExclusiveGroup::QQuickExclusiveGroup(QObject *parent)
......
......@@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE
\endcode
Note that in this case, the \c index parameter passed to \l insertItem() is relative
to the position of the \l Instatiator in the menu, as opposed to absolute position
to the position of the \l Instantiator in the menu, as opposed to absolute position
in the menu.
\sa MenuItem, MenuSeparator
......@@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE
Adds an item to the menu. Returns the newly created \l MenuItem.
\sa insertItem(int before, string title)
\sa insertItem()
*/
/*!
......
......@@ -329,14 +329,14 @@ void QQuickMenuText::updateIcon()
Emitted when either the menu item or its bound action have been activated.
\sa trigger(), Action::triggered(), Action::toggled()
\sa trigger(), Action::triggered, Action::toggled
*/
/*! \qmlmethod MenuItem::trigger()
Manually trigger a menu item. Will also trigger the item's bound action.
\sa triggered(), Action::trigger()
\sa triggered, Action::trigger()
*/
/*!
......@@ -360,7 +360,7 @@ void QQuickMenuText::updateIcon()
If the menu item is checkable, this property reflects its checked state. Defaults to \c false.
\sa checkable, Action::toggled()
\sa checkable, Action::toggled
*/
/*! \qmlproperty ExclusiveGroup MenuItem::exclusiveGroup
......@@ -378,9 +378,9 @@ void QQuickMenuText::updateIcon()
/*! \qmlsignal MenuItem::toggled(checked)
Emitted whenever a menu item's \c checked property changes.
This usually happens at the same time as \l triggered().
This usually happens at the same time as \l triggered.
\sa checked, triggered(), Action::triggered(), Action::toggled()
\sa checked, triggered, Action::triggered, Action::toggled
*/
/*!
......@@ -503,7 +503,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a)
QString QQuickMenuItem::text() const
{
QString ownText = QQuickMenuText::text();
if (!ownText.isEmpty())
if (!ownText.isNull())
return ownText;
return m_boundAction ? m_boundAction->text() : QString();
}
......
......@@ -42,6 +42,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Styles 1.0
import "style.js" as StyleHelpers
/*!
\qmltype BasicButton
......@@ -83,6 +84,9 @@ Control {
If a button has an action associated, the action defines the
button's properties like checked, text, tooltip etc.
When an action is set, it's still possible to override the \l text,
\l tooltip, \l iconSource, and \l iconName properties.
The default value is \c null. */
property Action action: null
......@@ -91,8 +95,28 @@ Control {
The default value is \c false. */
property bool activeFocusOnPress: false
/*! This property holds the text shown on the button. If the button has no
text, the \l text property will be an empty string.
The default value is the empty string.
*/
property string text: action ? action.text : ""
/*! This property holds the button tooltip. */
property string tooltip
property string tooltip: action ? (action.tooltip || StyleHelpers.removeMnemonics(action.text)) : ""
/*! This property holds the icon shown on the button. If the button has no
icon, the iconSource property will be an empty string.
The default value is the empty string.
*/
property url iconSource: action ? action.iconSource : ""
/*! The image label source as theme name.
When an icon from the platform icon theme is found, this takes
precedence over iconSource.
*/
property string iconName: action ? action.iconName : ""
/*! \internal */
property color __textColor: syspal.text
......@@ -101,7 +125,11 @@ Control {
/*! \internal */
property alias __containsMouse: behavior.containsMouse
/*! \internal */
readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName)
/*! \internal */
property Action __action: action || ownAction
/*! \internal */
readonly property Action __iconAction: __iconOverriden ? ownAction : __action
/*! \internal */
onExclusiveGroupChanged: {
......@@ -119,7 +147,8 @@ Control {
Action {
id: ownAction
iconSource: !button.action ? button.iconSource : ""
iconSource: !button.action || __iconOverriden ? button.iconSource : ""
iconName: !button.action || __iconOverriden ? button.iconName : ""
}
Connections {
......@@ -181,9 +210,6 @@ Control {
enabled: action.enabled
checkable: action.checkable
checked: action.checked
text: action.text
iconSource: action.iconSource
tooltip: action.tooltip
}
}
]
......
......@@ -40,13 +40,24 @@
.pragma library
function replaceAmpersands(match, p1, p2, p3) {
function underlineAmpersands(match, p1, p2, p3) {
if (p2 === "&")
return p1.concat(p2, p3)
return p1.concat("<u>", p2, "</u>", p3)
}
function removeAmpersands(match, p1, p2, p3) {
return p1.concat(p2, p3)
}
function replaceAmpersands(text, replaceFunction) {
return text.replace(/([^&]*)&(.)([^&]*)/g, replaceFunction)
}
function stylizeMnemonics(text) {
return replaceAmpersands(text, underlineAmpersands)
}
return text.replace(/([^&]*)&(.)([^&]*)/g, replaceAmpersands)
function removeMnemonics(text) {
return replaceAmpersands(text, removeAmpersands)
}