summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/controls/Styles/Base/TextAreaStyle.qml99
-rw-r--r--src/controls/Styles/Desktop/TextAreaStyle.qml60
-rw-r--r--src/controls/Styles/qmldir1
-rw-r--r--src/controls/Styles/styles.pri2
-rw-r--r--src/controls/TextArea.qml22
-rw-r--r--tests/auto/controls/data/tst_styles.qml7
-rw-r--r--tests/manual/testbench/content/Components.qml2
7 files changed, 181 insertions, 12 deletions
diff --git a/src/controls/Styles/Base/TextAreaStyle.qml b/src/controls/Styles/Base/TextAreaStyle.qml
new file mode 100644
index 00000000..c974c01d
--- /dev/null
+++ b/src/controls/Styles/Base/TextAreaStyle.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.1
+import QtQuick.Controls 1.1
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype TextAreaStyle
+ \inqmlmodule QtQuick.Controls.Styles
+ \since 5.2
+ \ingroup controlsstyling
+ \brief Provides custom styling for TextArea.
+
+ Example:
+ \qml
+ TextArea {
+ style: TextAreaStyle {
+ textColor: "#333"
+ selectionColor: "steelblue"
+ selectedTextColor: "#eee"
+ backgroundColor: "#eee"
+ }
+ }
+ \endqml
+*/
+
+ScrollViewStyle {
+ id: style
+
+ /*! The \l TextArea attached to this style. */
+ readonly property TextArea control: __control
+
+ /*! The current font. */
+ property font font
+
+ /*! The text color. */
+ property color textColor: __syspal.text
+
+ /*! The text highlight color, used behind selections. */
+ property color selectionColor: __syspal.highlight
+
+ /*! The highlighted text color, used in selections. */
+ property color selectedTextColor: __syspal.highlightedText
+
+ /*! The background color. */
+ property color backgroundColor: control.backgroundVisible ? __syspal.base : "transparent"
+
+ /*!
+ \qmlproperty enumeration renderType
+
+ Override the default rendering type for the control.
+
+ Supported render types are:
+ \list
+ \li Text.QtRendering
+ \li Text.NativeRendering - the default
+ \endlist
+
+ \sa Text::renderType
+ */
+ property int renderType: Text.NativeRendering
+}
diff --git a/src/controls/Styles/Desktop/TextAreaStyle.qml b/src/controls/Styles/Desktop/TextAreaStyle.qml
new file mode 100644
index 00000000..3f2904a3
--- /dev/null
+++ b/src/controls/Styles/Desktop/TextAreaStyle.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.1
+import QtQuick.Controls 1.1
+import QtQuick.Controls.Private 1.0
+
+ScrollViewStyle {
+ property font font: __styleitem.font
+ property color textColor: __styleitem.textColor
+ property color selectionColor: __syspal.highlight
+ property color selectedTextColor: __syspal.highlightedText
+ property color backgroundColor: control.backgroundVisible ? __syspal.base : "transparent"
+
+ property StyleItem __styleitem: StyleItem{
+ property color textColor: styleHint("textColor")
+ elementType: "edit"
+ visible: false
+ active: control.activeFocus
+ onActiveChanged: textColor = styleHint("textColor")
+ }
+
+ property int renderType: Text.NativeRendering
+}
diff --git a/src/controls/Styles/qmldir b/src/controls/Styles/qmldir
index 1688f662..8e53b6ba 100644
--- a/src/controls/Styles/qmldir
+++ b/src/controls/Styles/qmldir
@@ -11,4 +11,5 @@ SpinBoxStyle 1.1 Base/SpinBoxStyle.qml
SwitchStyle 1.1 Base/SwitchStyle.qml
TabViewStyle 1.0 Base/TabViewStyle.qml
TableViewStyle 1.0 Base/TableViewStyle.qml
+TextAreaStyle 1.1 Base/TextAreaStyle.qml
TextFieldStyle 1.0 Base/TextFieldStyle.qml
diff --git a/src/controls/Styles/styles.pri b/src/controls/Styles/styles.pri
index 05a53619..4c57944c 100644
--- a/src/controls/Styles/styles.pri
+++ b/src/controls/Styles/styles.pri
@@ -18,6 +18,7 @@ STYLES_QML_FILES = \
$$PWD/Base/StatusBarStyle.qml \
$$PWD/Base/TableViewStyle.qml \
$$PWD/Base/TabViewStyle.qml \
+ $$PWD/Base/TextAreaStyle.qml \
$$PWD/Base/TextFieldStyle.qml \
$$PWD/Base/ToolBarStyle.qml \
$$PWD/Base/ToolButtonStyle.qml
@@ -41,6 +42,7 @@ STYLES_QML_FILES += \
$$PWD/Desktop/StatusBarStyle.qml\
$$PWD/Desktop/TabViewStyle.qml \
$$PWD/Desktop/TableViewStyle.qml \
+ $$PWD/Desktop/TextAreaStyle.qml \
$$PWD/Desktop/TextFieldStyle.qml \
$$PWD/Desktop/ToolBarStyle.qml \
$$PWD/Desktop/ToolButtonStyle.qml
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 9083a2aa..72697919 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -64,6 +64,9 @@ import QtQuick.Controls.Private 1.0
You can translate between cursor positions (characters from the start of the document) and pixel
points using positionAt() and positionToRectangle().
+ You can create a custom appearance for a TextArea by
+ assigning a \l{QtQuick.Controls.Styles::TextAreaStyle}{TextAreaStyle}.
+
\sa TextField, TextEdit
*/
@@ -645,6 +648,8 @@ ScrollView {
Accessible.role: Accessible.EditableText
+ style: Qt.createComponent(Settings.style + "/TextAreaStyle.qml", area)
+
/*!
\qmlproperty TextDocument TextArea::textDocument
@@ -663,16 +668,11 @@ ScrollView {
id: edit
focus: true
- SystemPalette {
- id: palette
- colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
- }
-
Rectangle {
id: colorRect
parent: viewport
anchors.fill: parent
- color: palette.base
+ color: __style ? __style.backgroundColor : "white"
z: -1
}
@@ -709,11 +709,11 @@ ScrollView {
onContentHeightChanged: edit.doLayout()
onWrapModeChanged: edit.doLayout()
- renderType: Text.NativeRendering
-
- color: palette.text
- selectionColor: palette.highlight
- selectedTextColor: palette.highlightedText
+ renderType: __style ? __style.renderType : Text.NativeRendering
+ font: __style ? __style.font : font
+ color: __style ? __style.textColor : "darkgray"
+ selectionColor: __style ? __style.selectionColor : "darkred"
+ selectedTextColor: __style ? __style.selectedTextColor : "white"
wrapMode: TextEdit.WordWrap
textMargin: 4
diff --git a/tests/auto/controls/data/tst_styles.qml b/tests/auto/controls/data/tst_styles.qml
index 126c84a7..a458a78d 100644
--- a/tests/auto/controls/data/tst_styles.qml
+++ b/tests/auto/controls/data/tst_styles.qml
@@ -157,5 +157,12 @@ Item {
Rectangle { width: 50; height: 50; property Component style: TabViewStyle {}}'
, container, '')
}
+
+ function test_createTextAreaStyle() {
+ var control = Qt.createQmlObject(
+ 'import QtQuick 2.1; import QtQuick.Controls 1.1; import QtQuick.Controls.Styles 1.1; \
+ Rectangle { width: 50; height: 50; property Component style: TextAreaStyle {}}'
+ , container, '')
+ }
}
}
diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml
index 059a1f16..98642aff 100644
--- a/tests/manual/testbench/content/Components.qml
+++ b/tests/manual/testbench/content/Components.qml
@@ -143,7 +143,7 @@ Item {
property Component sliderStyle: SliderStyle {}
property Component progressbarStyle: ProgressBarStyle {}
property Component textfieldStyle: TextFieldStyle {}
- property Component textareaStyle: null
+ property Component textareaStyle: TextAreaStyle {}
property Component spinboxStyle: SpinBoxStyle {}
property Component toolbarStyle: ToolBarStyle {}
property Component statusbarStyle: StatusBarStyle {}