From c087f066475e683974245c6eb2c996936bf76bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 21 Apr 2021 11:25:19 +0800 Subject: [PATCH] remove 88 minus; set text order changed --- doric-Qt/doric/plugin/DoricModalPlugin.cpp | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/doric-Qt/doric/plugin/DoricModalPlugin.cpp b/doric-Qt/doric/plugin/DoricModalPlugin.cpp index 88570707..0701053d 100644 --- a/doric-Qt/doric/plugin/DoricModalPlugin.cpp +++ b/doric-Qt/doric/plugin/DoricModalPlugin.cpp @@ -29,8 +29,6 @@ void DoricModalPlugin::toast(QString jsValueString, QString callbackId) { QQuickItem *item = qobject_cast(component.create()); item->setParentItem(rootObject); - item->childItems().at(0)->childItems().at(0)->setProperty("text", msg); - // init set y if ((gravity & DoricGravity::DoricGravityBottom) == DoricGravity::DoricGravityBottom) { @@ -39,8 +37,7 @@ void DoricModalPlugin::toast(QString jsValueString, QString callbackId) { DoricGravity::DoricGravityTop) { item->setProperty("y", 20); } else { - item->setProperty("y", - (rootObject->height() - item->height() - 88) / 2); + item->setProperty("y", (rootObject->height() - item->height()) / 2); } // update x @@ -49,20 +46,22 @@ void DoricModalPlugin::toast(QString jsValueString, QString callbackId) { }); // update y - connect(item, &QQuickItem::heightChanged, - [rootObject, item, gravity]() { - if ((gravity & DoricGravity::DoricGravityBottom) == - DoricGravity::DoricGravityBottom) { - item->setProperty("y", rootObject->height() - - item->height() - 20); - } else if ((gravity & DoricGravity::DoricGravityTop) == - DoricGravity::DoricGravityTop) { - item->setProperty("y", 20); - } else { - item->setProperty( - "y", (rootObject->height() - item->height() - 88) / 2); - } - }); + connect( + item, &QQuickItem::heightChanged, [rootObject, item, gravity]() { + if ((gravity & DoricGravity::DoricGravityBottom) == + DoricGravity::DoricGravityBottom) { + item->setProperty("y", + rootObject->height() - item->height() - 20); + } else if ((gravity & DoricGravity::DoricGravityTop) == + DoricGravity::DoricGravityTop) { + item->setProperty("y", 20); + } else { + item->setProperty("y", + (rootObject->height() - item->height()) / 2); + } + }); + + item->childItems().at(0)->childItems().at(0)->setProperty("text", msg); QTimer::singleShot(2000, qApp, [item]() { item->setParent(nullptr);