Commit f87741a2 authored by Karel Slaný's avatar Karel Slaný

Partially exposing the content of data-box list to accessibility interface.

parent 80ca9c5c
/*
* Copyright (C) 2014-2017 CZ.NIC
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -132,17 +132,73 @@ ListView {
} // GridLayout
} // Item
MouseArea {
anchors.fill: parent
onClicked: {
/*
* Returns specified value:
* -1 - none ov below
* 0 - show box detail
* 1 - deselect box
* 2 - select box
*/
function actionOnClick() {
var ret = -1;
if (canDetailBoxes && !(canSelectBoxes || canDeselectBoxes)) {
root.boxDetail(rDbID)
ret = 0;
} else if (!canDetailBoxes && (canSelectBoxes || canDeselectBoxes)) {
if (rDbSelected && canDeselectBoxes) {
root.boxDeselect(rDbID)
ret = 1;
} else if (!rDbSelected && canSelectBoxes) {
root.boxSelect(rDbID)
ret = 2;
}
}
return ret;
}
/* Construct string to be presented to accessibility interface. */
function accessibleText() {
var aText = "";
switch (actionOnClick()) {
case 0:
aText += qsTr("View details about data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 1:
aText += qsTr("Deselect data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
case 2:
aText += qsTr("Select data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
break;
default:
break;
}
return aText;
}
function handleClick() {
switch (actionOnClick()) {
case 0:
root.boxDetail(rDbID)
break;
case 1:
root.boxDeselect(rDbID)
break;
case 2:
root.boxSelect(rDbID)
break;
default:
break;
}
}
anchors.fill: parent
Accessible.role: Accessible.Button
Accessible.name: accessibleText()
Accessible.onPressAction: {
handleClick()
}
onClicked: {
handleClick()
}
}
Rectangle {
......@@ -183,14 +239,43 @@ ListView {
MouseArea {
// visible only if canDetailBoxes
visible: (!canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes)
anchors.fill: parent
onClicked: {
// we must allow remove exist recipients from model.
if (!canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes) {
/*
* Returns true if can delete entries.
*/
function canRemoveEntries() {
return !canDetailBoxes && !(canSelectBoxes || canDeselectBoxes) && canRemoveBoxes;
}
/* Construct string to be presented to accessibility interface. */
function accessibleText() {
var aText = "";
if (canRemoveEntries()) {
aText += qsTr("Remove data box '%1' (identifier '%2').").arg(rDbName).arg(rDbID);
}
return aText;
}
function handleClick() {
/* We must allow removal of existing recipients from model. */
if (canRemoveEntries()) {
root.boxRemove(rDbID)
}
}
} // MouseArea
anchors.fill: parent
Accessible.role: Accessible.Button
Accessible.name: accessibleText()
Accessible.onPressAction: {
handleClick()
}
onClicked: {
handleClick()
}
}
} // Rectangle
Rectangle {
anchors.top: parent.bottom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment