diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentHorizontalButtons.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentHorizontalButtons.qml index 84a61b35cc72e6855011a7d08b388b28f3daf10e..f2759bf3d4ff8fdb03f6cbe2181b5af76684c80d 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentHorizontalButtons.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentHorizontalButtons.qml @@ -5,7 +5,6 @@ QGroupBox { id: aligmentHorizontalButtons layout: HorizontalLayout { topMargin: 6 - rightMargin: 10; QWidget { fixedHeight: 32 diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentVerticalButtons.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentVerticalButtons.qml index 90da27b60756d58bf64784dca1e44a3163d3c17f..9b13025585ee06e411a9de541d95a04e256be46b 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentVerticalButtons.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/AlignmentVerticalButtons.qml @@ -5,7 +5,6 @@ QGroupBox { id: alignmentVerticalButtons layout: HorizontalLayout { topMargin: 6 - rightMargin: 10; QWidget { fixedHeight: 32 diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/AnchorButtons.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/AnchorButtons.qml index abac8f209c91b7cd4f2db01a02878404ad953407..d8dc5ad484f5978841bce3f27a6dceec864d10c7 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/AnchorButtons.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/AnchorButtons.qml @@ -21,8 +21,8 @@ QWidget { QPushButton { checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 31 + fixedHeight: 28 styleSheetFile: "anchortop.css"; checked: anchorBackend.topAnchored; @@ -39,10 +39,10 @@ QWidget { QPushButton { - x: 32 + x: 31 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 30 + fixedHeight: 28 styleSheetFile: "anchorbottom.css"; @@ -59,10 +59,10 @@ QWidget { } QPushButton { - x: 64 + x: 61 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 30 + fixedHeight: 28 styleSheetFile: "anchorleft.css"; @@ -79,10 +79,10 @@ QWidget { QPushButton { - x: 96 + x: 91 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 30 + fixedHeight: 28 styleSheetFile: "anchorright.css"; @@ -98,10 +98,10 @@ QWidget { } QPushButton { - x: 128 + x: 121 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 19 + fixedHeight: 28 styleSheetFile: "anchorspacer.css"; @@ -109,9 +109,9 @@ QWidget { } QPushButton { - x: 128 + 21 - fixedWidth: 32 - fixedHeight: 32 + x: 140 + fixedWidth: 30 + fixedHeight: 28 styleSheetFile: "anchorfill.css"; @@ -119,51 +119,51 @@ QWidget { } QPushButton { - x: 128 + 21 + 32 + x: 170 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 19 + fixedHeight: 28 styleSheetFile: "anchorspacer.css"; } QPushButton { - x: 128 + 42 + 64 + x: 189 checkable: true - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 30 + fixedHeight: 28 - styleSheetFile: "anchorhorizontal.css"; + styleSheetFile: "anchorvertical.css"; - checked: anchorBackend.horizontalCentered; + checked: anchorBackend.verticalCentered; onToggled: { if (checked) { anchorBackend.leftAnchored = false; anchorBackend.rightAnchored = false; - anchorBackend.horizontalCentered = true; + anchorBackend.verticalCentered = true; } else { - anchorBackend.horizontalCentered = false; + anchorBackend.verticalCentered = false; } } } QPushButton { - x: 128 + 42 + 32 + x: 219 checkable: true - fixedWidth: 32 - fixedHeight: 32 - - styleSheetFile: "anchorvertical.css"; + fixedWidth: 31 + fixedHeight: 28 + + styleSheetFile: "anchorhorizontal.css"; - checked: anchorBackend.verticalCentered; + checked: anchorBackend.horizontalCentered; onToggled: { if (checked) { anchorBackend.topAnchored = false; anchorBackend.bottomAnchored = false; - anchorBackend.verticalCentered = true; + anchorBackend.horizontalCentered = true; } else { - anchorBackend.verticalCentered = false; + anchorBackend.horizontalCentered = false; } } } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/CheckBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/CheckBox.qml index db3dd5f07c9aefde151e65eb9f0b50bd62813335..4b1b69de938a47a0827b679dac13834af856a01a 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/CheckBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/CheckBox.qml @@ -76,7 +76,7 @@ QWidget { //This is a special checkBox that does color coding for states ExtendedFunctionButton { backendValue: checkBox.backendValue - y: 4 + y: 3 x: localCheckBox.x + 18; } } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/ColorGroupBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/ColorGroupBox.qml index 51b039f948ad49455ebb5b6cd1909dc0d5a7e986..c589511bf24820558d4be88c1176efd66f9ef03a 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/ColorGroupBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/ColorGroupBox.qml @@ -138,6 +138,8 @@ QExtGroupBox { QWidget { layout: HorizontalLayout { + leftMargin: 12 + spacing: 0 ColorBox { id: colorControl; @@ -159,7 +161,8 @@ QExtGroupBox { layout: VerticalLayout { topMargin: 4 bottomMargin: 4 - rightMargin: 4 + rightMargin: 0 + leftMargin: 0 spacing: 2 QWidget { layout: HorizontalLayout { diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml index 9530811d7aab649bfb27b94b22ed07af263d38c9..5e1efa3e3c7a6eeb1bf1adbb6f70bde5f42a1220 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml @@ -65,6 +65,7 @@ QWidget { //This is a special doubleSpinBox that does color coding for states layout: HorizontalLayout { id: layoutH; + spacing: 4 QLabel { id: label; diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/FontGroupBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/FontGroupBox.qml index 7b272359803fd509acc2d6669e2b326dae93ac0c..dfc62d76bc779940e8e0ec689eda4b12331cb949 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/FontGroupBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/FontGroupBox.qml @@ -10,6 +10,7 @@ GroupBox { QWidget { layout: HorizontalLayout { + rightMargin: 12 Label { text: "Font" } @@ -58,6 +59,7 @@ GroupBox { QWidget { visible: showStyle layout: HorizontalLayout { + rightMargin: 12 Label { text: "Style" } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/ImageSpecifics.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/ImageSpecifics.qml index 08335b2739ba89eb2a7b36248e570093cf38a2ba..0b03bb1463af8f051024d74ad713ba6a7ae37a11 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/ImageSpecifics.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/ImageSpecifics.qml @@ -51,7 +51,7 @@ QWidget { QWidget { layout: HorizontalLayout { Label { - text: "Antialiasing:" + text: "Aliasing" } CheckBox { diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/Label.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/Label.qml index d2736a4a8985ea5a9c2aa67f0b99c7805449fd86..5005e78038a2bab40406c5674c2d75f691e8d975 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/Label.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/Label.qml @@ -6,5 +6,5 @@ QLabel { font.bold: true; alignment: "Qt::AlignRight | Qt::AlignVCenter" - fixedWidth: 98 + fixedWidth: 68 } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/Layout.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/Layout.qml index 7f1180214ee0e9a80e41d260a37d69d680ea055e..e57c76e2d109c92bbece3121e4802e4c20689857 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/Layout.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/Layout.qml @@ -10,7 +10,7 @@ GroupBox { enabled: anchorBackend.hasParent; property var targetLabelWidth: 90 - 20 - 26 - property int leftMarginMargin: 0 + property int leftMarginMargin: 16 layout: VerticalLayout { Label { @@ -19,6 +19,7 @@ GroupBox { QWidget { layout: HorizontalLayout { leftMargin: 10 + topMargin: 8 AnchorButtons { @@ -39,8 +40,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-top.png)"; } @@ -88,8 +89,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-bottom.png)"; } @@ -136,8 +137,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-left.png)"; } @@ -183,8 +184,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-right.png)"; } @@ -230,8 +231,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-horizontal.png)"; } @@ -277,8 +278,8 @@ GroupBox { leftMargin: 10 QLabel { //iconFromFile: "qrc:qmldesigner/images/icon-top.png" - fixedWidth: 32 - fixedHeight: 32 + fixedWidth: 16 + fixedHeight: 16 styleSheet: "border-image: url(:/qmldesigner/images/icon-vertical.png)"; } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/LineEdit.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/LineEdit.qml index ac782b83543ad72ac4def66fe904d064688684df..6a44ab9817b7f0fe82742e265e14f9ac73783c63 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/LineEdit.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/LineEdit.qml @@ -43,7 +43,7 @@ QWidget { QLineEdit { id: lineEditWidget - styleSheet: "padding-left: 16;" + styleSheet: "padding-left: 32;" width: lineEdit.width height: lineEdit.height @@ -66,7 +66,7 @@ QWidget { ExtendedFunctionButton { backendValue: lineEdit.backendValue y: 4 - x: 3 + x: 0 visible: lineEdit.enabled } } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/PropertyFrame.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/PropertyFrame.qml index 4d1136c8b26373fc9cceae011f5cbaf2e7c0cfce..14bd2d7966589c93c0a7bff98a6816839d8f3f2b 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/PropertyFrame.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/PropertyFrame.qml @@ -4,6 +4,6 @@ import Bauhaus 1.0 WidgetFrame { id: propertyFrame; - minimumWidth: 360; + minimumWidth: 300; styleSheetFile: "propertyEditor.css"; } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleColorGroupBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleColorGroupBox.qml index 096efff72ea606a6d1fcb606be9115cac53f3870..a8299551f89fa4ae70ac2a1a5963b6e152df8dc7 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleColorGroupBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleColorGroupBox.qml @@ -9,7 +9,7 @@ GroupBox { layout: VerticalLayout { ColorGroupBox { - caption: "Color" + caption: "Rectangle" finished: finishedNotify @@ -17,7 +17,7 @@ GroupBox { } ColorGroupBox { - caption: "Border Color" + caption: "Border" finished: finishedNotify backendColor: backendValues.border_color diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleSpecifics.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleSpecifics.qml index cebed70b081b9d5665242e0ceba937e48d257594..197ee274c12ad0cd1cabbb272f0a3b3f7f409181 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleSpecifics.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/RectangleSpecifics.qml @@ -20,6 +20,7 @@ QWidget { caption: "Rectangle" layout: VerticalLayout { + rightMargin: 24 IntEditor { backendValue: backendValues.radius @@ -35,7 +36,7 @@ QWidget { id: borderWidth; backendValue: backendValues.border_width === undefined ? 0 : backendValues.border_width - caption: "Border Width" + caption: "Border" baseStateFlag: isBaseState; step: 1; diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml index 488a44c34397988ff56f9146e7fbdc1844f96570..ac65579217550f161e876425adf7b5d52b6be44d 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml @@ -10,7 +10,7 @@ QWidget { //This is a special spinBox that does color coding for states property alias singleStep: box.singleStep; property alias minimum: box.minimum property alias maximum: box.maximum - property alias enabled: box.enabled + property bool enabled: true minimumHeight: 22; @@ -62,12 +62,14 @@ QWidget { //This is a special spinBox that does color coding for states ColorScheme { id:scheme; } layout: HorizontalLayout { + spacing: 4 QSpinBox { property alias backendValue: spinBox.backendValue + + enabled: !backendValue.isBound && spinBox.enabled; keyboardTracking: false; id: box; - enabled: backendValue.isBound property bool readingFromBackend: false; property int valueFromBackend: spinBox.backendValue.value; diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/StandardTextColorGroupBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/StandardTextColorGroupBox.qml index 69f6f2d787074098d3eb65085687ba9b2d5c688c..38926cb8345e42e6b18caabf70a5829b465c668e 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/StandardTextColorGroupBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/StandardTextColorGroupBox.qml @@ -36,7 +36,7 @@ GroupBox { ColorGroupBox { visible: showSelectedTextColor - caption: "Selected Text" + caption: "Selected" finished: finishedNotify diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/Switches.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/Switches.qml index fcf2bc79a1b327b8aabd779205de4efd2916de45..7b6a70b4384304d908cbc95ff79d18038910c575 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/Switches.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/Switches.qml @@ -35,8 +35,8 @@ QFrame { id: layoutMode; checkable: true; checked: false; - toolTip: "layout and geometry"; - text: "Geometry"; + toolTip: qsTr("layout and geometry"); + text: qsTr("Geometry"); onClicked: { extendedMode.checked = false; standardMode.checked = false; @@ -52,7 +52,7 @@ QFrame { toolTip: "advanced properties"; checkable: true; checked: false; - text: "Advanced" + text: qsTr("Advanced") onClicked: { standardMode.checked = false; layoutMode.checked = false; diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/TextEditSpecifics.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/TextEditSpecifics.qml index c97a73bd0c59fad83f8b5cb272aa5276303e471b..75e317155bcdb40b12c09d070b6db860f749f42c 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/TextEditSpecifics.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/TextEditSpecifics.qml @@ -28,8 +28,9 @@ QWidget { QWidget { layout: HorizontalLayout { + rightMargin: 12 Label { - text: "Text Format" + text: "Format" } ComboBox { baseStateFlag: isBaseState diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/TextInputGroupBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/TextInputGroupBox.qml index 679d0f5a93640aa1b97e05e93526dc82163106bd..25d69558d992aae3163f3f588069f65d79a1412d 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/TextInputGroupBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/TextInputGroupBox.qml @@ -10,15 +10,25 @@ GroupBox { QWidget { layout: HorizontalLayout { + Label {text: "Flags"} CheckBox { - text: "Read Only"; baseStateFlag: isBaseState; checkable: true; backendValue: backendValues.readOnly; } + + + + } + } + + QWidget { + layout: HorizontalLayout { + Label {text: ""} + CheckBox { text: "Cursor Visible"; @@ -28,6 +38,12 @@ GroupBox { } + } + } + + QWidget { + layout: HorizontalLayout { + Label {text: ""} CheckBox { text: "Focus On Press"; baseStateFlag: isBaseState; diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/alignmenttopbutton.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/alignmenttopbutton.css index e95c4aa5f32a00b5ec6392c0dbe8053d89508609..9356377536c327592e428357ce5962ba70208928 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/alignmenttopbutton.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/alignmenttopbutton.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/button_alignment_top_normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/button_alignment_top_normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/button_alignment_top_pressed.png) 3; + border-image: url(:/qmldesigner/images/button_alignment_top_pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/button_alignment_top_pressed.png) 3; + border-image: url(:/qmldesigner/images/button_alignment_top_pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorbottom.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorbottom.css index 3f099aa99c8edf04e8d6903e9e12c312c9d6f2f1..98ad512dc962a177859d5b75be64074a23297259 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorbottom.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorbottom.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-bottom-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-bottom-normal.png); } - QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-bottom-pressed.png) 3; +QPushButton:pressed { + border-image: url(:/qmldesigner/images/anchor-bottom-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-bottom-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-bottom-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorfill.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorfill.css index a54050c0b25073350dc983c8e1be30ed8708b92f..c382641d03310d94df7314794eedf9a2328a04f5 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorfill.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorfill.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-fill-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-fill-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-fill-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-fill-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-fill-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-fill-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorhorizontal.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorhorizontal.css index 0f516137ea5c7ef6239d023d5c0d209d1a9ab440..28be04e0eadff4ad56aa5bbd348c12953ca93afd 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorhorizontal.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorhorizontal.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-horizontal-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-horizontal-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-horizontal-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-horizontal-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-horizontal-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-horizontal-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorleft.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorleft.css index 579bc31e1966fc1b4c3b7be524e62ff16b35c6fa..53c9604c0ac8f06b0f643a82591c035636fee082 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorleft.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorleft.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-left-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-left-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-left-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-left-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-left-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-left-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorright.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorright.css index 7eabfbb3971203ee091820e483f64481f80ab573..ee1690e23c9ec6be9074328390e695ff22d07232 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorright.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorright.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-right-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-right-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-right-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-right-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-right-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-right-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorspacer.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorspacer.css index 68c908d6ca871e1652713be9473c625136a4660d..22cfdf85989c5ae739905fbd6bb197f4a2b4a0eb 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorspacer.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorspacer.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-spacer.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-spacer.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-spacer.png) 3; + border-image: url(:/qmldesigner/images/anchor-spacer.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-spacer.png) 3; + border-image: url(:/qmldesigner/images/anchor-spacer.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchortop.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchortop.css index 57a0842eb55bd608cd61edd43a5949f097e309e3..2310144c1e8e6222cf6ed4a345af21475baeeb03 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchortop.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchortop.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-top-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-top-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-top-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-top-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-top-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-top-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorvertical.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorvertical.css index 62a2d779d969e59cd241c55e47fe9aa33f7efd88..578030e0658191a80e94e072e70327b4878063c1 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorvertical.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/anchorvertical.css @@ -1,12 +1,11 @@ QPushButton { - border-image: url(:/qmldesigner/images/anchor-vertical-normal.png) 3; - border-width: 3; + border-image: url(:/qmldesigner/images/anchor-vertical-normal.png); } QPushButton:pressed { - border-image: url(:/qmldesigner/images/anchor-vertical-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-vertical-pressed.png); } QPushButton:checked { - border-image: url(:/qmldesigner/images/anchor-vertical-pressed.png) 3; + border-image: url(:/qmldesigner/images/anchor-vertical-pressed.png); } diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/propertyEditor.css b/share/qtcreator/qmldesigner/propertyeditor/Qt/propertyEditor.css index 68df338f632e7005d5b4d5bd5dcfffdb9ca025b1..0f23858ad58f1f763924909d4791c8519f92fd53 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/propertyEditor.css +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/propertyEditor.css @@ -69,10 +69,10 @@ QPlainTextEdit { font-size: 11px; color: white; - padding-right: 4px; + padding-right: 2px; padding-top: 2px; padding-bottom: 2px; - padding-left: 20px; + padding-left: 20px; border: 2px solid #0F0F0F; border-radius: 6px; border-width: 1; @@ -88,10 +88,10 @@ QPlainTextEdit { font-size: 11px; color: white; - padding-right: 4px; + padding-right: 2px; padding-top: 2px; padding-bottom: 2px; - padding-left: 20px; + padding-left: 20px; border: 2px solid #0F0F0F; border-radius: 6px; border-width: 1; @@ -199,19 +199,19 @@ QPushButton { QPushButton, QComboBox[editable="false"], QComboBox[editable="true"] { - border-image: url(:/qmldesigner/images/pushbutton.png) 4; + border-image: url(:/qmldesigner/images/combobox-normal.png) 4; border-width: 3; } QPushButton:hover, QComboBox[editable="false"]:hover, QComboBox[editable="true"]:hover, QMenuBar::item:hover { - border-image: url(:/qmldesigner/images/pushbutton_hover.png) 4; + border-image: url(:/qmldesigner/images/combobox-normal.png) 4; border-width: 3; } QPushButton:pressed, QComboBox[editable="false"]:on, QComboBox[editable="true"]:on, QMenuBar::item:on { - border-image: url(:/qmldesigner/images/pushbutton_pressed.png) 4; + border-image: url(:/qmldesigner/images/combobox-pressed.png) 4; border-width: 3; } @@ -404,18 +404,15 @@ QMenu::separator { } QSlider::groove:horizontal { - height: 8px; - border: 2px solid #0F0F0F; - border-radius: 6px; - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #2c2c2c, stop: 1 #333333); + height: 2px; + border-image: url(:/qmldesigner/images/slider_line.png) 0; margin: 5px 0; } QSlider::handle:horizontal { - border: 2px solid #1B1B1B; - border-image: url(:/qmldesigner/images/pushbutton.png) 3; - width: 6px; + image: url(:/qmldesigner/images/slider_indikator.png); + width: 8px; + height: 8px; margin: 0px 0; } diff --git a/src/plugins/qmldesigner/components/formeditor/toolbox.cpp b/src/plugins/qmldesigner/components/formeditor/toolbox.cpp index fc4534de93f12f80db4c3fc099a5289eedba542d..787b3fabf33d7d116389d0f12835d031525c8e7b 100644 --- a/src/plugins/qmldesigner/components/formeditor/toolbox.cpp +++ b/src/plugins/qmldesigner/components/formeditor/toolbox.cpp @@ -78,4 +78,9 @@ void ToolBox::addAction(QAction *action) m_toolBar->addAction(action); } +QList<QAction*> ToolBox::actions() const +{ + return m_toolBar->actions(); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/toolbox.h b/src/plugins/qmldesigner/components/formeditor/toolbox.h index a2ede944b4d1777b7c09c22b0a4b7eb6e0784034..6195b095322ece34a32b6df41c49720854a537ce 100644 --- a/src/plugins/qmldesigner/components/formeditor/toolbox.h +++ b/src/plugins/qmldesigner/components/formeditor/toolbox.h @@ -44,6 +44,7 @@ public: ToolBox(QWidget *parentWidget); void setActions(const QList<QAction*> &actions); void addAction(QAction *action); + QList<QAction*> actions() const; private: QToolBar *m_toolBar; diff --git a/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.cpp b/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.cpp deleted file mode 100644 index 35cb7b58ae4dd26d8afc1c6323d64630411a2abf..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 <QtGui/QStackedWidget> - -#include <allpropertiesbox.h> - -#include "designdocumentcontroller.h" -#include "allpropertiesviewcontroller.h" - -namespace QmlDesigner { - -AllPropertiesViewController::AllPropertiesViewController(QObject* parent): - StackedUtilityPanelController(parent) -{ - setObjectName("PropertiesViewController"); -} - -QWidget* AllPropertiesViewController::stackedPageWidget(DesignDocumentController* designDocumentController) const -{ - return designDocumentController->allPropertiesBox(); -} - -void AllPropertiesViewController::showNewLookProperties() -{ - AllPropertiesBox* propsBox = dynamic_cast<AllPropertiesBox*>(dynamic_cast<QStackedWidget*>(contentWidget())->currentWidget()); - if (propsBox) - propsBox->showNewLook(); -} - -void AllPropertiesViewController::showTraditionalProperties() -{ - AllPropertiesBox* propsBox = dynamic_cast<AllPropertiesBox*>(dynamic_cast<QStackedWidget*>(contentWidget())->currentWidget()); - if (propsBox) - propsBox->showTraditional(); -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.h b/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.h deleted file mode 100644 index 210ed5040416be0e02e44bd4619f8cc948d76727..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/allpropertiesviewcontroller.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 ALLPROPERTIESVIEWCONTROLLER_H -#define ALLPROPERTIESVIEWCONTROLLER_H - -#include "stackedutilitypanelcontroller.h" - -namespace QmlDesigner { - -class AllPropertiesViewController : public StackedUtilityPanelController -{ - Q_OBJECT - -public: - AllPropertiesViewController(QObject* parent = 0); - -public slots: - void showNewLookProperties(); - void showTraditionalProperties(); - -protected: - class QWidget* stackedPageWidget(class DesignDocumentController* designDocumentController) const; -}; - -} // namespace QmlDesigner - -#endif // ALLPROPERTIESVIEWCONTROLLER_H diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index 71e0ed10ec9de89295f0b1ac8629758cb9c6b0ee..7135777bbb509a2d66500c41c78f016cfe68edce 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -97,13 +97,11 @@ public: QWeakPointer<SubComponentManager> subComponentManager; QWeakPointer<Internal::ViewLogger> viewLogger; - QWeakPointer<QProcess> previewProcess; - QWeakPointer<QProcess> previewWithDebugProcess; - QString fileName; QUrl searchPath; bool documentLoaded; bool syncBlocked; + QWeakPointer<ComponentAction> componentAction; }; @@ -117,39 +115,20 @@ DesignDocumentController::DesignDocumentController(QObject *parent) : QObject(parent), m_d(new DesignDocumentControllerPrivate) { - m_d->itemLibrary = new ItemLibrary; - m_d->navigator = new NavigatorView(this); - m_d->allPropertiesBox = new AllPropertiesBox; - m_d->statesEditorWidget = new StatesEditorWidget; - m_d->stackedWidget = new QStackedWidget; - m_d->documentLoaded = false; m_d->syncBlocked = false; } DesignDocumentController::~DesignDocumentController() { - delete m_d->formEditorView.data(); - - // deleting the widgets should be safe because these are QWeakPointer's - delete m_d->itemLibrary.data(); - delete m_d->allPropertiesBox.data(); - delete m_d->statesEditorWidget.data(); - delete m_d->stackedWidget.data(); - delete m_d->model.data(); delete m_d->subComponentModel.data(); delete m_d->rewriterView.data(); - // m_d->textEdit is child of stackedWidget or owned by external widget - delete m_d->textModifier; if (m_d->componentTextModifier) //componentTextModifier might not be created delete m_d->componentTextModifier; - delete m_d->previewProcess.data(); - delete m_d->previewWithDebugProcess.data(); - delete m_d; } @@ -163,76 +142,11 @@ Model *DesignDocumentController::masterModel() const return m_d->masterModel.data(); } -QWidget *DesignDocumentController::documentWidget() const -{ - return m_d->stackedWidget.data(); -} - -void DesignDocumentController::togglePreview(bool visible) -{ - if (!m_d->documentLoaded) - return; - - if (visible) { - Q_ASSERT(!m_d->previewProcess); - - QString directory; - if (!m_d->fileName.isEmpty()) { - directory = QFileInfo(m_d->fileName).absoluteDir().path(); - } else { - directory = QDir::tempPath(); - } - m_d->previewProcess = createPreviewProcess(directory); - connect(m_d->previewProcess.data(), SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(emitPreviewVisibilityChanged())); - } else { - Q_ASSERT(m_d->previewProcess); - - delete m_d->previewProcess.data(); - } -} - -void DesignDocumentController::toggleWithDebugPreview(bool visible) -{ - if (!m_d->documentLoaded) - return; - - if (visible) { - Q_ASSERT(!m_d->previewWithDebugProcess); - - QString directory; - if (!m_d->fileName.isEmpty()) { - directory = QFileInfo(m_d->fileName).absoluteDir().path(); - } else { - directory = QDir::tempPath(); - } - m_d->previewWithDebugProcess = createPreviewWithDebugProcess(directory); - connect(m_d->previewWithDebugProcess.data(), SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(emitPreviewWithDebugVisibilityChanged())); - } else { - Q_ASSERT(m_d->previewWithDebugProcess); - - delete m_d->previewWithDebugProcess.data(); - } -} - -bool DesignDocumentController::previewVisible() const +QWidget *DesignDocumentController::centralWidget() const { - if (!m_d->documentLoaded) - return false; - - return m_d->previewProcess; + return qobject_cast<QWidget*>(parent()); } -bool DesignDocumentController::previewWithDebugVisible() const -{ - if (!m_d->documentLoaded) - return false; - - return m_d->previewWithDebugProcess; -} - - /*! Returns whether the model is automatically updated if the text editor changes. */ @@ -272,14 +186,29 @@ QList<RewriterView::Error> DesignDocumentController::qmlErrors() const return m_d->rewriterView->errors(); } -void DesignDocumentController::emitPreviewVisibilityChanged() +void DesignDocumentController::setItemLibrary(ItemLibrary* itemLibrary) +{ + m_d->itemLibrary = itemLibrary; +} + +void DesignDocumentController::setNavigator(NavigatorView* navigatorView) +{ + m_d->navigator = navigatorView; +} + +void DesignDocumentController::setAllPropertiesBox(AllPropertiesBox* allPropertiesBox) { - emit previewVisibilityChanged(false); + m_d->allPropertiesBox = allPropertiesBox; } -void DesignDocumentController::emitPreviewWithDebugVisibilityChanged() +void DesignDocumentController::setStatesEditorWidget(StatesEditorWidget* statesEditorWidget) { - emit previewWithDebugVisibilityChanged(false); + m_d->statesEditorWidget = statesEditorWidget; +} + +void DesignDocumentController::setFormEditorView(FormEditorView *formEditorView) +{ + m_d->formEditorView = formEditorView; } QString DesignDocumentController::displayName() const @@ -411,21 +340,21 @@ void DesignDocumentController::loadCurrentModel() Q_ASSERT(m_d->model); m_d->model->setMasterModel(m_d->masterModel.data()); - m_d->allPropertiesBox->setModel(m_d->model.data()); - m_d->model->attachView(m_d->navigator.data()); m_d->itemLibrary->setMetaInfo(m_d->model->metaInfo()); - if (m_d->formEditorView.isNull()) { - m_d->formEditorView = new FormEditorView(this); - m_d->stackedWidget->addWidget(m_d->formEditorView->widget()); - ComponentAction *componentAction = new ComponentAction(m_d->formEditorView->widget()); - componentAction->setModel(m_d->model.data()); - // TODO: Enable again - //m_d->formEditorView->widget()->lowerToolBox()->addAction(componentAction); - connect(componentAction, SIGNAL(currentComponentChanged(ModelNode)), SLOT(changeCurrentModelTo(ModelNode))); //TODO component action - connect(m_d->itemLibrary.data(), SIGNAL(itemActivated(const QString&)), m_d->formEditorView.data(), SLOT(activateItemCreator(const QString&))); + if (!m_d->componentAction) { + m_d->componentAction = new ComponentAction(m_d->formEditorView->widget()); + m_d->componentAction->setModel(m_d->model.data()); + connect(m_d->componentAction.data(), SIGNAL(currentComponentChanged(ModelNode)), SLOT(changeCurrentModelTo(ModelNode))); + m_d->formEditorView->widget()->lowerToolBox()->addAction(m_d->componentAction.data()); } + foreach (QAction *action , m_d->formEditorView->widget()->lowerToolBox()->actions()) + if (qobject_cast<ComponentAction*>(action)) + action->setVisible(false); + m_d->componentAction->setVisible(true); + + connect(m_d->itemLibrary.data(), SIGNAL(itemActivated(const QString&)), m_d->formEditorView.data(), SLOT(activateItemCreator(const QString&))); m_d->model->attachView(m_d->formEditorView.data()); @@ -436,6 +365,8 @@ void DesignDocumentController::loadCurrentModel() // Will call setCurrentState (formEditorView etc has to be constructed first) m_d->statesEditorWidget->setup(m_d->model.data()); + m_d->allPropertiesBox->setModel(m_d->model.data()); + m_d->documentLoaded = true; Q_ASSERT(m_d->masterModel); } @@ -461,13 +392,13 @@ void DesignDocumentController::doRealSaveAs(const QString &fileName) QFileInfo fileInfo(fileName); if (fileInfo.exists() && !fileInfo.isWritable()) { - QMessageBox msgBox(documentWidget()); + QMessageBox msgBox(centralWidget()); msgBox.setIcon(QMessageBox::Warning); msgBox.setText(tr("Cannot save to file \"%1\": permission denied.").arg(fileInfo.baseName())); msgBox.exec(); return; } else if (!fileInfo.exists() && !fileInfo.dir().exists()) { - QMessageBox msgBox(documentWidget()); + QMessageBox msgBox(centralWidget()); msgBox.setIcon(QMessageBox::Warning); msgBox.setText(tr("Parent folder \"%1\" for file \"%2\" does not exist.") .arg(fileInfo.dir().dirName()) @@ -477,28 +408,7 @@ void DesignDocumentController::doRealSaveAs(const QString &fileName) } setFileName(fileName); - save(documentWidget()); -} - -bool DesignDocumentController::save(QWidget *parent) -{ -// qDebug() << "Saving document to file \"" << m_d->fileName << "\"..."; -// - if (m_d->fileName.isEmpty()) { - saveAs(parent); - return true; - } - QFile file(m_d->fileName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - showError(tr("Cannot write file: \"%1\".").arg(m_d->fileName), parent); - return false; - } - - QString errorMessage; - bool result = save(&file, &errorMessage); - if (!result) - showError(errorMessage, parent); - return result; + save(centralWidget()); } bool DesignDocumentController::isDirty() const @@ -511,17 +421,21 @@ bool DesignDocumentController::isDirty() const bool DesignDocumentController::isUndoAvailable() const { - return m_d->textEdit->document()->isUndoAvailable(); + + if (m_d->textEdit) + return m_d->textEdit->document()->isUndoAvailable(); + return false; } bool DesignDocumentController::isRedoAvailable() const { - return m_d->textEdit->document()->isRedoAvailable(); + if (m_d->textEdit) + return m_d->textEdit->document()->isRedoAvailable(); + return false; } void DesignDocumentController::close() { - documentWidget()->close(); m_d->documentLoaded = false; emit designDocumentClosed(); } @@ -752,26 +666,6 @@ void DesignDocumentController::showError(const QString &message, QWidget *parent msgBox.exec(); } -QWidget *DesignDocumentController::itemLibrary() const -{ - return m_d->itemLibrary.data(); -} - -QWidget *DesignDocumentController::navigator() const -{ - return m_d->navigator->widget(); -} - -QWidget *DesignDocumentController::allPropertiesBox() const -{ - return m_d->allPropertiesBox.data(); -} - -QWidget *DesignDocumentController::statesEditorWidget() const -{ - return m_d->statesEditorWidget.data(); -} - RewriterView *DesignDocumentController::rewriterView() const { return m_d->rewriterView.data(); @@ -803,79 +697,26 @@ void DesignDocumentController::showForm() } #endif // ENABLE_TEXT_VIEW -QProcess *DesignDocumentController::createPreviewProcess(const QString &dirPath) -{ - Q_ASSERT(QDir(dirPath).exists()); - - QProcess *previewProcess = new QProcess(this); - previewProcess->setWorkingDirectory(dirPath); - - QTemporaryFile *temporaryFile = new QTemporaryFile(QDir(dirPath).absoluteFilePath("bauhaus_tmp")); - temporaryFile->setParent(previewProcess); - - temporaryFile->open(); - - m_d->textModifier->save(temporaryFile); - - QStringList qmlViewerArgumentList; -// qmlViewerArgumentList.append("-L"); -// qmlViewerArgumentList.append(dirPath); - previewProcess->setWorkingDirectory(dirPath); - qmlViewerArgumentList.append(temporaryFile->fileName()); - - temporaryFile->close(); - - previewProcess->start(QString("%1/qml").arg(QCoreApplication::applicationDirPath()), qmlViewerArgumentList); - if (!previewProcess->waitForStarted()) - previewProcess->start("qml", qmlViewerArgumentList); - if (!previewProcess->waitForStarted()) - QMessageBox::warning(documentWidget(), "qml runtime not found", "qml runtime should be in the PATH or in the same directory like the bauhaus binary."); - - return previewProcess; -} - -QProcess *DesignDocumentController::createPreviewWithDebugProcess(const QString &dirPath) +bool DesignDocumentController::save(QWidget *parent) { - Q_ASSERT(QDir(dirPath).exists()); - - QProcess *previewProcess = new QProcess(this); - previewProcess->setWorkingDirectory(dirPath); - - QProcess *debugger = new QProcess(previewProcess); - - QTemporaryFile *temporaryFile = new QTemporaryFile(QDir(dirPath).absoluteFilePath("bauhaus_tmp")); - temporaryFile->setParent(previewProcess); - - temporaryFile->open(); - - m_d->textModifier->save(temporaryFile); - - QStringList environmentList = QProcess::systemEnvironment(); - environmentList.append("QML_DEBUG_SERVER_PORT=3768"); - previewProcess->setEnvironment(environmentList); - - QStringList qmlViewerArgumentList; -// qmlViewerArgumentList.append("-L"); -// qmlViewerArgumentList.append(libraryPath); - qmlViewerArgumentList.append(temporaryFile->fileName()); - - temporaryFile->close(); - - debugger->setWorkingDirectory(dirPath); - debugger->start(QString("%1/qmldebugger").arg(QCoreApplication::applicationDirPath())); - if (!debugger->waitForStarted()) - debugger->start("qmldebugger", qmlViewerArgumentList); - if (!debugger->waitForStarted()) - QMessageBox::warning(documentWidget(), "qmldebugger not found", "qmldebugger should in the PATH or in the same directory like the bauhaus binary."); - - previewProcess->setWorkingDirectory(dirPath); - previewProcess->start(QString("%1/qml").arg(QCoreApplication::applicationDirPath()), qmlViewerArgumentList); - if (!previewProcess->waitForStarted()) - previewProcess->start("qml", qmlViewerArgumentList); - if (!previewProcess->waitForStarted()) - QMessageBox::warning(documentWidget(), "qml runtime not found", "qml runtime should in the PATH or in the same directory like the bauhaus binary."); + // qDebug() << "Saving document to file \"" << m_d->fileName << "\"..."; + // + if (m_d->fileName.isEmpty()) { + saveAs(parent); + return true; + } + QFile file(m_d->fileName); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + showError(tr("Cannot write file: \"%1\".").arg(m_d->fileName), parent); + return false; + } - return previewProcess; + QString errorMessage; + bool result = save(&file, &errorMessage); + if (!result) + showError(errorMessage, parent); + return result; + save(centralWidget()); } bool DesignDocumentController::save(QIODevice *device, QString * /*errorMessage*/) @@ -884,12 +725,11 @@ bool DesignDocumentController::save(QIODevice *device, QString * /*errorMessage* QByteArray data = m_d->textEdit->toPlainText().toLatin1(); device->write(data); m_d->textEdit->setPlainText(data); // clear undo/redo history - return true; - } else { - return false; } + return false; } + QString DesignDocumentController::contextHelpId() const { DesignDocumentControllerView view; diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h index 311861fc112e5a0197feea1c27de9fa2033cb893..dd06e26d4e384f2bcf7796b1aa7a86d5a9893308 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h @@ -51,6 +51,11 @@ class ModelNode; class TextModifier; class QmlObjectNode; class RewriterView; +class ItemLibrary; +class NavigatorView; +class AllPropertiesBox; +class StatesEditorWidget; +class FormEditorView; class DesignDocumentController: public QObject { @@ -74,18 +79,9 @@ public: bool isRedoAvailable() const; Model *model() const; - Model *masterModel() const; + Model *masterModel() const; - QWidget *documentWidget() const; - QWidget *itemLibrary() const; - QWidget *navigator() const; - QWidget *allPropertiesBox() const; - QWidget *statesEditorWidget() const; - - RewriterView *rewriterView() const; - - bool previewVisible() const; - bool previewWithDebugVisible() const; + RewriterView *rewriterView() const; bool isModelSyncBlocked() const; void blockModelSync(bool block); @@ -93,14 +89,18 @@ public: QString contextHelpId() const; QList<RewriterView::Error> qmlErrors() const; + void setItemLibrary(ItemLibrary* itemLibrary); + void setNavigator(NavigatorView* navigatorView); + void setAllPropertiesBox(AllPropertiesBox* allPropertiesBox); + void setStatesEditorWidget(StatesEditorWidget* statesEditorWidget); + void setFormEditorView(FormEditorView *formEditorView); + signals: void displayNameChanged(const QString &newFileName); void dirtyStateChanged(bool newState); void undoAvailable(bool isAvailable); void redoAvailable(bool isAvailable); - void previewVisibilityChanged(bool visible); - void previewWithDebugVisibilityChanged(bool visible); void designDocumentClosed(); void qmlErrorsChanged(const QList<RewriterView::Error> &errors); @@ -114,12 +114,6 @@ public slots: void cutSelected(); void paste(); void selectAll(); - - void togglePreview(bool visible); - void toggleWithDebugPreview(bool visible); - - void emitPreviewVisibilityChanged(); - void emitPreviewWithDebugVisibilityChanged(); void undo(); void redo(); @@ -134,11 +128,9 @@ private slots: void changeCurrentModelTo(const ModelNode &node); private: - QProcess *createPreviewProcess(const QString &dirPath); - QProcess *createPreviewWithDebugProcess(const QString &dirPath); - bool save(QIODevice *device, QString *errorMessage); - + QWidget *centralWidget() const; class DesignDocumentControllerPrivate *m_d; + bool save(QIODevice *device, QString *errorMessage); }; } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/integration/documentcloser.cpp b/src/plugins/qmldesigner/components/integration/documentcloser.cpp deleted file mode 100644 index dbbe6f7edcbb416fcd81b53e94f767a565001ddf..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/documentcloser.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 "documentcloser.h" - -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> -#include <QtCore/QFileInfo> - -#include <QtGui/QMessageBox> - -#include "designdocumentcontroller.h" - -namespace QmlDesigner { - -DocumentCloser::DocumentCloser(): - m_quitWhenDone(false) -{ -} - -void DocumentCloser::close(DesignDocumentController* designDocument) -{ - DocumentCloser* closer = new DocumentCloser; - closer->m_designDocuments.append(designDocument); - closer->runClose(designDocument); -} - -void DocumentCloser::runClose(DesignDocumentController* designDocument) -{ - bool isDirty = designDocument->isDirty(); - -//#ifndef QT_NO_DEBUG -// isDirty=false; -//#endif - - if (isDirty) { - QMessageBox* msgBox = new QMessageBox(designDocument->documentWidget()); - QString txt = tr("Do you want to save the changes you made in the document \"%1\"?"); - QString shortFileName = QFileInfo(designDocument->fileName()).baseName(); - msgBox->setText(txt.arg(shortFileName)); - msgBox->setInformativeText(tr("Your changes will be lost if you don't save them.")); - msgBox->setIcon(QMessageBox::Question); - msgBox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - msgBox->setDefaultButton(QMessageBox::Save); - msgBox->setEscapeButton(QMessageBox::Cancel); - msgBox->resize(451, 131); - msgBox->open(this, SLOT(choiceMade())); - } else { - designDocument->close(); - closeDone(); - } -} - -void DocumentCloser::choiceMade() -{ - QMessageBox* msgBox = dynamic_cast<QMessageBox*>(sender()); - if (!msgBox) - return; - - switch (msgBox->result()) { - case QMessageBox::Save: - m_designDocuments.first()->save(); - - case QMessageBox::Discard: - m_designDocuments.first()->close(); - closeDone(); - break; - - case QMessageBox::Cancel: - default: - closeCancelled(); - } -} - -void DocumentCloser::closeCancelled() -{ - delete this; -} - -void DocumentCloser::closeDone() -{ - if (!m_designDocuments.isEmpty()) // should always be the case, but let's be safe. - m_designDocuments.removeFirst(); - - bool quit = m_quitWhenDone; - - if (m_designDocuments.isEmpty()) { - delete this; - - if (quit) { - qApp->quit(); - } - } else { - runClose(m_designDocuments.first().data()); - } -} - -void DocumentCloser::close(QList<QWeakPointer<DesignDocumentController> > designDocuments, bool quitWhenAllEditorsClosed) -{ - if (designDocuments.isEmpty()) { - if (quitWhenAllEditorsClosed) { - qApp->quit(); - } - } else { - DocumentCloser* closer = new DocumentCloser; - closer->m_designDocuments = designDocuments; - closer->m_quitWhenDone = quitWhenAllEditorsClosed; - closer->runClose(closer->m_designDocuments.first().data()); - } -} - -} // namespace QmlDesigner - diff --git a/src/plugins/qmldesigner/components/integration/documentcloser.h b/src/plugins/qmldesigner/components/integration/documentcloser.h deleted file mode 100644 index b69c234de1c6e16b67a0aa601a1ca9c2966cbe5d..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/documentcloser.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 DOCUMENTCLOSER_H -#define DOCUMENTCLOSER_H - -#include <QWeakPointer> -#include <QtCore/QList> -#include <QtCore/QObject> - - -#include "designdocumentcontroller.h" - -namespace QmlDesigner { - -class DocumentCloser : public QObject -{ - Q_OBJECT - -public: - static void close(DesignDocumentController* designDocument); - static void close(QList<QWeakPointer<DesignDocumentController> > designDocuments, bool quitWhenAllEditorsClosed); - -private: - DocumentCloser(); - - void runClose(DesignDocumentController* designDocument); - void closeDone(); - void closeCancelled(); - -private slots: - void choiceMade(); - -private: - QList<QWeakPointer<DesignDocumentController> > m_designDocuments; - bool m_quitWhenDone; -}; - -} // namespace QmlDesigner - -#endif // DOCUMENTCLOSER_H diff --git a/src/plugins/qmldesigner/components/integration/integration.pri b/src/plugins/qmldesigner/components/integration/integration.pri index 0247e2df106b44dfcb72dc98af78d661204bb38d..1548688998608679d4b39ac06c55753bda38c87d 100644 --- a/src/plugins/qmldesigner/components/integration/integration.pri +++ b/src/plugins/qmldesigner/components/integration/integration.pri @@ -2,32 +2,20 @@ VPATH += $$PWD INCLUDEPATH += $$PWD SOURCES += \ integrationcore.cpp \ - multipledocumentscontroller.cpp \ designdocumentcontroller.cpp \ designdocumentcontrollerview.cpp \ - navigatorcontroller.cpp \ - allpropertiesviewcontroller.cpp \ utilitypanelcontroller.cpp \ - widgetboxcontroller.cpp \ stackedutilitypanelcontroller.cpp \ - stateseditorcontroller.cpp \ - documentcloser.cpp \ componentaction.cpp \ componentview.cpp \ xuifiledialog.cpp HEADERS += \ integrationcore.h \ - multipledocumentscontroller.h \ designdocumentcontrollerview.h \ designdocumentcontroller.h \ - navigatorcontroller.h \ - allpropertiesviewcontroller.h \ utilitypanelcontroller.h \ - widgetboxcontroller.h \ stackedutilitypanelcontroller.h \ - stateseditorcontroller.h \ - documentcloser.h \ componentaction.h \ componentview.h \ xuifiledialog.h diff --git a/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.cpp b/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.cpp deleted file mode 100644 index 24793e0746bf9569318ad36d4a6a0e05fa5cc5cf..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 "multipledocumentscontroller.h" - -#include <QtCore/QFileInfo> -#include <QtGui/QTextEdit> -#include <QtGui/QMessageBox> - -#include <QDeclarativeError> - -#include <model.h> -#include "designdocumentcontroller.h" -#include "documentcloser.h" - - -namespace QmlDesigner { - -static QString createTitle(const QString& fileName) -{ - return QFileInfo(fileName).baseName(); -} - -MultipleDocumentsController::MultipleDocumentsController(QWidget* parent): - QObject(parent), - m_tabWidget(new QTabWidget), - m_undoAction(new QAction(tr("&Undo"), this)), - m_redoAction(new QAction(tr("&Redo"), this)) -{ - m_tabWidget->setDocumentMode(true); - m_tabWidget->setTabsClosable(true); - m_tabWidget->setMovable(true); - - connect(tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); - connect(tabWidget(), SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int))); -} - -MultipleDocumentsController::~MultipleDocumentsController() -{ -} - -QTabWidget *MultipleDocumentsController::tabWidget() const -{ - return m_tabWidget.data(); -} - -DesignDocumentController* MultipleDocumentsController::findActiveDocument(QWidget* documentWidget) -{ - foreach (const QWeakPointer<DesignDocumentController> &controller, m_documentControllers) - if (controller->documentWidget() == documentWidget) - return controller.data(); - - return 0; -} - -void MultipleDocumentsController::rewireDocumentActions(DesignDocumentController* oldActiveDocument, DesignDocumentController* newActiveDocument) -{ - if (oldActiveDocument) { - disconnect(undoAction(), SIGNAL(triggered()), oldActiveDocument, SLOT(undo())); - disconnect(redoAction(), SIGNAL(triggered()), oldActiveDocument, SLOT(redo())); -#ifdef ENABLE_TEXT_VIEW - disconnect(m_showTextAction.data(), SIGNAL(triggered()), oldActiveDocument, SLOT(showText())); - disconnect(m_showFormAction.data(), SIGNAL(triggered()), oldActiveDocument, SLOT(showForm())); -#endif // ENABLE_TEXT_VIEW - } - - if (newActiveDocument) { - connect(undoAction(), SIGNAL(triggered()), newActiveDocument, SLOT(undo())); - connect(redoAction(), SIGNAL(triggered()), newActiveDocument, SLOT(redo())); -#ifdef ENABLE_TEXT_VIEW - connect(m_showTextAction.data(), SIGNAL(triggered()), newActiveDocument, SLOT(showText())); - connect(m_showFormAction.data(), SIGNAL(triggered()), newActiveDocument, SLOT(showForm())); - if (m_showTextAction->isChecked()) - newActiveDocument->showText(); - else - newActiveDocument->showForm(); -#endif // ENABLE_TEXT_VIEW - } -} - -void MultipleDocumentsController::currentTabChanged(int newCurrentTab) -{ - DesignDocumentController* oldActiveDocument = 0; - if (!m_documentControllers.isEmpty()) { - oldActiveDocument = m_documentControllers.first().data(); - } - - if (newCurrentTab == -1) { - emit activeDocumentChanged(0); - if (oldActiveDocument && oldActiveDocument->previewVisible()) - emit previewVisibilityChanged(false); - if (oldActiveDocument && oldActiveDocument->previewWithDebugVisible()) - emit previewWithDebugVisibilityChanged(false); - - if (oldActiveDocument) - rewireDocumentActions(oldActiveDocument, 0); - } else { - DesignDocumentController* newActiveDocument = findActiveDocument(m_tabWidget->currentWidget()); - m_undoAction->setEnabled(newActiveDocument->isUndoAvailable()); - m_redoAction->setEnabled(newActiveDocument->isRedoAvailable()); - - rewireDocumentActions(oldActiveDocument, newActiveDocument); - - m_documentControllers.removeOne(newActiveDocument); - m_documentControllers.prepend(newActiveDocument); - emit activeDocumentChanged(newActiveDocument); - if (oldActiveDocument && oldActiveDocument->previewVisible()) - emit previewVisibilityChanged(newActiveDocument->previewVisible()); - if (oldActiveDocument && oldActiveDocument->previewWithDebugVisible()) - emit previewWithDebugVisibilityChanged(newActiveDocument->previewWithDebugVisible()); - } -} - -void MultipleDocumentsController::tabCloseRequested(int tabIndex) -{ - DesignDocumentController* controller = findActiveDocument(m_tabWidget->widget(tabIndex)); - - if (controller) - DocumentCloser::close(controller); -} - -void MultipleDocumentsController::documentDisplayNameChanged(const QString &/*fileName*/) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - documentDirtyStateChanged(documentController->isDirty()); -} - -void MultipleDocumentsController::documentDirtyStateChanged(bool newState) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - int tabIdx = m_tabWidget->indexOf(documentController->documentWidget()); - - if (newState) - m_tabWidget->setTabText(tabIdx, tr("* %1").arg(createTitle(documentController->displayName()))); - else - m_tabWidget->setTabText(tabIdx, createTitle(documentController->displayName())); -} - -void MultipleDocumentsController::documentUndoAvailable(bool isAvailable) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - if (m_documentControllers.first().data() == documentController) - m_undoAction->setEnabled(isAvailable); -} - -void MultipleDocumentsController::documentRedoAvailable(bool isAvailable) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - if (m_documentControllers.first().data() == documentController) - m_redoAction->setEnabled(isAvailable); -} - -void MultipleDocumentsController::documentPreviewVisibilityChanged(bool visible) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - if (m_documentControllers.first().data() == documentController) - emit previewVisibilityChanged(visible); -} - -void MultipleDocumentsController::documentPreviewWithDebugVisibilityChanged(bool visible) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - if (m_documentControllers.first().data() == documentController) - emit previewWithDebugVisibilityChanged(visible); -} - -void MultipleDocumentsController::open(DesignDocumentController* documentController) -{ - m_documentControllers.append(documentController); - - int newTabIndex = m_tabWidget->addTab(documentController->documentWidget(), createTitle(documentController->displayName())); - m_tabWidget->setCurrentIndex(newTabIndex); - - connect(documentController, SIGNAL(displayNameChanged(QString)), - this, SLOT(documentDisplayNameChanged(QString))); - connect(documentController, SIGNAL(dirtyStateChanged(bool)), - this, SLOT(documentDirtyStateChanged(bool))); - connect(documentController, SIGNAL(undoAvailable(bool)), - this, SLOT(documentUndoAvailable(bool))); - connect(documentController, SIGNAL(redoAvailable(bool)), - this, SLOT(documentRedoAvailable(bool))); - connect(documentController, SIGNAL(previewVisibilityChanged(bool)), - this, SLOT(documentPreviewVisibilityChanged(bool))); - connect(documentController, SIGNAL(previewWithDebugVisibilityChanged(bool)), - this, SLOT(documentPreviewWithDebugVisibilityChanged(bool))); - connect(documentController, SIGNAL(designDocumentClosed()), - this, SLOT(designDocumentClosed())); - connect(documentController, SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), - this, SLOT(designDocumentError(QList<RewriterView::Error>))); - - emit documentCountChanged(m_documentControllers.size()); -} - -void MultipleDocumentsController::designDocumentClosed() -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - rewireDocumentActions(documentController, 0); - - m_tabWidget->removeTab(m_tabWidget->indexOf(documentController->documentWidget())); - m_documentControllers.removeOne(documentController); - emit documentClosed(documentController); - emit documentCountChanged(m_documentControllers.size()); -} - -void MultipleDocumentsController::designDocumentError(const QList<RewriterView::Error> &error) -{ - DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - Q_ASSERT(documentController); - - if (error.isEmpty()) - return; - - QMessageBox msgBox(documentController->documentWidget()); - msgBox.setWindowFlags(Qt::Sheet | Qt::MSWindowsFixedSizeDialogHint); - msgBox.setWindowTitle("Invalid qml"); - msgBox.setText(error.first().toString()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); -} - -void MultipleDocumentsController::doSave() -{ - if (!m_documentControllers.isEmpty()) - m_documentControllers.first()->save(dynamic_cast<QWidget*>(parent())); -} - -void MultipleDocumentsController::doSaveAs() -{ - QWidget* parentWindow = dynamic_cast<QWidget*>(parent()); - - if (!m_documentControllers.isEmpty()) - m_documentControllers.first()->saveAs(parentWindow); -} - -void MultipleDocumentsController::doPreview(bool visible) -{ - if (m_documentControllers.isEmpty()) - return; - - m_documentControllers.first()->togglePreview(visible); -} - -void MultipleDocumentsController::doPreviewWithDebug(bool visible) -{ - if (m_documentControllers.isEmpty()) - return; - - m_documentControllers.first()->toggleWithDebugPreview(visible); -} - -void MultipleDocumentsController::doDelete() -{ - m_documentControllers.first()->deleteSelected(); -} - -void MultipleDocumentsController::doCopy() -{ - m_documentControllers.first()->copySelected(); -} - -void MultipleDocumentsController::doCut() -{ - m_documentControllers.first()->cutSelected(); -} - -void MultipleDocumentsController::doPaste() -{ - m_documentControllers.first()->paste(); -} - -void MultipleDocumentsController::closeAll(bool quitWhenAllEditorsClosed) -{ - DocumentCloser::close(m_documentControllers, quitWhenAllEditorsClosed); -} - -QAction* MultipleDocumentsController::undoAction() -{ - return m_undoAction.data(); -} - -QAction* MultipleDocumentsController::redoAction() -{ - return m_redoAction.data(); -} - -#ifdef ENABLE_TEXT_VIEW -QAction* MultipleDocumentsController::showFormAction(QMenu* parent) -{ - if (!m_showFormAction) { - m_showFormAction = new QAction(tr("&Form"), parent); - m_showFormAction->setShortcut(QKeySequence("Ctrl+Shift+F")); - m_showFormAction->setCheckable(true); - } - - return m_showFormAction.data(); -} -#endif // ENABLE_TEXT_VIEW - -#ifdef ENABLE_TEXT_VIEW -QAction* MultipleDocumentsController::showTextAction(QMenu* parent) -{ - if (!m_showTextAction) { - m_showTextAction = new QAction(tr("&Text"), parent); - m_showTextAction->setShortcut(QKeySequence("Ctrl+Shift+T")); - m_showTextAction->setCheckable(true); - } - - return m_showTextAction.data(); -} - -#endif // ENABLE_TEXT_VIEW - -} // namespace QmlDesigner - diff --git a/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.h b/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.h deleted file mode 100644 index 84cf48bf6569e220806417822c82de0d73e1589e..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/multipledocumentscontroller.h +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 MultipleDocumentsController_h -#define MultipleDocumentsController_h - -#include <rewriterview.h> - -#include <QWeakPointer> -#include <QtCore/QObject> -#include <QtCore/QList> -#include <QWeakPointer> - -#include <QtGui/QAction> -#include <QtGui/QMenu> -#include <QtGui/QTabWidget> -#include <QtGui/QUndoGroup> - -class QDeclarativeError; - -namespace QmlDesigner { - -class DesignDocumentController; - -class MultipleDocumentsController : public QObject -{ - Q_OBJECT - -public: - MultipleDocumentsController(QWidget* parent = 0); // a bit of a hack - ~MultipleDocumentsController(); - - QTabWidget* tabWidget() const; - - QAction* undoAction(); - QAction* redoAction(); -#ifdef ENABLE_TEXT_VIEW - QAction* showFormAction(QMenu* parent); - QAction* showTextAction(QMenu* parent); -#endif // ENABLE_TEXT_VIEW - void open(DesignDocumentController* documentController); - void closeAll(bool quitWhenAllEditorsClosed); - unsigned activeDocumentCount() const { return m_documentControllers.size(); } - -signals: - void activeDocumentChanged(DesignDocumentController* documentController); - void documentClosed(DesignDocumentController* documentController); - void documentCountChanged(unsigned newDocumentCount); - - void previewVisibilityChanged(bool); - void previewWithDebugVisibilityChanged(bool); - -public slots: - void doSave(); - void doSaveAs(); - void doPreview(bool visible); - void doPreviewWithDebug(bool visible); - void doDelete(); - void doCopy(); - void doCut(); - void doPaste(); - - void documentDisplayNameChanged(const QString &fileName); - void documentDirtyStateChanged(bool newState); - void documentUndoAvailable(bool isAvailable); - void documentRedoAvailable(bool isAvailable); - void documentPreviewVisibilityChanged(bool visible); - void documentPreviewWithDebugVisibilityChanged(bool visible); - -protected slots: - void currentTabChanged(int newCurrentTab); - void tabCloseRequested(int tabIndex); - void designDocumentClosed(); - void designDocumentError(const QList<RewriterView::Error> &errors); - -private: - DesignDocumentController* findActiveDocument(QWidget* documentWidget); - void rewireDocumentActions(DesignDocumentController* oldActiveDocument, DesignDocumentController* newActiveDocument); - -private: - QWeakPointer<QTabWidget> m_tabWidget; - QWeakPointer<QAction> m_undoAction; - QWeakPointer<QAction> m_redoAction; -#ifdef ENABLE_TEXT_VIEW - QWeakPointer<QAction> m_showTextAction; - QWeakPointer<QAction> m_showFormAction; -#endif // ENABLE_TEXT_VIEW - - QList<QWeakPointer<DesignDocumentController> > m_documentControllers; -}; - -} // namespace QmlDesigner - -#endif // MultipleDocumentsController_h diff --git a/src/plugins/qmldesigner/components/integration/navigatorcontroller.cpp b/src/plugins/qmldesigner/components/integration/navigatorcontroller.cpp deleted file mode 100644 index 131f2bd874a5cf6fe742ea81520e6e91c4d8750f..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/navigatorcontroller.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 <navigatorwidget.h> - -#include "designdocumentcontroller.h" -#include "navigatorcontroller.h" - -namespace QmlDesigner { - -NavigatorController::NavigatorController(QObject* parent): - StackedUtilityPanelController(parent) -{ - setObjectName("navigatorController"); - contentWidget()->setObjectName("navigatorStack"); -} - -QWidget* NavigatorController::stackedPageWidget(DesignDocumentController* designDocumentController) const -{ - if (designDocumentController) - return designDocumentController->navigator(); - else - return 0; -} - -} // namespace QmlDesigner - diff --git a/src/plugins/qmldesigner/components/integration/navigatorcontroller.h b/src/plugins/qmldesigner/components/integration/navigatorcontroller.h deleted file mode 100644 index d0bd17a7dba09bafe9c9c7623fc66f8305b163a0..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/navigatorcontroller.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 NAVIGATORCONTROLLER_H -#define NAVIGATORCONTROLLER_H - -#include "stackedutilitypanelcontroller.h" - -namespace QmlDesigner { - -class NavigatorController : public StackedUtilityPanelController -{ -public: - NavigatorController(QObject* parent = 0); - -protected: - class QWidget* stackedPageWidget(class DesignDocumentController* designDocumentController) const; -}; - -} // namespace QmlDesigner - -#endif // NAVIGATORCONTROLLER_H diff --git a/src/plugins/qmldesigner/components/integration/stateseditorcontroller.cpp b/src/plugins/qmldesigner/components/integration/stateseditorcontroller.cpp deleted file mode 100644 index 9a82c487f4037c48301462285088b31d273dc5ee..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/stateseditorcontroller.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 "designdocumentcontroller.h" -#include "stateseditorcontroller.h" - -namespace QmlDesigner { - -StatesEditorController::StatesEditorController(QObject* parent): - StackedUtilityPanelController(parent) -{ - setObjectName("StatesEditorController"); - contentWidget()->setObjectName("statesEditorStack"); -} - -QWidget* StatesEditorController::stackedPageWidget(DesignDocumentController* designDocumentController) const -{ - if (designDocumentController) - return designDocumentController->statesEditorWidget(); - else - return 0; -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/integration/stateseditorcontroller.h b/src/plugins/qmldesigner/components/integration/stateseditorcontroller.h deleted file mode 100644 index 32350b3c3118cb651fc37f2a1ea840f10f20707b..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/stateseditorcontroller.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 STATESEDITORCONTROLLER_H -#define STATESEDITORCONTROLLER_H - -#include "stackedutilitypanelcontroller.h" - -namespace QmlDesigner { - -class StatesEditorController : public StackedUtilityPanelController -{ -public: - StatesEditorController(QObject* parent = 0); - -protected: - class QWidget* stackedPageWidget(class DesignDocumentController* designDocumentController) const; -}; - -} // namespace QmlDesigner - -#endif // STATESEDITORCONTROLLER_H diff --git a/src/plugins/qmldesigner/components/integration/widgetboxcontroller.cpp b/src/plugins/qmldesigner/components/integration/widgetboxcontroller.cpp deleted file mode 100644 index 14f9c5cce28cfff9c46154084f8e76c9aec47348..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/widgetboxcontroller.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 <itemlibrary.h> - -#include "designdocumentcontroller.h" -#include "widgetboxcontroller.h" - -namespace QmlDesigner { - -ItemLibraryController::ItemLibraryController(QObject* parent): - StackedUtilityPanelController(parent) -{ - setObjectName("ItemLibraryController"); -} - -QWidget* ItemLibraryController::stackedPageWidget(DesignDocumentController* designDocumentController) const -{ - if (designDocumentController) - return designDocumentController->itemLibrary(); - else - return 0; -} - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/integration/widgetboxcontroller.h b/src/plugins/qmldesigner/components/integration/widgetboxcontroller.h deleted file mode 100644 index 1a452ce8c4720e2a865006e590ae765dc4b78c3d..0000000000000000000000000000000000000000 --- a/src/plugins/qmldesigner/components/integration/widgetboxcontroller.h +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 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 ItemLibraryCONTROLLER_H -#define ItemLibraryCONTROLLER_H - -#include "stackedutilitypanelcontroller.h" - -namespace QmlDesigner { - -class ItemLibraryController : public StackedUtilityPanelController -{ -public: - ItemLibraryController(QObject* parent = 0); - -protected: - class QWidget* stackedPageWidget(class DesignDocumentController* designDocumentController) const; -}; - -} // namespace QmlDesigner - -#endif // ItemLibraryCONTROLLER_H diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index 67b1141e6cdb62d8e21907ac57d67e9f3632a2d6..ba83b7ccac6e517d8b8022fb6cb0b20d95b36802 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -257,7 +257,7 @@ PropertyEditor::PropertyEditor(QWidget *parent) : file.open(QFile::ReadOnly); QString styleSheet = QLatin1String(file.readAll()); m_stackedWidget->setStyleSheet(styleSheet); - m_stackedWidget->setMinimumWidth(360); + m_stackedWidget->setMinimumWidth(300); m_collapseButton->raise(); m_collapseButton->show(); connect(m_collapseButton, SIGNAL(expand()), this, SLOT(expand())); @@ -465,7 +465,7 @@ void PropertyEditor::changeExpression(const QString &name) void PropertyEditor::expand() { - m_stackedWidget->setMinimumWidth(360); + m_stackedWidget->setMinimumWidth(300); m_stackedWidget->setMaximumWidth(1000); m_stackedWidget->parentWidget()->layout()->update(); @@ -475,6 +475,11 @@ void PropertyEditor::expand() while (parentWidget) { if (Core::SideBar *sideBar = qobject_cast<Core::SideBar*>(parentWidget)) { childWidget->setMaximumWidth(2000); + foreach (QObject* child, sideBar->children()) { + if (QWidget* otherWidget = qobject_cast<QWidget*>(child)) + if (otherWidget != childWidget && !qobject_cast<QComboBox*>(otherWidget)) + otherWidget->show(); + } QList<QComboBox*> list = sideBar->findChildren<QComboBox*>(); foreach (QComboBox* box, list) { if (qobject_cast<QToolBar*>(box->parentWidget())) @@ -502,10 +507,18 @@ void PropertyEditor::collapse() while (parentWidget) { if (Core::SideBar *sideBar = qobject_cast<Core::SideBar*>(parentWidget)) { childWidget->setMaximumWidth(22); + foreach (QObject* child, sideBar->children()) { + if (QWidget* otherWidget = qobject_cast<QWidget*>(child)) + if (otherWidget != childWidget && !qobject_cast<QComboBox*>(otherWidget)) + otherWidget->hide(); + } + QSplitter* parentSplitter = qobject_cast<QSplitter*>(sideBar->parentWidget()); - QList<int> s = sideBar->sizes(); + QList<int> s = parentSplitter->sizes(); + qDebug() << s; s.removeLast(); s.append(25); + qDebug() << s; parentSplitter->setSizes(s); parentSplitter->refresh(); parentSplitter->update(); @@ -574,7 +587,7 @@ void PropertyEditor::setQmlDir(const QString &qmlDir) void PropertyEditor::delayedResetView() { if (m_timerId == 0) - m_timerId = startTimer(500); + m_timerId = startTimer(200); } void PropertyEditor::timerEvent(QTimerEvent *timerEvent) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 1ce3eea3b9e6ad26eba2343247f6869d7f28ab2e..70aeb2ec95da0eab4325db5a1a7160c0a622f976 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -124,7 +124,8 @@ void PropertyEditorValue::setExpression(const QString &expression) bool PropertyEditorValue::isInSubState() const { - return modelNode().isValid() && QmlDesigner::QmlObjectNode(modelNode()).propertyAffectedByCurrentState(name()); + const QmlDesigner::QmlObjectNode objectNode(modelNode()); + return objectNode.isValid() && objectNode.propertyAffectedByCurrentState(name()); } bool PropertyEditorValue::isBound() const diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-bottom-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-bottom-normal.png index 147c052bf1db01f41904369e0c6a0b6ad32231dc..4564f8027ba9ebda664f5ff8b642f966c98bb833 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-bottom-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-bottom-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-bottom-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-bottom-pressed.png index 39f8a7e05080b0caba18e64ff57ef0f8d226dcbb..93e72ac72851d55eff8c38ec04f5dbfce0ea7e60 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-bottom-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-bottom-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-fill-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-fill-normal.png index d0b4286a779e7cb3346220ac409983462a660af5..677fe77db79f41d487d3932a1c2fd25e018e510c 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-fill-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-fill-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-fill-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-fill-pressed.png index de19b77854ce960661bef1c1c289fb75d03ea8ec..7fe7aedd2e1705166987cf9b9b0b8baba13d6ff8 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-fill-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-fill-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-normal.png index b6cdb388c3c02c323b62f2231c6242c05684047a..f5af7a23785f76176af6a0a784d0df3b17973bf6 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-pressed.png index 3dec4e3550ec43edb983d4acb902e5f03378d04e..7ea90d8bb4a5d6bf7ce09c6984832ef1fc5de7c4 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-horizontal-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-left-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-left-normal.png index 60c8eb72cb5a0278fcc0af455a571186f878af03..9fbb7647cfe4a1b1492c8129a1df9509f15805e1 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-left-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-left-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-left-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-left-pressed.png index 3b805dd96f6c28c1d55ba3a6752366e5cd8ecf40..aaf79f3c39c85c4757a118dac6cbd26c0b8c680b 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-left-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-left-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-right-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-right-normal.png index f3feba133079c7c8241174cf784238b19eb5e4ae..f65bbc4bc1981e4a49216e4cb3c0ea20af8de482 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-right-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-right-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-right-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-right-pressed.png index 541b04a1138f8e6b4f1faef569d109c59fd175dc..8ffd30c939d09dd7bdc42eb727d13e2a3ef1aadc 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-right-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-right-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-spacer.png b/src/plugins/qmldesigner/components/resources/images/anchor-spacer.png index 1010b8f03570be18f5dd1990725a4d5ac6b110b9..3d4ac0e1851815659d47e86a60fa699bcd65e363 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-spacer.png and b/src/plugins/qmldesigner/components/resources/images/anchor-spacer.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-top-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-top-normal.png index 705f7e20103111824dacd85e2b0ebca19eddd2fe..0c10b784d0a53cc0e8426c69f0b006cfc72f8b69 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-top-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-top-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-top-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-top-pressed.png index e2ae0cb67edaaf93a00c908beac3571848575206..b90b6d8287a4b7cc16cd0d93f7736d0ea6382b3f 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-top-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-top-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-vertical-normal.png b/src/plugins/qmldesigner/components/resources/images/anchor-vertical-normal.png index 20365cedae96c6f3185b89db967d46a3b785fdc7..b36fd7d0d36a4c0cea48c15e00e15f1131ddd49b 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-vertical-normal.png and b/src/plugins/qmldesigner/components/resources/images/anchor-vertical-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/anchor-vertical-pressed.png b/src/plugins/qmldesigner/components/resources/images/anchor-vertical-pressed.png index 87bb66e733b345ab865dbdef0aa4c575af55121d..d824ab1d8827fc4051f9749f2bb31d6f47beb0e8 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/anchor-vertical-pressed.png and b/src/plugins/qmldesigner/components/resources/images/anchor-vertical-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_checked.png b/src/plugins/qmldesigner/components/resources/images/checkbox_checked.png index da70623c24af80737ded77440944adfd0d66f586..91d7cd07de05babad26d4be11887b695bfa2d61c 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_checked.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_checked.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_checked_hover.png b/src/plugins/qmldesigner/components/resources/images/checkbox_checked_hover.png index 27172e9cf8ed04471610244fb7c32788de0aa5be..91d7cd07de05babad26d4be11887b695bfa2d61c 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_checked_hover.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_checked_hover.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_checked_pressed.png b/src/plugins/qmldesigner/components/resources/images/checkbox_checked_pressed.png index ea55f80f2f882c3f4a1cbbd48ad9aafe605d51de..183f80bbc178afa3082513bc596824a2fcf51f75 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_checked_pressed.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_checked_pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked.png b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked.png index 87003e5a23145f97d18fec587de6345a6e05108e..c9b6bcbe350dac013008d0aa07245b61aa7d8401 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_hover.png b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_hover.png index 118c5896beb3a14baaaf37e6f7a7bb1450b975e9..c9b6bcbe350dac013008d0aa07245b61aa7d8401 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_hover.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_hover.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_pressed.png b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_pressed.png index 670fc43ca778e861535a5b6c699412ae36fe8224..a65132bb16204a3b455e87ec9d5e2caef322e2f5 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_pressed.png and b/src/plugins/qmldesigner/components/resources/images/checkbox_unchecked_pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/combobox-normal.png b/src/plugins/qmldesigner/components/resources/images/combobox-normal.png new file mode 100644 index 0000000000000000000000000000000000000000..232f131f7f147eced6decf150f0272b25a5d5ed2 Binary files /dev/null and b/src/plugins/qmldesigner/components/resources/images/combobox-normal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/combobox-pressed.png b/src/plugins/qmldesigner/components/resources/images/combobox-pressed.png new file mode 100644 index 0000000000000000000000000000000000000000..3098889bf728d8d433106f35288238e7fbfcbaa9 Binary files /dev/null and b/src/plugins/qmldesigner/components/resources/images/combobox-pressed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/down_arrow.png b/src/plugins/qmldesigner/components/resources/images/down_arrow.png index 20f3aa243684927a6f26f7485340dedb0a2c2985..cc832f3261a570f0642d5f34238a4e4a76d25d40 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/down_arrow.png and b/src/plugins/qmldesigner/components/resources/images/down_arrow.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/eye_crossed.png b/src/plugins/qmldesigner/components/resources/images/eye_crossed.png index c8729ca200d5edd15f3cc7f16cd39159515ed08f..8c7ede732bb0a82d9637b443459abec30ff1cdf2 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/eye_crossed.png and b/src/plugins/qmldesigner/components/resources/images/eye_crossed.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/eye_open.png b/src/plugins/qmldesigner/components/resources/images/eye_open.png index 79dc3b2184fdbf90db7941719eec76892732ec8b..133378a8e7dd3a82296c0fd4b2093efce0e26972 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/eye_open.png and b/src/plugins/qmldesigner/components/resources/images/eye_open.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-bottom.png b/src/plugins/qmldesigner/components/resources/images/icon-bottom.png index 71f2965c9dedb47d87157c88a4f2556f462fff76..51955a197f0284af67b2f10ffb6550a7e5fa9900 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-bottom.png and b/src/plugins/qmldesigner/components/resources/images/icon-bottom.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-horizontal.png b/src/plugins/qmldesigner/components/resources/images/icon-horizontal.png index b55afb662d49a2e2fb36f19383f8beb761e8e095..f1225ebee46430e2fc82a8a8663056eae87ce1ea 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-horizontal.png and b/src/plugins/qmldesigner/components/resources/images/icon-horizontal.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-left.png b/src/plugins/qmldesigner/components/resources/images/icon-left.png index 743da4ac67f72b9f5697110a1fd57b9a6bc0d54a..3c18792f7d52d27496d140a525f8b3399501a35b 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-left.png and b/src/plugins/qmldesigner/components/resources/images/icon-left.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-right.png b/src/plugins/qmldesigner/components/resources/images/icon-right.png index a9b119d4197272cf8c31f3b514dd9eb9dc1d58f1..37cc31910c24f06743c4c6b2338f61cfdd9945b5 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-right.png and b/src/plugins/qmldesigner/components/resources/images/icon-right.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-top.png b/src/plugins/qmldesigner/components/resources/images/icon-top.png index f18f6f789dacc5c6dfc3570932db2eaaac19fbc1..68421538eee7b83d25c75f854b0103f62dfaf310 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-top.png and b/src/plugins/qmldesigner/components/resources/images/icon-top.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/icon-vertical.png b/src/plugins/qmldesigner/components/resources/images/icon-vertical.png index b76d51771488072b443c268c46d986f09ae03186..f705e15ea7e7df5f7951956911ee070a26c2ea7e 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/icon-vertical.png and b/src/plugins/qmldesigner/components/resources/images/icon-vertical.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/lock.png b/src/plugins/qmldesigner/components/resources/images/lock.png index de043938133a98706b58e9df09c83ecaec0a290a..8f1b546c8dce785e0390754c93365e4ecede80d6 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/lock.png and b/src/plugins/qmldesigner/components/resources/images/lock.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/slider_indikator.png b/src/plugins/qmldesigner/components/resources/images/slider_indikator.png new file mode 100644 index 0000000000000000000000000000000000000000..1d0ef69c6ef5a635c5634babd2e41576e5eff4c7 Binary files /dev/null and b/src/plugins/qmldesigner/components/resources/images/slider_indikator.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/slider_line.png b/src/plugins/qmldesigner/components/resources/images/slider_line.png new file mode 100644 index 0000000000000000000000000000000000000000..f7c0cb1246677939d218a01f197489e0bb2d3cb1 Binary files /dev/null and b/src/plugins/qmldesigner/components/resources/images/slider_line.png differ diff --git a/src/plugins/qmldesigner/components/resources/images/up_arrow.png b/src/plugins/qmldesigner/components/resources/images/up_arrow.png index 048b2fd2ff9caf1bc3e5cca0460d99e3bbffc2a8..94161f3ce4f4ffff2620d805556dabe6cf11e814 100644 Binary files a/src/plugins/qmldesigner/components/resources/images/up_arrow.png and b/src/plugins/qmldesigner/components/resources/images/up_arrow.png differ diff --git a/src/plugins/qmldesigner/components/resources/resources.qrc b/src/plugins/qmldesigner/components/resources/resources.qrc index f3916f8127e2b8038a701322bdfdbb22e483fd37..926de01f7f60a45675038337ef4a91df493fc99d 100644 --- a/src/plugins/qmldesigner/components/resources/resources.qrc +++ b/src/plugins/qmldesigner/components/resources/resources.qrc @@ -87,5 +87,9 @@ <file>images/collapse-button-normal.png</file> <file>images/collapse-button-hover-mirrored.png</file> <file>images/collapse-button-normal-mirrored.png</file> + <file>images/combobox-normal.png</file> + <file>images/combobox-pressed.png</file> + <file>images/slider_indikator.png</file> + <file>images/slider_line.png</file> </qresource> </RCC> diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index ba162be4fa0abeb5b3755d1686634dd389469fba..ae25fb86d172f72b52affc1880805fb1b67ca455 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -49,7 +49,8 @@ namespace Internal { */ StatesEditorView::StatesEditorView(StatesEditorModel *editorModel, QObject *parent) : QmlModelView(parent), - m_editorModel(editorModel) + m_editorModel(editorModel), + m_attachedToModel(false) { Q_ASSERT(m_editorModel); } @@ -79,7 +80,9 @@ void StatesEditorView::setCurrentState(int index) if (m_modelStates.isEmpty()) return; - Q_ASSERT(index >= 0 && index < m_modelStates.count()); + Q_ASSERT(index < m_modelStates.count()); + if (index == -1) + return; if (m_modelStates.indexOf(currentState()) == index) return; @@ -174,17 +177,19 @@ void StatesEditorView::modelAttached(Model *model) return; m_modelStates.insert(0, baseState()); + m_attachedToModel = true; m_editorModel->insertState(0, baseState().name()); // Add custom states m_stateRootNode = QmlItemNode(rootModelNode()); if (!m_stateRootNode.isValid()) - return; + return; for (int i = 0; i < m_stateRootNode.states().allStates().size(); ++i) { QmlModelState state = QmlItemNode(rootModelNode()).states().allStates().at(i); insertModelState(i, state); } + } void StatesEditorView::modelAboutToBeDetached(Model *model) @@ -192,6 +197,8 @@ void StatesEditorView::modelAboutToBeDetached(Model *model) if (debug) qDebug() << __FUNCTION__; + m_attachedToModel = false; + clearModelStates(); QmlModelView::modelAboutToBeDetached(model); @@ -390,6 +397,9 @@ QPixmap StatesEditorView::renderState(int i) if (debug) qDebug() << __FUNCTION__ << i; + if (!m_attachedToModel) + return QPixmap(); + Q_ASSERT(i >= 0 && i < m_modelStates.size()); nodeInstanceView()->setBlockChangeSignal(true); QmlModelState oldState = currentState(); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 003035078f1323c25e92af84b2aeac58ecf25c6b..44bc5b6ac6330d7252f9c5058fb2871e62595ec5 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -53,6 +53,7 @@ public: QPixmap renderState(int i); QmlItemNode stateRootNode() { return m_stateRootNode; } + bool isAttachedToModel() const { return m_attachedToModel; } protected: // AbstractView @@ -95,6 +96,7 @@ private: QList<int> m_updateTimerIdList; QmlModelState m_oldRewriterAmendState; + bool m_attachedToModel; }; } // namespace Internal diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index b4af32522366433fd91798037941b4f748bc859d..faeb4fd21b4c3d2a11f1f93bac208a5822893a16 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -115,7 +115,8 @@ bool StatesEditorWidgetPrivate::validStateName(const QString &name) const void StatesEditorWidgetPrivate::currentStateChanged() { - statesEditorView->setCurrentState(currentIndex()); + if (statesEditorView->isAttachedToModel()) + statesEditorView->setCurrentState(currentIndex()); } void StatesEditorWidgetPrivate::addState() diff --git a/src/plugins/qmldesigner/core/model/qmlmodelview.cpp b/src/plugins/qmldesigner/core/model/qmlmodelview.cpp index 708fe73da119f20cc17d3f6985a8c926b0ca924a..198109c9fa41c1e5dc1670501b0522ed0211fa88 100644 --- a/src/plugins/qmldesigner/core/model/qmlmodelview.cpp +++ b/src/plugins/qmldesigner/core/model/qmlmodelview.cpp @@ -300,9 +300,10 @@ void QmlModelView::activateState(const QmlModelState &state) QmlModelState oldState = m_state; NodeInstance newStateInstance = instanceForModelNode(state.modelNode()); - NodeInstance oldStateInstance = instanceForModelNode(oldState.modelNode()); + NodeInstance oldStateInstance = oldState.isValid() ? instanceForModelNode(oldState.modelNode()) : NodeInstance(); if (state.isBaseState()) { - oldStateInstance.deactivateState(); + if (oldStateInstance.isValid()) + oldStateInstance.deactivateState(); } else { newStateInstance.activateState(); } diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 499095bf102f659aee3249a9c335486493bfa636..ba77b5c57866ea28becef8cbdd7e882b25c83ceb 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -32,6 +32,7 @@ #include <model.h> #include <rewriterview.h> +#include <formeditorwidget.h> #include <coreplugin/icore.h> #include <coreplugin/minisplitter.h> @@ -41,6 +42,8 @@ #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/modemanager.h> #include <coreplugin/editortoolbar.h> +#include <coreplugin/inavigationwidgetfactory.h> +#include <extensionsystem/pluginmanager.h> #include <utils/parameteraction.h> #include <utils/qtcassert.h> @@ -57,6 +60,7 @@ #include <QtGui/QMenu> #include <QtGui/QClipboard> #include <QtGui/QLabel> +#include <QtGui/QProgressDialog> using Core::MiniSplitter; using Core::IEditor; @@ -73,11 +77,11 @@ enum { namespace QmlDesigner { namespace Internal { -DocumentWarningWidget::DocumentWarningWidget(DocumentWidget *documentWidget, QWidget *parent) : +DocumentWarningWidget::DocumentWarningWidget(DesignModeWidget *parent) : QFrame(parent), m_errorMessage(new QLabel("Placeholder", this)), m_goToError(new QLabel(this)), - m_documentWidget(documentWidget) + m_designModeWidget(parent) { setFrameStyle(QFrame::Panel | QFrame::Raised); setLineWidth(1); @@ -108,264 +112,20 @@ void DocumentWarningWidget::setError(const RewriterView::Error &error) void DocumentWarningWidget::goToError() { - m_documentWidget->textEditor()->gotoLine(m_error.line(), m_error.column()); + m_designModeWidget->textEditor()->gotoLine(m_error.line(), m_error.column()); Core::EditorManager::instance()->ensureEditorManagerVisible(); } -DocumentWidget::DocumentWidget(TextEditor::ITextEditor *textEditor, QPlainTextEdit *textEdit, QmlDesigner::DesignDocumentController *document, DesignModeWidget *mainWidget) : - QWidget(), - m_textEditor(textEditor), - m_textBuffer(textEdit), - m_document(document), - m_mainWidget(mainWidget), - m_mainSplitter(0), - m_leftSideBar(0), - m_rightSideBar(0), - m_designToolBar(new QToolBar), - m_fakeToolBar(Core::EditorManager::createToolBar(this)), - m_isDisabled(false), - m_warningWidget(0) -{ - setup(); -} - -DocumentWidget::~DocumentWidget() -{ - // Make sure component widgets are deleted first in SideBarItem::~SideBarItem - // before the DesignDocumentController runs (and deletes them again). - m_document->deleteLater(); -} - -QmlDesigner::DesignDocumentController *DocumentWidget::document() const -{ - return m_document; -} - -TextEditor::ITextEditor *DocumentWidget::textEditor() const -{ - return m_textEditor; -} - -void DocumentWidget::setAutoSynchronization(bool sync) -{ - if (debug) - qDebug() << Q_FUNC_INFO << sync; - - document()->blockModelSync(!sync); - - if (sync) { - // text editor -> visual editor - if (!document()->model()) { - document()->loadMaster(m_textBuffer.data()); - } - - QList<RewriterView::Error> errors = document()->qmlErrors(); - if (errors.isEmpty()) { - // set selection to text cursor - RewriterView *rewriter = document()->rewriterView(); - const int cursorPos = m_textBuffer->textCursor().position(); - ModelNode node = nodeForPosition(cursorPos); - if (node.isValid()) { - rewriter->setSelectedModelNodes(QList<ModelNode>() << node); - } - enable(); - } else { - disable(errors); - } - - connect(document(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), - this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); - - } else { - if (document()->model() && document()->qmlErrors().isEmpty()) { - RewriterView *rewriter = document()->rewriterView(); - // visual editor -> text editor - ModelNode selectedNode; - if (!rewriter->selectedModelNodes().isEmpty()) - selectedNode = rewriter->selectedModelNodes().first(); - - if (selectedNode.isValid()) { - const int nodeOffset = rewriter->nodeOffset(selectedNode); - if (nodeOffset > 0) { - const ModelNode currentSelectedNode - = nodeForPosition(m_textBuffer->textCursor().position()); - if (currentSelectedNode != selectedNode) { - int line, column; - textEditor()->convertPosition(nodeOffset, &line, &column); - textEditor()->gotoLine(line, column); - } - } - } - } - - disconnect(document(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), - this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); - } -} - -void DocumentWidget::enable() -{ - if (debug) - qDebug() << Q_FUNC_INFO; - m_warningWidget->setVisible(false); - m_document->documentWidget()->setEnabled(true); - m_document->statesEditorWidget()->setEnabled(true); - m_leftSideBar->setEnabled(true); - m_rightSideBar->setEnabled(true); - m_isDisabled = false; -} - -void DocumentWidget::disable(const QList<RewriterView::Error> &errors) -{ - if (debug) - qDebug() << Q_FUNC_INFO; - Q_ASSERT(!errors.isEmpty()); - m_warningWidget->setError(errors.first()); - m_warningWidget->setVisible(true); - m_document->documentWidget()->setEnabled(false); - m_document->statesEditorWidget()->setEnabled(false); - m_leftSideBar->setEnabled(false); - m_rightSideBar->setEnabled(false); - m_isDisabled = true; -} - -void DocumentWidget::updateErrorStatus(const QList<RewriterView::Error> &errors) -{ - if (debug) - qDebug() << Q_FUNC_INFO << errors.count(); - - if (m_isDisabled && errors.isEmpty()) { - enable(); - } else if (!errors.isEmpty()) { - disable(errors); - } -} - -void DocumentWidget::readSettings() -{ - QSettings *settings = Core::ICore::instance()->settings(); - - settings->beginGroup("Bauhaus"); - m_leftSideBar->readSettings(settings, QLatin1String("LeftSideBar")); - m_rightSideBar->readSettings(settings, QLatin1String("RightSideBar")); - if (settings->contains("MainSplitter")) { - const QByteArray splitterState = settings->value("MainSplitter").toByteArray(); - m_mainSplitter->restoreState(splitterState); - } - settings->endGroup(); -} - -void DocumentWidget::saveSettings() -{ - QSettings *settings = Core::ICore::instance()->settings(); - - settings->beginGroup("Bauhaus"); - m_leftSideBar->saveSettings(settings, QLatin1String("LeftSideBar")); - m_rightSideBar->saveSettings(settings, QLatin1String("RightSideBar")); - settings->setValue("MainSplitter", m_mainSplitter->saveState()); - settings->endGroup(); -} - - -void DocumentWidget::resizeEvent(QResizeEvent *event) -{ - m_warningWidget->move(QPoint(event->size().width() / 2, - event->size().height() / 2)); - QWidget::resizeEvent(event); -} - -void DocumentWidget::setup() -{ - m_mainSplitter = new MiniSplitter(this); - m_mainSplitter->setObjectName("mainSplitter"); - - // warning frame should be not in layout, but still child of the widget - m_warningWidget = new DocumentWarningWidget(this, this); - m_warningWidget->setVisible(false); - - // Left area: - Core::SideBarItem *navigatorItem = new Core::SideBarItem(m_document->navigator()); - Core::SideBarItem *libraryItem = new Core::SideBarItem(m_document->itemLibrary()); - Core::SideBarItem *propertiesItem = new Core::SideBarItem(m_document->allPropertiesBox()); - - QList<Core::SideBarItem*> leftSideBarItems, rightSideBarItems; - leftSideBarItems << navigatorItem << libraryItem; - rightSideBarItems << propertiesItem; - - m_leftSideBar = new Core::SideBar(leftSideBarItems, QList<Core::SideBarItem*>() << navigatorItem << libraryItem); - m_rightSideBar = new Core::SideBar(rightSideBarItems, QList<Core::SideBarItem*>() << propertiesItem); - - m_designToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); - - m_fakeToolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone); - m_fakeToolBar->addEditor(textEditor()); - m_fakeToolBar->addCenterToolBar(m_designToolBar); - m_fakeToolBar->setNavigationVisible(false); - - // right area: - QWidget *centerWidget = new QWidget; - { - QVBoxLayout *rightLayout = new QVBoxLayout(centerWidget); - rightLayout->setMargin(0); - rightLayout->setSpacing(0); - rightLayout->addWidget(m_fakeToolBar); - rightLayout->addWidget(m_document->statesEditorWidget()); - rightLayout->addWidget(m_document->documentWidget()); - } - - // m_mainSplitter area: - m_mainSplitter->addWidget(m_leftSideBar); - m_mainSplitter->addWidget(centerWidget); - m_mainSplitter->addWidget(m_rightSideBar); - - // Finishing touches: - m_mainSplitter->setOpaqueResize(false); - m_mainSplitter->setStretchFactor(1, 1); - m_mainSplitter->setSizes(QList<int>() << 150 << 300 << 150); - - QLayout *mainLayout = new QBoxLayout(QBoxLayout::RightToLeft, this); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_mainSplitter); -} - -bool DocumentWidget::isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const { - return (nodeOffset <= cursorPos) && (nodeOffset + nodeLength > cursorPos); -} - -ModelNode DocumentWidget::nodeForPosition(int cursorPos) const -{ - RewriterView *rewriter = m_document->rewriterView(); - QList<ModelNode> nodes = rewriter->allModelNodes(); - - ModelNode bestNode; - int bestNodeOffset = -1; - - foreach (const ModelNode &node, nodes) { - const int nodeOffset = rewriter->nodeOffset(node); - const int nodeLength = rewriter->nodeLength(node); - if (isInNodeDefinition(nodeOffset, nodeLength, cursorPos) - && (nodeOffset > bestNodeOffset)) { - bestNode = node; - bestNodeOffset = nodeOffset; - } - } - - return bestNode; -} - // ---------- DesignModeWidget DesignModeWidget::DesignModeWidget(QWidget *parent) : QWidget(parent), - m_documentWidgetStack(new QStackedWidget), - m_currentDocumentWidget(0), - m_currentTextEdit(0), - m_syncWithTextEdit(false) + m_syncWithTextEdit(false), + m_mainSplitter(0), + m_leftSideBar(0), + m_rightSideBar(0), + m_setup(false), + m_warningWidget(0) { - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->addWidget(m_documentWidgetStack); - m_undoAction = new QAction(tr("&Undo"), this); connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); m_redoAction = new QAction(tr("&Redo"), this); @@ -380,11 +140,6 @@ DesignModeWidget::DesignModeWidget(QWidget *parent) : connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(paste())); m_selectAllAction = new Utils::ParameterAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); connect(m_selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll())); - - QLabel *defaultBackground = new QLabel(tr("Loading ...")); - defaultBackground->setAlignment(Qt::AlignCenter); - - m_documentWidgetStack->addWidget(defaultBackground); } DesignModeWidget::~DesignModeWidget() @@ -393,6 +148,9 @@ DesignModeWidget::~DesignModeWidget() void DesignModeWidget::showEditor(Core::IEditor *editor) { + show(); + setup(); + QString fileName; QPlainTextEdit *textEdit = 0; TextEditor::ITextEditor *textEditor = 0; @@ -401,49 +159,52 @@ void DesignModeWidget::showEditor(Core::IEditor *editor) fileName = editor->file()->fileName(); textEdit = qobject_cast<QPlainTextEdit*>(editor->widget()); textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); + m_fakeToolBar->addEditor(textEditor); } if (debug) qDebug() << Q_FUNC_INFO << fileName; - m_currentTextEdit = textEdit; - DocumentWidget *documentWidget = 0; + if (textEdit) + m_currentTextEdit = textEdit; + + if (textEditor) + m_textEditor = textEditor; + DesignDocumentController *document = 0; if (textEdit && textEditor && fileName.endsWith(QLatin1String(".qml"))) { if (m_documentHash.contains(textEdit)) { - documentWidget = m_documentHash.value(textEdit); + document = m_documentHash.value(textEdit).data(); } else { - DesignDocumentController *newDocument = new DesignDocumentController(0); + DesignDocumentController *newDocument = new DesignDocumentController(this); + + newDocument->setAllPropertiesBox(m_allPropertiesBox.data()); + newDocument->setNavigator(m_navigator.data()); + newDocument->setStatesEditorWidget(m_statesEditorWidget.data()); + newDocument->setItemLibrary(m_itemLibrary.data()); + newDocument->setFormEditorView(m_formEditorView.data()); + newDocument->setFileName(fileName); - documentWidget = new DocumentWidget(textEditor, textEdit, newDocument, this); - connect(documentWidget->document(), SIGNAL(undoAvailable(bool)), - this, SLOT(undoAvailable(bool))); - connect(documentWidget->document(), SIGNAL(redoAvailable(bool)), - this, SLOT(redoAvailable(bool))); -// connect(documentWidget->document(), SIGNAL(deleteAvailable(bool)), -// this, SLOT(deleteAvailable(bool))); + document = newDocument; - m_documentHash.insert(textEdit, documentWidget); - m_documentWidgetStack->addWidget(documentWidget); + m_documentHash.insert(textEdit, document); } } - - setCurrentDocumentWidget(documentWidget); + setCurrentDocument(document); } void DesignModeWidget::closeEditors(QList<Core::IEditor*> editors) { foreach (Core::IEditor* editor, editors) { if (QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit*>(editor->widget())) { - if (m_currentTextEdit == textEdit) { - setCurrentDocumentWidget(0); + if (m_currentTextEdit.data() == textEdit) { + setCurrentDocument(0); } if (m_documentHash.contains(textEdit)) { if (debug) qDebug() << Q_FUNC_INFO << editor->file()->fileName(); - DocumentWidget *document = m_documentHash.take(textEdit); - m_documentWidgetStack->removeWidget(document); + DesignDocumentController *document = m_documentHash.take(textEdit).data(); delete document; } } @@ -485,53 +246,82 @@ QAction *DesignModeWidget::selectAllAction() const return m_selectAllAction; } +void DesignModeWidget::readSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup("Bauhaus"); + m_leftSideBar->readSettings(settings, QLatin1String("LeftSideBar")); + m_rightSideBar->readSettings(settings, QLatin1String("RightSideBar")); + if (settings->contains("MainSplitter")) { + const QByteArray splitterState = settings->value("MainSplitter").toByteArray(); + m_mainSplitter->restoreState(splitterState); + } + settings->endGroup(); +} + +void DesignModeWidget::saveSettings() +{ + QSettings *settings = Core::ICore::instance()->settings(); + + settings->beginGroup("Bauhaus"); + m_leftSideBar->saveSettings(settings, QLatin1String("LeftSideBar")); + m_rightSideBar->saveSettings(settings, QLatin1String("RightSideBar")); + settings->setValue("MainSplitter", m_mainSplitter->saveState()); + settings->endGroup(); +} + void DesignModeWidget::undo() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->undo(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->undo(); } void DesignModeWidget::redo() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->redo(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->redo(); } void DesignModeWidget::deleteSelected() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->deleteSelected(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->deleteSelected(); } void DesignModeWidget::cutSelected() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->cutSelected(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->cutSelected(); } void DesignModeWidget::copySelected() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->copySelected(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->copySelected(); } void DesignModeWidget::paste() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->paste(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->paste(); } void DesignModeWidget::selectAll() { - if (m_currentDocumentWidget) - m_currentDocumentWidget->document()->selectAll(); + if (m_currentDesignDocumentController) + m_currentDesignDocumentController->selectAll(); +} + +void DesignModeWidget::closeCurrentEditor() +{ } void DesignModeWidget::undoAvailable(bool isAvailable) { DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - if (m_currentDocumentWidget && - m_currentDocumentWidget->document() == documentController) { + if (m_currentDesignDocumentController && + m_currentDesignDocumentController.data() == documentController) { m_undoAction->setEnabled(isAvailable); } } @@ -539,44 +329,333 @@ void DesignModeWidget::undoAvailable(bool isAvailable) void DesignModeWidget::redoAvailable(bool isAvailable) { DesignDocumentController *documentController = qobject_cast<DesignDocumentController*>(sender()); - if (m_currentDocumentWidget && - m_currentDocumentWidget->document() == documentController) { + if (m_currentDesignDocumentController && + m_currentDesignDocumentController.data() == documentController) { m_redoAction->setEnabled(isAvailable); } } -void DesignModeWidget::setCurrentDocumentWidget(DocumentWidget *newDocumentWidget) + +void DesignModeWidget::enable() +{ + if (debug) + qDebug() << Q_FUNC_INFO; + m_warningWidget->setVisible(false); + m_formEditorView->widget()->setEnabled(true); + m_statesEditorWidget->setEnabled(true); + m_leftSideBar->setEnabled(true); + m_rightSideBar->setEnabled(true); + m_isDisabled = false; +} + +void DesignModeWidget::disable(const QList<RewriterView::Error> &errors) +{ + if (debug) + qDebug() << Q_FUNC_INFO; + Q_ASSERT(!errors.isEmpty()); + m_warningWidget->setError(errors.first()); + m_warningWidget->setVisible(true); + m_warningWidget->move(width() / 2, height() / 2); + m_formEditorView->widget()->setEnabled(false); + m_statesEditorWidget->setEnabled(false); + m_leftSideBar->setEnabled(false); + m_rightSideBar->setEnabled(false); + m_isDisabled = true; +} + +void DesignModeWidget::updateErrorStatus(const QList<RewriterView::Error> &errors) +{ + if (debug) + qDebug() << Q_FUNC_INFO << errors.count(); + + if (m_isDisabled && errors.isEmpty()) { + enable(); + } else if (!errors.isEmpty()) { + disable(errors); + } +} + +void DesignModeWidget::setAutoSynchronization(bool sync) { if (debug) - qDebug() << Q_FUNC_INFO << newDocumentWidget; + qDebug() << Q_FUNC_INFO << sync; + + m_currentDesignDocumentController->blockModelSync(!sync); - if (m_currentDocumentWidget == newDocumentWidget) + if (sync) { + // text editor -> visual editor + if (!m_currentDesignDocumentController->model()) { + m_currentDesignDocumentController->loadMaster(m_currentTextEdit.data()); + } else { + m_currentDesignDocumentController->loadCurrentModel(); + } + + QList<RewriterView::Error> errors = m_currentDesignDocumentController->qmlErrors(); + if (errors.isEmpty()) { + // set selection to text cursor + RewriterView *rewriter = m_currentDesignDocumentController->rewriterView(); + const int cursorPos = m_currentTextEdit->textCursor().position(); + ModelNode node = nodeForPosition(cursorPos); + if (node.isValid()) { + rewriter->setSelectedModelNodes(QList<ModelNode>() << node); + } + enable(); + } else { + disable(errors); + } + + connect(m_currentDesignDocumentController.data(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), + this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); + + } else { + if (m_currentDesignDocumentController->model() && m_currentDesignDocumentController->qmlErrors().isEmpty()) { + RewriterView *rewriter = m_currentDesignDocumentController->rewriterView(); + // visual editor -> text editor + ModelNode selectedNode; + if (!rewriter->selectedModelNodes().isEmpty()) + selectedNode = rewriter->selectedModelNodes().first(); + + if (selectedNode.isValid()) { + const int nodeOffset = rewriter->nodeOffset(selectedNode); + if (nodeOffset > 0) { + const ModelNode currentSelectedNode + = nodeForPosition(m_currentTextEdit->textCursor().position()); + if (currentSelectedNode != selectedNode) { + int line, column; + m_textEditor->convertPosition(nodeOffset, &line, &column); + m_textEditor->gotoLine(line, column); + } + } + } + } + + disconnect(m_currentDesignDocumentController.data(), SIGNAL(qmlErrorsChanged(QList<RewriterView::Error>)), + this, SLOT(updateErrorStatus(QList<RewriterView::Error>))); + } +} + +void DesignModeWidget::setCurrentDocument(DesignDocumentController *newDesignDocumentController) +{ + if (debug) + qDebug() << Q_FUNC_INFO << newDesignDocumentController; + + if (m_currentDesignDocumentController.data() == newDesignDocumentController) return; + if (m_currentDesignDocumentController) { + setAutoSynchronization(false); + saveSettings(); + } - if (m_currentDocumentWidget) { - m_currentDocumentWidget->setAutoSynchronization(false); - m_currentDocumentWidget->saveSettings(); + if (currentDesignDocumentController()) { + disconnect(currentDesignDocumentController(), SIGNAL(undoAvailable(bool)), + this, SLOT(undoAvailable(bool))); + disconnect(currentDesignDocumentController(), SIGNAL(redoAvailable(bool)), + this, SLOT(redoAvailable(bool))); + disconnect(currentDesignDocumentController(), SIGNAL(deleteAvailable(bool)), + this, SLOT(deleteAvailable(bool))); } - m_currentDocumentWidget = newDocumentWidget; + m_currentDesignDocumentController = newDesignDocumentController; + + connect(currentDesignDocumentController(), SIGNAL(undoAvailable(bool)), + this, SLOT(undoAvailable(bool))); + connect(currentDesignDocumentController(), SIGNAL(redoAvailable(bool)), + this, SLOT(redoAvailable(bool))); + + if (m_currentDesignDocumentController) { - if (m_currentDocumentWidget) { - m_currentDocumentWidget->setAutoSynchronization(true); - m_documentWidgetStack->setCurrentWidget(m_currentDocumentWidget); - m_currentDocumentWidget->readSettings(); - m_undoAction->setEnabled(m_currentDocumentWidget->document()->isUndoAvailable()); - m_redoAction->setEnabled(m_currentDocumentWidget->document()->isRedoAvailable()); + setAutoSynchronization(true); + m_undoAction->setEnabled(m_currentDesignDocumentController->isUndoAvailable()); + m_redoAction->setEnabled(m_currentDesignDocumentController->isRedoAvailable()); } else { - m_documentWidgetStack->setCurrentIndex(0); + //detach all views m_undoAction->setEnabled(false); m_redoAction->setEnabled(false); } } +void DesignModeWidget::setup() +{ + if (m_setup) + return; + m_setup = true; + + QList<Core::INavigationWidgetFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<Core::INavigationWidgetFactory>(); + + QWidget *openDocumentsWidget = 0; + QWidget *projectsExplorer = 0; + QWidget *fileSystemExplorer = 0; + + + foreach(Core::INavigationWidgetFactory *factory, factories) + { + Core::NavigationView navigationView; + navigationView.widget = 0; + if (factory->displayName() == QLatin1String("Projects")) { + navigationView = factory->createWidget(); + projectsExplorer = navigationView.widget; + projectsExplorer->setWindowTitle(tr("Projects")); + } + if (factory->displayName() == QLatin1String("File System")) { + navigationView = factory->createWidget(); + fileSystemExplorer = navigationView.widget; + fileSystemExplorer->setWindowTitle(tr("File System")); + } + if (factory->displayName() == QLatin1String("Open Documents")) { + navigationView = factory->createWidget(); + openDocumentsWidget = navigationView.widget; + openDocumentsWidget->setWindowTitle(tr("Open Documents")); + } + + if (navigationView.widget) + { + QFile file(":/qmldesigner/stylesheet.css"); + file.open(QFile::ReadOnly); + QFile file2(":/qmldesigner/scrollbar.css"); + file2.open(QFile::ReadOnly); + + QString labelStyle = QLatin1String("QLabel { background-color: #707070; }"); + + QString styleSheet = file.readAll() + file2.readAll() + labelStyle; + navigationView.widget->setStyleSheet(styleSheet); + } + } + + m_navigator = new NavigatorView(this); + + m_allPropertiesBox = new AllPropertiesBox(this); + m_statesEditorWidget = new StatesEditorWidget(this); + + m_formEditorView = new FormEditorView(this); + + m_itemLibrary = new ItemLibrary(this); + + m_designToolBar = new QToolBar; + m_fakeToolBar = Core::EditorManager::createToolBar(this); + + + m_mainSplitter = new MiniSplitter(this); + m_mainSplitter->setObjectName("mainSplitter"); + + // warning frame should be not in layout, but still child of the widget + m_warningWidget = new DocumentWarningWidget(this); + m_warningWidget->setVisible(false); + + // Left area: + + Core::SideBarItem *navigatorItem = new Core::SideBarItem(m_navigator->widget()); + Core::SideBarItem *libraryItem = new Core::SideBarItem(m_itemLibrary.data()); + Core::SideBarItem *propertiesItem = new Core::SideBarItem(m_allPropertiesBox.data()); + + + QList<Core::SideBarItem*> leftSideBarItems, rightSideBarItems; + leftSideBarItems << navigatorItem << libraryItem; + rightSideBarItems << propertiesItem; + + if (projectsExplorer) { + Core::SideBarItem *projectExplorerItem = new Core::SideBarItem(projectsExplorer); + rightSideBarItems << projectExplorerItem; + } + + if (fileSystemExplorer) { + Core::SideBarItem *fileSystemExplorerItem = new Core::SideBarItem(fileSystemExplorer); + rightSideBarItems << fileSystemExplorerItem; + } + + if (openDocumentsWidget) { + Core::SideBarItem *openDocumentsItem = new Core::SideBarItem(openDocumentsWidget); + rightSideBarItems << openDocumentsItem; + } + + m_leftSideBar = new Core::SideBar(leftSideBarItems, QList<Core::SideBarItem*>() << navigatorItem << libraryItem); + m_rightSideBar = new Core::SideBar(rightSideBarItems, QList<Core::SideBarItem*>() << propertiesItem); + + m_designToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); + + m_fakeToolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone); + //m_fakeToolBar->addEditor(textEditor()); ### what does this mean? + m_fakeToolBar->addCenterToolBar(m_designToolBar); + m_fakeToolBar->setNavigationVisible(false); + + connect(m_fakeToolBar, SIGNAL(closeClicked()), this, SLOT(closeCurrentEditor())); + + // right area: + QWidget *centerWidget = new QWidget; + { + QVBoxLayout *rightLayout = new QVBoxLayout(centerWidget); + rightLayout->setMargin(0); + rightLayout->setSpacing(0); + rightLayout->addWidget(m_fakeToolBar); + //### we now own these here + rightLayout->addWidget(m_statesEditorWidget.data()); + rightLayout->addWidget(m_formEditorView->widget()); + } + + // m_mainSplitter area: + m_mainSplitter->addWidget(m_leftSideBar); + m_mainSplitter->addWidget(centerWidget); + m_mainSplitter->addWidget(m_rightSideBar); + + // Finishing touches: + m_mainSplitter->setOpaqueResize(false); + m_mainSplitter->setStretchFactor(1, 1); + m_mainSplitter->setSizes(QList<int>() << 150 << 300 << 150); + + QLayout *mainLayout = new QBoxLayout(QBoxLayout::RightToLeft, this); + mainLayout->setMargin(0); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_mainSplitter); + + m_warningWidget->setVisible(false); + m_statesEditorWidget->setEnabled(true); + m_leftSideBar->setEnabled(true); + m_rightSideBar->setEnabled(true); + + readSettings(); + + show(); + QApplication::processEvents(); +} + +void DesignModeWidget::resizeEvent(QResizeEvent *event) +{ + if (m_warningWidget) + m_warningWidget->move(QPoint(event->size().width() / 2, event->size().height() / 2)); + QWidget::resizeEvent(event); +} + + +bool DesignModeWidget::isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const { + return (nodeOffset <= cursorPos) && (nodeOffset + nodeLength > cursorPos); +} + + +ModelNode DesignModeWidget::nodeForPosition(int cursorPos) const +{ + RewriterView *rewriter = m_currentDesignDocumentController->rewriterView(); + QList<ModelNode> nodes = rewriter->allModelNodes(); + + ModelNode bestNode; + int bestNodeOffset = -1; + + foreach (const ModelNode &node, nodes) { + const int nodeOffset = rewriter->nodeOffset(node); + const int nodeLength = rewriter->nodeLength(node); + if (isInNodeDefinition(nodeOffset, nodeLength, cursorPos) + && (nodeOffset > bestNodeOffset)) { + bestNode = node; + bestNodeOffset = nodeOffset; + } + } + + return bestNode; +} + + QString DesignModeWidget::contextHelpId() const { - if (m_currentDocumentWidget) - return m_currentDocumentWidget->document()->contextHelpId(); + if (m_currentDesignDocumentController) + return m_currentDesignDocumentController->contextHelpId(); return QString(); } diff --git a/src/plugins/qmldesigner/designmodewidget.h b/src/plugins/qmldesigner/designmodewidget.h index ec4eb3c5a8f41b4fc931675cbb23120a3d970c99..934ec7b08ea33ea22eebe20795057d2a09e366df 100644 --- a/src/plugins/qmldesigner/designmodewidget.h +++ b/src/plugins/qmldesigner/designmodewidget.h @@ -40,8 +40,10 @@ #include <designdocumentcontroller.h> #include <itemlibrary.h> #include <navigatorwidget.h> +#include <navigatorview.h> #include <stateseditorwidget.h> #include <modelnode.h> +#include <formeditorview.h> #include <QWeakPointer> @@ -78,7 +80,7 @@ class DocumentWarningWidget : public QFrame Q_OBJECT Q_DISABLE_COPY(DocumentWarningWidget) public: - explicit DocumentWarningWidget(DocumentWidget *documentWidget, QWidget *parent = 0); + explicit DocumentWarningWidget(DesignModeWidget *parent = 0); void setError(const RewriterView::Error &error); @@ -88,52 +90,8 @@ private slots: private: QLabel *m_errorMessage; QLabel *m_goToError; - DocumentWidget *m_documentWidget; RewriterView::Error m_error; -}; - -class DocumentWidget : public QWidget -{ - Q_OBJECT - Q_DISABLE_COPY(DocumentWidget) -public: - explicit DocumentWidget(TextEditor::ITextEditor *textEditor, QPlainTextEdit *textEdit, QmlDesigner::DesignDocumentController *document, DesignModeWidget *mainWidget); - ~DocumentWidget(); - - QmlDesigner::DesignDocumentController *document() const; - TextEditor::ITextEditor *textEditor() const; - - void setAutoSynchronization(bool sync); - - void readSettings(); - void saveSettings(); - -protected: - void resizeEvent(QResizeEvent *event); - -private slots: - void enable(); - void disable(const QList<RewriterView::Error> &errors); - void updateErrorStatus(const QList<RewriterView::Error> &errors); - -private: - void setup(); - bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const; - QmlDesigner::ModelNode nodeForPosition(int cursorPos) const; - - TextEditor::ITextEditor *m_textEditor; - QWeakPointer<QPlainTextEdit> m_textBuffer; - QmlDesigner::DesignDocumentController *m_document; - DesignModeWidget *m_mainWidget; - QSplitter *m_mainSplitter; - Core::SideBar *m_leftSideBar; - Core::SideBar *m_rightSideBar; - - QToolBar *m_designToolBar; - Core::EditorToolBar *m_fakeToolBar; - - bool m_isDisabled; - DocumentWarningWidget *m_warningWidget; + DesignModeWidget *m_designModeWidget; }; class DesignModeWidget : public QWidget @@ -144,8 +102,6 @@ public: explicit DesignModeWidget(QWidget *parent = 0); ~DesignModeWidget(); -// void syncWithTextEdit(bool sync); - void showEditor(Core::IEditor *editor); void closeEditors(const QList<Core::IEditor*> editors); QString contextHelpId() const; @@ -158,6 +114,12 @@ public: QAction *pasteAction() const; QAction *selectAllAction() const; + void readSettings(); + void saveSettings(); + void setAutoSynchronization(bool sync); + + TextEditor::ITextEditor *textEditor() const {return m_textEditor; } + private slots: void undo(); void redo(); @@ -166,17 +128,26 @@ private slots: void copySelected(); void paste(); void selectAll(); + void closeCurrentEditor(); void undoAvailable(bool isAvailable); void redoAvailable(bool isAvailable); + void enable(); + void disable(const QList<RewriterView::Error> &errors); + void updateErrorStatus(const QList<RewriterView::Error> &errors); + +protected: + void resizeEvent(QResizeEvent *event); + private: - void setCurrentDocumentWidget(DocumentWidget *newDocumentWidget); + DesignDocumentController *currentDesignDocumentController() const {return m_currentDesignDocumentController.data(); } + void setCurrentDocument(DesignDocumentController *newDesignDocumentController); - QStackedWidget *m_documentWidgetStack; - QHash<QPlainTextEdit*,DocumentWidget*> m_documentHash; - DocumentWidget *m_currentDocumentWidget; - QPlainTextEdit *m_currentTextEdit; + //QStackedWidget *m_documentWidgetStack; + QHash<QPlainTextEdit*,QWeakPointer<DesignDocumentController> > m_documentHash; + QWeakPointer<DesignDocumentController> m_currentDesignDocumentController; + QWeakPointer<QPlainTextEdit> m_currentTextEdit; QAction *m_undoAction; QAction *m_redoAction; @@ -186,7 +157,30 @@ private: QAction *m_pasteAction; QAction *m_selectAllAction; + QWeakPointer<ItemLibrary> m_itemLibrary; + QWeakPointer<NavigatorView> m_navigator; + QWeakPointer<AllPropertiesBox> m_allPropertiesBox; + QWeakPointer<StatesEditorWidget> m_statesEditorWidget; + QWeakPointer<FormEditorView> m_formEditorView; + bool m_syncWithTextEdit; + + void setup(); + bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const; + QmlDesigner::ModelNode nodeForPosition(int cursorPos) const; + + TextEditor::ITextEditor *m_textEditor; + + QSplitter *m_mainSplitter; + Core::SideBar *m_leftSideBar; + Core::SideBar *m_rightSideBar; + + QToolBar *m_designToolBar; + Core::EditorToolBar *m_fakeToolBar; + + bool m_isDisabled; + bool m_setup; + DocumentWarningWidget *m_warningWidget; }; } // namespace Internal