Commit 4b4eeaa6 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Fix ComboList for Qt 5.12

Also fix most of QML warnings on anchors (parent null)
parent aecb0195
Pipeline #984 passed with stage
in 30 seconds
......@@ -57,14 +57,14 @@ Item {
target: lbl;
anchors {
left: ico.right;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
AnchorChanges {
target: ico;
anchors {
left: parent.left;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
},
......@@ -75,8 +75,8 @@ Item {
AnchorChanges {
target: lbl;
anchors {
verticalCenter: parent.verticalCenter;
horizontalCenter: parent.horizontalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
horizontalCenter: (parent ? parent.horizontalCenter : undefined);
}
}
}
......
......@@ -60,7 +60,7 @@ MouseArea {
visible: (sourceComponent !== null);
anchors {
top: parent.top;
horizontalCenter: parent.horizontalCenter;
horizontalCenter: (parent ? parent.horizontalCenter : undefined);
}
}
}
......
......@@ -89,7 +89,7 @@ Item {
: Style.colorForeground)
: Style.colorBorder);
symbol: Style.symbolArrowLeft;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
MouseArea {
id: clickerPrevYear;
......@@ -102,7 +102,7 @@ Item {
MouseArea {
implicitWidth: editYear.implicitWidth;
implicitHeight: editYear.implicitHeight
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onClicked: {
editYear.visible = true;
editYear.forceActiveFocus ();
......@@ -139,7 +139,7 @@ Item {
: Style.colorForeground)
: Style.colorBorder);
symbol: Style.symbolArrowRight;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
MouseArea {
id: clickerNextYear;
......@@ -161,7 +161,7 @@ Item {
: Style.colorForeground)
: Style.colorBorder);
symbol: Style.symbolArrowLeft;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
MouseArea {
id: clickerPrevMonth;
......@@ -175,7 +175,7 @@ Item {
text: Qt.locale ().monthName (currentMonth -1, Locale.LongFormat);
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Style.fontSizeBig;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
Stretcher { }
SymbolLoader {
......@@ -186,7 +186,7 @@ Item {
: Style.colorForeground)
: Style.colorBorder);
symbol: Style.symbolArrowRight;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
MouseArea {
id: clickerNextMonth;
......@@ -217,7 +217,7 @@ Item {
verticalAlignment: Text.AlignVCenter;
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Style.fontSizeSmall;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
}
......
......@@ -6,7 +6,7 @@ Item {
width: implicitWidth;
height: implicitHeight;
implicitWidth: (dumbLayout.width + arrow.width + padding * 3);
implicitHeight: (loaderCurrent.height + padding * 2);
implicitHeight: (dumbLayout.height / count + padding * 2);
property int padding : Style.spacingNormal;
property bool filterable : false;
......@@ -42,6 +42,23 @@ Item {
return ret;
}
Rectangle {
id: rect;
radius: Style.roundness;
enabled: base.enabled;
antialiasing: radius;
gradient: (enabled
? (clicker.pressed ||
clicker.dropdownItem
? Style.gradientPressed ()
: Style.gradientIdle (Qt.lighter (Style.colorClickable, clicker.containsMouse ? 1.15 : 1.0)))
: Style.gradientDisabled ());
border {
width: Style.lineSize;
color: Style.colorBorder;
}
anchors.fill: parent;
}
StretchColumnContainer {
id: dumbLayout;
opacity: 0;
......@@ -50,32 +67,22 @@ Item {
id: repeater;
model: base.model;
delegate: Loader {
id: loader;
id: loaderDumb;
sourceComponent: base.delegate;
onInstanceChanged: {
if (instance !== null) {
instance.active = true;
instance.model = model;
instance.modelData = model.modelData;
instance.index = Qt.binding (function () { return loaderDumb.idx; });
}
}
readonly property var value : (item ? item ["value"] : undefined);
readonly property var key : (item ? item ["key"] : undefined);
readonly property ComboListDelegate instance : item;
Binding {
target: loader.item;
property: "index";
value: model.index;
}
Binding {
target: loader.item;
property: "model";
value: (typeof (model) !== "undefined" ? model : undefined);
}
Binding {
target: loader.item;
property: "modelData";
value: (typeof (modelData) !== "undefined" ? modelData : undefined);
}
Binding {
target: loader.item;
property: "active";
value: true;
}
readonly property var idx : model.index;
readonly property var value : (instance ? instance.value : undefined);
readonly property var key : (instance ? instance.key : undefined);
}
}
}
......@@ -107,29 +114,6 @@ Item {
}
}
}
PixelPerfectContainer {
contentItem: rect;
anchors.fill: parent;
Rectangle {
id: rect;
width: Math.round (parent.width);
height: Math.round (parent.height);
radius: Style.roundness;
enabled: base.enabled;
antialiasing: radius;
gradient: (enabled
? (clicker.pressed ||
clicker.dropdownItem
? Style.gradientPressed ()
: Style.gradientIdle (Qt.lighter (Style.colorClickable, clicker.containsMouse ? 1.15 : 1.0)))
: Style.gradientDisabled ());
border {
width: Style.lineSize;
color: Style.colorBorder;
}
}
}
Loader {
id: loaderCurrent;
clip: true;
......@@ -141,32 +125,17 @@ Item {
margins: padding;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
Binding {
target: loaderCurrent.item;
property: "index";
value: currentIdx;
}
Binding {
target: loaderCurrent.item;
property: "key";
value: currentKey;
}
Binding {
target: loaderCurrent.item;
property: "value";
value: (currentValue || placeholder);
}
Binding {
target: loaderCurrent.item;
property: "active";
value: false;
}
Binding {
target: loaderCurrent.item;
property: "opacity";
value: (currentKey !== undefined ? 1.0 : 0.65);
onInstanceChanged: {
if (instance !== null) {
instance.active = false;
instance.index = Qt.binding (function () { return base.currentIdx; });
instance.key = Qt.binding (function () { return base.currentKey; });
instance.value = Qt.binding (function () { return (base.currentValue || base.placeholder); });
instance.opacity = Qt.binding (function () { return (base.currentKey !== undefined ? 1.0 : 0.65); });
}
}
readonly property ComboListDelegate instance : item;
}
SymbolLoader {
id: arrow;
......@@ -297,18 +266,20 @@ Item {
id: repeaterDropdown;
model: base.model;
delegate: MouseArea {
width: implicitWidth;
height: implicitHeight;
id: dlg;
visible: frame.matches (loader.instance.value);
hoverEnabled: Style.useHovering;
implicitWidth: (loader.width + padding * 2);
implicitHeight: (loader.height + padding * 2);
implicitWidth: (loader.implicitWidth + padding * 2);
implicitHeight: (loader.implicitHeight + padding * 2);
onClicked: {
currentIdx = model.index;
currentIdx = idx;
clicker.destroyDropdown ();
}
ExtraAnchors.horizontalFill: parent;
readonly property var idx : model.index;
readonly property bool curr : (idx === base.currentIdx);
Rectangle {
color: Style.colorHighlight;
opacity: 0.65;
......@@ -322,32 +293,20 @@ Item {
sourceComponent: base.delegate;
anchors {
margins: padding;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
ExtraAnchors.horizontalFill: parent;
onInstanceChanged: {
if (instance !== null) {
instance.index = Qt.binding (function () { return dlg.idx; });
instance.active = Qt.binding (function () { return dlg.curr; });
instance.model = model;
instance.modelData = model.modelData;
}
}
readonly property ComboListDelegate instance : item;
}
Binding {
target: loader.item;
property: "index";
value: model.index;
}
Binding {
target: loader.item;
property: "model";
value: (typeof (model) !== "undefined" ? model : undefined);
}
Binding {
target: loader.item;
property: "modelData";
value: (typeof (modelData) !== "undefined" ? modelData : undefined);
}
Binding {
target: loader.item;
property: "active";
value: (model.index === base.currentIdx);
}
}
}
}
......
......@@ -3,12 +3,10 @@ import QtQmlTricks.UiElements 2.0;
ComboListDelegate {
id: base;
key: (modelData ? modelData [attributeKey] : undefined);
value: (modelData ? modelData [attributeValue] : "");
width: implicitWidth;
height: implicitHeight;
implicitWidth: lbl.contentWidth;
implicitHeight: lbl.contentHeight;
key: (base.modelData ? base.modelData [base.attributeKey] : undefined);
value: (base.modelData ? base.modelData [base.attributeValue] : "");
implicitWidth: lbl.implicitWidth;
implicitHeight: lbl.implicitHeight;
property string attributeKey : "key";
property string attributeValue : "value";
......
......@@ -3,12 +3,10 @@ import QtQmlTricks.UiElements 2.0;
ComboListDelegate {
id: base;
key: (model ? model [roleKey] : undefined);
value: (model ? model [roleValue] : "");
width: implicitWidth;
height: implicitHeight;
implicitWidth: lbl.contentWidth;
implicitHeight: lbl.contentHeight;
key: (base.model ? base.model [base.roleKey] : undefined);
value: (base.model ? base.model [base.roleValue] : "");
implicitWidth: lbl.implicitWidth;
implicitHeight: lbl.implicitHeight;
property string roleKey : "key";
property string roleValue : "value";
......
......@@ -3,12 +3,10 @@ import QtQmlTricks.UiElements 2.0;
ComboListDelegate {
id: base;
key: modelData;
value: (modelData ? modelData : "");
width: implicitWidth;
height: implicitHeight;
implicitWidth: lbl.contentWidth;
implicitHeight: lbl.contentHeight;
key: base.modelData;
value: (base.modelData ? base.modelData : "");
implicitWidth: lbl.implicitWidth;
implicitHeight: lbl.implicitHeight;
readonly property alias label : lbl;
......
......@@ -53,7 +53,7 @@ FocusScope {
model: FileSystem.drivesList;
visible: (FileSystem.rootPath !== "/");
delegate: ComboListDelegateForSimpleVar { }
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onCurrentKeyChanged: {
if (currentKey !== undefined && currentKey !== "" && ready) {
rootFolder = currentKey;
......@@ -70,14 +70,14 @@ FocusScope {
Stretcher {
height: implicitHeight;
implicitHeight: path.height;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
TextLabel {
id: path;
text: folder;
wrapMode: Text.WrapAtWordBoundaryOrAnywhere;
font.pixelSize: Style.fontSizeSmall;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
ExtraAnchors.horizontalFill: parent;
}
}
......@@ -89,7 +89,7 @@ FocusScope {
size: Style.iconSize (1);
color: Style.colorForeground;
}
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onClicked: { goToFolder (FileSystem.parentDir (folder)); }
}
}
......@@ -144,7 +144,7 @@ FocusScope {
anchors {
left: parent.left;
margins: Style.spacingNormal;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
TextLabel {
......@@ -157,7 +157,7 @@ FocusScope {
left: img.right;
right: parent.right;
margins: Style.spacingNormal;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
}
......@@ -168,14 +168,14 @@ FocusScope {
TextLabel {
text: qsTr ("Name :");
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
TextBox {
id: inputName;
focus: true;
enabled: (selectionType & selectAllowNew);
implicitWidth: -1;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onAccepted: { base.fileNameReturned (); }
readonly property string value : (text.trim ());
......
......@@ -336,14 +336,14 @@ Group {
visible: (sourceComponent !== null);
rotation: -parent.rotation;
sourceComponent: base.icon;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
TextLabel {
text: base.title;
visible: (text !== "");
font.pixelSize: Style.fontSizeBig;
font.capitalization: Font.SmallCaps;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
Stretcher { }
}
......@@ -387,7 +387,7 @@ Group {
spacing: Style.spacingNormal;
anchors {
margins: Style.spacingNormal;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
ExtraAnchors.horizontalFill: parent;
......@@ -396,12 +396,12 @@ Group {
enabled: base.enabled;
visible: (sourceComponent !== null);
sourceComponent: base.icon;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
}
Stretcher {
height: implicitHeight;
implicitHeight: lbl.implicitHeight;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
TextLabel {
id: lbl;
......@@ -422,7 +422,7 @@ Group {
}
visible: detachable;
padding: (Style.lineSize * 2);
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onClicked: { detach (); }
}
TextButton {
......@@ -442,7 +442,7 @@ Group {
}
visible: collapsable;
padding: (Style.lineSize * 2);
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
onClicked: { collapse (); }
}
}
......
......@@ -27,7 +27,7 @@ Item {
Item {
id: bar;
height: barSize;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
ExtraAnchors.horizontalFill: parent;
Rectangle {
......
......@@ -51,7 +51,7 @@ ProgressJauge {
width: Style.lineSize;
color: Style.colorBorder;
}
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
Binding on x {
when: !clicker.pressed;
......
......@@ -14,7 +14,7 @@ Rectangle {
id: layout;
spacing: Style.spacingNormal;
anchors.margins: Style.spacingNormal;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
ExtraAnchors.horizontalFill: parent;
// NOTE : CONTENT GOES HERE
......
......@@ -220,7 +220,7 @@ QtObject {
antialiasing: true;
anchors {
verticalCenter: parent.top;
horizontalCenter: parent.horizontalCenter;
horizontalCenter: (parent ? parent.horizontalCenter : undefined);
alignWhenCentered: false;
}
}
......@@ -246,7 +246,7 @@ QtObject {
antialiasing: true;
anchors {
verticalCenter: parent.bottom;
horizontalCenter: parent.horizontalCenter;
horizontalCenter: (parent ? parent.horizontalCenter : undefined);
alignWhenCentered: false;
}
}
......@@ -271,7 +271,7 @@ QtObject {
rotation: 45;
antialiasing: true;
anchors {
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
horizontalCenter: parent.right;
alignWhenCentered: false;
}
......@@ -297,7 +297,7 @@ QtObject {
rotation: 45;
antialiasing: true;
anchors {
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
horizontalCenter: parent.left;
alignWhenCentered: false;
}
......
......@@ -65,14 +65,14 @@ Item {
anchors {
left: ico.right;
right: parent.right;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
AnchorChanges {
target: ico;
anchors {
left: parent.left;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
PropertyChanges {
......@@ -94,7 +94,7 @@ Item {
anchors {
left: parent.left;
right: parent.right;
verticalCenter: parent.verticalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
}
}
PropertyChanges {
......@@ -114,8 +114,8 @@ Item {
AnchorChanges {
target: ico;
anchors {
verticalCenter: parent.verticalCenter;
horizontalCenter: parent.horizontalCenter;
verticalCenter: (parent ? parent.verticalCenter : undefined);
horizontalCenter: (parent ? parent.horizontalCenter : undefined);
}
}
PropertyChanges {
......
......@@ -24,7 +24,7 @@ AutoRepeatableClicker {
target: ico;
anchors {
left: parent.left;
verticalCenter: parent.verticalCenter;
verticalCenter: (ico && ico.parent ? parent.verticalCenter : undefined);
}
}
AnchorChanges {
......@@ -32,7 +32,7 @@ AutoRepeatableClicker {
anchors {
left: ico.right;
right: parent.right;
verticalCenter: parent.verticalCenter;
verticalCenter: (lbl && lbl.parent ? parent.verticalCenter : undefined);
}
}
},
......@@ -52,14 +52,14 @@ AutoRepeatableClicker {
anchors {
left: parent.left;
right: ico.left;
verticalCenter: parent.verticalCenter;
verticalCenter: (lbl && lbl.parent ? parent.verticalCenter : undefined);
}
}
AnchorChanges {
target: ico;
anchors {
right: parent.right;
verticalCenter: parent.verticalCenter;
verticalCenter: (ico && ico.parent ? parent.verticalCenter : undefined);
}
}
},
......@@ -75,8 +75,8 @@ AutoRepeatableClicker {
AnchorChanges {
target: lbl;
anchors {
verticalCenter: parent.verticalCenter;
horizontalCenter: parent.horizontalCenter;
verticalCenter: (lbl && lbl.parent ? parent.verticalCenter : undefined);
horizontalCenter: (lbl && lbl.parent ? parent.horizontalCenter : undefined);
}
}
},
......@@ -92,8 +92,8 @@ AutoRepeatableClicker {
AnchorChanges {
target: ico;
anchors {
verticalCenter: parent.verticalCenter;
horizontalCenter: parent.horizontalCenter;
verticalCenter: (ico && ico.parent ? parent.verticalCenter : undefined);
horizontalCenter: (ico && ico.parent ? parent.horizontalCenter : undefined);
}
}
},
......@@ -133,8 +133,8 @@ AutoRepeatableClicker {
}
Binding {
target: (ico.item && "color" in ico.item ? ico.item : null);
when: (autoColorIcon && ico.item)
target: ico.item;
when: (autoColorIcon && ico.item && "color" in ico.item);
property: "color";
value: textColor;
}
......
......@@ -32,7 +32,7 @@ Item {
StretchColumnContainer {
spacing: Style.spacingSmall;
anchors.verticalCenter: parent.verticalCenter;
anchors.verticalCenter: (parent ? parent.verticalCenter : undefined);
SymbolLoader {
size: Style.fontSizeNormal;
......@@ -42,7 +42,7 @@ Item {
: Style.colorForeground)
: Style.colorBorder);
symbol: Style.symbolArrowUp;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.horizontalCenter: (parent ? parent.horizontalCenter : undefined);
AutoRepeatableClicker {
id: clickerIncrHours;
......@@ -57,7 +57,7 @@ Item {
textAlign: TextInput.AlignHCenter;
validator: IntValidator { top: 23; bottom: 0; }
implicitWidth: metrics.width;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.horizontalCenter: (parent ? parent.horizontalCenter : undefined);