abstract spec mode

This commit is contained in:
王劲鹏 2021-04-06 11:19:48 +08:00 committed by osborn
parent 7e59150831
commit 3a251b5adf
4 changed files with 47 additions and 41 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.1, 2021-04-01T16:59:16. --> <!-- Written by QtCreator 4.14.2, 2021-04-06T10:55:52. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -88,16 +88,16 @@
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value> <value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.0.2 MSVC2019 64bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.0.3 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.0.2 MSVC2019 64bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.0.3 MSVC2019 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.602.win64_msvc2019_64_kit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.603.win64_msvc2019_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value> <value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -136,8 +136,8 @@
<value type="int" key="RunSystemFunction">0</value> <value type="int" key="RunSystemFunction">0</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -178,8 +178,8 @@
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value> <value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -301,7 +301,7 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value> <value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_2_MSVC2019_64bit-Debug</value> <value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MSVC2019_64bit-Debug</value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>
@ -310,16 +310,16 @@
<variable>ProjectExplorer.Project.Target.1</variable> <variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value> <value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.0.1 MinGW 64-bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.0.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.0.1 MinGW 64-bit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.0.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.601.win64_mingw81_kit</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.603.win64_mingw81_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value> <value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -358,8 +358,8 @@
<value type="int" key="RunSystemFunction">0</value> <value type="int" key="RunSystemFunction">0</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -400,8 +400,8 @@
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value> <value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\maverick\Workspace\Doric\doric-Qt\build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_1_MinGW_64_bit-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/maverick/Workspace/Doric/doric-Qt/build-doric-Desktop_Qt_6_0_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -516,11 +516,10 @@
<valuelist type="QVariantList" key="CustomOutputParsers"/> <valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/maverick/Workspace/Doric/doric-Qt/doric/doric.pro</value> <value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap> </valuemap>

View File

@ -57,7 +57,7 @@ void DoricSuperNode::blendSubLayoutConfig(DoricViewNode *viewNode,
QJsonValue DoricSuperNode::generateDefaultLayoutConfig() { QJsonValue DoricSuperNode::generateDefaultLayoutConfig() {
QJsonObject layoutConfig; QJsonObject layoutConfig;
layoutConfig.insert("widthSpec", 0); layoutConfig.insert("widthSpec", SpecMode::JUST);
layoutConfig.insert("heightSpec", 0); layoutConfig.insert("heightSpec", SpecMode::JUST);
return layoutConfig; return layoutConfig;
} }

View File

@ -12,28 +12,28 @@ void DoricViewNode::blendLayoutConfig(QJsonValue jsObject) {
if (widthSpec.isDouble()) { if (widthSpec.isDouble()) {
switch (widthSpec.toInt()) { switch (widthSpec.toInt()) {
case 0: case SpecMode::JUST:
mView->setProperty("widthSpec", 0); mView->setProperty("widthSpec", SpecMode::JUST);
break; break;
case 1: case SpecMode::FIT:
mView->setProperty("widthSpec", 1); mView->setProperty("widthSpec", SpecMode::FIT);
break; break;
case 2: case SpecMode::MOST:
mView->setProperty("widthSpec", 2); mView->setProperty("widthSpec", SpecMode::MOST);
break; break;
} }
} }
if (heightSpec.isDouble()) { if (heightSpec.isDouble()) {
switch (heightSpec.toInt()) { switch (heightSpec.toInt()) {
case 0: case SpecMode::JUST:
mView->setProperty("heightSpec", 0); mView->setProperty("heightSpec", SpecMode::JUST);
break; break;
case 1: case SpecMode::FIT:
mView->setProperty("heightSpec", 1); mView->setProperty("heightSpec", SpecMode::FIT);
break; break;
case 2: case SpecMode::MOST:
mView->setProperty("heightSpec", 2); mView->setProperty("heightSpec", SpecMode::MOST);
break; break;
} }
} }
@ -87,7 +87,7 @@ void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
} else { } else {
QJsonValue widthSpec = this->mLayoutConfig["widthSpec"]; QJsonValue widthSpec = this->mLayoutConfig["widthSpec"];
if (widthSpec.isDouble()) { if (widthSpec.isDouble()) {
if (widthSpec.toInt() == 0) { if (widthSpec.toInt() == SpecMode::JUST) {
view->setWidth(prop.toInt()); view->setWidth(prop.toInt());
} }
} }
@ -101,7 +101,7 @@ void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
} else { } else {
QJsonValue heightSpec = this->mLayoutConfig["heightSpec"]; QJsonValue heightSpec = this->mLayoutConfig["heightSpec"];
if (heightSpec.isDouble()) { if (heightSpec.isDouble()) {
if (heightSpec.toInt() == 0) { if (heightSpec.toInt() == SpecMode::JUST) {
view->setHeight(prop.toInt()); view->setHeight(prop.toInt());
} }
} }

View File

@ -1,12 +1,19 @@
#ifndef DORICVIEWNODE_H #ifndef DORICVIEWNODE_H
#define DORICVIEWNODE_H #define DORICVIEWNODE_H
#include <QQuickItem>
#include <QJsonValue>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonValue>
#include <QQuickItem>
#include "../utils/DoricContextHolder.h" #include "../utils/DoricContextHolder.h"
class SpecMode {
public:
const static int JUST = 0;
const static int FIT = 1;
const static int MOST = 2;
};
class DoricSuperNode; class DoricSuperNode;
class DoricViewNode : public DoricContextHolder { class DoricViewNode : public DoricContextHolder {