new qmlfmt script and test application to main.qml
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
1319674940
commit
1af5662416
|
@ -0,0 +1,86 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
indent = " "
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
log.Fatal("Required argument(s): filename(s)")
|
||||
}
|
||||
|
||||
for _, filename := range os.Args[1:] {
|
||||
processFile(filename)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func processFile(filename string) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not read file %v: %v\n", filename, err)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
var lines []string
|
||||
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
file.Close()
|
||||
|
||||
file, err = os.Create(filename)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.Fatalf("Could not write to file %v: %v\n", filename, err)
|
||||
}
|
||||
|
||||
indentCount := 0
|
||||
inMultiLineComment := false
|
||||
|
||||
for _, line := range lines {
|
||||
|
||||
singleCommentPos := strings.Index(line, "//")
|
||||
multiLineCommentStartPos := strings.Index(line, "/*")
|
||||
multiLineCommentEndPos := strings.Index(line, "*/")
|
||||
|
||||
closePos := strings.Index(line, "}")
|
||||
if !inMultiLineComment && closePos > -1 && (singleCommentPos == -1 || closePos < singleCommentPos) &&
|
||||
(multiLineCommentStartPos == -1 || closePos < multiLineCommentStartPos) &&
|
||||
(multiLineCommentEndPos == -1 || closePos > multiLineCommentEndPos) {
|
||||
indentCount--
|
||||
}
|
||||
|
||||
trimedLine := strings.Trim(line, " \t")
|
||||
if trimedLine == "" {
|
||||
file.Write([]byte("\n"))
|
||||
} else {
|
||||
file.Write([]byte(strings.Repeat(indent, indentCount) + trimedLine + "\n"))
|
||||
}
|
||||
|
||||
openPos := strings.Index(line, "{")
|
||||
if !inMultiLineComment && openPos > -1 && (singleCommentPos == -1 || openPos < singleCommentPos) &&
|
||||
(multiLineCommentStartPos == -1 || openPos < multiLineCommentStartPos) &&
|
||||
(multiLineCommentEndPos == -1 || openPos > multiLineCommentEndPos) {
|
||||
indentCount++
|
||||
}
|
||||
|
||||
if multiLineCommentStartPos > -1 {
|
||||
inMultiLineComment = true
|
||||
}
|
||||
|
||||
if multiLineCommentEndPos > -1 {
|
||||
inMultiLineComment = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick 2.5
|
||||
|
||||
QtObject {
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; }
|
||||
PropertyAnimation { id: anmPopup; easing.type: Easing.InQuart; duration: 7000; target: popup; property: "opacity"; to: 0; }
|
||||
|
||||
Rectangle { // THE ERROR MESSAGE POPUP
|
||||
id: popup
|
||||
|
|
|
@ -38,5 +38,5 @@ Item {
|
|||
readonly property int sidePaneMinSize: 700
|
||||
readonly property int doublePaneMinSize: 1000
|
||||
|
||||
property ThemeType theme: CwtchDark { }
|
||||
property ThemeType theme: CwtchDark { }
|
||||
}
|
|
@ -59,9 +59,9 @@ PortraitRow {
|
|||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: { setColors(status) }
|
||||
Component.onCompleted: { setColors(status) }
|
||||
|
||||
onStatusChanged: { setColors(status) }
|
||||
onStatusChanged: { setColors(status) }
|
||||
|
||||
function setColors(status) {
|
||||
//-2:WtfCodeError,-1:Error,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Synced,5:Failed,6:Killed
|
||||
|
|
|
@ -292,18 +292,18 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
ListModel { id: folder_activities_clothing }
|
||||
ListModel { id: folder_expressions }
|
||||
ListModel { id: folder_food_drink_herbs }
|
||||
ListModel { id: folder_gsr }
|
||||
ListModel { id: folder_nature }
|
||||
ListModel { id: folder_objects }
|
||||
ListModel { id: folder_people }
|
||||
ListModel { id: folder_symbols }
|
||||
ListModel { id: folder_travel_places }
|
||||
ListModel { id: folder_utils }
|
||||
ListModel { id: folder_other }
|
||||
ListModel { id: folder_search }
|
||||
ListModel { id: folder_activities_clothing }
|
||||
ListModel { id: folder_expressions }
|
||||
ListModel { id: folder_food_drink_herbs }
|
||||
ListModel { id: folder_gsr }
|
||||
ListModel { id: folder_nature }
|
||||
ListModel { id: folder_objects }
|
||||
ListModel { id: folder_people }
|
||||
ListModel { id: folder_symbols }
|
||||
ListModel { id: folder_travel_places }
|
||||
ListModel { id: folder_utils }
|
||||
ListModel { id: folder_other }
|
||||
ListModel { id: folder_search }
|
||||
|
||||
DelegateModel {
|
||||
id: emojiModel
|
||||
|
|
|
@ -27,7 +27,7 @@ Item {
|
|||
|
||||
property real logscale: 4 * Math.log10(gcd.themeScale + 1)
|
||||
|
||||
onDualPaneChanged: { realignProfile() }
|
||||
onDualPaneChanged: { realignProfile() }
|
||||
|
||||
function realignProfile() {
|
||||
if (dualPane) {
|
||||
|
@ -63,7 +63,7 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: { realignProfile() }
|
||||
Component.onCompleted: { realignProfile() }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
# go get cwtch.im/ui/cmd/qmlfmt
|
||||
|
||||
cd qml
|
||||
find -iname "*.qml" | xargs qmlfmt
|
||||
|
||||
cd ..
|
Reference in New Issue