New QmlDesigner plugin & Design mode
This adds a new "Design" mode that can be used to manipulate qml files in a visual way. It will only get build if you have the declarativeui module in Qt. This is a squashed import from the Bauhaus project. Share & enjoy :)
3
.gitignore
vendored
@@ -73,3 +73,6 @@ bin/qtcreator_process_stub*
|
||||
bin/qtcreator.exe
|
||||
share/doc/qtcreator/qtcreator.qch
|
||||
tests/manual/cplusplus/cplusplus0
|
||||
tests/auto/qml/qmldesigner/bauhaustests/tst_bauhaus
|
||||
tests/auto/qml/qmldesigner/coretests/tst_qmldesigner_core
|
||||
tests/auto/qml/qmldesigner/propertyeditortests/tst_propertyeditor
|
||||
|
||||
86
share/qtcreator/qmldesigner/Button.qml
Normal file
@@ -0,0 +1,86 @@
|
||||
import Qt 4.6
|
||||
|
||||
Rectangle {
|
||||
property var label: "Button"
|
||||
signal clicked
|
||||
|
||||
width: 75
|
||||
height: 20
|
||||
radius: 10
|
||||
color: "grey"
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent;
|
||||
anchors.leftMargin: 1;
|
||||
anchors.rightMargin: 1;
|
||||
anchors.topMargin: 1;
|
||||
anchors.bottomMargin: 1;
|
||||
|
||||
color: "#2c2c2c";
|
||||
radius: 9
|
||||
|
||||
Rectangle {
|
||||
id: buttonGradientRectangle
|
||||
anchors.fill: parent;
|
||||
anchors.leftMargin: 1;
|
||||
anchors.rightMargin: 1;
|
||||
anchors.topMargin: 1;
|
||||
anchors.bottomMargin: 1;
|
||||
|
||||
color: "black";
|
||||
gradient: normalGradient
|
||||
radius: 8;
|
||||
|
||||
Gradient {
|
||||
id: pressedGradient
|
||||
GradientStop { position: 0.0; color: "#686868" }
|
||||
GradientStop { position: 1.0; color: "#8a8a8a" }
|
||||
}
|
||||
|
||||
Gradient {
|
||||
id: normalGradient
|
||||
GradientStop { position: 0.0; color: "#8a8a8a" }
|
||||
GradientStop { position: 1.0; color: "#686868" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
color: "white"
|
||||
text: parent.label
|
||||
style: "Raised";
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
horizontalAlignment: "AlignHCenter";
|
||||
verticalAlignment: "AlignVCenter";
|
||||
}
|
||||
|
||||
MouseRegion {
|
||||
id: mouseRegion
|
||||
anchors.fill: parent
|
||||
onReleased: { parent.clicked.emit(); }
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "released"
|
||||
when: !mouseRegion.pressed
|
||||
|
||||
PropertyChanges {
|
||||
target: buttonGradientRectangle
|
||||
gradient: normalGradient
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "pressed"
|
||||
when: mouseRegion.pressed
|
||||
|
||||
PropertyChanges {
|
||||
target: buttonGradientRectangle
|
||||
gradient: pressedGradient
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
share/qtcreator/qmldesigner/gradient.png
Normal file
|
After Width: | Height: | Size: 332 KiB |
199
share/qtcreator/qmldesigner/propertyeditor/Qt/AnchorBox.qml
Normal file
@@ -0,0 +1,199 @@
|
||||
import Qt 4.6
|
||||
|
||||
QWidget {
|
||||
width:220;fixedWidth: width
|
||||
height:220;fixedHeight: height
|
||||
styleSheetFile: "anchorbox.css"
|
||||
|
||||
Script {
|
||||
function isBorderAnchored() {
|
||||
return anchorBackend.leftAnchored || anchorBackend.topAnchored || anchorBackend.rightAnchored || anchorBackend.bottomAnchored;
|
||||
}
|
||||
|
||||
function fill() {
|
||||
anchorBackend.fill();
|
||||
}
|
||||
|
||||
function breakLayout() {
|
||||
anchorBackend.resetLayout()
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "fill";
|
||||
height:20;fixedHeight: height;
|
||||
x: 0;
|
||||
y: 0;
|
||||
width:200;fixedWidth: width;
|
||||
id: QPushButton1;
|
||||
onReleased: fill();
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "break";
|
||||
y: 200;
|
||||
height:20;fixedHeight: height;
|
||||
width:200;fixedWidth: width;
|
||||
x: 0;
|
||||
id: QPushButton3;
|
||||
onReleased: breakLayout();
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
height:100;fixedHeight: height;
|
||||
text: "left";
|
||||
font.bold: true;
|
||||
x: 16 ;
|
||||
y: 60;
|
||||
//styleSheet: "border-radius:5px; background-color: #ffda82";
|
||||
width:30;fixedWidth: width;
|
||||
id: QPushButton5;
|
||||
checkable: true;
|
||||
checked: anchorBackend.leftAnchored;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.horizontalCentered = false;
|
||||
anchorBackend.leftAnchored = true;
|
||||
} else {
|
||||
anchorBackend.leftAnchored = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "top";
|
||||
font.bold: true;
|
||||
//styleSheet: "border-radius:5px; background-color: #ffda82";
|
||||
height:72;fixedHeight: height;
|
||||
width:100;fixedWidth: width;
|
||||
x: 49;
|
||||
y: 30;
|
||||
id: QPushButton6;
|
||||
checkable: true;
|
||||
checked: anchorBackend.topAnchored;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.verticalCentered = false;
|
||||
anchorBackend.topAnchored = true;
|
||||
} else {
|
||||
anchorBackend.topAnchored = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "right";
|
||||
font.bold: true;
|
||||
x: 153;
|
||||
y: 60;
|
||||
//styleSheet: "border-radius:5px; background-color: #ffda82";
|
||||
width:30;fixedWidth: width;
|
||||
height:100;fixedHeight: height;
|
||||
id: QPushButton7;
|
||||
checkable: true;
|
||||
checked: anchorBackend.rightAnchored;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.horizontalCentered = false;
|
||||
anchorBackend.rightAnchored = true;
|
||||
} else {
|
||||
anchorBackend.rightAnchored = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "bottom";
|
||||
font.bold: true;
|
||||
//styleSheet: "border-radius:5px; background-color: #ffda82";
|
||||
width:100;fixedWidth: width;
|
||||
x: 49;
|
||||
y: 164;
|
||||
height:27;fixedHeight: height;
|
||||
id: QPushButton8;
|
||||
checkable: true;
|
||||
checked: anchorBackend.bottomAnchored;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.verticalCentered = false;
|
||||
anchorBackend.bottomAnchored = true;
|
||||
} else {
|
||||
anchorBackend.bottomAnchored = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QToolButton {
|
||||
width:100;fixedWidth: width;
|
||||
//styleSheet: "border-radius:50px;background-color: rgba(85, 170, 255, 255)";
|
||||
x: 49;
|
||||
y: 60;
|
||||
height:100;fixedHeight: height;
|
||||
id: QPushButton9;
|
||||
|
||||
QPushButton {
|
||||
width:24;fixedWidth: width;
|
||||
//styleSheet: "border-radius:5px; background-color: #bf3f00;";
|
||||
x: 38;
|
||||
y: 2;
|
||||
height:96;fixedHeight: height;
|
||||
checkable: true;
|
||||
id: horizontalCenterButton;
|
||||
checked: anchorBackend.horizontalCentered;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.rightAnchored = false;
|
||||
anchorBackend.leftAnchored = false;
|
||||
anchorBackend.horizontalCentered = true;
|
||||
} else {
|
||||
anchorBackend.horizontalCentered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
height:24;fixedHeight: height;
|
||||
x: 2;
|
||||
y: 38;
|
||||
width:96;fixedWidth: width;
|
||||
id: verticalCenterButton;
|
||||
checkable: true;
|
||||
checked: anchorBackend.verticalCentered;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.topAnchored = false;
|
||||
anchorBackend.bottomAnchored = false;
|
||||
anchorBackend.verticalCentered = true;
|
||||
} else {
|
||||
anchorBackend.verticalCentered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
text: "center";
|
||||
font.bold: true;
|
||||
//styleSheet: "border-radius:20px; background-color: #ff5500";
|
||||
width:40;fixedWidth: width;
|
||||
height:40;fixedHeight: height;
|
||||
x: 30;
|
||||
y: 30;
|
||||
id: centerButton;
|
||||
checkable: true;
|
||||
checked: anchorBackend.verticalCentered && anchorBackend.horizontalCentered;
|
||||
onReleased: {
|
||||
if (checked) {
|
||||
anchorBackend.leftAnchored = false;
|
||||
anchorBackend.topAnchored = false;
|
||||
anchorBackend.rightAnchored = false;
|
||||
anchorBackend.bottomAnchored = false;
|
||||
anchorBackend.verticalCentered = true;
|
||||
anchorBackend.horizontalCentered = true;
|
||||
} else {
|
||||
anchorBackend.verticalCentered = false;
|
||||
anchorBackend.horizontalCentered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 240;
|
||||
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Image";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
bottomMargin: 12;
|
||||
leftMargin: 12;
|
||||
rightMargin: 12;
|
||||
|
||||
FileWidget {
|
||||
enabled: isBaseState || backendValues.id.value != "";
|
||||
maximumWidth: 250;
|
||||
text: "Source: ";
|
||||
fileName: backendValues.source.value;
|
||||
onFileNameChanged: {
|
||||
backendValues.source.value = fileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IntEditor {
|
||||
id: pixelSize;
|
||||
backendValue: backendValues.border_left;
|
||||
caption: "Border Left: "
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
backendValue: backendValues.border_right;
|
||||
caption: "Border Right: "
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
backendValue: backendValues.border_top;
|
||||
caption: "Border Top: "
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
backendValue: backendValues.border_bottom;
|
||||
caption: "Border Bottom:"
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
share/qtcreator/qmldesigner/propertyeditor/Qt/CheckBox.qml
Normal file
@@ -0,0 +1,38 @@
|
||||
import Qt 4.6
|
||||
|
||||
QCheckBox { //This is a special CheckBox that does color coding for states
|
||||
id: CheckBox;
|
||||
|
||||
property var backendValue;
|
||||
property var baseStateFlag;
|
||||
|
||||
checkable: true;
|
||||
checked: backendValue.value === undefined ? false : backendValue.value;
|
||||
onToggled: {
|
||||
backendValue.value = checked;
|
||||
}
|
||||
|
||||
onBaseStateFlagChanged: {
|
||||
evaluate();
|
||||
}
|
||||
|
||||
onBackendValueChanged: {
|
||||
evaluate();
|
||||
}
|
||||
|
||||
Script {
|
||||
function evaluate() {
|
||||
if (baseStateFlag) {
|
||||
if (backendValue.isInModel)
|
||||
CheckBox.setStyleSheet("color: white;");
|
||||
else
|
||||
CheckBox.setStyleSheet("color: gray;");
|
||||
} else {
|
||||
if (backendValue.IsInSubState)
|
||||
CheckBox.setStyleSheet("color: blue;");
|
||||
else
|
||||
CheckBox.setStyleSheet("color: gray;");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 200;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Grid";
|
||||
id: GridSpecifics;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 18;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 8;
|
||||
rightMargin: 8;
|
||||
|
||||
|
||||
IntEditor {
|
||||
id: spacing;
|
||||
backendValue: backendValues.spacing;
|
||||
caption: "Spacing: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
144
share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml
Normal file
@@ -0,0 +1,144 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QWidget { //This is a special DoubleSpinBox that does color coding for states
|
||||
id: DoubleSpinBox;
|
||||
|
||||
property var backendValue;
|
||||
property var baseStateFlag;
|
||||
property alias singleStep: box.singleStep
|
||||
property alias minimum: box.minimum
|
||||
property alias maximum: box.maximum
|
||||
|
||||
minimumHeight: 22;
|
||||
|
||||
onBaseStateFlagChanged: {
|
||||
evaluate();
|
||||
setIcon();
|
||||
}
|
||||
|
||||
onBackendValueChanged: {
|
||||
evaluate();
|
||||
setIcon();
|
||||
}
|
||||
|
||||
Script {
|
||||
function evaluate() {
|
||||
if (baseStateFlag) {
|
||||
if (backendValue != null && backendValue.isInModel)
|
||||
DoubleSpinBox.setStyleSheet("color: white;");
|
||||
else
|
||||
DoubleSpinBox.setStyleSheet("color: gray;");
|
||||
} else {
|
||||
if (backendValue != null && backendValue.isInSubState)
|
||||
DoubleSpinBox.setStyleSheet("color: blue;");
|
||||
else
|
||||
DoubleSpinBox.setStyleSheet("color: gray;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 2;
|
||||
spacing: 0;
|
||||
|
||||
QDoubleSpinBox {
|
||||
id: box;
|
||||
decimals: 2;
|
||||
keyboardTracking: false;
|
||||
enabled: (backendValue == null || backendValue.complexNode == null) ? false : !backendValue.isBound && !backendValue.complexNode.exists
|
||||
value: DoubleSpinBox.backendValue == null ? .0 : DoubleSpinBox.backendValue.value;
|
||||
onValueChanged: {
|
||||
if (DoubleSpinBox.backendValue != null)
|
||||
DoubleSpinBox.backendValue.value = value;
|
||||
}
|
||||
onFocusChanged: {
|
||||
//extendedSwitches.active = focus;
|
||||
//extendedSwitches.backendValue = backendValue;
|
||||
}
|
||||
|
||||
onMouseOverChanged: {
|
||||
//extendedButton.active = mouseOver;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QToolButton {
|
||||
property bool active: false;
|
||||
id: extendedButton;
|
||||
iconFromFile: "images/expression.png";
|
||||
visible: false;
|
||||
width: 14;
|
||||
height: 14;
|
||||
y: box.y + 2;
|
||||
x: box.x + 2;
|
||||
focusPolicy: "Qt::NoFocus";
|
||||
opacity: 0;
|
||||
|
||||
opacity: Behavior {
|
||||
NumberAnimation {
|
||||
easing: "easeInSine"
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
|
||||
}
|
||||
|
||||
Script {
|
||||
function setIcon() {
|
||||
if (backendValue == null)
|
||||
extendedButton.iconFromFile = "images/placeholder.png"
|
||||
else if (backendValue.isBound) {
|
||||
extendedButton.iconFromFile = "images/expression.png"
|
||||
} else {
|
||||
if (backendValue.complexNode != null && backendValue.complexNode.exists) {
|
||||
extendedButton.iconFromFile = "images/behaivour.png"
|
||||
} else {
|
||||
extendedButton.iconFromFile = "images/placeholder.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMouseOverChanged: {
|
||||
if (mouseOver) {
|
||||
iconFromFile = "images/submenu.png";
|
||||
opacity = 1;
|
||||
} else {
|
||||
setIcon();
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
setIcon();
|
||||
opacity = 1;
|
||||
} else {
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
menu: QMenu {
|
||||
actions: [
|
||||
QAction {
|
||||
text: "Reset";
|
||||
},
|
||||
QAction {
|
||||
text: "Set Expression";
|
||||
},
|
||||
QAction {
|
||||
text: "Add Behaivour";
|
||||
}
|
||||
]
|
||||
}
|
||||
toolButtonStyle: "Qt::ToolButtonIconOnly";
|
||||
popupMode: "QToolButton::InstantPopup";
|
||||
arrowType: "Qt::NoArrow";
|
||||
}
|
||||
}
|
||||
191
share/qtcreator/qmldesigner/propertyeditor/Qt/Extended.qml
Normal file
@@ -0,0 +1,191 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
caption: "Effects"
|
||||
id: Extended;
|
||||
maximumHeight: 260;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
property var effect: backendValues == null || backendValues.effect === undefined ? null : backendValues.effect
|
||||
property var complexNode : effect === null ? null : effect.complexNode
|
||||
|
||||
QWidget {
|
||||
maximumHeight: 40;
|
||||
layout: QHBoxLayout {
|
||||
QLabel {
|
||||
text: "Effects: ";
|
||||
font.bold: true;
|
||||
}
|
||||
QComboBox {
|
||||
enabled: isBaseState;
|
||||
property var type: complexNode == null ? null : complexNode.type
|
||||
property var dirty;
|
||||
id: effectComboBox;
|
||||
items : { [
|
||||
"None",
|
||||
"Blur",
|
||||
"Opacity",
|
||||
"Colorize",
|
||||
"DropShadow"
|
||||
] }
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (dirty) //avoid recursion;
|
||||
return;
|
||||
if (complexNode != null && complexNode.exists)
|
||||
complexNode.remove();
|
||||
if (currentText == "None") {
|
||||
;
|
||||
} else if (complexNode != null) {
|
||||
complexNode.add("Qt/" + currentText);
|
||||
}
|
||||
}
|
||||
|
||||
onTypeChanged: {
|
||||
dirty = true;
|
||||
if (complexNode != null && complexNode.type != "")
|
||||
currentText = complexNode.type;
|
||||
else
|
||||
currentText = "None";
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}// QWidget
|
||||
|
||||
property var properties: complexNode == null ? null : complexNode.properties
|
||||
|
||||
QWidget {
|
||||
minimumHeight: 20;
|
||||
layout: QVBoxLayout {
|
||||
|
||||
QWidget {
|
||||
visible: effectComboBox.currentText == "Blur";
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
IntEditor {
|
||||
id: blurRadius;
|
||||
backendValue: properties == null ? null : properties.blurRadius;
|
||||
caption: "Blur Radius:"
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
visible: effectComboBox.currentText == "Opacity";
|
||||
layout: QVBoxLayout {
|
||||
DoubleSpinBox {
|
||||
id: OpcacityEffectSpinBox;
|
||||
objectName: "OpcacityEffectSpinBox";
|
||||
backendValue: properties == null ? null : properties.opacity;
|
||||
minimum: 0;
|
||||
maximum: 1;
|
||||
singleStep: 0.1;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
visible: effectComboBox.currentText == "Colorize";
|
||||
layout: QVBoxLayout {
|
||||
|
||||
property var colorProp: properties == null ? null : properties.color
|
||||
|
||||
ColorWidget {
|
||||
id: ColorizeColor;
|
||||
text: "Color:";
|
||||
minimumHeight: 20;
|
||||
minimumWidth: 20;
|
||||
color: (colorProp == null) ? "black" : colorProp.value;
|
||||
onColorChanged: {
|
||||
colorProp.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
visible: effectComboBox.currentText == "Pixelize";
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
IntEditor {
|
||||
id: pixelSize;
|
||||
backendValue: properties == null ? null : properties.pixelSize;
|
||||
caption: "Pixel Size:"
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
visible: effectComboBox.currentText == "DropShadow";
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 12;
|
||||
IntEditor {
|
||||
id: blurRadiusShadow;
|
||||
backendValue: properties == null ? null : properties.blurRadius;
|
||||
caption: "Blur Radius:"
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 20;
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
id: DropShadowColor;
|
||||
maximumHeight: 40;
|
||||
text: "Color:";
|
||||
minimumHeight: 20;
|
||||
minimumWidth: 20;
|
||||
color: properties == null || properties.color == null ? "black" : properties.color.value
|
||||
onColorChanged: {
|
||||
if (properties != null && properties.color != null)
|
||||
properties.color.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
id: xOffset;
|
||||
backendValue: properties == null ? 0 : properties.xOffset;
|
||||
caption: "x Offset: "
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 20;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
id: yOffset;
|
||||
backendValue: properties == null ? 0 : properties.yOffset;
|
||||
caption: "y Offset: "
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} //QVBoxLayout
|
||||
} //GroupBox
|
||||
@@ -0,0 +1,30 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QScrollArea {
|
||||
widgetResizable: true;
|
||||
styleSheetFile: ":/qmldesigner/scrollbar.css";
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: ExtendedPane;
|
||||
visible: false;
|
||||
visible: false;
|
||||
content: ProperyEditorExtended;
|
||||
QFrame {
|
||||
minimumHeight: 440;
|
||||
id: ProperyEditorExtended
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
Extended {
|
||||
id: extendedBox;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QFrame {
|
||||
visible: false;
|
||||
focusPolicy: "Qt::NoFocus"
|
||||
id: extendedSwitches;
|
||||
property bool active: false;
|
||||
property var backendValue;
|
||||
styleSheetFile: "switch.css";
|
||||
property var specialModeIcon;
|
||||
specialModeIcon: "images/standard.png";
|
||||
|
||||
opacity: 0;
|
||||
|
||||
opacity: Behavior {
|
||||
NumberAnimation {
|
||||
easing: "easeInSine"
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (!nameLineEdit.focus)
|
||||
if (active) {
|
||||
opacity = 1;
|
||||
} else {
|
||||
opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 4;
|
||||
leftMargin: 10;
|
||||
rightMargin: 8;
|
||||
spacing: 4;
|
||||
|
||||
QPushButton {
|
||||
focusPolicy: "Qt::NoFocus"
|
||||
onReleased: backendValue.resetValue();
|
||||
iconFromFile: "images/reset-button.png";
|
||||
toolTip: "reset property";
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
id: nameLineEdit;
|
||||
readOnly: false;
|
||||
//focusPolicy: "Qt::NoFocus"
|
||||
text: backendValue == null ? "" : backendValue.expression;
|
||||
onEditingFinished: {
|
||||
if (backendValue != null)
|
||||
backendValue.expression = text;
|
||||
}
|
||||
onFocusChanged: {
|
||||
extendedSwitches.active = focus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
finished: finishedNotify;
|
||||
caption: "Flickable";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 15;
|
||||
bottomMargin: 6;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
id: contentWidget;
|
||||
maximumHeight: 220;
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "Horizontal Velocity:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "Vertical Velocity:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "Maximum Flick Velocity:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "Over Shoot:"
|
||||
font.bold: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
|
||||
DoubleSpinBox {
|
||||
id: HorizontalVelocitySpinBox;
|
||||
objectName: "HorizontalVelocitySpinBox";
|
||||
backendValue: backendValues.horizontalVelocity;
|
||||
minimumWidth: 30;
|
||||
minimum: 0.1
|
||||
maximum: 10
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
|
||||
DoubleSpinBox {
|
||||
id: VerticalVelocitySpinBox;
|
||||
objectName: "VerticalVelocitySpinBox";
|
||||
backendValue: backendValues.verticalVelocity;
|
||||
minimumWidth: 30;
|
||||
minimum: 0.1
|
||||
maximum: 10
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
|
||||
DoubleSpinBox {
|
||||
id: MaximumVelocitySpinBox;
|
||||
objectName: "MaximumVelocitySpinBox";
|
||||
backendValue: backendValues.maximumFlickVelocity;
|
||||
minimumWidth: 30;
|
||||
minimum: 0.1
|
||||
maximum: 10
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: OvershootCheckBox;
|
||||
text: "overshoot";
|
||||
backendValue: backendValues.overShoot;
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 200;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Text";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
id: textSpecifics;
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 4;
|
||||
rightMargin: 4;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 8;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "Text:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLineEdit {
|
||||
text: backendValues.text.value;
|
||||
onTextChanged: {
|
||||
backendValues.text.value = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "wrap:"
|
||||
font.bold: true;
|
||||
}
|
||||
QCheckBox {
|
||||
|
||||
text: "isWrapping";
|
||||
checkable: true;
|
||||
checked: backendValues.wrap.value;
|
||||
onToggled: {
|
||||
backendValues.wrap.value = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontWidget {
|
||||
text: "Font:";
|
||||
dataFont: backendValues.font.value;
|
||||
onDataFontChanged: {
|
||||
backendValues.font.value = dataFont;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLabel {
|
||||
styleSheet: "QLabel {font: normal }";
|
||||
text: backendValues.horizontalAlignment.value;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignLeft", "AlignRight", "AlignHCenter"] }
|
||||
currentText: backendValues.hAlign.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.horizontalAlignment.value;
|
||||
print(currentText);
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
print("set");
|
||||
print(currentText);
|
||||
backendValues.horizontalAlignment.value = currentText;
|
||||
print(currentText);
|
||||
print("set");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLine {
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
ColorWidget {
|
||||
text: "Color:";
|
||||
color: backendValues.color.value;
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
}
|
||||
ColorWidget {
|
||||
text: "Style color:";
|
||||
color: backendValues.styleColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.styleColor.value = strColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
173
share/qtcreator/qmldesigner/propertyeditor/Qt/Geometry.qml
Normal file
@@ -0,0 +1,173 @@
|
||||
import Qt 4.6
|
||||
|
||||
GroupBox {
|
||||
finished: finishedNotify;
|
||||
id: Geometry;
|
||||
caption: "Geometry";
|
||||
|
||||
maximumHeight: 240;
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 14;
|
||||
bottomMargin: 4;
|
||||
leftMargin: 4;
|
||||
rightMargin: 4;
|
||||
|
||||
QWidget {
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 60;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
spacing: 25;
|
||||
|
||||
QLabel {
|
||||
text: "Position:";
|
||||
font.bold: true;
|
||||
}
|
||||
QLabel {
|
||||
text: "Size:"
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
|
||||
//---
|
||||
|
||||
QWidget { // 1
|
||||
layout: QHBoxLayout { //2
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
QWidget { //3
|
||||
layout: QVBoxLayout { //4
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
DoubleSpinBox {
|
||||
id: XSpinBox;
|
||||
singleStep: 1;
|
||||
objectName: "XSpinBox";
|
||||
enabled: anchorBackend.hasParent;
|
||||
backendValue: backendValues.x == undefined ? 0 : backendValues.x
|
||||
minimum: -2000;
|
||||
maximum: 2000;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QLabel { //6
|
||||
text: "X";
|
||||
alignment: "Qt::AlignHCenter"
|
||||
font.bold: true;
|
||||
} // 6
|
||||
} //QHBoxLayout //4
|
||||
} //QWidget //3
|
||||
QWidget { // 7
|
||||
layout: QVBoxLayout { //8
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
|
||||
DoubleSpinBox {
|
||||
id: YSpinBox;
|
||||
singleStep: 1;
|
||||
objectName: "YSpinBox";
|
||||
backendValue: backendValues.y == undefined ? 0 : backendValues.y
|
||||
enabled: anchorBackend.hasParent;
|
||||
minimum: -2000;
|
||||
maximum: 2000;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QLabel { //10
|
||||
text: "Y";
|
||||
alignment: "Qt::AlignHCenter";
|
||||
font.bold: true;
|
||||
} //10
|
||||
} //QVBoxLayout //8
|
||||
} // QWidget //3
|
||||
|
||||
} //QHBoxLayout //7
|
||||
} //QWidget //1
|
||||
//---
|
||||
} //QHBoxLayout
|
||||
} //GroupBox
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 10;
|
||||
//---
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
DoubleSpinBox {
|
||||
id: WidthSpinBox;
|
||||
singleStep: 1;
|
||||
objectName: "WidthSpinBox";
|
||||
backendValue: backendValues.width == undefined ? 0 : backendValues.width
|
||||
minimum: -2000;
|
||||
maximum: 2000;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QLabel {
|
||||
text: "Width";
|
||||
alignment: "Qt::AlignHCenter";
|
||||
font.bold: true;
|
||||
}
|
||||
} //QVBoxLayout
|
||||
} //QWidget
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
DoubleSpinBox {
|
||||
id: HeightSpinBox;
|
||||
singleStep: 1;
|
||||
objectName: "HeightSpinBox";
|
||||
backendValue: backendValues.height == undefined ? 0 : backendValues.height
|
||||
minimum: -2000;
|
||||
maximum: 2000;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QLabel {
|
||||
id: HeightLabel;
|
||||
text: "Height";
|
||||
alignment: "Qt::AlignHCenter";
|
||||
font.bold: true;
|
||||
}
|
||||
} //QVBoxLayout
|
||||
} //QWidget
|
||||
} //QHBoxLayout
|
||||
} //QWidget
|
||||
//---
|
||||
|
||||
} // QHBoxLayout
|
||||
} //Widget
|
||||
|
||||
IntEditor {
|
||||
id: borderWidth;
|
||||
backendValue: backendValues.z == undefined ? 0 : backendValues.z
|
||||
caption: "z:"
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 100;
|
||||
}
|
||||
} //QVBoxLayout
|
||||
|
||||
} //QWidget
|
||||
|
||||
|
||||
} //QHBoxLayout
|
||||
|
||||
} //QGroupBox
|
||||
@@ -0,0 +1,49 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 200;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Grid";
|
||||
id: GridSpecifics;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 18;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 8;
|
||||
rightMargin: 8;
|
||||
|
||||
|
||||
IntEditor {
|
||||
id: spacing;
|
||||
backendValue: backendValues.spacing;
|
||||
caption: "Spacing: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
id: rows;
|
||||
backendValue: backendValues.rows;
|
||||
caption: "Rows: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
id: columns;
|
||||
backendValue: backendValues.columns;
|
||||
caption: "Columns: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
share/qtcreator/qmldesigner/propertyeditor/Qt/GroupBox.qml
Normal file
@@ -0,0 +1,57 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QExtGroupBox {
|
||||
id: GroupBox;
|
||||
|
||||
property var finished;
|
||||
|
||||
property var caption;
|
||||
|
||||
property var oldMaximumHeight;
|
||||
|
||||
onFinishedChanged: {
|
||||
CheckBox.raise();
|
||||
maximumHeight = height;
|
||||
oldMaximumHeight = maximumHeight;
|
||||
visible = false;
|
||||
visible = true;
|
||||
x = 6;
|
||||
}
|
||||
|
||||
QToolButton {
|
||||
//QCheckBox {
|
||||
id: CheckBox;
|
||||
text: "";
|
||||
focusPolicy: "Qt::NoFocus";
|
||||
styleSheetFile: "specialCheckBox.css";
|
||||
y: 4;
|
||||
x: 6;
|
||||
height: 12;
|
||||
width: 12;
|
||||
arrowType: "Qt::DownArrow";
|
||||
toolButtonStyle: "Qt::ToolButtonTextBesideIcon";
|
||||
checkable: true;
|
||||
checked: true;
|
||||
font.bold: true;
|
||||
onClicked: {
|
||||
if (checked) {
|
||||
//GroupBox.maximumHeight = oldMaximumHeight;
|
||||
collapsed = false;
|
||||
text = "";
|
||||
width = 12;
|
||||
x = 6;
|
||||
arrowType = "Qt::DownArrow";
|
||||
} else {
|
||||
//GroupBox.maximumHeight = 20;
|
||||
|
||||
collapsed = true;
|
||||
text = GroupBox.caption;
|
||||
visible = true;
|
||||
width = 120;
|
||||
x = 2;
|
||||
arrowType = "Qt::RightArrow";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QExtGroupBox {
|
||||
id: GroupBoxOption;
|
||||
|
||||
property var finished;
|
||||
|
||||
property var caption;
|
||||
|
||||
property var oldMaximumHeight;
|
||||
|
||||
onFinishedChanged: {
|
||||
CheckBox.raise();
|
||||
maximumHeight = height;
|
||||
oldMaximumHeight = maximumHeight;
|
||||
minimumHeight = height;
|
||||
x = 6;
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import Qt 4.6
|
||||
|
||||
QLineEdit {
|
||||
text: "";
|
||||
readOnly: true;
|
||||
maximumHeight: 2;
|
||||
styleSheet: "QLineEdit {border: 2px solid #3F3F3F;}";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 240;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Image";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
bottomMargin: 12;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
|
||||
FileWidget {
|
||||
enabled: isBaseState || backendValues.id.value != "";
|
||||
maximumWidth: 250;
|
||||
text: "Source: ";
|
||||
fileName: backendValues.source.value;
|
||||
onFileNameChanged: {
|
||||
backendValues.source.value = fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
share/qtcreator/qmldesigner/propertyeditor/Qt/IntEditor.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QWidget {
|
||||
id: IntEditor;
|
||||
|
||||
property var backendValue;
|
||||
property var baseStateFlag;
|
||||
|
||||
property var caption;
|
||||
|
||||
property var maximumValue: 99
|
||||
property var minimumValue: 0
|
||||
property var step: 1
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
QLabel {
|
||||
text: caption
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
backendValue: IntEditor.backendValue;
|
||||
minimum: minimumValue;
|
||||
maximum: maximumValue;
|
||||
baseStateFlag: IntEditor.baseStateFlag;
|
||||
}
|
||||
|
||||
|
||||
QSlider {
|
||||
property alias backendValue: IntEditor.backendValue
|
||||
orientation: "Qt::Horizontal";
|
||||
minimum: minimumValue
|
||||
maximum: maximumValue
|
||||
singleStep: step
|
||||
|
||||
value: (backendValue == undefined
|
||||
|| backendValue == null
|
||||
|| backendValue.value == undefined
|
||||
|| backendValue.value == null) ? 0 : backendValue.value
|
||||
onValueChanged: {
|
||||
if (backendValue != undefined && backendValue != null)
|
||||
backendValue.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
104
share/qtcreator/qmldesigner/propertyeditor/Qt/ItemPane.qml
Normal file
@@ -0,0 +1,104 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
PropertyFrame {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
spacing: 0;
|
||||
|
||||
Switches {
|
||||
}
|
||||
|
||||
ExtendedSwitches {
|
||||
id: extendedSwitches;
|
||||
}
|
||||
|
||||
ScrollArea {
|
||||
styleSheetFile: ":/qmldesigner/scrollbar.css";
|
||||
widgetResizable: true;
|
||||
|
||||
finished: finishedNotify;
|
||||
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: standardPane;
|
||||
|
||||
|
||||
content: ProperyEditorStandard;
|
||||
QFrame {
|
||||
minimumHeight: 1100;
|
||||
id: ProperyEditorStandard
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
Geometry {
|
||||
}
|
||||
|
||||
Modifiers {
|
||||
|
||||
}
|
||||
|
||||
WidgetLoader {
|
||||
id: specificsOne;
|
||||
source: specificsUrl;
|
||||
}
|
||||
|
||||
|
||||
QScrollArea {
|
||||
}
|
||||
|
||||
} // layout
|
||||
} //QWidget
|
||||
} //QScrollArea
|
||||
|
||||
|
||||
ScrollArea {
|
||||
widgetResizable: true;
|
||||
styleSheetFile: ":/qmldesigner/scrollbar.css";
|
||||
finished: finishedNotify;
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: specialPane;
|
||||
visible: false;
|
||||
visible: false;
|
||||
content: ProperyEditorSpecial;
|
||||
QFrame {
|
||||
minimumHeight: 600;
|
||||
id: ProperyEditorSpecial
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
|
||||
WidgetLoader {
|
||||
id: specificsOne2;
|
||||
source: specificsUrl;
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedPane {
|
||||
id: extendedPane;
|
||||
}
|
||||
|
||||
LayoutPane {
|
||||
id: layoutPane;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
22
share/qtcreator/qmldesigner/propertyeditor/Qt/Layout.qml
Normal file
@@ -0,0 +1,22 @@
|
||||
import Qt 4.6
|
||||
|
||||
GroupBox {
|
||||
finished: finishedNotify;
|
||||
caption: "Layout";
|
||||
id: Layout;
|
||||
maximumHeight: 340;
|
||||
enabled: anchorBackend.hasParent;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 20;
|
||||
bottomMargin: 10;
|
||||
leftMargin: 40;
|
||||
rightMargin: 20;
|
||||
spacing: 20
|
||||
QLabel {
|
||||
text: "Layout"
|
||||
}
|
||||
AnchorBox {}
|
||||
}
|
||||
|
||||
}
|
||||
29
share/qtcreator/qmldesigner/propertyeditor/Qt/LayoutPane.qml
Normal file
@@ -0,0 +1,29 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QScrollArea {
|
||||
widgetResizable: true;
|
||||
styleSheetFile: ":/qmldesigner/scrollbar.css";
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: LayoutPane;
|
||||
visible: false;
|
||||
content: ProperyEditorLayout;
|
||||
QFrame {
|
||||
enabled: isBaseState;
|
||||
id: ProperyEditorLayout;
|
||||
minimumHeight: 460;
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
Layout {
|
||||
id: layoutBox;
|
||||
}
|
||||
QScrollArea {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
85
share/qtcreator/qmldesigner/propertyeditor/Qt/ListView.qml
Normal file
@@ -0,0 +1,85 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
PropertyFrame {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
spacing: 0;
|
||||
|
||||
Switches {
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: standardPane;
|
||||
content: ProperyEditorStandard;
|
||||
QFrame {
|
||||
minimumHeight: 400;
|
||||
id: ProperyEditorStandard
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
Geometry {
|
||||
}
|
||||
|
||||
Modifiers {
|
||||
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
}
|
||||
|
||||
} // layout
|
||||
} //QWidget
|
||||
} //QScrollArea
|
||||
|
||||
|
||||
QScrollArea {
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: specialPane;
|
||||
visible: false;
|
||||
visible: false;
|
||||
content: ProperyEditorSpecial;
|
||||
QFrame {
|
||||
minimumHeight: 200;
|
||||
id: ProperyEditorSpecial
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
Type {
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExtendedPane {
|
||||
id: extendedPane;
|
||||
}
|
||||
|
||||
LayoutPane {
|
||||
id: layoutPane;
|
||||
}
|
||||
|
||||
|
||||
ResetPane {
|
||||
id: resetPane;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
finished: finishedNotify;
|
||||
caption: "List View";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 15;
|
||||
bottomMargin: 6;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
id: contentWidget;
|
||||
maximumHeight: 260;
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
QLabel {
|
||||
minimumHeight: 22;
|
||||
text: "Highlight Follows:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 22;
|
||||
text: "Key Navigation Wraps:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 22;
|
||||
text: "Snap Position:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 22;
|
||||
text: "Spacing:"
|
||||
font.bold: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
CheckBox {
|
||||
id: HighlightFollowsCurrentItemCheckBox;
|
||||
text: "";
|
||||
backendValue: backendValues.highlightFollowsCurrentItem;
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: WrapCheckBox;
|
||||
text: "";
|
||||
backendValue: backendValues.wrap;
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
id: SnapPositionSpinBox;
|
||||
objectName: "SnapPositionSpinBox";
|
||||
backendValue: backendValues.snapPosition;
|
||||
minimumWidth: 30;
|
||||
minimum: 0;
|
||||
maximum: 1000;
|
||||
singleStep: 1;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
id: SpacingSpinBox;
|
||||
objectName: "SpacingSpinBox";
|
||||
backendValue: backendValues.spacing;
|
||||
minimumWidth: 30;
|
||||
minimum: 0;
|
||||
maximum: 1000;
|
||||
singleStep: 1;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
218
share/qtcreator/qmldesigner/propertyeditor/Qt/Modifiers.qml
Normal file
@@ -0,0 +1,218 @@
|
||||
import Qt 4.6
|
||||
|
||||
GroupBox {
|
||||
|
||||
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Modifiers"
|
||||
minimumHeight: 30;
|
||||
minimumHeight: 180;
|
||||
id: Mofifiers;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 6;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
id: contentWidget;
|
||||
maximumHeight: 240;
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 30;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 50;
|
||||
text: "Rotation:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
text: "Scale:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
text: "Scale:"
|
||||
text: ""
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
text: "Opacity:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLabel {
|
||||
text: "Visibility:"
|
||||
font.bold: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 02;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 5;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 3;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
SpinBox {
|
||||
id: RotationSpinBox;
|
||||
backendValue: backendValues.rotation;
|
||||
onBackendValueChanged: {
|
||||
if (backendValue.value > 180)
|
||||
RotationDial.value = (backendValue.value - 360);
|
||||
else
|
||||
RotationDial.value = backendValue.value;
|
||||
}
|
||||
minimum: 0;
|
||||
maximum: 360;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QDial {
|
||||
id: RotationDial;
|
||||
wrapping: true;
|
||||
focusPolicy: "Qt::ClickFocus";
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 50;
|
||||
minimum: -180;
|
||||
maximum: 180;
|
||||
singleStep: 45;
|
||||
onValueChanged : {
|
||||
if (value < 0)
|
||||
RotationSpinBox.backendValue.value = 360 + value;
|
||||
else
|
||||
RotationSpinBox.backendValue.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 10;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
DoubleSpinBox {
|
||||
id: ScaleSpinBox;
|
||||
objectName: "ScaleSpinBox";
|
||||
backendValue: backendValues.scale;
|
||||
minimumWidth: 60;
|
||||
minimum: 0.01
|
||||
maximum: 10
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
onBackendValueChanged: {
|
||||
ScaleSlider.value = backendValue.value * 10;
|
||||
}
|
||||
}
|
||||
QSlider {
|
||||
id: ScaleSlider;
|
||||
orientation: "Qt::Horizontal";
|
||||
minimum: 1;
|
||||
maximum: 100;
|
||||
singleStep: 1;
|
||||
onValueChanged: {
|
||||
backendValues.scale.value = value / 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 5;
|
||||
bottomMargin: 5;
|
||||
leftMargin: 10;
|
||||
rightMargin: 0;
|
||||
|
||||
QLabel {
|
||||
text: "Origin: ";
|
||||
}
|
||||
QComboBox {
|
||||
items : { [
|
||||
"TopLeft", "Top", "TopRight", "Left", "Center", "Right", "BottomLeft", "Bottom",
|
||||
"BottomRight"
|
||||
] }
|
||||
|
||||
currentText: backendValues.transformOrigin.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.transformOrigin.value;
|
||||
}
|
||||
onCurrentTextChanged: {
|
||||
backendValues.transformOrigin.value = currentText;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 5;
|
||||
bottomMargin: 10;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
DoubleSpinBox {
|
||||
id: OpacitySpinBox;
|
||||
backendValue: backendValues.opacity === undefined ? null : backendValues.opacity
|
||||
minimumWidth: 60;
|
||||
minimum: 0;
|
||||
maximum: 1;
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QSlider {
|
||||
orientation: "Qt::Horizontal";
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
singleStep: 5;
|
||||
value: backendValues.opacity === undefined ? 0 : (backendValues.opacity.value * 100)
|
||||
onValueChanged: {
|
||||
if (backendValues.opacity !== undefined)
|
||||
backendValues.opacity.value = value / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckBox {
|
||||
id: VisibleCheckBox;
|
||||
text: "item visibilty";
|
||||
backendValue: backendValues.visible === undefined ? false : backendValues.visible;
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
}
|
||||
CheckBox {
|
||||
id: ClipCheckBox;
|
||||
text: "clipping item";
|
||||
backendValue: backendValues.clip === undefined ? false : backendValues.clip;
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import Qt 4.6
|
||||
|
||||
WidgetFrame {
|
||||
id: PropertyFrame;
|
||||
|
||||
minimumWidth: 300;
|
||||
//maximumWidth: 300;
|
||||
styleSheetFile: "propertyEditor.css";
|
||||
//visible: isBaseState;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Rect"
|
||||
|
||||
minimumHeight: 340;
|
||||
maximumHeight: 340;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 12;
|
||||
bottomMargin: 20;
|
||||
leftMargin: 20;
|
||||
rightMargin: 20;
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 20;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 8;
|
||||
bottomMargin: 20;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "Radius:"
|
||||
font.bold: true;
|
||||
}
|
||||
SpinBox {
|
||||
id: RadiusSpinBox;
|
||||
backendValue: backendValues.radius === undefined ? null : backendValues.radius
|
||||
minimum: 0;
|
||||
maximum: 100;
|
||||
baseStateFlag: isBaseState;
|
||||
}
|
||||
QSlider {
|
||||
orientation: "Qt::Horizontal";
|
||||
minimum: 0;
|
||||
maximum: 100;
|
||||
singleStep: 1;
|
||||
value: backendValues.radius === undefined ? null : backendValues.radius.value
|
||||
onValueChanged: {
|
||||
backendValues.radius.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
spacing: 20;
|
||||
|
||||
ColorWidget {
|
||||
text: "Color:";
|
||||
color: backendValues.color === undefined ? null : backendValues.color.value;
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
//modelNode: backendValues.color.modelNode;
|
||||
complexGradientNode: backendValues.color === undefined ? null : backendValues.color.complexNode
|
||||
|
||||
showGradientButton: true;
|
||||
}
|
||||
ColorWidget {
|
||||
text: "Tint color:";
|
||||
color: backendValues.tintColor === undefined ? "black" : backendValues.tintColor.value
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLine {
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
minimumHeight: 80;
|
||||
maximumHeight: 120;
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
|
||||
QWidget {
|
||||
id: PenGroupBox;
|
||||
|
||||
maximumHeight: 80;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 10;
|
||||
bottomMargin: 10;
|
||||
leftMargin: 20;
|
||||
rightMargin: 20;
|
||||
IntEditor {
|
||||
|
||||
id: borderWidth;
|
||||
backendValue: backendValues.border_width === undefined ? 0 : backendValues.border_width
|
||||
|
||||
caption: "Pen Width:"
|
||||
baseStateFlag: isBaseState;
|
||||
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 100;
|
||||
}
|
||||
ColorWidget {
|
||||
id: PenColor;
|
||||
text: "Pen Color:";
|
||||
minimumHeight: 20;
|
||||
minimumWidth: 20;
|
||||
color: backendValues.border_color.value;
|
||||
onColorChanged: {
|
||||
backendValues.border_color.value = strColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
share/qtcreator/qmldesigner/propertyeditor/Qt/ResetPane.qml
Normal file
@@ -0,0 +1,41 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QScrollArea {
|
||||
horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff";
|
||||
id: ResetPane;
|
||||
visible: false;
|
||||
content: ProperyEditorReset;
|
||||
QFrame {
|
||||
//minimumHeight: 1800;
|
||||
id: ProperyEditorReset
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
|
||||
Type {
|
||||
}
|
||||
ResetWidget {
|
||||
id: resetWidget;
|
||||
//minimumHeight: 2000;
|
||||
|
||||
|
||||
height: 500;
|
||||
width: 200;
|
||||
backendObject: backendValues;
|
||||
|
||||
QLineEdit {
|
||||
visible: false;
|
||||
text: backendValues.id;
|
||||
onTextChanged: {
|
||||
resetWidget.resetView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 200;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Grid";
|
||||
id: GridSpecifics;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 18;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 8;
|
||||
rightMargin: 8;
|
||||
|
||||
|
||||
IntEditor {
|
||||
id: spacing;
|
||||
backendValue: backendValues.spacing;
|
||||
caption: "Spacing: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
share/qtcreator/qmldesigner/propertyeditor/Qt/ScrollArea.qml
Normal file
@@ -0,0 +1,14 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
|
||||
QScrollArea {
|
||||
|
||||
property var finished;
|
||||
|
||||
onFinishedChanged: {
|
||||
setupProperWheelBehaviour();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
72
share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml
Normal file
@@ -0,0 +1,72 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
QWidget { //This is a special SpinBox that does color coding for states
|
||||
id: SpinBox;
|
||||
|
||||
property var backendValue;
|
||||
property var baseStateFlag;
|
||||
property alias singleStep: box.singleStep;
|
||||
property alias minimum: box.minimum
|
||||
property alias maximum: box.maximum
|
||||
|
||||
minimumHeight: 22;
|
||||
|
||||
onBaseStateFlagChanged: {
|
||||
evaluate();
|
||||
}
|
||||
|
||||
onBackendValueChanged: {
|
||||
evaluate();
|
||||
}
|
||||
|
||||
Script {
|
||||
function evaluate() {
|
||||
if (baseStateFlag) {
|
||||
if (backendValue != null && backendValue.isInModel)
|
||||
SpinBox.setStyleSheet("color: white;");
|
||||
else
|
||||
SpinBox.setStyleSheet("color: gray;");
|
||||
} else {
|
||||
if (backendValue != null && backendValue.isInSubState)
|
||||
SpinBox.setStyleSheet("color: blue;");
|
||||
else
|
||||
SpinBox.setStyleSheet("color: gray;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 10;
|
||||
spacing: 0;
|
||||
|
||||
QSpinBox {
|
||||
property alias backendValue: SpinBox.backendValue
|
||||
|
||||
keyboardTracking: false;
|
||||
id: box;
|
||||
enabled: backendValue === undefined || backendValue.isBound === undefined || backendValue.isBound === null ? false : !backendValue.isBound
|
||||
value: backendValue == undefined || backendValue.value == undefined || backendValue.value === null ? 0 : backendValue.value;
|
||||
onValueChanged: {
|
||||
if (backendValue != undefined && backendValue != null)
|
||||
backendValue.value = value;
|
||||
}
|
||||
onFocusChanged: {
|
||||
//extendedSwitches.active = focus;
|
||||
//extendedSwitches.backendValue = backendValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QToolButton {
|
||||
visible: false;
|
||||
width: 10;
|
||||
height: 10;
|
||||
y: box.y + box.height - 11;
|
||||
x: box.width - 1;
|
||||
focusPolicy: "Qt::NoFocus";
|
||||
}
|
||||
}
|
||||
85
share/qtcreator/qmldesigner/propertyeditor/Qt/Switches.qml
Normal file
@@ -0,0 +1,85 @@
|
||||
import Qt 4.6
|
||||
|
||||
QFrame {
|
||||
styleSheetFile: "switch.css";
|
||||
property var specialModeIcon;
|
||||
specialModeIcon: "images/standard.png";
|
||||
maximumWidth: 286;
|
||||
minimumWidth: 286;
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 4;
|
||||
rightMargin: 80;
|
||||
spacing: 0;
|
||||
|
||||
QPushButton {
|
||||
checkable: true;
|
||||
checked: true;
|
||||
id: standardMode;
|
||||
toolTip: "general item properties";
|
||||
iconFromFile: "images/rect-icon.png";
|
||||
onClicked: {
|
||||
extendedMode.checked = false;
|
||||
layoutMode.checked = false;
|
||||
specialMode.checked = false;
|
||||
checked = true;
|
||||
standardPane.visible = true;
|
||||
extendedPane.visible = false;
|
||||
layoutPane.visible = false;
|
||||
specialPane.visible = false;
|
||||
}
|
||||
}
|
||||
QPushButton {
|
||||
checkable: true;
|
||||
checked: false;
|
||||
id: specialMode;
|
||||
toolTip: "type specific properties";
|
||||
iconFromFile: specialModeIcon;
|
||||
onClicked: {
|
||||
extendedMode.checked = false;
|
||||
standardMode.checked = false;
|
||||
layoutMode.checked = false;
|
||||
checked = true;
|
||||
specialPane.visible = true;
|
||||
standardPane.visible = false;
|
||||
extendedPane.visible = false;
|
||||
layoutPane.visible = false;
|
||||
}
|
||||
}
|
||||
QPushButton {
|
||||
id: extendedMode;
|
||||
toolTip: "extended properties";
|
||||
checkable: true;
|
||||
checked: false;
|
||||
iconFromFile: "images/extended.png";
|
||||
onClicked: {
|
||||
standardMode.checked = false;
|
||||
layoutMode.checked = false;
|
||||
specialMode.checked = false;
|
||||
checked = true;
|
||||
standardPane.visible = false;
|
||||
extendedPane.visible = true;
|
||||
layoutPane.visible = false;
|
||||
specialPane.visible = false;
|
||||
}
|
||||
}
|
||||
QPushButton {
|
||||
id: layoutMode;
|
||||
checkable: true;
|
||||
checked: false;
|
||||
toolTip: "layout properties";
|
||||
iconFromFile: "images/layout.png";
|
||||
onClicked: {
|
||||
extendedMode.checked = false;
|
||||
standardMode.checked = false;
|
||||
specialMode.checked = false;
|
||||
checked = true;
|
||||
standardPane.visible = false;
|
||||
extendedPane.visible = false;
|
||||
layoutPane.visible = true;
|
||||
specialPane.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 600;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Text Edit";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
id: textSpecifics;
|
||||
topMargin: 20;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 4;
|
||||
rightMargin: 4;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 8;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 0;
|
||||
spacing: 20;
|
||||
QLabel {
|
||||
alignment: "AlignTop";
|
||||
text: "Text:"
|
||||
font.bold: true;
|
||||
}
|
||||
QTextEdit {
|
||||
minimumHeight: 80;
|
||||
property var localText: backendValues.text.value;
|
||||
onLocalTextChanged: {
|
||||
if (localText != plainText)
|
||||
plainText = localText;
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
backendValues.text.value = plainText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "wrap:"
|
||||
font.bold: true;
|
||||
}
|
||||
CheckBox {
|
||||
text: "isWrapping";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontWidget {
|
||||
text: "Font:";
|
||||
|
||||
bold: backendValues.font_bold.value;
|
||||
italic: backendValues.font_italic.value;
|
||||
family: backendValues.font_family.value;
|
||||
fontSize: backendValues.font_pointSize.value;
|
||||
|
||||
onDataFontChanged: {
|
||||
if (bold)
|
||||
backendValues.font_bold.value = bold;
|
||||
else
|
||||
backendValues.font_bold.resetValue();
|
||||
|
||||
if (italic)
|
||||
backendValues.font_italic.value = bold;
|
||||
else
|
||||
backendValues.font_italic.resetValue();
|
||||
|
||||
backendValues.font_family.value = family;
|
||||
backendValues.font_pointSize.value = fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 8;
|
||||
leftMargin: 6;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Text Format:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
minimumHeight: 22;
|
||||
items : { ["PlainText", "RichText", "AutoText"] }
|
||||
currentText: backendValues.textFormat.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.textFormat.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
backendValues.textFormat.value = currentText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 6;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Horizontal Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignLeft", "AlignRight", "AlignHCenter"] }
|
||||
currentText: backendValues.horizontalAlignment.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.horizontalAlignment.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
backendValues.horizontalAlignment.value = currentText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 6;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Vertical Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignTop", "AlignBottom", "AlignVCenter"] }
|
||||
currentText: backendValues.verticalAlignment.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.verticalAlignment.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
backendValues.verticalAlignment.value = currentText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Color:";
|
||||
color: backendValues.color.value;
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Selection Color:";
|
||||
color: backendValues.selectionColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.selectionColor.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Selected Text Color:";
|
||||
color: backendValues.selectedTextColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.selectedTextColor.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
CheckBox {
|
||||
|
||||
text: "Read Only";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.readOnly;
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
text: "Cursor Visible";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.cursorVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
CheckBox {
|
||||
text: "Focus On Press";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues. focusOnPress.value;
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
text: "Persistent Selection";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.persistentSelection.value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 420;
|
||||
minimumHeight: 420;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Text Input";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
id: textSpecifics;
|
||||
topMargin: 12;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 8;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "Text:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLineEdit {
|
||||
minimumHeight: 24;
|
||||
text: backendValues.text.value;
|
||||
onTextChanged: {
|
||||
backendValues.text.value = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontWidget {
|
||||
text: "Font:";
|
||||
|
||||
bold: backendValues.font_bold.value;
|
||||
italic: backendValues.font_italic.value;
|
||||
family: backendValues.font_family.value;
|
||||
fontSize: backendValues.font_pointSize.value;
|
||||
|
||||
onDataFontChanged: {
|
||||
|
||||
if (bold)
|
||||
backendValues.font_bold.value = bold;
|
||||
else
|
||||
backendValues.font_bold.resetValue();
|
||||
|
||||
if (italic)
|
||||
backendValues.font_italic.value = bold;
|
||||
else
|
||||
backendValues.font_italic.resetValue();
|
||||
|
||||
backendValues.font_family.value = family;
|
||||
backendValues.font_pointSize.value = fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 6;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Horizontal Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignLeft", "AlignRight", "AlignHCenter"] }
|
||||
currentText: backendValues.horizontalAlignment.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.horizontalAlignment.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
backendValues.horizontalAlignment.value = currentText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Color:";
|
||||
color: backendValues.color.value;
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Selection Color:";
|
||||
color: backendValues.selectionColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.selectionColor.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
ColorWidget {
|
||||
minimumHeight: 20;
|
||||
maximumHeight: 20;
|
||||
text: "Selected Text Color:";
|
||||
color: backendValues.selectedTextColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.selectedTextColor.value = strColor;
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
CheckBox {
|
||||
|
||||
text: "Read Only";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.readOnly;
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
|
||||
text: "Cursor Visible";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues.cursorVisible;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
CheckBox {
|
||||
text: "Focus On Press";
|
||||
baseStateFlag: isBaseState;
|
||||
checkable: true;
|
||||
backendValue: backendValues. focusOnPress;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
172
share/qtcreator/qmldesigner/propertyeditor/Qt/TextSpecifics.qml
Normal file
@@ -0,0 +1,172 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 280;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "Text";
|
||||
|
||||
layout: QVBoxLayout {
|
||||
id: textSpecifics;
|
||||
topMargin: 12;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 4;
|
||||
rightMargin: 4;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 8;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "Text:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLineEdit {
|
||||
minimumHeight: 24;
|
||||
text: backendValues.text.value;
|
||||
onTextChanged: {
|
||||
backendValues.text.value = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
QLabel {
|
||||
text: "wrap:"
|
||||
font.bold: true;
|
||||
}
|
||||
CheckBox {
|
||||
baseStateFlag: isBaseState;
|
||||
text: "isWrapping";
|
||||
checkable: true;
|
||||
backendValue: backendValues.wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontWidget {
|
||||
text: "Font:";
|
||||
|
||||
bold: backendValues.font_bold.value;
|
||||
italic: backendValues.font_italic.value;
|
||||
family: backendValues.font_family.value;
|
||||
fontSize: backendValues.font_pointSize.value;
|
||||
|
||||
onDataFontChanged: {
|
||||
|
||||
if (bold)
|
||||
backendValues.font_bold.value = bold;
|
||||
else
|
||||
backendValues.font_bold.resetValue();
|
||||
|
||||
if (italic)
|
||||
backendValues.font_italic.value = bold;
|
||||
else
|
||||
backendValues.font_italic.resetValue();
|
||||
|
||||
backendValues.font_family.value = family;
|
||||
backendValues.font_pointSize.value = fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Horizontal Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignLeft", "AlignRight", "AlignHCenter"] }
|
||||
currentText: backendValues.horizontalAlignment.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.horizontalAlignment.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3);
|
||||
backendValues.horizontalAlignment.value = currentText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 4;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 6;
|
||||
QLabel {
|
||||
text: "Vertical Alignment:"
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
items : { ["AlignTop", "AlignBottom", "AlignVCenter"] }
|
||||
currentText: backendValues.verticalAlignment.value;
|
||||
onItemsChanged: {
|
||||
currentText = backendValues.verticalAlignment.value;
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
if (count == 3)
|
||||
backendValues.verticalAlignment.value = currentText;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLine {
|
||||
}
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 2;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
ColorWidget {
|
||||
text: "Color:";
|
||||
color: backendValues.color.value;
|
||||
onColorChanged: {
|
||||
backendValues.color.value = strColor;
|
||||
}
|
||||
}
|
||||
ColorWidget {
|
||||
text: "Style color:";
|
||||
color: backendValues.styleColor.value;
|
||||
onColorChanged: {
|
||||
backendValues.styleColor.value = strColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
94
share/qtcreator/qmldesigner/propertyeditor/Qt/Type.qml
Normal file
@@ -0,0 +1,94 @@
|
||||
import Qt 4.6
|
||||
|
||||
GroupBox {
|
||||
id: Type;
|
||||
finished: finishedNotify;
|
||||
caption: "Type";
|
||||
|
||||
maximumHeight: 100;
|
||||
minimumWidth: 280;
|
||||
layout: QHBoxLayout {
|
||||
|
||||
topMargin: 2;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
rightMargin: 10;
|
||||
|
||||
|
||||
|
||||
QWidget {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
bottomMargin: 10;
|
||||
|
||||
QLabel {
|
||||
text: "Type:";
|
||||
windowTextColor: isBaseState ? "#000000" : "#FF0000";
|
||||
}
|
||||
|
||||
QLabel {
|
||||
font.bold: true;
|
||||
text: "Id:";
|
||||
}
|
||||
|
||||
QLabel {
|
||||
text: "state:";
|
||||
font.bold: true;
|
||||
}
|
||||
|
||||
} //QVBoxLayout
|
||||
} //QWidget
|
||||
QWidget {
|
||||
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 10;
|
||||
bottomMargin: 10;
|
||||
|
||||
QLineEdit {
|
||||
styleSheetFile: "typeLabel.css"
|
||||
text: backendValues.className === undefined ? "" : backendValues.className.value;
|
||||
readOnly :true;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
id: IdLineEdit;
|
||||
objectName: "IdLineEdit";
|
||||
readOnly: isBaseState != true;
|
||||
text: backendValues.id === undefined ? "" : backendValues.id.value;
|
||||
onEditingFinished: {
|
||||
backendValues.id.value = text;
|
||||
}
|
||||
} //LineEdit
|
||||
|
||||
QLineEdit {
|
||||
visible: isBaseState != true;
|
||||
textColor: "#ff0000";
|
||||
readOnly :true;
|
||||
text: stateName;
|
||||
styleSheetFile: "typeLabel.css"
|
||||
onTextChanged: {
|
||||
if (!visible) {
|
||||
IdLineEdit.textColor = "#000000";
|
||||
} else {
|
||||
IdLineEdit.textColor = "#777777";
|
||||
}
|
||||
}
|
||||
} //LineEdit
|
||||
|
||||
QLineEdit {
|
||||
visible: isBaseState;
|
||||
readOnly :true;
|
||||
text: "";
|
||||
styleSheetFile: "typeLabel.css"
|
||||
} //LineEdit
|
||||
|
||||
} //QVBoxLayout
|
||||
} //QWidget
|
||||
|
||||
|
||||
} //QHBoxLayout
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
GroupBox {
|
||||
maximumHeight: 200;
|
||||
|
||||
finished: finishedNotify;
|
||||
caption: "WebView";
|
||||
id: webViewSpecifics;
|
||||
|
||||
layout: QVBoxLayout {
|
||||
|
||||
topMargin: 18;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 8;
|
||||
rightMargin: 8;
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "Url:"
|
||||
font.bold: true;
|
||||
}
|
||||
QLineEdit {
|
||||
text: backendValues.url.value;
|
||||
onEditingFinished: {
|
||||
backendValues.url.value = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
IntEditor {
|
||||
id: preferredWidth;
|
||||
backendValue: backendValues.preferredWidth;
|
||||
caption: "Prefered Width: "
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
IntEditor {
|
||||
id: webPageWidth;
|
||||
backendValue: backendValues.preferredHeight;
|
||||
caption: "Web Page Height:"
|
||||
baseStateFlag: isBaseState;
|
||||
step: 1;
|
||||
minimumValue: 0;
|
||||
maximumValue: 2000;
|
||||
}
|
||||
|
||||
QWidget {
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 10;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
spacing: 20;
|
||||
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "ZommFactor:"
|
||||
font.bold: true;
|
||||
}
|
||||
DoubleSpinBox {
|
||||
id: ZoomSpinBox;
|
||||
objectName: "ZommSpinBox";
|
||||
backendValue: backendValues.zoomFactor;
|
||||
minimumWidth: 60;
|
||||
minimum: 0.01
|
||||
maximum: 10
|
||||
singleStep: 0.1
|
||||
baseStateFlag: isBaseState;
|
||||
onBackendValueChanged: {
|
||||
ZoomSlider.value = backendValue.value * 10;
|
||||
}
|
||||
}
|
||||
QSlider {
|
||||
id: ZoomSlider;
|
||||
orientation: "Qt::Horizontal";
|
||||
minimum: 1;
|
||||
maximum: 100;
|
||||
singleStep: 1;
|
||||
onValueChanged: {
|
||||
backendValues.zoomFactor.value = value / 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
share/qtcreator/qmldesigner/propertyeditor/Qt/anchorbox.css
Normal file
@@ -0,0 +1,32 @@
|
||||
QPushButton::checked
|
||||
{
|
||||
border: 3px solid #2222aa;
|
||||
border-radius: 4px;
|
||||
border-image: none;
|
||||
background-color: #909090;
|
||||
}
|
||||
|
||||
QPushButton:pressed
|
||||
{
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
|
||||
QPushButton:flat {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
|
||||
QPushButton:default {
|
||||
border-color: 1px solid black;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
border: 2px solid #333333;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QFrame{
|
||||
border: 2px solid black;
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
background: #aaabae;
|
||||
}
|
||||
45
share/qtcreator/qmldesigner/propertyeditor/Qt/emptyPane.qml
Normal file
@@ -0,0 +1,45 @@
|
||||
import Qt 4.6
|
||||
import Bauhaus 1.0
|
||||
|
||||
PropertyFrame {
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 0;
|
||||
bottomMargin: 0;
|
||||
leftMargin: 0;
|
||||
rightMargin: 0;
|
||||
spacing: 0;
|
||||
|
||||
Switches {
|
||||
}
|
||||
|
||||
ScrollArea {
|
||||
styleSheetFile: ":/qmldesigner/scrollbar.css";
|
||||
widgetResizable: true;
|
||||
content: QFrame {
|
||||
maximumHeight: 38;
|
||||
layout: QVBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 2;
|
||||
leftMargin: 2;
|
||||
rightMargin: 2;
|
||||
QExtGroupBox {
|
||||
font.bold: true;
|
||||
maximumHeight: 100;
|
||||
minimumWidth: 280;
|
||||
minimumHeight: 32;
|
||||
layout: QHBoxLayout {
|
||||
topMargin: 6;
|
||||
bottomMargin: 2;
|
||||
QLabel {
|
||||
minimumHeight: 20;
|
||||
text: "No Item Selected";
|
||||
alignment: "AlignHCenter";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 433 B |
|
After Width: | Height: | Size: 340 B |
BIN
share/qtcreator/qmldesigner/propertyeditor/Qt/images/button.png
Normal file
|
After Width: | Height: | Size: 687 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 855 B |
|
After Width: | Height: | Size: 575 B |
|
After Width: | Height: | Size: 293 B |
|
After Width: | Height: | Size: 369 B |
|
After Width: | Height: | Size: 292 B |
|
After Width: | Height: | Size: 293 B |
BIN
share/qtcreator/qmldesigner/propertyeditor/Qt/images/layout.png
Normal file
|
After Width: | Height: | Size: 369 B |
|
After Width: | Height: | Size: 885 B |
|
After Width: | Height: | Size: 424 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 311 B |
|
After Width: | Height: | Size: 237 B |
|
After Width: | Height: | Size: 741 B |
|
After Width: | Height: | Size: 871 B |
|
After Width: | Height: | Size: 340 B |
BIN
share/qtcreator/qmldesigner/propertyeditor/Qt/images/submenu.png
Normal file
|
After Width: | Height: | Size: 447 B |
|
After Width: | Height: | Size: 368 B |
|
After Width: | Height: | Size: 582 B |
BIN
share/qtcreator/qmldesigner/propertyeditor/Qt/images/upArrow.png
Normal file
|
After Width: | Height: | Size: 849 B |
@@ -0,0 +1,35 @@
|
||||
QPushButton::checked
|
||||
{
|
||||
border-radius: 4px;
|
||||
border: 4px solid #4f4f41;
|
||||
border-image: none;
|
||||
background-color: #9a9b9e;
|
||||
}
|
||||
|
||||
QPushButton:pressed
|
||||
{
|
||||
border: 1px solid #5f5f51;
|
||||
background-color: #dadbde;
|
||||
background: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QPushButton:flat {
|
||||
border: 1px solid #5f5f51;
|
||||
background-color: #eadbde;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QPushButton:default {
|
||||
border-color: 1px solid black;
|
||||
background-color: #eadbde;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
QFrame{
|
||||
border: 2px solid black;
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
background: #aaabae;
|
||||
}
|
||||
397
share/qtcreator/qmldesigner/propertyeditor/Qt/propertyEditor.css
Normal file
@@ -0,0 +1,397 @@
|
||||
QFrame, QSpinBox {
|
||||
background-color: #707070;
|
||||
}
|
||||
|
||||
QFrame
|
||||
{
|
||||
border-radius: 0px;
|
||||
font-size: 11px
|
||||
}
|
||||
|
||||
WidgetFrame {
|
||||
border: 0px;
|
||||
background-color: #707070;
|
||||
}
|
||||
|
||||
QComboBox QAbstractItemView {
|
||||
border: 2px solid darkgray;
|
||||
background-color: White;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
border: none;
|
||||
border-image: none;
|
||||
padding: 0;
|
||||
background: none;
|
||||
color: #dedede;
|
||||
font: bold
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: 0px;
|
||||
border-radius: 0px;
|
||||
background-color: #707070;
|
||||
}
|
||||
|
||||
QGroupBox
|
||||
{
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
|
||||
stop: 0 #4a4a4a, stop: 1 #4f4f4f);
|
||||
border: 1px solid #4F4F4F;
|
||||
border-radius: 5px;
|
||||
color: white;
|
||||
font: bold
|
||||
}
|
||||
|
||||
QLineEdit
|
||||
{
|
||||
color: white;
|
||||
border: 2px solid #0F0F0F;
|
||||
border-radius: 6px;
|
||||
border-width: 1;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #2c2c2c, stop: 1 #333333);
|
||||
}
|
||||
|
||||
QTextEdit
|
||||
{
|
||||
border: 2px solid #8F8F8F;
|
||||
border-radius: 10px;
|
||||
padding: 0 8px;
|
||||
background-color: white;
|
||||
selection-background-color: darkgray;
|
||||
}
|
||||
|
||||
QSpinBox
|
||||
{
|
||||
font-size: 11px;
|
||||
color: white;
|
||||
padding-right: 20px; /* make room for the arrows */
|
||||
padding-top: 2px; /* make room for the arrows */
|
||||
padding-bottom: 2px; /* make room for the arrows */
|
||||
border: 2px solid #0F0F0F;
|
||||
border-radius: 6px;
|
||||
border-width: 1;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #2c2c2c, stop: 1 #333333);
|
||||
|
||||
min-height: 14px;
|
||||
max-height: 14px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox
|
||||
{
|
||||
font-size: 11px;
|
||||
color: white;
|
||||
padding-right: 20px; /* make room for the arrows */
|
||||
padding-top: 2px; /* make room for the arrows */
|
||||
padding-bottom: 2px; /* make room for the arrows */
|
||||
border: 2px solid #0F0F0F;
|
||||
border-radius: 6px;
|
||||
border-width: 1;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #2c2c2c, stop: 1 #333333);
|
||||
max-height: 14px;
|
||||
min-height: 14px;
|
||||
}
|
||||
|
||||
QSpinBox::down-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: bottom right; /* position at bottom right corner */
|
||||
border-image: url(:/qmldesigner/images/spindown.png) 1;
|
||||
|
||||
width: 16px;
|
||||
border-width: 1px;
|
||||
border-top-width: 0;
|
||||
}
|
||||
|
||||
QSpinBox::down-button:hover {
|
||||
border-image: url(:/qmldesigner/images/spindown_hover.png) 1;
|
||||
}
|
||||
|
||||
QSpinBox::down-button:pressed {
|
||||
border-image: url(:/qmldesigner/images/spindown_pressed.png) 1;
|
||||
}
|
||||
|
||||
|
||||
QSpinBox::up-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: top right; /* position at bottom right corner */
|
||||
border-image: url(:/qmldesigner/images/spinup.png) 1;
|
||||
|
||||
width: 16px;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
QSpinBox::up-button:hover {
|
||||
border-image: url(:/qmldesigner/images/spinup_hover.png) 1;
|
||||
}
|
||||
|
||||
QSpinBox::up-button:pressed {
|
||||
border-image: url(:/qmldesigner/images/spinup_pressed.png) 1;
|
||||
}
|
||||
|
||||
|
||||
QDoubleSpinBox::down-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: bottom right; /* position at bottom right corner */
|
||||
border-image: url(:/qmldesigner/images/spindown.png) 1;
|
||||
|
||||
width: 16px;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-button:hover {
|
||||
border-image: url(:/qmldesigner/images/spindown_hover.png) 1;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::down-button:pressed {
|
||||
border-image: url(:/qmldesigner/images/spindown_pressed.png) 1;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: top right; /* position at bottom right corner */
|
||||
border-image: url(:/qmldesigner/images/spinup.png) 1;
|
||||
|
||||
width: 16px;
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:hover {
|
||||
border-image: url(:/qmldesigner/images/spinup_hover.png) 1;
|
||||
}
|
||||
|
||||
QDoubleSpinBox::up-button:pressed {
|
||||
border-image: url(:/qmldesigner/images/spinup_pressed.png) 1;
|
||||
}
|
||||
|
||||
QToolButton
|
||||
{
|
||||
background: none;
|
||||
border: none;
|
||||
background-color: none;
|
||||
}
|
||||
|
||||
QToolButton::pressed
|
||||
{
|
||||
background: none;
|
||||
border: none;
|
||||
background-color: none;
|
||||
}
|
||||
|
||||
QToolButton::checked
|
||||
{
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
padding: 0px;
|
||||
font-size: 11px
|
||||
}
|
||||
|
||||
QPushButton, QComboBox[editable="false"],
|
||||
QComboBox[editable="true"]::drop-down {
|
||||
border-image: url(:/qmldesigner/images/pushbutton.png) 3;
|
||||
border-width: 3;
|
||||
}
|
||||
|
||||
QPushButton:hover, QComboBox[editable="false"]:hover,
|
||||
QComboBox[editable="true"]::drop-down:hover, QMenuBar::item:hover {
|
||||
border-image: url(:/qmldesigner/images/pushbutton_hover.png) 3;
|
||||
border-width: 3;
|
||||
}
|
||||
|
||||
QPushButton:pressed, QComboBox[editable="false"]:on,
|
||||
QComboBox[editable="true"]::drop-down:on, QMenuBar::item:on {
|
||||
border-image: url(:/qmldesigner/images/pushbutton_pressed.png) 3;
|
||||
border-width: 3;
|
||||
}
|
||||
|
||||
/* Customize read-only comboboxes. */
|
||||
|
||||
QComboBox
|
||||
{
|
||||
font-size: 11px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QComboBox[editable="false"] {
|
||||
padding-left: 3px;
|
||||
padding-right: 20px; /* space for the arrow */
|
||||
}
|
||||
|
||||
QComboBox[editable="false"]::drop-down {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: top right;
|
||||
width: 15px;
|
||||
border-left-style: solid;
|
||||
border-left-color: black;
|
||||
border-left-width: 1px;
|
||||
}
|
||||
|
||||
QComboBox[editable="false"]::down-arrow {
|
||||
subcontrol-origin: content;
|
||||
subcontrol-position: center;
|
||||
position: relative;
|
||||
left: 1px; /* 1 pixel dropdown border */
|
||||
}
|
||||
|
||||
/* The combobox arrow is on when the popup is open. */
|
||||
QComboBox[editable="false"]::down-arrow:on {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
left: 2px;
|
||||
}
|
||||
|
||||
/* Customize editable comboboxes. */
|
||||
|
||||
QComboBox[editable="true"] {
|
||||
padding-right: 16px;
|
||||
}
|
||||
|
||||
QComboBox[editable="true"]::drop-down {
|
||||
subcontrol-origin: border;
|
||||
subcontrol-position: top right;
|
||||
width: 13px;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
bottom: 2px;
|
||||
right: 2px;
|
||||
}
|
||||
|
||||
QComboBox[editable="true"]::drop-down,
|
||||
QComboBox[editable="true"]::drop-down:hover,
|
||||
QComboBox[editable="true"]::drop-down:on {
|
||||
border-width: 0px;
|
||||
border-left-width: 3px; /* we need only left and center part */
|
||||
}
|
||||
|
||||
/* Shift the arrow when it's open. */
|
||||
QComboBox[editable="true"]::down-arrow:on {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
QRadioButton {
|
||||
spacing: 5px;
|
||||
}
|
||||
|
||||
QRadioButton::indicator {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
}
|
||||
|
||||
QRadioButton::indicator::unchecked {
|
||||
image: url(:/qmldesigner/images/radiobutton_unchecked.png);
|
||||
}
|
||||
|
||||
QRadioButton::indicator:unchecked:hover {
|
||||
image: url(:/qmldesigner/images/radiobutton_unchecked_hover.png);
|
||||
}
|
||||
|
||||
QRadioButton::indicator:unchecked:pressed {
|
||||
image: url(:/qmldesigner/images/radiobutton_unchecked_pressed.png);
|
||||
}
|
||||
|
||||
QRadioButton::indicator::checked {
|
||||
image: url(:/qmldesigner/images/radiobutton_checked.png);
|
||||
}
|
||||
|
||||
QRadioButton::indicator:checked:hover {
|
||||
image: url(:/qmldesigner/images/radiobutton_checked_hover.png);
|
||||
}
|
||||
|
||||
QRadioButton::indicator:checked:pressed {
|
||||
image: url(:/qmldesigner/images/radiobutton_checked_pressed.png);
|
||||
}
|
||||
|
||||
/* Customize arrows. */
|
||||
|
||||
*::down-arrow, *::menu-indicator {
|
||||
image: url(:/qmldesigner/images/down_arrow.png);
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
*::down-arrow:disabled, *::down-arrow:off {
|
||||
image: url(:/qmldesigner/images/down_arrow_disabled.png);
|
||||
}
|
||||
|
||||
*::up-arrow {
|
||||
image: url(:/qmldesigner/images/up_arrow.png);
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
}
|
||||
|
||||
*::up-arrow:disabled, *::up-arrow:off {
|
||||
image: url(:/qmldesigner/images/up_arrow_disabled.png);
|
||||
}
|
||||
|
||||
/* Customize push buttons and comboboxes. Our read-only combobox
|
||||
is very similar to a push button, so they share the same border image. */
|
||||
|
||||
|
||||
/* Customize check boxes. */
|
||||
QCheckBox {
|
||||
spacing: 8px;
|
||||
font-size: 11px
|
||||
}
|
||||
|
||||
QCheckBox::indicator {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
QCheckBox::indicator:unchecked {
|
||||
image: url(:/qmldesigner/images/checkbox_unchecked.png);
|
||||
}
|
||||
|
||||
QCheckBox::indicator:unchecked:hover {
|
||||
image: url(:/qmldesigner/images/checkbox_unchecked_hover.png);
|
||||
}
|
||||
|
||||
QCheckBox::indicator:unchecked:pressed {
|
||||
image: url(:/qmldesigner/images/checkbox_unchecked_pressed.png);
|
||||
}
|
||||
|
||||
QCheckBox::indicator:checked {
|
||||
image: url(:/qmldesigner/images/checkbox_checked.png);
|
||||
}
|
||||
|
||||
QCheckBox::indicator:checked:hover {
|
||||
image: url(:/qmldesigner/images/checkbox_checked_hover.png);
|
||||
}
|
||||
|
||||
QCheckBox::indicator:checked:pressed {
|
||||
image: url(:/qmldesigner/images/checkbox_checked_pressed.png);
|
||||
}
|
||||
|
||||
QMenu {
|
||||
background-color: #494949; /* sets background of the menu */
|
||||
border: 1px solid black;
|
||||
margin: 0px; /* some spacing around the menu */
|
||||
color: #cacaca;
|
||||
}
|
||||
|
||||
QMenu::item {
|
||||
/* sets background of menu item. set this to something non-transparent
|
||||
if you want menu color and menu item color to be different */
|
||||
background-color: transparent;
|
||||
padding: 2px 25px 2px 20px;
|
||||
}
|
||||
|
||||
QMenu::item:selected { /* when user selects item using mouse or keyboard */
|
||||
background-color: #d2d2d2;
|
||||
padding: 2px;
|
||||
color: #404040;
|
||||
border-radius: 4px;
|
||||
}
|
||||
QMenu::separator {
|
||||
height: 1px;
|
||||
background: #404040;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
QCheckBox {
|
||||
spacing: 2px;
|
||||
border-width: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QCheckBox::indicator {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
}
|
||||
QLabel {
|
||||
border : 2px solid gray;
|
||||
border-radius: 10px;
|
||||
padding: 0 8px;
|
||||
background: yellow;
|
||||
selection-background-color: darkgray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
32
share/qtcreator/qmldesigner/propertyeditor/Qt/switch.css
Normal file
@@ -0,0 +1,32 @@
|
||||
QPushButton {
|
||||
border: 0px solid #6f6f61;
|
||||
border-image: url(:/images/button2_normal.png) 2 2 2 2;
|
||||
border-radius: 1px;
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
margin: 0px 0 2px 0;
|
||||
}
|
||||
|
||||
QPushButton::checked
|
||||
{
|
||||
border-image: url(:/images/button2_pressed.png) 2 2 2 2;
|
||||
border: 1px solid #4f4f41;
|
||||
}
|
||||
|
||||
QPushButton:pressed {
|
||||
border-image: url(:/images/button2_pressed.png) 2 2 2 2;
|
||||
|
||||
}
|
||||
|
||||
QPushButton:flat {
|
||||
border: none; /* no border for a flat push button */
|
||||
}
|
||||
|
||||
QPushButton:default {
|
||||
border-image: url(:/images/button2_normal.png) 2 2 2 2;
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
border-image: url(:/images/button2_hovered.png) 2 2 2 2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
QLineEdit {
|
||||
color: lightGray;
|
||||
border: 2px solid #0F0F0F;
|
||||
border-radius: 6px;
|
||||
border-width: 2;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #2c2c2c, stop: 1 #333333);
|
||||
}
|
||||
BIN
share/qtcreator/qmldesigner/welcome-card.png
Normal file
|
After Width: | Height: | Size: 58 KiB |
147
share/qtcreator/qmldesigner/welcomescreen.qml
Normal file
@@ -0,0 +1,147 @@
|
||||
import Qt 4.6
|
||||
|
||||
Image {
|
||||
id: screen
|
||||
property var selectedFile
|
||||
signal openFile
|
||||
source: "gradient.png"
|
||||
|
||||
width: 1045
|
||||
height: 680
|
||||
|
||||
Image {
|
||||
source: "welcome-card.png"
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
transformOrigin: "Center"
|
||||
smooth: true
|
||||
scale: 0
|
||||
|
||||
//Animation
|
||||
scale: SequentialAnimation {
|
||||
running: true
|
||||
NumberAnimation {
|
||||
to: 1
|
||||
duration: 400
|
||||
easing: "easeOutCirc"
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: "Recent files"
|
||||
style: "Sunken"
|
||||
color: "white"
|
||||
font.pointSize: 14
|
||||
x: 70
|
||||
y: 160
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "New file"
|
||||
style: "Sunken"
|
||||
color: "white"
|
||||
font.pointSize: 14
|
||||
x: 380
|
||||
y: 160
|
||||
opacity: 0.8
|
||||
}
|
||||
|
||||
Item {
|
||||
id: leftSide
|
||||
width: 300
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
ListView {
|
||||
id: recentFilesListView
|
||||
width: 280
|
||||
height: 320
|
||||
x: 60
|
||||
y: 200
|
||||
overShoot: false
|
||||
|
||||
model: recentFiles
|
||||
delegate: fileDelegate
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: rightSide
|
||||
x: 300
|
||||
width: 300
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
|
||||
|
||||
ListView {
|
||||
id: templatesListView
|
||||
width: 280
|
||||
height: 320
|
||||
x: 80
|
||||
y: 200
|
||||
overShoot: false
|
||||
|
||||
model: templatesList
|
||||
delegate: fileDelegate
|
||||
}
|
||||
}
|
||||
Button {
|
||||
id: chooseButton
|
||||
label: " Choose"
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 13
|
||||
anchors.rightMargin: 40
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: fileDelegate
|
||||
Item {
|
||||
width: parent.width
|
||||
height: fileDelegateText.height
|
||||
|
||||
Text {
|
||||
id: fileDelegateText
|
||||
anchors.left: parent.left
|
||||
color: "white"
|
||||
text: name
|
||||
}
|
||||
|
||||
MouseRegion {
|
||||
anchors.top: fileDelegateText.top
|
||||
anchors.left: fileDelegateText.left
|
||||
anchors.right: fileDelegateText.right
|
||||
anchors.bottom: fileDelegateText.bottom
|
||||
onClicked: {
|
||||
screen.selectedFile = fileName;
|
||||
screen.openFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
ListModel {
|
||||
id: recentFiles
|
||||
ListElement {
|
||||
fileName: "file1.qml"
|
||||
}
|
||||
ListElement {
|
||||
fileName: "file2.qml"
|
||||
}
|
||||
ListElement {
|
||||
fileName: "file3.qml"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
ListModel {
|
||||
id: templatesList
|
||||
ListElement {
|
||||
fileName: ":/qmldesigner/templates/General/Empty Fx"
|
||||
name: "Fx Rectangle (640x480)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,8 @@ DATA_DIRS = \
|
||||
designer \
|
||||
schemes \
|
||||
styles \
|
||||
gdbmacros
|
||||
gdbmacros \
|
||||
qmldesigner
|
||||
|
||||
!isEmpty(copydata) {
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ SUBDIRS = plugin_coreplugin \
|
||||
debugger/dumper.pro
|
||||
|
||||
contains(QT_CONFIG, declarative) {
|
||||
SUBDIRS += plugin_qmlinspector
|
||||
SUBDIRS += plugin_qmlinspector \
|
||||
plugin_qmldesigner
|
||||
}
|
||||
|
||||
plugin_coreplugin.subdir = coreplugin
|
||||
@@ -184,6 +185,10 @@ plugin_qmlprojectmanager.depends += plugin_projectexplorer
|
||||
plugin_qmlprojectmanager.depends += plugin_help
|
||||
plugin_qmlprojectmanager.depends += plugin_qmleditor
|
||||
|
||||
plugin_qmldesigner.subdir = qmldesigner
|
||||
plugin_qmldesigner.depends = plugin_coreplugin
|
||||
plugin_qmldesigner.depends += plugin_texteditor
|
||||
|
||||
plugin_qmlinspector.subdir = qmlinspector
|
||||
plugin_qmlinspector.depends += plugin_projectexplorer
|
||||
plugin_qmlinspector.depends += plugin_coreplugin
|
||||
|
||||
25
src/plugins/qmldesigner/QmlDesigner.pluginspec
Normal file
@@ -0,0 +1,25 @@
|
||||
<plugin name="QmlDesigner" version="1.3.80" compatVersion="1.3.80">
|
||||
<vendor>Nokia Corporation</vendor>
|
||||
<copyright>(C) 2008-2009 Nokia Corporation</copyright>
|
||||
<license>
|
||||
Commercial Usage
|
||||
|
||||
Licensees holding valid Qt Commercial licenses may use this plugin in
|
||||
accordance with the Qt Commercial License Agreement provided with the
|
||||
Software or, alternatively, in accordance with the terms contained in
|
||||
a written agreement between you and Nokia.
|
||||
|
||||
GNU Lesser General Public License Usage
|
||||
|
||||
Alternatively, this plugin may be used under the terms of the GNU Lesser
|
||||
General Public License version 2.1 as published by the Free Software
|
||||
Foundation. Please review the following information to
|
||||
ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
|
||||
<description>Editor for QML.</description>
|
||||
<url>http://qt.nokia.com</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.3.80"/>
|
||||
<dependency name="TextEditor" version="1.3.80"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
46
src/plugins/qmldesigner/application.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "application.h"
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# define SHARE_PATH "/../Resources/qmldesigner"
|
||||
#else
|
||||
# define SHARE_PATH "/../share/qtcreator/qmldesigner"
|
||||
#endif
|
||||
|
||||
QString Application::sharedDirPath()
|
||||
{
|
||||
QString appPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
return QFileInfo(appPath + SHARE_PATH).absoluteFilePath();
|
||||
}
|
||||
40
src/plugins/qmldesigner/application.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
class Application {
|
||||
public:
|
||||
static QString sharedDirPath();
|
||||
};
|
||||
|
||||
#endif // APPLICATION_H
|
||||
@@ -0,0 +1,190 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "abstractformeditortool.h"
|
||||
#include "formeditorview.h"
|
||||
#include "formeditorview.h"
|
||||
|
||||
#include <QtDebug>
|
||||
#include <QGraphicsSceneDragDropEvent>
|
||||
#include <nodemetainfo.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AbstractFormEditorTool::AbstractFormEditorTool(FormEditorView *editorView) : m_view(editorView)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractFormEditorTool::~AbstractFormEditorTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FormEditorView* AbstractFormEditorTool::view() const
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
FormEditorScene* AbstractFormEditorTool::scene() const
|
||||
{
|
||||
return view()->scene();
|
||||
}
|
||||
|
||||
void AbstractFormEditorTool::setItems(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
m_itemList = itemList;
|
||||
selectedItemsChanged(m_itemList);
|
||||
}
|
||||
|
||||
QList<FormEditorItem*> AbstractFormEditorTool::items() const
|
||||
{
|
||||
return m_itemList;
|
||||
}
|
||||
|
||||
bool AbstractFormEditorTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
|
||||
if (firstSelectableItem == 0)
|
||||
return false;
|
||||
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(firstSelectableItem);
|
||||
QList<QmlItemNode> selectedNodes = view()->selectedQmlItemNodes();
|
||||
|
||||
if (formEditorItem != 0
|
||||
&& selectedNodes.contains(formEditorItem->qmlItemNode()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
QList<QmlItemNode> selectedNodes = view()->selectedQmlItemNodes();
|
||||
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem
|
||||
&& selectedNodes.contains(formEditorItem->qmlItemNode())
|
||||
&& !formEditorItem->qmlItemNode().isRootNode()
|
||||
&& (formEditorItem->qmlItemNode().hasShowContent()))
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem
|
||||
&& !formEditorItem->qmlItemNode().isRootNode()
|
||||
&& selectedNodes.contains(formEditorItem->qmlItemNode()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool AbstractFormEditorTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||
return item;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
FormEditorItem *AbstractFormEditorTool::topMovableFormEditorItem(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem
|
||||
&& (formEditorItem->qmlItemNode().hasShowContent()))
|
||||
return formEditorItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
FormEditorItem* AbstractFormEditorTool::topFormEditorItem(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem && !formEditorItem->qmlItemNode().isRootNode())
|
||||
return formEditorItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
FormEditorItem* AbstractFormEditorTool::topFormEditorItemWithRootItem(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem)
|
||||
return formEditorItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractFormEditorTool::dropEvent(QGraphicsSceneDragDropEvent * /* event */)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
void AbstractFormEditorTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
event->accept();
|
||||
view()->changeToDragTool();
|
||||
view()->currentTool()->dragEnterEvent(event);
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractFormEditorTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * /* event */)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
void AbstractFormEditorTool::dragMoveEvent(QGraphicsSceneDragDropEvent * /* event */)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ABSTRACTFORMEDITORTOOL_H
|
||||
#define ABSTRACTFORMEDITORTOOL_H
|
||||
|
||||
#include "formeditoritem.h"
|
||||
|
||||
class QGraphicsItem;
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorView;
|
||||
|
||||
class AbstractFormEditorTool
|
||||
{
|
||||
|
||||
public:
|
||||
AbstractFormEditorTool(FormEditorView* view);
|
||||
|
||||
virtual ~AbstractFormEditorTool();
|
||||
|
||||
virtual void mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) = 0;
|
||||
virtual void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) = 0;
|
||||
virtual void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) = 0;
|
||||
virtual void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) = 0;
|
||||
|
||||
virtual void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event) = 0;
|
||||
|
||||
virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *event) = 0;
|
||||
virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
|
||||
|
||||
virtual void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList) = 0;
|
||||
// virtual QVariant itemChange(QList<QGraphicsItem*> itemList,
|
||||
// QGraphicsItem::GraphicsItemChange change,
|
||||
// const QVariant &value ) = 0;
|
||||
// virtual void update() = 0;
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void formEditorItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
|
||||
|
||||
void setItems(const QList<FormEditorItem*> &itemList);
|
||||
QList<FormEditorItem*> items() const;
|
||||
|
||||
static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
|
||||
static FormEditorItem* topMovableFormEditorItem(const QList<QGraphicsItem*> &itemList);
|
||||
bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
|
||||
bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
|
||||
bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
static FormEditorItem* topFormEditorItem(const QList<QGraphicsItem*> &itemList);
|
||||
static FormEditorItem* topFormEditorItemWithRootItem(const QList<QGraphicsItem*> &itemList);
|
||||
protected:
|
||||
|
||||
virtual void selectedItemsChanged(const QList<FormEditorItem*> &itemList) = 0;
|
||||
|
||||
|
||||
FormEditorView *view() const;
|
||||
FormEditorScene* scene() const;
|
||||
private:
|
||||
FormEditorView *m_view;
|
||||
QList<FormEditorItem*> m_itemList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ABSTRACTFORMEDITORTOOL_H
|
||||
BIN
src/plugins/qmldesigner/components/formeditor/anchor.png
Normal file
|
After Width: | Height: | Size: 415 B |
@@ -0,0 +1,537 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorcontroller.h"
|
||||
|
||||
#include "formeditoritem.h"
|
||||
#include "layeritem.h"
|
||||
#include "formeditorscene.h"
|
||||
#include "anchorhandleitem.h"
|
||||
#include <QtDebug>
|
||||
#include <cmath>
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorControllerData::AnchorControllerData(LayerItem *layerItem, FormEditorItem *formEditorItem)
|
||||
: layerItem(layerItem),
|
||||
formEditorItem(formEditorItem),
|
||||
topItem(0),
|
||||
leftItem(0),
|
||||
rightItem(0),
|
||||
bottomItem(0)
|
||||
{
|
||||
}
|
||||
|
||||
AnchorControllerData::AnchorControllerData(const AnchorControllerData &other)
|
||||
: layerItem(other.layerItem),
|
||||
formEditorItem(other.formEditorItem),
|
||||
topItem(other.topItem),
|
||||
leftItem(other.leftItem),
|
||||
rightItem(other.rightItem),
|
||||
bottomItem(other.bottomItem)
|
||||
{
|
||||
}
|
||||
|
||||
AnchorControllerData::~AnchorControllerData()
|
||||
{
|
||||
if (layerItem) {
|
||||
layerItem->scene()->removeItem(topItem);
|
||||
layerItem->scene()->removeItem(leftItem);
|
||||
layerItem->scene()->removeItem(rightItem);
|
||||
layerItem->scene()->removeItem(bottomItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AnchorController::AnchorController()
|
||||
: m_data(new AnchorControllerData(0, 0))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AnchorController::AnchorController(const QSharedPointer<AnchorControllerData> &data)
|
||||
: m_data(data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AnchorController::AnchorController(LayerItem *layerItem, FormEditorItem *formEditorItem)
|
||||
: m_data(new AnchorControllerData(layerItem, formEditorItem))
|
||||
{
|
||||
m_data->topItem = new AnchorHandleItem(layerItem, *this);
|
||||
m_data->topItem->setZValue(400);
|
||||
m_data->topItem->setToolTip(m_data->topItem->toolTipString());
|
||||
|
||||
m_data->leftItem = new AnchorHandleItem(layerItem, *this);
|
||||
m_data->leftItem->setZValue(400);
|
||||
m_data->leftItem->setToolTip(m_data->leftItem->toolTipString());
|
||||
|
||||
m_data->rightItem = new AnchorHandleItem(layerItem, *this);
|
||||
m_data->rightItem->setZValue(400);
|
||||
m_data->rightItem->setToolTip(m_data->rightItem->toolTipString());
|
||||
|
||||
m_data->bottomItem = new AnchorHandleItem(layerItem, *this);
|
||||
m_data->bottomItem->setZValue(400);
|
||||
m_data->bottomItem->setToolTip(m_data->bottomItem->toolTipString());
|
||||
|
||||
m_data->sceneTransform = formEditorItem->sceneTransform();
|
||||
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
|
||||
bool AnchorController::isValid() const
|
||||
{
|
||||
return m_data->formEditorItem != 0;
|
||||
}
|
||||
|
||||
void AnchorController::show()
|
||||
{
|
||||
m_data->topItem->show();
|
||||
m_data->leftItem->show();
|
||||
m_data->rightItem->show();
|
||||
m_data->bottomItem->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AnchorController::hide()
|
||||
{
|
||||
m_data->topItem->hide();
|
||||
m_data->leftItem->hide();
|
||||
m_data->rightItem->hide();
|
||||
m_data->bottomItem->hide();
|
||||
}
|
||||
|
||||
|
||||
static QPointF topCenter(const QRectF &rect)
|
||||
{
|
||||
return QPointF(rect.center().x(), rect.top());
|
||||
}
|
||||
|
||||
static QPointF leftCenter(const QRectF &rect)
|
||||
{
|
||||
return QPointF(rect.left(), rect.center().y());
|
||||
}
|
||||
|
||||
static QPointF rightCenter(const QRectF &rect)
|
||||
{
|
||||
return QPointF(rect.right(), rect.center().y());
|
||||
}
|
||||
|
||||
static QPointF bottomCenter(const QRectF &rect)
|
||||
{
|
||||
return QPointF(rect.center().x(), rect.bottom());
|
||||
}
|
||||
|
||||
static QPainterPath curveToPath(const QPointF &firstPoint,
|
||||
const QPointF &secondPoint,
|
||||
const QPointF &thirdPoint,
|
||||
const QPointF &fourthPoint)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.moveTo(firstPoint);
|
||||
path.cubicTo(secondPoint, thirdPoint, fourthPoint);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
static QPointF anchorPoint(const QRectF &boundingRect, AnchorLine::Type anchorLine, double baseOffset, double innerOffset = 0.0)
|
||||
{
|
||||
switch(anchorLine) {
|
||||
case AnchorLine::Top : return topCenter(boundingRect) + QPointF(baseOffset, innerOffset);
|
||||
case AnchorLine::Bottom : return bottomCenter(boundingRect) - QPointF(baseOffset, innerOffset);
|
||||
case AnchorLine::Left : return leftCenter(boundingRect) + QPointF(innerOffset, baseOffset);
|
||||
case AnchorLine::Right : return rightCenter(boundingRect) - QPointF(innerOffset, baseOffset);
|
||||
default: return QPointF();
|
||||
}
|
||||
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
|
||||
static QPainterPath createArrowPath(QPointF arrowCenter, double arrowDegrees)
|
||||
{
|
||||
QRectF arrowRect(0.0, 0.0, 16., 16.);
|
||||
arrowRect.moveCenter(arrowCenter);
|
||||
QPainterPath arrowPath;
|
||||
|
||||
|
||||
arrowPath.moveTo(arrowCenter);
|
||||
|
||||
arrowPath.arcTo(arrowRect, arrowDegrees + 180 - 20, 40.);
|
||||
|
||||
return arrowPath;
|
||||
}
|
||||
|
||||
AnchorHandlePathData AnchorController::createPainterPathForAnchor(const QRectF &boundingRect,
|
||||
AnchorLine::Type anchorLine,
|
||||
const QPointF &targetPoint) const
|
||||
{
|
||||
|
||||
|
||||
QPointF firstPointInLayerSpace(m_data->sceneTransform.map(anchorPoint(boundingRect, anchorLine, 0.0, 5.0)));
|
||||
|
||||
QPointF topLeftBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.topLeft()));
|
||||
QPointF bottomLeftBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.bottomLeft()));
|
||||
QPointF topRightBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.topRight()));
|
||||
QPointF bottomRightBoundingBoxInLayerSpace(m_data->sceneTransform.map(boundingRect.bottomRight()));
|
||||
|
||||
AnchorLine::Type secondAnchorLine(AnchorLine::Invalid);
|
||||
|
||||
QPointF secondPointInLayerSpace(targetPoint);
|
||||
if (targetPoint.isNull()) {
|
||||
AnchorLine targetAnchorLine(m_data->formEditorItem->qmlItemNode().anchors().instanceAnchor(anchorLine));
|
||||
secondAnchorLine = targetAnchorLine.type();
|
||||
FormEditorItem *targetItem = m_data->formEditorItem->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode());;
|
||||
bool secondItemIsParent = m_data->formEditorItem->parentItem() == targetItem;
|
||||
|
||||
if (secondItemIsParent)
|
||||
secondPointInLayerSpace = (targetItem->mapToItem(m_data->layerItem.data(),
|
||||
anchorPoint(targetItem->qmlItemNode().instanceBoundingRect(), targetAnchorLine.type(), 0.0)));
|
||||
else
|
||||
|
||||
secondPointInLayerSpace = (targetItem->mapToItem(m_data->layerItem.data(),
|
||||
anchorPoint(targetItem->qmlItemNode().instanceBoundingRect(), targetAnchorLine.type(), 0.0)));
|
||||
}
|
||||
|
||||
QPointF firstControlPointInLayerSpace = (3. * firstPointInLayerSpace + 3 * secondPointInLayerSpace) / 6.;
|
||||
QPointF secondControlPointInLayerSpace = (3 * firstPointInLayerSpace + 3. * secondPointInLayerSpace) / 6.;
|
||||
|
||||
bool showAnchorLine(true);
|
||||
switch (anchorLine) {
|
||||
case AnchorLine::Top :
|
||||
case AnchorLine::Bottom :
|
||||
firstControlPointInLayerSpace.rx() = firstPointInLayerSpace.x();
|
||||
if (qAbs(secondPointInLayerSpace.y() - firstPointInLayerSpace.y()) < 18.0)
|
||||
showAnchorLine = false;
|
||||
if (qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) < 20.0 &&
|
||||
qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) > 20.0) {
|
||||
firstControlPointInLayerSpace.ry() = firstPointInLayerSpace.y() + ((firstControlPointInLayerSpace.y() - firstPointInLayerSpace.y() > 0) ? 20 : -20);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Left :
|
||||
case AnchorLine::Right :
|
||||
firstControlPointInLayerSpace.ry() = firstPointInLayerSpace.y();
|
||||
if (qAbs(secondPointInLayerSpace.x() - firstPointInLayerSpace.x()) < 18.0)
|
||||
showAnchorLine = false;
|
||||
if (qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) < 20.0 &&
|
||||
qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) > 20.0) {
|
||||
firstControlPointInLayerSpace.rx() = firstPointInLayerSpace.x() + ((firstControlPointInLayerSpace.x() - firstPointInLayerSpace.x() > 0) ? 20 : -20);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(secondAnchorLine) {
|
||||
case AnchorLine::Top :
|
||||
case AnchorLine::Bottom :
|
||||
secondControlPointInLayerSpace.rx() = secondPointInLayerSpace.x();
|
||||
if (qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) < 20.0 &&
|
||||
qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) > 20.0) {
|
||||
secondControlPointInLayerSpace.ry() = secondPointInLayerSpace.y() + ((secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y() < 0) ? 20 : -20);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Left :
|
||||
case AnchorLine::Right :
|
||||
secondControlPointInLayerSpace.ry() = secondPointInLayerSpace.y();
|
||||
if (qAbs(secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x()) < 20.0 &&
|
||||
qAbs(secondControlPointInLayerSpace.y() - secondPointInLayerSpace.y()) > 20.0) {
|
||||
secondControlPointInLayerSpace.rx() = secondPointInLayerSpace.x() + ((secondControlPointInLayerSpace.x() - secondPointInLayerSpace.x() < 0) ? 20 : -20);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
QPainterPath anchorLinePath;
|
||||
anchorLinePath.setFillRule(Qt::WindingFill);
|
||||
|
||||
QRectF baseRect(0.0, 0.0, 5., 5.);
|
||||
baseRect.moveCenter(firstPointInLayerSpace);
|
||||
QPainterPath basePath;
|
||||
basePath.addRoundedRect(baseRect, 6., 6.);
|
||||
anchorLinePath = anchorLinePath.united(basePath);
|
||||
|
||||
QRectF baseLineRect;
|
||||
switch (anchorLine) {
|
||||
case AnchorLine::Left : {
|
||||
baseLineRect = QRectF(topLeftBoundingBoxInLayerSpace, bottomLeftBoundingBoxInLayerSpace);
|
||||
baseLineRect.setWidth(3);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Top : {
|
||||
baseLineRect = QRectF(topLeftBoundingBoxInLayerSpace, topRightBoundingBoxInLayerSpace);
|
||||
baseLineRect.setHeight(3);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Right : {
|
||||
baseLineRect = QRectF(topRightBoundingBoxInLayerSpace, bottomRightBoundingBoxInLayerSpace);
|
||||
baseLineRect.adjust(-3, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Bottom : {
|
||||
baseLineRect = QRectF(bottomLeftBoundingBoxInLayerSpace, bottomRightBoundingBoxInLayerSpace);
|
||||
baseLineRect.adjust(0, -3, 0, 0);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (!baseLineRect.isEmpty()) {
|
||||
|
||||
QPainterPath baseLinePath;
|
||||
baseLinePath.addRoundedRect(baseLineRect, 1., 1.);
|
||||
anchorLinePath = anchorLinePath.united(baseLinePath);
|
||||
}
|
||||
|
||||
QPainterPath arrowPath;
|
||||
arrowPath.setFillRule(Qt::WindingFill);
|
||||
|
||||
|
||||
|
||||
if (showAnchorLine) {
|
||||
QPainterPath curvePath(curveToPath(firstPointInLayerSpace,
|
||||
firstControlPointInLayerSpace,
|
||||
secondControlPointInLayerSpace,
|
||||
secondPointInLayerSpace));
|
||||
|
||||
double arrowDegrees = curvePath.angleAtPercent(curvePath.percentAtLength(curvePath.length() - 2.5));
|
||||
|
||||
|
||||
|
||||
QPainterPathStroker arrowPathStroker;
|
||||
arrowPathStroker.setWidth(2.0);
|
||||
arrowPathStroker.setCapStyle(Qt::RoundCap);
|
||||
|
||||
arrowPath = arrowPath.united(arrowPathStroker.createStroke(curvePath));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QRectF arrowCutRect(0.0, 0.0, 8., 8.);
|
||||
arrowCutRect.moveCenter(secondPointInLayerSpace);
|
||||
QPainterPath arrowCutPath;
|
||||
arrowCutPath.addRect(arrowCutRect);
|
||||
arrowPath = arrowPath.subtracted(arrowCutPath);
|
||||
|
||||
arrowPath = arrowPath.united(createArrowPath(secondPointInLayerSpace, arrowDegrees));
|
||||
}
|
||||
|
||||
AnchorHandlePathData pathData;
|
||||
pathData.arrowPath = arrowPath;
|
||||
pathData.sourceAnchorLinePath = anchorLinePath;
|
||||
pathData.beginArrowPoint = firstPointInLayerSpace;
|
||||
pathData.endArrowPoint = secondPointInLayerSpace;
|
||||
|
||||
pathData.targetAnchorLinePath = createTargetAnchorLinePath(anchorLine);
|
||||
pathData.targetNamePath = createTargetNamePathPath(anchorLine);
|
||||
|
||||
return pathData;
|
||||
}
|
||||
|
||||
QPainterPath AnchorController::createTargetNamePathPath(AnchorLine::Type anchorLine) const
|
||||
{
|
||||
QPainterPath path;
|
||||
QmlAnchors anchors(formEditorItem()->qmlItemNode().anchors());
|
||||
if (anchors.instanceHasAnchor(anchorLine)) {
|
||||
AnchorLine targetAnchorLine(anchors.instanceAnchor(anchorLine));
|
||||
|
||||
FormEditorItem *targetItem = formEditorItem()->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode());
|
||||
QRectF boundingRect(targetItem->qmlItemNode().instanceBoundingRect());
|
||||
|
||||
QTransform sceneTransform(targetItem->qmlItemNode().instanceSceneTransform());
|
||||
|
||||
QPointF centerBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.center()));
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(24);
|
||||
QString nameString(QString("%1 (%2)").arg(targetAnchorLine.qmlItemNode().simplfiedTypeName()).arg(targetAnchorLine.qmlItemNode().id()));
|
||||
path.addText(0., -4., font, nameString);
|
||||
//path.translate(centerBoundingBoxInLayerSpace - path.qmlItemNode().instanceBoundingRect().center());
|
||||
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
QPainterPath AnchorController::createTargetAnchorLinePath(AnchorLine::Type anchorLine) const
|
||||
{
|
||||
QPainterPath path;
|
||||
QmlAnchors anchors(formEditorItem()->qmlItemNode().anchors());
|
||||
if (anchors.instanceHasAnchor(anchorLine)) {
|
||||
AnchorLine targetAnchorLine(anchors.instanceAnchor(anchorLine));
|
||||
|
||||
FormEditorItem *targetItem = formEditorItem()->scene()->itemForQmlItemNode(targetAnchorLine.qmlItemNode());
|
||||
QRectF boundingRect(targetItem->qmlItemNode().instanceBoundingRect());
|
||||
|
||||
QTransform sceneTransform(targetItem->qmlItemNode().instanceSceneTransform());
|
||||
|
||||
QPointF topLeftBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.topLeft()));
|
||||
QPointF bottomLeftBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.bottomLeft()));
|
||||
QPointF topRightBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.topRight()));
|
||||
QPointF bottomRightBoundingBoxInLayerSpace(sceneTransform.map(boundingRect.bottomRight()));
|
||||
|
||||
|
||||
switch(targetAnchorLine.type()) {
|
||||
case AnchorLine::Top : {
|
||||
path.moveTo(topLeftBoundingBoxInLayerSpace);
|
||||
path.lineTo(topRightBoundingBoxInLayerSpace);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Bottom : {
|
||||
path.moveTo(bottomLeftBoundingBoxInLayerSpace);
|
||||
path.lineTo(bottomRightBoundingBoxInLayerSpace);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Left : {
|
||||
path.moveTo(topLeftBoundingBoxInLayerSpace);
|
||||
path.lineTo(bottomLeftBoundingBoxInLayerSpace);
|
||||
}
|
||||
break;
|
||||
case AnchorLine::Right : {
|
||||
path.moveTo(topRightBoundingBoxInLayerSpace);
|
||||
path.lineTo(bottomRightBoundingBoxInLayerSpace);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
QPainterPathStroker pathStroker;
|
||||
pathStroker.setWidth(20.0);
|
||||
pathStroker.setCapStyle(Qt::RoundCap);
|
||||
path = pathStroker.createStroke(path);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void AnchorController::updatePosition()
|
||||
{
|
||||
QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();
|
||||
QPointF beginPoint;
|
||||
QPointF endPoint;
|
||||
QmlAnchors anchors(m_data->formEditorItem->qmlItemNode().anchors());
|
||||
m_data->sceneTransform = m_data->formEditorItem->sceneTransform();
|
||||
|
||||
if (anchors.instanceHasAnchor(AnchorLine::Top))
|
||||
m_data->topItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Top));
|
||||
else
|
||||
m_data->topItem->setHandlePath(AnchorHandlePathData());
|
||||
|
||||
if (anchors.instanceHasAnchor(AnchorLine::Bottom))
|
||||
m_data->bottomItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Bottom));
|
||||
else
|
||||
m_data->bottomItem->setHandlePath(AnchorHandlePathData());
|
||||
|
||||
if (anchors.instanceHasAnchor(AnchorLine::Right))
|
||||
m_data->rightItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Right));
|
||||
else
|
||||
m_data->rightItem->setHandlePath(AnchorHandlePathData());
|
||||
|
||||
if (anchors.instanceHasAnchor(AnchorLine::Left))
|
||||
m_data->leftItem->setHandlePath(createPainterPathForAnchor(boundingRect, AnchorLine::Left));
|
||||
else
|
||||
m_data->leftItem->setHandlePath(AnchorHandlePathData());
|
||||
}
|
||||
|
||||
|
||||
FormEditorItem* AnchorController::formEditorItem() const
|
||||
{
|
||||
return m_data->formEditorItem;
|
||||
}
|
||||
|
||||
QWeakPointer<AnchorControllerData> AnchorController::weakPointer() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
bool AnchorController::isTopHandle(const AnchorHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->topItem;
|
||||
}
|
||||
|
||||
bool AnchorController::isLeftHandle(const AnchorHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->leftItem;
|
||||
}
|
||||
|
||||
bool AnchorController::isRightHandle(const AnchorHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->rightItem;
|
||||
}
|
||||
|
||||
bool AnchorController::isBottomHandle(const AnchorHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->bottomItem;
|
||||
}
|
||||
|
||||
void AnchorController::updateTargetPoint(AnchorLine::Type anchorLine, const QPointF &targetPoint)
|
||||
{
|
||||
QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();
|
||||
|
||||
switch(anchorLine) {
|
||||
case AnchorLine::Top :
|
||||
m_data->topItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break;
|
||||
case AnchorLine::Bottom :
|
||||
m_data->bottomItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break;
|
||||
case AnchorLine::Left :
|
||||
m_data->leftItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break;
|
||||
case AnchorLine::Right :
|
||||
m_data->rightItem->setHandlePath(createPainterPathForAnchor(boundingRect, anchorLine, targetPoint)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorController::highlight(AnchorLine::Type anchorLine)
|
||||
{
|
||||
switch(anchorLine) {
|
||||
case AnchorLine::Top :
|
||||
m_data->topItem->setHighlighted(true); break;
|
||||
case AnchorLine::Bottom :
|
||||
m_data->bottomItem->setHighlighted(true); break;
|
||||
case AnchorLine::Left :
|
||||
m_data->leftItem->setHighlighted(true); break;
|
||||
case AnchorLine::Right :
|
||||
m_data->rightItem->setHighlighted(true); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorController::clearHighlight()
|
||||
{
|
||||
m_data->topItem->setHighlighted(false);
|
||||
m_data->leftItem->setHighlighted(false);
|
||||
m_data->rightItem->setHighlighted(false);
|
||||
m_data->bottomItem->setHighlighted(false);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
117
src/plugins/qmldesigner/components/formeditor/anchorcontroller.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORCONTROLLER_H
|
||||
#define ANCHORCONTROLLER_H
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QPainterPath>
|
||||
#include <QPair>
|
||||
#include <QTransform>
|
||||
#include <qmlanchors.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
struct AnchorHandlePathData
|
||||
{
|
||||
QPainterPath sourceAnchorLinePath;
|
||||
QPainterPath targetAnchorLinePath;
|
||||
QPainterPath arrowPath;
|
||||
QPainterPath targetNamePath;
|
||||
QPointF beginArrowPoint;
|
||||
QPointF endArrowPoint;
|
||||
};
|
||||
|
||||
class FormEditorItem;
|
||||
class LayerItem;
|
||||
class AnchorHandleItem;
|
||||
|
||||
class AnchorControllerData
|
||||
{
|
||||
public:
|
||||
AnchorControllerData(LayerItem *layerItem,
|
||||
FormEditorItem *formEditorItem);
|
||||
AnchorControllerData(const AnchorControllerData &other);
|
||||
~AnchorControllerData();
|
||||
|
||||
QWeakPointer<LayerItem> layerItem;
|
||||
FormEditorItem *formEditorItem;
|
||||
|
||||
AnchorHandleItem *topItem;
|
||||
AnchorHandleItem *leftItem;
|
||||
AnchorHandleItem *rightItem;
|
||||
AnchorHandleItem *bottomItem;
|
||||
|
||||
QTransform sceneTransform;
|
||||
};
|
||||
|
||||
|
||||
class AnchorController
|
||||
{
|
||||
public:
|
||||
AnchorController();
|
||||
AnchorController(LayerItem *layerItem, FormEditorItem *formEditorItem);
|
||||
AnchorController(const QSharedPointer<AnchorControllerData> &data);
|
||||
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void updatePosition();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QWeakPointer<AnchorControllerData> weakPointer() const;
|
||||
|
||||
|
||||
FormEditorItem *formEditorItem() const;
|
||||
|
||||
bool isTopHandle(const AnchorHandleItem *handle) const;
|
||||
bool isLeftHandle(const AnchorHandleItem *handle) const;
|
||||
bool isRightHandle(const AnchorHandleItem *handle) const;
|
||||
bool isBottomHandle(const AnchorHandleItem *handle) const;
|
||||
|
||||
void updateTargetPoint(AnchorLine::Type anchorLine, const QPointF &targetPoint);
|
||||
|
||||
void clearHighlight();
|
||||
void highlight(AnchorLine::Type anchorLine);
|
||||
|
||||
private: //functions
|
||||
AnchorHandlePathData createPainterPathForAnchor(const QRectF &boundingRect,
|
||||
AnchorLine::Type anchorLine,
|
||||
const QPointF &targetPoint = QPointF()) const;
|
||||
QPainterPath createTargetAnchorLinePath(AnchorLine::Type anchorLine) const;
|
||||
QPainterPath createTargetNamePathPath(AnchorLine::Type anchorLine) const;
|
||||
private:
|
||||
QSharedPointer<AnchorControllerData> m_data;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORCONTROLLER_H
|
||||
@@ -0,0 +1,212 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorhandleitem.h"
|
||||
|
||||
#include <formeditoritem.h>
|
||||
#include <QPen>
|
||||
#include <QPainterPathStroker>
|
||||
#include <cmath>
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorHandleItem::AnchorHandleItem(QGraphicsItem *parent, const AnchorController &anchorController)
|
||||
: QGraphicsItemGroup(parent),
|
||||
m_anchorControllerData(anchorController.weakPointer()),
|
||||
m_sourceAnchorLinePathItem(new QGraphicsPathItem(this)),
|
||||
m_arrowPathItem(new QGraphicsPathItem(this)),
|
||||
m_targetAnchorLinePathItem(new QGraphicsPathItem(this)),
|
||||
m_targetNamePathItem(new QGraphicsPathItem(this))
|
||||
{
|
||||
addToGroup(m_sourceAnchorLinePathItem);
|
||||
addToGroup(m_arrowPathItem);
|
||||
addToGroup(m_targetAnchorLinePathItem);
|
||||
addToGroup(m_targetNamePathItem);
|
||||
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
|
||||
AnchorLine::Type AnchorHandleItem::sourceAnchorLine() const
|
||||
{
|
||||
if (isTopHandle())
|
||||
return AnchorLine::Top;
|
||||
if (isBottomHandle())
|
||||
return AnchorLine::Bottom;
|
||||
if (isLeftHandle())
|
||||
return AnchorLine::Left;
|
||||
if (isRightHandle())
|
||||
return AnchorLine::Right;
|
||||
|
||||
return AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
AnchorLine AnchorHandleItem::targetAnchorLine() const
|
||||
{
|
||||
QmlAnchors anchors(anchorController().formEditorItem()->qmlItemNode().anchors());
|
||||
|
||||
if (isTopHandle())
|
||||
return anchors.instanceAnchor(AnchorLine::Top);
|
||||
if (isBottomHandle())
|
||||
return anchors.instanceAnchor(AnchorLine::Bottom);
|
||||
if (isLeftHandle())
|
||||
return anchors.instanceAnchor(AnchorLine::Left);
|
||||
if (isRightHandle())
|
||||
return anchors.instanceAnchor(AnchorLine::Right);
|
||||
|
||||
return AnchorLine();
|
||||
}
|
||||
|
||||
static QString anchorLineToString(AnchorLine::Type anchorLineType)
|
||||
{
|
||||
switch(anchorLineType) {
|
||||
case AnchorLine::Top: return "Top";
|
||||
case AnchorLine::Bottom: return "Bottom";
|
||||
case AnchorLine::Left: return "Left";
|
||||
case AnchorLine::Right: return "Right";
|
||||
default: break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
||||
}
|
||||
|
||||
QString AnchorHandleItem::toolTipString() const
|
||||
{
|
||||
QString templateString("<p>Anchor Handle</p><p>%1</p><p>%2</p>");
|
||||
QmlItemNode fromNode(anchorController().formEditorItem()->qmlItemNode());
|
||||
QString fromString(QString("%3: %1(%2)").arg(fromNode.simplfiedTypeName(), fromNode.id(), anchorLineToString(sourceAnchorLine())));
|
||||
|
||||
AnchorLine toAnchorLine(targetAnchorLine());
|
||||
QmlItemNode toNode(toAnchorLine.qmlItemNode());
|
||||
QString toString;
|
||||
if (toNode.isValid())
|
||||
toString = QString("%3: %1(%2)").arg(toNode.simplfiedTypeName(), toNode.id(), anchorLineToString(toAnchorLine.type()));
|
||||
|
||||
return templateString.arg(fromString).arg(toString);
|
||||
}
|
||||
|
||||
void AnchorHandleItem::setHandlePath(const AnchorHandlePathData &pathData)
|
||||
{
|
||||
m_beginArrowPoint = pathData.beginArrowPoint;
|
||||
m_endArrowPoint = pathData.endArrowPoint;
|
||||
m_arrowPathItem->setPath(pathData.arrowPath);
|
||||
m_sourceAnchorLinePathItem->setPath(pathData.sourceAnchorLinePath);
|
||||
m_targetAnchorLinePathItem->setPath(pathData.targetAnchorLinePath);
|
||||
m_targetNamePathItem->setPath(pathData.targetNamePath);
|
||||
|
||||
setHighlighted(false);
|
||||
}
|
||||
|
||||
AnchorController AnchorHandleItem::anchorController() const
|
||||
{
|
||||
Q_ASSERT(!m_anchorControllerData.isNull());
|
||||
return AnchorController(m_anchorControllerData.toStrongRef());
|
||||
}
|
||||
|
||||
AnchorHandleItem* AnchorHandleItem::fromGraphicsItem(QGraphicsItem *item)
|
||||
{
|
||||
return qgraphicsitem_cast<AnchorHandleItem*>(item);
|
||||
}
|
||||
|
||||
bool AnchorHandleItem::isTopHandle() const
|
||||
{
|
||||
return anchorController().isTopHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorHandleItem::isLeftHandle() const
|
||||
{
|
||||
return anchorController().isLeftHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorHandleItem::isRightHandle() const
|
||||
{
|
||||
return anchorController().isRightHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorHandleItem::isBottomHandle() const
|
||||
{
|
||||
return anchorController().isBottomHandle(this);
|
||||
}
|
||||
|
||||
AnchorLine::Type AnchorHandleItem::anchorType() const
|
||||
{
|
||||
if (isTopHandle())
|
||||
return AnchorLine::Top;
|
||||
|
||||
if (isBottomHandle())
|
||||
return AnchorLine::Bottom;
|
||||
|
||||
if (isLeftHandle())
|
||||
return AnchorLine::Left;
|
||||
|
||||
if (isRightHandle())
|
||||
return AnchorLine::Right;
|
||||
|
||||
|
||||
return AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
void AnchorHandleItem::setHighlighted(bool highlight)
|
||||
{
|
||||
QLinearGradient gradient(m_beginArrowPoint, m_endArrowPoint);
|
||||
gradient.setCoordinateMode(QGradient::LogicalMode);
|
||||
m_arrowPathItem->setPen(QPen(QBrush(Qt::gray), 1.0, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
|
||||
m_targetAnchorLinePathItem->setPen(QColor(70, 0, 0, 90));
|
||||
m_targetAnchorLinePathItem->setBrush(QColor(255, 0, 0, 50));
|
||||
m_arrowPathItem->setPen(QPen(QBrush(Qt::gray), 1.0, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
|
||||
m_targetNamePathItem->setPen(QColor(0, 0, 255, 90));
|
||||
m_targetNamePathItem->setBrush(QColor(0, 0, 255, 50));
|
||||
|
||||
if (highlight) {
|
||||
gradient.setColorAt(0.0, QColor(0, 0, 120, 255));
|
||||
gradient.setColorAt(1.0, QColor(120, 0, 0, 255));
|
||||
m_arrowPathItem->setBrush(gradient);
|
||||
m_sourceAnchorLinePathItem->setPen(QColor(0, 0, 70, 255));
|
||||
m_sourceAnchorLinePathItem->setBrush(QColor(0, 0, 70, 255));
|
||||
m_targetAnchorLinePathItem->show();
|
||||
m_targetNamePathItem->show();
|
||||
|
||||
} else {
|
||||
gradient.setColorAt(0.0, QColor(0, 0, 255, 255));
|
||||
gradient.setColorAt(1.0, QColor(255, 0, 0, 255));
|
||||
m_arrowPathItem->setBrush(gradient);
|
||||
m_sourceAnchorLinePathItem->setPen(QColor(0, 0, 100, 255));
|
||||
m_sourceAnchorLinePathItem->setBrush(QColor(0, 0, 100, 255));
|
||||
m_targetAnchorLinePathItem->hide();
|
||||
m_targetNamePathItem->hide();
|
||||
}
|
||||
}
|
||||
|
||||
QPointF AnchorHandleItem::itemSpacePosition() const
|
||||
{
|
||||
return parentItem()->mapToItem(anchorController().formEditorItem(), pos());
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,91 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORHANDLEITEM_H
|
||||
#define ANCHORHANDLEITEM_H
|
||||
|
||||
#include <QGraphicsItemGroup>
|
||||
|
||||
#include "anchorcontroller.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnchorHandleItem : public QGraphicsItemGroup
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
Type = 0xEAEC
|
||||
};
|
||||
|
||||
|
||||
AnchorHandleItem(QGraphicsItem *parent, const AnchorController &anchorController);
|
||||
|
||||
void setHandlePath(const AnchorHandlePathData &pathData);
|
||||
|
||||
int type() const;
|
||||
|
||||
AnchorController anchorController() const;
|
||||
|
||||
static AnchorHandleItem* fromGraphicsItem(QGraphicsItem *item);
|
||||
|
||||
|
||||
bool isTopHandle() const;
|
||||
bool isLeftHandle() const;
|
||||
bool isRightHandle() const;
|
||||
bool isBottomHandle() const;
|
||||
|
||||
QPointF itemSpacePosition() const;
|
||||
|
||||
AnchorLine::Type anchorType() const;
|
||||
|
||||
QString toolTipString() const;
|
||||
AnchorLine targetAnchorLine() const;
|
||||
AnchorLine::Type sourceAnchorLine() const;
|
||||
|
||||
void setHighlighted(bool highlight);
|
||||
|
||||
private:
|
||||
QWeakPointer<AnchorControllerData> m_anchorControllerData;
|
||||
QGraphicsPathItem *m_sourceAnchorLinePathItem;
|
||||
QGraphicsPathItem *m_arrowPathItem;
|
||||
QGraphicsPathItem *m_targetAnchorLinePathItem;
|
||||
QGraphicsPathItem *m_targetNamePathItem;
|
||||
QPointF m_beginArrowPoint;
|
||||
QPointF m_endArrowPoint;
|
||||
};
|
||||
|
||||
inline int AnchorHandleItem::type() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORHANDLEITEM_H
|
||||
@@ -0,0 +1,116 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorindicator.h"
|
||||
|
||||
#include <QSet>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorIndicator::AnchorIndicator(LayerItem *layerItem)
|
||||
: m_layerItem(layerItem)
|
||||
{
|
||||
Q_ASSERT(layerItem);
|
||||
}
|
||||
|
||||
AnchorIndicator::~AnchorIndicator()
|
||||
{
|
||||
m_itemControllerHash.clear();
|
||||
}
|
||||
|
||||
void AnchorIndicator::show()
|
||||
{
|
||||
QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash);
|
||||
while (itemControllerIterator.hasNext()) {
|
||||
AnchorController controller = itemControllerIterator.next().value();
|
||||
controller.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AnchorIndicator::hide()
|
||||
{
|
||||
QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash);
|
||||
while (itemControllerIterator.hasNext()) {
|
||||
AnchorController controller = itemControllerIterator.next().value();
|
||||
controller.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorIndicator::clear()
|
||||
{
|
||||
m_itemControllerHash.clear();
|
||||
}
|
||||
|
||||
void AnchorIndicator::setItems(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
clear();
|
||||
|
||||
foreach (FormEditorItem *item, itemList) {
|
||||
AnchorController controller(m_layerItem, item);
|
||||
m_itemControllerHash.insert(item, controller);
|
||||
}
|
||||
|
||||
updateItems(itemList);
|
||||
}
|
||||
|
||||
void AnchorIndicator::updateItems(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
foreach (FormEditorItem *item, itemList) {
|
||||
if (m_itemControllerHash.contains(item)) {
|
||||
AnchorController controller(m_itemControllerHash.value(item));
|
||||
controller.updatePosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorIndicator::updateTargetPoint(FormEditorItem *item, AnchorLine::Type anchorLine, const QPointF &targetPoint)
|
||||
{
|
||||
AnchorController controller(m_itemControllerHash.value(item));
|
||||
controller.updateTargetPoint(anchorLine, targetPoint);
|
||||
}
|
||||
|
||||
void AnchorIndicator::clearHighlight()
|
||||
{
|
||||
QHashIterator<FormEditorItem*, AnchorController> itemControllerIterator(m_itemControllerHash);
|
||||
while (itemControllerIterator.hasNext()) {
|
||||
AnchorController controller = itemControllerIterator.next().value();
|
||||
controller.clearHighlight();
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorIndicator::highlight(FormEditorItem *item, AnchorLine::Type anchorLine)
|
||||
{
|
||||
if (m_itemControllerHash.contains(item)) {
|
||||
AnchorController controller(m_itemControllerHash.value(item));
|
||||
controller.highlight(anchorLine);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,64 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORINDICATOR_H
|
||||
#define ANCHORINDICATOR_H
|
||||
|
||||
#include "anchorcontroller.h"
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnchorIndicator
|
||||
{
|
||||
public:
|
||||
AnchorIndicator(LayerItem *layerItem);
|
||||
~AnchorIndicator();
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
void clear();
|
||||
|
||||
void setItems(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void updateItems(const QList<FormEditorItem*> &itemList);
|
||||
void updateTargetPoint(FormEditorItem *item, AnchorLine::Type anchorLine, const QPointF &targetPoint);
|
||||
|
||||
void clearHighlight();
|
||||
void highlight(FormEditorItem *item, AnchorLine::Type anchorLine);
|
||||
|
||||
private:
|
||||
QHash<FormEditorItem*, AnchorController> m_itemControllerHash;
|
||||
LayerItem *m_layerItem;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORINDICATOR_H
|
||||
@@ -0,0 +1,236 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorlinecontroller.h"
|
||||
|
||||
#include "formeditoritem.h"
|
||||
#include "layeritem.h"
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#include "anchorlinehandleitem.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
||||
AnchorLineControllerData::AnchorLineControllerData(LayerItem *layerItem, FormEditorItem *formEditorItem)
|
||||
: layerItem(layerItem),
|
||||
formEditorItem(formEditorItem),
|
||||
topItem(0),
|
||||
leftItem(0),
|
||||
rightItem(0),
|
||||
bottomItem(0)
|
||||
{
|
||||
}
|
||||
|
||||
AnchorLineControllerData::AnchorLineControllerData(const AnchorLineControllerData &other)
|
||||
: layerItem(other.layerItem),
|
||||
formEditorItem(other.formEditorItem),
|
||||
topItem(other.topItem),
|
||||
leftItem(other.leftItem),
|
||||
rightItem(other.rightItem),
|
||||
bottomItem(other.bottomItem)
|
||||
{}
|
||||
|
||||
AnchorLineControllerData::~AnchorLineControllerData()
|
||||
{
|
||||
if (layerItem) {
|
||||
layerItem->scene()->removeItem(topItem);
|
||||
layerItem->scene()->removeItem(leftItem);
|
||||
layerItem->scene()->removeItem(rightItem);
|
||||
layerItem->scene()->removeItem(bottomItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AnchorLineController::AnchorLineController()
|
||||
: m_data(new AnchorLineControllerData(0, 0))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AnchorLineController::AnchorLineController(const QSharedPointer<AnchorLineControllerData> &data)
|
||||
: m_data(data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AnchorLineController::AnchorLineController(LayerItem *layerItem, FormEditorItem *formEditorItem)
|
||||
: m_data(new AnchorLineControllerData(layerItem, formEditorItem))
|
||||
{
|
||||
m_data->topItem = new AnchorLineHandleItem(layerItem, *this);
|
||||
m_data->topItem->setZValue(300);
|
||||
|
||||
m_data->leftItem = new AnchorLineHandleItem(layerItem, *this);
|
||||
m_data->leftItem->setZValue(300);
|
||||
|
||||
m_data->rightItem = new AnchorLineHandleItem(layerItem, *this);
|
||||
m_data->rightItem->setZValue(300);
|
||||
|
||||
m_data->bottomItem = new AnchorLineHandleItem(layerItem, *this);
|
||||
m_data->bottomItem->setZValue(300);
|
||||
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
|
||||
bool AnchorLineController::isValid() const
|
||||
{
|
||||
return m_data->formEditorItem != 0;
|
||||
}
|
||||
|
||||
void AnchorLineController::show(AnchorLine::Type anchorLineMask)
|
||||
{
|
||||
if (anchorLineMask & AnchorLine::Top)
|
||||
m_data->topItem->show();
|
||||
else
|
||||
m_data->topItem->hide();
|
||||
|
||||
if (anchorLineMask & AnchorLine::Left)
|
||||
m_data->leftItem->show();
|
||||
else
|
||||
m_data->leftItem->hide();
|
||||
|
||||
if (anchorLineMask & AnchorLine::Right)
|
||||
m_data->rightItem->show();
|
||||
else
|
||||
m_data->rightItem->hide();
|
||||
|
||||
if (anchorLineMask & AnchorLine::Bottom)
|
||||
m_data->bottomItem->show();
|
||||
else
|
||||
m_data->bottomItem->hide();
|
||||
}
|
||||
|
||||
void AnchorLineController::hide()
|
||||
{
|
||||
m_data->topItem->hide();
|
||||
m_data->leftItem->hide();
|
||||
m_data->rightItem->hide();
|
||||
m_data->bottomItem->hide();
|
||||
}
|
||||
|
||||
static QPainterPath rectToPath(const QRectF &rect)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(rect, 4, 4);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void AnchorLineController::updatePosition()
|
||||
{
|
||||
QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();
|
||||
|
||||
QRectF topBoundingRect(boundingRect);
|
||||
QRectF leftBoundingRect(boundingRect);
|
||||
QRectF bottomBoundingRect(boundingRect);
|
||||
QRectF rightBoundingRect(boundingRect);
|
||||
|
||||
|
||||
if (formEditorItem()->isContainer()) {
|
||||
topBoundingRect.setBottom(boundingRect.top() + 6);
|
||||
topBoundingRect.adjust(7, -5, -7, 0);
|
||||
|
||||
leftBoundingRect.setRight(boundingRect.left() + 6);
|
||||
leftBoundingRect.adjust(-5, 7, 0, -7);
|
||||
|
||||
bottomBoundingRect.setTop(boundingRect.bottom() - 6);
|
||||
bottomBoundingRect.adjust(7, 0, -7, 5);
|
||||
|
||||
rightBoundingRect.setLeft(boundingRect.right() - 6);
|
||||
rightBoundingRect.adjust(0, 7, 5, -7);
|
||||
|
||||
} else {
|
||||
double height = qMin(boundingRect.height() / 4., 10.);
|
||||
double width = qMin(boundingRect.width() / 4., 10.);
|
||||
|
||||
topBoundingRect.setHeight(height);
|
||||
topBoundingRect.adjust(width, -4, -width, -1);
|
||||
|
||||
leftBoundingRect.setWidth(width);
|
||||
leftBoundingRect.adjust(-4, height, -1, -height);
|
||||
|
||||
bottomBoundingRect.setTop(boundingRect.bottom() - height);
|
||||
bottomBoundingRect.adjust(width, 1, -width, 4);
|
||||
|
||||
rightBoundingRect.setLeft(boundingRect.right() - width);
|
||||
rightBoundingRect.adjust(1, height, 4, -height);
|
||||
}
|
||||
|
||||
m_data->topItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
|
||||
rectToPath(topBoundingRect)));
|
||||
m_data->leftItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
|
||||
rectToPath(leftBoundingRect)));
|
||||
m_data->bottomItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
|
||||
rectToPath(bottomBoundingRect)));
|
||||
m_data->rightItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
|
||||
rectToPath(rightBoundingRect)));
|
||||
}
|
||||
|
||||
|
||||
FormEditorItem* AnchorLineController::formEditorItem() const
|
||||
{
|
||||
return m_data->formEditorItem;
|
||||
}
|
||||
|
||||
QWeakPointer<AnchorLineControllerData> AnchorLineController::weakPointer() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
|
||||
bool AnchorLineController::isTopHandle(const AnchorLineHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->topItem;
|
||||
}
|
||||
|
||||
bool AnchorLineController::isLeftHandle(const AnchorLineHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->leftItem;
|
||||
}
|
||||
|
||||
bool AnchorLineController::isRightHandle(const AnchorLineHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->rightItem;
|
||||
}
|
||||
|
||||
bool AnchorLineController::isBottomHandle(const AnchorLineHandleItem *handle) const
|
||||
{
|
||||
return handle == m_data->bottomItem;
|
||||
}
|
||||
|
||||
void AnchorLineController::clearHighlight()
|
||||
{
|
||||
m_data->topItem->setHiglighted(false);
|
||||
m_data->leftItem->setHiglighted(false);
|
||||
m_data->rightItem->setHiglighted(false);
|
||||
m_data->bottomItem->setHiglighted(false);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,93 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORLINECONTROLLER_H
|
||||
#define ANCHORLINECONTROLLER_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <qmlanchors.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorItem;
|
||||
class LayerItem;
|
||||
class AnchorLineHandleItem;
|
||||
|
||||
class AnchorLineControllerData
|
||||
{
|
||||
public:
|
||||
AnchorLineControllerData(LayerItem *layerItem,
|
||||
FormEditorItem *formEditorItem);
|
||||
AnchorLineControllerData(const AnchorLineControllerData &other);
|
||||
~AnchorLineControllerData();
|
||||
|
||||
QWeakPointer<LayerItem> layerItem;
|
||||
FormEditorItem *formEditorItem;
|
||||
|
||||
AnchorLineHandleItem *topItem;
|
||||
AnchorLineHandleItem *leftItem;
|
||||
AnchorLineHandleItem *rightItem;
|
||||
AnchorLineHandleItem *bottomItem;
|
||||
};
|
||||
|
||||
|
||||
class AnchorLineController
|
||||
{
|
||||
public:
|
||||
AnchorLineController();
|
||||
AnchorLineController(LayerItem *layerItem, FormEditorItem *formEditorItem);
|
||||
AnchorLineController(const QSharedPointer<AnchorLineControllerData> &data);
|
||||
|
||||
void show(AnchorLine::Type anchorLineMask);
|
||||
void hide();
|
||||
|
||||
void updatePosition();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QWeakPointer<AnchorLineControllerData> weakPointer() const;
|
||||
|
||||
|
||||
FormEditorItem *formEditorItem() const;
|
||||
|
||||
bool isTopHandle(const AnchorLineHandleItem *handle) const;
|
||||
bool isLeftHandle(const AnchorLineHandleItem *handle) const;
|
||||
bool isRightHandle(const AnchorLineHandleItem *handle) const;
|
||||
bool isBottomHandle(const AnchorLineHandleItem *handle) const;
|
||||
|
||||
void clearHighlight();
|
||||
|
||||
private:
|
||||
QSharedPointer<AnchorLineControllerData> m_data;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORLINECONTROLLER_H
|
||||
@@ -0,0 +1,148 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorlinehandleitem.h"
|
||||
|
||||
#include <formeditoritem.h>
|
||||
#include <QPen>
|
||||
#include <cmath>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorLineHandleItem::AnchorLineHandleItem(QGraphicsItem *parent, const AnchorLineController &anchorLineController)
|
||||
: QGraphicsPathItem(parent),
|
||||
m_anchorLineControllerData(anchorLineController.weakPointer())
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
setHiglighted(false);
|
||||
}
|
||||
|
||||
void AnchorLineHandleItem::setHandlePath(const QPainterPath & path)
|
||||
{
|
||||
setPath(path);
|
||||
update();
|
||||
}
|
||||
|
||||
QRectF AnchorLineHandleItem::boundingRect() const
|
||||
{
|
||||
return QGraphicsPathItem::boundingRect();
|
||||
}
|
||||
|
||||
QPainterPath AnchorLineHandleItem::shape() const
|
||||
{
|
||||
return QGraphicsPathItem::shape();
|
||||
}
|
||||
|
||||
AnchorLineController AnchorLineHandleItem::anchorLineController() const
|
||||
{
|
||||
Q_ASSERT(!m_anchorLineControllerData.isNull());
|
||||
return AnchorLineController(m_anchorLineControllerData.toStrongRef());
|
||||
}
|
||||
|
||||
AnchorLine::Type AnchorLineHandleItem::anchorLine() const
|
||||
{
|
||||
if (isTopHandle())
|
||||
return AnchorLine::Top;
|
||||
|
||||
if (isLeftHandle())
|
||||
return AnchorLine::Left;
|
||||
|
||||
if (isRightHandle())
|
||||
return AnchorLine::Right;
|
||||
|
||||
if (isBottomHandle())
|
||||
return AnchorLine::Bottom;
|
||||
|
||||
return AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
AnchorLineHandleItem* AnchorLineHandleItem::fromGraphicsItem(QGraphicsItem *item)
|
||||
{
|
||||
return qgraphicsitem_cast<AnchorLineHandleItem*>(item);
|
||||
}
|
||||
|
||||
bool AnchorLineHandleItem::isTopHandle() const
|
||||
{
|
||||
return anchorLineController().isTopHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorLineHandleItem::isLeftHandle() const
|
||||
{
|
||||
return anchorLineController().isLeftHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorLineHandleItem::isRightHandle() const
|
||||
{
|
||||
return anchorLineController().isRightHandle(this);
|
||||
}
|
||||
|
||||
bool AnchorLineHandleItem::isBottomHandle() const
|
||||
{
|
||||
return anchorLineController().isBottomHandle(this);
|
||||
}
|
||||
|
||||
AnchorLine::Type AnchorLineHandleItem::anchorLineType() const
|
||||
{
|
||||
if (isTopHandle())
|
||||
return AnchorLine::Top;
|
||||
|
||||
if (isBottomHandle())
|
||||
return AnchorLine::Bottom;
|
||||
|
||||
if (isLeftHandle())
|
||||
return AnchorLine::Left;
|
||||
|
||||
if (isRightHandle())
|
||||
return AnchorLine::Right;
|
||||
|
||||
|
||||
return AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
QPointF AnchorLineHandleItem::itemSpacePosition() const
|
||||
{
|
||||
return parentItem()->mapToItem(anchorLineController().formEditorItem(), pos());
|
||||
}
|
||||
|
||||
void AnchorLineHandleItem::setHiglighted(bool highlight)
|
||||
{
|
||||
if (highlight) {
|
||||
QPen pen;
|
||||
pen.setColor(QColor(108, 141, 221));
|
||||
setPen(pen);
|
||||
setBrush(QColor(108, 141, 221, 140));
|
||||
} else {
|
||||
QPen pen;
|
||||
pen.setColor(QColor(108, 141, 221));
|
||||
setPen(pen);
|
||||
setBrush(QColor(108, 141, 221, 60));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,86 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORLINEHANDLEITEM_H
|
||||
#define ANCHORLINEHANDLEITEM_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
|
||||
#include "anchorlinecontroller.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnchorLineHandleItem : public QGraphicsPathItem
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
Type = 0xEAEB
|
||||
};
|
||||
|
||||
|
||||
AnchorLineHandleItem(QGraphicsItem *parent, const AnchorLineController &AnchorLineController);
|
||||
|
||||
void setHandlePath(const QPainterPath & path);
|
||||
|
||||
int type() const;
|
||||
QRectF boundingRect() const;
|
||||
QPainterPath shape() const;
|
||||
|
||||
AnchorLineController anchorLineController() const;
|
||||
AnchorLine::Type anchorLine() const;
|
||||
|
||||
|
||||
static AnchorLineHandleItem* fromGraphicsItem(QGraphicsItem *item);
|
||||
|
||||
|
||||
bool isTopHandle() const;
|
||||
bool isLeftHandle() const;
|
||||
bool isRightHandle() const;
|
||||
bool isBottomHandle() const;
|
||||
|
||||
QPointF itemSpacePosition() const;
|
||||
|
||||
AnchorLine::Type anchorLineType() const;
|
||||
|
||||
void setHiglighted(bool highlight);
|
||||
|
||||
|
||||
private:
|
||||
QWeakPointer<AnchorLineControllerData> m_anchorLineControllerData;
|
||||
};
|
||||
|
||||
inline int AnchorLineHandleItem::type() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORLINEHANDLEITEM_H
|
||||
@@ -0,0 +1,131 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchorlineindicator.h"
|
||||
|
||||
#include <QSet>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorLineIndicator::AnchorLineIndicator(LayerItem *layerItem)
|
||||
: m_layerItem(layerItem)
|
||||
{
|
||||
Q_ASSERT(layerItem);
|
||||
}
|
||||
|
||||
AnchorLineIndicator::~AnchorLineIndicator()
|
||||
{
|
||||
m_itemControllerHash.clear();
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::show(AnchorLine::Type anchorLineMask)
|
||||
{
|
||||
QHashIterator<FormEditorItem*, AnchorLineController> itemControllerIterator(m_itemControllerHash);
|
||||
while (itemControllerIterator.hasNext()) {
|
||||
AnchorLineController controller = itemControllerIterator.next().value();
|
||||
controller.show(anchorLineMask);
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::hide()
|
||||
{
|
||||
QHashIterator<FormEditorItem*, AnchorLineController> itemControllerIterator(m_itemControllerHash);
|
||||
while (itemControllerIterator.hasNext()) {
|
||||
AnchorLineController controller = itemControllerIterator.next().value();
|
||||
controller.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::clear()
|
||||
{
|
||||
m_itemControllerHash.clear();
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::setItem(FormEditorItem* item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
QList<FormEditorItem*> itemList;
|
||||
itemList.append(item);
|
||||
|
||||
setItems(itemList);
|
||||
}
|
||||
|
||||
static bool equalLists(const QList<FormEditorItem*> &firstList, const QList<FormEditorItem*> &secondList)
|
||||
{
|
||||
return firstList.toSet() == secondList.toSet();
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::setItems(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
if (equalLists(itemList, m_itemControllerHash.keys()))
|
||||
return;
|
||||
|
||||
clear();
|
||||
|
||||
foreach (FormEditorItem *item, itemList) {
|
||||
AnchorLineController controller(m_layerItem, item);
|
||||
m_itemControllerHash.insert(item, controller);
|
||||
}
|
||||
|
||||
show(AnchorLine::AllMask);
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::updateItems(const QList<FormEditorItem*> &itemList)
|
||||
{
|
||||
foreach (FormEditorItem *item, itemList) {
|
||||
if (m_itemControllerHash.contains(item)) {
|
||||
AnchorLineController controller(m_itemControllerHash.value(item));
|
||||
controller.updatePosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::update()
|
||||
{
|
||||
foreach (FormEditorItem *item, m_itemControllerHash.keys()) {
|
||||
if (m_itemControllerHash.contains(item)) {
|
||||
AnchorLineController controller(m_itemControllerHash.value(item));
|
||||
controller.updatePosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorLineIndicator::clearHighlight()
|
||||
{
|
||||
foreach (FormEditorItem *item, m_itemControllerHash.keys()) {
|
||||
if (m_itemControllerHash.contains(item)) {
|
||||
AnchorLineController controller(m_itemControllerHash.value(item));
|
||||
controller.clearHighlight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,69 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORLINEINDICATOR_H
|
||||
#define ANCHORLINEINDICATOR_H
|
||||
|
||||
#include "layeritem.h"
|
||||
#include "anchorlinecontroller.h"
|
||||
#include <QHash>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorItem;
|
||||
|
||||
class AnchorLineIndicator
|
||||
{
|
||||
public:
|
||||
AnchorLineIndicator(LayerItem *layerItem);
|
||||
~AnchorLineIndicator();
|
||||
|
||||
void show(AnchorLine::Type anchorLineMask);
|
||||
|
||||
void hide();
|
||||
|
||||
void clear();
|
||||
|
||||
void update();
|
||||
|
||||
void setItems(const QList<FormEditorItem*> &itemList);
|
||||
void setItem(FormEditorItem* item);
|
||||
void updateItems(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void clearHighlight();
|
||||
|
||||
private:
|
||||
QHash<FormEditorItem*, AnchorLineController> m_itemControllerHash;
|
||||
|
||||
LayerItem *m_layerItem;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORLINEINDICATOR_H
|
||||
@@ -0,0 +1,144 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchormanipulator.h"
|
||||
|
||||
#include "formeditoritem.h"
|
||||
#include "formeditorscene.h"
|
||||
#include "formeditorview.h"
|
||||
#include <model.h>
|
||||
#include <rewritertransaction.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorManipulator::AnchorManipulator(FormEditorView *view)
|
||||
: m_beginFormEditorItem(0),
|
||||
m_beginAnchorLine(AnchorLine::Invalid),
|
||||
m_view(view)
|
||||
{
|
||||
}
|
||||
|
||||
AnchorManipulator::~AnchorManipulator()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void AnchorManipulator::begin(FormEditorItem *beginItem, AnchorLine::Type anchorLine)
|
||||
{
|
||||
m_beginFormEditorItem = beginItem;
|
||||
m_beginAnchorLine = anchorLine;
|
||||
}
|
||||
|
||||
static double offset(const QPointF &topLeft, const QPointF &bottomRight, AnchorLine::Type anchorLine)
|
||||
{
|
||||
switch(anchorLine) {
|
||||
case AnchorLine::Top : return topLeft.y();
|
||||
case AnchorLine::Left : return topLeft.x();
|
||||
case AnchorLine::Bottom : return bottomRight.y();
|
||||
case AnchorLine::Right : return bottomRight.x();
|
||||
default: break;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void AnchorManipulator::setMargin(FormEditorItem *endItem, AnchorLine::Type endAnchorLine)
|
||||
{
|
||||
QPointF beginItemTopLeft(m_beginFormEditorItem->mapToParent(m_beginFormEditorItem->qmlItemNode().instanceBoundingRect().topLeft()));
|
||||
QPointF endItemTopLeft(m_beginFormEditorItem->parentItem()->mapFromItem(endItem, endItem->qmlItemNode().instanceBoundingRect().topLeft()));
|
||||
|
||||
QPointF beginItemBottomRight(m_beginFormEditorItem->mapToParent(m_beginFormEditorItem->qmlItemNode().instanceBoundingRect().bottomRight()));
|
||||
QPointF endItemBottomRight(m_beginFormEditorItem->parentItem()->mapFromItem(endItem, endItem->qmlItemNode().instanceBoundingRect().bottomRight()));
|
||||
|
||||
QPointF topLeftAnchorOffset = beginItemTopLeft - endItemTopLeft;
|
||||
QPointF bottomRightAnchorOffset = endItemBottomRight - beginItemBottomRight;
|
||||
|
||||
|
||||
double anchorOffset = 0.0;
|
||||
if (m_beginAnchorLine & (AnchorLine::Bottom | AnchorLine::Right)) {
|
||||
anchorOffset = offset(endItemTopLeft, endItemBottomRight, endAnchorLine) -
|
||||
offset(beginItemTopLeft, beginItemBottomRight, m_beginAnchorLine);
|
||||
} else {
|
||||
anchorOffset = offset(beginItemTopLeft, beginItemBottomRight, m_beginAnchorLine) -
|
||||
offset(endItemTopLeft, endItemBottomRight, endAnchorLine);
|
||||
}
|
||||
|
||||
m_beginFormEditorItem->qmlItemNode().anchors().setMargin(m_beginAnchorLine, anchorOffset);
|
||||
}
|
||||
void AnchorManipulator::addAnchor(FormEditorItem *endItem, AnchorLine::Type endAnchorLine)
|
||||
{
|
||||
RewriterTransaction m_rewriterTransaction = m_view->beginRewriterTransaction();
|
||||
setMargin(endItem, endAnchorLine);
|
||||
|
||||
m_beginFormEditorItem->qmlItemNode().anchors().setAnchor(m_beginAnchorLine,
|
||||
endItem->qmlItemNode(),
|
||||
endAnchorLine);
|
||||
}
|
||||
|
||||
void AnchorManipulator::removeAnchor()
|
||||
{
|
||||
RewriterTransaction transaction = m_view->beginRewriterTransaction();
|
||||
QmlAnchors anchors(m_beginFormEditorItem->qmlItemNode().anchors());
|
||||
if (anchors.instanceHasAnchor(m_beginAnchorLine)) {
|
||||
anchors.removeAnchor(m_beginAnchorLine);
|
||||
anchors.removeMargin(m_beginAnchorLine);
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorManipulator::clear()
|
||||
{
|
||||
m_beginFormEditorItem = 0;
|
||||
m_beginAnchorLine = AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
bool AnchorManipulator::isActive() const
|
||||
{
|
||||
return m_beginFormEditorItem && m_beginAnchorLine != AnchorLine::Invalid;
|
||||
}
|
||||
|
||||
AnchorLine::Type AnchorManipulator::beginAnchorLine() const
|
||||
{
|
||||
return m_beginAnchorLine;
|
||||
}
|
||||
|
||||
bool AnchorManipulator::beginAnchorLineIsHorizontal() const
|
||||
{
|
||||
return beginAnchorLine() & AnchorLine::HorizontalMask;
|
||||
}
|
||||
bool AnchorManipulator::beginAnchorLineIsVertical() const
|
||||
{
|
||||
return beginAnchorLine() & AnchorLine::HorizontalMask;
|
||||
}
|
||||
|
||||
FormEditorItem *AnchorManipulator::beginFormEditorItem() const
|
||||
{
|
||||
return m_beginFormEditorItem;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,71 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORMANIPULATOR_H
|
||||
#define ANCHORMANIPULATOR_H
|
||||
|
||||
#include <qmlanchors.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorItem;
|
||||
class FormEditorView;
|
||||
|
||||
class AnchorManipulator
|
||||
{
|
||||
public:
|
||||
AnchorManipulator(FormEditorView *view);
|
||||
~AnchorManipulator();
|
||||
void begin(FormEditorItem *beginItem, AnchorLine::Type anchorLine);
|
||||
void addAnchor(FormEditorItem *endItem, AnchorLine::Type anchorLine);
|
||||
void removeAnchor();
|
||||
|
||||
void clear();
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
bool beginAnchorLineIsHorizontal() const;
|
||||
bool beginAnchorLineIsVertical() const;
|
||||
|
||||
AnchorLine::Type beginAnchorLine() const;
|
||||
|
||||
FormEditorItem *beginFormEditorItem() const;
|
||||
|
||||
private: // fucntions
|
||||
void setMargin(FormEditorItem *endItem, AnchorLine::Type endAnchorLine);
|
||||
|
||||
private: // variables
|
||||
FormEditorItem *m_beginFormEditorItem;
|
||||
AnchorLine::Type m_beginAnchorLine;
|
||||
QWeakPointer<FormEditorView> m_view;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
#endif // ANCHORMANIPULATOR_H
|
||||
226
src/plugins/qmldesigner/components/formeditor/anchortool.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "anchortool.h"
|
||||
|
||||
#include "formeditorscene.h"
|
||||
#include "formeditorview.h"
|
||||
#include <qmlitemnode.h>
|
||||
#include <qmlanchors.h>
|
||||
#include "anchorlinehandleitem.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
AnchorTool::AnchorTool(FormEditorView* editorView)
|
||||
: AbstractFormEditorTool(editorView),
|
||||
m_anchorLineIndicator(editorView->scene()->manipulatorLayerItem()),
|
||||
m_anchorIndicator(editorView->scene()->manipulatorLayerItem()),
|
||||
m_anchorManipulator(editorView),
|
||||
m_lastAnchorLineHandleItem(0)
|
||||
{
|
||||
m_hoverTimeLine.setDuration(200);
|
||||
connect(&m_hoverTimeLine, SIGNAL(finished()), SLOT(checkIfStillHovering()));
|
||||
}
|
||||
|
||||
AnchorTool::~AnchorTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AnchorTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *)
|
||||
{
|
||||
AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList);
|
||||
if (anchorLineHandleItem) {
|
||||
m_anchorManipulator.begin(anchorLineHandleItem->anchorLineController().formEditorItem(),
|
||||
anchorLineHandleItem->anchorLineType());
|
||||
}
|
||||
|
||||
m_anchorLineIndicator.clear();
|
||||
|
||||
}
|
||||
|
||||
bool areAchorable(FormEditorItem *firstItem, FormEditorItem *secondItem)
|
||||
{
|
||||
return firstItem->qmlItemNode().anchors().canAnchor(secondItem->qmlItemNode());
|
||||
}
|
||||
|
||||
void AnchorTool::mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (m_anchorManipulator.isActive()) {
|
||||
FormEditorItem *targetItem = 0;
|
||||
AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList);
|
||||
if (anchorLineHandleItem && areAchorable(m_anchorManipulator.beginFormEditorItem(), anchorLineHandleItem->anchorLineController().formEditorItem())) {
|
||||
targetItem = anchorLineHandleItem->anchorLineController().formEditorItem();
|
||||
} else {
|
||||
FormEditorItem *topFormEditItem = topFormEditorItemWithRootItem(itemList);
|
||||
if (topFormEditItem && areAchorable(m_anchorManipulator.beginFormEditorItem(), topFormEditItem)) {
|
||||
targetItem = topFormEditItem;
|
||||
} else {
|
||||
m_anchorLineIndicator.hide();
|
||||
m_anchorIndicator.updateTargetPoint(m_anchorManipulator.beginFormEditorItem(), m_anchorManipulator.beginAnchorLine(), event->scenePos());
|
||||
}
|
||||
}
|
||||
|
||||
if (targetItem) {
|
||||
targetItem->qmlItemNode().selectNode();
|
||||
m_anchorLineIndicator.setItem(targetItem);
|
||||
m_anchorLineIndicator.show(m_anchorManipulator.beginFormEditorItem()->qmlItemNode().anchors().possibleAnchorLines(m_anchorManipulator.beginAnchorLine(), targetItem->qmlItemNode()));
|
||||
m_anchorIndicator.updateTargetPoint(m_anchorManipulator.beginFormEditorItem(), m_anchorManipulator.beginAnchorLine(), event->scenePos());
|
||||
targetItem->qmlItemNode().selectNode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AnchorTool::mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *)
|
||||
{
|
||||
if (m_anchorManipulator.isActive()) {
|
||||
AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList);
|
||||
if (anchorLineHandleItem) {
|
||||
m_anchorManipulator.addAnchor(anchorLineHandleItem->anchorLineController().formEditorItem(),
|
||||
anchorLineHandleItem->anchorLineType());
|
||||
} else {
|
||||
m_anchorManipulator.removeAnchor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
FormEditorItem *topFormEditItem = topFormEditorItem(itemList);
|
||||
if (topFormEditItem)
|
||||
topFormEditItem->qmlItemNode().selectNode();
|
||||
|
||||
m_anchorManipulator.clear();
|
||||
m_anchorLineIndicator.clear();
|
||||
}
|
||||
|
||||
void AnchorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
||||
QGraphicsSceneMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void AnchorTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
m_anchorLineIndicator.clearHighlight();
|
||||
m_anchorIndicator.clearHighlight();
|
||||
m_lastMousePosition = event->scenePos();
|
||||
FormEditorItem *topFormEditItem = 0;
|
||||
AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(itemList);
|
||||
|
||||
if (anchorLineHandleItem) {
|
||||
anchorLineHandleItem->setHiglighted(true);
|
||||
m_anchorIndicator.highlight(anchorLineHandleItem->anchorLineController().formEditorItem(),
|
||||
anchorLineHandleItem->anchorLineType());
|
||||
topFormEditItem = anchorLineHandleItem->anchorLineController().formEditorItem();
|
||||
if (m_hoverTimeLine.state() == QTimeLine::NotRunning) {
|
||||
m_lastAnchorLineHandleItem = anchorLineHandleItem;
|
||||
m_hoverTimeLine.start();
|
||||
}
|
||||
} else {
|
||||
topFormEditItem = topFormEditorItem(itemList);
|
||||
}
|
||||
|
||||
if (topFormEditItem) {
|
||||
m_anchorLineIndicator.setItem(topFormEditItem);
|
||||
m_anchorLineIndicator.show(AnchorLine::AllMask);
|
||||
topFormEditItem->qmlItemNode().selectNode();
|
||||
} else {
|
||||
|
||||
m_anchorLineIndicator.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorTool::checkIfStillHovering()
|
||||
{
|
||||
AnchorLineHandleItem *anchorLineHandleItem = topAnchorLineHandleItem(scene()->items(m_lastMousePosition));
|
||||
|
||||
if (anchorLineHandleItem && anchorLineHandleItem == m_lastAnchorLineHandleItem) {
|
||||
FormEditorItem *sourceFormEditItem = anchorLineHandleItem->anchorLineController().formEditorItem();
|
||||
QmlAnchors anchors(sourceFormEditItem->qmlItemNode().anchors());
|
||||
if (anchors.instanceHasAnchor(anchorLineHandleItem->anchorLine())) {
|
||||
QmlItemNode targetNode(anchors.instanceAnchor(anchorLineHandleItem->anchorLine()).qmlItemNode());
|
||||
FormEditorItem *targetFormEditorItem = scene()->itemForQmlItemNode(targetNode);
|
||||
targetFormEditorItem->showAttention();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnchorTool::keyPressEvent(QKeyEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
void AnchorTool::keyReleaseEvent(QKeyEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
void AnchorTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItems)
|
||||
{
|
||||
QList<FormEditorItem*> newItemList = items().toSet().subtract(removedItems.toSet()).toList();
|
||||
setItems(newItemList);
|
||||
m_anchorIndicator.setItems(newItemList);
|
||||
m_anchorLineIndicator.clear();
|
||||
}
|
||||
|
||||
void AnchorTool::selectedItemsChanged(const QList<FormEditorItem*> &/*itemList*/)
|
||||
{
|
||||
m_anchorIndicator.setItems(view()->scene()->allFormEditorItems());
|
||||
m_anchorIndicator.show();
|
||||
}
|
||||
|
||||
void AnchorTool::clear()
|
||||
{
|
||||
m_anchorLineIndicator.clear();
|
||||
m_anchorIndicator.clear();
|
||||
}
|
||||
|
||||
void AnchorTool::formEditorItemsChanged(const QList<FormEditorItem*> &)
|
||||
{
|
||||
m_anchorLineIndicator.updateItems(view()->scene()->allFormEditorItems());
|
||||
m_anchorIndicator.updateItems(view()->scene()->allFormEditorItems());
|
||||
}
|
||||
|
||||
AnchorLineHandleItem* AnchorTool::topAnchorLineHandleItem(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
AnchorLineHandleItem *anchorLineItem = AnchorLineHandleItem::fromGraphicsItem(item);
|
||||
if (anchorLineItem)
|
||||
return anchorLineItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
88
src/plugins/qmldesigner/components/formeditor/anchortool.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ANCHORTOOL_H
|
||||
#define ANCHORTOOL_H
|
||||
|
||||
#include <QTimeLine>
|
||||
|
||||
#include "abstractformeditortool.h"
|
||||
|
||||
#include "anchorlineindicator.h"
|
||||
#include "anchorindicator.h"
|
||||
#include "anchormanipulator.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class AnchorLineHandleItem;
|
||||
|
||||
class AnchorTool : public QObject, public AbstractFormEditorTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AnchorTool(FormEditorView* editorView);
|
||||
~AnchorTool();
|
||||
|
||||
void mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
|
||||
void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void clear();
|
||||
|
||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
static AnchorLineHandleItem* topAnchorLineHandleItem(const QList<QGraphicsItem*> & itemList);
|
||||
|
||||
private slots:
|
||||
void checkIfStillHovering();
|
||||
|
||||
private: //variables
|
||||
AnchorLineIndicator m_anchorLineIndicator;
|
||||
AnchorIndicator m_anchorIndicator;
|
||||
AnchorManipulator m_anchorManipulator;
|
||||
QTimeLine m_hoverTimeLine;
|
||||
QPointF m_lastMousePosition;
|
||||
AnchorLineHandleItem *m_lastAnchorLineHandleItem;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // ANCHORTOOL_H
|
||||
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "controlelement.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QBrush>
|
||||
#include "layeritem.h"
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ControlElement::ControlElement(LayerItem *layerItem)
|
||||
: m_controlShape(new QGraphicsRectItem(layerItem))
|
||||
{
|
||||
QPen pen;
|
||||
pen.setStyle(Qt::DashLine);
|
||||
pen.setColor(Qt::blue);
|
||||
m_controlShape->setPen(pen);
|
||||
}
|
||||
|
||||
ControlElement::~ControlElement()
|
||||
{
|
||||
delete m_controlShape;
|
||||
}
|
||||
|
||||
void ControlElement::hide()
|
||||
{
|
||||
m_controlShape->hide();
|
||||
}
|
||||
|
||||
void ControlElement::setBoundingRect(const QRectF &rect)
|
||||
{
|
||||
m_controlShape->show();
|
||||
m_controlShape->setRect(m_controlShape->mapFromScene(rect).boundingRect());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CONTROLELEMENT_H
|
||||
#define CONTROLELEMENT_H
|
||||
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class LayerItem;
|
||||
|
||||
class ControlElement
|
||||
{
|
||||
public:
|
||||
ControlElement(LayerItem *layerItem);
|
||||
~ControlElement();
|
||||
|
||||
void hide();
|
||||
|
||||
void setBoundingRect(const QRectF &rect);
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *m_controlShape;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CONTROLELEMENT_H
|
||||
315
src/plugins/qmldesigner/components/formeditor/dragtool.cpp
Normal file
@@ -0,0 +1,315 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "dragtool.h"
|
||||
|
||||
#include "formeditorscene.h"
|
||||
#include "formeditorview.h"
|
||||
#include "modelutilities.h"
|
||||
#include "itemutilfunctions.h"
|
||||
#include <customdraganddrop.h>
|
||||
#include <metainfo.h>
|
||||
|
||||
#include "resizehandleitem.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QtDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
DragTool::DragTool(FormEditorView *editorView)
|
||||
: AbstractFormEditorTool(editorView),
|
||||
m_moveManipulator(editorView->scene()->manipulatorLayerItem(), editorView),
|
||||
m_selectionIndicator(editorView->scene()->manipulatorLayerItem())
|
||||
{
|
||||
// view()->setCursor(Qt::SizeAllCursor);
|
||||
}
|
||||
|
||||
|
||||
DragTool::~DragTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::clear()
|
||||
{
|
||||
m_moveManipulator.clear();
|
||||
m_selectionIndicator.clear();
|
||||
m_movingItem.clear();
|
||||
}
|
||||
|
||||
void DragTool::mousePressEvent(const QList<QGraphicsItem*> &,
|
||||
QGraphicsSceneMouseEvent *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::mouseMoveEvent(const QList<QGraphicsItem*> &,
|
||||
QGraphicsSceneMouseEvent *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::hoverMoveEvent(const QList<QGraphicsItem*> &,
|
||||
QGraphicsSceneMouseEvent * /*event*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::keyPressEvent(QKeyEvent *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::keyReleaseEvent(QKeyEvent *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DragTool::mouseReleaseEvent(const QList<QGraphicsItem*> &/*itemList*/,
|
||||
QGraphicsSceneMouseEvent *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> & /*itemList*/,
|
||||
QGraphicsSceneMouseEvent * /*event*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::itemsAboutToRemoved(const QList<FormEditorItem*> & /* removedItemList */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DragTool::selectedItemsChanged(const QList<FormEditorItem*> &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DragTool::updateMoveManipulator()
|
||||
{
|
||||
if (m_moveManipulator.isActive())
|
||||
return;
|
||||
}
|
||||
|
||||
void DragTool::beginWithPoint(const QPointF &beginPoint)
|
||||
{
|
||||
m_movingItem = scene()->itemForQmlItemNode(m_dragNode);
|
||||
|
||||
m_moveManipulator.setItem(m_movingItem.data());
|
||||
m_moveManipulator.begin(beginPoint);
|
||||
|
||||
}
|
||||
|
||||
void DragTool::createQmlItemNode(const ItemLibraryInfo &itemLibraryRepresentation, QmlItemNode parentNode, QPointF scenePos)
|
||||
{
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
|
||||
|
||||
MetaInfo metaInfo = MetaInfo::global();
|
||||
|
||||
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
|
||||
QPointF pos = parentItem->mapFromScene(scenePos);
|
||||
|
||||
m_dragNode = view()->createQmlItemNode(itemLibraryRepresentation, pos, parentNode);
|
||||
|
||||
Q_ASSERT(m_dragNode.modelNode().isValid());
|
||||
Q_ASSERT(m_dragNode.isValid());
|
||||
|
||||
QList<QmlItemNode> nodeList;
|
||||
nodeList.append(m_dragNode);
|
||||
view()->setSelectedQmlItemNodes(nodeList);
|
||||
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
||||
}
|
||||
|
||||
void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos)
|
||||
{
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::hide();
|
||||
|
||||
MetaInfo metaInfo = MetaInfo::global();
|
||||
|
||||
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
|
||||
QPointF pos = parentItem->mapFromScene(scenePos);
|
||||
|
||||
m_dragNode = view()->createQmlItemNodeFromImage(imageName, pos, parentNode);
|
||||
|
||||
QList<QmlItemNode> nodeList;
|
||||
nodeList.append(m_dragNode);
|
||||
view()->setSelectedQmlItemNodes(nodeList);
|
||||
m_selectionIndicator.setItems(scene()->itemsForQmlItemNodes(nodeList));
|
||||
}
|
||||
|
||||
FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorItem * currentItem)
|
||||
{
|
||||
QList<QGraphicsItem *> list = scene()->items(point);
|
||||
foreach (QGraphicsItem *item, list) {
|
||||
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (formEditorItem && formEditorItem != currentItem && formEditorItem->isContainer())
|
||||
return formEditorItem;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void DragTool::formEditorItemsChanged(const QList<FormEditorItem*> & itemList)
|
||||
{
|
||||
if (m_movingItem && itemList.contains(m_movingItem.data())) {
|
||||
QList<FormEditorItem*> updateItemList;
|
||||
updateItemList.append(m_movingItem.data());
|
||||
m_selectionIndicator.updateItems(updateItemList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DragTool::dropEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
event->accept();
|
||||
end(event->scenePos());
|
||||
//Q_ASSERT(m_token.isValid());
|
||||
m_rewriterTransaction.commit();
|
||||
m_dragNode = ModelNode();
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
}
|
||||
|
||||
void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
if (!m_rewriterTransaction.isValid()) {
|
||||
m_rewriterTransaction = view()->beginRewriterTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DragTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
event->accept();
|
||||
if (m_dragNode.isValid())
|
||||
m_dragNode.destroy();
|
||||
end(event->scenePos());
|
||||
m_rewriterTransaction.commit();
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::show();
|
||||
QList<QmlItemNode> nodeList;
|
||||
view()->setSelectedQmlItemNodes(nodeList);
|
||||
view()->changeToSelectionTool();
|
||||
}
|
||||
}
|
||||
|
||||
static ItemLibraryInfo ItemLibraryInfoFromData(const QByteArray &data)
|
||||
{
|
||||
QDataStream stream(data);
|
||||
|
||||
ItemLibraryInfo itemLibraryInfo;
|
||||
stream >> itemLibraryInfo;
|
||||
|
||||
return itemLibraryInfo;
|
||||
}
|
||||
|
||||
void DragTool::dragMoveEvent(QGraphicsSceneDragDropEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo") ||
|
||||
event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
event->accept();
|
||||
QPointF scenePos = event->scenePos();
|
||||
if (m_dragNode.isValid()) {
|
||||
|
||||
FormEditorItem *parentItem = calculateContainer(event->scenePos() - QPoint(2, 2));
|
||||
if (!parentItem) { //if there is no parent any more - the use left the scene
|
||||
end(event->scenePos());
|
||||
m_dragNode.destroy(); //delete the node then
|
||||
QmlDesignerItemLibraryDragAndDrop::CustomDragAndDrop::show();
|
||||
return;
|
||||
}
|
||||
//move
|
||||
move(event->scenePos());
|
||||
} else {
|
||||
//create new node if container
|
||||
|
||||
FormEditorItem *parentItem = calculateContainer(event->scenePos());
|
||||
if (!parentItem)
|
||||
return;
|
||||
QmlItemNode parentNode; //get possible container parentNode
|
||||
if (parentItem)
|
||||
parentNode = parentItem->qmlItemNode();
|
||||
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.itemlibraryinfo")) {
|
||||
Q_ASSERT(!event->mimeData()->data("application/vnd.bauhaus.itemlibraryinfo").isEmpty());
|
||||
ItemLibraryInfo ItemLibraryInfo = ItemLibraryInfoFromData(event->mimeData()->data("application/vnd.bauhaus.itemlibraryinfo"));
|
||||
createQmlItemNode(ItemLibraryInfo, parentNode, event->scenePos());
|
||||
} else if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
Q_ASSERT(!event->mimeData()->data("application/vnd.bauhaus.libraryresource").isEmpty());
|
||||
QString imageName = QString::fromLatin1((event->mimeData()->data("application/vnd.bauhaus.libraryresource")));
|
||||
createQmlItemNodeFromImage(imageName, parentNode, event->scenePos());
|
||||
} else Q_ASSERT(false);
|
||||
beginWithPoint(event->scenePos());
|
||||
}
|
||||
}
|
||||
if (event->mimeData()->hasFormat("application/vnd.bauhaus.libraryresource")) {
|
||||
}
|
||||
}
|
||||
|
||||
void DragTool::end(QPointF scenePos)
|
||||
{
|
||||
m_moveManipulator.end(scenePos);
|
||||
clear();
|
||||
}
|
||||
|
||||
void DragTool::move(QPointF scenePos)
|
||||
{
|
||||
if (!m_movingItem)
|
||||
return;
|
||||
|
||||
FormEditorItem *containerItem = calculateContainer(scenePos - QPoint(2, 2), m_movingItem.data());
|
||||
if (containerItem &&
|
||||
containerItem != m_movingItem->parentItem() &&
|
||||
view()->currentState().isBaseState()) {
|
||||
|
||||
m_moveManipulator.reparentTo(containerItem);
|
||||
}
|
||||
|
||||
//MoveManipulator::Snapping useSnapping = MoveManipulator::NoSnapping;
|
||||
MoveManipulator::Snapping useSnapping = MoveManipulator::UseSnapping;
|
||||
/* if (event->modifiers().testFlag(Qt::ControlModifier) != view()->isSnapButtonChecked())
|
||||
useSnapping = MoveManipulator::UseSnapping;*/
|
||||
|
||||
m_moveManipulator.update(scenePos, useSnapping);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
105
src/plugins/qmldesigner/components/formeditor/dragtool.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef DRAGTOOL_H
|
||||
#define DRAGTOOL_H
|
||||
|
||||
#include "abstractformeditortool.h"
|
||||
#include "movemanipulator.h"
|
||||
#include "selectionindicator.h"
|
||||
#include "resizeindicator.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
|
||||
class DragTool : public AbstractFormEditorTool
|
||||
{
|
||||
public:
|
||||
DragTool(FormEditorView* editorView);
|
||||
~DragTool();
|
||||
|
||||
void mousePressEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
|
||||
void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
void updateMoveManipulator();
|
||||
|
||||
void beginWithPoint(const QPointF &beginPoint);
|
||||
|
||||
|
||||
virtual void dropEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
|
||||
|
||||
//void beginWithPoint(const QPointF &beginPoint);
|
||||
|
||||
void clear();
|
||||
|
||||
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void createQmlItemNode(const ItemLibraryInfo &ItemLibraryRepresentation, QmlItemNode parentNode, QPointF scenePos);
|
||||
void createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos);
|
||||
FormEditorItem* calculateContainer(const QPointF &point, FormEditorItem * currentItem = 0);
|
||||
|
||||
void begin(QPointF scenePos);
|
||||
void end(QPointF scenePos);
|
||||
void move(QPointF scenePos);
|
||||
|
||||
MoveManipulator m_moveManipulator;
|
||||
SelectionIndicator m_selectionIndicator;
|
||||
QWeakPointer<FormEditorItem> m_movingItem;
|
||||
RewriterTransaction m_rewriterTransaction;
|
||||
QmlItemNode m_dragNode;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // DRAGTOOL_H
|
||||
84
src/plugins/qmldesigner/components/formeditor/formeditor.pri
Normal file
@@ -0,0 +1,84 @@
|
||||
VPATH += $$PWD
|
||||
QT += opengl
|
||||
INCLUDEPATH += $$PWD
|
||||
INCLUDEPATH += $$PWD/../navigator
|
||||
DEPENDPATH += $$PWD
|
||||
SOURCES += formeditoritem.cpp \
|
||||
formeditorview.cpp \
|
||||
formeditorscene.cpp \
|
||||
formeditorwidget.cpp \
|
||||
selectiontool.cpp \
|
||||
abstractformeditortool.cpp \
|
||||
controlelement.cpp \
|
||||
resizemanipulator.cpp \
|
||||
movemanipulator.cpp \
|
||||
layeritem.cpp \
|
||||
itemutilfunctions.cpp \
|
||||
selectionrectangle.cpp \
|
||||
rubberbandselectionmanipulator.cpp \
|
||||
movetool.cpp \
|
||||
selectionindicator.cpp \
|
||||
snappinglinecreator.cpp \
|
||||
snapper.cpp \
|
||||
onedimensionalcluster.cpp \
|
||||
singleselectionmanipulator.cpp \
|
||||
scalemanipulator.cpp \
|
||||
resizetool.cpp \
|
||||
resizeindicator.cpp \
|
||||
scaleitem.cpp \
|
||||
resizecontroller.cpp \
|
||||
resizehandleitem.cpp \
|
||||
anchortool.cpp \
|
||||
anchorlineindicator.cpp \
|
||||
anchorlinecontroller.cpp \
|
||||
anchorlinehandleitem.cpp \
|
||||
anchormanipulator.cpp \
|
||||
anchorindicator.cpp \
|
||||
anchorcontroller.cpp \
|
||||
anchorhandleitem.cpp \
|
||||
dragtool.cpp \
|
||||
itemcreatortool.cpp \
|
||||
toolbox.cpp \
|
||||
zoomaction.cpp \
|
||||
formeditorgraphicsview.cpp \
|
||||
numberseriesaction.cpp
|
||||
HEADERS += formeditorscene.h \
|
||||
formeditorwidget.h \
|
||||
formeditoritem.h \
|
||||
formeditorview.h \
|
||||
selectiontool.h \
|
||||
abstractformeditortool.h \
|
||||
controlelement.h \
|
||||
resizemanipulator.h \
|
||||
movemanipulator.h \
|
||||
layeritem.h \
|
||||
itemutilfunctions.h \
|
||||
selectionrectangle.h \
|
||||
rubberbandselectionmanipulator.h \
|
||||
movetool.h \
|
||||
selectionindicator.h \
|
||||
snappinglinecreator.h \
|
||||
snapper.h \
|
||||
onedimensionalcluster.h \
|
||||
singleselectionmanipulator.h \
|
||||
scalemanipulator.h \
|
||||
resizetool.h \
|
||||
resizeindicator.h \
|
||||
scaleitem.h \
|
||||
resizecontroller.h \
|
||||
resizehandleitem.h \
|
||||
anchortool.h \
|
||||
anchorlineindicator.h \
|
||||
anchorlinecontroller.h \
|
||||
anchorlinehandleitem.h \
|
||||
anchormanipulator.h \
|
||||
anchorindicator.h \
|
||||
anchorcontroller.h \
|
||||
anchorhandleitem.h \
|
||||
dragtool.h \
|
||||
itemcreatortool.cpp \
|
||||
toolbox.h \
|
||||
zoomaction.h \
|
||||
formeditorgraphicsview.h \
|
||||
numberseriesaction.h
|
||||
RESOURCES += formeditor.qrc
|
||||
12
src/plugins/qmldesigner/components/formeditor/formeditor.qrc
Normal file
@@ -0,0 +1,12 @@
|
||||
<RCC>
|
||||
<qresource prefix="/icon/handle">
|
||||
<file>resize_handle.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icon/tool">
|
||||
<file>anchor.png</file>
|
||||
<file>transform.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icon/layout">
|
||||
<file>snapping.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||