From 5ead7e7ddd5430b6a0b5597754f13583b653d67b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 7 Mar 2011 15:32:07 +1000 Subject: PinchArea example produced incorrect scaling. The maths was dodgy - producing far greater scaling than that provided by PinchArea. Change-Id: I4a1ee1b0d65eed623ec9ee92c22c9740116430c5 Task-number: QTBUG-17828 Reviewed-by: Michael Brasser --- .../declarative/touchinteraction/pincharea/flickresize.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/declarative/touchinteraction/pincharea/flickresize.qml b/examples/declarative/touchinteraction/pincharea/flickresize.qml index a2f81ff..9439ace 100644 --- a/examples/declarative/touchinteraction/pincharea/flickresize.qml +++ b/examples/declarative/touchinteraction/pincharea/flickresize.qml @@ -54,14 +54,21 @@ Rectangle { PinchArea { width: Math.max(flick.contentWidth, flick.width) height: Math.max(flick.contentHeight, flick.height) + + property real initialWidth + property real initialHeight + onPinchStarted: { + initialWidth = flick.contentWidth + initialHeight = flick.contentHeight + } + onPinchUpdated: { // adjust content pos due to drag flick.contentX += pinch.previousCenter.x - pinch.center.x flick.contentY += pinch.previousCenter.y - pinch.center.y // resize content - var scale = 1.0 + pinch.scale - pinch.previousScale - flick.resizeContent(flick.contentWidth * scale, flick.contentHeight * scale, pinch.center) + flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center) } onPinchFinished: { -- cgit v0.12 From 88c4bd4d5fc25a58d3b71c540acd6f2484c3a9a3 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 7 Mar 2011 15:58:17 +1000 Subject: Set correct initial value for TextEdit and TextInput canPaste property Change-Id: Ied5b257305fa68db64fcf270ad2a42f691fbdca2 Task-number: QTBUG-17765 Reviewed-by: Martin Jones --- .../graphicsitems/qdeclarativetextedit.cpp | 1 + .../graphicsitems/qdeclarativetextinput.cpp | 1 + .../tst_qdeclarativetextedit.cpp | 38 ++++++++++++++++++++++ .../tst_qdeclarativetextinput.cpp | 38 ++++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index c28d7f4..d3c5b82 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -1469,6 +1469,7 @@ void QDeclarativeTextEditPrivate::init() #ifndef QT_NO_CLIPBOARD QObject::connect(q, SIGNAL(readOnlyChanged(bool)), q, SLOT(q_canPasteChanged())); QObject::connect(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged())); + canPaste = control->canPaste(); #endif document = control->document(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 8b21008..29b1f6b 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1766,6 +1766,7 @@ void QDeclarativeTextInputPrivate::init() q, SLOT(q_canPasteChanged())); q->connect(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged())); + canPaste = !control->isReadOnly() && QApplication::clipboard()->text().length() != 0; #endif // QT_NO_CLIPBOARD q->connect(control, SIGNAL(updateMicroFocus()), q, SLOT(updateMicroFocus())); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index dc1063f..e26077c 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -130,6 +130,8 @@ private slots: void navigation(); void readOnly(); void copyAndPaste(); + void canPaste(); + void canPasteEmpty(); void textInput(); void openInputPanelOnClick(); void openInputPanelOnFocus(); @@ -1545,6 +1547,42 @@ void tst_qdeclarativetextedit::copyAndPaste() { #endif } +void tst_qdeclarativetextedit::canPaste() { +#ifndef QT_NO_CLIPBOARD + + QApplication::clipboard()->setText("Some text"); + + QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; + QDeclarativeComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // check initial value - QTBUG-17765 + QTextControl tc; + QCOMPARE(textEdit->canPaste(), tc.canPaste()); + +#endif +} + +void tst_qdeclarativetextedit::canPasteEmpty() { +#ifndef QT_NO_CLIPBOARD + + QApplication::clipboard()->clear(); + + QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; + QDeclarativeComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // check initial value - QTBUG-17765 + QTextControl tc; + QCOMPARE(textEdit->canPaste(), tc.canPaste()); + +#endif +} + void tst_qdeclarativetextedit::readOnly() { QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml"); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index ef64dd9..a7a4e5e 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -114,6 +114,8 @@ private slots: void cursorRectangle(); void navigation(); void copyAndPaste(); + void canPasteEmpty(); + void canPaste(); void readOnly(); void openInputPanelOnClick(); @@ -1391,6 +1393,42 @@ void tst_qdeclarativetextinput::copyAndPaste() { #endif } +void tst_qdeclarativetextinput::canPasteEmpty() { +#ifndef QT_NO_CLIPBOARD + + QApplication::clipboard()->clear(); + + QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; + QDeclarativeComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QLineControl lc; + bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0; + QCOMPARE(textInput->canPaste(), cp); + +#endif +} + +void tst_qdeclarativetextinput::canPaste() { +#ifndef QT_NO_CLIPBOARD + + QApplication::clipboard()->setText("Some text"); + + QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; + QDeclarativeComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QLineControl lc; + bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0; + QCOMPARE(textInput->canPaste(), cp); + +#endif +} + void tst_qdeclarativetextinput::passwordCharacter() { QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }"; -- cgit v0.12