AccessibleTabButton.qml 1.82 KB
Newer Older
Karel Slaný's avatar
Karel Slaný committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

import QtQuick 2.7
import QtQuick.Controls 2.2

/*
 * Accessible button component.
 */
TabButton {
    id: root

    /* These properties must be set by caller. */
    property string accessibleDescription: ""
    property string accessibleName: ""

    Accessible.role: Accessible.Button
38 39
    Accessible.checkable: root.checkable
    Accessible.checked: root.checked
Karel Slaný's avatar
Karel Slaný committed
40 41 42
    Accessible.description: root.accessibleDescription
    Accessible.name: (root.accessibleName !== "") ? root.accessibleName : root.text
    Accessible.onPressAction: {
Karel Slaný's avatar
Karel Slaný committed
43 44 45 46 47 48
        /*
         * It looks like TabBar is actually a Container of checkable
         * AbstractButton elements. For further details see sources of
         * QQuickTabBar, QQuickContainer and QQuickAbstractButton. Some hints
         * can also be found here: https://stackoverflow.com/a/32426364
         */
49
        root.checked = true
Karel Slaný's avatar
Karel Slaný committed
50 51
    }
}