From 3dadb7aca5982ae5efd890ea122da2625ea8e746 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 10 Apr 2015 14:54:34 +0200 Subject: Remove "abstract" prefix from the C++ classes The QML type registration is still using Abstract-prefix to avoid conflicts, until QTBUG-43581 & QTBUG-43582 have been resolved so that the public types can be used for accessing attached properties and enums. Change-Id: I469712461f706a83c226e4017282ca1d6914c670 Reviewed-by: J-P Nurmi --- src/calendar/calendar.pri | 12 +- src/calendar/qquickabstractcalendarview.cpp | 255 ----------- src/calendar/qquickabstractcalendarview_p.h | 112 ----- src/calendar/qquickabstractdayofweekrow.cpp | 87 ---- src/calendar/qquickabstractdayofweekrow_p.h | 84 ---- src/calendar/qquickabstractweeknumbercolumn.cpp | 113 ----- src/calendar/qquickabstractweeknumbercolumn_p.h | 94 ---- src/calendar/qquickcalendarview.cpp | 255 +++++++++++ src/calendar/qquickcalendarview_p.h | 112 +++++ src/calendar/qquickdayofweekrow.cpp | 87 ++++ src/calendar/qquickdayofweekrow_p.h | 84 ++++ src/calendar/qquickweeknumbercolumn.cpp | 113 +++++ src/calendar/qquickweeknumbercolumn_p.h | 94 ++++ src/controls/controls.pri | 110 ++--- src/controls/qquickabstractapplicationwindow.cpp | 235 ---------- src/controls/qquickabstractapplicationwindow_p.h | 99 ---- src/controls/qquickabstractbusyindicator.cpp | 110 ----- src/controls/qquickabstractbusyindicator_p.h | 83 ---- src/controls/qquickabstractbutton.cpp | 189 -------- src/controls/qquickabstractbutton_p.h | 100 ---- src/controls/qquickabstractbutton_p_p.h | 69 --- src/controls/qquickabstractcheckable.cpp | 190 -------- src/controls/qquickabstractcheckable_p.h | 105 ----- src/controls/qquickabstractcheckable_p_p.h | 68 --- src/controls/qquickabstractcheckbox.cpp | 57 --- src/controls/qquickabstractcheckbox_p.h | 65 --- src/controls/qquickabstractcontainer.cpp | 138 ------ src/controls/qquickabstractcontainer_p.h | 93 ---- src/controls/qquickabstractcontainer_p_p.h | 67 --- src/controls/qquickabstractframe.cpp | 57 --- src/controls/qquickabstractframe_p.h | 65 --- src/controls/qquickabstractgroupbox.cpp | 134 ------ src/controls/qquickabstractgroupbox_p.h | 88 ---- src/controls/qquickabstractlabel.cpp | 105 ----- src/controls/qquickabstractlabel_p.h | 84 ---- src/controls/qquickabstractpageindicator.cpp | 107 ----- src/controls/qquickabstractpageindicator_p.h | 83 ---- src/controls/qquickabstractprogressbar.cpp | 188 -------- src/controls/qquickabstractprogressbar_p.h | 103 ----- src/controls/qquickabstractradiobutton.cpp | 60 --- src/controls/qquickabstractradiobutton_p.h | 65 --- src/controls/qquickabstractscrollbar.cpp | 432 ------------------ src/controls/qquickabstractscrollbar_p.h | 143 ------ src/controls/qquickabstractscrollindicator.cpp | 323 ------------- src/controls/qquickabstractscrollindicator_p.h | 131 ------ src/controls/qquickabstractslider.cpp | 454 ------------------- src/controls/qquickabstractslider_p.h | 144 ------ src/controls/qquickabstractstackview.cpp | 553 ----------------------- src/controls/qquickabstractstackview_p.cpp | 507 --------------------- src/controls/qquickabstractstackview_p.h | 174 ------- src/controls/qquickabstractstackview_p_p.h | 158 ------- src/controls/qquickabstractswitch.cpp | 199 -------- src/controls/qquickabstractswitch_p.h | 93 ---- src/controls/qquickabstracttabbar.cpp | 88 ---- src/controls/qquickabstracttabbar_p.h | 81 ---- src/controls/qquickabstracttabbutton.cpp | 58 --- src/controls/qquickabstracttabbutton_p.h | 65 --- src/controls/qquickabstracttabview.cpp | 236 ---------- src/controls/qquickabstracttabview_p.h | 129 ------ src/controls/qquickabstracttextarea.cpp | 140 ------ src/controls/qquickabstracttextarea_p.h | 91 ---- src/controls/qquickabstracttextfield.cpp | 140 ------ src/controls/qquickabstracttextfield_p.h | 91 ---- src/controls/qquickabstracttogglebutton.cpp | 57 --- src/controls/qquickabstracttogglebutton_p.h | 65 --- src/controls/qquickabstracttoolbar.cpp | 57 --- src/controls/qquickabstracttoolbar_p.h | 65 --- src/controls/qquickapplicationwindow.cpp | 235 ++++++++++ src/controls/qquickapplicationwindow_p.h | 99 ++++ src/controls/qquickbusyindicator.cpp | 110 +++++ src/controls/qquickbusyindicator_p.h | 83 ++++ src/controls/qquickbutton.cpp | 189 ++++++++ src/controls/qquickbutton_p.h | 100 ++++ src/controls/qquickbutton_p_p.h | 69 +++ src/controls/qquickcheckable.cpp | 190 ++++++++ src/controls/qquickcheckable_p.h | 105 +++++ src/controls/qquickcheckable_p_p.h | 68 +++ src/controls/qquickcheckbox.cpp | 57 +++ src/controls/qquickcheckbox_p.h | 65 +++ src/controls/qquickcontainer.cpp | 138 ++++++ src/controls/qquickcontainer_p.h | 93 ++++ src/controls/qquickcontainer_p_p.h | 67 +++ src/controls/qquickframe.cpp | 57 +++ src/controls/qquickframe_p.h | 65 +++ src/controls/qquickgroupbox.cpp | 134 ++++++ src/controls/qquickgroupbox_p.h | 88 ++++ src/controls/qquicklabel.cpp | 105 +++++ src/controls/qquicklabel_p.h | 84 ++++ src/controls/qquickpageindicator.cpp | 107 +++++ src/controls/qquickpageindicator_p.h | 83 ++++ src/controls/qquickprogressbar.cpp | 188 ++++++++ src/controls/qquickprogressbar_p.h | 103 +++++ src/controls/qquickradiobutton.cpp | 60 +++ src/controls/qquickradiobutton_p.h | 65 +++ src/controls/qquickscrollbar.cpp | 432 ++++++++++++++++++ src/controls/qquickscrollbar_p.h | 143 ++++++ src/controls/qquickscrollindicator.cpp | 323 +++++++++++++ src/controls/qquickscrollindicator_p.h | 131 ++++++ src/controls/qquickslider.cpp | 454 +++++++++++++++++++ src/controls/qquickslider_p.h | 144 ++++++ src/controls/qquickstackview.cpp | 553 +++++++++++++++++++++++ src/controls/qquickstackview_p.cpp | 507 +++++++++++++++++++++ src/controls/qquickstackview_p.h | 174 +++++++ src/controls/qquickstackview_p_p.h | 158 +++++++ src/controls/qquickswitch.cpp | 199 ++++++++ src/controls/qquickswitch_p.h | 93 ++++ src/controls/qquicktabbar.cpp | 88 ++++ src/controls/qquicktabbar_p.h | 81 ++++ src/controls/qquicktabbutton.cpp | 58 +++ src/controls/qquicktabbutton_p.h | 65 +++ src/controls/qquicktabview.cpp | 236 ++++++++++ src/controls/qquicktabview_p.h | 129 ++++++ src/controls/qquicktextarea.cpp | 140 ++++++ src/controls/qquicktextarea_p.h | 91 ++++ src/controls/qquicktextfield.cpp | 140 ++++++ src/controls/qquicktextfield_p.h | 91 ++++ src/controls/qquicktogglebutton.cpp | 57 +++ src/controls/qquicktogglebutton_p.h | 65 +++ src/controls/qquicktoolbar.cpp | 57 +++ src/controls/qquicktoolbar_p.h | 65 +++ src/extras/extras.pri | 4 +- src/extras/qquickabstractdrawer.cpp | 388 ---------------- src/extras/qquickabstractdrawer_p.h | 113 ----- src/extras/qquickdrawer.cpp | 388 ++++++++++++++++ src/extras/qquickdrawer_p.h | 113 +++++ src/imports/calendar/qtquickcalendar2plugin.cpp | 12 +- src/imports/controls/qtquickcontrols2plugin.cpp | 88 ++-- src/imports/extras/qtquickextras2plugin.cpp | 4 +- 128 files changed, 8842 insertions(+), 8842 deletions(-) delete mode 100644 src/calendar/qquickabstractcalendarview.cpp delete mode 100644 src/calendar/qquickabstractcalendarview_p.h delete mode 100644 src/calendar/qquickabstractdayofweekrow.cpp delete mode 100644 src/calendar/qquickabstractdayofweekrow_p.h delete mode 100644 src/calendar/qquickabstractweeknumbercolumn.cpp delete mode 100644 src/calendar/qquickabstractweeknumbercolumn_p.h create mode 100644 src/calendar/qquickcalendarview.cpp create mode 100644 src/calendar/qquickcalendarview_p.h create mode 100644 src/calendar/qquickdayofweekrow.cpp create mode 100644 src/calendar/qquickdayofweekrow_p.h create mode 100644 src/calendar/qquickweeknumbercolumn.cpp create mode 100644 src/calendar/qquickweeknumbercolumn_p.h delete mode 100644 src/controls/qquickabstractapplicationwindow.cpp delete mode 100644 src/controls/qquickabstractapplicationwindow_p.h delete mode 100644 src/controls/qquickabstractbusyindicator.cpp delete mode 100644 src/controls/qquickabstractbusyindicator_p.h delete mode 100644 src/controls/qquickabstractbutton.cpp delete mode 100644 src/controls/qquickabstractbutton_p.h delete mode 100644 src/controls/qquickabstractbutton_p_p.h delete mode 100644 src/controls/qquickabstractcheckable.cpp delete mode 100644 src/controls/qquickabstractcheckable_p.h delete mode 100644 src/controls/qquickabstractcheckable_p_p.h delete mode 100644 src/controls/qquickabstractcheckbox.cpp delete mode 100644 src/controls/qquickabstractcheckbox_p.h delete mode 100644 src/controls/qquickabstractcontainer.cpp delete mode 100644 src/controls/qquickabstractcontainer_p.h delete mode 100644 src/controls/qquickabstractcontainer_p_p.h delete mode 100644 src/controls/qquickabstractframe.cpp delete mode 100644 src/controls/qquickabstractframe_p.h delete mode 100644 src/controls/qquickabstractgroupbox.cpp delete mode 100644 src/controls/qquickabstractgroupbox_p.h delete mode 100644 src/controls/qquickabstractlabel.cpp delete mode 100644 src/controls/qquickabstractlabel_p.h delete mode 100644 src/controls/qquickabstractpageindicator.cpp delete mode 100644 src/controls/qquickabstractpageindicator_p.h delete mode 100644 src/controls/qquickabstractprogressbar.cpp delete mode 100644 src/controls/qquickabstractprogressbar_p.h delete mode 100644 src/controls/qquickabstractradiobutton.cpp delete mode 100644 src/controls/qquickabstractradiobutton_p.h delete mode 100644 src/controls/qquickabstractscrollbar.cpp delete mode 100644 src/controls/qquickabstractscrollbar_p.h delete mode 100644 src/controls/qquickabstractscrollindicator.cpp delete mode 100644 src/controls/qquickabstractscrollindicator_p.h delete mode 100644 src/controls/qquickabstractslider.cpp delete mode 100644 src/controls/qquickabstractslider_p.h delete mode 100644 src/controls/qquickabstractstackview.cpp delete mode 100644 src/controls/qquickabstractstackview_p.cpp delete mode 100644 src/controls/qquickabstractstackview_p.h delete mode 100644 src/controls/qquickabstractstackview_p_p.h delete mode 100644 src/controls/qquickabstractswitch.cpp delete mode 100644 src/controls/qquickabstractswitch_p.h delete mode 100644 src/controls/qquickabstracttabbar.cpp delete mode 100644 src/controls/qquickabstracttabbar_p.h delete mode 100644 src/controls/qquickabstracttabbutton.cpp delete mode 100644 src/controls/qquickabstracttabbutton_p.h delete mode 100644 src/controls/qquickabstracttabview.cpp delete mode 100644 src/controls/qquickabstracttabview_p.h delete mode 100644 src/controls/qquickabstracttextarea.cpp delete mode 100644 src/controls/qquickabstracttextarea_p.h delete mode 100644 src/controls/qquickabstracttextfield.cpp delete mode 100644 src/controls/qquickabstracttextfield_p.h delete mode 100644 src/controls/qquickabstracttogglebutton.cpp delete mode 100644 src/controls/qquickabstracttogglebutton_p.h delete mode 100644 src/controls/qquickabstracttoolbar.cpp delete mode 100644 src/controls/qquickabstracttoolbar_p.h create mode 100644 src/controls/qquickapplicationwindow.cpp create mode 100644 src/controls/qquickapplicationwindow_p.h create mode 100644 src/controls/qquickbusyindicator.cpp create mode 100644 src/controls/qquickbusyindicator_p.h create mode 100644 src/controls/qquickbutton.cpp create mode 100644 src/controls/qquickbutton_p.h create mode 100644 src/controls/qquickbutton_p_p.h create mode 100644 src/controls/qquickcheckable.cpp create mode 100644 src/controls/qquickcheckable_p.h create mode 100644 src/controls/qquickcheckable_p_p.h create mode 100644 src/controls/qquickcheckbox.cpp create mode 100644 src/controls/qquickcheckbox_p.h create mode 100644 src/controls/qquickcontainer.cpp create mode 100644 src/controls/qquickcontainer_p.h create mode 100644 src/controls/qquickcontainer_p_p.h create mode 100644 src/controls/qquickframe.cpp create mode 100644 src/controls/qquickframe_p.h create mode 100644 src/controls/qquickgroupbox.cpp create mode 100644 src/controls/qquickgroupbox_p.h create mode 100644 src/controls/qquicklabel.cpp create mode 100644 src/controls/qquicklabel_p.h create mode 100644 src/controls/qquickpageindicator.cpp create mode 100644 src/controls/qquickpageindicator_p.h create mode 100644 src/controls/qquickprogressbar.cpp create mode 100644 src/controls/qquickprogressbar_p.h create mode 100644 src/controls/qquickradiobutton.cpp create mode 100644 src/controls/qquickradiobutton_p.h create mode 100644 src/controls/qquickscrollbar.cpp create mode 100644 src/controls/qquickscrollbar_p.h create mode 100644 src/controls/qquickscrollindicator.cpp create mode 100644 src/controls/qquickscrollindicator_p.h create mode 100644 src/controls/qquickslider.cpp create mode 100644 src/controls/qquickslider_p.h create mode 100644 src/controls/qquickstackview.cpp create mode 100644 src/controls/qquickstackview_p.cpp create mode 100644 src/controls/qquickstackview_p.h create mode 100644 src/controls/qquickstackview_p_p.h create mode 100644 src/controls/qquickswitch.cpp create mode 100644 src/controls/qquickswitch_p.h create mode 100644 src/controls/qquicktabbar.cpp create mode 100644 src/controls/qquicktabbar_p.h create mode 100644 src/controls/qquicktabbutton.cpp create mode 100644 src/controls/qquicktabbutton_p.h create mode 100644 src/controls/qquicktabview.cpp create mode 100644 src/controls/qquicktabview_p.h create mode 100644 src/controls/qquicktextarea.cpp create mode 100644 src/controls/qquicktextarea_p.h create mode 100644 src/controls/qquicktextfield.cpp create mode 100644 src/controls/qquicktextfield_p.h create mode 100644 src/controls/qquicktogglebutton.cpp create mode 100644 src/controls/qquicktogglebutton_p.h create mode 100644 src/controls/qquicktoolbar.cpp create mode 100644 src/controls/qquicktoolbar_p.h delete mode 100644 src/extras/qquickabstractdrawer.cpp delete mode 100644 src/extras/qquickabstractdrawer_p.h create mode 100644 src/extras/qquickdrawer.cpp create mode 100644 src/extras/qquickdrawer_p.h (limited to 'src') diff --git a/src/calendar/calendar.pri b/src/calendar/calendar.pri index 67267388..1e1f4107 100644 --- a/src/calendar/calendar.pri +++ b/src/calendar/calendar.pri @@ -1,19 +1,19 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qquickabstractcalendarview_p.h \ - $$PWD/qquickabstractdayofweekrow_p.h \ - $$PWD/qquickabstractweeknumbercolumn_p.h \ $$PWD/qquickcalendarmodel_p.h \ + $$PWD/qquickcalendarview_p.h \ $$PWD/qquickdayofweekmodel_p.h \ + $$PWD/qquickdayofweekrow_p.h \ $$PWD/qquickmonthmodel_p.h \ + $$PWD/qquickweeknumbercolumn_p.h \ $$PWD/qquickweeknumbermodel_p.h SOURCES += \ - $$PWD/qquickabstractcalendarview.cpp \ - $$PWD/qquickabstractdayofweekrow.cpp \ - $$PWD/qquickabstractweeknumbercolumn.cpp \ $$PWD/qquickcalendarmodel.cpp \ + $$PWD/qquickcalendarview.cpp \ $$PWD/qquickdayofweekmodel.cpp \ + $$PWD/qquickdayofweekrow.cpp \ $$PWD/qquickmonthmodel.cpp \ + $$PWD/qquickweeknumbercolumn.cpp \ $$PWD/qquickweeknumbermodel.cpp diff --git a/src/calendar/qquickabstractcalendarview.cpp b/src/calendar/qquickabstractcalendarview.cpp deleted file mode 100644 index c076cc0c..00000000 --- a/src/calendar/qquickabstractcalendarview.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 "qquickabstractcalendarview_p.h" -#include "qquickmonthmodel_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractCalendarViewPrivate : public QQuickAbstractContainerPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractCalendarView) - -public: - QQuickAbstractCalendarViewPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR) { } - - QQuickItem *cellAt(const QPoint &pos) const; - QDate dateOf(QQuickItem *cell) const; - - void updatePress(const QPoint &pos); - void clearPress(bool clicked); - - static void setContextProperty(QQuickItem *item, const QString &name, const QVariant &value); - - QString title; - QVariant source; - QDate pressedDate; - int pressTimer; - QQuickItem *pressedItem; - QQuickMonthModel *model; -}; - -QQuickItem *QQuickAbstractCalendarViewPrivate::cellAt(const QPoint &pos) const -{ - Q_Q(const QQuickAbstractCalendarView); - if (contentItem) { - QPointF mapped = q->mapToItem(contentItem, pos); - return contentItem->childAt(mapped.x(), mapped.y()); - } - return Q_NULLPTR; -} - -QDate QQuickAbstractCalendarViewPrivate::dateOf(QQuickItem *cell) const -{ - if (contentItem) - return model->dateAt(contentItem->childItems().indexOf(cell)); - return QDate(); -} - -void QQuickAbstractCalendarViewPrivate::updatePress(const QPoint &pos) -{ - Q_Q(QQuickAbstractCalendarView); - clearPress(false); - pressedItem = cellAt(pos); - setContextProperty(pressedItem, QStringLiteral("pressed"), true); - pressedDate = dateOf(pressedItem); - if (pressedDate.isValid()) - emit q->pressed(pressedDate); -} - -void QQuickAbstractCalendarViewPrivate::clearPress(bool clicked) -{ - Q_Q(QQuickAbstractCalendarView); - setContextProperty(pressedItem, QStringLiteral("pressed"), false); - if (pressedDate.isValid()) { - emit q->released(pressedDate); - if (clicked) - emit q->clicked(pressedDate); - } - pressedDate = QDate(); - pressedItem = Q_NULLPTR; -} - -void QQuickAbstractCalendarViewPrivate::setContextProperty(QQuickItem *item, const QString &name, const QVariant &value) -{ - QQmlContext *context = qmlContext(item); - if (context && context->isValid()) { - context = context->parentContext(); - if (context && context->isValid()) - context->setContextProperty(name, value); - } -} - -QQuickAbstractCalendarView::QQuickAbstractCalendarView(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractCalendarViewPrivate), parent) -{ - Q_D(QQuickAbstractCalendarView); - setFlag(ItemIsFocusScope); - setActiveFocusOnTab(true); - setAcceptedMouseButtons(Qt::LeftButton); - - d->model = new QQuickMonthModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickMonthModel::monthChanged, this, &QQuickAbstractCalendarView::monthChanged); - connect(d->model, &QQuickMonthModel::yearChanged, this, &QQuickAbstractCalendarView::yearChanged); - connect(d->model, &QQuickMonthModel::localeChanged, this, &QQuickAbstractCalendarView::localeChanged); - connect(d->model, &QQuickMonthModel::titleChanged, this, &QQuickAbstractCalendarView::titleChanged); -} - -int QQuickAbstractCalendarView::month() const -{ - Q_D(const QQuickAbstractCalendarView); - return d->model->month(); -} - -void QQuickAbstractCalendarView::setMonth(int month) -{ - Q_D(QQuickAbstractCalendarView); - d->model->setMonth(month); -} - -int QQuickAbstractCalendarView::year() const -{ - Q_D(const QQuickAbstractCalendarView); - return d->model->year(); -} - -void QQuickAbstractCalendarView::setYear(int year) -{ - Q_D(QQuickAbstractCalendarView); - d->model->setYear(year); -} - -QLocale QQuickAbstractCalendarView::locale() const -{ - Q_D(const QQuickAbstractCalendarView); - return d->model->locale(); -} - -void QQuickAbstractCalendarView::setLocale(const QLocale &locale) -{ - Q_D(QQuickAbstractCalendarView); - d->model->setLocale(locale); -} - -QVariant QQuickAbstractCalendarView::source() const -{ - Q_D(const QQuickAbstractCalendarView); - return d->source; -} - -void QQuickAbstractCalendarView::setSource(const QVariant &source) -{ - Q_D(QQuickAbstractCalendarView); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QString QQuickAbstractCalendarView::title() const -{ - Q_D(const QQuickAbstractCalendarView); - if (d->title.isNull()) - return d->model->title(); - return d->title; -} - -void QQuickAbstractCalendarView::setTitle(const QString &title) -{ - Q_D(QQuickAbstractCalendarView); - if (d->title != title) { - d->title = title; - emit titleChanged(); - } -} - -void QQuickAbstractCalendarView::componentComplete() -{ - Q_D(QQuickAbstractCalendarView); - QQuickAbstractContainer::componentComplete(); - if (d->contentItem) { - foreach (QQuickItem *child, d->contentItem->childItems()) { - if (!child->inherits("QQuickRepeater")) - d->setContextProperty(child, QStringLiteral("pressed"), false); - } - } -} - -void QQuickAbstractCalendarView::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractCalendarView); - d->updatePress(event->pos()); - if (d->pressedDate.isValid()) - d->pressTimer = startTimer(qGuiApp->styleHints()->mousePressAndHoldInterval()); - event->accept(); -} - -void QQuickAbstractCalendarView::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractCalendarView); - d->updatePress(event->pos()); - event->accept(); -} - -void QQuickAbstractCalendarView::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractCalendarView); - d->clearPress(true); - event->accept(); -} - -void QQuickAbstractCalendarView::mouseUngrabEvent() -{ - Q_D(QQuickAbstractCalendarView); - d->clearPress(false); -} - -void QQuickAbstractCalendarView::timerEvent(QTimerEvent *event) -{ - Q_D(QQuickAbstractCalendarView); - if (event->timerId() == d->pressTimer) { - if (d->pressedDate.isValid()) - emit pressAndHold(d->pressedDate); - killTimer(d->pressTimer); - } -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickabstractcalendarview_p.h b/src/calendar/qquickabstractcalendarview_p.h deleted file mode 100644 index d7334cf4..00000000 --- a/src/calendar/qquickabstractcalendarview_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 QQUICKABSTRACTCALENDARVIEW_P_H -#define QQUICKABSTRACTCALENDARVIEW_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractCalendarViewPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickAbstractCalendarView : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - -public: - explicit QQuickAbstractCalendarView(QQuickItem *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - - QString title() const; - void setTitle(const QString &title); - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - void sourceChanged(); - void titleChanged(); - - void pressed(const QDate &date); - void released(const QDate &date); - void clicked(const QDate &date); - void pressAndHold(const QDate &date); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractCalendarView) - Q_DECLARE_PRIVATE(QQuickAbstractCalendarView) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCALENDARVIEW_P_H diff --git a/src/calendar/qquickabstractdayofweekrow.cpp b/src/calendar/qquickabstractdayofweekrow.cpp deleted file mode 100644 index 0d2830de..00000000 --- a/src/calendar/qquickabstractdayofweekrow.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 "qquickabstractdayofweekrow_p.h" -#include "qquickdayofweekmodel_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractDayOfWeekRowPrivate : public QQuickAbstractContainerPrivate -{ -public: - QVariant source; - QQuickDayOfWeekModel *model; -}; - -QQuickAbstractDayOfWeekRow::QQuickAbstractDayOfWeekRow(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractDayOfWeekRowPrivate), parent) -{ - Q_D(QQuickAbstractDayOfWeekRow); - d->model = new QQuickDayOfWeekModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickDayOfWeekModel::localeChanged, this, &QQuickAbstractDayOfWeekRow::localeChanged); -} - -QLocale QQuickAbstractDayOfWeekRow::locale() const -{ - Q_D(const QQuickAbstractDayOfWeekRow); - return d->model->locale(); -} - -void QQuickAbstractDayOfWeekRow::setLocale(const QLocale &locale) -{ - Q_D(QQuickAbstractDayOfWeekRow); - d->model->setLocale(locale); -} - -QVariant QQuickAbstractDayOfWeekRow::source() const -{ - Q_D(const QQuickAbstractDayOfWeekRow); - return d->source; -} - -void QQuickAbstractDayOfWeekRow::setSource(const QVariant &source) -{ - Q_D(QQuickAbstractDayOfWeekRow); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickabstractdayofweekrow_p.h b/src/calendar/qquickabstractdayofweekrow_p.h deleted file mode 100644 index 03b23348..00000000 --- a/src/calendar/qquickabstractdayofweekrow_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 QQUICKABSTRACTDAYOFWEEKROW_P_H -#define QQUICKABSTRACTDAYOFWEEKROW_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractDayOfWeekRowPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickAbstractDayOfWeekRow : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - -public: - explicit QQuickAbstractDayOfWeekRow(QQuickItem *parent = Q_NULLPTR); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - -Q_SIGNALS: - void localeChanged(); - void sourceChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractDayOfWeekRow) - Q_DECLARE_PRIVATE(QQuickAbstractDayOfWeekRow) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTDAYOFWEEKROW_P_H diff --git a/src/calendar/qquickabstractweeknumbercolumn.cpp b/src/calendar/qquickabstractweeknumbercolumn.cpp deleted file mode 100644 index 9357c0cf..00000000 --- a/src/calendar/qquickabstractweeknumbercolumn.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 "qquickabstractweeknumbercolumn_p.h" -#include "qquickweeknumbermodel_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractWeekNumberColumnPrivate : public QQuickAbstractContainerPrivate -{ -public: - QVariant source; - QQuickWeekNumberModel *model; -}; - -QQuickAbstractWeekNumberColumn::QQuickAbstractWeekNumberColumn(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractWeekNumberColumnPrivate), parent) -{ - Q_D(QQuickAbstractWeekNumberColumn); - d->model = new QQuickWeekNumberModel(this); - d->source = QVariant::fromValue(d->model); - connect(d->model, &QQuickWeekNumberModel::monthChanged, this, &QQuickAbstractWeekNumberColumn::monthChanged); - connect(d->model, &QQuickWeekNumberModel::yearChanged, this, &QQuickAbstractWeekNumberColumn::yearChanged); - connect(d->model, &QQuickWeekNumberModel::localeChanged, this, &QQuickAbstractWeekNumberColumn::localeChanged); -} - -int QQuickAbstractWeekNumberColumn::month() const -{ - Q_D(const QQuickAbstractWeekNumberColumn); - return d->model->month(); -} - -void QQuickAbstractWeekNumberColumn::setMonth(int month) -{ - Q_D(QQuickAbstractWeekNumberColumn); - d->model->setMonth(month); -} - -int QQuickAbstractWeekNumberColumn::year() const -{ - Q_D(const QQuickAbstractWeekNumberColumn); - return d->model->year(); -} - -void QQuickAbstractWeekNumberColumn::setYear(int year) -{ - Q_D(QQuickAbstractWeekNumberColumn); - d->model->setYear(year); -} - -QLocale QQuickAbstractWeekNumberColumn::locale() const -{ - Q_D(const QQuickAbstractWeekNumberColumn); - return d->model->locale(); -} - -void QQuickAbstractWeekNumberColumn::setLocale(const QLocale &locale) -{ - Q_D(QQuickAbstractWeekNumberColumn); - d->model->setLocale(locale); -} - -QVariant QQuickAbstractWeekNumberColumn::source() const -{ - Q_D(const QQuickAbstractWeekNumberColumn); - return d->source; -} - -void QQuickAbstractWeekNumberColumn::setSource(const QVariant &source) -{ - Q_D(QQuickAbstractWeekNumberColumn); - if (d->source != source) { - d->source = source; - emit sourceChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/calendar/qquickabstractweeknumbercolumn_p.h b/src/calendar/qquickabstractweeknumbercolumn_p.h deleted file mode 100644 index cc0a2856..00000000 --- a/src/calendar/qquickabstractweeknumbercolumn_p.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Calendar 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 QQUICKABSTRACTWEEKNUMBERCOLUMN_P_H -#define QQUICKABSTRACTWEEKNUMBERCOLUMN_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractWeekNumberColumnPrivate; - -class Q_QUICKCALENDAR_EXPORT QQuickAbstractWeekNumberColumn : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) - Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) - Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) - Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) - -public: - explicit QQuickAbstractWeekNumberColumn(QQuickItem *parent = Q_NULLPTR); - - int month() const; - void setMonth(int month); - - int year() const; - void setYear(int year); - - QLocale locale() const; - void setLocale(const QLocale &locale); - - QVariant source() const; - void setSource(const QVariant &source); - -Q_SIGNALS: - void monthChanged(); - void yearChanged(); - void localeChanged(); - void sourceChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractWeekNumberColumn) - Q_DECLARE_PRIVATE(QQuickAbstractWeekNumberColumn) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTWEEKNUMBERCOLUMN_P_H diff --git a/src/calendar/qquickcalendarview.cpp b/src/calendar/qquickcalendarview.cpp new file mode 100644 index 00000000..f797d686 --- /dev/null +++ b/src/calendar/qquickcalendarview.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Calendar 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 "qquickcalendarview_p.h" +#include "qquickmonthmodel_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickCalendarViewPrivate : public QQuickContainerPrivate +{ + Q_DECLARE_PUBLIC(QQuickCalendarView) + +public: + QQuickCalendarViewPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR) { } + + QQuickItem *cellAt(const QPoint &pos) const; + QDate dateOf(QQuickItem *cell) const; + + void updatePress(const QPoint &pos); + void clearPress(bool clicked); + + static void setContextProperty(QQuickItem *item, const QString &name, const QVariant &value); + + QString title; + QVariant source; + QDate pressedDate; + int pressTimer; + QQuickItem *pressedItem; + QQuickMonthModel *model; +}; + +QQuickItem *QQuickCalendarViewPrivate::cellAt(const QPoint &pos) const +{ + Q_Q(const QQuickCalendarView); + if (contentItem) { + QPointF mapped = q->mapToItem(contentItem, pos); + return contentItem->childAt(mapped.x(), mapped.y()); + } + return Q_NULLPTR; +} + +QDate QQuickCalendarViewPrivate::dateOf(QQuickItem *cell) const +{ + if (contentItem) + return model->dateAt(contentItem->childItems().indexOf(cell)); + return QDate(); +} + +void QQuickCalendarViewPrivate::updatePress(const QPoint &pos) +{ + Q_Q(QQuickCalendarView); + clearPress(false); + pressedItem = cellAt(pos); + setContextProperty(pressedItem, QStringLiteral("pressed"), true); + pressedDate = dateOf(pressedItem); + if (pressedDate.isValid()) + emit q->pressed(pressedDate); +} + +void QQuickCalendarViewPrivate::clearPress(bool clicked) +{ + Q_Q(QQuickCalendarView); + setContextProperty(pressedItem, QStringLiteral("pressed"), false); + if (pressedDate.isValid()) { + emit q->released(pressedDate); + if (clicked) + emit q->clicked(pressedDate); + } + pressedDate = QDate(); + pressedItem = Q_NULLPTR; +} + +void QQuickCalendarViewPrivate::setContextProperty(QQuickItem *item, const QString &name, const QVariant &value) +{ + QQmlContext *context = qmlContext(item); + if (context && context->isValid()) { + context = context->parentContext(); + if (context && context->isValid()) + context->setContextProperty(name, value); + } +} + +QQuickCalendarView::QQuickCalendarView(QQuickItem *parent) : + QQuickContainer(*(new QQuickCalendarViewPrivate), parent) +{ + Q_D(QQuickCalendarView); + setFlag(ItemIsFocusScope); + setActiveFocusOnTab(true); + setAcceptedMouseButtons(Qt::LeftButton); + + d->model = new QQuickMonthModel(this); + d->source = QVariant::fromValue(d->model); + connect(d->model, &QQuickMonthModel::monthChanged, this, &QQuickCalendarView::monthChanged); + connect(d->model, &QQuickMonthModel::yearChanged, this, &QQuickCalendarView::yearChanged); + connect(d->model, &QQuickMonthModel::localeChanged, this, &QQuickCalendarView::localeChanged); + connect(d->model, &QQuickMonthModel::titleChanged, this, &QQuickCalendarView::titleChanged); +} + +int QQuickCalendarView::month() const +{ + Q_D(const QQuickCalendarView); + return d->model->month(); +} + +void QQuickCalendarView::setMonth(int month) +{ + Q_D(QQuickCalendarView); + d->model->setMonth(month); +} + +int QQuickCalendarView::year() const +{ + Q_D(const QQuickCalendarView); + return d->model->year(); +} + +void QQuickCalendarView::setYear(int year) +{ + Q_D(QQuickCalendarView); + d->model->setYear(year); +} + +QLocale QQuickCalendarView::locale() const +{ + Q_D(const QQuickCalendarView); + return d->model->locale(); +} + +void QQuickCalendarView::setLocale(const QLocale &locale) +{ + Q_D(QQuickCalendarView); + d->model->setLocale(locale); +} + +QVariant QQuickCalendarView::source() const +{ + Q_D(const QQuickCalendarView); + return d->source; +} + +void QQuickCalendarView::setSource(const QVariant &source) +{ + Q_D(QQuickCalendarView); + if (d->source != source) { + d->source = source; + emit sourceChanged(); + } +} + +QString QQuickCalendarView::title() const +{ + Q_D(const QQuickCalendarView); + if (d->title.isNull()) + return d->model->title(); + return d->title; +} + +void QQuickCalendarView::setTitle(const QString &title) +{ + Q_D(QQuickCalendarView); + if (d->title != title) { + d->title = title; + emit titleChanged(); + } +} + +void QQuickCalendarView::componentComplete() +{ + Q_D(QQuickCalendarView); + QQuickContainer::componentComplete(); + if (d->contentItem) { + foreach (QQuickItem *child, d->contentItem->childItems()) { + if (!child->inherits("QQuickRepeater")) + d->setContextProperty(child, QStringLiteral("pressed"), false); + } + } +} + +void QQuickCalendarView::mousePressEvent(QMouseEvent *event) +{ + Q_D(QQuickCalendarView); + d->updatePress(event->pos()); + if (d->pressedDate.isValid()) + d->pressTimer = startTimer(qGuiApp->styleHints()->mousePressAndHoldInterval()); + event->accept(); +} + +void QQuickCalendarView::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QQuickCalendarView); + d->updatePress(event->pos()); + event->accept(); +} + +void QQuickCalendarView::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QQuickCalendarView); + d->clearPress(true); + event->accept(); +} + +void QQuickCalendarView::mouseUngrabEvent() +{ + Q_D(QQuickCalendarView); + d->clearPress(false); +} + +void QQuickCalendarView::timerEvent(QTimerEvent *event) +{ + Q_D(QQuickCalendarView); + if (event->timerId() == d->pressTimer) { + if (d->pressedDate.isValid()) + emit pressAndHold(d->pressedDate); + killTimer(d->pressTimer); + } +} + +QT_END_NAMESPACE diff --git a/src/calendar/qquickcalendarview_p.h b/src/calendar/qquickcalendarview_p.h new file mode 100644 index 00000000..407d441f --- /dev/null +++ b/src/calendar/qquickcalendarview_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Calendar 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 QQUICKCALENDARVIEW_P_H +#define QQUICKCALENDARVIEW_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickCalendarViewPrivate; + +class Q_QUICKCALENDAR_EXPORT QQuickCalendarView : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) + Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) + Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) + Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) + +public: + explicit QQuickCalendarView(QQuickItem *parent = Q_NULLPTR); + + int month() const; + void setMonth(int month); + + int year() const; + void setYear(int year); + + QLocale locale() const; + void setLocale(const QLocale &locale); + + QVariant source() const; + void setSource(const QVariant &source); + + QString title() const; + void setTitle(const QString &title); + +Q_SIGNALS: + void monthChanged(); + void yearChanged(); + void localeChanged(); + void sourceChanged(); + void titleChanged(); + + void pressed(const QDate &date); + void released(const QDate &date); + void clicked(const QDate &date); + void pressAndHold(const QDate &date); + +protected: + void componentComplete() Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickCalendarView) + Q_DECLARE_PRIVATE(QQuickCalendarView) +}; + +QT_END_NAMESPACE + +#endif // QQUICKCALENDARVIEW_P_H diff --git a/src/calendar/qquickdayofweekrow.cpp b/src/calendar/qquickdayofweekrow.cpp new file mode 100644 index 00000000..ea401bf0 --- /dev/null +++ b/src/calendar/qquickdayofweekrow.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Calendar 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 "qquickdayofweekrow_p.h" +#include "qquickdayofweekmodel_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QQuickDayOfWeekRowPrivate : public QQuickContainerPrivate +{ +public: + QVariant source; + QQuickDayOfWeekModel *model; +}; + +QQuickDayOfWeekRow::QQuickDayOfWeekRow(QQuickItem *parent) : + QQuickContainer(*(new QQuickDayOfWeekRowPrivate), parent) +{ + Q_D(QQuickDayOfWeekRow); + d->model = new QQuickDayOfWeekModel(this); + d->source = QVariant::fromValue(d->model); + connect(d->model, &QQuickDayOfWeekModel::localeChanged, this, &QQuickDayOfWeekRow::localeChanged); +} + +QLocale QQuickDayOfWeekRow::locale() const +{ + Q_D(const QQuickDayOfWeekRow); + return d->model->locale(); +} + +void QQuickDayOfWeekRow::setLocale(const QLocale &locale) +{ + Q_D(QQuickDayOfWeekRow); + d->model->setLocale(locale); +} + +QVariant QQuickDayOfWeekRow::source() const +{ + Q_D(const QQuickDayOfWeekRow); + return d->source; +} + +void QQuickDayOfWeekRow::setSource(const QVariant &source) +{ + Q_D(QQuickDayOfWeekRow); + if (d->source != source) { + d->source = source; + emit sourceChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/calendar/qquickdayofweekrow_p.h b/src/calendar/qquickdayofweekrow_p.h new file mode 100644 index 00000000..27c81e6f --- /dev/null +++ b/src/calendar/qquickdayofweekrow_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 Calendar 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 QQUICKDAYOFWEEKROW_P_H +#define QQUICKDAYOFWEEKROW_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickDayOfWeekRowPrivate; + +class Q_QUICKCALENDAR_EXPORT QQuickDayOfWeekRow : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) + Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) + +public: + explicit QQuickDayOfWeekRow(QQuickItem *parent = Q_NULLPTR); + + QLocale locale() const; + void setLocale(const QLocale &locale); + + QVariant source() const; + void setSource(const QVariant &source); + +Q_SIGNALS: + void localeChanged(); + void sourceChanged(); + +private: + Q_DISABLE_COPY(QQuickDayOfWeekRow) + Q_DECLARE_PRIVATE(QQuickDayOfWeekRow) +}; + +QT_END_NAMESPACE + +#endif // QQUICKDAYOFWEEKROW_P_H diff --git a/src/calendar/qquickweeknumbercolumn.cpp b/src/calendar/qquickweeknumbercolumn.cpp new file mode 100644 index 00000000..748ae694 --- /dev/null +++ b/src/calendar/qquickweeknumbercolumn.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Calendar 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 "qquickweeknumbercolumn_p.h" +#include "qquickweeknumbermodel_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QQuickWeekNumberColumnPrivate : public QQuickContainerPrivate +{ +public: + QVariant source; + QQuickWeekNumberModel *model; +}; + +QQuickWeekNumberColumn::QQuickWeekNumberColumn(QQuickItem *parent) : + QQuickContainer(*(new QQuickWeekNumberColumnPrivate), parent) +{ + Q_D(QQuickWeekNumberColumn); + d->model = new QQuickWeekNumberModel(this); + d->source = QVariant::fromValue(d->model); + connect(d->model, &QQuickWeekNumberModel::monthChanged, this, &QQuickWeekNumberColumn::monthChanged); + connect(d->model, &QQuickWeekNumberModel::yearChanged, this, &QQuickWeekNumberColumn::yearChanged); + connect(d->model, &QQuickWeekNumberModel::localeChanged, this, &QQuickWeekNumberColumn::localeChanged); +} + +int QQuickWeekNumberColumn::month() const +{ + Q_D(const QQuickWeekNumberColumn); + return d->model->month(); +} + +void QQuickWeekNumberColumn::setMonth(int month) +{ + Q_D(QQuickWeekNumberColumn); + d->model->setMonth(month); +} + +int QQuickWeekNumberColumn::year() const +{ + Q_D(const QQuickWeekNumberColumn); + return d->model->year(); +} + +void QQuickWeekNumberColumn::setYear(int year) +{ + Q_D(QQuickWeekNumberColumn); + d->model->setYear(year); +} + +QLocale QQuickWeekNumberColumn::locale() const +{ + Q_D(const QQuickWeekNumberColumn); + return d->model->locale(); +} + +void QQuickWeekNumberColumn::setLocale(const QLocale &locale) +{ + Q_D(QQuickWeekNumberColumn); + d->model->setLocale(locale); +} + +QVariant QQuickWeekNumberColumn::source() const +{ + Q_D(const QQuickWeekNumberColumn); + return d->source; +} + +void QQuickWeekNumberColumn::setSource(const QVariant &source) +{ + Q_D(QQuickWeekNumberColumn); + if (d->source != source) { + d->source = source; + emit sourceChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/calendar/qquickweeknumbercolumn_p.h b/src/calendar/qquickweeknumbercolumn_p.h new file mode 100644 index 00000000..66b4c85f --- /dev/null +++ b/src/calendar/qquickweeknumbercolumn_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Calendar 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 QQUICKWEEKNUMBERCOLUMN_P_H +#define QQUICKWEEKNUMBERCOLUMN_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickWeekNumberColumnPrivate; + +class Q_QUICKCALENDAR_EXPORT QQuickWeekNumberColumn : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(int month READ month WRITE setMonth NOTIFY monthChanged FINAL) + Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL) + Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL) + Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL) + +public: + explicit QQuickWeekNumberColumn(QQuickItem *parent = Q_NULLPTR); + + int month() const; + void setMonth(int month); + + int year() const; + void setYear(int year); + + QLocale locale() const; + void setLocale(const QLocale &locale); + + QVariant source() const; + void setSource(const QVariant &source); + +Q_SIGNALS: + void monthChanged(); + void yearChanged(); + void localeChanged(); + void sourceChanged(); + +private: + Q_DISABLE_COPY(QQuickWeekNumberColumn) + Q_DECLARE_PRIVATE(QQuickWeekNumberColumn) +}; + +QT_END_NAMESPACE + +#endif // QQUICKWEEKNUMBERCOLUMN_P_H diff --git a/src/controls/controls.pri b/src/controls/controls.pri index aea9b06f..0205a03e 100644 --- a/src/controls/controls.pri +++ b/src/controls/controls.pri @@ -1,63 +1,63 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qquickabstractapplicationwindow_p.h \ - $$PWD/qquickabstractbusyindicator_p.h \ - $$PWD/qquickabstractbutton_p.h \ - $$PWD/qquickabstractbutton_p_p.h \ - $$PWD/qquickabstractcheckable_p.h \ - $$PWD/qquickabstractcheckable_p_p.h \ - $$PWD/qquickabstractcheckbox_p.h \ - $$PWD/qquickabstractcontainer_p.h \ - $$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 \ - $$PWD/qquickabstractscrollbar_p.h \ - $$PWD/qquickabstractscrollindicator_p.h \ - $$PWD/qquickabstractslider_p.h \ - $$PWD/qquickabstractstackview_p.h \ - $$PWD/qquickabstractstackview_p_p.h \ - $$PWD/qquickabstractswitch_p.h \ - $$PWD/qquickabstracttabbar_p.h \ - $$PWD/qquickabstracttabbutton_p.h \ - $$PWD/qquickabstracttabview_p.h \ - $$PWD/qquickabstracttextarea_p.h \ - $$PWD/qquickabstracttextfield_p.h \ - $$PWD/qquickabstracttogglebutton_p.h \ - $$PWD/qquickabstracttoolbar_p.h \ + $$PWD/qquickapplicationwindow_p.h \ + $$PWD/qquickbusyindicator_p.h \ + $$PWD/qquickbutton_p.h \ + $$PWD/qquickbutton_p_p.h \ + $$PWD/qquickcheckable_p.h \ + $$PWD/qquickcheckable_p_p.h \ + $$PWD/qquickcheckbox_p.h \ + $$PWD/qquickcontainer_p.h \ + $$PWD/qquickcontainer_p_p.h \ $$PWD/qquickcontrol_p.h \ $$PWD/qquickcontrol_p_p.h \ - $$PWD/qquickexclusivegroup_p.h + $$PWD/qquickexclusivegroup_p.h \ + $$PWD/qquickframe_p.h \ + $$PWD/qquickgroupbox_p.h \ + $$PWD/qquicklabel_p.h \ + $$PWD/qquickpageindicator_p.h \ + $$PWD/qquickprogressbar_p.h \ + $$PWD/qquickradiobutton_p.h \ + $$PWD/qquickscrollbar_p.h \ + $$PWD/qquickscrollindicator_p.h \ + $$PWD/qquickslider_p.h \ + $$PWD/qquickstackview_p.h \ + $$PWD/qquickstackview_p_p.h \ + $$PWD/qquickswitch_p.h \ + $$PWD/qquicktabbar_p.h \ + $$PWD/qquicktabbutton_p.h \ + $$PWD/qquicktabview_p.h \ + $$PWD/qquicktextarea_p.h \ + $$PWD/qquicktextfield_p.h \ + $$PWD/qquicktogglebutton_p.h \ + $$PWD/qquicktoolbar_p.h SOURCES += \ - $$PWD/qquickabstractapplicationwindow.cpp \ - $$PWD/qquickabstractbusyindicator.cpp \ - $$PWD/qquickabstractbutton.cpp \ - $$PWD/qquickabstractcheckable.cpp \ - $$PWD/qquickabstractcheckbox.cpp \ - $$PWD/qquickabstractcontainer.cpp \ - $$PWD/qquickabstractframe.cpp \ - $$PWD/qquickabstractgroupbox.cpp \ - $$PWD/qquickabstractlabel.cpp \ - $$PWD/qquickabstractpageindicator.cpp \ - $$PWD/qquickabstractprogressbar.cpp \ - $$PWD/qquickabstractradiobutton.cpp \ - $$PWD/qquickabstractscrollbar.cpp \ - $$PWD/qquickabstractscrollindicator.cpp \ - $$PWD/qquickabstractslider.cpp \ - $$PWD/qquickabstractstackview.cpp \ - $$PWD/qquickabstractstackview_p.cpp \ - $$PWD/qquickabstractswitch.cpp \ - $$PWD/qquickabstracttabbar.cpp \ - $$PWD/qquickabstracttabbutton.cpp \ - $$PWD/qquickabstracttabview.cpp \ - $$PWD/qquickabstracttextarea.cpp \ - $$PWD/qquickabstracttextfield.cpp \ - $$PWD/qquickabstracttogglebutton.cpp \ - $$PWD/qquickabstracttoolbar.cpp \ + $$PWD/qquickapplicationwindow.cpp \ + $$PWD/qquickbusyindicator.cpp \ + $$PWD/qquickbutton.cpp \ + $$PWD/qquickcheckable.cpp \ + $$PWD/qquickcheckbox.cpp \ + $$PWD/qquickcontainer.cpp \ $$PWD/qquickcontrol.cpp \ - $$PWD/qquickexclusivegroup.cpp + $$PWD/qquickexclusivegroup.cpp \ + $$PWD/qquickframe.cpp \ + $$PWD/qquickgroupbox.cpp \ + $$PWD/qquicklabel.cpp \ + $$PWD/qquickpageindicator.cpp \ + $$PWD/qquickprogressbar.cpp \ + $$PWD/qquickradiobutton.cpp \ + $$PWD/qquickscrollbar.cpp \ + $$PWD/qquickscrollindicator.cpp \ + $$PWD/qquickslider.cpp \ + $$PWD/qquickstackview.cpp \ + $$PWD/qquickstackview_p.cpp \ + $$PWD/qquickswitch.cpp \ + $$PWD/qquicktabbar.cpp \ + $$PWD/qquicktabbutton.cpp \ + $$PWD/qquicktabview.cpp \ + $$PWD/qquicktextarea.cpp \ + $$PWD/qquicktextfield.cpp \ + $$PWD/qquicktogglebutton.cpp \ + $$PWD/qquicktoolbar.cpp diff --git a/src/controls/qquickabstractapplicationwindow.cpp b/src/controls/qquickabstractapplicationwindow.cpp deleted file mode 100644 index c5045e77..00000000 --- a/src/controls/qquickabstractapplicationwindow.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractapplicationwindow_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ApplicationWindow - \inherits Window - \instantiates QQuickAbstractApplicationWindow - \inqmlmodule QtQuick.Controls - \ingroup application - \brief An application window. - - TODO -*/ - -class QQuickAbstractApplicationWindowPrivate : public QQuickItemChangeListener -{ - Q_DECLARE_PUBLIC(QQuickAbstractApplicationWindow) - -public: - QQuickAbstractApplicationWindowPrivate() : contentWidth(0), contentHeight(0), header(Q_NULLPTR), footer(Q_NULLPTR) { } - - void relayout(); - - void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE; - void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE; - - qreal contentWidth; - qreal contentHeight; - QQuickItem *header; - QQuickItem *footer; - QQuickAbstractApplicationWindow *q_ptr; -}; - -void QQuickAbstractApplicationWindowPrivate::relayout() -{ - Q_Q(QQuickAbstractApplicationWindow); - QQuickItem *content = q->contentItem(); - qreal hh = header ? header->height() : 0; - qreal fh = footer ? footer->height() : 0; - - content->setY(hh); - content->setHeight(q->height() - hh - fh); - - if (header) - header->setY(-hh); - if (footer) - footer->setY(content->height()); -} - -void QQuickAbstractApplicationWindowPrivate::itemImplicitWidthChanged(QQuickItem *item) -{ - Q_UNUSED(item); - relayout(); -} - -void QQuickAbstractApplicationWindowPrivate::itemImplicitHeightChanged(QQuickItem *item) -{ - Q_UNUSED(item); - relayout(); -} - -QQuickAbstractApplicationWindow::QQuickAbstractApplicationWindow(QWindow *parent) : - QQuickWindowQmlImpl(parent), d_ptr(new QQuickAbstractApplicationWindowPrivate) -{ - d_ptr->q_ptr = this; -} - -QQuickAbstractApplicationWindow::~QQuickAbstractApplicationWindow() -{ - Q_D(QQuickAbstractApplicationWindow); - if (d->header) - QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); - if (d->footer) - QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); -} - -/*! - \qmlproperty Item QtQuickControls2::ApplicationWindow::header - - TODO -*/ -QQuickItem *QQuickAbstractApplicationWindow::header() const -{ - Q_D(const QQuickAbstractApplicationWindow); - return d->header; -} - -void QQuickAbstractApplicationWindow::setHeader(QQuickItem *header) -{ - Q_D(QQuickAbstractApplicationWindow); - if (d->header != header) { - delete d->header; - d->header = header; - if (header) { - header->setParentItem(contentItem()); - QQuickItemPrivate *p = QQuickItemPrivate::get(header); - p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); - if (qFuzzyIsNull(header->z())) - header->setZ(1); - } - emit headerChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::ApplicationWindow::footer - - TODO -*/ -QQuickItem *QQuickAbstractApplicationWindow::footer() const -{ - Q_D(const QQuickAbstractApplicationWindow); - return d->footer; -} - -void QQuickAbstractApplicationWindow::setFooter(QQuickItem *footer) -{ - Q_D(QQuickAbstractApplicationWindow); - if (d->footer != footer) { - delete d->footer; - d->footer = footer; - if (footer) { - footer->setParentItem(contentItem()); - QQuickItemPrivate *p = QQuickItemPrivate::get(footer); - p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); - if (qFuzzyIsNull(footer->z())) - footer->setZ(1); - } - emit footerChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::ApplicationWindow::contentWidth - - TODO -*/ -qreal QQuickAbstractApplicationWindow::contentWidth() const -{ - Q_D(const QQuickAbstractApplicationWindow); - return d->contentWidth; -} - -void QQuickAbstractApplicationWindow::setContentWidth(qreal width) -{ - Q_D(QQuickAbstractApplicationWindow); - if (d->contentWidth != width) { - d->contentWidth = width; - emit contentWidthChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::ApplicationWindow::contentHeight - - TODO -*/ -qreal QQuickAbstractApplicationWindow::contentHeight() const -{ - Q_D(const QQuickAbstractApplicationWindow); - return d->contentHeight; -} - -void QQuickAbstractApplicationWindow::setContentHeight(qreal height) -{ - Q_D(QQuickAbstractApplicationWindow); - if (d->contentHeight != height) { - d->contentHeight = height; - emit contentHeightChanged(); - } -} - -void QQuickAbstractApplicationWindow::resizeEvent(QResizeEvent *event) -{ - QQuickWindowQmlImpl::resizeEvent(event); - - Q_D(QQuickAbstractApplicationWindow); - if (d->header) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->header); - if (!p->widthValid) { - d->header->setWidth(width()); - p->widthValid = false; - } - } - if (d->footer) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->footer); - if (!p->widthValid) { - d->footer->setWidth(width()); - p->widthValid = false; - } - } - d->relayout(); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractapplicationwindow_p.h b/src/controls/qquickabstractapplicationwindow_p.h deleted file mode 100644 index 4b378123..00000000 --- a/src/controls/qquickabstractapplicationwindow_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTAPPLICATIONWINDOW_P_H -#define QQUICKABSTRACTAPPLICATIONWINDOW_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractApplicationWindowPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractApplicationWindow : public QQuickWindowQmlImpl -{ - Q_OBJECT - Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) - Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) - Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) - Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) - -public: - explicit QQuickAbstractApplicationWindow(QWindow *parent = Q_NULLPTR); - ~QQuickAbstractApplicationWindow(); - - QQuickItem *header() const; - void setHeader(QQuickItem *header); - - QQuickItem *footer() const; - void setFooter(QQuickItem *footer); - - qreal contentWidth() const; - void setContentWidth(qreal width); - - qreal contentHeight() const; - void setContentHeight(qreal height); - -Q_SIGNALS: - void headerChanged(); - void footerChanged(); - void contentWidthChanged(); - void contentHeightChanged(); - -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractApplicationWindow) - Q_DECLARE_PRIVATE(QQuickAbstractApplicationWindow) - QScopedPointer d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTAPPLICATIONWINDOW_P_H diff --git a/src/controls/qquickabstractbusyindicator.cpp b/src/controls/qquickabstractbusyindicator.cpp deleted file mode 100644 index 4370668a..00000000 --- a/src/controls/qquickabstractbusyindicator.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractbusyindicator_p.h" -#include "qquickcontrol_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype BusyIndicator - \inherits Control - \instantiates QQuickAbstractBusyIndicator - \inqmlmodule QtQuick.Controls - \ingroup indicators - \brief A busy indicator. - - TODO -*/ - -class QQuickAbstractBusyIndicatorPrivate : public QQuickControlPrivate -{ -public: - QQuickAbstractBusyIndicatorPrivate() : running(false), indicator(Q_NULLPTR) { } - - bool running; - QQuickItem *indicator; -}; - -QQuickAbstractBusyIndicator::QQuickAbstractBusyIndicator(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractBusyIndicatorPrivate), parent) -{ -} - -/*! - \qmlproperty bool QtQuickControls2::BusyIndicator::running - - TODO -*/ -bool QQuickAbstractBusyIndicator::isRunning() const -{ - Q_D(const QQuickAbstractBusyIndicator); - return d->running; -} - -void QQuickAbstractBusyIndicator::setRunning(bool running) -{ - Q_D(QQuickAbstractBusyIndicator); - if (d->running != running) { - d->running = running; - emit runningChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::BusyIndicator::indicator - - TODO -*/ -QQuickItem *QQuickAbstractBusyIndicator::indicator() const -{ - Q_D(const QQuickAbstractBusyIndicator); - return d->indicator; -} - -void QQuickAbstractBusyIndicator::setIndicator(QQuickItem *indicator) -{ - Q_D(QQuickAbstractBusyIndicator); - if (d->indicator != indicator) { - delete d->indicator; - d->indicator = indicator; - if (indicator && !indicator->parentItem()) - indicator->setParentItem(this); - emit indicatorChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractbusyindicator_p.h b/src/controls/qquickabstractbusyindicator_p.h deleted file mode 100644 index e9955c6e..00000000 --- a/src/controls/qquickabstractbusyindicator_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTBUSYINDICATOR_P_H -#define QQUICKABSTRACTBUSYINDICATOR_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractBusyIndicatorPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractBusyIndicator : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged FINAL) - Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - -public: - explicit QQuickAbstractBusyIndicator(QQuickItem *parent = Q_NULLPTR); - - bool isRunning() const; - void setRunning(bool running); - - QQuickItem *indicator() const; - void setIndicator(QQuickItem *indicator); - -Q_SIGNALS: - void runningChanged(); - void indicatorChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractBusyIndicator) - Q_DECLARE_PRIVATE(QQuickAbstractBusyIndicator) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTBUSYINDICATOR_P_H diff --git a/src/controls/qquickabstractbutton.cpp b/src/controls/qquickabstractbutton.cpp deleted file mode 100644 index 5b207520..00000000 --- a/src/controls/qquickabstractbutton.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractbutton_p.h" -#include "qquickabstractbutton_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Button - \inherits Control - \instantiates QQuickAbstractButton - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A button control. - - TODO -*/ - -QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() : - pressed(false), label(Q_NULLPTR) -{ -} - -QQuickAbstractButton::QQuickAbstractButton(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractButtonPrivate), parent) -{ - setActiveFocusOnTab(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -QQuickAbstractButton::QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent) : - QQuickControl(dd, parent) -{ - setActiveFocusOnTab(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -/*! - \qmlproperty string QtQuickControls2::Button::text - - TODO -*/ -QString QQuickAbstractButton::text() const -{ - Q_D(const QQuickAbstractButton); - return d->text; -} - -void QQuickAbstractButton::setText(const QString &text) -{ - Q_D(QQuickAbstractButton); - if (d->text != text) { - d->text = text; - emit textChanged(); - } -} - -/*! - \qmlproperty bool QtQuickControls2::Button::pressed - - TODO -*/ -bool QQuickAbstractButton::isPressed() const -{ - Q_D(const QQuickAbstractButton); - return d->pressed; -} - -void QQuickAbstractButton::setPressed(bool pressed) -{ - Q_D(QQuickAbstractButton); - if (d->pressed != pressed) { - d->pressed = pressed; - emit pressedChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::Button::label - - TODO -*/ -QQuickItem *QQuickAbstractButton::label() const -{ - Q_D(const QQuickAbstractButton); - return d->label; -} - -void QQuickAbstractButton::setLabel(QQuickItem *label) -{ - Q_D(QQuickAbstractButton); - if (d->label != label) { - delete d->label; - d->label = label; - if (label && !label->parentItem()) - label->setParentItem(this); - emit labelChanged(); - } -} - -void QQuickAbstractButton::focusOutEvent(QFocusEvent *event) -{ - QQuickControl::focusOutEvent(event); - setPressed(false); -} - -void QQuickAbstractButton::keyPressEvent(QKeyEvent *event) -{ - QQuickControl::keyPressEvent(event); - if (event->key() == Qt::Key_Space) { - setPressed(true); - event->accept(); - } -} - -void QQuickAbstractButton::keyReleaseEvent(QKeyEvent *event) -{ - QQuickControl::keyReleaseEvent(event); - if (event->key() == Qt::Key_Space) { - emit clicked(); - setPressed(false); - event->accept(); - } -} - -void QQuickAbstractButton::mousePressEvent(QMouseEvent *event) -{ - QQuickControl::mousePressEvent(event); - setPressed(true); - event->accept(); -} - -void QQuickAbstractButton::mouseMoveEvent(QMouseEvent *event) -{ - QQuickControl::mouseMoveEvent(event); - setPressed(contains(event->pos())); - event->accept(); -} - -void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event) -{ - QQuickControl::mouseReleaseEvent(event); - if (contains(event->pos())) - emit clicked(); - setPressed(false); - event->accept(); -} - -void QQuickAbstractButton::mouseUngrabEvent() -{ - QQuickControl::mouseUngrabEvent(); - setPressed(false); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractbutton_p.h b/src/controls/qquickabstractbutton_p.h deleted file mode 100644 index 2bbfb5b8..00000000 --- a/src/controls/qquickabstractbutton_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTBUTTON_P_H -#define QQUICKABSTRACTBUTTON_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractButtonPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractButton : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) - Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) - Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) - -public: - explicit QQuickAbstractButton(QQuickItem *parent = Q_NULLPTR); - - QString text() const; - void setText(const QString &text); - - bool isPressed() const; - void setPressed(bool pressed); - - QQuickItem *label() const; - void setLabel(QQuickItem *label); - -Q_SIGNALS: - void clicked(); - void textChanged(); - void pressedChanged(); - void labelChanged(); - -protected: - QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent); - - void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractButton) - Q_DECLARE_PRIVATE(QQuickAbstractButton) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTBUTTON_P_H diff --git a/src/controls/qquickabstractbutton_p_p.h b/src/controls/qquickabstractbutton_p_p.h deleted file mode 100644 index 252a2863..00000000 --- a/src/controls/qquickabstractbutton_p_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTBUTTON_P_P_H -#define QQUICKABSTRACTBUTTON_P_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractButtonPrivate : public QQuickControlPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractButton) - -public: - QQuickAbstractButtonPrivate(); - - QString text; - bool pressed; - QQuickItem *label; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTBUTTON_P_P_H diff --git a/src/controls/qquickabstractcheckable.cpp b/src/controls/qquickabstractcheckable.cpp deleted file mode 100644 index 3811ada4..00000000 --- a/src/controls/qquickabstractcheckable.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractcheckable_p.h" -#include "qquickabstractcheckable_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Checkable - \inherits Button - \instantiates QQuickAbstractCheckable - \inqmlmodule QtQuick.Controls - \qmlabstract - \internal -*/ - -QQuickAbstractCheckablePrivate::QQuickAbstractCheckablePrivate() : - checked(false), exclusive(false), indicator(Q_NULLPTR), layoutDirection(Qt::LeftToRight) -{ -} - -QQuickAbstractCheckable::QQuickAbstractCheckable(QQuickItem *parent) : - QQuickAbstractButton(*(new QQuickAbstractCheckablePrivate), parent) -{ -} - -QQuickAbstractCheckable::QQuickAbstractCheckable(QQuickAbstractCheckablePrivate &dd, QQuickItem *parent) : - QQuickAbstractButton(dd, parent) -{ -} - -/*! - \qmlproperty bool QtQuickControls2::Checkable::checked - - TODO -*/ -bool QQuickAbstractCheckable::isChecked() const -{ - Q_D(const QQuickAbstractCheckable); - return d->checked; -} - -void QQuickAbstractCheckable::setChecked(bool checked) -{ - Q_D(QQuickAbstractCheckable); - if (d->checked != checked) { - d->checked = checked; - emit checkedChanged(); - } -} - -bool QQuickAbstractCheckable::isExclusive() const -{ - Q_D(const QQuickAbstractCheckable); - return d->exclusive; -} - -void QQuickAbstractCheckable::setExclusive(bool exclusive) -{ - Q_D(QQuickAbstractCheckable); - d->exclusive = exclusive; -} - -/*! - \qmlproperty Item QtQuickControls2::Checkable::indicator - - TODO -*/ -QQuickItem *QQuickAbstractCheckable::indicator() const -{ - Q_D(const QQuickAbstractCheckable); - return d->indicator; -} - -void QQuickAbstractCheckable::setIndicator(QQuickItem *indicator) -{ - Q_D(QQuickAbstractCheckable); - if (d->indicator != indicator) { - delete d->indicator; - d->indicator = indicator; - if (indicator) { - if (!indicator->parentItem()) - indicator->setParentItem(this); - indicator->setAcceptedMouseButtons(Qt::LeftButton); - } - emit indicatorChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::Checkable::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractCheckable::layoutDirection() const -{ - Q_D(const QQuickAbstractCheckable); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::Checkable::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractCheckable::effectiveLayoutDirection() const -{ - Q_D(const QQuickAbstractCheckable); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickAbstractCheckable::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickAbstractCheckable); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlmethod void QtQuickControls2::Checkable::toggle() - - TODO -*/ -void QQuickAbstractCheckable::toggle() -{ - Q_D(QQuickAbstractCheckable); - setChecked(!d->checked); -} - -void QQuickAbstractCheckable::keyReleaseEvent(QKeyEvent *event) -{ - Q_D(QQuickAbstractCheckable); - QQuickAbstractButton::keyReleaseEvent(event); - if (event->key() == Qt::Key_Space) - setChecked(d->exclusive || !d->checked); -} - -void QQuickAbstractCheckable::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractCheckable); - QQuickAbstractButton::mouseReleaseEvent(event); - if (contains(event->pos())) - setChecked(d->exclusive || !d->checked); -} - -void QQuickAbstractCheckable::mirrorChange() -{ - emit effectiveLayoutDirectionChanged(); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractcheckable_p.h b/src/controls/qquickabstractcheckable_p.h deleted file mode 100644 index b470fd60..00000000 --- a/src/controls/qquickabstractcheckable_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCHECKABLE_P_H -#define QQUICKABSTRACTCHECKABLE_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractCheckablePrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractCheckable : public QQuickAbstractButton -{ - Q_OBJECT - Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) - Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) - -public: - explicit QQuickAbstractCheckable(QQuickItem *parent = Q_NULLPTR); - - bool isChecked() const; - void setChecked(bool checked); - - bool isExclusive() const; - void setExclusive(bool exclusive); - - QQuickItem *indicator() const; - void setIndicator(QQuickItem *indicator); - - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - -public Q_SLOTS: - void toggle(); - -Q_SIGNALS: - void checkedChanged(); - void indicatorChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); - -protected: - QQuickAbstractCheckable(QQuickAbstractCheckablePrivate &dd, QQuickItem *parent); - - void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - - void mirrorChange() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractCheckable) - Q_DECLARE_PRIVATE(QQuickAbstractCheckable) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCHECKABLE_P_H diff --git a/src/controls/qquickabstractcheckable_p_p.h b/src/controls/qquickabstractcheckable_p_p.h deleted file mode 100644 index dcc44b8d..00000000 --- a/src/controls/qquickabstractcheckable_p_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCHECKABLE_P_P_H -#define QQUICKABSTRACTCHECKABLE_P_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractCheckablePrivate : public QQuickAbstractButtonPrivate -{ -public: - QQuickAbstractCheckablePrivate(); - - bool checked; - bool exclusive; - QQuickItem *indicator; - Qt::LayoutDirection layoutDirection; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCHECKABLE_P_P_H diff --git a/src/controls/qquickabstractcheckbox.cpp b/src/controls/qquickabstractcheckbox.cpp deleted file mode 100644 index 67d9efab..00000000 --- a/src/controls/qquickabstractcheckbox.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractcheckbox_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype CheckBox - \inherits Checkable - \instantiates QQuickAbstractCheckBox - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A check box control. - - TODO -*/ - -QQuickAbstractCheckBox::QQuickAbstractCheckBox(QQuickItem *parent) : - QQuickAbstractCheckable(parent) -{ -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractcheckbox_p.h b/src/controls/qquickabstractcheckbox_p.h deleted file mode 100644 index 6016143f..00000000 --- a/src/controls/qquickabstractcheckbox_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCHECKBOX_P_H -#define QQUICKABSTRACTCHECKBOX_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractCheckBox : public QQuickAbstractCheckable -{ - Q_OBJECT - -public: - explicit QQuickAbstractCheckBox(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCHECKBOX_P_H diff --git a/src/controls/qquickabstractcontainer.cpp b/src/controls/qquickabstractcontainer.cpp deleted file mode 100644 index 263ced7a..00000000 --- a/src/controls/qquickabstractcontainer.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractcontainer_p.h" -#include "qquickabstractcontainer_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Container - \inherits Control - \instantiates QQuickAbstractContainer - \inqmlmodule QtQuick.Controls - \qmlabstract - \internal -*/ - -QQuickAbstractContainerPrivate::QQuickAbstractContainerPrivate() : - contentWidth(0), contentHeight(0), contentItem(Q_NULLPTR) -{ -} - -QQuickAbstractContainer::QQuickAbstractContainer(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractContainerPrivate), parent) -{ -} - -QQuickAbstractContainer::QQuickAbstractContainer(QQuickAbstractContainerPrivate &dd, QQuickItem *parent) : - QQuickControl(dd, parent) -{ -} - -/*! - \qmlproperty real QtQuickControls2::Container::contentWidth - - TODO -*/ -qreal QQuickAbstractContainer::contentWidth() const -{ - Q_D(const QQuickAbstractContainer); - return d->contentWidth; -} - -void QQuickAbstractContainer::setContentWidth(qreal width) -{ - Q_D(QQuickAbstractContainer); - if (d->contentWidth != width) { - d->contentWidth = width; - emit contentWidthChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::Container::contentHeight - - TODO -*/ -qreal QQuickAbstractContainer::contentHeight() const -{ - Q_D(const QQuickAbstractContainer); - return d->contentHeight; -} - -void QQuickAbstractContainer::setContentHeight(qreal height) -{ - Q_D(QQuickAbstractContainer); - if (d->contentHeight != height) { - d->contentHeight = height; - emit contentHeightChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::Container::contentItem - - TODO -*/ -QQuickItem *QQuickAbstractContainer::contentItem() const -{ - Q_D(const QQuickAbstractContainer); - return d->contentItem; -} - -void QQuickAbstractContainer::setContentItem(QQuickItem *item) -{ - Q_D(QQuickAbstractContainer); - if (d->contentItem != item) { - contentItemChange(d->contentItem, item); - delete d->contentItem; - d->contentItem = item; - if (item) { - if (!item->parentItem()) - item->setParentItem(this); - } - emit contentItemChanged(); - } -} - -void QQuickAbstractContainer::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) -{ - Q_UNUSED(newItem); - Q_UNUSED(oldItem); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractcontainer_p.h b/src/controls/qquickabstractcontainer_p.h deleted file mode 100644 index 71bc5f5d..00000000 --- a/src/controls/qquickabstractcontainer_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCONTAINER_P_H -#define QQUICKABSTRACTCONTAINER_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractContainerPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractContainer : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) - Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) - Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) - -public: - explicit QQuickAbstractContainer(QQuickItem *parent = Q_NULLPTR); - - qreal contentWidth() const; - void setContentWidth(qreal width); - - qreal contentHeight() const; - void setContentHeight(qreal height); - - QQuickItem *contentItem() const; - void setContentItem(QQuickItem *item); - -Q_SIGNALS: - void contentWidthChanged(); - void contentHeightChanged(); - void contentItemChanged(); - -protected: - QQuickAbstractContainer(QQuickAbstractContainerPrivate &dd, QQuickItem *parent); - - virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem); - -private: - Q_DISABLE_COPY(QQuickAbstractContainer) - Q_DECLARE_PRIVATE(QQuickAbstractContainer) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCONTAINER_P_H diff --git a/src/controls/qquickabstractcontainer_p_p.h b/src/controls/qquickabstractcontainer_p_p.h deleted file mode 100644 index 8e19277d..00000000 --- a/src/controls/qquickabstractcontainer_p_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTCONTAINER_P_P_H -#define QQUICKABSTRACTCONTAINER_P_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractContainerPrivate : public QQuickControlPrivate -{ -public: - QQuickAbstractContainerPrivate(); - - qreal contentWidth; - qreal contentHeight; - QQuickItem *contentItem; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTCONTAINER_P_P_H diff --git a/src/controls/qquickabstractframe.cpp b/src/controls/qquickabstractframe.cpp deleted file mode 100644 index 9f8f2aa6..00000000 --- a/src/controls/qquickabstractframe.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractframe_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Frame - \inherits Container - \instantiates QQuickAbstractFrame - \inqmlmodule QtQuick.Controls - \ingroup containers - \brief A frame control. - - TODO -*/ - -QQuickAbstractFrame::QQuickAbstractFrame(QQuickItem *parent) : - QQuickAbstractContainer(parent) -{ -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractframe_p.h b/src/controls/qquickabstractframe_p.h deleted file mode 100644 index 6c03660f..00000000 --- a/src/controls/qquickabstractframe_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTFRAME_P_H -#define QQUICKABSTRACTFRAME_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractFrame : public QQuickAbstractContainer -{ - Q_OBJECT - -public: - explicit QQuickAbstractFrame(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTFRAME_P_H diff --git a/src/controls/qquickabstractgroupbox.cpp b/src/controls/qquickabstractgroupbox.cpp deleted file mode 100644 index 8d2f9ec0..00000000 --- a/src/controls/qquickabstractgroupbox.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractgroupbox_p.h" -#include "qquickabstractcontainer_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype GroupBox - \inherits Container - \instantiates QQuickAbstractGroupBox - \inqmlmodule QtQuick.Controls - \ingroup containers - \brief A group box control. - - TODO -*/ - -class QQuickAbstractGroupBoxPrivate : public QQuickAbstractContainerPrivate -{ -public: - QQuickAbstractGroupBoxPrivate() : label(Q_NULLPTR), frame(Q_NULLPTR) { } - - QString title; - QQuickItem *label; - QQuickItem *frame; -}; - -QQuickAbstractGroupBox::QQuickAbstractGroupBox(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractGroupBoxPrivate), parent) -{ -} - -/*! - \qmlproperty string QtQuickControls2::GroupBox::title - - TODO -*/ -QString QQuickAbstractGroupBox::title() const -{ - Q_D(const QQuickAbstractGroupBox); - return d->title; -} - -void QQuickAbstractGroupBox::setTitle(const QString &title) -{ - Q_D(QQuickAbstractGroupBox); - if (d->title != title) { - d->title = title; - emit titleChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::GroupBox::label - - TODO -*/ -QQuickItem *QQuickAbstractGroupBox::label() const -{ - Q_D(const QQuickAbstractGroupBox); - return d->label; -} - -void QQuickAbstractGroupBox::setLabel(QQuickItem *label) -{ - Q_D(QQuickAbstractGroupBox); - if (d->label != label) { - delete d->label; - d->label = label; - if (label && !label->parentItem()) - label->setParentItem(this); - emit labelChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::GroupBox::frame - - TODO -*/ -QQuickItem *QQuickAbstractGroupBox::frame() const -{ - Q_D(const QQuickAbstractGroupBox); - return d->frame; -} - -void QQuickAbstractGroupBox::setFrame(QQuickItem *frame) -{ - Q_D(QQuickAbstractGroupBox); - if (d->frame != frame) { - delete d->frame; - d->frame = frame; - if (frame && !frame->parentItem()) - frame->setParentItem(this); - emit frameChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractgroupbox_p.h b/src/controls/qquickabstractgroupbox_p.h deleted file mode 100644 index 5e77fb23..00000000 --- a/src/controls/qquickabstractgroupbox_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTGROUPBOX_P_H -#define QQUICKABSTRACTGROUPBOX_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractGroupBoxPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractGroupBox : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) - Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL) - -public: - explicit QQuickAbstractGroupBox(QQuickItem *parent = Q_NULLPTR); - - QString title() const; - void setTitle(const QString &title); - - QQuickItem *label() const; - void setLabel(QQuickItem *label); - - QQuickItem *frame() const; - void setFrame(QQuickItem *frame); - -Q_SIGNALS: - void titleChanged(); - void labelChanged(); - void frameChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractGroupBox) - Q_DECLARE_PRIVATE(QQuickAbstractGroupBox) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTGROUPBOX_P_H diff --git a/src/controls/qquickabstractlabel.cpp b/src/controls/qquickabstractlabel.cpp deleted file mode 100644 index 8e1df9cb..00000000 --- a/src/controls/qquickabstractlabel.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -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 deleted file mode 100644 index d731550c..00000000 --- a/src/controls/qquickabstractlabel_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -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 d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTLABEL_P_H diff --git a/src/controls/qquickabstractpageindicator.cpp b/src/controls/qquickabstractpageindicator.cpp deleted file mode 100644 index ee3b98bd..00000000 --- a/src/controls/qquickabstractpageindicator.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractpageindicator_p.h" -#include "qquickabstractcontainer_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype PageIndicator - \inherits Control - \instantiates QQuickAbstractPageIndicator - \inqmlmodule QtQuick.Controls - \ingroup indicators - \brief A page indicator. - - TODO -*/ - -class QQuickAbstractPageIndicatorPrivate : public QQuickAbstractContainerPrivate -{ -public: - QQuickAbstractPageIndicatorPrivate() : count(0), currentIndex(0) { } - - int count; - int currentIndex; -}; - -QQuickAbstractPageIndicator::QQuickAbstractPageIndicator(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractPageIndicatorPrivate), parent) -{ -} - -/*! - \qmlproperty int QtQuickControls2::PageIndicator::count - - TODO -*/ -int QQuickAbstractPageIndicator::count() const -{ - Q_D(const QQuickAbstractPageIndicator); - return d->count; -} - -void QQuickAbstractPageIndicator::setCount(int count) -{ - Q_D(QQuickAbstractPageIndicator); - if (d->count != count) { - d->count = count; - emit countChanged(); - } -} - -/*! - \qmlproperty int QtQuickControls2::PageIndicator::currentIndex - - TODO -*/ -int QQuickAbstractPageIndicator::currentIndex() const -{ - Q_D(const QQuickAbstractPageIndicator); - return d->currentIndex; -} - -void QQuickAbstractPageIndicator::setCurrentIndex(int index) -{ - Q_D(QQuickAbstractPageIndicator); - if (d->currentIndex != index) { - d->currentIndex = index; - emit currentIndexChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractpageindicator_p.h b/src/controls/qquickabstractpageindicator_p.h deleted file mode 100644 index 4198f644..00000000 --- a/src/controls/qquickabstractpageindicator_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTPAGEINDICATOR_P_H -#define QQUICKABSTRACTPAGEINDICATOR_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractPageIndicatorPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractPageIndicator : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged FINAL) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) - -public: - explicit QQuickAbstractPageIndicator(QQuickItem *parent = Q_NULLPTR); - - int count() const; - void setCount(int count); - - int currentIndex() const; - void setCurrentIndex(int index); - -Q_SIGNALS: - void countChanged(); - void currentIndexChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractPageIndicator) - Q_DECLARE_PRIVATE(QQuickAbstractPageIndicator) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTPAGEINDICATOR_P_H diff --git a/src/controls/qquickabstractprogressbar.cpp b/src/controls/qquickabstractprogressbar.cpp deleted file mode 100644 index 7e38b167..00000000 --- a/src/controls/qquickabstractprogressbar.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractprogressbar_p.h" -#include "qquickcontrol_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ProgressBar - \inherits Control - \instantiates QQuickAbstractProgressBar - \inqmlmodule QtQuick.Controls - \ingroup indicators - \brief A progress bar. - - TODO -*/ - -class QQuickAbstractProgressBarPrivate : public QQuickControlPrivate -{ -public: - QQuickAbstractProgressBarPrivate() : value(0), indeterminate(false), - layoutDirection(Qt::LeftToRight), indicator(Q_NULLPTR) { } - - qreal value; - bool indeterminate; - Qt::LayoutDirection layoutDirection; - QQuickItem *indicator; -}; - -QQuickAbstractProgressBar::QQuickAbstractProgressBar(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractProgressBarPrivate), parent) -{ -} - -/*! - \qmlproperty real QtQuickControls2::ProgressBar::value - - TODO -*/ -qreal QQuickAbstractProgressBar::value() const -{ - Q_D(const QQuickAbstractProgressBar); - return d->value; -} - -void QQuickAbstractProgressBar::setValue(qreal value) -{ - Q_D(QQuickAbstractProgressBar); - value = qBound(0.0, value, 1.0); - if (!qFuzzyCompare(d->value, value)) { - d->value = value; - emit valueChanged(); - emit visualPositionChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::ProgressBar::visualPosition - - TODO -*/ -qreal QQuickAbstractProgressBar::visualPosition() const -{ - Q_D(const QQuickAbstractProgressBar); - if (effectiveLayoutDirection() == Qt::RightToLeft) - return 1.0 - d->value; - return d->value; -} - -/*! - \qmlproperty bool QtQuickControls2::ProgressBar::indeterminate - - TODO -*/ -bool QQuickAbstractProgressBar::isIndeterminate() const -{ - Q_D(const QQuickAbstractProgressBar); - return d->indeterminate; -} - -void QQuickAbstractProgressBar::setIndeterminate(bool indeterminate) -{ - Q_D(QQuickAbstractProgressBar); - if (d->indeterminate != indeterminate) { - d->indeterminate = indeterminate; - emit indeterminateChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::ProgressBar::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractProgressBar::layoutDirection() const -{ - Q_D(const QQuickAbstractProgressBar); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::ProgressBar::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractProgressBar::effectiveLayoutDirection() const -{ - Q_D(const QQuickAbstractProgressBar); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickAbstractProgressBar::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickAbstractProgressBar); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::ProgressBar::indicator - - TODO -*/ -QQuickItem *QQuickAbstractProgressBar::indicator() const -{ - Q_D(const QQuickAbstractProgressBar); - return d->indicator; -} - -void QQuickAbstractProgressBar::setIndicator(QQuickItem *indicator) -{ - Q_D(QQuickAbstractProgressBar); - if (d->indicator != indicator) { - delete d->indicator; - d->indicator = indicator; - if (indicator && !indicator->parentItem()) - indicator->setParentItem(this); - emit indicatorChanged(); - } -} - -void QQuickAbstractProgressBar::mirrorChange() -{ - emit effectiveLayoutDirectionChanged(); - emit visualPositionChanged(); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractprogressbar_p.h b/src/controls/qquickabstractprogressbar_p.h deleted file mode 100644 index d8d3ac36..00000000 --- a/src/controls/qquickabstractprogressbar_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTPROGRESSBAR_P_H -#define QQUICKABSTRACTPROGRESSBAR_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractProgressBarPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractProgressBar : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) - Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) - Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) - Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - -public: - explicit QQuickAbstractProgressBar(QQuickItem *parent = Q_NULLPTR); - - qreal value() const; - void setValue(qreal value); - - qreal visualPosition() const; - - bool isIndeterminate() const; - void setIndeterminate(bool indeterminate); - - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - - QQuickItem *indicator() const; - void setIndicator(QQuickItem *indicator); - -Q_SIGNALS: - void valueChanged(); - void visualPositionChanged(); - void indeterminateChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); - void indicatorChanged(); - -protected: - void mirrorChange() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractProgressBar) - Q_DECLARE_PRIVATE(QQuickAbstractProgressBar) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTPROGRESSBAR_P_H diff --git a/src/controls/qquickabstractradiobutton.cpp b/src/controls/qquickabstractradiobutton.cpp deleted file mode 100644 index 75f47ac0..00000000 --- a/src/controls/qquickabstractradiobutton.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractradiobutton_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype RadioButton - \inherits Checkable - \instantiates QQuickAbstractRadioButton - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A radio button control. - - TODO - - \sa ExclusiveGroup -*/ - -QQuickAbstractRadioButton::QQuickAbstractRadioButton(QQuickItem *parent) : - QQuickAbstractCheckable(parent) -{ - setExclusive(true); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractradiobutton_p.h b/src/controls/qquickabstractradiobutton_p.h deleted file mode 100644 index 9d027ee6..00000000 --- a/src/controls/qquickabstractradiobutton_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTRADIOBUTTON_P_H -#define QQUICKABSTRACTRADIOBUTTON_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractRadioButton : public QQuickAbstractCheckable -{ - Q_OBJECT - -public: - explicit QQuickAbstractRadioButton(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTRADIOBUTTON_P_H diff --git a/src/controls/qquickabstractscrollbar.cpp b/src/controls/qquickabstractscrollbar.cpp deleted file mode 100644 index e1036bd0..00000000 --- a/src/controls/qquickabstractscrollbar.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractscrollbar_p.h" -#include "qquickcontrol_p_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ScrollBar - \inherits Control - \instantiates QQuickAbstractScrollBar - \inqmlmodule QtQuick.Controls - \ingroup indicators - \ingroup sliders - \brief A scroll bar. - - TODO -*/ - -class QQuickAbstractScrollBarPrivate : public QQuickControlPrivate -{ -public: - QQuickAbstractScrollBarPrivate() : size(0), position(0), offset(0), - active(false), pressed(false), moving(false), - orientation(Qt::Vertical), handle(Q_NULLPTR) { } - - static QQuickAbstractScrollBarPrivate *get(QQuickAbstractScrollBar *bar) - { - return bar->d_func(); - } - - qreal size; - qreal position; - qreal offset; - bool active; - bool pressed; - bool moving; - Qt::Orientation orientation; - QQuickItem *handle; -}; - -QQuickAbstractScrollBar::QQuickAbstractScrollBar(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractScrollBarPrivate), parent) -{ - setKeepMouseGrab(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -QQuickScrollBarAttached *QQuickAbstractScrollBar::qmlAttachedProperties(QObject *object) -{ - QQuickFlickable *flickable = qobject_cast(object); - if (flickable) - return new QQuickScrollBarAttached(flickable); - - qWarning() << "ScrollBar must be attached to a Flickable" << object; - return Q_NULLPTR; -} - -/*! - \qmlproperty real QtQuickControls2::ScrollBar::size - - TODO -*/ -qreal QQuickAbstractScrollBar::size() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->size; -} - -void QQuickAbstractScrollBar::setSize(qreal size) -{ - Q_D(QQuickAbstractScrollBar); - if (!qFuzzyCompare(d->size, size)) { - d->size = size; - emit sizeChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::ScrollBar::position - - TODO -*/ -qreal QQuickAbstractScrollBar::position() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->position; -} - -void QQuickAbstractScrollBar::setPosition(qreal position) -{ - Q_D(QQuickAbstractScrollBar); - if (!qFuzzyCompare(d->position, position)) { - d->position = position; - emit positionChanged(); - } -} - -/*! - \qmlproperty bool QtQuickControls2::ScrollBar::active - - TODO -*/ -bool QQuickAbstractScrollBar::isActive() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->active; -} - -void QQuickAbstractScrollBar::setActive(bool active) -{ - Q_D(QQuickAbstractScrollBar); - if (d->active != active) { - d->active = active; - emit activeChanged(); - } -} - -/*! - \qmlproperty bool QtQuickControls2::ScrollBar::pressed - - TODO -*/ -bool QQuickAbstractScrollBar::isPressed() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->pressed; -} - -void QQuickAbstractScrollBar::setPressed(bool pressed) -{ - Q_D(QQuickAbstractScrollBar); - if (d->pressed != pressed) { - d->pressed = pressed; - setActive(d->pressed || d->moving); - emit pressedChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::ScrollBar::orientation - - TODO -*/ -Qt::Orientation QQuickAbstractScrollBar::orientation() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->orientation; -} - -void QQuickAbstractScrollBar::setOrientation(Qt::Orientation orientation) -{ - Q_D(QQuickAbstractScrollBar); - if (d->orientation != orientation) { - d->orientation = orientation; - emit orientationChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::ScrollBar::handle - - TODO -*/ -QQuickItem *QQuickAbstractScrollBar::handle() const -{ - Q_D(const QQuickAbstractScrollBar); - return d->handle; -} - -void QQuickAbstractScrollBar::setHandle(QQuickItem *handle) -{ - Q_D(QQuickAbstractScrollBar); - if (d->handle != handle) { - delete d->handle; - d->handle = handle; - if (handle && !handle->parentItem()) - handle->setParentItem(this); - emit handleChanged(); - } -} - -void QQuickAbstractScrollBar::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractScrollBar); - QQuickControl::mousePressEvent(event); - d->offset = positionAt(event->pos()) - d->position; - if (d->offset < 0 || d->offset > d->size) - d->offset = d->size / 2; - setPressed(true); - event->accept(); -} - -void QQuickAbstractScrollBar::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractScrollBar); - QQuickControl::mouseMoveEvent(event); - setPosition(qBound(0.0, positionAt(event->pos()) - d->offset, 1.0 - d->size)); - event->accept(); -} - -void QQuickAbstractScrollBar::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractScrollBar); - QQuickControl::mouseReleaseEvent(event); - setPosition(qBound(0.0, positionAt(event->pos()) - d->offset, 1.0 - d->size)); - d->offset = 0.0; - setPressed(false); - event->accept(); -} - -qreal QQuickAbstractScrollBar::positionAt(const QPoint &point) const -{ - Q_D(const QQuickAbstractScrollBar); - if (d->orientation == Qt::Horizontal) - return point.x() / width(); - else - return point.y() / height(); -} - -class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener -{ -public: - QQuickScrollBarAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { } - - void activateHorizontal(); - void activateVertical(); - void scrollHorizontal(); - void scrollVertical(); - - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - - QQuickFlickable *flickable; - QQuickAbstractScrollBar *horizontal; - QQuickAbstractScrollBar *vertical; -}; - -void QQuickScrollBarAttachedPrivate::activateHorizontal() -{ - QQuickAbstractScrollBarPrivate *p = QQuickAbstractScrollBarPrivate::get(horizontal); - p->moving = flickable->isMovingHorizontally(); - horizontal->setActive(p->moving || p->pressed); -} - -void QQuickScrollBarAttachedPrivate::activateVertical() -{ - QQuickAbstractScrollBarPrivate *p = QQuickAbstractScrollBarPrivate::get(vertical); - p->moving = flickable->isMovingVertically(); - vertical->setActive(p->moving || p->pressed); -} - -// TODO: QQuickFlickable::maxXYExtent() -class QQuickFriendlyFlickable : public QQuickFlickable -{ - friend class QQuickScrollBarAttachedPrivate; -}; - -void QQuickScrollBarAttachedPrivate::scrollHorizontal() -{ - QQuickFriendlyFlickable *f = reinterpret_cast(flickable); - - const qreal viewwidth = f->width(); - const qreal maxxextent = -f->maxXExtent() + f->minXExtent(); - qreal cx = horizontal->position() * (maxxextent + viewwidth) - f->minXExtent(); - if (!qIsNaN(cx) && !qFuzzyCompare(cx, flickable->contentX())) - flickable->setContentX(cx); -} - -void QQuickScrollBarAttachedPrivate::scrollVertical() -{ - QQuickFriendlyFlickable *f = reinterpret_cast(flickable); - - const qreal viewheight = f->height(); - const qreal maxyextent = -f->maxYExtent() + f->minYExtent(); - qreal cy = vertical->position() * (maxyextent + viewheight) - f->minYExtent(); - if (!qIsNaN(cy) && !qFuzzyCompare(cy, flickable->contentY())) - flickable->setContentY(cy); -} - -void QQuickScrollBarAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_ASSERT(item == flickable); - if (horizontal) { - QQuickItemPrivate *p = QQuickItemPrivate::get(horizontal); - if (!p->widthValid) { - horizontal->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height())) - horizontal->setY(newGeometry.height() - horizontal->height()); - } - if (vertical) { - QQuickItemPrivate *p = QQuickItemPrivate::get(vertical); - if (!p->heightValid) { - vertical->setHeight(newGeometry.height()); - p->heightValid = false; - } - if (!p->isMirrored() && (qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width()))) - vertical->setX(newGeometry.width() - vertical->width()); - } -} - -QQuickScrollBarAttached::QQuickScrollBarAttached(QQuickFlickable *flickable) : - QObject(*(new QQuickScrollBarAttachedPrivate(flickable)), flickable) -{ - Q_D(QQuickScrollBarAttached); - QQuickItemPrivate *p = QQuickItemPrivate::get(flickable); - p->addItemChangeListener(d, QQuickItemPrivate::Geometry); -} - -QQuickAbstractScrollBar *QQuickScrollBarAttached::horizontal() const -{ - Q_D(const QQuickScrollBarAttached); - return d->horizontal; -} - -void QQuickScrollBarAttached::setHorizontal(QQuickAbstractScrollBar *horizontal) -{ - Q_D(QQuickScrollBarAttached); - if (d->horizontal != horizontal) { - if (d->horizontal) { - QObjectPrivate::disconnect(d->horizontal, &QQuickAbstractScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal); - QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal))); - disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal))); - } - - d->horizontal = horizontal; - - if (horizontal) { - if (!horizontal->parentItem()) - horizontal->setParentItem(d->flickable); - horizontal->setOrientation(Qt::Horizontal); - - QObjectPrivate::connect(horizontal, &QQuickAbstractScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal); - QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal))); - connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal))); - - horizontal->setSize(area->property("widthRatio").toReal()); - horizontal->setPosition(area->property("xPosition").toReal()); - } - emit horizontalChanged(); - } -} - -QQuickAbstractScrollBar *QQuickScrollBarAttached::vertical() const -{ - Q_D(const QQuickScrollBarAttached); - return d->vertical; -} - -void QQuickScrollBarAttached::setVertical(QQuickAbstractScrollBar *vertical) -{ - Q_D(QQuickScrollBarAttached); - if (d->vertical != vertical) { - if (d->vertical) { - QObjectPrivate::disconnect(d->vertical, &QQuickAbstractScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical); - QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal))); - disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal))); - } - - d->vertical = vertical; - - if (vertical) { - if (!vertical->parentItem()) - vertical->setParentItem(d->flickable); - vertical->setOrientation(Qt::Vertical); - - QObjectPrivate::connect(vertical, &QQuickAbstractScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical); - QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal))); - connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal))); - - vertical->setSize(area->property("heightRatio").toReal()); - vertical->setPosition(area->property("yPosition").toReal()); - } - emit verticalChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractscrollbar_p.h b/src/controls/qquickabstractscrollbar_p.h deleted file mode 100644 index ba0ce101..00000000 --- a/src/controls/qquickabstractscrollbar_p.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSCROLLBAR_P_H -#define QQUICKABSTRACTSCROLLBAR_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 - -QT_BEGIN_NAMESPACE - -class QQuickFlickable; -class QQuickScrollBarAttached; -class QQuickAbstractScrollBarPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractScrollBar : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(qreal size READ size NOTIFY sizeChanged FINAL) - Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL) - Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) - Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) - -public: - explicit QQuickAbstractScrollBar(QQuickItem *parent = Q_NULLPTR); - - static QQuickScrollBarAttached *qmlAttachedProperties(QObject *object); - - qreal size() const; - qreal position() const; - - bool isActive() const; - void setActive(bool active); - - bool isPressed() const; - void setPressed(bool pressed); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - QQuickItem *handle() const; - void setHandle(QQuickItem *handle); - -public Q_SLOTS: - void setSize(qreal size); - void setPosition(qreal position); - -Q_SIGNALS: - void sizeChanged(); - void positionChanged(); - void activeChanged(); - void pressedChanged(); - void orientationChanged(); - void handleChanged(); - -protected: - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - - virtual qreal positionAt(const QPoint &point) const; - -private: - Q_DISABLE_COPY(QQuickAbstractScrollBar) - Q_DECLARE_PRIVATE(QQuickAbstractScrollBar) -}; - -class QQuickScrollBarAttachedPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickScrollBarAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQuickAbstractScrollBar *horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL) - Q_PROPERTY(QQuickAbstractScrollBar *vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL) - -public: - explicit QQuickScrollBarAttached(QQuickFlickable *flickable); - - QQuickAbstractScrollBar *horizontal() const; - void setHorizontal(QQuickAbstractScrollBar *horizontal); - - QQuickAbstractScrollBar *vertical() const; - void setVertical(QQuickAbstractScrollBar *vertical); - -Q_SIGNALS: - void horizontalChanged(); - void verticalChanged(); - -private: - Q_DISABLE_COPY(QQuickScrollBarAttached) - Q_DECLARE_PRIVATE(QQuickScrollBarAttached) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QQuickAbstractScrollBar, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QQUICKABSTRACTSCROLLBAR_P_H diff --git a/src/controls/qquickabstractscrollindicator.cpp b/src/controls/qquickabstractscrollindicator.cpp deleted file mode 100644 index 93d7917e..00000000 --- a/src/controls/qquickabstractscrollindicator.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractscrollindicator_p.h" -#include "qquickcontrol_p_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ScrollIndicator - \inherits Control - \instantiates QQuickAbstractScrollIndicator - \inqmlmodule QtQuick.Controls - \ingroup indicators - \brief A scroll indicator. - - TODO -*/ - -class QQuickAbstractScrollIndicatorPrivate : public QQuickControlPrivate -{ -public: - QQuickAbstractScrollIndicatorPrivate() : size(0), position(0), - active(false), orientation(Qt::Vertical), indicator(Q_NULLPTR) { } - - qreal size; - qreal position; - bool active; - Qt::Orientation orientation; - QQuickItem *indicator; -}; - -QQuickAbstractScrollIndicator::QQuickAbstractScrollIndicator(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractScrollIndicatorPrivate), parent) -{ -} - -QQuickScrollIndicatorAttached *QQuickAbstractScrollIndicator::qmlAttachedProperties(QObject *object) -{ - QQuickFlickable *flickable = qobject_cast(object); - if (flickable) - return new QQuickScrollIndicatorAttached(flickable); - - qWarning() << "ScrollIndicator must be attached to a Flickable" << object; - return Q_NULLPTR; -} - -/*! - \qmlproperty real QtQuickControls2::ScrollIndicator::size - - TODO -*/ -qreal QQuickAbstractScrollIndicator::size() const -{ - Q_D(const QQuickAbstractScrollIndicator); - return d->size; -} - -void QQuickAbstractScrollIndicator::setSize(qreal size) -{ - Q_D(QQuickAbstractScrollIndicator); - if (!qFuzzyCompare(d->size, size)) { - d->size = size; - emit sizeChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::ScrollIndicator::position - - TODO -*/ -qreal QQuickAbstractScrollIndicator::position() const -{ - Q_D(const QQuickAbstractScrollIndicator); - return d->position; -} - -void QQuickAbstractScrollIndicator::setPosition(qreal position) -{ - Q_D(QQuickAbstractScrollIndicator); - if (!qFuzzyCompare(d->position, position)) { - d->position = position; - emit positionChanged(); - } -} - -/*! - \qmlproperty bool QtQuickControls2::ScrollIndicator::active - - TODO -*/ -bool QQuickAbstractScrollIndicator::isActive() const -{ - Q_D(const QQuickAbstractScrollIndicator); - return d->active; -} - -void QQuickAbstractScrollIndicator::setActive(bool active) -{ - Q_D(QQuickAbstractScrollIndicator); - if (d->active != active) { - d->active = active; - emit activeChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::ScrollIndicator::orientation - - TODO -*/ -Qt::Orientation QQuickAbstractScrollIndicator::orientation() const -{ - Q_D(const QQuickAbstractScrollIndicator); - return d->orientation; -} - -void QQuickAbstractScrollIndicator::setOrientation(Qt::Orientation orientation) -{ - Q_D(QQuickAbstractScrollIndicator); - if (d->orientation != orientation) { - d->orientation = orientation; - emit orientationChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::ScrollIndicator::indicator - - TODO -*/ -QQuickItem *QQuickAbstractScrollIndicator::indicator() const -{ - Q_D(const QQuickAbstractScrollIndicator); - return d->indicator; -} - -void QQuickAbstractScrollIndicator::setIndicator(QQuickItem *indicator) -{ - Q_D(QQuickAbstractScrollIndicator); - if (d->indicator != indicator) { - delete d->indicator; - d->indicator = indicator; - if (indicator && !indicator->parentItem()) - indicator->setParentItem(this); - emit indicatorChanged(); - } -} - -class QQuickScrollIndicatorAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener -{ -public: - QQuickScrollIndicatorAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { } - - void activateHorizontal(); - void activateVertical(); - - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - - QQuickFlickable *flickable; - QQuickAbstractScrollIndicator *horizontal; - QQuickAbstractScrollIndicator *vertical; -}; - -void QQuickScrollIndicatorAttachedPrivate::activateHorizontal() -{ - horizontal->setActive(flickable->isMovingHorizontally()); -} - -void QQuickScrollIndicatorAttachedPrivate::activateVertical() -{ - vertical->setActive(flickable->isMovingVertically()); -} - -void QQuickScrollIndicatorAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_ASSERT(item == flickable); - if (horizontal) { - QQuickItemPrivate *p = QQuickItemPrivate::get(horizontal); - if (!p->widthValid) { - horizontal->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height())) - horizontal->setY(newGeometry.height() - horizontal->height()); - } - if (vertical) { - QQuickItemPrivate *p = QQuickItemPrivate::get(vertical); - if (!p->heightValid) { - vertical->setHeight(newGeometry.height()); - p->heightValid = false; - } - if (!p->isMirrored() && (qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width()))) - vertical->setX(newGeometry.width() - vertical->width()); - } -} - -QQuickScrollIndicatorAttached::QQuickScrollIndicatorAttached(QQuickFlickable *flickable) : - QObject(*(new QQuickScrollIndicatorAttachedPrivate(flickable)), flickable) -{ - Q_D(QQuickScrollIndicatorAttached); - QQuickItemPrivate *p = QQuickItemPrivate::get(flickable); - p->addItemChangeListener(d, QQuickItemPrivate::Geometry); -} - -QQuickAbstractScrollIndicator *QQuickScrollIndicatorAttached::horizontal() const -{ - Q_D(const QQuickScrollIndicatorAttached); - return d->horizontal; -} - -void QQuickScrollIndicatorAttached::setHorizontal(QQuickAbstractScrollIndicator *horizontal) -{ - Q_D(QQuickScrollIndicatorAttached); - if (d->horizontal != horizontal) { - if (d->horizontal) { - QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal))); - disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal))); - } - - d->horizontal = horizontal; - - if (horizontal) { - if (!horizontal->parentItem()) - horizontal->setParentItem(d->flickable); - horizontal->setOrientation(Qt::Horizontal); - - QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal))); - connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal))); - - horizontal->setSize(area->property("widthRatio").toReal()); - horizontal->setPosition(area->property("xPosition").toReal()); - } - emit horizontalChanged(); - } -} - -QQuickAbstractScrollIndicator *QQuickScrollIndicatorAttached::vertical() const -{ - Q_D(const QQuickScrollIndicatorAttached); - return d->vertical; -} - -void QQuickScrollIndicatorAttached::setVertical(QQuickAbstractScrollIndicator *vertical) -{ - Q_D(QQuickScrollIndicatorAttached); - if (d->vertical != vertical) { - if (d->vertical) { - QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal))); - disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal))); - } - - d->vertical = vertical; - - if (vertical) { - if (!vertical->parentItem()) - vertical->setParentItem(d->flickable); - vertical->setOrientation(Qt::Vertical); - - QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical); - - // TODO: export QQuickFlickableVisibleArea - QObject *area = d->flickable->property("visibleArea").value(); - connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal))); - connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal))); - - vertical->setSize(area->property("heightRatio").toReal()); - vertical->setPosition(area->property("yPosition").toReal()); - } - emit verticalChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractscrollindicator_p.h b/src/controls/qquickabstractscrollindicator_p.h deleted file mode 100644 index 2263a358..00000000 --- a/src/controls/qquickabstractscrollindicator_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSCROLLINDICATOR_P_H -#define QQUICKABSTRACTSCROLLINDICATOR_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 - -QT_BEGIN_NAMESPACE - -class QQuickFlickable; -class QQuickScrollIndicatorAttached; -class QQuickAbstractScrollIndicatorPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractScrollIndicator : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(qreal size READ size NOTIFY sizeChanged FINAL) - Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) - Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - -public: - explicit QQuickAbstractScrollIndicator(QQuickItem *parent = Q_NULLPTR); - - static QQuickScrollIndicatorAttached *qmlAttachedProperties(QObject *object); - - qreal size() const; - qreal position() const; - - bool isActive() const; - void setActive(bool active); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - QQuickItem *indicator() const; - void setIndicator(QQuickItem *indicator); - -public Q_SLOTS: - void setSize(qreal size); - void setPosition(qreal position); - -Q_SIGNALS: - void sizeChanged(); - void positionChanged(); - void activeChanged(); - void orientationChanged(); - void indicatorChanged(); - -private: - Q_DISABLE_COPY(QQuickAbstractScrollIndicator) - Q_DECLARE_PRIVATE(QQuickAbstractScrollIndicator) -}; - -class QQuickScrollIndicatorAttachedPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickScrollIndicatorAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQuickAbstractScrollIndicator *horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL) - Q_PROPERTY(QQuickAbstractScrollIndicator *vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL) - -public: - explicit QQuickScrollIndicatorAttached(QQuickFlickable *flickable); - - QQuickAbstractScrollIndicator *horizontal() const; - void setHorizontal(QQuickAbstractScrollIndicator *horizontal); - - QQuickAbstractScrollIndicator *vertical() const; - void setVertical(QQuickAbstractScrollIndicator *vertical); - -Q_SIGNALS: - void horizontalChanged(); - void verticalChanged(); - -private: - Q_DISABLE_COPY(QQuickScrollIndicatorAttached) - Q_DECLARE_PRIVATE(QQuickScrollIndicatorAttached) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QQuickAbstractScrollIndicator, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QQUICKABSTRACTSCROLLINDICATOR_P_H diff --git a/src/controls/qquickabstractslider.cpp b/src/controls/qquickabstractslider.cpp deleted file mode 100644 index 52fa11af..00000000 --- a/src/controls/qquickabstractslider.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractslider_p.h" -#include "qquickcontrol_p_p.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Slider - \inherits Control - \instantiates QQuickAbstractSlider - \inqmlmodule QtQuick.Controls - \ingroup sliders - \brief A slider control. - - TODO -*/ - -class QQuickAbstractSliderPrivate : public QQuickControlPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractSlider) - -public: - QQuickAbstractSliderPrivate() : value(0), position(0), stepSize(0), - pressed(false), orientation(Qt::Horizontal), layoutDirection(Qt::LeftToRight), - snapMode(QQuickAbstractSlider::NoSnap), handle(Q_NULLPTR), track(Q_NULLPTR) { } - - qreal snapPosition(qreal position) const; - qreal positionAt(const QPoint &point) const; - - qreal value; - qreal position; - qreal stepSize; - bool pressed; - QPoint pressPoint; - Qt::Orientation orientation; - Qt::LayoutDirection layoutDirection; - QQuickAbstractSlider::SnapMode snapMode; - QQuickItem *handle; - QQuickItem *track; -}; - -qreal QQuickAbstractSliderPrivate::snapPosition(qreal position) const -{ - if (qFuzzyIsNull(stepSize)) - return position; - return qRound(position / stepSize) * stepSize; -} - -qreal QQuickAbstractSliderPrivate::positionAt(const QPoint &point) const -{ - Q_Q(const QQuickAbstractSlider); - if (orientation == Qt::Horizontal) { - const qreal hw = handle ? handle->width() : 0; - const qreal offset = hw / 2; - const qreal extent = q->width() - hw; - if (!qFuzzyIsNull(extent)) { - const qreal pos = (point.x() - offset) / extent; - if (q->effectiveLayoutDirection() == Qt::RightToLeft) - return 1.0 - pos; - return pos; - } - } else { - const qreal hh = handle ? handle->height() : 0; - const qreal offset = hh / 2; - const qreal extent = q->height() - hh; - if (!qFuzzyIsNull(extent)) - return (point.y() - offset) / extent; - } - return 0; -} - -QQuickAbstractSlider::QQuickAbstractSlider(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractSliderPrivate), parent) -{ - setActiveFocusOnTab(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -/*! - \qmlproperty real QtQuickControls2::Slider::value - - TODO -*/ -qreal QQuickAbstractSlider::value() const -{ - Q_D(const QQuickAbstractSlider); - return d->value; -} - -void QQuickAbstractSlider::setValue(qreal value) -{ - Q_D(QQuickAbstractSlider); - value = qBound(0.0, value, 1.0); - if (!qFuzzyCompare(d->value, value)) { - d->value = value; - setPosition(value); - emit valueChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::Slider::position - - TODO -*/ -qreal QQuickAbstractSlider::position() const -{ - Q_D(const QQuickAbstractSlider); - return d->position; -} - -/*! - \qmlproperty real QtQuickControls2::Slider::visualPosition - - TODO -*/ -qreal QQuickAbstractSlider::visualPosition() const -{ - Q_D(const QQuickAbstractSlider); - if (d->orientation == Qt::Vertical || effectiveLayoutDirection() == Qt::RightToLeft) - return 1.0 - d->position; - return d->position; -} - -void QQuickAbstractSlider::setPosition(qreal position) -{ - Q_D(QQuickAbstractSlider); - position = qBound(0.0, position, 1.0); - if (!qFuzzyCompare(d->position, position)) { - d->position = position; - emit positionChanged(); - emit visualPositionChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::Slider::stepSize - - TODO -*/ -qreal QQuickAbstractSlider::stepSize() const -{ - Q_D(const QQuickAbstractSlider); - return d->stepSize; -} - -void QQuickAbstractSlider::setStepSize(qreal step) -{ - Q_D(QQuickAbstractSlider); - if (!qFuzzyCompare(d->stepSize, step)) { - d->stepSize = step; - emit stepSizeChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::Slider::snapMode - - TODO -*/ -QQuickAbstractSlider::SnapMode QQuickAbstractSlider::snapMode() const -{ - Q_D(const QQuickAbstractSlider); - return d->snapMode; -} - -void QQuickAbstractSlider::setSnapMode(SnapMode mode) -{ - Q_D(QQuickAbstractSlider); - if (d->snapMode != mode) { - d->snapMode = mode; - emit snapModeChanged(); - } -} - -/*! - \qmlproperty bool QtQuickControls2::Slider::pressed - - TODO -*/ -bool QQuickAbstractSlider::isPressed() const -{ - Q_D(const QQuickAbstractSlider); - return d->pressed; -} - -void QQuickAbstractSlider::setPressed(bool pressed) -{ - Q_D(QQuickAbstractSlider); - if (d->pressed != pressed) { - d->pressed = pressed; - emit pressedChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::Slider::orientation - - TODO -*/ -Qt::Orientation QQuickAbstractSlider::orientation() const -{ - Q_D(const QQuickAbstractSlider); - return d->orientation; -} - -void QQuickAbstractSlider::setOrientation(Qt::Orientation orientation) -{ - Q_D(QQuickAbstractSlider); - if (d->orientation != orientation) { - d->orientation = orientation; - emit orientationChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuickControls2::Slider::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractSlider::layoutDirection() const -{ - Q_D(const QQuickAbstractSlider); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::Slider::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickAbstractSlider::effectiveLayoutDirection() const -{ - Q_D(const QQuickAbstractSlider); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickAbstractSlider::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickAbstractSlider); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::Slider::handle - - TODO -*/ -QQuickItem *QQuickAbstractSlider::handle() const -{ - Q_D(const QQuickAbstractSlider); - return d->handle; -} - -void QQuickAbstractSlider::setHandle(QQuickItem *handle) -{ - Q_D(QQuickAbstractSlider); - if (d->handle != handle) { - delete d->handle; - d->handle = handle; - if (handle && !handle->parentItem()) - handle->setParentItem(this); - emit handleChanged(); - } -} - -/*! - \qmlproperty Item QtQuickControls2::Slider::track - - TODO -*/ -QQuickItem *QQuickAbstractSlider::track() const -{ - Q_D(const QQuickAbstractSlider); - return d->track; -} - -void QQuickAbstractSlider::setTrack(QQuickItem *track) -{ - Q_D(QQuickAbstractSlider); - if (d->track != track) { - delete d->track; - d->track = track; - if (track && !track->parentItem()) - track->setParentItem(this); - emit trackChanged(); - } -} - -/*! - \qmlmethod void QtQuickControls2::Slider::increase() - - TODO -*/ -void QQuickAbstractSlider::increase() -{ - Q_D(QQuickAbstractSlider); - qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; - setValue(d->value + step); -} - -/*! - \qmlmethod void QtQuickControls2::Slider::decrease() - - TODO -*/ -void QQuickAbstractSlider::decrease() -{ - Q_D(QQuickAbstractSlider); - qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; - setValue(d->value - step); -} - -void QQuickAbstractSlider::keyPressEvent(QKeyEvent *event) -{ - Q_D(QQuickAbstractSlider); - QQuickControl::keyPressEvent(event); - if (d->orientation == Qt::Horizontal) { - if (event->key() == Qt::Key_Left) { - setPressed(true); - if (effectiveLayoutDirection() == Qt::RightToLeft) - increase(); - else - decrease(); - event->accept(); - } else if (event->key() == Qt::Key_Right) { - setPressed(true); - if (effectiveLayoutDirection() == Qt::RightToLeft) - decrease(); - else - increase(); - event->accept(); - } - } else { - if (event->key() == Qt::Key_Up) { - setPressed(true); - increase(); - event->accept(); - } else if (event->key() == Qt::Key_Down) { - setPressed(true); - decrease(); - event->accept(); - } - } -} - -void QQuickAbstractSlider::keyReleaseEvent(QKeyEvent *event) -{ - QQuickControl::keyReleaseEvent(event); - setPressed(false); -} - -void QQuickAbstractSlider::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractSlider); - QQuickControl::mousePressEvent(event); - d->pressPoint = event->pos(); - setPressed(true); - event->accept(); -} - -void QQuickAbstractSlider::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractSlider); - QQuickControl::mouseMoveEvent(event); - if (!keepMouseGrab()) { - if (d->orientation == Qt::Horizontal) - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().x() - d->pressPoint.x(), Qt::XAxis, event)); - else - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().y() - d->pressPoint.y(), Qt::YAxis, event)); - } - if (keepMouseGrab()) { - qreal pos = d->positionAt(event->pos()); - if (d->snapMode == SnapAlways) - pos = d->snapPosition(pos); - setPosition(pos); - } - event->accept(); -} - -void QQuickAbstractSlider::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractSlider); - QQuickControl::mouseReleaseEvent(event); - d->pressPoint = QPoint(); - if (keepMouseGrab()) { - qreal pos = d->positionAt(event->pos()); - if (d->snapMode != NoSnap) - pos = d->snapPosition(pos); - setValue(pos); - setKeepMouseGrab(false); - } - setPressed(false); - event->accept(); -} - -void QQuickAbstractSlider::mouseUngrabEvent() -{ - Q_D(QQuickAbstractSlider); - QQuickControl::mouseUngrabEvent(); - d->pressPoint = QPoint(); - setPressed(false); -} - -void QQuickAbstractSlider::mirrorChange() -{ - emit effectiveLayoutDirectionChanged(); - emit visualPositionChanged(); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractslider_p.h b/src/controls/qquickabstractslider_p.h deleted file mode 100644 index 5481c184..00000000 --- a/src/controls/qquickabstractslider_p.h +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSLIDER_P_H -#define QQUICKABSTRACTSLIDER_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractSliderPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractSlider : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) - Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) - Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) - Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) - Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) - Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) - Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) - Q_PROPERTY(QQuickItem *track READ track WRITE setTrack NOTIFY trackChanged FINAL) - -public: - explicit QQuickAbstractSlider(QQuickItem *parent = Q_NULLPTR); - - qreal value() const; - void setValue(qreal value); - - qreal position() const; - qreal visualPosition() const; - void setPosition(qreal position); - - qreal stepSize() const; - void setStepSize(qreal step); - - enum SnapMode { - NoSnap, - SnapAlways, - SnapOnRelease - }; - Q_ENUM(SnapMode) - - SnapMode snapMode() const; - void setSnapMode(SnapMode mode); - - bool isPressed() const; - void setPressed(bool pressed); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - - QQuickItem *handle() const; - void setHandle(QQuickItem *handle); - - QQuickItem *track() const; - void setTrack(QQuickItem *track); - -public Q_SLOTS: - void increase(); - void decrease(); - -Q_SIGNALS: - void valueChanged(); - void positionChanged(); - void visualPositionChanged(); - void stepSizeChanged(); - void snapModeChanged(); - void pressedChanged(); - void orientationChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); - void handleChanged(); - void trackChanged(); - -protected: - void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void mirrorChange() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractSlider) - Q_DECLARE_PRIVATE(QQuickAbstractSlider) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTSLIDER_P_H diff --git a/src/controls/qquickabstractstackview.cpp b/src/controls/qquickabstractstackview.cpp deleted file mode 100644 index e5496697..00000000 --- a/src/controls/qquickabstractstackview.cpp +++ /dev/null @@ -1,553 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractstackview_p.h" -#include "qquickabstractstackview_p_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype StackView - \inherits Container - \instantiates QQuickAbstractStackView - \inqmlmodule QtQuick.Controls - \ingroup navigation - \brief A stack view control. - - TODO -*/ - -QQuickAbstractStackView::QQuickAbstractStackView(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractStackViewPrivate), parent) -{ - setFlag(ItemIsFocusScope); -} - -QQuickAbstractStackView::~QQuickAbstractStackView() -{ - Q_D(QQuickAbstractStackView); - if (d->transitioner) { - d->transitioner->setChangeListener(Q_NULLPTR); - delete d->transitioner; - } - qDeleteAll(d->elements); -} - -QQuickStackAttached *QQuickAbstractStackView::qmlAttachedProperties(QObject *object) -{ - QQuickItem *item = qobject_cast(object); - if (!item) { - qmlInfo(object) << "StackView must be attached to an Item"; - return Q_NULLPTR; - } - return new QQuickStackAttached(item); -} - -/*! - \qmlproperty bool QtQuickControls2::StackView::busy - \readonly - This property holds whether a transition is running. -*/ -bool QQuickAbstractStackView::busy() const -{ - Q_D(const QQuickAbstractStackView); - return d->transitioner && !d->transitioner->runningJobs.isEmpty(); -} - -/*! - \qmlproperty int QtQuickControls2::StackView::depth - \readonly - This property holds the number of items currently pushed onto the stack. -*/ -int QQuickAbstractStackView::depth() const -{ - Q_D(const QQuickAbstractStackView); - return d->elements.count(); -} - -/*! - \qmlproperty Item QtQuickControls2::StackView::currentItem - \readonly - This property holds the current top-most item in the stack. -*/ -QQuickItem *QQuickAbstractStackView::currentItem() const -{ - Q_D(const QQuickAbstractStackView); - return d->currentItem; -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::get(index, behavior = DontLoad) - - Supported behavior values: - \li StackView.DontLoad - \li StackView.ForceLoad - - TODO -*/ -QQuickItem *QQuickAbstractStackView::get(int index, LoadBehavior behavior) -{ - Q_D(QQuickAbstractStackView); - QQuickStackElement *element = d->elements.value(index); - if (element) { - if (behavior == ForceLoad) - element->load(this); - return element->item; - } - return Q_NULLPTR; -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::find(callback, behavior = DontLoad) - - Supported behavior values: - \li StackView.DontLoad - \li StackView.ForceLoad - - TODO -*/ -QQuickItem *QQuickAbstractStackView::find(const QJSValue &callback, LoadBehavior behavior) -{ - Q_D(QQuickAbstractStackView); - QJSValue func(callback); - QQmlEngine *engine = qmlEngine(this); - if (!engine || !func.isCallable()) // TODO: warning? - return Q_NULLPTR; - - for (int i = d->elements.count() - 1; i >= 0; --i) { - QQuickStackElement *element = d->elements.at(i); - if (behavior == ForceLoad) - element->load(this); - if (element->item) { - QJSValue rv = func.call(QJSValueList() << engine->newQObject(element->item) << i); - if (rv.toBool()) - return element->item; - } - } - - return Q_NULLPTR; -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::push(item, properties, operation) - - TODO -*/ -void QQuickAbstractStackView::push(QQmlV4Function *args) -{ - Q_D(QQuickAbstractStackView); - if (args->length() <= 0) { - qmlInfo(this) << "push: missing arguments"; - args->setReturnValue(QV4::Encode::null()); - return; - } - - QV4::ExecutionEngine *v4 = args->v4engine(); - QV4::Scope scope(v4); - - Operation operation = d->elements.isEmpty() ? Immediate : Transition; - QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]); - if (lastArg->isInt32()) - operation = static_cast(lastArg->toInt32()); - - QList elements = d->parseElements(args); - if (elements.isEmpty()) { - qmlInfo(this) << "push: nothing to push"; - args->setReturnValue(QV4::Encode::null()); - return; - } - - QQuickStackElement *exit = Q_NULLPTR; - if (!d->elements.isEmpty()) - exit = d->elements.top(); - - if (d->pushElements(elements)) { - emit depthChanged(); - QQuickStackElement *enter = d->elements.top(); - d->pushTransition(enter, exit, boundingRect(), operation == Immediate); - d->setCurrentItem(enter->item); - } - - if (d->currentItem) { - QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, d->currentItem)); - args->setReturnValue(rv->asReturnedValue()); - } else { - args->setReturnValue(QV4::Encode::null()); - } -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::pop(item = null, operation = Transition) - - TODO -*/ -void QQuickAbstractStackView::pop(QQmlV4Function *args) -{ - Q_D(QQuickAbstractStackView); - int argc = args->length(); - if (d->elements.count() <= 1 || argc > 2) { - if (argc > 2) - qmlInfo(this) << "pop: too many arguments"; - args->setReturnValue(QV4::Encode::null()); - return; - } - - QQuickStackElement *exit = d->elements.pop(); - QQuickStackElement *enter = d->elements.top(); - - QV4::ExecutionEngine *v4 = args->v4engine(); - QV4::Scope scope(v4); - - if (argc > 0) { - QV4::ScopedValue value(scope, (*args)[0]); - if (value->isNull()) { - enter = d->elements.value(0); - } else if (!value->isUndefined() && !value->isInt32()) { - enter = d->findElement(value); - if (!enter) { - qmlInfo(this) << "pop: unknown argument: " << value->toQString(); // TODO: safe? - args->setReturnValue(QV4::Encode::null()); - d->elements.push(exit); // restore - return; - } - } - } - - Operation operation = Transition; - if (argc > 0) { - QV4::ScopedValue lastArg(scope, (*args)[argc - 1]); - if (lastArg->isInt32()) - operation = static_cast(lastArg->toInt32()); - } - - QQuickItem *previousItem = Q_NULLPTR; - - if (d->popElements(enter)) { - if (exit) - previousItem = exit->item; - emit depthChanged(); - d->popTransition(enter, exit, boundingRect(), operation == Immediate); - d->setCurrentItem(enter->item); - } - - if (previousItem) { - QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, previousItem)); - args->setReturnValue(rv->asReturnedValue()); - } else { - args->setReturnValue(QV4::Encode::null()); - } -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::push(item, properties, operation = Transition) - - TODO -*/ -void QQuickAbstractStackView::replace(QQmlV4Function *args) -{ - Q_D(QQuickAbstractStackView); - if (args->length() <= 0) { - qmlInfo(this) << "replace: missing arguments"; - args->setReturnValue(QV4::Encode::null()); - return; - } - - QV4::ExecutionEngine *v4 = args->v4engine(); - QV4::Scope scope(v4); - - Operation operation = d->elements.isEmpty() ? Immediate : Transition; - QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]); - if (lastArg->isInt32()) - operation = static_cast(lastArg->toInt32()); - - QQuickStackElement *target = Q_NULLPTR; - QV4::ScopedValue firstArg(scope, (*args)[0]); - if (firstArg->isNull()) - target = d->elements.value(0); - else if (!firstArg->isInt32()) - target = d->findElement(firstArg); - - QList elements = d->parseElements(args, target ? 1 : 0); - if (elements.isEmpty()) { - qmlInfo(this) << "replace: nothing to push"; - args->setReturnValue(QV4::Encode::null()); - return; - } - - int depth = d->elements.count(); - QQuickStackElement* exit = Q_NULLPTR; - if (!d->elements.isEmpty()) - exit = d->elements.pop(); - - if (d->replaceElements(target, elements)) { - if (depth != d->elements.count()) - emit depthChanged(); - QQuickStackElement *enter = d->elements.top(); - d->replaceTransition(enter, exit, boundingRect(), operation == Immediate); - d->setCurrentItem(enter->item); - } - - if (d->currentItem) { - QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, d->currentItem)); - args->setReturnValue(rv->asReturnedValue()); - } else { - args->setReturnValue(QV4::Encode::null()); - } -} - -/*! - \qmlmethod Item QtQuickControls2::StackView::clear() - - TODO -*/ -void QQuickAbstractStackView::clear() -{ - Q_D(QQuickAbstractStackView); - d->setCurrentItem(Q_NULLPTR); - qDeleteAll(d->elements); - d->elements.clear(); - emit depthChanged(); -} - -/*! - \qmlproperty var QtQuickControls2::StackView::initialItem - - This property holds the initial item. - - \sa push() -*/ -QVariant QQuickAbstractStackView::initialItem() const -{ - Q_D(const QQuickAbstractStackView); - return d->initialItem; -} - -void QQuickAbstractStackView::setInitialItem(const QVariant &item) -{ - Q_D(QQuickAbstractStackView); - d->initialItem = item; -} - -/*! - \qmlproperty Transition QtQuickControls2::StackView::popEnter - - TODO -*/ -QQuickTransition *QQuickAbstractStackView::popEnter() const -{ - Q_D(const QQuickAbstractStackView); - if (d->transitioner) - return d->transitioner->removeDisplacedTransition; - return Q_NULLPTR; -} - -void QQuickAbstractStackView::setPopEnter(QQuickTransition *enter) -{ - Q_D(QQuickAbstractStackView); - d->ensureTransitioner(); - if (d->transitioner->removeDisplacedTransition != enter) { - d->transitioner->removeDisplacedTransition = enter; - emit popEnterChanged(); - } -} - -/*! - \qmlproperty Transition QtQuickControls2::StackView::popExit - - TODO -*/ -QQuickTransition *QQuickAbstractStackView::popExit() const -{ - Q_D(const QQuickAbstractStackView); - if (d->transitioner) - return d->transitioner->removeTransition; - return Q_NULLPTR; -} - -void QQuickAbstractStackView::setPopExit(QQuickTransition *exit) -{ - Q_D(QQuickAbstractStackView); - d->ensureTransitioner(); - if (d->transitioner->removeTransition != exit) { - d->transitioner->removeTransition = exit; - emit popExitChanged(); - } -} - -/*! - \qmlproperty Transition QtQuickControls2::StackView::pushEnter - - TODO -*/ -QQuickTransition *QQuickAbstractStackView::pushEnter() const -{ - Q_D(const QQuickAbstractStackView); - if (d->transitioner) - return d->transitioner->addTransition; - return Q_NULLPTR; -} - -void QQuickAbstractStackView::setPushEnter(QQuickTransition *enter) -{ - Q_D(QQuickAbstractStackView); - d->ensureTransitioner(); - if (d->transitioner->addTransition != enter) { - d->transitioner->addTransition = enter; - emit pushEnterChanged(); - } -} - -/*! - \qmlproperty Transition QtQuickControls2::StackView::pushExit - - TODO -*/ -QQuickTransition *QQuickAbstractStackView::pushExit() const -{ - Q_D(const QQuickAbstractStackView); - if (d->transitioner) - return d->transitioner->addDisplacedTransition; - return Q_NULLPTR; -} - -void QQuickAbstractStackView::setPushExit(QQuickTransition *exit) -{ - Q_D(QQuickAbstractStackView); - d->ensureTransitioner(); - if (d->transitioner->addDisplacedTransition != exit) { - d->transitioner->addDisplacedTransition = exit; - emit pushExitChanged(); - } -} - -void QQuickAbstractStackView::componentComplete() -{ - QQuickAbstractContainer::componentComplete(); - - Q_D(QQuickAbstractStackView); - QQuickStackElement *element = Q_NULLPTR; - if (QObject *o = d->initialItem.value()) - element = QQuickStackElement::fromObject(o, this); - else if (d->initialItem.canConvert()) - element = QQuickStackElement::fromString(d->initialItem.toString(), this); - if (d->pushElement(element)) { - emit depthChanged(); - d->setCurrentItem(element->item); - } -} - -void QQuickAbstractStackView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - QQuickAbstractContainer::geometryChanged(newGeometry, oldGeometry); - - Q_D(QQuickAbstractStackView); - foreach (QQuickStackElement *element, d->elements) { - if (element->item) { - QQuickItemPrivate *p = QQuickItemPrivate::get(element->item); - if (!p->widthValid) { - element->item->setWidth(newGeometry.width()); - p->widthValid = false; - } - if (!p->heightValid) { - element->item->setHeight(newGeometry.height()); - p->heightValid = false; - } - } - } -} - -void QQuickStackAttachedPrivate::init() -{ - QQuickItem *item = qobject_cast(parent); - if (item) { - QQuickAbstractStackView *view = qobject_cast(item->parentItem()); - if (view) { - element = QQuickAbstractStackViewPrivate::get(view)->findElement(item); - if (element) - initialized = true; - } - } -} - -void QQuickStackAttachedPrivate::reset() -{ - Q_Q(QQuickStackAttached); - int oldIndex = element ? element->index : -1; - QQuickAbstractStackView::Status oldStatus = element ? element->status : QQuickAbstractStackView::Inactive; - - element = Q_NULLPTR; - - if (oldIndex != -1) - emit q->indexChanged(); - if (oldStatus != QQuickAbstractStackView::Inactive) - emit q->statusChanged(); -} - -QQuickStackAttached::QQuickStackAttached(QQuickItem *parent) : - QObject(*(new QQuickStackAttachedPrivate), parent) -{ -} - -/*! - \qmlattachedproperty int QtQuickControls2::StackView::index - - TODO -*/ -int QQuickStackAttached::index() const -{ - Q_D(const QQuickStackAttached); - if (!d->initialized) - const_cast(d)->init(); - return d->element ? d->element->index : -1; -} - -/*! - \qmlattachedproperty enumeration QtQuickControls2::StackView::status - - TODO -*/ -QQuickAbstractStackView::Status QQuickStackAttached::status() const -{ - Q_D(const QQuickStackAttached); - if (!d->initialized) - const_cast(d)->init(); - return d->element ? d->element->status : QQuickAbstractStackView::Inactive; -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractstackview_p.cpp b/src/controls/qquickabstractstackview_p.cpp deleted file mode 100644 index 76061461..00000000 --- a/src/controls/qquickabstractstackview_p.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractstackview_p_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static QQuickStackAttached *attachedStackObject(QQuickItem *item) -{ - return qobject_cast(qmlAttachedPropertiesObject(item, false)); -} - -class QQuickStackIncubator : public QQmlIncubator -{ -public: - QQuickStackIncubator(QQuickStackElement *element) : QQmlIncubator(Synchronous), element(element) { } - -protected: - void setInitialState(QObject *object) Q_DECL_OVERRIDE { element->initItem(object); } - -private: - QQuickStackElement *element; -}; - -QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(Q_NULLPTR), - index(-1), removal(false), ownItem(false), ownComponent(false), - context(Q_NULLPTR), component(Q_NULLPTR), incubator(Q_NULLPTR), view(Q_NULLPTR), - status(QQuickAbstractStackView::Inactive) -{ -} - -QQuickStackElement::~QQuickStackElement() -{ - if (item) { - QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed); - - QQuickStackAttached *attached = attachedStackObject(item); - if (attached) - QQuickStackAttachedPrivate::get(attached)->reset(); - } - - if (ownComponent) - delete component; - - if (ownItem && item) { - item->setParentItem(Q_NULLPTR); - item->deleteLater(); - item = Q_NULLPTR; - } else if (item) { - item->setVisible(false); - item->setParentItem(originalParent); - } - - delete context; - delete incubator; -} - -QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickAbstractStackView *view) -{ - QQuickStackElement *element = new QQuickStackElement; - element->component = new QQmlComponent(qmlEngine(view), QUrl(str), view); - element->ownComponent = true; - return element; -} - -QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickAbstractStackView *view) -{ - QQuickStackElement *element = new QQuickStackElement; - element->component = qobject_cast(object); - if (!element->component) { - element->component = new QQmlComponent(qmlEngine(view), view); - element->ownComponent = true; - } - element->item = qobject_cast(object); - if (element->item) { - element->originalParent = element->item->parentItem(); - element->item->setParentItem(view); - QQuickItemPrivate::get(element->item)->addItemChangeListener(element, QQuickItemPrivate::Destroyed); - } - return element; -} - -bool QQuickStackElement::load(QQuickAbstractStackView *parent) -{ - view = parent; - if (!item) { - ownItem = true; - - QQmlContext *creationContext = component->creationContext(); - if (!creationContext) - creationContext = qmlContext(parent); - context = new QQmlContext(creationContext); - context->setContextObject(parent); - - delete incubator; - incubator = new QQuickStackIncubator(this); - component->create(*incubator, context); - } - initProperties(); - return item; -} - -void QQuickStackElement::initItem(QObject *object) -{ - item = qmlobject_cast(object); - if (item) { - QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership); - QQuickItemPrivate *p = QQuickItemPrivate::get(item); - if (!p->widthValid) { - item->setWidth(view->width()); - p->widthValid = false; - } - if (!p->heightValid) { - item->setHeight(view->height()); - p->heightValid = false; - } - item->setParentItem(view); - p->addItemChangeListener(this, QQuickItemPrivate::Destroyed); - } - initProperties(); -} - -void QQuickStackElement::initProperties() -{ - if (!properties.isUndefined()) { - QQmlComponentPrivate *d = QQmlComponentPrivate::get(component); - Q_ASSERT(d && d->engine); - QV4::ExecutionEngine *v4 = qmlGlobal.engine(); - Q_ASSERT(v4); - QV4::Scope scope(v4); - QV4::ScopedValue ipv(scope, properties.value()); - d->initializeObjectWithInitialProperties(*qmlGlobal.valueRef(), ipv, item); - properties.clear(); - } -} - -void QQuickStackElement::setIndex(int value) -{ - if (index != value) { - index = value; - QQuickStackAttached *attached = attachedStackObject(item); - if (attached) - emit attached->indexChanged(); - } -} - -void QQuickStackElement::setStatus(QQuickAbstractStackView::Status value) -{ - if (status != value) { - status = value; - QQuickStackAttached *attached = attachedStackObject(item); - if (attached) - emit attached->statusChanged(); - } -} - -void QQuickStackElement::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget) -{ - if (transitioner) - transitioner->transitionNextReposition(this, type, asTarget); -} - -bool QQuickStackElement::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds) -{ - if (transitioner) { - // TODO: add force argument to QQuickItemViewTransitionableItem::prepareTransition()? - nextTransitionToSet = true; - nextTransitionFromSet = true; - nextTransitionFrom += QPointF(1, 1); - return QQuickItemViewTransitionableItem::prepareTransition(transitioner, index, viewBounds); - } - return false; -} - -void QQuickStackElement::startTransition(QQuickItemViewTransitioner *transitioner) -{ - if (transitioner) - QQuickItemViewTransitionableItem::startTransition(transitioner, index); -} - -void QQuickStackElement::itemDestroyed(QQuickItem *) -{ - item = Q_NULLPTR; -} - -QQuickAbstractStackViewPrivate::QQuickAbstractStackViewPrivate() : currentItem(Q_NULLPTR), transitioner(Q_NULLPTR) -{ -} - -void QQuickAbstractStackViewPrivate::setCurrentItem(QQuickItem *item) -{ - Q_Q(QQuickAbstractStackView); - if (currentItem != item) { - currentItem = item; - if (item) - item->setVisible(true); - emit q->currentItemChanged(); - } -} - -static bool initProperties(QQuickStackElement *element, const QV4::Value &props, QQmlV4Function *args) -{ - if (props.isObject()) { - const QV4::QObjectWrapper *wrapper = props.as(); - if (!wrapper) { - QV4::ExecutionEngine *v4 = args->v4engine(); - element->properties.set(v4, props); - element->qmlGlobal.set(v4, args->qmlGlobal()); - return true; - } - } - return false; -} - -QList QQuickAbstractStackViewPrivate::parseElements(QQmlV4Function *args, int from) -{ - QV4::ExecutionEngine *v4 = args->v4engine(); - QV4::Scope scope(v4); - - QList elements; - - int argc = args->length(); - for (int i = from; i < argc; ++i) { - QV4::ScopedValue arg(scope, (*args)[i]); - if (QV4::ArrayObject *array = arg->asArrayObject()) { - int len = array->getLength(); - for (int j = 0; j < len; ++j) { - QV4::ScopedValue value(scope, array->getIndexed(j)); - QQuickStackElement *element = createElement(value); - if (element) { - if (j < len - 1) { - QV4::ScopedValue props(scope, array->getIndexed(j + 1)); - if (initProperties(element, props, args)) - ++j; - } - elements += element; - } - } - } else { - QQuickStackElement *element = createElement(arg); - if (element) { - if (i < argc - 1) { - QV4::ScopedValue props(scope, (*args)[i + 1]); - if (initProperties(element, props, args)) - ++i; - } - elements += element; - } - } - } - return elements; -} - -QQuickStackElement *QQuickAbstractStackViewPrivate::findElement(QQuickItem *item) const -{ - if (item) { - foreach (QQuickStackElement *e, elements) { - if (e->item == item) - return e; - } - } - return Q_NULLPTR; -} - -QQuickStackElement *QQuickAbstractStackViewPrivate::findElement(const QV4::Value &value) const -{ - if (const QV4::QObjectWrapper *o = value.as()) - return findElement(qobject_cast(o->object())); - return Q_NULLPTR; -} - -QQuickStackElement *QQuickAbstractStackViewPrivate::createElement(const QV4::Value &value) -{ - Q_Q(QQuickAbstractStackView); - if (QV4::String *s = value.asString()) - return QQuickStackElement::fromString(s->toQString(), q); - if (const QV4::QObjectWrapper *o = value.as()) - return QQuickStackElement::fromObject(o->object(), q); - return Q_NULLPTR; -} - -bool QQuickAbstractStackViewPrivate::pushElements(const QList &elems) -{ - Q_Q(QQuickAbstractStackView); - if (!elems.isEmpty()) { - foreach (QQuickStackElement *e, elems) { - e->setIndex(elements.count()); - elements += e; - } - return elements.top()->load(q); - } - return false; -} - -bool QQuickAbstractStackViewPrivate::pushElement(QQuickStackElement *element) -{ - if (element) - return pushElements(QList() << element); - return false; -} - -bool QQuickAbstractStackViewPrivate::popElements(QQuickStackElement *element) -{ - Q_Q(QQuickAbstractStackView); - if (elements.count() > 1) { - while (elements.count() > 1 && elements.top() != element) { - delete elements.pop(); - if (!element) - break; - } - } - return elements.top()->load(q); -} - -bool QQuickAbstractStackViewPrivate::replaceElements(QQuickStackElement *target, const QList &elems) -{ - if (target) { - while (!elements.isEmpty()) { - QQuickStackElement* top = elements.pop(); - delete top; - if (top == target) - break; - } - } - return pushElements(elems); -} - -void QQuickAbstractStackViewPrivate::ensureTransitioner() -{ - if (!transitioner) { - transitioner = new QQuickItemViewTransitioner; - transitioner->setChangeListener(this); - } -} - -void QQuickAbstractStackViewPrivate::popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) -{ - Q_Q(QQuickAbstractStackView); - if (exit) { - exit->setStatus(QQuickAbstractStackView::Deactivating); - exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true); - } - if (enter) { - enter->setStatus(QQuickAbstractStackView::Activating); - enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false); - } - - if (exit && exit->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(exit, transitioner->removeTransition); - else - exit->startTransition(transitioner); - } - if (enter && enter->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(enter, transitioner->removeDisplacedTransition); - else - enter->startTransition(transitioner); - } - - if (!immediate) - emit q->busyChanged(); - - if (transitioner) - transitioner->resetTargetLists(); -} - -void QQuickAbstractStackViewPrivate::pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) -{ - Q_Q(QQuickAbstractStackView); - if (enter) { - enter->setStatus(QQuickAbstractStackView::Activating); - enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); - } - if (exit) { - exit->setStatus(QQuickAbstractStackView::Deactivating); - exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); - } - - if (enter && enter->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(enter, transitioner->addTransition); - else - enter->startTransition(transitioner); - } - if (exit && exit->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(exit, transitioner->addDisplacedTransition); - else - exit->startTransition(transitioner); - } - - if (!immediate) - emit q->busyChanged(); - - if (transitioner) - transitioner->resetTargetLists(); -} - -void QQuickAbstractStackViewPrivate::replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) -{ - Q_Q(QQuickAbstractStackView); - if (enter) { - enter->setStatus(QQuickAbstractStackView::Activating); - enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); - } - if (exit) { - exit->removal = true; - exit->setStatus(QQuickAbstractStackView::Deactivating); - exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); - } - - if (enter && enter->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(enter, transitioner->addTransition); - else - enter->startTransition(transitioner); - } - if (exit && exit->prepareTransition(transitioner, viewBounds)) { - if (immediate) - completeTransition(exit, transitioner->addDisplacedTransition); - else - exit->startTransition(transitioner); - } - - if (!immediate) - emit q->busyChanged(); - - if (transitioner) - transitioner->resetTargetLists(); -} - -void QQuickAbstractStackViewPrivate::completeTransition(QQuickStackElement *element, QQuickTransition *transition) -{ - if (transition) { - // TODO: add a proper way to complete a transition - QQmlListProperty animations = transition->animations(); - int count = animations.count(&animations); - for (int i = 0; i < count; ++i) { - QQuickAbstractAnimation *anim = animations.at(&animations, i); - anim->complete(); - } - viewItemTransitionFinished(element); - } -} - -void QQuickAbstractStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransitionableItem *transitionable) -{ - Q_Q(QQuickAbstractStackView); - - QQuickStackElement *element = static_cast(transitionable); - if (element->status == QQuickAbstractStackView::Activating) { - element->setStatus(QQuickAbstractStackView::Active); - } else if (element->status == QQuickAbstractStackView::Deactivating) { - element->setStatus(QQuickAbstractStackView::Inactive); - element->item->setVisible(false); - if (element->removal || element->isPendingRemoval()) - delete element; - } - - if (transitioner->runningJobs.isEmpty()) - emit q->busyChanged(); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractstackview_p.h b/src/controls/qquickabstractstackview_p.h deleted file mode 100644 index d15a7be4..00000000 --- a/src/controls/qquickabstractstackview_p.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSTACKVIEW_P_H -#define QQUICKABSTRACTSTACKVIEW_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 - -QT_BEGIN_NAMESPACE - -class QQmlV4Function; -class QQuickTransition; -class QQuickStackElement; -class QQuickStackAttached; -class QQuickAbstractStackViewPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractStackView : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(bool busy READ busy NOTIFY busyChanged FINAL) - Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL) - Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL) - Q_PROPERTY(QVariant initialItem READ initialItem WRITE setInitialItem FINAL) - Q_PROPERTY(QQuickTransition *popEnter READ popEnter WRITE setPopEnter NOTIFY popEnterChanged FINAL) - Q_PROPERTY(QQuickTransition *popExit READ popExit WRITE setPopExit NOTIFY popExitChanged FINAL) - Q_PROPERTY(QQuickTransition *pushEnter READ pushEnter WRITE setPushEnter NOTIFY pushEnterChanged FINAL) - Q_PROPERTY(QQuickTransition *pushExit READ pushExit WRITE setPushExit NOTIFY pushExitChanged FINAL) - -public: - explicit QQuickAbstractStackView(QQuickItem *parent = Q_NULLPTR); - ~QQuickAbstractStackView(); - - static QQuickStackAttached *qmlAttachedProperties(QObject *object); - - bool busy() const; - int depth() const; - QQuickItem *currentItem() const; - - enum Status { - Inactive = 0, - Deactivating = 1, - Activating = 2, - Active = 3 - }; - Q_ENUM(Status) - - QVariant initialItem() const; - void setInitialItem(const QVariant &item); - - QQuickTransition *popEnter() const; - void setPopEnter(QQuickTransition *enter); - - QQuickTransition *popExit() const; - void setPopExit(QQuickTransition *exit); - - QQuickTransition *pushEnter() const; - void setPushEnter(QQuickTransition *enter); - - QQuickTransition *pushExit() const; - void setPushExit(QQuickTransition *exit); - - enum LoadBehavior { - DontLoad, - ForceLoad - }; - Q_ENUM(LoadBehavior) - - Q_INVOKABLE QQuickItem *get(int index, LoadBehavior behavior = DontLoad); - Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad); - - enum Operation { - Transition, - Immediate - }; - Q_ENUM(Operation) - - Q_INVOKABLE void push(QQmlV4Function *args); - Q_INVOKABLE void pop(QQmlV4Function *args); - Q_INVOKABLE void replace(QQmlV4Function *args); - -public Q_SLOTS: - void clear(); - -Q_SIGNALS: - void busyChanged(); - void depthChanged(); - void currentItemChanged(); - void popEnterChanged(); - void popExitChanged(); - void pushEnterChanged(); - void pushExitChanged(); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractStackView) - Q_DECLARE_PRIVATE(QQuickAbstractStackView) -}; - -class QQuickStackAttachedPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickStackAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) - Q_PROPERTY(QQuickAbstractStackView::Status status READ status NOTIFY statusChanged FINAL) - -public: - explicit QQuickStackAttached(QQuickItem *parent = Q_NULLPTR); - - int index() const; - QQuickAbstractStackView::Status status() const; - -Q_SIGNALS: - void indexChanged(); - void statusChanged(); - -private: - Q_DISABLE_COPY(QQuickStackAttached) - Q_DECLARE_PRIVATE(QQuickStackAttached) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QQuickAbstractStackView, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QQuickAbstractStackView) - -#endif // QQUICKABSTRACTSTACKVIEW_P_H diff --git a/src/controls/qquickabstractstackview_p_p.h b/src/controls/qquickabstractstackview_p_p.h deleted file mode 100644 index 5cda34f9..00000000 --- a/src/controls/qquickabstractstackview_p_p.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSTACKVIEW_P_P_H -#define QQUICKABSTRACTSTACKVIEW_P_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 -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QQmlContext; -class QQmlComponent; -class QQmlIncubator; - -class QQuickStackElement : public QQuickItemViewTransitionableItem, public QQuickItemChangeListener -{ - QQuickStackElement(); - -public: - ~QQuickStackElement(); - - static QQuickStackElement *fromString(const QString &str, QQuickAbstractStackView *view); - static QQuickStackElement *fromObject(QObject *object, QQuickAbstractStackView *view); - - bool load(QQuickAbstractStackView *parent); - void initItem(QObject *object); - void initProperties(); - - void setIndex(int index); - void setStatus(QQuickAbstractStackView::Status status); - - void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget); - bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds); - void startTransition(QQuickItemViewTransitioner *transitioner); - - void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; - - int index; - bool removal; - bool ownItem; - bool ownComponent; - QQmlContext *context; - QQmlComponent *component; - QQmlIncubator *incubator; - QQuickAbstractStackView *view; - QPointer originalParent; - QQuickAbstractStackView::Status status; - QV4::PersistentValue properties; - QV4::PersistentValue qmlGlobal; -}; - -class QQuickAbstractStackViewPrivate : public QQuickAbstractContainerPrivate, public QQuickItemViewTransitionChangeListener -{ - Q_DECLARE_PUBLIC(QQuickAbstractStackView) - -public: - QQuickAbstractStackViewPrivate(); - - static QQuickAbstractStackViewPrivate *get(QQuickAbstractStackView *view) - { - return view->d_func(); - } - - void setCurrentItem(QQuickItem *item); - - QList parseElements(QQmlV4Function *args, int from = 0); - QQuickStackElement *findElement(QQuickItem *item) const; - QQuickStackElement *findElement(const QV4::Value &value) const; - QQuickStackElement *createElement(const QV4::Value &value); - bool pushElements(const QList &elements); - bool pushElement(QQuickStackElement *element); - bool popElements(QQuickStackElement *element); - bool replaceElements(QQuickStackElement *element, const QList &elements); - - void ensureTransitioner(); - void popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); - void pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); - void replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); - void completeTransition(QQuickStackElement *element, QQuickTransition *transition); - - void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) Q_DECL_OVERRIDE; - - QVariant initialItem; - QQuickItem *currentItem; - QStack elements; - QQuickItemViewTransitioner *transitioner; -}; - -class QQuickStackAttachedPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QQuickStackAttached) - -public: - QQuickStackAttachedPrivate() : initialized(false), element(Q_NULLPTR) { } - - static QQuickStackAttachedPrivate *get(QQuickStackAttached *attached) - { - return attached->d_func(); - } - - void init(); - void reset(); - - bool initialized; - QQuickStackElement *element; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTSTACKVIEW_P_P_H diff --git a/src/controls/qquickabstractswitch.cpp b/src/controls/qquickabstractswitch.cpp deleted file mode 100644 index 0251a887..00000000 --- a/src/controls/qquickabstractswitch.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstractswitch_p.h" -#include "qquickabstractcheckable_p_p.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmltype Switch - \inherits Checkable - \instantiates QQuickAbstractSwitch - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A switch control. - - TODO -*/ - -class QQuickAbstractSwitchPrivate : public QQuickAbstractCheckablePrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractSwitch) - -public: - QQuickAbstractSwitchPrivate() : position(0) { } - - void updatePosition(); - - qreal position; - QPoint pressPoint; -}; - -void QQuickAbstractSwitchPrivate::updatePosition() -{ - Q_Q(QQuickAbstractSwitch); - q->setPosition(checked ? 1.0 : 0.0); -} - -QQuickAbstractSwitch::QQuickAbstractSwitch(QQuickItem *parent) : - QQuickAbstractCheckable(*(new QQuickAbstractSwitchPrivate), parent) -{ - setFiltersChildMouseEvents(true); - QObjectPrivate::connect(this, &QQuickAbstractCheckable::checkedChanged, d_func(), &QQuickAbstractSwitchPrivate::updatePosition); -} - -/*! - \qmlproperty real QtQuickControls2::Switch::position - - TODO -*/ -qreal QQuickAbstractSwitch::position() const -{ - Q_D(const QQuickAbstractSwitch); - return d->position; -} - -void QQuickAbstractSwitch::setPosition(qreal position) -{ - Q_D(QQuickAbstractSwitch); - position = qBound(0.0, position, 1.0); - if (d->position != position) { - d->position = position; - emit positionChanged(); - emit visualPositionChanged(); - } -} - -/*! - \qmlproperty real QtQuickControls2::Switch::visualPosition - - TODO -*/ -qreal QQuickAbstractSwitch::visualPosition() const -{ - Q_D(const QQuickAbstractSwitch); - if (isMirrored()) - return 1.0 - d->position; - return d->position; -} - -void QQuickAbstractSwitch::mirrorChange() -{ - QQuickAbstractCheckable::mirrorChange(); - emit visualPositionChanged(); -} - -bool QQuickAbstractSwitch::childMouseEventFilter(QQuickItem *child, QEvent *event) -{ - if (child == indicator()) { - switch (event->type()) { - case QEvent::MouseButtonPress: - return handleMousePressEvent(child, static_cast(event)); - case QEvent::MouseMove: - return handleMouseMoveEvent(child, static_cast(event)); - case QEvent::MouseButtonRelease: - return handleMouseReleaseEvent(child, static_cast(event)); - case QEvent::UngrabMouse: - return handleMouseUngrabEvent(child); - default: - return false; - } - } - return false; -} - -bool QQuickAbstractSwitch::handleMousePressEvent(QQuickItem *child, QMouseEvent *event) -{ - Q_D(QQuickAbstractSwitch); - Q_UNUSED(child); - d->pressPoint = event->pos(); - setPressed(true); - event->accept(); - return true; -} - -bool QQuickAbstractSwitch::handleMouseMoveEvent(QQuickItem *child, QMouseEvent *event) -{ - Q_D(QQuickAbstractSwitch); - if (!child->keepMouseGrab()) - child->setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().x() - d->pressPoint.x(), Qt::XAxis, event)); - if (child->keepMouseGrab()) { - setPosition(positionAt(event->pos())); - event->accept(); - } - return true; -} - -bool QQuickAbstractSwitch::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event) -{ - Q_D(QQuickAbstractSwitch); - d->pressPoint = QPoint(); - setPressed(false); - if (child->keepMouseGrab()) { - setChecked(position() > 0.5); - setPosition(isChecked() ? 1.0 : 0.0); - child->setKeepMouseGrab(false); - } else { - emit clicked(); - toggle(); - } - event->accept(); - return true; -} - -bool QQuickAbstractSwitch::handleMouseUngrabEvent(QQuickItem *child) -{ - Q_D(QQuickAbstractSwitch); - Q_UNUSED(child); - d->pressPoint = QPoint(); - setChecked(position() > 0.5); - setPosition(isChecked() ? 1.0 : 0.0); - setPressed(false); - return true; -} - -qreal QQuickAbstractSwitch::positionAt(const QPoint &point) const -{ - qreal pos = point.x() / indicator()->width(); - if (isMirrored()) - return 1.0 - pos; - return pos; -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstractswitch_p.h b/src/controls/qquickabstractswitch_p.h deleted file mode 100644 index 1ca7a196..00000000 --- a/src/controls/qquickabstractswitch_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTSWITCH_P_H -#define QQUICKABSTRACTSWITCH_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractSwitchPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractSwitch : public QQuickAbstractCheckable -{ - Q_OBJECT - Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL) - Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) - -public: - explicit QQuickAbstractSwitch(QQuickItem *parent = Q_NULLPTR); - - qreal position() const; - void setPosition(qreal position); - - qreal visualPosition() const; - -Q_SIGNALS: - void positionChanged(); - void visualPositionChanged(); - -protected: - void mirrorChange() Q_DECL_OVERRIDE; - bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE; - - bool handleMousePressEvent(QQuickItem *child, QMouseEvent *event); - bool handleMouseMoveEvent(QQuickItem *child, QMouseEvent *event); - bool handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event); - bool handleMouseUngrabEvent(QQuickItem *child); - - virtual qreal positionAt(const QPoint &point) const; - -private: - Q_DISABLE_COPY(QQuickAbstractSwitch) - Q_DECLARE_PRIVATE(QQuickAbstractSwitch) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTSWITCH_P_H diff --git a/src/controls/qquickabstracttabbar.cpp b/src/controls/qquickabstracttabbar.cpp deleted file mode 100644 index 2917a3b7..00000000 --- a/src/controls/qquickabstracttabbar.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttabbar_p.h" -#include "qquickabstractcontainer_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype TabBar - \inherits Container - \instantiates QQuickAbstractTabBar - \inqmlmodule QtQuick.Controls - \ingroup tabs - \brief A tab bar control. - - TODO -*/ - -class QQuickAbstractTabBarPrivate : public QQuickAbstractContainerPrivate -{ -public: - QQuickAbstractTabBarPrivate() : currentIndex(0) { } - - int currentIndex; -}; - -QQuickAbstractTabBar::QQuickAbstractTabBar(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractTabBarPrivate), parent) -{ - setFlag(ItemIsFocusScope); - setActiveFocusOnTab(true); -} - -/*! - \qmlproperty int QtQuickControls2::TabBar::currentIndex - - TODO -*/ -int QQuickAbstractTabBar::currentIndex() const -{ - Q_D(const QQuickAbstractTabBar); - return d->currentIndex; -} - -void QQuickAbstractTabBar::setCurrentIndex(int index) -{ - Q_D(QQuickAbstractTabBar); - if (d->currentIndex != index) { - d->currentIndex = index; - emit currentIndexChanged(index); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttabbar_p.h b/src/controls/qquickabstracttabbar_p.h deleted file mode 100644 index 1781986f..00000000 --- a/src/controls/qquickabstracttabbar_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTABBAR_P_H -#define QQUICKABSTRACTTABBAR_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractTabBarPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractTabBar : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) - -public: - explicit QQuickAbstractTabBar(QQuickItem *parent = Q_NULLPTR); - - int currentIndex() const; - -public Q_SLOTS: - void setCurrentIndex(int index); - -Q_SIGNALS: - void currentIndexChanged(int index); - -private: - Q_DISABLE_COPY(QQuickAbstractTabBar) - Q_DECLARE_PRIVATE(QQuickAbstractTabBar) - friend class QQuickAbstractTabView; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTABBAR_P_H diff --git a/src/controls/qquickabstracttabbutton.cpp b/src/controls/qquickabstracttabbutton.cpp deleted file mode 100644 index df2b2c92..00000000 --- a/src/controls/qquickabstracttabbutton.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttabbutton_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype TabButton - \inherits Checkable - \instantiates QQuickAbstractTabButton - \inqmlmodule QtQuick.Controls - \ingroup tabs - \brief A tab button control. - - TODO -*/ - -QQuickAbstractTabButton::QQuickAbstractTabButton(QQuickItem *parent) : - QQuickAbstractCheckable(parent) -{ - setExclusive(true); -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttabbutton_p.h b/src/controls/qquickabstracttabbutton_p.h deleted file mode 100644 index 8aa5b75e..00000000 --- a/src/controls/qquickabstracttabbutton_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTABBUTTON_P_H -#define QQUICKABSTRACTTABBUTTON_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractTabButton : public QQuickAbstractCheckable -{ - Q_OBJECT - -public: - explicit QQuickAbstractTabButton(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTABBUTTON_P_H diff --git a/src/controls/qquickabstracttabview.cpp b/src/controls/qquickabstracttabview.cpp deleted file mode 100644 index 8a0aa7ac..00000000 --- a/src/controls/qquickabstracttabview.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttabview_p.h" -#include "qquickabstracttabbar_p.h" -#include "qquickabstractcontainer_p_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype TabView - \inherits Container - \instantiates QQuickAbstractTabView - \inqmlmodule QtQuick.Controls - \ingroup tabs - \brief A tab view control. - - TODO -*/ - -class QQuickAbstractTabViewPrivate : public QQuickAbstractContainerPrivate -{ -public: - QQuickAbstractTabViewPrivate() : currentIndex(0), bar(Q_NULLPTR) { } - - int currentIndex; - QQuickAbstractTabBar *bar; -}; - -QQuickAbstractTabView::QQuickAbstractTabView(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractTabViewPrivate), parent) -{ - setFlag(ItemIsFocusScope); - setActiveFocusOnTab(true); -} - -/*! - \qmlproperty int QtQuickControls2::TabView::currentIndex - - TODO -*/ -int QQuickAbstractTabView::currentIndex() const -{ - Q_D(const QQuickAbstractTabView); - return d->currentIndex; -} - -void QQuickAbstractTabView::setCurrentIndex(int index) -{ - Q_D(QQuickAbstractTabView); - if (d->currentIndex != index) { - d->currentIndex = index; - emit currentIndexChanged(index); - } -} - -/*! - \qmlproperty TabBar QtQuickControls2::TabView::tabBar - - TODO -*/ -QQuickAbstractTabBar *QQuickAbstractTabView::tabBar() const -{ - Q_D(const QQuickAbstractTabView); - return d->bar; -} - -void QQuickAbstractTabView::setTabBar(QQuickAbstractTabBar *bar) -{ - Q_D(QQuickAbstractTabView); - if (d->bar != bar) { - if (d->bar) { - disconnect(this, &QQuickAbstractTabView::currentIndexChanged, d->bar, &QQuickAbstractTabBar::setCurrentIndex); - disconnect(d->bar, &QQuickAbstractTabBar::currentIndexChanged, this, &QQuickAbstractTabView::setCurrentIndex); - if (d->bar->parentItem() == this) - delete d->bar; - } - d->bar = bar; - if (bar) { - connect(this, &QQuickAbstractTabView::currentIndexChanged, d->bar, &QQuickAbstractTabBar::setCurrentIndex); - connect(bar, &QQuickAbstractTabBar::currentIndexChanged, this, &QQuickAbstractTabView::setCurrentIndex); - if (!bar->parentItem()) - bar->setParentItem(this); - - int barIndex = bar->currentIndex(); - if (d->currentIndex != barIndex) { - if (d->currentIndex != -1) - bar->setCurrentIndex(d->currentIndex); - else if (barIndex != -1) - setCurrentIndex(barIndex); - } - } - emit tabBarChanged(); - } -} - -void QQuickAbstractTabView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickAbstractTabView); - QQuickControl::geometryChanged(newGeometry, oldGeometry); - if (d->bar) { - QQuickItemPrivate *p = QQuickItemPrivate::get(d->bar); - if (!p->widthValid) { - d->bar->setWidth(newGeometry.width()); - p->widthValid = false; - } - } -} - -/*! - \qmltype Tab - \inherits QtObject - \instantiates QQuickTabAttached - \inqmlmodule QtQuick.Controls - \ingroup tabs - \brief TODO - - TODO -*/ - -QQuickTabAttached::QQuickTabAttached(QObject *parent) : - QObject(parent), m_index(-1), m_visible(true), m_view(Q_NULLPTR) -{ -} - -QQuickTabAttached *QQuickTabAttached::qmlAttachedProperties(QObject *object) -{ - return new QQuickTabAttached(object); -} - -/*! - \qmlattachedproperty int QtQuickControls2::Tab::index - - TODO -*/ -int QQuickTabAttached::index() const -{ - return m_index; -} - -void QQuickTabAttached::setIndex(int index) -{ - if (m_index != index) { - m_index = index; - emit indexChanged(); - } -} - -/*! - \qmlattachedproperty string QtQuickControls2::Tab::title - - TODO -*/ -QString QQuickTabAttached::title() const -{ - return m_title; -} - -void QQuickTabAttached::setTitle(const QString &title) -{ - if (m_title != title) { - m_title = title; - emit titleChanged(); - } -} - -/*! - \qmlattachedproperty bool QtQuickControls2::Tab::visible - - TODO -*/ -bool QQuickTabAttached::isVisible() const -{ - return m_visible; -} - -void QQuickTabAttached::setVisible(bool visible) -{ - if (m_visible != visible) { - m_visible = visible; - emit visibleChanged(); - } -} - -/*! - \qmlattachedproperty TabView QtQuickControls2::Tab::view - - TODO -*/ -QQuickAbstractTabView *QQuickTabAttached::view() const -{ - return m_view; -} - -void QQuickTabAttached::setView(QQuickAbstractTabView *view) -{ - if (m_view != view) { - m_view = view; - emit viewChanged(); - } -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttabview_p.h b/src/controls/qquickabstracttabview_p.h deleted file mode 100644 index a068529d..00000000 --- a/src/controls/qquickabstracttabview_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTABVIEW_P_H -#define QQUICKABSTRACTTABVIEW_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 - -QT_BEGIN_NAMESPACE - -class QQuickAbstractTabBar; -class QQuickAbstractTabViewPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractTabView : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) - Q_PROPERTY(QQuickAbstractTabBar *tabBar READ tabBar WRITE setTabBar NOTIFY tabBarChanged FINAL) - -public: - explicit QQuickAbstractTabView(QQuickItem *parent = Q_NULLPTR); - - int currentIndex() const; - - QQuickAbstractTabBar *tabBar() const; - void setTabBar(QQuickAbstractTabBar *bar); - -public Q_SLOTS: - void setCurrentIndex(int index); - -Q_SIGNALS: - void currentIndexChanged(int index); - void tabBarChanged(); - -protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractTabView) - Q_DECLARE_PRIVATE(QQuickAbstractTabView) -}; - -class Q_QUICKCONTROLS_EXPORT QQuickTabAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(QQuickAbstractTabView *view READ view WRITE setView NOTIFY viewChanged FINAL) - -public: - explicit QQuickTabAttached(QObject *parent = Q_NULLPTR); - - static QQuickTabAttached *qmlAttachedProperties(QObject *object); - - int index() const; - void setIndex(int index); - - QString title() const; - void setTitle(const QString &title); - - bool isVisible() const; - void setVisible(bool visible); - - QQuickAbstractTabView *view() const; - void setView(QQuickAbstractTabView *view); - -Q_SIGNALS: - void indexChanged(); - void titleChanged(); - void visibleChanged(); - void viewChanged(); - -private: - int m_index; - bool m_visible; - QString m_title; - QQuickAbstractTabView *m_view; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QQuickTabAttached, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QQUICKABSTRACTTABVIEW_P_H diff --git a/src/controls/qquickabstracttextarea.cpp b/src/controls/qquickabstracttextarea.cpp deleted file mode 100644 index f2ab95bf..00000000 --- a/src/controls/qquickabstracttextarea.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttextarea_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractTextAreaPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractTextArea) - -public: - QQuickAbstractTextAreaPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { } - - QQuickItem *background; - QQuickText *placeholder; - QQuickAbstractTextArea *q_ptr; -}; - -QQuickAbstractTextArea::QQuickAbstractTextArea(QQuickItem *parent) : - QQuickTextEdit(parent), d_ptr(new QQuickAbstractTextAreaPrivate) -{ - Q_D(QQuickAbstractTextArea); - d->q_ptr = this; -} - -QQuickAbstractTextArea::~QQuickAbstractTextArea() -{ -} - -QQuickItem *QQuickAbstractTextArea::background() const -{ - Q_D(const QQuickAbstractTextArea); - return d->background; -} - -void QQuickAbstractTextArea::setBackground(QQuickItem *background) -{ - Q_D(QQuickAbstractTextArea); - if (d->background != background) { - delete d->background; - d->background = background; - if (background) { - background->setParentItem(this); - if (qFuzzyIsNull(background->z())) - background->setZ(-1); - } - emit backgroundChanged(); - } -} - -QQuickText *QQuickAbstractTextArea::placeholder() const -{ - Q_D(const QQuickAbstractTextArea); - return d->placeholder; -} - -void QQuickAbstractTextArea::setPlaceholder(QQuickText *placeholder) -{ - Q_D(QQuickAbstractTextArea); - if (d->placeholder != placeholder) { - delete d->placeholder; - d->placeholder = placeholder; - if (placeholder && !placeholder->parentItem()) - placeholder->setParentItem(this); - emit placeholderChanged(); - } -} - -void QQuickAbstractTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickAbstractTextArea); - QQuickTextEdit::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; - } - } -} - -QSGNode *QQuickAbstractTextArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) -{ - QQuickDefaultClipNode *clipNode = static_cast(oldNode); - if (!clipNode) - clipNode = new QQuickDefaultClipNode(QRectF()); - - clipNode->setRect(clipRect().adjusted(leftPadding(), topPadding(), -rightPadding(), -bottomPadding())); - clipNode->update(); - - QSGNode *textNode = QQuickTextEdit::updatePaintNode(clipNode->firstChild(), data); - if (!textNode->parent()) - clipNode->appendChildNode(textNode); - - return clipNode; -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttextarea_p.h b/src/controls/qquickabstracttextarea_p.h deleted file mode 100644 index 24e76d29..00000000 --- a/src/controls/qquickabstracttextarea_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTEXTAREA_P_H -#define QQUICKABSTRACTTEXTAREA_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickText; -class QQuickAbstractTextAreaPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextArea : public QQuickTextEdit -{ - Q_OBJECT - Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) - Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) - -public: - explicit QQuickAbstractTextArea(QQuickItem *parent = Q_NULLPTR); - ~QQuickAbstractTextArea(); - - QQuickItem *background() const; - void setBackground(QQuickItem *background); - - QQuickText *placeholder() const; - void setPlaceholder(QQuickText *placeholder); - -Q_SIGNALS: - void backgroundChanged(); - void placeholderChanged(); - -protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractTextArea) - Q_DECLARE_PRIVATE(QQuickAbstractTextArea) - QScopedPointer d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTEXTAREA_P_H diff --git a/src/controls/qquickabstracttextfield.cpp b/src/controls/qquickabstracttextfield.cpp deleted file mode 100644 index b7b35a5d..00000000 --- a/src/controls/qquickabstracttextfield.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttextfield_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractTextFieldPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractTextField) - -public: - QQuickAbstractTextFieldPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { } - - QQuickItem *background; - QQuickText *placeholder; - QQuickAbstractTextField *q_ptr; -}; - -QQuickAbstractTextField::QQuickAbstractTextField(QQuickItem *parent) : - QQuickTextInput(parent), d_ptr(new QQuickAbstractTextFieldPrivate) -{ - Q_D(QQuickAbstractTextField); - d->q_ptr = this; -} - -QQuickAbstractTextField::~QQuickAbstractTextField() -{ -} - -QQuickItem *QQuickAbstractTextField::background() const -{ - Q_D(const QQuickAbstractTextField); - return d->background; -} - -void QQuickAbstractTextField::setBackground(QQuickItem *background) -{ - Q_D(QQuickAbstractTextField); - if (d->background != background) { - delete d->background; - d->background = background; - if (background) { - background->setParentItem(this); - if (qFuzzyIsNull(background->z())) - background->setZ(-1); - } - emit backgroundChanged(); - } -} - -QQuickText *QQuickAbstractTextField::placeholder() const -{ - Q_D(const QQuickAbstractTextField); - return d->placeholder; -} - -void QQuickAbstractTextField::setPlaceholder(QQuickText *placeholder) -{ - Q_D(QQuickAbstractTextField); - if (d->placeholder != placeholder) { - delete d->placeholder; - d->placeholder = placeholder; - if (placeholder && !placeholder->parentItem()) - placeholder->setParentItem(this); - emit placeholderChanged(); - } -} - -void QQuickAbstractTextField::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickAbstractTextField); - QQuickTextInput::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; - } - } -} - -QSGNode *QQuickAbstractTextField::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) -{ - QQuickDefaultClipNode *clipNode = static_cast(oldNode); - if (!clipNode) - clipNode = new QQuickDefaultClipNode(QRectF()); - - clipNode->setRect(clipRect().adjusted(leftPadding(), topPadding(), -rightPadding(), -bottomPadding())); - clipNode->update(); - - QSGNode *textNode = QQuickTextInput::updatePaintNode(clipNode->firstChild(), data); - if (!textNode->parent()) - clipNode->appendChildNode(textNode); - - return clipNode; -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttextfield_p.h b/src/controls/qquickabstracttextfield_p.h deleted file mode 100644 index 248c6a55..00000000 --- a/src/controls/qquickabstracttextfield_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTEXTFIELD_P_H -#define QQUICKABSTRACTTEXTFIELD_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickText; -class QQuickAbstractTextFieldPrivate; - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractTextField : public QQuickTextInput -{ - Q_OBJECT - Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) - Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) - -public: - explicit QQuickAbstractTextField(QQuickItem *parent = Q_NULLPTR); - ~QQuickAbstractTextField(); - - QQuickItem *background() const; - void setBackground(QQuickItem *background); - - QQuickText *placeholder() const; - void setPlaceholder(QQuickText *placeholder); - -Q_SIGNALS: - void backgroundChanged(); - void placeholderChanged(); - -protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractTextField) - Q_DECLARE_PRIVATE(QQuickAbstractTextField) - QScopedPointer d_ptr; -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTEXTFIELD_P_H diff --git a/src/controls/qquickabstracttogglebutton.cpp b/src/controls/qquickabstracttogglebutton.cpp deleted file mode 100644 index 663817e0..00000000 --- a/src/controls/qquickabstracttogglebutton.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttogglebutton_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ToggleButton - \inherits Checkable - \instantiates QQuickAbstractToggleButton - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A toggle button control. - - TODO -*/ - -QQuickAbstractToggleButton::QQuickAbstractToggleButton(QQuickItem *parent) : - QQuickAbstractSwitch(parent) -{ -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttogglebutton_p.h b/src/controls/qquickabstracttogglebutton_p.h deleted file mode 100644 index 7b6bde6e..00000000 --- a/src/controls/qquickabstracttogglebutton_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTOGGLEBUTTON_P_H -#define QQUICKABSTRACTTOGGLEBUTTON_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractToggleButton : public QQuickAbstractSwitch -{ - Q_OBJECT - -public: - explicit QQuickAbstractToggleButton(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTOGGLEBUTTON_P_H diff --git a/src/controls/qquickabstracttoolbar.cpp b/src/controls/qquickabstracttoolbar.cpp deleted file mode 100644 index 29119be0..00000000 --- a/src/controls/qquickabstracttoolbar.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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 "qquickabstracttoolbar_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ToolBar - \inherits Container - \instantiates QQuickAbstractToolBar - \inqmlmodule QtQuick.Controls - \ingroup containers - \brief A tool bar control. - - TODO -*/ - -QQuickAbstractToolBar::QQuickAbstractToolBar(QQuickItem *parent) : - QQuickAbstractContainer(parent) -{ -} - -QT_END_NAMESPACE diff --git a/src/controls/qquickabstracttoolbar_p.h b/src/controls/qquickabstracttoolbar_p.h deleted file mode 100644 index 154d4bd5..00000000 --- a/src/controls/qquickabstracttoolbar_p.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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 QQUICKABSTRACTTOOLBAR_P_H -#define QQUICKABSTRACTTOOLBAR_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 - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS_EXPORT QQuickAbstractToolBar : public QQuickAbstractContainer -{ - Q_OBJECT - -public: - explicit QQuickAbstractToolBar(QQuickItem *parent = Q_NULLPTR); -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTTOOLBAR_P_H diff --git a/src/controls/qquickapplicationwindow.cpp b/src/controls/qquickapplicationwindow.cpp new file mode 100644 index 00000000..7a4809ab --- /dev/null +++ b/src/controls/qquickapplicationwindow.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** 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 "qquickapplicationwindow_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ApplicationWindow + \inherits Window + \instantiates QQuickApplicationWindow + \inqmlmodule QtQuick.Controls + \ingroup application + \brief An application window. + + TODO +*/ + +class QQuickApplicationWindowPrivate : public QQuickItemChangeListener +{ + Q_DECLARE_PUBLIC(QQuickApplicationWindow) + +public: + QQuickApplicationWindowPrivate() : contentWidth(0), contentHeight(0), header(Q_NULLPTR), footer(Q_NULLPTR) { } + + void relayout(); + + void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE; + + qreal contentWidth; + qreal contentHeight; + QQuickItem *header; + QQuickItem *footer; + QQuickApplicationWindow *q_ptr; +}; + +void QQuickApplicationWindowPrivate::relayout() +{ + Q_Q(QQuickApplicationWindow); + QQuickItem *content = q->contentItem(); + qreal hh = header ? header->height() : 0; + qreal fh = footer ? footer->height() : 0; + + content->setY(hh); + content->setHeight(q->height() - hh - fh); + + if (header) + header->setY(-hh); + if (footer) + footer->setY(content->height()); +} + +void QQuickApplicationWindowPrivate::itemImplicitWidthChanged(QQuickItem *item) +{ + Q_UNUSED(item); + relayout(); +} + +void QQuickApplicationWindowPrivate::itemImplicitHeightChanged(QQuickItem *item) +{ + Q_UNUSED(item); + relayout(); +} + +QQuickApplicationWindow::QQuickApplicationWindow(QWindow *parent) : + QQuickWindowQmlImpl(parent), d_ptr(new QQuickApplicationWindowPrivate) +{ + d_ptr->q_ptr = this; +} + +QQuickApplicationWindow::~QQuickApplicationWindow() +{ + Q_D(QQuickApplicationWindow); + if (d->header) + QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); + if (d->footer) + QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); +} + +/*! + \qmlproperty Item QtQuickControls2::ApplicationWindow::header + + TODO +*/ +QQuickItem *QQuickApplicationWindow::header() const +{ + Q_D(const QQuickApplicationWindow); + return d->header; +} + +void QQuickApplicationWindow::setHeader(QQuickItem *header) +{ + Q_D(QQuickApplicationWindow); + if (d->header != header) { + delete d->header; + d->header = header; + if (header) { + header->setParentItem(contentItem()); + QQuickItemPrivate *p = QQuickItemPrivate::get(header); + p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); + if (qFuzzyIsNull(header->z())) + header->setZ(1); + } + emit headerChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::ApplicationWindow::footer + + TODO +*/ +QQuickItem *QQuickApplicationWindow::footer() const +{ + Q_D(const QQuickApplicationWindow); + return d->footer; +} + +void QQuickApplicationWindow::setFooter(QQuickItem *footer) +{ + Q_D(QQuickApplicationWindow); + if (d->footer != footer) { + delete d->footer; + d->footer = footer; + if (footer) { + footer->setParentItem(contentItem()); + QQuickItemPrivate *p = QQuickItemPrivate::get(footer); + p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight); + if (qFuzzyIsNull(footer->z())) + footer->setZ(1); + } + emit footerChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::ApplicationWindow::contentWidth + + TODO +*/ +qreal QQuickApplicationWindow::contentWidth() const +{ + Q_D(const QQuickApplicationWindow); + return d->contentWidth; +} + +void QQuickApplicationWindow::setContentWidth(qreal width) +{ + Q_D(QQuickApplicationWindow); + if (d->contentWidth != width) { + d->contentWidth = width; + emit contentWidthChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::ApplicationWindow::contentHeight + + TODO +*/ +qreal QQuickApplicationWindow::contentHeight() const +{ + Q_D(const QQuickApplicationWindow); + return d->contentHeight; +} + +void QQuickApplicationWindow::setContentHeight(qreal height) +{ + Q_D(QQuickApplicationWindow); + if (d->contentHeight != height) { + d->contentHeight = height; + emit contentHeightChanged(); + } +} + +void QQuickApplicationWindow::resizeEvent(QResizeEvent *event) +{ + QQuickWindowQmlImpl::resizeEvent(event); + + Q_D(QQuickApplicationWindow); + if (d->header) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->header); + if (!p->widthValid) { + d->header->setWidth(width()); + p->widthValid = false; + } + } + if (d->footer) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->footer); + if (!p->widthValid) { + d->footer->setWidth(width()); + p->widthValid = false; + } + } + d->relayout(); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickapplicationwindow_p.h b/src/controls/qquickapplicationwindow_p.h new file mode 100644 index 00000000..6d7522fe --- /dev/null +++ b/src/controls/qquickapplicationwindow_p.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 QQUICKAPPLICATIONWINDOW_P_H +#define QQUICKAPPLICATIONWINDOW_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickApplicationWindowPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickApplicationWindow : public QQuickWindowQmlImpl +{ + Q_OBJECT + Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) + Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) + Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) + Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) + +public: + explicit QQuickApplicationWindow(QWindow *parent = Q_NULLPTR); + ~QQuickApplicationWindow(); + + QQuickItem *header() const; + void setHeader(QQuickItem *header); + + QQuickItem *footer() const; + void setFooter(QQuickItem *footer); + + qreal contentWidth() const; + void setContentWidth(qreal width); + + qreal contentHeight() const; + void setContentHeight(qreal height); + +Q_SIGNALS: + void headerChanged(); + void footerChanged(); + void contentWidthChanged(); + void contentHeightChanged(); + +protected: + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickApplicationWindow) + Q_DECLARE_PRIVATE(QQuickApplicationWindow) + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QQUICKAPPLICATIONWINDOW_P_H diff --git a/src/controls/qquickbusyindicator.cpp b/src/controls/qquickbusyindicator.cpp new file mode 100644 index 00000000..8e0faf0c --- /dev/null +++ b/src/controls/qquickbusyindicator.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** 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 "qquickbusyindicator_p.h" +#include "qquickcontrol_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype BusyIndicator + \inherits Control + \instantiates QQuickBusyIndicator + \inqmlmodule QtQuick.Controls + \ingroup indicators + \brief A busy indicator. + + TODO +*/ + +class QQuickBusyIndicatorPrivate : public QQuickControlPrivate +{ +public: + QQuickBusyIndicatorPrivate() : running(false), indicator(Q_NULLPTR) { } + + bool running; + QQuickItem *indicator; +}; + +QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent) : + QQuickControl(*(new QQuickBusyIndicatorPrivate), parent) +{ +} + +/*! + \qmlproperty bool QtQuickControls2::BusyIndicator::running + + TODO +*/ +bool QQuickBusyIndicator::isRunning() const +{ + Q_D(const QQuickBusyIndicator); + return d->running; +} + +void QQuickBusyIndicator::setRunning(bool running) +{ + Q_D(QQuickBusyIndicator); + if (d->running != running) { + d->running = running; + emit runningChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::BusyIndicator::indicator + + TODO +*/ +QQuickItem *QQuickBusyIndicator::indicator() const +{ + Q_D(const QQuickBusyIndicator); + return d->indicator; +} + +void QQuickBusyIndicator::setIndicator(QQuickItem *indicator) +{ + Q_D(QQuickBusyIndicator); + if (d->indicator != indicator) { + delete d->indicator; + d->indicator = indicator; + if (indicator && !indicator->parentItem()) + indicator->setParentItem(this); + emit indicatorChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickbusyindicator_p.h b/src/controls/qquickbusyindicator_p.h new file mode 100644 index 00000000..b0fcbb4c --- /dev/null +++ b/src/controls/qquickbusyindicator_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 QQUICKBUSYINDICATOR_P_H +#define QQUICKBUSYINDICATOR_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 + +QT_BEGIN_NAMESPACE + +class QQuickBusyIndicatorPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickBusyIndicator : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged FINAL) + Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) + +public: + explicit QQuickBusyIndicator(QQuickItem *parent = Q_NULLPTR); + + bool isRunning() const; + void setRunning(bool running); + + QQuickItem *indicator() const; + void setIndicator(QQuickItem *indicator); + +Q_SIGNALS: + void runningChanged(); + void indicatorChanged(); + +private: + Q_DISABLE_COPY(QQuickBusyIndicator) + Q_DECLARE_PRIVATE(QQuickBusyIndicator) +}; + +QT_END_NAMESPACE + +#endif // QQUICKBUSYINDICATOR_P_H diff --git a/src/controls/qquickbutton.cpp b/src/controls/qquickbutton.cpp new file mode 100644 index 00000000..805af923 --- /dev/null +++ b/src/controls/qquickbutton.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** 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 "qquickbutton_p.h" +#include "qquickbutton_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Button + \inherits Control + \instantiates QQuickButton + \inqmlmodule QtQuick.Controls + \ingroup buttons + \brief A button control. + + TODO +*/ + +QQuickButtonPrivate::QQuickButtonPrivate() : + pressed(false), label(Q_NULLPTR) +{ +} + +QQuickButton::QQuickButton(QQuickItem *parent) : + QQuickControl(*(new QQuickButtonPrivate), parent) +{ + setActiveFocusOnTab(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +QQuickButton::QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent) : + QQuickControl(dd, parent) +{ + setActiveFocusOnTab(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +/*! + \qmlproperty string QtQuickControls2::Button::text + + TODO +*/ +QString QQuickButton::text() const +{ + Q_D(const QQuickButton); + return d->text; +} + +void QQuickButton::setText(const QString &text) +{ + Q_D(QQuickButton); + if (d->text != text) { + d->text = text; + emit textChanged(); + } +} + +/*! + \qmlproperty bool QtQuickControls2::Button::pressed + + TODO +*/ +bool QQuickButton::isPressed() const +{ + Q_D(const QQuickButton); + return d->pressed; +} + +void QQuickButton::setPressed(bool pressed) +{ + Q_D(QQuickButton); + if (d->pressed != pressed) { + d->pressed = pressed; + emit pressedChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::Button::label + + TODO +*/ +QQuickItem *QQuickButton::label() const +{ + Q_D(const QQuickButton); + return d->label; +} + +void QQuickButton::setLabel(QQuickItem *label) +{ + Q_D(QQuickButton); + if (d->label != label) { + delete d->label; + d->label = label; + if (label && !label->parentItem()) + label->setParentItem(this); + emit labelChanged(); + } +} + +void QQuickButton::focusOutEvent(QFocusEvent *event) +{ + QQuickControl::focusOutEvent(event); + setPressed(false); +} + +void QQuickButton::keyPressEvent(QKeyEvent *event) +{ + QQuickControl::keyPressEvent(event); + if (event->key() == Qt::Key_Space) { + setPressed(true); + event->accept(); + } +} + +void QQuickButton::keyReleaseEvent(QKeyEvent *event) +{ + QQuickControl::keyReleaseEvent(event); + if (event->key() == Qt::Key_Space) { + emit clicked(); + setPressed(false); + event->accept(); + } +} + +void QQuickButton::mousePressEvent(QMouseEvent *event) +{ + QQuickControl::mousePressEvent(event); + setPressed(true); + event->accept(); +} + +void QQuickButton::mouseMoveEvent(QMouseEvent *event) +{ + QQuickControl::mouseMoveEvent(event); + setPressed(contains(event->pos())); + event->accept(); +} + +void QQuickButton::mouseReleaseEvent(QMouseEvent *event) +{ + QQuickControl::mouseReleaseEvent(event); + if (contains(event->pos())) + emit clicked(); + setPressed(false); + event->accept(); +} + +void QQuickButton::mouseUngrabEvent() +{ + QQuickControl::mouseUngrabEvent(); + setPressed(false); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickbutton_p.h b/src/controls/qquickbutton_p.h new file mode 100644 index 00000000..4b30b4d3 --- /dev/null +++ b/src/controls/qquickbutton_p.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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 QQUICKBUTTON_P_H +#define QQUICKBUTTON_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 + +QT_BEGIN_NAMESPACE + +class QQuickButtonPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickButton : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) + Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) + Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) + +public: + explicit QQuickButton(QQuickItem *parent = Q_NULLPTR); + + QString text() const; + void setText(const QString &text); + + bool isPressed() const; + void setPressed(bool pressed); + + QQuickItem *label() const; + void setLabel(QQuickItem *label); + +Q_SIGNALS: + void clicked(); + void textChanged(); + void pressedChanged(); + void labelChanged(); + +protected: + QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent); + + void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickButton) + Q_DECLARE_PRIVATE(QQuickButton) +}; + +QT_END_NAMESPACE + +#endif // QQUICKBUTTON_P_H diff --git a/src/controls/qquickbutton_p_p.h b/src/controls/qquickbutton_p_p.h new file mode 100644 index 00000000..ca67c224 --- /dev/null +++ b/src/controls/qquickbutton_p_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 QQUICKBUTTON_P_P_H +#define QQUICKBUTTON_P_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 + +QT_BEGIN_NAMESPACE + +class QQuickButtonPrivate : public QQuickControlPrivate +{ + Q_DECLARE_PUBLIC(QQuickButton) + +public: + QQuickButtonPrivate(); + + QString text; + bool pressed; + QQuickItem *label; +}; + +QT_END_NAMESPACE + +#endif // QQUICKBUTTON_P_P_H diff --git a/src/controls/qquickcheckable.cpp b/src/controls/qquickcheckable.cpp new file mode 100644 index 00000000..c5526c0b --- /dev/null +++ b/src/controls/qquickcheckable.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** 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 "qquickcheckable_p.h" +#include "qquickcheckable_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Checkable + \inherits Button + \instantiates QQuickCheckable + \inqmlmodule QtQuick.Controls + \qmlabstract + \internal +*/ + +QQuickCheckablePrivate::QQuickCheckablePrivate() : + checked(false), exclusive(false), indicator(Q_NULLPTR), layoutDirection(Qt::LeftToRight) +{ +} + +QQuickCheckable::QQuickCheckable(QQuickItem *parent) : + QQuickButton(*(new QQuickCheckablePrivate), parent) +{ +} + +QQuickCheckable::QQuickCheckable(QQuickCheckablePrivate &dd, QQuickItem *parent) : + QQuickButton(dd, parent) +{ +} + +/*! + \qmlproperty bool QtQuickControls2::Checkable::checked + + TODO +*/ +bool QQuickCheckable::isChecked() const +{ + Q_D(const QQuickCheckable); + return d->checked; +} + +void QQuickCheckable::setChecked(bool checked) +{ + Q_D(QQuickCheckable); + if (d->checked != checked) { + d->checked = checked; + emit checkedChanged(); + } +} + +bool QQuickCheckable::isExclusive() const +{ + Q_D(const QQuickCheckable); + return d->exclusive; +} + +void QQuickCheckable::setExclusive(bool exclusive) +{ + Q_D(QQuickCheckable); + d->exclusive = exclusive; +} + +/*! + \qmlproperty Item QtQuickControls2::Checkable::indicator + + TODO +*/ +QQuickItem *QQuickCheckable::indicator() const +{ + Q_D(const QQuickCheckable); + return d->indicator; +} + +void QQuickCheckable::setIndicator(QQuickItem *indicator) +{ + Q_D(QQuickCheckable); + if (d->indicator != indicator) { + delete d->indicator; + d->indicator = indicator; + if (indicator) { + if (!indicator->parentItem()) + indicator->setParentItem(this); + indicator->setAcceptedMouseButtons(Qt::LeftButton); + } + emit indicatorChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::Checkable::layoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickCheckable::layoutDirection() const +{ + Q_D(const QQuickCheckable); + return d->layoutDirection; +} + +/*! + \qmlproperty enumeration QtQuickControls2::Checkable::effectiveLayoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickCheckable::effectiveLayoutDirection() const +{ + Q_D(const QQuickCheckable); + if (isMirrored()) + return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; + return d->layoutDirection; +} + +void QQuickCheckable::setLayoutDirection(Qt::LayoutDirection direction) +{ + Q_D(QQuickCheckable); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + emit effectiveLayoutDirectionChanged(); + } +} + +/*! + \qmlmethod void QtQuickControls2::Checkable::toggle() + + TODO +*/ +void QQuickCheckable::toggle() +{ + Q_D(QQuickCheckable); + setChecked(!d->checked); +} + +void QQuickCheckable::keyReleaseEvent(QKeyEvent *event) +{ + Q_D(QQuickCheckable); + QQuickButton::keyReleaseEvent(event); + if (event->key() == Qt::Key_Space) + setChecked(d->exclusive || !d->checked); +} + +void QQuickCheckable::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QQuickCheckable); + QQuickButton::mouseReleaseEvent(event); + if (contains(event->pos())) + setChecked(d->exclusive || !d->checked); +} + +void QQuickCheckable::mirrorChange() +{ + emit effectiveLayoutDirectionChanged(); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickcheckable_p.h b/src/controls/qquickcheckable_p.h new file mode 100644 index 00000000..71629a49 --- /dev/null +++ b/src/controls/qquickcheckable_p.h @@ -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$ +** +****************************************************************************/ + +#ifndef QQUICKCHECKABLE_P_H +#define QQUICKCHECKABLE_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 + +QT_BEGIN_NAMESPACE + +class QQuickCheckablePrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickCheckable : public QQuickButton +{ + Q_OBJECT + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) + Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) + +public: + explicit QQuickCheckable(QQuickItem *parent = Q_NULLPTR); + + bool isChecked() const; + void setChecked(bool checked); + + bool isExclusive() const; + void setExclusive(bool exclusive); + + QQuickItem *indicator() const; + void setIndicator(QQuickItem *indicator); + + Qt::LayoutDirection layoutDirection() const; + Qt::LayoutDirection effectiveLayoutDirection() const; + void setLayoutDirection(Qt::LayoutDirection direction); + +public Q_SLOTS: + void toggle(); + +Q_SIGNALS: + void checkedChanged(); + void indicatorChanged(); + void layoutDirectionChanged(); + void effectiveLayoutDirectionChanged(); + +protected: + QQuickCheckable(QQuickCheckablePrivate &dd, QQuickItem *parent); + + void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + + void mirrorChange() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickCheckable) + Q_DECLARE_PRIVATE(QQuickCheckable) +}; + +QT_END_NAMESPACE + +#endif // QQUICKCHECKABLE_P_H diff --git a/src/controls/qquickcheckable_p_p.h b/src/controls/qquickcheckable_p_p.h new file mode 100644 index 00000000..2e5b9e39 --- /dev/null +++ b/src/controls/qquickcheckable_p_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 QQUICKCHECKABLE_P_P_H +#define QQUICKCHECKABLE_P_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 + +QT_BEGIN_NAMESPACE + +class QQuickCheckablePrivate : public QQuickButtonPrivate +{ +public: + QQuickCheckablePrivate(); + + bool checked; + bool exclusive; + QQuickItem *indicator; + Qt::LayoutDirection layoutDirection; +}; + +QT_END_NAMESPACE + +#endif // QQUICKCHECKABLE_P_P_H diff --git a/src/controls/qquickcheckbox.cpp b/src/controls/qquickcheckbox.cpp new file mode 100644 index 00000000..680b3b13 --- /dev/null +++ b/src/controls/qquickcheckbox.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 "qquickcheckbox_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype CheckBox + \inherits Checkable + \instantiates QQuickCheckBox + \inqmlmodule QtQuick.Controls + \ingroup buttons + \brief A check box control. + + TODO +*/ + +QQuickCheckBox::QQuickCheckBox(QQuickItem *parent) : + QQuickCheckable(parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickcheckbox_p.h b/src/controls/qquickcheckbox_p.h new file mode 100644 index 00000000..152695ba --- /dev/null +++ b/src/controls/qquickcheckbox_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKCHECKBOX_P_H +#define QQUICKCHECKBOX_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickCheckBox : public QQuickCheckable +{ + Q_OBJECT + +public: + explicit QQuickCheckBox(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKCHECKBOX_P_H diff --git a/src/controls/qquickcontainer.cpp b/src/controls/qquickcontainer.cpp new file mode 100644 index 00000000..71b2a9a1 --- /dev/null +++ b/src/controls/qquickcontainer.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** 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 "qquickcontainer_p.h" +#include "qquickcontainer_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Container + \inherits Control + \instantiates QQuickContainer + \inqmlmodule QtQuick.Controls + \qmlabstract + \internal +*/ + +QQuickContainerPrivate::QQuickContainerPrivate() : + contentWidth(0), contentHeight(0), contentItem(Q_NULLPTR) +{ +} + +QQuickContainer::QQuickContainer(QQuickItem *parent) : + QQuickControl(*(new QQuickContainerPrivate), parent) +{ +} + +QQuickContainer::QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent) : + QQuickControl(dd, parent) +{ +} + +/*! + \qmlproperty real QtQuickControls2::Container::contentWidth + + TODO +*/ +qreal QQuickContainer::contentWidth() const +{ + Q_D(const QQuickContainer); + return d->contentWidth; +} + +void QQuickContainer::setContentWidth(qreal width) +{ + Q_D(QQuickContainer); + if (d->contentWidth != width) { + d->contentWidth = width; + emit contentWidthChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::Container::contentHeight + + TODO +*/ +qreal QQuickContainer::contentHeight() const +{ + Q_D(const QQuickContainer); + return d->contentHeight; +} + +void QQuickContainer::setContentHeight(qreal height) +{ + Q_D(QQuickContainer); + if (d->contentHeight != height) { + d->contentHeight = height; + emit contentHeightChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::Container::contentItem + + TODO +*/ +QQuickItem *QQuickContainer::contentItem() const +{ + Q_D(const QQuickContainer); + return d->contentItem; +} + +void QQuickContainer::setContentItem(QQuickItem *item) +{ + Q_D(QQuickContainer); + if (d->contentItem != item) { + contentItemChange(d->contentItem, item); + delete d->contentItem; + d->contentItem = item; + if (item) { + if (!item->parentItem()) + item->setParentItem(this); + } + emit contentItemChanged(); + } +} + +void QQuickContainer::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) +{ + Q_UNUSED(newItem); + Q_UNUSED(oldItem); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickcontainer_p.h b/src/controls/qquickcontainer_p.h new file mode 100644 index 00000000..6e3e224a --- /dev/null +++ b/src/controls/qquickcontainer_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 QQUICKCONTAINER_P_H +#define QQUICKCONTAINER_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 + +QT_BEGIN_NAMESPACE + +class QQuickContainerPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickContainer : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) + Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) + Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) + +public: + explicit QQuickContainer(QQuickItem *parent = Q_NULLPTR); + + qreal contentWidth() const; + void setContentWidth(qreal width); + + qreal contentHeight() const; + void setContentHeight(qreal height); + + QQuickItem *contentItem() const; + void setContentItem(QQuickItem *item); + +Q_SIGNALS: + void contentWidthChanged(); + void contentHeightChanged(); + void contentItemChanged(); + +protected: + QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent); + + virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem); + +private: + Q_DISABLE_COPY(QQuickContainer) + Q_DECLARE_PRIVATE(QQuickContainer) +}; + +QT_END_NAMESPACE + +#endif // QQUICKCONTAINER_P_H diff --git a/src/controls/qquickcontainer_p_p.h b/src/controls/qquickcontainer_p_p.h new file mode 100644 index 00000000..c0b52cec --- /dev/null +++ b/src/controls/qquickcontainer_p_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 QQUICKCONTAINER_P_P_H +#define QQUICKCONTAINER_P_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickContainerPrivate : public QQuickControlPrivate +{ +public: + QQuickContainerPrivate(); + + qreal contentWidth; + qreal contentHeight; + QQuickItem *contentItem; +}; + +QT_END_NAMESPACE + +#endif // QQUICKCONTAINER_P_P_H diff --git a/src/controls/qquickframe.cpp b/src/controls/qquickframe.cpp new file mode 100644 index 00000000..1a0f5f68 --- /dev/null +++ b/src/controls/qquickframe.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 "qquickframe_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Frame + \inherits Container + \instantiates QQuickFrame + \inqmlmodule QtQuick.Controls + \ingroup containers + \brief A frame control. + + TODO +*/ + +QQuickFrame::QQuickFrame(QQuickItem *parent) : + QQuickContainer(parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickframe_p.h b/src/controls/qquickframe_p.h new file mode 100644 index 00000000..85bd72fc --- /dev/null +++ b/src/controls/qquickframe_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKFRAME_P_H +#define QQUICKFRAME_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickFrame : public QQuickContainer +{ + Q_OBJECT + +public: + explicit QQuickFrame(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKFRAME_P_H diff --git a/src/controls/qquickgroupbox.cpp b/src/controls/qquickgroupbox.cpp new file mode 100644 index 00000000..3937f6c1 --- /dev/null +++ b/src/controls/qquickgroupbox.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** 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 "qquickgroupbox_p.h" +#include "qquickcontainer_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype GroupBox + \inherits Container + \instantiates QQuickGroupBox + \inqmlmodule QtQuick.Controls + \ingroup containers + \brief A group box control. + + TODO +*/ + +class QQuickGroupBoxPrivate : public QQuickContainerPrivate +{ +public: + QQuickGroupBoxPrivate() : label(Q_NULLPTR), frame(Q_NULLPTR) { } + + QString title; + QQuickItem *label; + QQuickItem *frame; +}; + +QQuickGroupBox::QQuickGroupBox(QQuickItem *parent) : + QQuickContainer(*(new QQuickGroupBoxPrivate), parent) +{ +} + +/*! + \qmlproperty string QtQuickControls2::GroupBox::title + + TODO +*/ +QString QQuickGroupBox::title() const +{ + Q_D(const QQuickGroupBox); + return d->title; +} + +void QQuickGroupBox::setTitle(const QString &title) +{ + Q_D(QQuickGroupBox); + if (d->title != title) { + d->title = title; + emit titleChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::GroupBox::label + + TODO +*/ +QQuickItem *QQuickGroupBox::label() const +{ + Q_D(const QQuickGroupBox); + return d->label; +} + +void QQuickGroupBox::setLabel(QQuickItem *label) +{ + Q_D(QQuickGroupBox); + if (d->label != label) { + delete d->label; + d->label = label; + if (label && !label->parentItem()) + label->setParentItem(this); + emit labelChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::GroupBox::frame + + TODO +*/ +QQuickItem *QQuickGroupBox::frame() const +{ + Q_D(const QQuickGroupBox); + return d->frame; +} + +void QQuickGroupBox::setFrame(QQuickItem *frame) +{ + Q_D(QQuickGroupBox); + if (d->frame != frame) { + delete d->frame; + d->frame = frame; + if (frame && !frame->parentItem()) + frame->setParentItem(this); + emit frameChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickgroupbox_p.h b/src/controls/qquickgroupbox_p.h new file mode 100644 index 00000000..d2e65f63 --- /dev/null +++ b/src/controls/qquickgroupbox_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QQUICKGROUPBOX_P_H +#define QQUICKGROUPBOX_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 + +QT_BEGIN_NAMESPACE + +class QQuickGroupBoxPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickGroupBox : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) + Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) + Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL) + +public: + explicit QQuickGroupBox(QQuickItem *parent = Q_NULLPTR); + + QString title() const; + void setTitle(const QString &title); + + QQuickItem *label() const; + void setLabel(QQuickItem *label); + + QQuickItem *frame() const; + void setFrame(QQuickItem *frame); + +Q_SIGNALS: + void titleChanged(); + void labelChanged(); + void frameChanged(); + +private: + Q_DISABLE_COPY(QQuickGroupBox) + Q_DECLARE_PRIVATE(QQuickGroupBox) +}; + +QT_END_NAMESPACE + +#endif // QQUICKGROUPBOX_P_H diff --git a/src/controls/qquicklabel.cpp b/src/controls/qquicklabel.cpp new file mode 100644 index 00000000..1536bb91 --- /dev/null +++ b/src/controls/qquicklabel.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 "qquicklabel_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickLabelPrivate +{ + Q_DECLARE_PUBLIC(QQuickLabel) + +public: + QQuickLabelPrivate() : background(Q_NULLPTR) { } + + QQuickItem *background; + QQuickLabel *q_ptr; +}; + +QQuickLabel::QQuickLabel(QQuickItem *parent) : + QQuickText(parent), d_ptr(new QQuickLabelPrivate) +{ + Q_D(QQuickLabel); + d->q_ptr = this; +} + +QQuickLabel::~QQuickLabel() +{ +} + +QQuickItem *QQuickLabel::background() const +{ + Q_D(const QQuickLabel); + return d->background; +} + +void QQuickLabel::setBackground(QQuickItem *background) +{ + Q_D(QQuickLabel); + 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 QQuickLabel::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickLabel); + 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/qquicklabel_p.h b/src/controls/qquicklabel_p.h new file mode 100644 index 00000000..009372fd --- /dev/null +++ b/src/controls/qquicklabel_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 QQUICKLABEL_P_H +#define QQUICKLABEL_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickLabelPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickLabel : public QQuickText +{ + Q_OBJECT + Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) + +public: + explicit QQuickLabel(QQuickItem *parent = Q_NULLPTR); + ~QQuickLabel(); + + 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(QQuickLabel) + Q_DECLARE_PRIVATE(QQuickLabel) + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QQUICKLABEL_P_H diff --git a/src/controls/qquickpageindicator.cpp b/src/controls/qquickpageindicator.cpp new file mode 100644 index 00000000..58b5d66f --- /dev/null +++ b/src/controls/qquickpageindicator.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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 "qquickpageindicator_p.h" +#include "qquickcontainer_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype PageIndicator + \inherits Control + \instantiates QQuickPageIndicator + \inqmlmodule QtQuick.Controls + \ingroup indicators + \brief A page indicator. + + TODO +*/ + +class QQuickPageIndicatorPrivate : public QQuickContainerPrivate +{ +public: + QQuickPageIndicatorPrivate() : count(0), currentIndex(0) { } + + int count; + int currentIndex; +}; + +QQuickPageIndicator::QQuickPageIndicator(QQuickItem *parent) : + QQuickContainer(*(new QQuickPageIndicatorPrivate), parent) +{ +} + +/*! + \qmlproperty int QtQuickControls2::PageIndicator::count + + TODO +*/ +int QQuickPageIndicator::count() const +{ + Q_D(const QQuickPageIndicator); + return d->count; +} + +void QQuickPageIndicator::setCount(int count) +{ + Q_D(QQuickPageIndicator); + if (d->count != count) { + d->count = count; + emit countChanged(); + } +} + +/*! + \qmlproperty int QtQuickControls2::PageIndicator::currentIndex + + TODO +*/ +int QQuickPageIndicator::currentIndex() const +{ + Q_D(const QQuickPageIndicator); + return d->currentIndex; +} + +void QQuickPageIndicator::setCurrentIndex(int index) +{ + Q_D(QQuickPageIndicator); + if (d->currentIndex != index) { + d->currentIndex = index; + emit currentIndexChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickpageindicator_p.h b/src/controls/qquickpageindicator_p.h new file mode 100644 index 00000000..dcf0d093 --- /dev/null +++ b/src/controls/qquickpageindicator_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 QQUICKPAGEINDICATOR_P_H +#define QQUICKPAGEINDICATOR_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 + +QT_BEGIN_NAMESPACE + +class QQuickPageIndicatorPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickPageIndicator : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged FINAL) + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) + +public: + explicit QQuickPageIndicator(QQuickItem *parent = Q_NULLPTR); + + int count() const; + void setCount(int count); + + int currentIndex() const; + void setCurrentIndex(int index); + +Q_SIGNALS: + void countChanged(); + void currentIndexChanged(); + +private: + Q_DISABLE_COPY(QQuickPageIndicator) + Q_DECLARE_PRIVATE(QQuickPageIndicator) +}; + +QT_END_NAMESPACE + +#endif // QQUICKPAGEINDICATOR_P_H diff --git a/src/controls/qquickprogressbar.cpp b/src/controls/qquickprogressbar.cpp new file mode 100644 index 00000000..5bd15091 --- /dev/null +++ b/src/controls/qquickprogressbar.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 "qquickprogressbar_p.h" +#include "qquickcontrol_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ProgressBar + \inherits Control + \instantiates QQuickProgressBar + \inqmlmodule QtQuick.Controls + \ingroup indicators + \brief A progress bar. + + TODO +*/ + +class QQuickProgressBarPrivate : public QQuickControlPrivate +{ +public: + QQuickProgressBarPrivate() : value(0), indeterminate(false), + layoutDirection(Qt::LeftToRight), indicator(Q_NULLPTR) { } + + qreal value; + bool indeterminate; + Qt::LayoutDirection layoutDirection; + QQuickItem *indicator; +}; + +QQuickProgressBar::QQuickProgressBar(QQuickItem *parent) : + QQuickControl(*(new QQuickProgressBarPrivate), parent) +{ +} + +/*! + \qmlproperty real QtQuickControls2::ProgressBar::value + + TODO +*/ +qreal QQuickProgressBar::value() const +{ + Q_D(const QQuickProgressBar); + return d->value; +} + +void QQuickProgressBar::setValue(qreal value) +{ + Q_D(QQuickProgressBar); + value = qBound(0.0, value, 1.0); + if (!qFuzzyCompare(d->value, value)) { + d->value = value; + emit valueChanged(); + emit visualPositionChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::ProgressBar::visualPosition + + TODO +*/ +qreal QQuickProgressBar::visualPosition() const +{ + Q_D(const QQuickProgressBar); + if (effectiveLayoutDirection() == Qt::RightToLeft) + return 1.0 - d->value; + return d->value; +} + +/*! + \qmlproperty bool QtQuickControls2::ProgressBar::indeterminate + + TODO +*/ +bool QQuickProgressBar::isIndeterminate() const +{ + Q_D(const QQuickProgressBar); + return d->indeterminate; +} + +void QQuickProgressBar::setIndeterminate(bool indeterminate) +{ + Q_D(QQuickProgressBar); + if (d->indeterminate != indeterminate) { + d->indeterminate = indeterminate; + emit indeterminateChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::ProgressBar::layoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickProgressBar::layoutDirection() const +{ + Q_D(const QQuickProgressBar); + return d->layoutDirection; +} + +/*! + \qmlproperty enumeration QtQuickControls2::ProgressBar::effectiveLayoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickProgressBar::effectiveLayoutDirection() const +{ + Q_D(const QQuickProgressBar); + if (isMirrored()) + return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; + return d->layoutDirection; +} + +void QQuickProgressBar::setLayoutDirection(Qt::LayoutDirection direction) +{ + Q_D(QQuickProgressBar); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + emit effectiveLayoutDirectionChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::ProgressBar::indicator + + TODO +*/ +QQuickItem *QQuickProgressBar::indicator() const +{ + Q_D(const QQuickProgressBar); + return d->indicator; +} + +void QQuickProgressBar::setIndicator(QQuickItem *indicator) +{ + Q_D(QQuickProgressBar); + if (d->indicator != indicator) { + delete d->indicator; + d->indicator = indicator; + if (indicator && !indicator->parentItem()) + indicator->setParentItem(this); + emit indicatorChanged(); + } +} + +void QQuickProgressBar::mirrorChange() +{ + emit effectiveLayoutDirectionChanged(); + emit visualPositionChanged(); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickprogressbar_p.h b/src/controls/qquickprogressbar_p.h new file mode 100644 index 00000000..9b046890 --- /dev/null +++ b/src/controls/qquickprogressbar_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 QQUICKPROGRESSBAR_P_H +#define QQUICKPROGRESSBAR_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 + +QT_BEGIN_NAMESPACE + +class QQuickProgressBarPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickProgressBar : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) + Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) + Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) + Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) + +public: + explicit QQuickProgressBar(QQuickItem *parent = Q_NULLPTR); + + qreal value() const; + void setValue(qreal value); + + qreal visualPosition() const; + + bool isIndeterminate() const; + void setIndeterminate(bool indeterminate); + + Qt::LayoutDirection layoutDirection() const; + Qt::LayoutDirection effectiveLayoutDirection() const; + void setLayoutDirection(Qt::LayoutDirection direction); + + QQuickItem *indicator() const; + void setIndicator(QQuickItem *indicator); + +Q_SIGNALS: + void valueChanged(); + void visualPositionChanged(); + void indeterminateChanged(); + void layoutDirectionChanged(); + void effectiveLayoutDirectionChanged(); + void indicatorChanged(); + +protected: + void mirrorChange() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickProgressBar) + Q_DECLARE_PRIVATE(QQuickProgressBar) +}; + +QT_END_NAMESPACE + +#endif // QQUICKPROGRESSBAR_P_H diff --git a/src/controls/qquickradiobutton.cpp b/src/controls/qquickradiobutton.cpp new file mode 100644 index 00000000..c42a0207 --- /dev/null +++ b/src/controls/qquickradiobutton.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 "qquickradiobutton_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype RadioButton + \inherits Checkable + \instantiates QQuickRadioButton + \inqmlmodule QtQuick.Controls + \ingroup buttons + \brief A radio button control. + + TODO + + \sa ExclusiveGroup +*/ + +QQuickRadioButton::QQuickRadioButton(QQuickItem *parent) : + QQuickCheckable(parent) +{ + setExclusive(true); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickradiobutton_p.h b/src/controls/qquickradiobutton_p.h new file mode 100644 index 00000000..5c5f76d7 --- /dev/null +++ b/src/controls/qquickradiobutton_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKRADIOBUTTON_P_H +#define QQUICKRADIOBUTTON_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickRadioButton : public QQuickCheckable +{ + Q_OBJECT + +public: + explicit QQuickRadioButton(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKRADIOBUTTON_P_H diff --git a/src/controls/qquickscrollbar.cpp b/src/controls/qquickscrollbar.cpp new file mode 100644 index 00000000..068d4525 --- /dev/null +++ b/src/controls/qquickscrollbar.cpp @@ -0,0 +1,432 @@ +/**************************************************************************** +** +** 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 "qquickscrollbar_p.h" +#include "qquickcontrol_p_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ScrollBar + \inherits Control + \instantiates QQuickScrollBar + \inqmlmodule QtQuick.Controls + \ingroup indicators + \ingroup sliders + \brief A scroll bar. + + TODO +*/ + +class QQuickScrollBarPrivate : public QQuickControlPrivate +{ +public: + QQuickScrollBarPrivate() : size(0), position(0), offset(0), + active(false), pressed(false), moving(false), + orientation(Qt::Vertical), handle(Q_NULLPTR) { } + + static QQuickScrollBarPrivate *get(QQuickScrollBar *bar) + { + return bar->d_func(); + } + + qreal size; + qreal position; + qreal offset; + bool active; + bool pressed; + bool moving; + Qt::Orientation orientation; + QQuickItem *handle; +}; + +QQuickScrollBar::QQuickScrollBar(QQuickItem *parent) : + QQuickControl(*(new QQuickScrollBarPrivate), parent) +{ + setKeepMouseGrab(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +QQuickScrollBarAttached *QQuickScrollBar::qmlAttachedProperties(QObject *object) +{ + QQuickFlickable *flickable = qobject_cast(object); + if (flickable) + return new QQuickScrollBarAttached(flickable); + + qWarning() << "ScrollBar must be attached to a Flickable" << object; + return Q_NULLPTR; +} + +/*! + \qmlproperty real QtQuickControls2::ScrollBar::size + + TODO +*/ +qreal QQuickScrollBar::size() const +{ + Q_D(const QQuickScrollBar); + return d->size; +} + +void QQuickScrollBar::setSize(qreal size) +{ + Q_D(QQuickScrollBar); + if (!qFuzzyCompare(d->size, size)) { + d->size = size; + emit sizeChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::ScrollBar::position + + TODO +*/ +qreal QQuickScrollBar::position() const +{ + Q_D(const QQuickScrollBar); + return d->position; +} + +void QQuickScrollBar::setPosition(qreal position) +{ + Q_D(QQuickScrollBar); + if (!qFuzzyCompare(d->position, position)) { + d->position = position; + emit positionChanged(); + } +} + +/*! + \qmlproperty bool QtQuickControls2::ScrollBar::active + + TODO +*/ +bool QQuickScrollBar::isActive() const +{ + Q_D(const QQuickScrollBar); + return d->active; +} + +void QQuickScrollBar::setActive(bool active) +{ + Q_D(QQuickScrollBar); + if (d->active != active) { + d->active = active; + emit activeChanged(); + } +} + +/*! + \qmlproperty bool QtQuickControls2::ScrollBar::pressed + + TODO +*/ +bool QQuickScrollBar::isPressed() const +{ + Q_D(const QQuickScrollBar); + return d->pressed; +} + +void QQuickScrollBar::setPressed(bool pressed) +{ + Q_D(QQuickScrollBar); + if (d->pressed != pressed) { + d->pressed = pressed; + setActive(d->pressed || d->moving); + emit pressedChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::ScrollBar::orientation + + TODO +*/ +Qt::Orientation QQuickScrollBar::orientation() const +{ + Q_D(const QQuickScrollBar); + return d->orientation; +} + +void QQuickScrollBar::setOrientation(Qt::Orientation orientation) +{ + Q_D(QQuickScrollBar); + if (d->orientation != orientation) { + d->orientation = orientation; + emit orientationChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::ScrollBar::handle + + TODO +*/ +QQuickItem *QQuickScrollBar::handle() const +{ + Q_D(const QQuickScrollBar); + return d->handle; +} + +void QQuickScrollBar::setHandle(QQuickItem *handle) +{ + Q_D(QQuickScrollBar); + if (d->handle != handle) { + delete d->handle; + d->handle = handle; + if (handle && !handle->parentItem()) + handle->setParentItem(this); + emit handleChanged(); + } +} + +void QQuickScrollBar::mousePressEvent(QMouseEvent *event) +{ + Q_D(QQuickScrollBar); + QQuickControl::mousePressEvent(event); + d->offset = positionAt(event->pos()) - d->position; + if (d->offset < 0 || d->offset > d->size) + d->offset = d->size / 2; + setPressed(true); + event->accept(); +} + +void QQuickScrollBar::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QQuickScrollBar); + QQuickControl::mouseMoveEvent(event); + setPosition(qBound(0.0, positionAt(event->pos()) - d->offset, 1.0 - d->size)); + event->accept(); +} + +void QQuickScrollBar::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QQuickScrollBar); + QQuickControl::mouseReleaseEvent(event); + setPosition(qBound(0.0, positionAt(event->pos()) - d->offset, 1.0 - d->size)); + d->offset = 0.0; + setPressed(false); + event->accept(); +} + +qreal QQuickScrollBar::positionAt(const QPoint &point) const +{ + Q_D(const QQuickScrollBar); + if (d->orientation == Qt::Horizontal) + return point.x() / width(); + else + return point.y() / height(); +} + +class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener +{ +public: + QQuickScrollBarAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { } + + void activateHorizontal(); + void activateVertical(); + void scrollHorizontal(); + void scrollVertical(); + + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + + QQuickFlickable *flickable; + QQuickScrollBar *horizontal; + QQuickScrollBar *vertical; +}; + +void QQuickScrollBarAttachedPrivate::activateHorizontal() +{ + QQuickScrollBarPrivate *p = QQuickScrollBarPrivate::get(horizontal); + p->moving = flickable->isMovingHorizontally(); + horizontal->setActive(p->moving || p->pressed); +} + +void QQuickScrollBarAttachedPrivate::activateVertical() +{ + QQuickScrollBarPrivate *p = QQuickScrollBarPrivate::get(vertical); + p->moving = flickable->isMovingVertically(); + vertical->setActive(p->moving || p->pressed); +} + +// TODO: QQuickFlickable::maxXYExtent() +class QQuickFriendlyFlickable : public QQuickFlickable +{ + friend class QQuickScrollBarAttachedPrivate; +}; + +void QQuickScrollBarAttachedPrivate::scrollHorizontal() +{ + QQuickFriendlyFlickable *f = reinterpret_cast(flickable); + + const qreal viewwidth = f->width(); + const qreal maxxextent = -f->maxXExtent() + f->minXExtent(); + qreal cx = horizontal->position() * (maxxextent + viewwidth) - f->minXExtent(); + if (!qIsNaN(cx) && !qFuzzyCompare(cx, flickable->contentX())) + flickable->setContentX(cx); +} + +void QQuickScrollBarAttachedPrivate::scrollVertical() +{ + QQuickFriendlyFlickable *f = reinterpret_cast(flickable); + + const qreal viewheight = f->height(); + const qreal maxyextent = -f->maxYExtent() + f->minYExtent(); + qreal cy = vertical->position() * (maxyextent + viewheight) - f->minYExtent(); + if (!qIsNaN(cy) && !qFuzzyCompare(cy, flickable->contentY())) + flickable->setContentY(cy); +} + +void QQuickScrollBarAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_ASSERT(item == flickable); + if (horizontal) { + QQuickItemPrivate *p = QQuickItemPrivate::get(horizontal); + if (!p->widthValid) { + horizontal->setWidth(newGeometry.width()); + p->widthValid = false; + } + if (qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height())) + horizontal->setY(newGeometry.height() - horizontal->height()); + } + if (vertical) { + QQuickItemPrivate *p = QQuickItemPrivate::get(vertical); + if (!p->heightValid) { + vertical->setHeight(newGeometry.height()); + p->heightValid = false; + } + if (!p->isMirrored() && (qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width()))) + vertical->setX(newGeometry.width() - vertical->width()); + } +} + +QQuickScrollBarAttached::QQuickScrollBarAttached(QQuickFlickable *flickable) : + QObject(*(new QQuickScrollBarAttachedPrivate(flickable)), flickable) +{ + Q_D(QQuickScrollBarAttached); + QQuickItemPrivate *p = QQuickItemPrivate::get(flickable); + p->addItemChangeListener(d, QQuickItemPrivate::Geometry); +} + +QQuickScrollBar *QQuickScrollBarAttached::horizontal() const +{ + Q_D(const QQuickScrollBarAttached); + return d->horizontal; +} + +void QQuickScrollBarAttached::setHorizontal(QQuickScrollBar *horizontal) +{ + Q_D(QQuickScrollBarAttached); + if (d->horizontal != horizontal) { + if (d->horizontal) { + QObjectPrivate::disconnect(d->horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal); + QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal))); + disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal))); + } + + d->horizontal = horizontal; + + if (horizontal) { + if (!horizontal->parentItem()) + horizontal->setParentItem(d->flickable); + horizontal->setOrientation(Qt::Horizontal); + + QObjectPrivate::connect(horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal); + QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal))); + connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal))); + + horizontal->setSize(area->property("widthRatio").toReal()); + horizontal->setPosition(area->property("xPosition").toReal()); + } + emit horizontalChanged(); + } +} + +QQuickScrollBar *QQuickScrollBarAttached::vertical() const +{ + Q_D(const QQuickScrollBarAttached); + return d->vertical; +} + +void QQuickScrollBarAttached::setVertical(QQuickScrollBar *vertical) +{ + Q_D(QQuickScrollBarAttached); + if (d->vertical != vertical) { + if (d->vertical) { + QObjectPrivate::disconnect(d->vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical); + QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal))); + disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal))); + } + + d->vertical = vertical; + + if (vertical) { + if (!vertical->parentItem()) + vertical->setParentItem(d->flickable); + vertical->setOrientation(Qt::Vertical); + + QObjectPrivate::connect(vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical); + QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal))); + connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal))); + + vertical->setSize(area->property("heightRatio").toReal()); + vertical->setPosition(area->property("yPosition").toReal()); + } + emit verticalChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickscrollbar_p.h b/src/controls/qquickscrollbar_p.h new file mode 100644 index 00000000..df21d02b --- /dev/null +++ b/src/controls/qquickscrollbar_p.h @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** 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 QQUICKSCROLLBAR_P_H +#define QQUICKSCROLLBAR_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 + +QT_BEGIN_NAMESPACE + +class QQuickFlickable; +class QQuickScrollBarAttached; +class QQuickScrollBarPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickScrollBar : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(qreal size READ size NOTIFY sizeChanged FINAL) + Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) + Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL) + Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) + Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) + +public: + explicit QQuickScrollBar(QQuickItem *parent = Q_NULLPTR); + + static QQuickScrollBarAttached *qmlAttachedProperties(QObject *object); + + qreal size() const; + qreal position() const; + + bool isActive() const; + void setActive(bool active); + + bool isPressed() const; + void setPressed(bool pressed); + + Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation orientation); + + QQuickItem *handle() const; + void setHandle(QQuickItem *handle); + +public Q_SLOTS: + void setSize(qreal size); + void setPosition(qreal position); + +Q_SIGNALS: + void sizeChanged(); + void positionChanged(); + void activeChanged(); + void pressedChanged(); + void orientationChanged(); + void handleChanged(); + +protected: + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + + virtual qreal positionAt(const QPoint &point) const; + +private: + Q_DISABLE_COPY(QQuickScrollBar) + Q_DECLARE_PRIVATE(QQuickScrollBar) +}; + +class QQuickScrollBarAttachedPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickScrollBarAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQuickScrollBar *horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL) + Q_PROPERTY(QQuickScrollBar *vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL) + +public: + explicit QQuickScrollBarAttached(QQuickFlickable *flickable); + + QQuickScrollBar *horizontal() const; + void setHorizontal(QQuickScrollBar *horizontal); + + QQuickScrollBar *vertical() const; + void setVertical(QQuickScrollBar *vertical); + +Q_SIGNALS: + void horizontalChanged(); + void verticalChanged(); + +private: + Q_DISABLE_COPY(QQuickScrollBarAttached) + Q_DECLARE_PRIVATE(QQuickScrollBarAttached) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQuickScrollBar, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQUICKSCROLLBAR_P_H diff --git a/src/controls/qquickscrollindicator.cpp b/src/controls/qquickscrollindicator.cpp new file mode 100644 index 00000000..afd83022 --- /dev/null +++ b/src/controls/qquickscrollindicator.cpp @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** 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 "qquickscrollindicator_p.h" +#include "qquickcontrol_p_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ScrollIndicator + \inherits Control + \instantiates QQuickScrollIndicator + \inqmlmodule QtQuick.Controls + \ingroup indicators + \brief A scroll indicator. + + TODO +*/ + +class QQuickScrollIndicatorPrivate : public QQuickControlPrivate +{ +public: + QQuickScrollIndicatorPrivate() : size(0), position(0), + active(false), orientation(Qt::Vertical), indicator(Q_NULLPTR) { } + + qreal size; + qreal position; + bool active; + Qt::Orientation orientation; + QQuickItem *indicator; +}; + +QQuickScrollIndicator::QQuickScrollIndicator(QQuickItem *parent) : + QQuickControl(*(new QQuickScrollIndicatorPrivate), parent) +{ +} + +QQuickScrollIndicatorAttached *QQuickScrollIndicator::qmlAttachedProperties(QObject *object) +{ + QQuickFlickable *flickable = qobject_cast(object); + if (flickable) + return new QQuickScrollIndicatorAttached(flickable); + + qWarning() << "ScrollIndicator must be attached to a Flickable" << object; + return Q_NULLPTR; +} + +/*! + \qmlproperty real QtQuickControls2::ScrollIndicator::size + + TODO +*/ +qreal QQuickScrollIndicator::size() const +{ + Q_D(const QQuickScrollIndicator); + return d->size; +} + +void QQuickScrollIndicator::setSize(qreal size) +{ + Q_D(QQuickScrollIndicator); + if (!qFuzzyCompare(d->size, size)) { + d->size = size; + emit sizeChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::ScrollIndicator::position + + TODO +*/ +qreal QQuickScrollIndicator::position() const +{ + Q_D(const QQuickScrollIndicator); + return d->position; +} + +void QQuickScrollIndicator::setPosition(qreal position) +{ + Q_D(QQuickScrollIndicator); + if (!qFuzzyCompare(d->position, position)) { + d->position = position; + emit positionChanged(); + } +} + +/*! + \qmlproperty bool QtQuickControls2::ScrollIndicator::active + + TODO +*/ +bool QQuickScrollIndicator::isActive() const +{ + Q_D(const QQuickScrollIndicator); + return d->active; +} + +void QQuickScrollIndicator::setActive(bool active) +{ + Q_D(QQuickScrollIndicator); + if (d->active != active) { + d->active = active; + emit activeChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::ScrollIndicator::orientation + + TODO +*/ +Qt::Orientation QQuickScrollIndicator::orientation() const +{ + Q_D(const QQuickScrollIndicator); + return d->orientation; +} + +void QQuickScrollIndicator::setOrientation(Qt::Orientation orientation) +{ + Q_D(QQuickScrollIndicator); + if (d->orientation != orientation) { + d->orientation = orientation; + emit orientationChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::ScrollIndicator::indicator + + TODO +*/ +QQuickItem *QQuickScrollIndicator::indicator() const +{ + Q_D(const QQuickScrollIndicator); + return d->indicator; +} + +void QQuickScrollIndicator::setIndicator(QQuickItem *indicator) +{ + Q_D(QQuickScrollIndicator); + if (d->indicator != indicator) { + delete d->indicator; + d->indicator = indicator; + if (indicator && !indicator->parentItem()) + indicator->setParentItem(this); + emit indicatorChanged(); + } +} + +class QQuickScrollIndicatorAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener +{ +public: + QQuickScrollIndicatorAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { } + + void activateHorizontal(); + void activateVertical(); + + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + + QQuickFlickable *flickable; + QQuickScrollIndicator *horizontal; + QQuickScrollIndicator *vertical; +}; + +void QQuickScrollIndicatorAttachedPrivate::activateHorizontal() +{ + horizontal->setActive(flickable->isMovingHorizontally()); +} + +void QQuickScrollIndicatorAttachedPrivate::activateVertical() +{ + vertical->setActive(flickable->isMovingVertically()); +} + +void QQuickScrollIndicatorAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_ASSERT(item == flickable); + if (horizontal) { + QQuickItemPrivate *p = QQuickItemPrivate::get(horizontal); + if (!p->widthValid) { + horizontal->setWidth(newGeometry.width()); + p->widthValid = false; + } + if (qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height())) + horizontal->setY(newGeometry.height() - horizontal->height()); + } + if (vertical) { + QQuickItemPrivate *p = QQuickItemPrivate::get(vertical); + if (!p->heightValid) { + vertical->setHeight(newGeometry.height()); + p->heightValid = false; + } + if (!p->isMirrored() && (qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width()))) + vertical->setX(newGeometry.width() - vertical->width()); + } +} + +QQuickScrollIndicatorAttached::QQuickScrollIndicatorAttached(QQuickFlickable *flickable) : + QObject(*(new QQuickScrollIndicatorAttachedPrivate(flickable)), flickable) +{ + Q_D(QQuickScrollIndicatorAttached); + QQuickItemPrivate *p = QQuickItemPrivate::get(flickable); + p->addItemChangeListener(d, QQuickItemPrivate::Geometry); +} + +QQuickScrollIndicator *QQuickScrollIndicatorAttached::horizontal() const +{ + Q_D(const QQuickScrollIndicatorAttached); + return d->horizontal; +} + +void QQuickScrollIndicatorAttached::setHorizontal(QQuickScrollIndicator *horizontal) +{ + Q_D(QQuickScrollIndicatorAttached); + if (d->horizontal != horizontal) { + if (d->horizontal) { + QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal))); + disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal))); + } + + d->horizontal = horizontal; + + if (horizontal) { + if (!horizontal->parentItem()) + horizontal->setParentItem(d->flickable); + horizontal->setOrientation(Qt::Horizontal); + + QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal))); + connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal))); + + horizontal->setSize(area->property("widthRatio").toReal()); + horizontal->setPosition(area->property("xPosition").toReal()); + } + emit horizontalChanged(); + } +} + +QQuickScrollIndicator *QQuickScrollIndicatorAttached::vertical() const +{ + Q_D(const QQuickScrollIndicatorAttached); + return d->vertical; +} + +void QQuickScrollIndicatorAttached::setVertical(QQuickScrollIndicator *vertical) +{ + Q_D(QQuickScrollIndicatorAttached); + if (d->vertical != vertical) { + if (d->vertical) { + QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal))); + disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal))); + } + + d->vertical = vertical; + + if (vertical) { + if (!vertical->parentItem()) + vertical->setParentItem(d->flickable); + vertical->setOrientation(Qt::Vertical); + + QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical); + + // TODO: export QQuickFlickableVisibleArea + QObject *area = d->flickable->property("visibleArea").value(); + connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal))); + connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal))); + + vertical->setSize(area->property("heightRatio").toReal()); + vertical->setPosition(area->property("yPosition").toReal()); + } + emit verticalChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickscrollindicator_p.h b/src/controls/qquickscrollindicator_p.h new file mode 100644 index 00000000..c8c8e946 --- /dev/null +++ b/src/controls/qquickscrollindicator_p.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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 QQUICKSCROLLINDICATOR_P_H +#define QQUICKSCROLLINDICATOR_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 + +QT_BEGIN_NAMESPACE + +class QQuickFlickable; +class QQuickScrollIndicatorAttached; +class QQuickScrollIndicatorPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickScrollIndicator : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(qreal size READ size NOTIFY sizeChanged FINAL) + Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) + Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) + Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) + +public: + explicit QQuickScrollIndicator(QQuickItem *parent = Q_NULLPTR); + + static QQuickScrollIndicatorAttached *qmlAttachedProperties(QObject *object); + + qreal size() const; + qreal position() const; + + bool isActive() const; + void setActive(bool active); + + Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation orientation); + + QQuickItem *indicator() const; + void setIndicator(QQuickItem *indicator); + +public Q_SLOTS: + void setSize(qreal size); + void setPosition(qreal position); + +Q_SIGNALS: + void sizeChanged(); + void positionChanged(); + void activeChanged(); + void orientationChanged(); + void indicatorChanged(); + +private: + Q_DISABLE_COPY(QQuickScrollIndicator) + Q_DECLARE_PRIVATE(QQuickScrollIndicator) +}; + +class QQuickScrollIndicatorAttachedPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickScrollIndicatorAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQuickScrollIndicator *horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL) + Q_PROPERTY(QQuickScrollIndicator *vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL) + +public: + explicit QQuickScrollIndicatorAttached(QQuickFlickable *flickable); + + QQuickScrollIndicator *horizontal() const; + void setHorizontal(QQuickScrollIndicator *horizontal); + + QQuickScrollIndicator *vertical() const; + void setVertical(QQuickScrollIndicator *vertical); + +Q_SIGNALS: + void horizontalChanged(); + void verticalChanged(); + +private: + Q_DISABLE_COPY(QQuickScrollIndicatorAttached) + Q_DECLARE_PRIVATE(QQuickScrollIndicatorAttached) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQuickScrollIndicator, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQUICKSCROLLINDICATOR_P_H diff --git a/src/controls/qquickslider.cpp b/src/controls/qquickslider.cpp new file mode 100644 index 00000000..a55b5c9d --- /dev/null +++ b/src/controls/qquickslider.cpp @@ -0,0 +1,454 @@ +/**************************************************************************** +** +** 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 "qquickslider_p.h" +#include "qquickcontrol_p_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Slider + \inherits Control + \instantiates QQuickSlider + \inqmlmodule QtQuick.Controls + \ingroup sliders + \brief A slider control. + + TODO +*/ + +class QQuickSliderPrivate : public QQuickControlPrivate +{ + Q_DECLARE_PUBLIC(QQuickSlider) + +public: + QQuickSliderPrivate() : value(0), position(0), stepSize(0), + pressed(false), orientation(Qt::Horizontal), layoutDirection(Qt::LeftToRight), + snapMode(QQuickSlider::NoSnap), handle(Q_NULLPTR), track(Q_NULLPTR) { } + + qreal snapPosition(qreal position) const; + qreal positionAt(const QPoint &point) const; + + qreal value; + qreal position; + qreal stepSize; + bool pressed; + QPoint pressPoint; + Qt::Orientation orientation; + Qt::LayoutDirection layoutDirection; + QQuickSlider::SnapMode snapMode; + QQuickItem *handle; + QQuickItem *track; +}; + +qreal QQuickSliderPrivate::snapPosition(qreal position) const +{ + if (qFuzzyIsNull(stepSize)) + return position; + return qRound(position / stepSize) * stepSize; +} + +qreal QQuickSliderPrivate::positionAt(const QPoint &point) const +{ + Q_Q(const QQuickSlider); + if (orientation == Qt::Horizontal) { + const qreal hw = handle ? handle->width() : 0; + const qreal offset = hw / 2; + const qreal extent = q->width() - hw; + if (!qFuzzyIsNull(extent)) { + const qreal pos = (point.x() - offset) / extent; + if (q->effectiveLayoutDirection() == Qt::RightToLeft) + return 1.0 - pos; + return pos; + } + } else { + const qreal hh = handle ? handle->height() : 0; + const qreal offset = hh / 2; + const qreal extent = q->height() - hh; + if (!qFuzzyIsNull(extent)) + return (point.y() - offset) / extent; + } + return 0; +} + +QQuickSlider::QQuickSlider(QQuickItem *parent) : + QQuickControl(*(new QQuickSliderPrivate), parent) +{ + setActiveFocusOnTab(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +/*! + \qmlproperty real QtQuickControls2::Slider::value + + TODO +*/ +qreal QQuickSlider::value() const +{ + Q_D(const QQuickSlider); + return d->value; +} + +void QQuickSlider::setValue(qreal value) +{ + Q_D(QQuickSlider); + value = qBound(0.0, value, 1.0); + if (!qFuzzyCompare(d->value, value)) { + d->value = value; + setPosition(value); + emit valueChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::Slider::position + + TODO +*/ +qreal QQuickSlider::position() const +{ + Q_D(const QQuickSlider); + return d->position; +} + +/*! + \qmlproperty real QtQuickControls2::Slider::visualPosition + + TODO +*/ +qreal QQuickSlider::visualPosition() const +{ + Q_D(const QQuickSlider); + if (d->orientation == Qt::Vertical || effectiveLayoutDirection() == Qt::RightToLeft) + return 1.0 - d->position; + return d->position; +} + +void QQuickSlider::setPosition(qreal position) +{ + Q_D(QQuickSlider); + position = qBound(0.0, position, 1.0); + if (!qFuzzyCompare(d->position, position)) { + d->position = position; + emit positionChanged(); + emit visualPositionChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::Slider::stepSize + + TODO +*/ +qreal QQuickSlider::stepSize() const +{ + Q_D(const QQuickSlider); + return d->stepSize; +} + +void QQuickSlider::setStepSize(qreal step) +{ + Q_D(QQuickSlider); + if (!qFuzzyCompare(d->stepSize, step)) { + d->stepSize = step; + emit stepSizeChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::Slider::snapMode + + TODO +*/ +QQuickSlider::SnapMode QQuickSlider::snapMode() const +{ + Q_D(const QQuickSlider); + return d->snapMode; +} + +void QQuickSlider::setSnapMode(SnapMode mode) +{ + Q_D(QQuickSlider); + if (d->snapMode != mode) { + d->snapMode = mode; + emit snapModeChanged(); + } +} + +/*! + \qmlproperty bool QtQuickControls2::Slider::pressed + + TODO +*/ +bool QQuickSlider::isPressed() const +{ + Q_D(const QQuickSlider); + return d->pressed; +} + +void QQuickSlider::setPressed(bool pressed) +{ + Q_D(QQuickSlider); + if (d->pressed != pressed) { + d->pressed = pressed; + emit pressedChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::Slider::orientation + + TODO +*/ +Qt::Orientation QQuickSlider::orientation() const +{ + Q_D(const QQuickSlider); + return d->orientation; +} + +void QQuickSlider::setOrientation(Qt::Orientation orientation) +{ + Q_D(QQuickSlider); + if (d->orientation != orientation) { + d->orientation = orientation; + emit orientationChanged(); + } +} + +/*! + \qmlproperty enumeration QtQuickControls2::Slider::layoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickSlider::layoutDirection() const +{ + Q_D(const QQuickSlider); + return d->layoutDirection; +} + +/*! + \qmlproperty enumeration QtQuickControls2::Slider::effectiveLayoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickSlider::effectiveLayoutDirection() const +{ + Q_D(const QQuickSlider); + if (isMirrored()) + return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; + return d->layoutDirection; +} + +void QQuickSlider::setLayoutDirection(Qt::LayoutDirection direction) +{ + Q_D(QQuickSlider); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + emit effectiveLayoutDirectionChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::Slider::handle + + TODO +*/ +QQuickItem *QQuickSlider::handle() const +{ + Q_D(const QQuickSlider); + return d->handle; +} + +void QQuickSlider::setHandle(QQuickItem *handle) +{ + Q_D(QQuickSlider); + if (d->handle != handle) { + delete d->handle; + d->handle = handle; + if (handle && !handle->parentItem()) + handle->setParentItem(this); + emit handleChanged(); + } +} + +/*! + \qmlproperty Item QtQuickControls2::Slider::track + + TODO +*/ +QQuickItem *QQuickSlider::track() const +{ + Q_D(const QQuickSlider); + return d->track; +} + +void QQuickSlider::setTrack(QQuickItem *track) +{ + Q_D(QQuickSlider); + if (d->track != track) { + delete d->track; + d->track = track; + if (track && !track->parentItem()) + track->setParentItem(this); + emit trackChanged(); + } +} + +/*! + \qmlmethod void QtQuickControls2::Slider::increase() + + TODO +*/ +void QQuickSlider::increase() +{ + Q_D(QQuickSlider); + qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; + setValue(d->value + step); +} + +/*! + \qmlmethod void QtQuickControls2::Slider::decrease() + + TODO +*/ +void QQuickSlider::decrease() +{ + Q_D(QQuickSlider); + qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; + setValue(d->value - step); +} + +void QQuickSlider::keyPressEvent(QKeyEvent *event) +{ + Q_D(QQuickSlider); + QQuickControl::keyPressEvent(event); + if (d->orientation == Qt::Horizontal) { + if (event->key() == Qt::Key_Left) { + setPressed(true); + if (effectiveLayoutDirection() == Qt::RightToLeft) + increase(); + else + decrease(); + event->accept(); + } else if (event->key() == Qt::Key_Right) { + setPressed(true); + if (effectiveLayoutDirection() == Qt::RightToLeft) + decrease(); + else + increase(); + event->accept(); + } + } else { + if (event->key() == Qt::Key_Up) { + setPressed(true); + increase(); + event->accept(); + } else if (event->key() == Qt::Key_Down) { + setPressed(true); + decrease(); + event->accept(); + } + } +} + +void QQuickSlider::keyReleaseEvent(QKeyEvent *event) +{ + QQuickControl::keyReleaseEvent(event); + setPressed(false); +} + +void QQuickSlider::mousePressEvent(QMouseEvent *event) +{ + Q_D(QQuickSlider); + QQuickControl::mousePressEvent(event); + d->pressPoint = event->pos(); + setPressed(true); + event->accept(); +} + +void QQuickSlider::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QQuickSlider); + QQuickControl::mouseMoveEvent(event); + if (!keepMouseGrab()) { + if (d->orientation == Qt::Horizontal) + setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().x() - d->pressPoint.x(), Qt::XAxis, event)); + else + setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().y() - d->pressPoint.y(), Qt::YAxis, event)); + } + if (keepMouseGrab()) { + qreal pos = d->positionAt(event->pos()); + if (d->snapMode == SnapAlways) + pos = d->snapPosition(pos); + setPosition(pos); + } + event->accept(); +} + +void QQuickSlider::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QQuickSlider); + QQuickControl::mouseReleaseEvent(event); + d->pressPoint = QPoint(); + if (keepMouseGrab()) { + qreal pos = d->positionAt(event->pos()); + if (d->snapMode != NoSnap) + pos = d->snapPosition(pos); + setValue(pos); + setKeepMouseGrab(false); + } + setPressed(false); + event->accept(); +} + +void QQuickSlider::mouseUngrabEvent() +{ + Q_D(QQuickSlider); + QQuickControl::mouseUngrabEvent(); + d->pressPoint = QPoint(); + setPressed(false); +} + +void QQuickSlider::mirrorChange() +{ + emit effectiveLayoutDirectionChanged(); + emit visualPositionChanged(); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickslider_p.h b/src/controls/qquickslider_p.h new file mode 100644 index 00000000..8215565d --- /dev/null +++ b/src/controls/qquickslider_p.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 QQUICKSLIDER_P_H +#define QQUICKSLIDER_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 + +QT_BEGIN_NAMESPACE + +class QQuickSliderPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickSlider : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) + Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) + Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) + Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) + Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) + Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) + Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) + Q_PROPERTY(QQuickItem *track READ track WRITE setTrack NOTIFY trackChanged FINAL) + +public: + explicit QQuickSlider(QQuickItem *parent = Q_NULLPTR); + + qreal value() const; + void setValue(qreal value); + + qreal position() const; + qreal visualPosition() const; + void setPosition(qreal position); + + qreal stepSize() const; + void setStepSize(qreal step); + + enum SnapMode { + NoSnap, + SnapAlways, + SnapOnRelease + }; + Q_ENUM(SnapMode) + + SnapMode snapMode() const; + void setSnapMode(SnapMode mode); + + bool isPressed() const; + void setPressed(bool pressed); + + Qt::Orientation orientation() const; + void setOrientation(Qt::Orientation orientation); + + Qt::LayoutDirection layoutDirection() const; + Qt::LayoutDirection effectiveLayoutDirection() const; + void setLayoutDirection(Qt::LayoutDirection direction); + + QQuickItem *handle() const; + void setHandle(QQuickItem *handle); + + QQuickItem *track() const; + void setTrack(QQuickItem *track); + +public Q_SLOTS: + void increase(); + void decrease(); + +Q_SIGNALS: + void valueChanged(); + void positionChanged(); + void visualPositionChanged(); + void stepSizeChanged(); + void snapModeChanged(); + void pressedChanged(); + void orientationChanged(); + void layoutDirectionChanged(); + void effectiveLayoutDirectionChanged(); + void handleChanged(); + void trackChanged(); + +protected: + void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + void mirrorChange() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickSlider) + Q_DECLARE_PRIVATE(QQuickSlider) +}; + +QT_END_NAMESPACE + +#endif // QQUICKSLIDER_P_H diff --git a/src/controls/qquickstackview.cpp b/src/controls/qquickstackview.cpp new file mode 100644 index 00000000..c8a7589a --- /dev/null +++ b/src/controls/qquickstackview.cpp @@ -0,0 +1,553 @@ +/**************************************************************************** +** +** 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 "qquickstackview_p.h" +#include "qquickstackview_p_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype StackView + \inherits Container + \instantiates QQuickStackView + \inqmlmodule QtQuick.Controls + \ingroup navigation + \brief A stack view control. + + TODO +*/ + +QQuickStackView::QQuickStackView(QQuickItem *parent) : + QQuickContainer(*(new QQuickStackViewPrivate), parent) +{ + setFlag(ItemIsFocusScope); +} + +QQuickStackView::~QQuickStackView() +{ + Q_D(QQuickStackView); + if (d->transitioner) { + d->transitioner->setChangeListener(Q_NULLPTR); + delete d->transitioner; + } + qDeleteAll(d->elements); +} + +QQuickStackAttached *QQuickStackView::qmlAttachedProperties(QObject *object) +{ + QQuickItem *item = qobject_cast(object); + if (!item) { + qmlInfo(object) << "StackView must be attached to an Item"; + return Q_NULLPTR; + } + return new QQuickStackAttached(item); +} + +/*! + \qmlproperty bool QtQuickControls2::StackView::busy + \readonly + This property holds whether a transition is running. +*/ +bool QQuickStackView::busy() const +{ + Q_D(const QQuickStackView); + return d->transitioner && !d->transitioner->runningJobs.isEmpty(); +} + +/*! + \qmlproperty int QtQuickControls2::StackView::depth + \readonly + This property holds the number of items currently pushed onto the stack. +*/ +int QQuickStackView::depth() const +{ + Q_D(const QQuickStackView); + return d->elements.count(); +} + +/*! + \qmlproperty Item QtQuickControls2::StackView::currentItem + \readonly + This property holds the current top-most item in the stack. +*/ +QQuickItem *QQuickStackView::currentItem() const +{ + Q_D(const QQuickStackView); + return d->currentItem; +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::get(index, behavior = DontLoad) + + Supported behavior values: + \li StackView.DontLoad + \li StackView.ForceLoad + + TODO +*/ +QQuickItem *QQuickStackView::get(int index, LoadBehavior behavior) +{ + Q_D(QQuickStackView); + QQuickStackElement *element = d->elements.value(index); + if (element) { + if (behavior == ForceLoad) + element->load(this); + return element->item; + } + return Q_NULLPTR; +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::find(callback, behavior = DontLoad) + + Supported behavior values: + \li StackView.DontLoad + \li StackView.ForceLoad + + TODO +*/ +QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavior) +{ + Q_D(QQuickStackView); + QJSValue func(callback); + QQmlEngine *engine = qmlEngine(this); + if (!engine || !func.isCallable()) // TODO: warning? + return Q_NULLPTR; + + for (int i = d->elements.count() - 1; i >= 0; --i) { + QQuickStackElement *element = d->elements.at(i); + if (behavior == ForceLoad) + element->load(this); + if (element->item) { + QJSValue rv = func.call(QJSValueList() << engine->newQObject(element->item) << i); + if (rv.toBool()) + return element->item; + } + } + + return Q_NULLPTR; +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::push(item, properties, operation) + + TODO +*/ +void QQuickStackView::push(QQmlV4Function *args) +{ + Q_D(QQuickStackView); + if (args->length() <= 0) { + qmlInfo(this) << "push: missing arguments"; + args->setReturnValue(QV4::Encode::null()); + return; + } + + QV4::ExecutionEngine *v4 = args->v4engine(); + QV4::Scope scope(v4); + + Operation operation = d->elements.isEmpty() ? Immediate : Transition; + QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]); + if (lastArg->isInt32()) + operation = static_cast(lastArg->toInt32()); + + QList elements = d->parseElements(args); + if (elements.isEmpty()) { + qmlInfo(this) << "push: nothing to push"; + args->setReturnValue(QV4::Encode::null()); + return; + } + + QQuickStackElement *exit = Q_NULLPTR; + if (!d->elements.isEmpty()) + exit = d->elements.top(); + + if (d->pushElements(elements)) { + emit depthChanged(); + QQuickStackElement *enter = d->elements.top(); + d->pushTransition(enter, exit, boundingRect(), operation == Immediate); + d->setCurrentItem(enter->item); + } + + if (d->currentItem) { + QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, d->currentItem)); + args->setReturnValue(rv->asReturnedValue()); + } else { + args->setReturnValue(QV4::Encode::null()); + } +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::pop(item = null, operation = Transition) + + TODO +*/ +void QQuickStackView::pop(QQmlV4Function *args) +{ + Q_D(QQuickStackView); + int argc = args->length(); + if (d->elements.count() <= 1 || argc > 2) { + if (argc > 2) + qmlInfo(this) << "pop: too many arguments"; + args->setReturnValue(QV4::Encode::null()); + return; + } + + QQuickStackElement *exit = d->elements.pop(); + QQuickStackElement *enter = d->elements.top(); + + QV4::ExecutionEngine *v4 = args->v4engine(); + QV4::Scope scope(v4); + + if (argc > 0) { + QV4::ScopedValue value(scope, (*args)[0]); + if (value->isNull()) { + enter = d->elements.value(0); + } else if (!value->isUndefined() && !value->isInt32()) { + enter = d->findElement(value); + if (!enter) { + qmlInfo(this) << "pop: unknown argument: " << value->toQString(); // TODO: safe? + args->setReturnValue(QV4::Encode::null()); + d->elements.push(exit); // restore + return; + } + } + } + + Operation operation = Transition; + if (argc > 0) { + QV4::ScopedValue lastArg(scope, (*args)[argc - 1]); + if (lastArg->isInt32()) + operation = static_cast(lastArg->toInt32()); + } + + QQuickItem *previousItem = Q_NULLPTR; + + if (d->popElements(enter)) { + if (exit) + previousItem = exit->item; + emit depthChanged(); + d->popTransition(enter, exit, boundingRect(), operation == Immediate); + d->setCurrentItem(enter->item); + } + + if (previousItem) { + QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, previousItem)); + args->setReturnValue(rv->asReturnedValue()); + } else { + args->setReturnValue(QV4::Encode::null()); + } +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::push(item, properties, operation = Transition) + + TODO +*/ +void QQuickStackView::replace(QQmlV4Function *args) +{ + Q_D(QQuickStackView); + if (args->length() <= 0) { + qmlInfo(this) << "replace: missing arguments"; + args->setReturnValue(QV4::Encode::null()); + return; + } + + QV4::ExecutionEngine *v4 = args->v4engine(); + QV4::Scope scope(v4); + + Operation operation = d->elements.isEmpty() ? Immediate : Transition; + QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]); + if (lastArg->isInt32()) + operation = static_cast(lastArg->toInt32()); + + QQuickStackElement *target = Q_NULLPTR; + QV4::ScopedValue firstArg(scope, (*args)[0]); + if (firstArg->isNull()) + target = d->elements.value(0); + else if (!firstArg->isInt32()) + target = d->findElement(firstArg); + + QList elements = d->parseElements(args, target ? 1 : 0); + if (elements.isEmpty()) { + qmlInfo(this) << "replace: nothing to push"; + args->setReturnValue(QV4::Encode::null()); + return; + } + + int depth = d->elements.count(); + QQuickStackElement* exit = Q_NULLPTR; + if (!d->elements.isEmpty()) + exit = d->elements.pop(); + + if (d->replaceElements(target, elements)) { + if (depth != d->elements.count()) + emit depthChanged(); + QQuickStackElement *enter = d->elements.top(); + d->replaceTransition(enter, exit, boundingRect(), operation == Immediate); + d->setCurrentItem(enter->item); + } + + if (d->currentItem) { + QV4::ScopedValue rv(scope, QV4::QObjectWrapper::wrap(v4, d->currentItem)); + args->setReturnValue(rv->asReturnedValue()); + } else { + args->setReturnValue(QV4::Encode::null()); + } +} + +/*! + \qmlmethod Item QtQuickControls2::StackView::clear() + + TODO +*/ +void QQuickStackView::clear() +{ + Q_D(QQuickStackView); + d->setCurrentItem(Q_NULLPTR); + qDeleteAll(d->elements); + d->elements.clear(); + emit depthChanged(); +} + +/*! + \qmlproperty var QtQuickControls2::StackView::initialItem + + This property holds the initial item. + + \sa push() +*/ +QVariant QQuickStackView::initialItem() const +{ + Q_D(const QQuickStackView); + return d->initialItem; +} + +void QQuickStackView::setInitialItem(const QVariant &item) +{ + Q_D(QQuickStackView); + d->initialItem = item; +} + +/*! + \qmlproperty Transition QtQuickControls2::StackView::popEnter + + TODO +*/ +QQuickTransition *QQuickStackView::popEnter() const +{ + Q_D(const QQuickStackView); + if (d->transitioner) + return d->transitioner->removeDisplacedTransition; + return Q_NULLPTR; +} + +void QQuickStackView::setPopEnter(QQuickTransition *enter) +{ + Q_D(QQuickStackView); + d->ensureTransitioner(); + if (d->transitioner->removeDisplacedTransition != enter) { + d->transitioner->removeDisplacedTransition = enter; + emit popEnterChanged(); + } +} + +/*! + \qmlproperty Transition QtQuickControls2::StackView::popExit + + TODO +*/ +QQuickTransition *QQuickStackView::popExit() const +{ + Q_D(const QQuickStackView); + if (d->transitioner) + return d->transitioner->removeTransition; + return Q_NULLPTR; +} + +void QQuickStackView::setPopExit(QQuickTransition *exit) +{ + Q_D(QQuickStackView); + d->ensureTransitioner(); + if (d->transitioner->removeTransition != exit) { + d->transitioner->removeTransition = exit; + emit popExitChanged(); + } +} + +/*! + \qmlproperty Transition QtQuickControls2::StackView::pushEnter + + TODO +*/ +QQuickTransition *QQuickStackView::pushEnter() const +{ + Q_D(const QQuickStackView); + if (d->transitioner) + return d->transitioner->addTransition; + return Q_NULLPTR; +} + +void QQuickStackView::setPushEnter(QQuickTransition *enter) +{ + Q_D(QQuickStackView); + d->ensureTransitioner(); + if (d->transitioner->addTransition != enter) { + d->transitioner->addTransition = enter; + emit pushEnterChanged(); + } +} + +/*! + \qmlproperty Transition QtQuickControls2::StackView::pushExit + + TODO +*/ +QQuickTransition *QQuickStackView::pushExit() const +{ + Q_D(const QQuickStackView); + if (d->transitioner) + return d->transitioner->addDisplacedTransition; + return Q_NULLPTR; +} + +void QQuickStackView::setPushExit(QQuickTransition *exit) +{ + Q_D(QQuickStackView); + d->ensureTransitioner(); + if (d->transitioner->addDisplacedTransition != exit) { + d->transitioner->addDisplacedTransition = exit; + emit pushExitChanged(); + } +} + +void QQuickStackView::componentComplete() +{ + QQuickContainer::componentComplete(); + + Q_D(QQuickStackView); + QQuickStackElement *element = Q_NULLPTR; + if (QObject *o = d->initialItem.value()) + element = QQuickStackElement::fromObject(o, this); + else if (d->initialItem.canConvert()) + element = QQuickStackElement::fromString(d->initialItem.toString(), this); + if (d->pushElement(element)) { + emit depthChanged(); + d->setCurrentItem(element->item); + } +} + +void QQuickStackView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + QQuickContainer::geometryChanged(newGeometry, oldGeometry); + + Q_D(QQuickStackView); + foreach (QQuickStackElement *element, d->elements) { + if (element->item) { + QQuickItemPrivate *p = QQuickItemPrivate::get(element->item); + if (!p->widthValid) { + element->item->setWidth(newGeometry.width()); + p->widthValid = false; + } + if (!p->heightValid) { + element->item->setHeight(newGeometry.height()); + p->heightValid = false; + } + } + } +} + +void QQuickStackAttachedPrivate::init() +{ + QQuickItem *item = qobject_cast(parent); + if (item) { + QQuickStackView *view = qobject_cast(item->parentItem()); + if (view) { + element = QQuickStackViewPrivate::get(view)->findElement(item); + if (element) + initialized = true; + } + } +} + +void QQuickStackAttachedPrivate::reset() +{ + Q_Q(QQuickStackAttached); + int oldIndex = element ? element->index : -1; + QQuickStackView::Status oldStatus = element ? element->status : QQuickStackView::Inactive; + + element = Q_NULLPTR; + + if (oldIndex != -1) + emit q->indexChanged(); + if (oldStatus != QQuickStackView::Inactive) + emit q->statusChanged(); +} + +QQuickStackAttached::QQuickStackAttached(QQuickItem *parent) : + QObject(*(new QQuickStackAttachedPrivate), parent) +{ +} + +/*! + \qmlattachedproperty int QtQuickControls2::StackView::index + + TODO +*/ +int QQuickStackAttached::index() const +{ + Q_D(const QQuickStackAttached); + if (!d->initialized) + const_cast(d)->init(); + return d->element ? d->element->index : -1; +} + +/*! + \qmlattachedproperty enumeration QtQuickControls2::StackView::status + + TODO +*/ +QQuickStackView::Status QQuickStackAttached::status() const +{ + Q_D(const QQuickStackAttached); + if (!d->initialized) + const_cast(d)->init(); + return d->element ? d->element->status : QQuickStackView::Inactive; +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickstackview_p.cpp b/src/controls/qquickstackview_p.cpp new file mode 100644 index 00000000..f2dfff52 --- /dev/null +++ b/src/controls/qquickstackview_p.cpp @@ -0,0 +1,507 @@ +/**************************************************************************** +** +** 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 "qquickstackview_p_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static QQuickStackAttached *attachedStackObject(QQuickItem *item) +{ + return qobject_cast(qmlAttachedPropertiesObject(item, false)); +} + +class QQuickStackIncubator : public QQmlIncubator +{ +public: + QQuickStackIncubator(QQuickStackElement *element) : QQmlIncubator(Synchronous), element(element) { } + +protected: + void setInitialState(QObject *object) Q_DECL_OVERRIDE { element->initItem(object); } + +private: + QQuickStackElement *element; +}; + +QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(Q_NULLPTR), + index(-1), removal(false), ownItem(false), ownComponent(false), + context(Q_NULLPTR), component(Q_NULLPTR), incubator(Q_NULLPTR), view(Q_NULLPTR), + status(QQuickStackView::Inactive) +{ +} + +QQuickStackElement::~QQuickStackElement() +{ + if (item) { + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed); + + QQuickStackAttached *attached = attachedStackObject(item); + if (attached) + QQuickStackAttachedPrivate::get(attached)->reset(); + } + + if (ownComponent) + delete component; + + if (ownItem && item) { + item->setParentItem(Q_NULLPTR); + item->deleteLater(); + item = Q_NULLPTR; + } else if (item) { + item->setVisible(false); + item->setParentItem(originalParent); + } + + delete context; + delete incubator; +} + +QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view) +{ + QQuickStackElement *element = new QQuickStackElement; + element->component = new QQmlComponent(qmlEngine(view), QUrl(str), view); + element->ownComponent = true; + return element; +} + +QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackView *view) +{ + QQuickStackElement *element = new QQuickStackElement; + element->component = qobject_cast(object); + if (!element->component) { + element->component = new QQmlComponent(qmlEngine(view), view); + element->ownComponent = true; + } + element->item = qobject_cast(object); + if (element->item) { + element->originalParent = element->item->parentItem(); + element->item->setParentItem(view); + QQuickItemPrivate::get(element->item)->addItemChangeListener(element, QQuickItemPrivate::Destroyed); + } + return element; +} + +bool QQuickStackElement::load(QQuickStackView *parent) +{ + view = parent; + if (!item) { + ownItem = true; + + QQmlContext *creationContext = component->creationContext(); + if (!creationContext) + creationContext = qmlContext(parent); + context = new QQmlContext(creationContext); + context->setContextObject(parent); + + delete incubator; + incubator = new QQuickStackIncubator(this); + component->create(*incubator, context); + } + initProperties(); + return item; +} + +void QQuickStackElement::initItem(QObject *object) +{ + item = qmlobject_cast(object); + if (item) { + QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership); + QQuickItemPrivate *p = QQuickItemPrivate::get(item); + if (!p->widthValid) { + item->setWidth(view->width()); + p->widthValid = false; + } + if (!p->heightValid) { + item->setHeight(view->height()); + p->heightValid = false; + } + item->setParentItem(view); + p->addItemChangeListener(this, QQuickItemPrivate::Destroyed); + } + initProperties(); +} + +void QQuickStackElement::initProperties() +{ + if (!properties.isUndefined()) { + QQmlComponentPrivate *d = QQmlComponentPrivate::get(component); + Q_ASSERT(d && d->engine); + QV4::ExecutionEngine *v4 = qmlGlobal.engine(); + Q_ASSERT(v4); + QV4::Scope scope(v4); + QV4::ScopedValue ipv(scope, properties.value()); + d->initializeObjectWithInitialProperties(*qmlGlobal.valueRef(), ipv, item); + properties.clear(); + } +} + +void QQuickStackElement::setIndex(int value) +{ + if (index != value) { + index = value; + QQuickStackAttached *attached = attachedStackObject(item); + if (attached) + emit attached->indexChanged(); + } +} + +void QQuickStackElement::setStatus(QQuickStackView::Status value) +{ + if (status != value) { + status = value; + QQuickStackAttached *attached = attachedStackObject(item); + if (attached) + emit attached->statusChanged(); + } +} + +void QQuickStackElement::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget) +{ + if (transitioner) + transitioner->transitionNextReposition(this, type, asTarget); +} + +bool QQuickStackElement::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds) +{ + if (transitioner) { + // TODO: add force argument to QQuickItemViewTransitionableItem::prepareTransition()? + nextTransitionToSet = true; + nextTransitionFromSet = true; + nextTransitionFrom += QPointF(1, 1); + return QQuickItemViewTransitionableItem::prepareTransition(transitioner, index, viewBounds); + } + return false; +} + +void QQuickStackElement::startTransition(QQuickItemViewTransitioner *transitioner) +{ + if (transitioner) + QQuickItemViewTransitionableItem::startTransition(transitioner, index); +} + +void QQuickStackElement::itemDestroyed(QQuickItem *) +{ + item = Q_NULLPTR; +} + +QQuickStackViewPrivate::QQuickStackViewPrivate() : currentItem(Q_NULLPTR), transitioner(Q_NULLPTR) +{ +} + +void QQuickStackViewPrivate::setCurrentItem(QQuickItem *item) +{ + Q_Q(QQuickStackView); + if (currentItem != item) { + currentItem = item; + if (item) + item->setVisible(true); + emit q->currentItemChanged(); + } +} + +static bool initProperties(QQuickStackElement *element, const QV4::Value &props, QQmlV4Function *args) +{ + if (props.isObject()) { + const QV4::QObjectWrapper *wrapper = props.as(); + if (!wrapper) { + QV4::ExecutionEngine *v4 = args->v4engine(); + element->properties.set(v4, props); + element->qmlGlobal.set(v4, args->qmlGlobal()); + return true; + } + } + return false; +} + +QList QQuickStackViewPrivate::parseElements(QQmlV4Function *args, int from) +{ + QV4::ExecutionEngine *v4 = args->v4engine(); + QV4::Scope scope(v4); + + QList elements; + + int argc = args->length(); + for (int i = from; i < argc; ++i) { + QV4::ScopedValue arg(scope, (*args)[i]); + if (QV4::ArrayObject *array = arg->asArrayObject()) { + int len = array->getLength(); + for (int j = 0; j < len; ++j) { + QV4::ScopedValue value(scope, array->getIndexed(j)); + QQuickStackElement *element = createElement(value); + if (element) { + if (j < len - 1) { + QV4::ScopedValue props(scope, array->getIndexed(j + 1)); + if (initProperties(element, props, args)) + ++j; + } + elements += element; + } + } + } else { + QQuickStackElement *element = createElement(arg); + if (element) { + if (i < argc - 1) { + QV4::ScopedValue props(scope, (*args)[i + 1]); + if (initProperties(element, props, args)) + ++i; + } + elements += element; + } + } + } + return elements; +} + +QQuickStackElement *QQuickStackViewPrivate::findElement(QQuickItem *item) const +{ + if (item) { + foreach (QQuickStackElement *e, elements) { + if (e->item == item) + return e; + } + } + return Q_NULLPTR; +} + +QQuickStackElement *QQuickStackViewPrivate::findElement(const QV4::Value &value) const +{ + if (const QV4::QObjectWrapper *o = value.as()) + return findElement(qobject_cast(o->object())); + return Q_NULLPTR; +} + +QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value) +{ + Q_Q(QQuickStackView); + if (QV4::String *s = value.asString()) + return QQuickStackElement::fromString(s->toQString(), q); + if (const QV4::QObjectWrapper *o = value.as()) + return QQuickStackElement::fromObject(o->object(), q); + return Q_NULLPTR; +} + +bool QQuickStackViewPrivate::pushElements(const QList &elems) +{ + Q_Q(QQuickStackView); + if (!elems.isEmpty()) { + foreach (QQuickStackElement *e, elems) { + e->setIndex(elements.count()); + elements += e; + } + return elements.top()->load(q); + } + return false; +} + +bool QQuickStackViewPrivate::pushElement(QQuickStackElement *element) +{ + if (element) + return pushElements(QList() << element); + return false; +} + +bool QQuickStackViewPrivate::popElements(QQuickStackElement *element) +{ + Q_Q(QQuickStackView); + if (elements.count() > 1) { + while (elements.count() > 1 && elements.top() != element) { + delete elements.pop(); + if (!element) + break; + } + } + return elements.top()->load(q); +} + +bool QQuickStackViewPrivate::replaceElements(QQuickStackElement *target, const QList &elems) +{ + if (target) { + while (!elements.isEmpty()) { + QQuickStackElement* top = elements.pop(); + delete top; + if (top == target) + break; + } + } + return pushElements(elems); +} + +void QQuickStackViewPrivate::ensureTransitioner() +{ + if (!transitioner) { + transitioner = new QQuickItemViewTransitioner; + transitioner->setChangeListener(this); + } +} + +void QQuickStackViewPrivate::popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) +{ + Q_Q(QQuickStackView); + if (exit) { + exit->setStatus(QQuickStackView::Deactivating); + exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true); + } + if (enter) { + enter->setStatus(QQuickStackView::Activating); + enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false); + } + + if (exit && exit->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(exit, transitioner->removeTransition); + else + exit->startTransition(transitioner); + } + if (enter && enter->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(enter, transitioner->removeDisplacedTransition); + else + enter->startTransition(transitioner); + } + + if (!immediate) + emit q->busyChanged(); + + if (transitioner) + transitioner->resetTargetLists(); +} + +void QQuickStackViewPrivate::pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) +{ + Q_Q(QQuickStackView); + if (enter) { + enter->setStatus(QQuickStackView::Activating); + enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + } + if (exit) { + exit->setStatus(QQuickStackView::Deactivating); + exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); + } + + if (enter && enter->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(enter, transitioner->addTransition); + else + enter->startTransition(transitioner); + } + if (exit && exit->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(exit, transitioner->addDisplacedTransition); + else + exit->startTransition(transitioner); + } + + if (!immediate) + emit q->busyChanged(); + + if (transitioner) + transitioner->resetTargetLists(); +} + +void QQuickStackViewPrivate::replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate) +{ + Q_Q(QQuickStackView); + if (enter) { + enter->setStatus(QQuickStackView::Activating); + enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true); + } + if (exit) { + exit->removal = true; + exit->setStatus(QQuickStackView::Deactivating); + exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false); + } + + if (enter && enter->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(enter, transitioner->addTransition); + else + enter->startTransition(transitioner); + } + if (exit && exit->prepareTransition(transitioner, viewBounds)) { + if (immediate) + completeTransition(exit, transitioner->addDisplacedTransition); + else + exit->startTransition(transitioner); + } + + if (!immediate) + emit q->busyChanged(); + + if (transitioner) + transitioner->resetTargetLists(); +} + +void QQuickStackViewPrivate::completeTransition(QQuickStackElement *element, QQuickTransition *transition) +{ + if (transition) { + // TODO: add a proper way to complete a transition + QQmlListProperty animations = transition->animations(); + int count = animations.count(&animations); + for (int i = 0; i < count; ++i) { + QQuickAbstractAnimation *anim = animations.at(&animations, i); + anim->complete(); + } + viewItemTransitionFinished(element); + } +} + +void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransitionableItem *transitionable) +{ + Q_Q(QQuickStackView); + + QQuickStackElement *element = static_cast(transitionable); + if (element->status == QQuickStackView::Activating) { + element->setStatus(QQuickStackView::Active); + } else if (element->status == QQuickStackView::Deactivating) { + element->setStatus(QQuickStackView::Inactive); + element->item->setVisible(false); + if (element->removal || element->isPendingRemoval()) + delete element; + } + + if (transitioner->runningJobs.isEmpty()) + emit q->busyChanged(); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickstackview_p.h b/src/controls/qquickstackview_p.h new file mode 100644 index 00000000..377af3c8 --- /dev/null +++ b/src/controls/qquickstackview_p.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** 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 QQUICKSTACKVIEW_P_H +#define QQUICKSTACKVIEW_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 + +QT_BEGIN_NAMESPACE + +class QQmlV4Function; +class QQuickTransition; +class QQuickStackElement; +class QQuickStackAttached; +class QQuickStackViewPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickStackView : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(bool busy READ busy NOTIFY busyChanged FINAL) + Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL) + Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL) + Q_PROPERTY(QVariant initialItem READ initialItem WRITE setInitialItem FINAL) + Q_PROPERTY(QQuickTransition *popEnter READ popEnter WRITE setPopEnter NOTIFY popEnterChanged FINAL) + Q_PROPERTY(QQuickTransition *popExit READ popExit WRITE setPopExit NOTIFY popExitChanged FINAL) + Q_PROPERTY(QQuickTransition *pushEnter READ pushEnter WRITE setPushEnter NOTIFY pushEnterChanged FINAL) + Q_PROPERTY(QQuickTransition *pushExit READ pushExit WRITE setPushExit NOTIFY pushExitChanged FINAL) + +public: + explicit QQuickStackView(QQuickItem *parent = Q_NULLPTR); + ~QQuickStackView(); + + static QQuickStackAttached *qmlAttachedProperties(QObject *object); + + bool busy() const; + int depth() const; + QQuickItem *currentItem() const; + + enum Status { + Inactive = 0, + Deactivating = 1, + Activating = 2, + Active = 3 + }; + Q_ENUM(Status) + + QVariant initialItem() const; + void setInitialItem(const QVariant &item); + + QQuickTransition *popEnter() const; + void setPopEnter(QQuickTransition *enter); + + QQuickTransition *popExit() const; + void setPopExit(QQuickTransition *exit); + + QQuickTransition *pushEnter() const; + void setPushEnter(QQuickTransition *enter); + + QQuickTransition *pushExit() const; + void setPushExit(QQuickTransition *exit); + + enum LoadBehavior { + DontLoad, + ForceLoad + }; + Q_ENUM(LoadBehavior) + + Q_INVOKABLE QQuickItem *get(int index, LoadBehavior behavior = DontLoad); + Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad); + + enum Operation { + Transition, + Immediate + }; + Q_ENUM(Operation) + + Q_INVOKABLE void push(QQmlV4Function *args); + Q_INVOKABLE void pop(QQmlV4Function *args); + Q_INVOKABLE void replace(QQmlV4Function *args); + +public Q_SLOTS: + void clear(); + +Q_SIGNALS: + void busyChanged(); + void depthChanged(); + void currentItemChanged(); + void popEnterChanged(); + void popExitChanged(); + void pushEnterChanged(); + void pushExitChanged(); + +protected: + void componentComplete() Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickStackView) + Q_DECLARE_PRIVATE(QQuickStackView) +}; + +class QQuickStackAttachedPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickStackAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) + Q_PROPERTY(QQuickStackView::Status status READ status NOTIFY statusChanged FINAL) + +public: + explicit QQuickStackAttached(QQuickItem *parent = Q_NULLPTR); + + int index() const; + QQuickStackView::Status status() const; + +Q_SIGNALS: + void indexChanged(); + void statusChanged(); + +private: + Q_DISABLE_COPY(QQuickStackAttached) + Q_DECLARE_PRIVATE(QQuickStackAttached) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQuickStackView, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QQuickStackView) + +#endif // QQUICKSTACKVIEW_P_H diff --git a/src/controls/qquickstackview_p_p.h b/src/controls/qquickstackview_p_p.h new file mode 100644 index 00000000..6a07e972 --- /dev/null +++ b/src/controls/qquickstackview_p_p.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** 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 QQUICKSTACKVIEW_P_P_H +#define QQUICKSTACKVIEW_P_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 +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlContext; +class QQmlComponent; +class QQmlIncubator; + +class QQuickStackElement : public QQuickItemViewTransitionableItem, public QQuickItemChangeListener +{ + QQuickStackElement(); + +public: + ~QQuickStackElement(); + + static QQuickStackElement *fromString(const QString &str, QQuickStackView *view); + static QQuickStackElement *fromObject(QObject *object, QQuickStackView *view); + + bool load(QQuickStackView *parent); + void initItem(QObject *object); + void initProperties(); + + void setIndex(int index); + void setStatus(QQuickStackView::Status status); + + void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget); + bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds); + void startTransition(QQuickItemViewTransitioner *transitioner); + + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; + + int index; + bool removal; + bool ownItem; + bool ownComponent; + QQmlContext *context; + QQmlComponent *component; + QQmlIncubator *incubator; + QQuickStackView *view; + QPointer originalParent; + QQuickStackView::Status status; + QV4::PersistentValue properties; + QV4::PersistentValue qmlGlobal; +}; + +class QQuickStackViewPrivate : public QQuickContainerPrivate, public QQuickItemViewTransitionChangeListener +{ + Q_DECLARE_PUBLIC(QQuickStackView) + +public: + QQuickStackViewPrivate(); + + static QQuickStackViewPrivate *get(QQuickStackView *view) + { + return view->d_func(); + } + + void setCurrentItem(QQuickItem *item); + + QList parseElements(QQmlV4Function *args, int from = 0); + QQuickStackElement *findElement(QQuickItem *item) const; + QQuickStackElement *findElement(const QV4::Value &value) const; + QQuickStackElement *createElement(const QV4::Value &value); + bool pushElements(const QList &elements); + bool pushElement(QQuickStackElement *element); + bool popElements(QQuickStackElement *element); + bool replaceElements(QQuickStackElement *element, const QList &elements); + + void ensureTransitioner(); + void popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); + void pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); + void replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate); + void completeTransition(QQuickStackElement *element, QQuickTransition *transition); + + void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) Q_DECL_OVERRIDE; + + QVariant initialItem; + QQuickItem *currentItem; + QStack elements; + QQuickItemViewTransitioner *transitioner; +}; + +class QQuickStackAttachedPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQuickStackAttached) + +public: + QQuickStackAttachedPrivate() : initialized(false), element(Q_NULLPTR) { } + + static QQuickStackAttachedPrivate *get(QQuickStackAttached *attached) + { + return attached->d_func(); + } + + void init(); + void reset(); + + bool initialized; + QQuickStackElement *element; +}; + +QT_END_NAMESPACE + +#endif // QQUICKSTACKVIEW_P_P_H diff --git a/src/controls/qquickswitch.cpp b/src/controls/qquickswitch.cpp new file mode 100644 index 00000000..8f970c9b --- /dev/null +++ b/src/controls/qquickswitch.cpp @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** 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 "qquickswitch_p.h" +#include "qquickcheckable_p_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Switch + \inherits Checkable + \instantiates QQuickSwitch + \inqmlmodule QtQuick.Controls + \ingroup buttons + \brief A switch control. + + TODO +*/ + +class QQuickSwitchPrivate : public QQuickCheckablePrivate +{ + Q_DECLARE_PUBLIC(QQuickSwitch) + +public: + QQuickSwitchPrivate() : position(0) { } + + void updatePosition(); + + qreal position; + QPoint pressPoint; +}; + +void QQuickSwitchPrivate::updatePosition() +{ + Q_Q(QQuickSwitch); + q->setPosition(checked ? 1.0 : 0.0); +} + +QQuickSwitch::QQuickSwitch(QQuickItem *parent) : + QQuickCheckable(*(new QQuickSwitchPrivate), parent) +{ + setFiltersChildMouseEvents(true); + QObjectPrivate::connect(this, &QQuickCheckable::checkedChanged, d_func(), &QQuickSwitchPrivate::updatePosition); +} + +/*! + \qmlproperty real QtQuickControls2::Switch::position + + TODO +*/ +qreal QQuickSwitch::position() const +{ + Q_D(const QQuickSwitch); + return d->position; +} + +void QQuickSwitch::setPosition(qreal position) +{ + Q_D(QQuickSwitch); + position = qBound(0.0, position, 1.0); + if (d->position != position) { + d->position = position; + emit positionChanged(); + emit visualPositionChanged(); + } +} + +/*! + \qmlproperty real QtQuickControls2::Switch::visualPosition + + TODO +*/ +qreal QQuickSwitch::visualPosition() const +{ + Q_D(const QQuickSwitch); + if (isMirrored()) + return 1.0 - d->position; + return d->position; +} + +void QQuickSwitch::mirrorChange() +{ + QQuickCheckable::mirrorChange(); + emit visualPositionChanged(); +} + +bool QQuickSwitch::childMouseEventFilter(QQuickItem *child, QEvent *event) +{ + if (child == indicator()) { + switch (event->type()) { + case QEvent::MouseButtonPress: + return handleMousePressEvent(child, static_cast(event)); + case QEvent::MouseMove: + return handleMouseMoveEvent(child, static_cast(event)); + case QEvent::MouseButtonRelease: + return handleMouseReleaseEvent(child, static_cast(event)); + case QEvent::UngrabMouse: + return handleMouseUngrabEvent(child); + default: + return false; + } + } + return false; +} + +bool QQuickSwitch::handleMousePressEvent(QQuickItem *child, QMouseEvent *event) +{ + Q_D(QQuickSwitch); + Q_UNUSED(child); + d->pressPoint = event->pos(); + setPressed(true); + event->accept(); + return true; +} + +bool QQuickSwitch::handleMouseMoveEvent(QQuickItem *child, QMouseEvent *event) +{ + Q_D(QQuickSwitch); + if (!child->keepMouseGrab()) + child->setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().x() - d->pressPoint.x(), Qt::XAxis, event)); + if (child->keepMouseGrab()) { + setPosition(positionAt(event->pos())); + event->accept(); + } + return true; +} + +bool QQuickSwitch::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event) +{ + Q_D(QQuickSwitch); + d->pressPoint = QPoint(); + setPressed(false); + if (child->keepMouseGrab()) { + setChecked(position() > 0.5); + setPosition(isChecked() ? 1.0 : 0.0); + child->setKeepMouseGrab(false); + } else { + emit clicked(); + toggle(); + } + event->accept(); + return true; +} + +bool QQuickSwitch::handleMouseUngrabEvent(QQuickItem *child) +{ + Q_D(QQuickSwitch); + Q_UNUSED(child); + d->pressPoint = QPoint(); + setChecked(position() > 0.5); + setPosition(isChecked() ? 1.0 : 0.0); + setPressed(false); + return true; +} + +qreal QQuickSwitch::positionAt(const QPoint &point) const +{ + qreal pos = point.x() / indicator()->width(); + if (isMirrored()) + return 1.0 - pos; + return pos; +} + +QT_END_NAMESPACE diff --git a/src/controls/qquickswitch_p.h b/src/controls/qquickswitch_p.h new file mode 100644 index 00000000..9c930967 --- /dev/null +++ b/src/controls/qquickswitch_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 QQUICKSWITCH_P_H +#define QQUICKSWITCH_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 + +QT_BEGIN_NAMESPACE + +class QQuickSwitchPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickSwitch : public QQuickCheckable +{ + Q_OBJECT + Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL) + Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) + +public: + explicit QQuickSwitch(QQuickItem *parent = Q_NULLPTR); + + qreal position() const; + void setPosition(qreal position); + + qreal visualPosition() const; + +Q_SIGNALS: + void positionChanged(); + void visualPositionChanged(); + +protected: + void mirrorChange() Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE; + + bool handleMousePressEvent(QQuickItem *child, QMouseEvent *event); + bool handleMouseMoveEvent(QQuickItem *child, QMouseEvent *event); + bool handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event); + bool handleMouseUngrabEvent(QQuickItem *child); + + virtual qreal positionAt(const QPoint &point) const; + +private: + Q_DISABLE_COPY(QQuickSwitch) + Q_DECLARE_PRIVATE(QQuickSwitch) +}; + +QT_END_NAMESPACE + +#endif // QQUICKSWITCH_P_H diff --git a/src/controls/qquicktabbar.cpp b/src/controls/qquicktabbar.cpp new file mode 100644 index 00000000..340c2701 --- /dev/null +++ b/src/controls/qquicktabbar.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 "qquicktabbar_p.h" +#include "qquickcontainer_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype TabBar + \inherits Container + \instantiates QQuickTabBar + \inqmlmodule QtQuick.Controls + \ingroup tabs + \brief A tab bar control. + + TODO +*/ + +class QQuickTabBarPrivate : public QQuickContainerPrivate +{ +public: + QQuickTabBarPrivate() : currentIndex(0) { } + + int currentIndex; +}; + +QQuickTabBar::QQuickTabBar(QQuickItem *parent) : + QQuickContainer(*(new QQuickTabBarPrivate), parent) +{ + setFlag(ItemIsFocusScope); + setActiveFocusOnTab(true); +} + +/*! + \qmlproperty int QtQuickControls2::TabBar::currentIndex + + TODO +*/ +int QQuickTabBar::currentIndex() const +{ + Q_D(const QQuickTabBar); + return d->currentIndex; +} + +void QQuickTabBar::setCurrentIndex(int index) +{ + Q_D(QQuickTabBar); + if (d->currentIndex != index) { + d->currentIndex = index; + emit currentIndexChanged(index); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktabbar_p.h b/src/controls/qquicktabbar_p.h new file mode 100644 index 00000000..aee165a9 --- /dev/null +++ b/src/controls/qquicktabbar_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 QQUICKTABBAR_P_H +#define QQUICKTABBAR_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 + +QT_BEGIN_NAMESPACE + +class QQuickTabBarPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickTabBar : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) + +public: + explicit QQuickTabBar(QQuickItem *parent = Q_NULLPTR); + + int currentIndex() const; + +public Q_SLOTS: + void setCurrentIndex(int index); + +Q_SIGNALS: + void currentIndexChanged(int index); + +private: + Q_DISABLE_COPY(QQuickTabBar) + Q_DECLARE_PRIVATE(QQuickTabBar) + friend class QQuickTabView; +}; + +QT_END_NAMESPACE + +#endif // QQUICKTABBAR_P_H diff --git a/src/controls/qquicktabbutton.cpp b/src/controls/qquicktabbutton.cpp new file mode 100644 index 00000000..62a556af --- /dev/null +++ b/src/controls/qquicktabbutton.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 "qquicktabbutton_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype TabButton + \inherits Checkable + \instantiates QQuickTabButton + \inqmlmodule QtQuick.Controls + \ingroup tabs + \brief A tab button control. + + TODO +*/ + +QQuickTabButton::QQuickTabButton(QQuickItem *parent) : + QQuickCheckable(parent) +{ + setExclusive(true); +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktabbutton_p.h b/src/controls/qquicktabbutton_p.h new file mode 100644 index 00000000..e62d8f63 --- /dev/null +++ b/src/controls/qquicktabbutton_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKTABBUTTON_P_H +#define QQUICKTABBUTTON_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickTabButton : public QQuickCheckable +{ + Q_OBJECT + +public: + explicit QQuickTabButton(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKTABBUTTON_P_H diff --git a/src/controls/qquicktabview.cpp b/src/controls/qquicktabview.cpp new file mode 100644 index 00000000..3a79a725 --- /dev/null +++ b/src/controls/qquicktabview.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** 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 "qquicktabview_p.h" +#include "qquicktabbar_p.h" +#include "qquickcontainer_p_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype TabView + \inherits Container + \instantiates QQuickTabView + \inqmlmodule QtQuick.Controls + \ingroup tabs + \brief A tab view control. + + TODO +*/ + +class QQuickTabViewPrivate : public QQuickContainerPrivate +{ +public: + QQuickTabViewPrivate() : currentIndex(0), bar(Q_NULLPTR) { } + + int currentIndex; + QQuickTabBar *bar; +}; + +QQuickTabView::QQuickTabView(QQuickItem *parent) : + QQuickContainer(*(new QQuickTabViewPrivate), parent) +{ + setFlag(ItemIsFocusScope); + setActiveFocusOnTab(true); +} + +/*! + \qmlproperty int QtQuickControls2::TabView::currentIndex + + TODO +*/ +int QQuickTabView::currentIndex() const +{ + Q_D(const QQuickTabView); + return d->currentIndex; +} + +void QQuickTabView::setCurrentIndex(int index) +{ + Q_D(QQuickTabView); + if (d->currentIndex != index) { + d->currentIndex = index; + emit currentIndexChanged(index); + } +} + +/*! + \qmlproperty TabBar QtQuickControls2::TabView::tabBar + + TODO +*/ +QQuickTabBar *QQuickTabView::tabBar() const +{ + Q_D(const QQuickTabView); + return d->bar; +} + +void QQuickTabView::setTabBar(QQuickTabBar *bar) +{ + Q_D(QQuickTabView); + if (d->bar != bar) { + if (d->bar) { + disconnect(this, &QQuickTabView::currentIndexChanged, d->bar, &QQuickTabBar::setCurrentIndex); + disconnect(d->bar, &QQuickTabBar::currentIndexChanged, this, &QQuickTabView::setCurrentIndex); + if (d->bar->parentItem() == this) + delete d->bar; + } + d->bar = bar; + if (bar) { + connect(this, &QQuickTabView::currentIndexChanged, d->bar, &QQuickTabBar::setCurrentIndex); + connect(bar, &QQuickTabBar::currentIndexChanged, this, &QQuickTabView::setCurrentIndex); + if (!bar->parentItem()) + bar->setParentItem(this); + + int barIndex = bar->currentIndex(); + if (d->currentIndex != barIndex) { + if (d->currentIndex != -1) + bar->setCurrentIndex(d->currentIndex); + else if (barIndex != -1) + setCurrentIndex(barIndex); + } + } + emit tabBarChanged(); + } +} + +void QQuickTabView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickTabView); + QQuickControl::geometryChanged(newGeometry, oldGeometry); + if (d->bar) { + QQuickItemPrivate *p = QQuickItemPrivate::get(d->bar); + if (!p->widthValid) { + d->bar->setWidth(newGeometry.width()); + p->widthValid = false; + } + } +} + +/*! + \qmltype Tab + \inherits QtObject + \instantiates QQuickTabAttached + \inqmlmodule QtQuick.Controls + \ingroup tabs + \brief TODO + + TODO +*/ + +QQuickTabAttached::QQuickTabAttached(QObject *parent) : + QObject(parent), m_index(-1), m_visible(true), m_view(Q_NULLPTR) +{ +} + +QQuickTabAttached *QQuickTabAttached::qmlAttachedProperties(QObject *object) +{ + return new QQuickTabAttached(object); +} + +/*! + \qmlattachedproperty int QtQuickControls2::Tab::index + + TODO +*/ +int QQuickTabAttached::index() const +{ + return m_index; +} + +void QQuickTabAttached::setIndex(int index) +{ + if (m_index != index) { + m_index = index; + emit indexChanged(); + } +} + +/*! + \qmlattachedproperty string QtQuickControls2::Tab::title + + TODO +*/ +QString QQuickTabAttached::title() const +{ + return m_title; +} + +void QQuickTabAttached::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + emit titleChanged(); + } +} + +/*! + \qmlattachedproperty bool QtQuickControls2::Tab::visible + + TODO +*/ +bool QQuickTabAttached::isVisible() const +{ + return m_visible; +} + +void QQuickTabAttached::setVisible(bool visible) +{ + if (m_visible != visible) { + m_visible = visible; + emit visibleChanged(); + } +} + +/*! + \qmlattachedproperty TabView QtQuickControls2::Tab::view + + TODO +*/ +QQuickTabView *QQuickTabAttached::view() const +{ + return m_view; +} + +void QQuickTabAttached::setView(QQuickTabView *view) +{ + if (m_view != view) { + m_view = view; + emit viewChanged(); + } +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktabview_p.h b/src/controls/qquicktabview_p.h new file mode 100644 index 00000000..2b2b00b2 --- /dev/null +++ b/src/controls/qquicktabview_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** 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 QQUICKTABVIEW_P_H +#define QQUICKTABVIEW_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 + +QT_BEGIN_NAMESPACE + +class QQuickTabBar; +class QQuickTabViewPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickTabView : public QQuickContainer +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) + Q_PROPERTY(QQuickTabBar *tabBar READ tabBar WRITE setTabBar NOTIFY tabBarChanged FINAL) + +public: + explicit QQuickTabView(QQuickItem *parent = Q_NULLPTR); + + int currentIndex() const; + + QQuickTabBar *tabBar() const; + void setTabBar(QQuickTabBar *bar); + +public Q_SLOTS: + void setCurrentIndex(int index); + +Q_SIGNALS: + void currentIndexChanged(int index); + void tabBarChanged(); + +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickTabView) + Q_DECLARE_PRIVATE(QQuickTabView) +}; + +class Q_QUICKCONTROLS_EXPORT QQuickTabAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) + Q_PROPERTY(QQuickTabView *view READ view WRITE setView NOTIFY viewChanged FINAL) + +public: + explicit QQuickTabAttached(QObject *parent = Q_NULLPTR); + + static QQuickTabAttached *qmlAttachedProperties(QObject *object); + + int index() const; + void setIndex(int index); + + QString title() const; + void setTitle(const QString &title); + + bool isVisible() const; + void setVisible(bool visible); + + QQuickTabView *view() const; + void setView(QQuickTabView *view); + +Q_SIGNALS: + void indexChanged(); + void titleChanged(); + void visibleChanged(); + void viewChanged(); + +private: + int m_index; + bool m_visible; + QString m_title; + QQuickTabView *m_view; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQuickTabAttached, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQUICKTABVIEW_P_H diff --git a/src/controls/qquicktextarea.cpp b/src/controls/qquicktextarea.cpp new file mode 100644 index 00000000..92c2d268 --- /dev/null +++ b/src/controls/qquicktextarea.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** 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 "qquicktextarea_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickTextAreaPrivate +{ + Q_DECLARE_PUBLIC(QQuickTextArea) + +public: + QQuickTextAreaPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { } + + QQuickItem *background; + QQuickText *placeholder; + QQuickTextArea *q_ptr; +}; + +QQuickTextArea::QQuickTextArea(QQuickItem *parent) : + QQuickTextEdit(parent), d_ptr(new QQuickTextAreaPrivate) +{ + Q_D(QQuickTextArea); + d->q_ptr = this; +} + +QQuickTextArea::~QQuickTextArea() +{ +} + +QQuickItem *QQuickTextArea::background() const +{ + Q_D(const QQuickTextArea); + return d->background; +} + +void QQuickTextArea::setBackground(QQuickItem *background) +{ + Q_D(QQuickTextArea); + if (d->background != background) { + delete d->background; + d->background = background; + if (background) { + background->setParentItem(this); + if (qFuzzyIsNull(background->z())) + background->setZ(-1); + } + emit backgroundChanged(); + } +} + +QQuickText *QQuickTextArea::placeholder() const +{ + Q_D(const QQuickTextArea); + return d->placeholder; +} + +void QQuickTextArea::setPlaceholder(QQuickText *placeholder) +{ + Q_D(QQuickTextArea); + if (d->placeholder != placeholder) { + delete d->placeholder; + d->placeholder = placeholder; + if (placeholder && !placeholder->parentItem()) + placeholder->setParentItem(this); + emit placeholderChanged(); + } +} + +void QQuickTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickTextArea); + QQuickTextEdit::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; + } + } +} + +QSGNode *QQuickTextArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) +{ + QQuickDefaultClipNode *clipNode = static_cast(oldNode); + if (!clipNode) + clipNode = new QQuickDefaultClipNode(QRectF()); + + clipNode->setRect(clipRect().adjusted(leftPadding(), topPadding(), -rightPadding(), -bottomPadding())); + clipNode->update(); + + QSGNode *textNode = QQuickTextEdit::updatePaintNode(clipNode->firstChild(), data); + if (!textNode->parent()) + clipNode->appendChildNode(textNode); + + return clipNode; +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktextarea_p.h b/src/controls/qquicktextarea_p.h new file mode 100644 index 00000000..ee51525b --- /dev/null +++ b/src/controls/qquicktextarea_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 QQUICKTEXTAREA_P_H +#define QQUICKTEXTAREA_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickText; +class QQuickTextAreaPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickTextArea : public QQuickTextEdit +{ + Q_OBJECT + Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) + Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) + +public: + explicit QQuickTextArea(QQuickItem *parent = Q_NULLPTR); + ~QQuickTextArea(); + + QQuickItem *background() const; + void setBackground(QQuickItem *background); + + QQuickText *placeholder() const; + void setPlaceholder(QQuickText *placeholder); + +Q_SIGNALS: + void backgroundChanged(); + void placeholderChanged(); + +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickTextArea) + Q_DECLARE_PRIVATE(QQuickTextArea) + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QQUICKTEXTAREA_P_H diff --git a/src/controls/qquicktextfield.cpp b/src/controls/qquicktextfield.cpp new file mode 100644 index 00000000..0d85fa05 --- /dev/null +++ b/src/controls/qquicktextfield.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** 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 "qquicktextfield_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickTextFieldPrivate +{ + Q_DECLARE_PUBLIC(QQuickTextField) + +public: + QQuickTextFieldPrivate() : background(Q_NULLPTR), placeholder(Q_NULLPTR) { } + + QQuickItem *background; + QQuickText *placeholder; + QQuickTextField *q_ptr; +}; + +QQuickTextField::QQuickTextField(QQuickItem *parent) : + QQuickTextInput(parent), d_ptr(new QQuickTextFieldPrivate) +{ + Q_D(QQuickTextField); + d->q_ptr = this; +} + +QQuickTextField::~QQuickTextField() +{ +} + +QQuickItem *QQuickTextField::background() const +{ + Q_D(const QQuickTextField); + return d->background; +} + +void QQuickTextField::setBackground(QQuickItem *background) +{ + Q_D(QQuickTextField); + if (d->background != background) { + delete d->background; + d->background = background; + if (background) { + background->setParentItem(this); + if (qFuzzyIsNull(background->z())) + background->setZ(-1); + } + emit backgroundChanged(); + } +} + +QQuickText *QQuickTextField::placeholder() const +{ + Q_D(const QQuickTextField); + return d->placeholder; +} + +void QQuickTextField::setPlaceholder(QQuickText *placeholder) +{ + Q_D(QQuickTextField); + if (d->placeholder != placeholder) { + delete d->placeholder; + d->placeholder = placeholder; + if (placeholder && !placeholder->parentItem()) + placeholder->setParentItem(this); + emit placeholderChanged(); + } +} + +void QQuickTextField::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickTextField); + QQuickTextInput::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; + } + } +} + +QSGNode *QQuickTextField::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) +{ + QQuickDefaultClipNode *clipNode = static_cast(oldNode); + if (!clipNode) + clipNode = new QQuickDefaultClipNode(QRectF()); + + clipNode->setRect(clipRect().adjusted(leftPadding(), topPadding(), -rightPadding(), -bottomPadding())); + clipNode->update(); + + QSGNode *textNode = QQuickTextInput::updatePaintNode(clipNode->firstChild(), data); + if (!textNode->parent()) + clipNode->appendChildNode(textNode); + + return clipNode; +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktextfield_p.h b/src/controls/qquicktextfield_p.h new file mode 100644 index 00000000..899e9054 --- /dev/null +++ b/src/controls/qquicktextfield_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 QQUICKTEXTFIELD_P_H +#define QQUICKTEXTFIELD_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickText; +class QQuickTextFieldPrivate; + +class Q_QUICKCONTROLS_EXPORT QQuickTextField : public QQuickTextInput +{ + Q_OBJECT + Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) + Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) + +public: + explicit QQuickTextField(QQuickItem *parent = Q_NULLPTR); + ~QQuickTextField(); + + QQuickItem *background() const; + void setBackground(QQuickItem *background); + + QQuickText *placeholder() const; + void setPlaceholder(QQuickText *placeholder); + +Q_SIGNALS: + void backgroundChanged(); + void placeholderChanged(); + +protected: + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickTextField) + Q_DECLARE_PRIVATE(QQuickTextField) + QScopedPointer d_ptr; +}; + +QT_END_NAMESPACE + +#endif // QQUICKTEXTFIELD_P_H diff --git a/src/controls/qquicktogglebutton.cpp b/src/controls/qquicktogglebutton.cpp new file mode 100644 index 00000000..40ea2e02 --- /dev/null +++ b/src/controls/qquicktogglebutton.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 "qquicktogglebutton_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ToggleButton + \inherits Checkable + \instantiates QQuickToggleButton + \inqmlmodule QtQuick.Controls + \ingroup buttons + \brief A toggle button control. + + TODO +*/ + +QQuickToggleButton::QQuickToggleButton(QQuickItem *parent) : + QQuickSwitch(parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktogglebutton_p.h b/src/controls/qquicktogglebutton_p.h new file mode 100644 index 00000000..a315033e --- /dev/null +++ b/src/controls/qquicktogglebutton_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKTOGGLEBUTTON_P_H +#define QQUICKTOGGLEBUTTON_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickToggleButton : public QQuickSwitch +{ + Q_OBJECT + +public: + explicit QQuickToggleButton(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKTOGGLEBUTTON_P_H diff --git a/src/controls/qquicktoolbar.cpp b/src/controls/qquicktoolbar.cpp new file mode 100644 index 00000000..90959ba9 --- /dev/null +++ b/src/controls/qquicktoolbar.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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 "qquicktoolbar_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype ToolBar + \inherits Container + \instantiates QQuickToolBar + \inqmlmodule QtQuick.Controls + \ingroup containers + \brief A tool bar control. + + TODO +*/ + +QQuickToolBar::QQuickToolBar(QQuickItem *parent) : + QQuickContainer(parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/controls/qquicktoolbar_p.h b/src/controls/qquicktoolbar_p.h new file mode 100644 index 00000000..50352186 --- /dev/null +++ b/src/controls/qquicktoolbar_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QQUICKTOOLBAR_P_H +#define QQUICKTOOLBAR_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 + +QT_BEGIN_NAMESPACE + +class Q_QUICKCONTROLS_EXPORT QQuickToolBar : public QQuickContainer +{ + Q_OBJECT + +public: + explicit QQuickToolBar(QQuickItem *parent = Q_NULLPTR); +}; + +QT_END_NAMESPACE + +#endif // QQUICKTOOLBAR_P_H diff --git a/src/extras/extras.pri b/src/extras/extras.pri index 6d82cdd0..c8cfeba4 100644 --- a/src/extras/extras.pri +++ b/src/extras/extras.pri @@ -1,7 +1,7 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qquickabstractdrawer_p.h + $$PWD/qquickdrawer_p.h SOURCES += \ - $$PWD/qquickabstractdrawer.cpp + $$PWD/qquickdrawer.cpp diff --git a/src/extras/qquickabstractdrawer.cpp b/src/extras/qquickabstractdrawer.cpp deleted file mode 100644 index d25a7f0d..00000000 --- a/src/extras/qquickabstractdrawer.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Extras 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 "qquickabstractdrawer_p.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QQuickAbstractDrawerPrivate : public QQuickControlPrivate -{ - Q_DECLARE_PUBLIC(QQuickAbstractDrawer) - -public: - QQuickAbstractDrawerPrivate() : edge(Qt::LeftEdge), offset(0), position(0), - content(Q_NULLPTR), animation(Q_NULLPTR) { } - - void updateContent(); - bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event); - bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event); - bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event); - - Qt::Edge edge; - qreal offset; - qreal position; - QPointF pressPoint; - QQuickItem *content; - QQuickPropertyAnimation *animation; -}; - -void QQuickAbstractDrawerPrivate::updateContent() -{ - Q_Q(QQuickAbstractDrawer); - if (!content) - return; - - switch (edge) { - case Qt::LeftEdge: - content->setX((position - 1.0) * content->width()); - break; - case Qt::RightEdge: - content->setX(q->width() + - position * content->width()); - break; - case Qt::TopEdge: - content->setY((position - 1.0) * content->height()); - break; - case Qt::BottomEdge: - content->setY(q->height() + - position * content->height()); - break; - } -} - -bool QQuickAbstractDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event) -{ - Q_Q(QQuickAbstractDrawer); - pressPoint = q->mapFromItem(item, event->pos()); - - if (qFuzzyIsNull(position)) { - // only accept pressing at drag margins when fully closed - switch (edge) { - case Qt::LeftEdge: - event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(event->x(), Qt::XAxis, event)); - break; - case Qt::RightEdge: - event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(q->width() - event->x(), Qt::XAxis, event)); - break; - case Qt::TopEdge: - event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(event->y(), Qt::YAxis, event)); - break; - case Qt::BottomEdge: - event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(q->height() - event->y(), Qt::YAxis, event)); - break; - } - offset = 0; - } else { - event->accept(); - offset = q->positionAt(pressPoint) - position; - } - - return item == q; -} - -bool QQuickAbstractDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event) -{ - Q_Q(QQuickAbstractDrawer); - QPointF movePoint = q->mapFromItem(item, event->pos()); - - if (!q->keepMouseGrab()) { - bool overThreshold = false; - if (edge == Qt::LeftEdge || edge == Qt::RightEdge) - overThreshold = QQuickWindowPrivate::dragOverThreshold(movePoint.x() - pressPoint.x(), Qt::XAxis, event); - else - overThreshold = QQuickWindowPrivate::dragOverThreshold(movePoint.y() - pressPoint.y(), Qt::YAxis, event); - - if (window && overThreshold) { - QQuickItem *grabber = q->window()->mouseGrabberItem(); - if (!grabber || !grabber->keepMouseGrab()) { - q->grabMouse(); - q->setKeepMouseGrab(overThreshold); - } - } - } - - if (q->keepMouseGrab()) - q->setPosition(q->positionAt(event->pos()) - offset); - event->accept(); - - return q->keepMouseGrab(); -} - -bool QQuickAbstractDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event) -{ - Q_Q(QQuickAbstractDrawer); - bool wasGrabbed = q->keepMouseGrab(); - if (wasGrabbed) { -// int startDragVelocity = QGuiApplication::styleHints()->startDragVelocity(); -// if (startDragVelocity && QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity) { -// QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event); -// qreal vel = (edge == Qt::LeftEdge || edge == Qt::RightEdge) ? velocity.x() : velocity.y(); -// qDebug() << vel << "vs." << startDragVelocity; -// } - if (position < 0.3) { - q->close(); - } else if (position > 0.7) { - q->open(); - } else { - switch (edge) { - case Qt::LeftEdge: - if (event->x() - pressPoint.x() > 0) - q->open(); - else - q->close(); - break; - case Qt::RightEdge: - if (event->x() - pressPoint.x() < 0) - q->open(); - else - q->close(); - break; - case Qt::TopEdge: - if (event->y() - pressPoint.y() > 0) - q->open(); - else - q->close(); - break; - case Qt::BottomEdge: - if (event->y() - pressPoint.y() < 0) - q->open(); - else - q->close(); - break; - } - } - q->setKeepMouseGrab(false); - } else { - if (item == q) - emit q->clicked(); - } - pressPoint = QPoint(); - event->accept(); - return wasGrabbed; -} - -QQuickAbstractDrawer::QQuickAbstractDrawer(QQuickItem *parent) : - QQuickControl(*(new QQuickAbstractDrawerPrivate), parent) -{ - setZ(1); - setFiltersChildMouseEvents(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -Qt::Edge QQuickAbstractDrawer::edge() const -{ - Q_D(const QQuickAbstractDrawer); - return d->edge; -} - -void QQuickAbstractDrawer::setEdge(Qt::Edge edge) -{ - Q_D(QQuickAbstractDrawer); - if (d->edge != edge) { - d->edge = edge; - if (isComponentComplete()) - d->updateContent(); - emit edgeChanged(); - } -} - -qreal QQuickAbstractDrawer::position() const -{ - Q_D(const QQuickAbstractDrawer); - return d->position; -} - -void QQuickAbstractDrawer::setPosition(qreal position) -{ - Q_D(QQuickAbstractDrawer); - position = qBound(0.0, position, 1.0); - if (!qFuzzyCompare(d->position, position)) { - d->position = position; - if (isComponentComplete()) - d->updateContent(); - emit positionChanged(); - } -} - -QQuickItem *QQuickAbstractDrawer::contentItem() const -{ - Q_D(const QQuickAbstractDrawer); - return d->content; -} - -void QQuickAbstractDrawer::setContentItem(QQuickItem *item) -{ - Q_D(QQuickAbstractDrawer); - if (d->content != item) { - delete d->content; - d->content = item; - if (item) - item->setParentItem(this); - if (isComponentComplete()) - d->updateContent(); - emit contentItemChanged(); - } -} - -QQuickPropertyAnimation *QQuickAbstractDrawer::animation() const -{ - Q_D(const QQuickAbstractDrawer); - return d->animation; -} - -void QQuickAbstractDrawer::setAnimation(QQuickPropertyAnimation *animation) -{ - Q_D(QQuickAbstractDrawer); - if (d->animation != animation) { - delete d->animation; - d->animation = animation; - if (animation) { - animation->setTargetObject(this); - animation->setProperty(QStringLiteral("position")); - } - emit animationChanged(); - } -} - -void QQuickAbstractDrawer::open() -{ - Q_D(QQuickAbstractDrawer); - if (d->animation) { - d->animation->stop(); - d->animation->setFrom(d->position); - d->animation->setTo(1.0); - d->animation->start(); - } else { - setPosition(1.0); - } -} - -void QQuickAbstractDrawer::close() -{ - Q_D(QQuickAbstractDrawer); - if (d->animation) { - d->animation->stop(); - d->animation->setFrom(d->position); - d->animation->setTo(0.0); - d->animation->start(); - } else { - setPosition(0.0); - } -} - -bool QQuickAbstractDrawer::childMouseEventFilter(QQuickItem *child, QEvent *event) -{ - Q_D(QQuickAbstractDrawer); - switch (event->type()) { - case QEvent::MouseButtonPress: - return d->handleMousePressEvent(child, static_cast(event)); - case QEvent::MouseMove: - return d->handleMouseMoveEvent(child, static_cast(event)); - case QEvent::MouseButtonRelease: - return d->handleMouseReleaseEvent(child, static_cast(event)); - default: - return false; - } -} - -void QQuickAbstractDrawer::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::mousePressEvent(event); - d->handleMousePressEvent(this, event); -} - -void QQuickAbstractDrawer::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::mouseMoveEvent(event); - d->handleMouseMoveEvent(this, event); -} - -void QQuickAbstractDrawer::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::mouseReleaseEvent(event); - d->handleMouseReleaseEvent(this, event); -} - -void QQuickAbstractDrawer::mouseUngrabEvent() -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::mouseUngrabEvent(); - d->pressPoint = QPoint(); -} - -void QQuickAbstractDrawer::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::geometryChanged(newGeometry, oldGeometry); - if (isComponentComplete()) - d->updateContent(); -} - -void QQuickAbstractDrawer::componentComplete() -{ - Q_D(QQuickAbstractDrawer); - QQuickControl::componentComplete(); - d->updateContent(); -} - -qreal QQuickAbstractDrawer::positionAt(const QPointF &point) const -{ - Q_D(const QQuickAbstractDrawer); - if (!d->content) - return 0.0; - - switch (d->edge) { - case Qt::TopEdge: - return point.y() / d->content->height(); - case Qt::LeftEdge: - return point.x() / d->content->width(); - case Qt::RightEdge: - return (width() - point.x()) / d->content->width(); - case Qt::BottomEdge: - return (height() - point.y()) / d->content->height(); - default: - return 0; - } -} - -QT_END_NAMESPACE diff --git a/src/extras/qquickabstractdrawer_p.h b/src/extras/qquickabstractdrawer_p.h deleted file mode 100644 index a2f91518..00000000 --- a/src/extras/qquickabstractdrawer_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Extras 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 QQUICKABSTRACTDRAWER_P_H -#define QQUICKABSTRACTDRAWER_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 -#include - -QT_BEGIN_NAMESPACE - -class QQuickPropertyAnimation; -class QQuickAbstractDrawerPrivate; - -class Q_QUICKEXTRAS_EXPORT QQuickAbstractDrawer : public QQuickControl -{ - Q_OBJECT - Q_PROPERTY(Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged FINAL) - Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL) - Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) - // TODO: make this a proper transition - Q_PROPERTY(QQuickPropertyAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged FINAL) - Q_CLASSINFO("DefaultProperty", "contentItem") - -public: - explicit QQuickAbstractDrawer(QQuickItem *parent = Q_NULLPTR); - - Qt::Edge edge() const; - void setEdge(Qt::Edge edge); - - qreal position() const; - void setPosition(qreal position); - - QQuickItem *contentItem() const; - void setContentItem(QQuickItem *item); - - QQuickPropertyAnimation *animation() const; - void setAnimation(QQuickPropertyAnimation *animation); - -public Q_SLOTS: - void open(); - void close(); - -Q_SIGNALS: - void clicked(); - void edgeChanged(); - void positionChanged(); - void contentItemChanged(); - void animationChanged(); - -protected: - bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseUngrabEvent() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - - virtual qreal positionAt(const QPointF &point) const; - -private: - Q_DISABLE_COPY(QQuickAbstractDrawer) - Q_DECLARE_PRIVATE(QQuickAbstractDrawer) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTDRAWER_P_H diff --git a/src/extras/qquickdrawer.cpp b/src/extras/qquickdrawer.cpp new file mode 100644 index 00000000..7c61688a --- /dev/null +++ b/src/extras/qquickdrawer.cpp @@ -0,0 +1,388 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Extras 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 "qquickdrawer_p.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickDrawerPrivate : public QQuickControlPrivate +{ + Q_DECLARE_PUBLIC(QQuickDrawer) + +public: + QQuickDrawerPrivate() : edge(Qt::LeftEdge), offset(0), position(0), + content(Q_NULLPTR), animation(Q_NULLPTR) { } + + void updateContent(); + bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event); + bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event); + bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event); + + Qt::Edge edge; + qreal offset; + qreal position; + QPointF pressPoint; + QQuickItem *content; + QQuickPropertyAnimation *animation; +}; + +void QQuickDrawerPrivate::updateContent() +{ + Q_Q(QQuickDrawer); + if (!content) + return; + + switch (edge) { + case Qt::LeftEdge: + content->setX((position - 1.0) * content->width()); + break; + case Qt::RightEdge: + content->setX(q->width() + - position * content->width()); + break; + case Qt::TopEdge: + content->setY((position - 1.0) * content->height()); + break; + case Qt::BottomEdge: + content->setY(q->height() + - position * content->height()); + break; + } +} + +bool QQuickDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event) +{ + Q_Q(QQuickDrawer); + pressPoint = q->mapFromItem(item, event->pos()); + + if (qFuzzyIsNull(position)) { + // only accept pressing at drag margins when fully closed + switch (edge) { + case Qt::LeftEdge: + event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(event->x(), Qt::XAxis, event)); + break; + case Qt::RightEdge: + event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(q->width() - event->x(), Qt::XAxis, event)); + break; + case Qt::TopEdge: + event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(event->y(), Qt::YAxis, event)); + break; + case Qt::BottomEdge: + event->setAccepted(!QQuickWindowPrivate::dragOverThreshold(q->height() - event->y(), Qt::YAxis, event)); + break; + } + offset = 0; + } else { + event->accept(); + offset = q->positionAt(pressPoint) - position; + } + + return item == q; +} + +bool QQuickDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event) +{ + Q_Q(QQuickDrawer); + QPointF movePoint = q->mapFromItem(item, event->pos()); + + if (!q->keepMouseGrab()) { + bool overThreshold = false; + if (edge == Qt::LeftEdge || edge == Qt::RightEdge) + overThreshold = QQuickWindowPrivate::dragOverThreshold(movePoint.x() - pressPoint.x(), Qt::XAxis, event); + else + overThreshold = QQuickWindowPrivate::dragOverThreshold(movePoint.y() - pressPoint.y(), Qt::YAxis, event); + + if (window && overThreshold) { + QQuickItem *grabber = q->window()->mouseGrabberItem(); + if (!grabber || !grabber->keepMouseGrab()) { + q->grabMouse(); + q->setKeepMouseGrab(overThreshold); + } + } + } + + if (q->keepMouseGrab()) + q->setPosition(q->positionAt(event->pos()) - offset); + event->accept(); + + return q->keepMouseGrab(); +} + +bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event) +{ + Q_Q(QQuickDrawer); + bool wasGrabbed = q->keepMouseGrab(); + if (wasGrabbed) { +// int startDragVelocity = QGuiApplication::styleHints()->startDragVelocity(); +// if (startDragVelocity && QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity) { +// QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event); +// qreal vel = (edge == Qt::LeftEdge || edge == Qt::RightEdge) ? velocity.x() : velocity.y(); +// qDebug() << vel << "vs." << startDragVelocity; +// } + if (position < 0.3) { + q->close(); + } else if (position > 0.7) { + q->open(); + } else { + switch (edge) { + case Qt::LeftEdge: + if (event->x() - pressPoint.x() > 0) + q->open(); + else + q->close(); + break; + case Qt::RightEdge: + if (event->x() - pressPoint.x() < 0) + q->open(); + else + q->close(); + break; + case Qt::TopEdge: + if (event->y() - pressPoint.y() > 0) + q->open(); + else + q->close(); + break; + case Qt::BottomEdge: + if (event->y() - pressPoint.y() < 0) + q->open(); + else + q->close(); + break; + } + } + q->setKeepMouseGrab(false); + } else { + if (item == q) + emit q->clicked(); + } + pressPoint = QPoint(); + event->accept(); + return wasGrabbed; +} + +QQuickDrawer::QQuickDrawer(QQuickItem *parent) : + QQuickControl(*(new QQuickDrawerPrivate), parent) +{ + setZ(1); + setFiltersChildMouseEvents(true); + setAcceptedMouseButtons(Qt::LeftButton); +} + +Qt::Edge QQuickDrawer::edge() const +{ + Q_D(const QQuickDrawer); + return d->edge; +} + +void QQuickDrawer::setEdge(Qt::Edge edge) +{ + Q_D(QQuickDrawer); + if (d->edge != edge) { + d->edge = edge; + if (isComponentComplete()) + d->updateContent(); + emit edgeChanged(); + } +} + +qreal QQuickDrawer::position() const +{ + Q_D(const QQuickDrawer); + return d->position; +} + +void QQuickDrawer::setPosition(qreal position) +{ + Q_D(QQuickDrawer); + position = qBound(0.0, position, 1.0); + if (!qFuzzyCompare(d->position, position)) { + d->position = position; + if (isComponentComplete()) + d->updateContent(); + emit positionChanged(); + } +} + +QQuickItem *QQuickDrawer::contentItem() const +{ + Q_D(const QQuickDrawer); + return d->content; +} + +void QQuickDrawer::setContentItem(QQuickItem *item) +{ + Q_D(QQuickDrawer); + if (d->content != item) { + delete d->content; + d->content = item; + if (item) + item->setParentItem(this); + if (isComponentComplete()) + d->updateContent(); + emit contentItemChanged(); + } +} + +QQuickPropertyAnimation *QQuickDrawer::animation() const +{ + Q_D(const QQuickDrawer); + return d->animation; +} + +void QQuickDrawer::setAnimation(QQuickPropertyAnimation *animation) +{ + Q_D(QQuickDrawer); + if (d->animation != animation) { + delete d->animation; + d->animation = animation; + if (animation) { + animation->setTargetObject(this); + animation->setProperty(QStringLiteral("position")); + } + emit animationChanged(); + } +} + +void QQuickDrawer::open() +{ + Q_D(QQuickDrawer); + if (d->animation) { + d->animation->stop(); + d->animation->setFrom(d->position); + d->animation->setTo(1.0); + d->animation->start(); + } else { + setPosition(1.0); + } +} + +void QQuickDrawer::close() +{ + Q_D(QQuickDrawer); + if (d->animation) { + d->animation->stop(); + d->animation->setFrom(d->position); + d->animation->setTo(0.0); + d->animation->start(); + } else { + setPosition(0.0); + } +} + +bool QQuickDrawer::childMouseEventFilter(QQuickItem *child, QEvent *event) +{ + Q_D(QQuickDrawer); + switch (event->type()) { + case QEvent::MouseButtonPress: + return d->handleMousePressEvent(child, static_cast(event)); + case QEvent::MouseMove: + return d->handleMouseMoveEvent(child, static_cast(event)); + case QEvent::MouseButtonRelease: + return d->handleMouseReleaseEvent(child, static_cast(event)); + default: + return false; + } +} + +void QQuickDrawer::mousePressEvent(QMouseEvent *event) +{ + Q_D(QQuickDrawer); + QQuickControl::mousePressEvent(event); + d->handleMousePressEvent(this, event); +} + +void QQuickDrawer::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QQuickDrawer); + QQuickControl::mouseMoveEvent(event); + d->handleMouseMoveEvent(this, event); +} + +void QQuickDrawer::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QQuickDrawer); + QQuickControl::mouseReleaseEvent(event); + d->handleMouseReleaseEvent(this, event); +} + +void QQuickDrawer::mouseUngrabEvent() +{ + Q_D(QQuickDrawer); + QQuickControl::mouseUngrabEvent(); + d->pressPoint = QPoint(); +} + +void QQuickDrawer::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_D(QQuickDrawer); + QQuickControl::geometryChanged(newGeometry, oldGeometry); + if (isComponentComplete()) + d->updateContent(); +} + +void QQuickDrawer::componentComplete() +{ + Q_D(QQuickDrawer); + QQuickControl::componentComplete(); + d->updateContent(); +} + +qreal QQuickDrawer::positionAt(const QPointF &point) const +{ + Q_D(const QQuickDrawer); + if (!d->content) + return 0.0; + + switch (d->edge) { + case Qt::TopEdge: + return point.y() / d->content->height(); + case Qt::LeftEdge: + return point.x() / d->content->width(); + case Qt::RightEdge: + return (width() - point.x()) / d->content->width(); + case Qt::BottomEdge: + return (height() - point.y()) / d->content->height(); + default: + return 0; + } +} + +QT_END_NAMESPACE diff --git a/src/extras/qquickdrawer_p.h b/src/extras/qquickdrawer_p.h new file mode 100644 index 00000000..1c42b290 --- /dev/null +++ b/src/extras/qquickdrawer_p.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Extras 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 QQUICKDRAWER_P_H +#define QQUICKDRAWER_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 +#include + +QT_BEGIN_NAMESPACE + +class QQuickPropertyAnimation; +class QQuickDrawerPrivate; + +class Q_QUICKEXTRAS_EXPORT QQuickDrawer : public QQuickControl +{ + Q_OBJECT + Q_PROPERTY(Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged FINAL) + Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL) + Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) + // TODO: make this a proper transition + Q_PROPERTY(QQuickPropertyAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged FINAL) + Q_CLASSINFO("DefaultProperty", "contentItem") + +public: + explicit QQuickDrawer(QQuickItem *parent = Q_NULLPTR); + + Qt::Edge edge() const; + void setEdge(Qt::Edge edge); + + qreal position() const; + void setPosition(qreal position); + + QQuickItem *contentItem() const; + void setContentItem(QQuickItem *item); + + QQuickPropertyAnimation *animation() const; + void setAnimation(QQuickPropertyAnimation *animation); + +public Q_SLOTS: + void open(); + void close(); + +Q_SIGNALS: + void clicked(); + void edgeChanged(); + void positionChanged(); + void contentItemChanged(); + void animationChanged(); + +protected: + bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseUngrabEvent() Q_DECL_OVERRIDE; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; + + virtual qreal positionAt(const QPointF &point) const; + +private: + Q_DISABLE_COPY(QQuickDrawer) + Q_DECLARE_PRIVATE(QQuickDrawer) +}; + +QT_END_NAMESPACE + +#endif // QQUICKDRAWER_P_H diff --git a/src/imports/calendar/qtquickcalendar2plugin.cpp b/src/imports/calendar/qtquickcalendar2plugin.cpp index 8e84e094..68ef2ad0 100644 --- a/src/imports/calendar/qtquickcalendar2plugin.cpp +++ b/src/imports/calendar/qtquickcalendar2plugin.cpp @@ -36,9 +36,9 @@ #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -57,9 +57,9 @@ public: void QtQuickCalendar2Plugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 2, 0, "AbstractCalendarView"); - qmlRegisterType(uri, 2, 0, "AbstractDayOfWeekRow"); - qmlRegisterType(uri, 2, 0, "AbstractWeekNumberColumn"); + qmlRegisterType(uri, 2, 0, "AbstractCalendarView"); + qmlRegisterType(uri, 2, 0, "AbstractDayOfWeekRow"); + qmlRegisterType(uri, 2, 0, "AbstractWeekNumberColumn"); qmlRegisterType(uri, 2, 0, "CalendarModel"); qmlRegisterType(uri, 2, 0, "DayOfWeekModel"); qmlRegisterType(uri, 2, 0, "MonthModel"); diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index ace8455e..9bfc6652 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -37,28 +37,28 @@ #include #include "qquicktheme_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -82,28 +82,28 @@ public: void QtQuickControls2Plugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 2, 0, "AbstractApplicationWindow"); - qmlRegisterType(uri, 2, 0, "AbstractBusyIndicator"); - qmlRegisterType(uri, 2, 0, "AbstractButton"); - qmlRegisterType(uri, 2, 0, "AbstractCheckBox"); - qmlRegisterType(uri, 2, 0, "AbstractFrame"); - qmlRegisterType(uri, 2, 0, "AbstractGroupBox"); - qmlRegisterType(uri, 2, 0, "AbstractLabel"); - qmlRegisterType(uri, 2, 0, "AbstractPageIndicator"); - qmlRegisterType(uri, 2, 0, "AbstractProgressBar"); - qmlRegisterType(uri, 2, 0, "AbstractRadioButton"); - qmlRegisterType(uri, 2, 0, "AbstractScrollBar"); - qmlRegisterType(uri, 2, 0, "AbstractScrollIndicator"); - qmlRegisterType(uri, 2, 0, "AbstractSlider"); - qmlRegisterType(uri, 2, 0, "AbstractStackView"); - qmlRegisterType(uri, 2, 0, "AbstractSwitch"); - qmlRegisterType(uri, 2, 0, "AbstractTabBar"); - qmlRegisterType(uri, 2, 0, "AbstractTabButton"); - qmlRegisterType(uri, 2, 0, "AbstractTabView"); - qmlRegisterType(uri, 2, 0, "AbstractTextArea"); - qmlRegisterType(uri, 2, 0, "AbstractTextField"); - qmlRegisterType(uri, 2, 0, "AbstractToggleButton"); - qmlRegisterType(uri, 2, 0, "AbstractToolBar"); + qmlRegisterType(uri, 2, 0, "AbstractApplicationWindow"); + qmlRegisterType(uri, 2, 0, "AbstractBusyIndicator"); + qmlRegisterType(uri, 2, 0, "AbstractButton"); + qmlRegisterType(uri, 2, 0, "AbstractCheckBox"); + qmlRegisterType(uri, 2, 0, "AbstractFrame"); + qmlRegisterType(uri, 2, 0, "AbstractGroupBox"); + qmlRegisterType(uri, 2, 0, "AbstractLabel"); + qmlRegisterType(uri, 2, 0, "AbstractPageIndicator"); + qmlRegisterType(uri, 2, 0, "AbstractProgressBar"); + qmlRegisterType(uri, 2, 0, "AbstractRadioButton"); + qmlRegisterType(uri, 2, 0, "AbstractScrollBar"); + qmlRegisterType(uri, 2, 0, "AbstractScrollIndicator"); + qmlRegisterType(uri, 2, 0, "AbstractSlider"); + qmlRegisterType(uri, 2, 0, "AbstractStackView"); + qmlRegisterType(uri, 2, 0, "AbstractSwitch"); + qmlRegisterType(uri, 2, 0, "AbstractTabBar"); + qmlRegisterType(uri, 2, 0, "AbstractTabButton"); + qmlRegisterType(uri, 2, 0, "AbstractTabView"); + qmlRegisterType(uri, 2, 0, "AbstractTextArea"); + qmlRegisterType(uri, 2, 0, "AbstractTextField"); + qmlRegisterType(uri, 2, 0, "AbstractToggleButton"); + qmlRegisterType(uri, 2, 0, "AbstractToolBar"); qmlRegisterUncreatableType(uri, 2, 0, "Exclusive", "Exclusive is an attached property"); qmlRegisterUncreatableType(uri, 2, 0, "Stack", "Stack is an attached property"); diff --git a/src/imports/extras/qtquickextras2plugin.cpp b/src/imports/extras/qtquickextras2plugin.cpp index 42f0d48e..e2e0d62d 100644 --- a/src/imports/extras/qtquickextras2plugin.cpp +++ b/src/imports/extras/qtquickextras2plugin.cpp @@ -36,7 +36,7 @@ #include -#include +#include QT_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ public: void QtQuickExtras2Plugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 2, 0, "AbstractDrawer"); + qmlRegisterType(uri, 2, 0, "AbstractDrawer"); } QT_END_NAMESPACE -- cgit v1.2.3