Keeping the name qmleasing, but most of the code from easingcurveeditor.
easingcurveeditor had more UI and functionality, as qmleasing could only
import AfterEffects curves. That functionality has now been added to
easingcurveeditor.
Change-Id: Iac1a004f13fe33a18449af1b08bd22138d525322
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
+++ /dev/null
-QT += qml quick widgets
-CONFIG -= app_bundle
-
-# Input
-SOURCES += main.cpp \
- splineeditor.cpp \
- mainwindow.cpp \
- segmentproperties.cpp
-
-RESOURCES = $$PWD/resources.qrc
-
-HEADERS += \
- splineeditor.h \
- mainwindow.h \
- segmentproperties.h
-
-FORMS += \
- properties.ui \
- pane.ui
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-
-#include <QApplication>
-
-int main(int argc, char ** argv)
-{
- QApplication app(argc, argv);
-
- MainWindow mainWindow;
- mainWindow.show();
- mainWindow.showQuickView();
-
- return app.exec();
-}
+++ /dev/null
-<RCC>
- <qresource prefix="/">
- <file>preview.qml</file>
- <file>Button.qml</file>
- </qresource>
-</RCC>
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-FocusScope {
- width: input.x + input.width
- height: border.height
-
- property alias name: name.text
- property alias text: input.text
-
- Text {
- id: name
- height: parent.height
- }
-
- TextInput {
- id: input
- anchors.left: name.right
- anchors.leftMargin: 4
- focus: true
- width: 50
- horizontalAlignment: "AlignRight"
- Rectangle {
- id: border
- x: -2; y: -2
- width: parent.width + 4
- height: parent.height + 4
- color: "transparent"
- border.color: input.activeFocus?"green":"lightgreen"
-
- border.width: 3
- radius: 5
- }
- }
-}
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 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 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import EasingPlot 1.0
-
-Rectangle {
- width: 775; height: 550
-
- function precision(n)
- {
- var str = n.toPrecision(3);
- while (str.length > 1 && (str[str.length - 1] == "0" || str[str.length - 1] == "."))
- str = str.substr(0, str.length - 1);
- return str;
- }
-
- function updateEasing() {
- var ini = Math.min(100, Math.max(0, Number(in_inf.text)));
- var outi = Math.min(100, Math.max(0, Number(out_inf.text)));
-
- var ins = Number(in_slope.text);
- var outs = Number(out_slope.text);
-
- var p1 = [ (ini / 100), (ini / 100) * ins ];
- var p2 = [ 1 - (outi / 100), 1 - (outi / 100) * outs ];
-
- text.text = "[ " + precision(p1[0]) + ", " + precision(p1[1]) + ", " + precision(p2[0]) + ", " + precision(p2[1]) + ", 1, 1 ]";
- }
-
- Rectangle {
- id: border
- width: 500; height: 500
- x: 25; y: 25
- border.color: "lightsteelblue"
- border.width: 3
- radius: 5
- color: "transparent"
-
- EasingPlot {
- id: plot
-
- anchors.centerIn: parent
- width: parent.width - 10
- height: parent.height - 10
-
- easing.type: "Bezier"
- easing.bezierCurve: eval(text.text)
- }
-
- }
-
- Text {
- text: "<u>After Effects curve</u>"
- anchors.horizontalCenter: text.horizontalCenter
- anchors.bottom: column.top
- anchors.bottomMargin: 14
- }
-
- Column {
- id: column
-
- y: 70
- anchors.right: parent.right
- anchors.rightMargin: 25
- spacing: 5
- TextField {
- id: in_inf
- focus: true
- name: "Input influence:"
- text: "33"
- anchors.right: parent.right
- KeyNavigation.tab: in_slope
- KeyNavigation.backtab: text
- onTextChanged: updateEasing();
- }
- TextField {
- id: in_slope
- name: "Input slope:"
- text: "0"
- anchors.right: parent.right
- KeyNavigation.tab: out_inf
- KeyNavigation.backtab: in_inf
- onTextChanged: updateEasing();
- }
- TextField {
- id: out_inf
- name: "Output influence:"
- text: "33"
- anchors.right: parent.right
- KeyNavigation.tab: out_slope
- KeyNavigation.backtab: in_slope
- onTextChanged: updateEasing();
- }
- TextField {
- id: out_slope
- name: "Output slope:"
- text: "0"
- anchors.right: parent.right
- KeyNavigation.tab: text
- KeyNavigation.backtab: out_info
- onTextChanged: updateEasing();
- }
- }
-
- Text {
- text: "<u>QML Bezier curve</u>"
- anchors.horizontalCenter: text.horizontalCenter
- anchors.bottom: text.top
- anchors.bottomMargin: 10
- }
-
- TextEdit {
- id: text
- x: 200
- width: 200
- height: 200
-
- Rectangle {
- x: -2; y: -2
- width: parent.width + 4
- height: parent.height + 4
- color: "transparent"
- border.color: text.activeFocus?"green":"lightgreen"
-
- border.width: 3
- radius: 5
- }
-
- wrapMode: "WordWrap"
-
- anchors.top: column.bottom
- anchors.topMargin: 50
- anchors.right: column.right
- KeyNavigation.tab: in_inf
- KeyNavigation.backtab: out_slope
- }
-
-
- Item {
- anchors.left: text.left
- anchors.top: text.bottom
- anchors.topMargin: 35
- width: text.width
- height: rect.height
-
- Rectangle {
- color: "gray"
- width: 50; height: 50
- id: rect
-
- NumberAnimation on x {
- id: animation
- running: false
- easing: plot.easing
- duration: 1000
- }
-
- radius: 5
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (rect.x < 5) {
- animation.to = text.width - rect.width;
- } else {
- animation.to = 0;
- }
- animation.start();
- }
- }
-
- Text {
- anchors.centerIn: parent
- text: "Click to Try"
- }
- }
-
- Component.onCompleted: updateEasing();
-}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ImportDialog</class>
+ <widget class="QDialog" name="ImportDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>164</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Import After Effects Curve</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>130</y>
+ <width>341</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="QWidget" name="formLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>10</y>
+ <width>361</width>
+ <height>101</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="labelAlignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Input Influence:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Output Influence:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Output Slope:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="inInfluenceEdit">
+ <property name="text">
+ <string>33</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="inSlopeEdit">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="outInfluenceEdit">
+ <property name="text">
+ <string>33</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="outSlopeEdit">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Input Slope:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ImportDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ImportDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
**
****************************************************************************/
-#include <QPainter>
-#include <QtQuick/QQuickView>
-#include <QGuiApplication>
-#include <QEasingCurve>
-#include <QtQuick/QQuickPaintedItem>
+#include "mainwindow.h"
-class EasingPlot : public QQuickPaintedItem
-{
- Q_OBJECT
- Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged);
-
-public:
- EasingPlot();
-
- QEasingCurve easing() const;
- void setEasing(const QEasingCurve &);
-
-signals:
- void easingChanged();
-
-protected:
- virtual void paint(QPainter *painter);
-
-private:
- QEasingCurve m_easing;
-};
-
-EasingPlot::EasingPlot()
-{
-}
-
-QEasingCurve EasingPlot::easing() const
-{
- return m_easing;
-}
-
-void EasingPlot::setEasing(const QEasingCurve &e)
-{
- if (m_easing == e)
- return;
-
- m_easing = e;
- emit easingChanged();
-
- update();
-}
-
-void EasingPlot::paint(QPainter *painter)
-{
- QPointF lastPoint(0, 0);
-
- for (int ii = 1; ii <= 100; ++ii) {
- qreal value = m_easing.valueForProgress(qreal(ii) / 100.);
-
- QPointF currentPoint(width() * qreal(ii) / 100., value * (height() - 1));
- painter->drawLine(lastPoint, currentPoint);
-
- lastPoint = currentPoint;
- }
-}
+#include <QApplication>
int main(int argc, char ** argv)
{
- QGuiApplication app(argc, argv);
-
- qmlRegisterType<EasingPlot>("EasingPlot", 1, 0, "EasingPlot");
+ QApplication app(argc, argv);
- QQuickView view;
- view.setSource(QUrl("qrc:/easing.qml"));
- view.show();
+ MainWindow mainWindow;
+ mainWindow.show();
+ mainWindow.showQuickView();
return app.exec();
}
-
-#include "main.moc"
#include <QEasingCurve>
#include <QHBoxLayout>
#include <QVBoxLayout>
+#include <QDoubleValidator>
+#include <QDialog>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
groupBoxLayout->addWidget(splineEditor->pointListWidget());
m_splineEditor = splineEditor;
connect(ui_properties.plainTextEdit, SIGNAL(textChanged()), this, SLOT(textEditTextChanged()));
+
+ QDialog* importDialog = new QDialog(this);
+ ui_import.setupUi(importDialog);
+ ui_import.inInfluenceEdit->setValidator(new QDoubleValidator(this));
+ ui_import.inSlopeEdit->setValidator(new QDoubleValidator(this));
+ ui_import.outInfluenceEdit->setValidator(new QDoubleValidator(this));
+ ui_import.outSlopeEdit->setValidator(new QDoubleValidator(this));
+ connect(ui_properties.importButton, SIGNAL(clicked()), importDialog, SLOT(show()));
+ connect(importDialog, SIGNAL(finished(int)), this, SLOT(importData(int)));
+
connect(this, SIGNAL(close()), this, SLOT(doClose()));
initQml();
}
{
quickView.close();
}
+
+void MainWindow::importData(int result)
+{
+ if (!result)
+ return;
+ double ii = ui_import.inInfluenceEdit->text().toDouble();
+ double is = ui_import.inSlopeEdit->text().toDouble();
+ double oi = ui_import.outInfluenceEdit->text().toDouble();
+ double os = ui_import.outSlopeEdit->text().toDouble();
+ ii = qBound<double>(0., ii, 100.) / 100.;
+ oi = qBound<double>(0., oi, 100.) / 100.;
+ QString generatedString = QString("[%1,%2,%3,%4,1,1]").arg(ii, 0, 'f', 3)
+ .arg(ii*is,0,'f',3).arg(1-oi, 0, 'f', 3).arg(1-(oi*os), 0, 'f', 3);
+ ui_properties.plainTextEdit->setPlainText(generatedString);
+}
#include <QMainWindow>
#include <QtQuick/QQuickView>
#include "ui_properties.h"
+#include "ui_import.h"
class SplineEditor;
public slots:
void textEditTextChanged();
+ void importData(int result);
protected:
virtual void moveEvent(QMoveEvent *event);
QQuickView quickView;
QWidget *m_placeholder;
Ui_Properties ui_properties;
+ Ui_ImportDialog ui_import;
SplineEditor *m_splineEditor;
};
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="6" column="1">
<spacer name="spacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
- <item row="5" column="0" colspan="3">
+ <item row="9" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
</property>
</widget>
</item>
+ <item row="4" column="0" colspan="3">
+ <widget class="QPushButton" name="importButton">
+ <property name="text">
+ <string>Import AfterEffects Curve</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
-QT += qml quick
+QT += qml quick widgets
CONFIG -= app_bundle
-SOURCES += main.cpp
+SOURCES += main.cpp \
+ splineeditor.cpp \
+ mainwindow.cpp \
+ segmentproperties.cpp
RESOURCES = $$PWD/resources.qrc
+
+HEADERS += \
+ splineeditor.h \
+ mainwindow.h \
+ segmentproperties.h
+
+FORMS += \
+ properties.ui \
+ pane.ui \
+ import.ui
<RCC>
<qresource prefix="/">
- <file>easing.qml</file>
- <file>TextField.qml</file>
+ <file>preview.qml</file>
+ <file>Button.qml</file>
</qresource>
</RCC>
qmlscene \
qmlplugindump \
qmlmin \
- qmleasing \
qmlprofiler \
qmlbundle \
qmltestrunner
-!contains(QT_CONFIG, no-widgets):SUBDIRS += easingcurveeditor
+!contains(QT_CONFIG, no-widgets):SUBDIRS += qmleasing