qml
[mdictionary] / src / mdictionary / qml / SearchBarWidget.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: searchBarWidget
5     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
6     color : myPalette.window;
7
8     property alias enableLineEdit: inputSearchText.enabled;
9
10     function setButtonText(string) { searchButton.setText(string) }
11     function setEnableHistoryPrev(Boolean) { historyPrevToolButton.enabled = Boolean }
12     function setEnableHistoryNext(Boolean) { historyNextToolButton.enabled = Boolean }
13     function setEnableHistoryShow(Boolean) { historyShowToolButton.enabled = Boolean }
14     function setEnableLineEdit(Boolean) { enableLineEdit = Boolean }
15     function setLineEditText(string) { inputSearchText.setText(string) }
16     function clear() { inputSearchText.setText("") }
17
18     signal searchButtonClicked(string text);
19     signal historyNextToolButtonClicked;
20     signal historyShowToolButtonClicked;
21     signal historyPrevToolButtonClicked;
22
23     MyTextLineEdit{
24         id: inputSearchText
25         width: (searchBarWidget.width - (searchBarWidget.height*3.5 + searchButton.width + 9));
26         height: searchBarWidget.height -1;
27         anchors.left: parent.left
28         anchors.verticalCenter: parent.verticalCenter
29         onEnterPressed: searchBarWidget.searchButtonClicked(text);
30         focus: searchBarWidget.focus
31         IconButton {
32             id: clearButton;
33             width:  inputSearchText.height-6;
34             height: inputSearchText.height-6;
35             anchors.rightMargin: 4
36             anchors.right: parent.right
37             anchors.verticalCenter: parent.verticalCenter
38             enabled: true;
39             pathToIcon: "qrc:/button/go-previous.png";
40             onClicked: clear();
41         }
42     }
43
44     Item {
45         id: buttonsBox
46         width: searchBarWidget.height*3.5 + searchButton.width + 9
47         height: searchBarWidget.height
48         anchors.right: parent.right
49         anchors.verticalCenter: parent.verticalCenter
50
51         Button {
52             id: searchButton
53             width: 100
54             height: searchBarWidget.height;
55             anchors.rightMargin: 3
56             anchors.right: historyPrevToolButton.left
57             anchors.verticalCenter: parent.verticalCenter
58             textInButton: "Search"
59             onClicked: searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
60         }
61
62         IconButton {
63             id: historyNextToolButton;
64             width:  searchBarWidget.height
65             height: searchBarWidget.height
66             anchors.right: parent.right
67             anchors.verticalCenter: parent.verticalCenter
68             enabled: true;
69             pathToIcon: "qrc:/button/go-previous.png";
70             onClicked: searchBarWidget.historyNextToolButtonClicked();
71         }
72
73         IconButton {
74             id: historyShowToolButton;
75             width:  searchBarWidget.height
76             height: searchBarWidget.height
77             anchors.rightMargin: 3
78             anchors.right: historyNextToolButton.left
79             anchors.verticalCenter: parent.verticalCenter
80             enabled: true;
81             pathToIcon: "qrc:/button/go-previous.png";
82             onClicked: searchBarWidget.historyShowToolButtonClicked();
83         }
84
85         IconButton {
86             id: historyPrevToolButton;
87             width:  searchBarWidget.height
88             height: searchBarWidget.height
89             anchors.rightMargin: 3
90             anchors.right: historyShowToolButton.left
91             anchors.verticalCenter: parent.verticalCenter
92             enabled: true;
93             pathToIcon: "qrc:/button/go-previous.png";
94             onClicked: searchBarWidget.historyPrevToolButtonClicked();
95         }
96     }
97 }