ExpressionEditor.qml 1.99 KB
Newer Older
1 2 3 4
import Qt 4.6
import Bauhaus 1.0

QWidget {
5
    id: expressionEditor;
6 7 8 9 10 11 12 13 14 15
    x: 6
    y: -400
    width: frame.width - 22
    height: 40
    property bool active: false
    property var backendValue;


    onActiveChanged: {
        //text = "";
16 17
        print("active")
        print(y)
18 19 20 21
        if (active) {
            textEdit.plainText = backendValue.expression
            textEdit.setFocus();
            opacity = 1;
22
            height = 60
23 24 25 26 27 28 29 30 31 32 33 34

        } else {
            opacity = 0;
            height = 40;
        }
    }

    opacity: 0
    onOpacityChanged: {
        if (opacity == 0)
            lower();
    }
35
    Behavior on opacity {
36 37 38 39 40
        NumberAnimation {
            duration: 100
        }
    }

41
    Behavior on height {
42 43 44 45 46 47
        NumberAnimation {
            duration: 100
        }
    }


48
    ExpressionEdit {
49 50 51 52 53 54 55 56 57 58 59 60 61
        id: textEdit;
        styleSheet: "QTextEdit {border-radius: 0px;}"
        documentTitle: "Expression"

        width: expressionEdit.width
        height: expressionEdit.height
        horizontalScrollBarPolicy: "Qt::ScrollBarAlwaysOff"
        verticalScrollBarPolicy: "Qt::ScrollBarAlwaysOff"

        onFocusChanged: {
            if (!focus)
                expressionEdit.active = false;
        }
62 63 64 65
		onReturnPressed: {
		    expressionEdit.backendValue.expression = textEdit.plainText;
			expressionEdit.active = false;		
		}
66
    }
67
	
68
    QPushButton {
69
        focusPolicy: "Qt::NoFocus";
70 71 72 73 74 75 76 77 78 79 80 81
        y: expressionEdit.height - 22;
        x: expressionEdit.width - 61;
        styleSheetFile: "applybutton.css";
        width: 29
        height: 19
        onClicked: {
            expressionEdit.backendValue.expression = textEdit.plainText;
            expressionEdit.active = false;
        }
    }

    QPushButton {
82
        focusPolicy: "Qt::NoFocus";
83 84 85 86 87 88 89 90 91 92
        y: expressionEdit.height - 22;
        x: expressionEdit.width - 32;
        styleSheetFile: "cancelbutton.css";
        width: 29
        height: 19
        onClicked: {
            expressionEdit.active = false;
        }
    }
}