<file>button/revert.png</file>
<file>button/checkboxCheckedDis.png</file>
<file>button/checkboxDis.png</file>
+ <file>button/buttonCenterFocus.png</file>
+ <file>button/buttonLeftFocus.png</file>
+ <file>button/buttonRFocus.png</file>
</qresource>
</RCC>
view= new QDeclarativeView();
ctxt = view->rootContext();
+ ctxt->setContextProperty("focusss",true);
view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SearchBarWidget.qml"));
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
this, SLOT(nextCompleter()));
connect(rootObject, SIGNAL(prevCompleter()),
this, SLOT(prevCompleter()));
+ connect(rootObject, SIGNAL(checkFocus()),
+ this, SLOT(checkFocus()));
+ connect(rootObject, SIGNAL(nextFocus()),
+ this, SLOT(nextFocus()));
connect(this, SIGNAL(progresSetMax(QVariant)),
rootObject2, SLOT(setMax(QVariant)));
connect(this, SIGNAL(setCompleterText(QVariant)),
rootObject, SLOT(setCompleterText(QVariant)));
+ connect(this, SIGNAL(focusOff()),
+ rootObject, SLOT(focusOff()));
connect(busyTimer, SIGNAL(timeout()),
this, SLOT(updateBusyTimer()));
connect(&delayTimer, SIGNAL(timeout()),
this, SLOT(delaySearchTimeout()));
- view->setFocus();
-
#else
initializeUI();
connect(searchPushButton, SIGNAL(clicked()),
searchWordLineEdit->setFocus();
#endif
-
+ setFocus();
busy = false;
setEnabled(true);
updateHistoryButtons(false,false,false);
}
+void SearchBarWidget::checkFocus(){
+ qDebug()<<"focus:"<<QApplication::focusWidget();
+ if(focusWidget()!=QApplication::focusWidget())
+ emit focusOff();
+}
+
+void SearchBarWidget::nextFocus(){
+ parentWidget()->nextInFocusChain()->setFocus();
+}
+
void SearchBarWidget::textChange(QString text){
QLineEdit line;
QString toSend="";
}
void SearchBarWidget::setFocus() {
- qDebug()<<"test3";
#ifndef Q_WS_MAEMO_5
view->setFocus();
#else
void progresSetValue(QVariant);
void progresSetValue2(QVariant);
void setCompleterText(QVariant);
+ void focusOff();
//! Requests to search for a list of words matching a word passed as
//! a parameter
void updateHistoryButtons(bool prev, bool next, bool list);
void setFocus();
+ void nextFocus();
+ void checkFocus();
private Q_SLOTS:
//! Clears search word line edit
void prevCompleter();
+
private:
QVBoxLayout* mainLayout;
#ifndef Q_WS_MAEMO_5
void SettingsWidget::save() {
_save = true;
+ qDebug()<<"tuuu";
hide();
}
#endif
connect(this, SIGNAL(setUrl(QVariant)),
rootObject, SLOT(setUrl(QVariant)));
+ emit setUrl(QDir::homePath() + "/.mdictionary/" + "html.html");
+
#else
realParent = qobject_cast<TranslationWidget*>(parent);
connect(searchSelectedAction, SIGNAL(triggered()),
this, SIGNAL(search()));
- connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
+ connect(page(), SIGNAL(selectionChanged()),
+ this, SLOT(selection()));
#endif
}
import Qt 4.7
-BorderImage {
+Rectangle {
id: button
property alias textInButton: buttonText.text
property bool checkable: false
function setText(string) { textInButton = qsTr(string); }
function press() { mouseArea.pressed }
- border { left: 10; top: 10; right: 10; bottom: 10 }
+
+ Keys.onReturnPressed: {
+ button.clicked();
+ if(checkable){
+ button.checked=!button.checked;
+ button.changeCheck();
+ }
+ }
MouseArea {
id: mouseArea
Image {
id: image1
- width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 //(35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1
height: parent.height
anchors.left: parent.left
source: "qrc:/button/buttonLeft.png"
anchors.left: image1.right
anchors.leftMargin: -1
source: "qrc:/button/buttonCenter.png"
- fillMode:Image.Stretch
+ //fillMode:Image.Stretch
+ fillMode: Image.TileHorizontally
+
}
Image {
id: image2
smooth: true
- width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1//(35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1
height: parent.height
anchors.right: parent.right
source: "qrc:/button/buttonR.png"
PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" }
PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" }
PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" }
+ },
+ State {
+ name: "focused";
+ when: (button.enabled && !mouseArea.pressed && button.focus)
+
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftFocus.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterFocus.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRFocus.png" }
}
+
]
}
property string pathToCheckedDicImage: "qrc:/button/checkboxCheckedDis.png"
property string pathToUncheckedDicImage: "qrc:/button/checkboxDis.png"
signal changed
+
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Space)
+ selected=!selected
+ }
+
height: {
var aspectRatio = sourceSize.height / sourceSize.width
return checkbox.width * aspectRatio
}
}
}
+
+ Rectangle{
+ id: focusRectangle
+ color: "#000000"
+ border.color: "#000000"
+ opacity: 0;
+ radius: 1
+ anchors.centerIn: parent
+ z:1;
+ }
+
+ onFocusChanged: {
+ if(focus)
+ focusRectangle.opacity=0.5;
+ else
+ focusRectangle.opacity=0;
+ }
}
contentsScale: 1
pressGrabTime: 0
- Keys.onRightPressed: {
- console.log("test");
- }
-
function doZoom(zoom,centerX,centerY)
{
var tempX = flickable.width/2 - parent.x*zoom;
Image {
id: image1
- z: 1
smooth: true
- width: (35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 //(35*parent.height)/107 +1
height: parent.height
anchors.left: parent.left
source: "qrc:/button/buttonLeft.png"
+ fillMode:Image.Stretch
}
Image {
id: image3
- z: 1
smooth: true
height: parent.height
anchors.right: image2.left
anchors.left: image1.right
anchors.leftMargin: -1
source: "qrc:/button/buttonCenter.png"
+ fillMode:Image.Stretch
+ //fillMode: Image.TileHorizontally
}
Image {
id: image2
- z: 1
smooth: true
- width: (35*parent.height)/107 +1
+ width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1//(35*parent.height)/107 +1
height: parent.height
anchors.right: parent.right
source: "qrc:/button/buttonR.png"
+ fillMode:Image.Stretch
}
PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
+ },
+ State {
+ name: "focused";
+ when: (rectangle.enabled && !mouseArea.pressed && rectangle.focus)
+
+ PropertyChanges { target: image1; source: "qrc:/button/buttonLeftFocus.png" }
+ PropertyChanges { target: image3; source: "qrc:/button/buttonCenterFocus.png" }
+ PropertyChanges { target: image2; source: "qrc:/button/buttonRFocus.png" }
}
]
}
return value;
}
+ function setFocus(){
+ text_input1.focus=true;
+ }
+
TextInput {
id: text_input1
x: 1
if(focus==false)
text=stringToInt(text);
}
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Up)
+ text_input1.text=((stringToInt(text_input1.text)+singleStep)>maxValue)?(maxValue):(stringToInt(text_input1.text)+singleStep);
+ else if (event.key == Qt.Key_Down){
+ text_input1.text=((stringToInt(text_input1.text)-singleStep)<minValue)?(minValue):(stringToInt(text_input1.text)-singleStep);
+ if(isTextInMinValue && stringToInt(text_input1.text)==minValue)
+ text_input1.text=textInMinValue
+ }
+ }
}
Timer {
timerDown.running=true;
}
}
+ states: [
+ State {
+ name: "focusState"; when: text_input1.focus && rectangle1.enabled;
+ PropertyChanges { target: rectangle1; border.width: 2 }
+ }
+ ]
}
signal nextCompleter();
signal prevCompleter();
+ signal isFocused();
+ signal checkFocus();
+
function setText(string) { textInLineEdit = string; }
function setCompleter(string) { completerItemText.text=string; }
function hideCompleter() { completerItem.visible=false; }
completerItemText.text="";
}
+ function setFocus(){
+ if(rectangle1.enabled){
+ text_input1.focus=true;
+ isFocused();
+ }
+ }
+
TextInput {
id: text_input1
width: rectangle1.width-20
else
completerItem.visible=false;
}
- focus: rectangle1.focus;
Keys.priority : Keys.AfterItem
Keys.onPressed: {
if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return)){
}
}
onTextChanged: rectangle1.textChange(text);
+ onFocusChanged: if(focus) isFocused();
+ onActiveFocusChanged: rectangle1.checkFocus();
}
states: [
State {
- name: "FokusState"; when: text_input1.focus==true && rectangle1.enabled==true;
+ name: "FokusState"; when: text_input1.focus && rectangle1.enabled;
PropertyChanges {
target: rectangle1
border.width: 3
}
},
State {
- name: "DisableState"; when: rectangle1.enabled==false;
+ name: "DisableState"; when: !rectangle1.enabled;
PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
}
]
color : myPalette.window;
property alias enableLineEdit: inputSearchText.enabled;
+ property int focusIndex:-1;
+
function setButtonText(string) { searchButton.setText(string) }
function setEnableHistoryPrev(Boolean) { historyPrevToolButton.enabled = Boolean }
function setLineEditText(string) { inputSearchText.setText(string) }
function setCompleterText(string) { inputSearchText.setCompleter(string) }
+ function setFocus(){
+ if(focusIndex==0){
+ inputSearchText.setFocus();
+ if(!inputSearchText.enabled)
+ focusIndex++;
+ }
+ if(focusIndex==1)
+ clearButton.focus=true;
+
+ if(focusIndex==2){
+ searchButton.focus = true
+ if(!searchButton.enabled)
+ focusIndex++;
+ }
+
+ if(focusIndex==3){
+ historyPrevToolButton.focus = true
+ if(!historyPrevToolButton.enabled)
+ focusIndex++;
+ }
+
+ if(focusIndex==4){
+ historyShowToolButton.focus = true
+ if(!historyShowToolButton.enabled)
+ focusIndex++;
+ }
+
+ if(focusIndex==5){
+ historyNextToolButton.focus = true
+ if(!historyNextToolButton.enabled)
+ focusIndex++;
+ }
+
+ if (focusIndex>5){
+ nextFocus();
+ focusIndex=-1;
+ focus=true;
+ }
+ }
+
+ function focusOff(){ focus=true; focusIndex=-1;}
+
+ signal nextFocus();
+ signal checkFocus();
signal searchButtonClicked(string text);
signal historyNextToolButtonClicked;
signal historyShowToolButtonClicked;
signal historyPrevToolButtonClicked;
signal textChange(string text);
-
signal nextCompleter();
signal prevCompleter();
+ Keys.onTabPressed: {
+ focusIndex++;
+ setFocus();
+ }
+
MyTextLineEdit{
id: inputSearchText
width: (searchBarWidget.width - (searchBarWidget.height*3.5 + searchButton.width + 9));
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
onEnterPressed: searchBarWidget.searchButtonClicked(text);
- focus: searchBarWidget.focus
useCompleter: true;
IconButton {
id: clearButton;
enabled: true;
pathToIcon: "qrc:/button/go-clear.png";
onClicked: clear();
+ onActiveFocusChanged:searchBarWidget.checkFocus();
}
onTextChange: searchBarWidget.textChange(text)
onNextCompleter: searchBarWidget.nextCompleter();
onPrevCompleter: searchBarWidget.prevCompleter();
+ onIsFocused: searchBarWidget.focusIndex=0;
+ onCheckFocus: searchBarWidget.checkFocus();
}
Item {
searchBarWidget.searchButtonClicked(inputSearchText.textInLineEdit);
inputSearchText.hideCompleter();
}
+ onActiveFocusChanged:searchBarWidget.checkFocus();
}
IconButton {
enabled: true;
pathToIcon: "qrc:/button/go-next.png";
onClicked: searchBarWidget.historyNextToolButtonClicked();
+ onActiveFocusChanged:searchBarWidget.checkFocus();
}
IconButton {
enabled: true;
pathToIcon: "qrc:/button/go-show.png";
onClicked: searchBarWidget.historyShowToolButtonClicked();
+ onActiveFocusChanged:searchBarWidget.checkFocus();
}
IconButton {
enabled: true;
pathToIcon: "qrc:/button/go-previous.png";
onClicked: searchBarWidget.historyPrevToolButtonClicked();
+ onActiveFocusChanged:searchBarWidget.checkFocus();
}
}
}
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
color : myPalette.window;
+ focus: true;
+ property int focusIndex:-1;
+
signal historySizeValueChanged(int intiger);
signal searchResulValueChanged(int intiger);
function setCheckedDictionaries(bool){
dictionariesCheckBox.selected=bool;
}
+ function setFocus(){
+ if(focusIndex==0){
+ searchSpinbox.setFocus();
+ if(!searchSpinbox.enabled)
+ focusIndex++;
+ }
+ if(focusIndex==1){
+ historySpinbox.setFocus();
+ if(!historySpinbox.enabled)
+ focusIndex++;
+ }
+ if(focusIndex==2){
+ bookmarkCheckBox.focus = true
+ if(!bookmarkCheckBox.enabled)
+ focusIndex++;
+ }
+ if(focusIndex==3){
+ dictionariesCheckBox.focus = true
+ if(!dictionariesCheckBox.enabled)
+ focusIndex++;
+ }
+ if(focusIndex==4){
+ saveButton.focus = true
+ if(!saveButton.enabled)
+ focusIndex++;
+ }
+ if(focusIndex>4){
+ focusIndex=-1;
+ focus=true;
+ }
+ }
+
+ Keys.onTabPressed: {
+ focusIndex++;
+ setFocus();
+ }
Text {
id: textSearch
anchors.left: textSearch.right
anchors.leftMargin: 20
onValueChange: rectangle1.searchResulValueChanged(intiger);
+ onFocusChanged: if(focus) focusIndex=0;
}
MySpinBox {
anchors.top: searchSpinbox.bottom
anchors.topMargin: 10
onValueChange: rectangle1.historySizeValueChanged(intiger);
+ onFocusChanged: if(focus) focusIndex=1;
}
Checkbox {
anchors.top: textSearchIn.bottom
anchors.topMargin: 0
onChanged: rectangle1.bookmarksCheckBoxChanged(selected);
+ onFocusChanged: if(focus) focusIndex=2;
}
Checkbox {
anchors.top: bookmarkCheckBox.bottom
anchors.topMargin: 3
onChanged: rectangle1.dictionariesCheckBoxChanged(selected);
+ onFocusChanged: if(focus) focusIndex=3;
}
Button {
anchors.right: parent.right
anchors.rightMargin: 5
textInButton: qsTr("Save")
- //onClicked: rectangle1.saveButtonClicked();
+ onClicked: rectangle1.saveButtonClicked();
+ onFocusChanged: if(focus) focusIndex=4;
}
}
id: webView
width:parent.width
height:parent.height
+ url:"file:///home/jakub/test.html";
anchors { top: headerSpace.bottom; left: parent.left; right: parent.right; bottom: parent.bottom }
}