/*******************************************************************************
This file is part of mDictionary.
mDictionary is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
mDictionary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mDictionary. If not, see .
Copyright 2010 Comarch S.A.
*******************************************************************************/
/*!
author: Marcin Kaźmierczak
*/
import Qt 4.7
Image {
id: checkbox
property bool selected
property string pathToCheckedImage: "qrc:/button/checkboxChecked.png"
property string pathToUncheckedImage: "qrc:/button/checkbox.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
}
width: sourceSize.width
smooth: true
states: [
State {
name: "checkeEn";
when: (checkbox.selected && checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToCheckedImage }
},
State {
name: "uncheckeEn";
when: ( !checkbox.selected && checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToUncheckedImage }
},
State {
name: "checkeDi";
when: (checkbox.selected && !checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToCheckedDicImage }
},
State {
name: "uncheckeDi";
when: ( !checkbox.selected && !checkbox.enabled);
PropertyChanges { target: checkbox; source: pathToUncheckedDicImage }
}
]
MouseArea{
id: area
anchors.fill: parent
onClicked: {
if(checkbox.enabled){
checkbox.selected = !checkbox.selected
changed()
}
}
}
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;
}
}