Browse Source

tab indentation in QML

cl-refactor
yann300 10 years ago
parent
commit
252910d387
  1. 63
      mix/qml/BasicContent.qml
  2. 92
      mix/qml/MainContent.qml
  3. 34
      mix/qml/TabStyle.qml
  4. 36
      mix/qml/main.qml

63
mix/qml/BasicContent.qml

@ -2,37 +2,34 @@ import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
Rectangle { Rectangle {
anchors.fill: parent
anchors.fill: parent width: parent.width
width: parent.width height: parent.height
height: parent.height color: "lightgray"
color: "lightgray" Text {
font.pointSize: 7
Text { anchors.left: parent.left
font.pointSize: 7 anchors.top: parent.top
anchors.left: parent.left anchors.topMargin: 3
anchors.top: parent.top anchors.leftMargin: 3
anchors.topMargin: 3 height: 9
anchors.leftMargin: 3 font.family: "Sego UI light"
height: 9 objectName: "status"
font.family: "Sego UI light" id: status
objectName: "status" }
id: status TextArea {
} readOnly: true
anchors.left: parent.left
TextArea { anchors.leftMargin: 10
readOnly: true anchors.top: status.bottom
anchors.left: parent.left anchors.topMargin: 3
anchors.leftMargin: 10 font.pointSize: 7
anchors.top: status.bottom font.family: "Sego UI light"
anchors.topMargin: 3 height: parent.height * 0.8
font.pointSize: 7 width: parent.width - 20
font.family: "Sego UI light" wrapMode: Text.Wrap
height: parent.height * 0.8 backgroundVisible: false
width: parent.width - 20 objectName: "content"
wrapMode: Text.Wrap id: content
backgroundVisible: false }
objectName: "content"
id: content
}
} }

92
mix/qml/MainContent.qml

@ -5,50 +5,50 @@ import QtQuick.Controls.Styles 1.2
import CodeEditorExtensionManager 1.0 import CodeEditorExtensionManager 1.0
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
height: parent.height height: parent.height
width: parent.width; width: parent.width;
id:root id:root
SplitView { SplitView {
anchors.fill: parent anchors.fill: parent
orientation: Qt.Vertical orientation: Qt.Vertical
Rectangle { Rectangle {
anchors.top: parent.top anchors.top: parent.top
id: contentView id: contentView
width: parent.width width: parent.width
height: parent.height * 0.7 height: parent.height * 0.7
TextArea { TextArea {
id: codeEditor id: codeEditor
height: parent.height height: parent.height
font.family: "Verdana" font.family: "Verdana"
font.pointSize: 9 font.pointSize: 9
width: parent.width width: parent.width
anchors.centerIn: parent anchors.centerIn: parent
tabChangesFocus: false tabChangesFocus: false
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Tab) { if (event.key === Qt.Key_Tab) {
codeEditor.insert(codeEditor.cursorPosition, "\t"); codeEditor.insert(codeEditor.cursorPosition, "\t");
event.accepted = true; event.accepted = true;
} }
} }
} }
} }
Rectangle { Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
id: contextualView id: contextualView
width: parent.width width: parent.width
Layout.minimumHeight: 20 Layout.minimumHeight: 20
height: parent.height * 0.3 height: parent.height * 0.3
TabView { TabView {
id: contextualTabs id: contextualTabs
antialiasing: true antialiasing: true
anchors.fill: parent anchors.fill: parent
style: TabStyle{} style: TabStyle {}
} }
} }
CodeEditorExtensionManager{ CodeEditorExtensionManager{
tabView: contextualTabs tabView: contextualTabs
editor: codeEditor editor: codeEditor
} }
} }
} }

34
mix/qml/TabStyle.qml

@ -3,21 +3,21 @@ import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2 import QtQuick.Controls.Styles 1.2
TabViewStyle { TabViewStyle {
frameOverlap: 1 frameOverlap: 1
tabBar: Rectangle { tabBar: Rectangle {
color: "lightgray" color: "lightgray"
} }
tab: Rectangle { tab: Rectangle {
color: "lightsteelblue" color: "lightsteelblue"
implicitWidth: Math.max(text.width + 4, 80) implicitWidth: Math.max(text.width + 4, 80)
implicitHeight: 20 implicitHeight: 20
radius: 2 radius: 2
Text { Text {
id: text id: text
anchors.centerIn: parent anchors.centerIn: parent
text: styleData.title text: styleData.title
color: styleData.selected ? "white" : "black" color: styleData.selected ? "white" : "black"
} }
} }
frame: Rectangle { color: "steelblue" } frame: Rectangle { color: "steelblue" }
} }

36
mix/qml/main.qml

@ -4,23 +4,21 @@ import QtQuick.Controls.Styles 1.2
import CodeEditorExtensionManager 1.0 import CodeEditorExtensionManager 1.0
ApplicationWindow { ApplicationWindow {
visible: true visible: true
width: 1000 width: 1000
height: 480 height: 480
minimumWidth: 400 minimumWidth: 400
minimumHeight: 300 minimumHeight: 300
title: qsTr("mix") title: qsTr("mix")
menuBar: MenuBar {
menuBar: MenuBar { Menu {
Menu { title: qsTr("File")
title: qsTr("File") MenuItem {
MenuItem { text: qsTr("Exit")
text: qsTr("Exit") onTriggered: Qt.quit();
onTriggered: Qt.quit(); }
} }
} }
} MainContent{
}
MainContent{
}
} }

Loading…
Cancel
Save