aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controls/controls.pri2
-rw-r--r--src/controls/qquickabstractlabel.cpp105
-rw-r--r--src/controls/qquickabstractlabel_p.h84
-rw-r--r--src/imports/controls/Label.qml6
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp3
5 files changed, 197 insertions, 3 deletions
diff --git a/src/controls/controls.pri b/src/controls/controls.pri
index 0a2e647d..b613b9e7 100644
--- a/src/controls/controls.pri
+++ b/src/controls/controls.pri
@@ -12,6 +12,7 @@ HEADERS += \
$$PWD/qquickabstractcontainer_p_p.h \
$$PWD/qquickabstractframe_p.h \
$$PWD/qquickabstractgroupbox_p.h \
+ $$PWD/qquickabstractlabel_p.h \
$$PWD/qquickabstractpageindicator_p.h \
$$PWD/qquickabstractprogressbar_p.h \
$$PWD/qquickabstractradiobutton_p.h \
@@ -41,6 +42,7 @@ SOURCES += \
$$PWD/qquickabstractcontainer.cpp \
$$PWD/qquickabstractframe.cpp \
$$PWD/qquickabstractgroupbox.cpp \
+ $$PWD/qquickabstractlabel.cpp \
$$PWD/qquickabstractpageindicator.cpp \
$$PWD/qquickabstractprogressbar.cpp \
$$PWD/qquickabstractradiobutton.cpp \
diff --git a/src/controls/qquickabstractlabel.cpp b/src/controls/qquickabstractlabel.cpp
new file mode 100644
index 00000000..8e1df9cb
--- /dev/null
+++ b/src/controls/qquickabstractlabel.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickabstractlabel_p.h"
+
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickclipnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractLabelPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickAbstractLabel)
+
+public:
+ QQuickAbstractLabelPrivate() : background(Q_NULLPTR) { }
+
+ QQuickItem *background;
+ QQuickAbstractLabel *q_ptr;
+};
+
+QQuickAbstractLabel::QQuickAbstractLabel(QQuickItem *parent) :
+ QQuickText(parent), d_ptr(new QQuickAbstractLabelPrivate)
+{
+ Q_D(QQuickAbstractLabel);
+ d->q_ptr = this;
+}
+
+QQuickAbstractLabel::~QQuickAbstractLabel()
+{
+}
+
+QQuickItem *QQuickAbstractLabel::background() const
+{
+ Q_D(const QQuickAbstractLabel);
+ return d->background;
+}
+
+void QQuickAbstractLabel::setBackground(QQuickItem *background)
+{
+ Q_D(QQuickAbstractLabel);
+ if (d->background != background) {
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ }
+ emit backgroundChanged();
+ }
+}
+
+void QQuickAbstractLabel::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickAbstractLabel);
+ QQuickText::geometryChanged(newGeometry, oldGeometry);
+ if (d->background) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(d->background);
+ if (!p->widthValid) {
+ d->background->setWidth(newGeometry.width());
+ p->widthValid = false;
+ }
+ if (!p->heightValid) {
+ d->background->setHeight(newGeometry.height());
+ p->heightValid = false;
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qquickabstractlabel_p.h b/src/controls/qquickabstractlabel_p.h
new file mode 100644
index 00000000..d731550c
--- /dev/null
+++ b/src/controls/qquickabstractlabel_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKABSTRACTLABEL_P_H
+#define QQUICKABSTRACTLABEL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractLabelPrivate;
+
+class Q_QUICKCONTROLS_EXPORT QQuickAbstractLabel : public QQuickText
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
+
+public:
+ explicit QQuickAbstractLabel(QQuickItem *parent = Q_NULLPTR);
+ ~QQuickAbstractLabel();
+
+ QQuickItem *background() const;
+ void setBackground(QQuickItem *background);
+
+Q_SIGNALS:
+ void backgroundChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(QQuickAbstractLabel)
+ Q_DECLARE_PRIVATE(QQuickAbstractLabel)
+ QScopedPointer<QQuickAbstractLabelPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKABSTRACTLABEL_P_H
diff --git a/src/imports/controls/Label.qml b/src/imports/controls/Label.qml
index f258791d..2cd3e5fa 100644
--- a/src/imports/controls/Label.qml
+++ b/src/imports/controls/Label.qml
@@ -37,11 +37,11 @@
import QtQuick 2.6
import QtQuick.Controls 2.0
-Text {
+AbstractLabel {
id: control
- // TODO: color: style.textColor
-
Accessible.name: text
Accessible.role: Accessible.StaticText
+
+ color: Style.textColor
}
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 7fbdfc8e..22622c9f 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -43,6 +43,7 @@
#include <QtQuickControls/private/qquickabstractcheckbox_p.h>
#include <QtQuickControls/private/qquickabstractframe_p.h>
#include <QtQuickControls/private/qquickabstractgroupbox_p.h>
+#include <QtQuickControls/private/qquickabstractlabel_p.h>
#include <QtQuickControls/private/qquickabstractpageindicator_p.h>
#include <QtQuickControls/private/qquickabstractprogressbar_p.h>
#include <QtQuickControls/private/qquickabstractradiobutton_p.h>
@@ -88,6 +89,7 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickAbstractCheckBox>(uri, 2, 0, "AbstractCheckBox");
qmlRegisterType<QQuickAbstractFrame>(uri, 2, 0, "AbstractFrame");
qmlRegisterType<QQuickAbstractGroupBox>(uri, 2, 0, "AbstractGroupBox");
+ qmlRegisterType<QQuickAbstractLabel>(uri, 2, 0, "AbstractLabel");
qmlRegisterType<QQuickAbstractPageIndicator>(uri, 2, 0, "AbstractPageIndicator");
qmlRegisterType<QQuickAbstractProgressBar>(uri, 2, 0, "AbstractProgressBar");
qmlRegisterType<QQuickAbstractRadioButton>(uri, 2, 0, "AbstractRadioButton");
@@ -113,6 +115,7 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickControl>(uri, 2, 0, "Control");
qmlRegisterType<QQuickExclusiveGroup>(uri, 2, 0, "ExclusiveGroup");
+ qmlRegisterRevision<QQuickText, 6>(uri, 2, 0);
qmlRegisterRevision<QQuickTextInput, 6>(uri, 2, 0);
qmlRegisterRevision<QQuickTextEdit, 6>(uri, 2, 0);
}