From b123c56d11ece08de53297203dd08fc0ce0fe36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 16 Mar 2021 15:20:46 +0800 Subject: [PATCH] add text wrap or precise width height --- doric-Qt/doric/doric.pro.user | 32 +-- doric-Qt/doric/doric.pro.user.a49b4ab | 319 ++++++++++++++++++++++++++ doric-Qt/doric/main.cpp | 2 +- doric-Qt/doric/resources/text.qml | 27 +++ doric-Qt/doric/test-layout.qml | 31 +-- doric-cli/package.json | 3 +- doric-js/package.json | 1 + 7 files changed, 373 insertions(+), 42 deletions(-) create mode 100644 doric-Qt/doric/doric.pro.user.a49b4ab diff --git a/doric-Qt/doric/doric.pro.user b/doric-Qt/doric/doric.pro.user index 37a3cca3..46bc4bb6 100644 --- a/doric-Qt/doric/doric.pro.user +++ b/doric-Qt/doric/doric.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {a49b4abd-08cf-4556-b46e-b0f44132419f} + {8f962447-7124-415a-9ec4-51e877569548} ProjectExplorer.Project.ActiveTarget @@ -67,7 +67,9 @@ 0 true - + + -fno-delayed-template-parsing + true Builtin.Questionable @@ -86,16 +88,16 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 6.0.1 clang 64bit - Desktop Qt 6.0.1 clang 64bit - qt.qt6.601.clang_64_kit + Desktop Qt 6.0.1 MinGW 64-bit + Desktop Qt 6.0.1 MinGW 64-bit + qt.qt6.601.win64_mingw81_kit 0 0 0 0 - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug + C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Debug + C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Debug true @@ -134,8 +136,8 @@ 0 - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Release - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Release + C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Release + C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Release true @@ -176,8 +178,8 @@ 0 - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Profile - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Profile + C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Profile + C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Profile true @@ -292,14 +294,14 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro - /Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro + C:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro false true true false true - /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug/doric.app/Contents/MacOS + C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Debug 1 diff --git a/doric-Qt/doric/doric.pro.user.a49b4ab b/doric-Qt/doric/doric.pro.user.a49b4ab new file mode 100644 index 00000000..37a3cca3 --- /dev/null +++ b/doric-Qt/doric/doric.pro.user.a49b4ab @@ -0,0 +1,319 @@ + + + + + + EnvironmentId + {a49b4abd-08cf-4556-b46e-b0f44132419f} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + true + Builtin.Questionable + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.0.1 clang 64bit + Desktop Qt 6.0.1 clang 64bit + qt.qt6.601.clang_64_kit + 0 + 0 + 0 + + 0 + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + 0 + + + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Release + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + + 0 + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Profile + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro + /Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro + false + true + true + false + true + /Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_clang_64bit-Debug/doric.app/Contents/MacOS + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/doric-Qt/doric/main.cpp b/doric-Qt/doric/main.cpp index 6115b025..00daa474 100644 --- a/doric-Qt/doric/main.cpp +++ b/doric-Qt/doric/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { QQmlApplicationEngine engine; qmlRegisterType("pub.doric.widget", 1, 0, "FlexLayoutService"); - // const QUrl url(QStringLiteral("qrc:/doric/qml/test-layout.qml")); +// const QUrl url(QStringLiteral("qrc:/doric/qml/test-layout.qml")); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect( &engine, &QQmlApplicationEngine::objectCreated, &app, diff --git a/doric-Qt/doric/resources/text.qml b/doric-Qt/doric/resources/text.qml index 9c867c90..19a00495 100644 --- a/doric-Qt/doric/resources/text.qml +++ b/doric-Qt/doric/resources/text.qml @@ -1,9 +1,36 @@ import QtQuick 2.12 import QtQuick.Controls 2.5 +import "util.mjs" as Util Rectangle { + property var uuid: Util.uuidv4() + property int childrenRectWidth: childrenRect.width + property int childrenRectHeight: childrenRect.width color: 'transparent' + property var tag: "Text" + + onWidthChanged: () => { + console.log(tag, uuid + " onWidthChanged: " + this.width) + } + + onHeightChanged: () => { + console.log(tag, uuid + " onHeightChanged: " + this.height) + } + + onChildrenRectChanged: () => { + console.log(tag, uuid + " childrenRect: " + uuid + " onChildrenRectChanged: " +childrenRect) + this.childrenRectWidth = childrenRect.width + this.childrenRectHeight = childrenRect.height + + if (this.width === 0) { + this.width = this.childrenRectWidth + } + if (this.height === 0) { + this.height = this.childrenRectHeight + } + } + Text { } diff --git a/doric-Qt/doric/test-layout.qml b/doric-Qt/doric/test-layout.qml index e7d2078a..0c849dcb 100644 --- a/doric-Qt/doric/test-layout.qml +++ b/doric-Qt/doric/test-layout.qml @@ -13,38 +13,19 @@ ApplicationWindow { width: childrenRect.width height: childrenRect.height - RowLayout { + ColumnLayout { spacing: 0 + width: 400 + Rectangle { - width: 100 - height: 100 - color: 'black' - Layout.alignment: Qt.AlignTop | Qt.AlignLeft - } - Rectangle { - Layout.topMargin: 30 - width: 100 - height: 100 - color: 'yellow' - } - Rectangle { - Layout.topMargin: 0 - width: 100 - height: 100 - color: 'black' - Layout.alignment: Qt.AlignTop | Qt.AlignLeft - } - Rectangle { - width: 100 - height: 100 - color: 'yellow' - } - Rectangle { + Layout.alignment: Qt.AlignHCenter width: 100 height: 100 color: 'black' } + Rectangle { + Layout.alignment: Qt.AlignHCenter width: 100 height: 100 color: 'yellow' diff --git a/doric-cli/package.json b/doric-cli/package.json index 8b138840..fd8f1e56 100644 --- a/doric-cli/package.json +++ b/doric-cli/package.json @@ -9,9 +9,10 @@ "scripts": { "start": "tsc && node dist/index.js", "clean": "rm -rf dist", + "clean-win32": "del dist", "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1", - "prepublish": "npm run clean && npm run build" + "prepublish": "npm run clean-win32 && npm run build" }, "repository": { "type": "git", diff --git a/doric-js/package.json b/doric-js/package.json index f761fed8..20abb011 100644 --- a/doric-js/package.json +++ b/doric-js/package.json @@ -7,6 +7,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc -p tsconfig.es5.json && mv -f lib-es5/src/ui/view.es5.js lib-es5/src/ui/view.js && tsc -d -p . && rollup -c && dts-bundle --configJson dts-bundle.json && cat src/image.d.ts >> index.d.ts", + "build-win32": "tsc -p tsconfig.es5.json && tsc -d -p . && rollup -c && dts-bundle --configJson dts-bundle.json", "dev": "tsc -w -p . & rollup -c -w", "clean": "rm -rf lib && rm -rf lib-es5 && rm -rf bundle", "prepublish": "npm run build"