| 1 |
/* |
| 2 |
* Copyright (C) 2016 Canonical Ltd |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License version 3 as |
| 6 |
* published by the Free Software Foundation. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authored by: Florian Boucault <[email protected]> |
| 17 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.4 |
| 20 |
import QtQuick.Layouts 1.3 |
| 21 |
import QtQml.Models 2.2 |
| 22 |
import Lomiri.Components 1.3 |
| 23 |
|
| 24 |
FocusScope { |
| 25 |
id: shortcutRow |
| 26 |
|
| 27 |
implicitWidth: units.gu(30) |
| 28 |
implicitHeight: units.gu(4) |
| 29 |
|
| 30 |
property string actionLabel |
| 31 |
property string shortcutSetting |
| 32 |
property int index |
| 33 |
|
| 34 |
Rectangle { |
| 35 |
anchors.fill: parent |
| 36 |
color: index % 2 == 0 ? theme.palette.normal.overlay |
| 37 |
: theme.palette.selected.overlay |
| 38 |
} |
| 39 |
|
| 40 |
MouseArea { |
| 41 |
anchors.fill: parent |
| 42 |
onClicked: shortcutEditor.start(); |
| 43 |
} |
| 44 |
|
| 45 |
ShortcutEditor { |
| 46 |
id: shortcutEditor |
| 47 |
|
| 48 |
sequence: settings[shortcutRow.shortcutSetting] |
| 49 |
onFinished: settings[shortcutRow.shortcutSetting] = sequence |
| 50 |
} |
| 51 |
|
| 52 |
RowLayout { |
| 53 |
anchors { |
| 54 |
leftMargin: units.gu(4) |
| 55 |
fill: parent |
| 56 |
} |
| 57 |
spacing: units.gu(2) |
| 58 |
|
| 59 |
Label { |
| 60 |
Layout.fillWidth: true |
| 61 |
verticalAlignment: Text.AlignVCenter |
| 62 |
text: shortcutRow.actionLabel |
| 63 |
elide: Text.ElideRight |
| 64 |
} |
| 65 |
|
| 66 |
Rectangle { |
| 67 |
Layout.fillHeight: true |
| 68 |
Layout.preferredWidth: units.dp(1) |
| 69 |
color: theme.palette.normal.base |
| 70 |
} |
| 71 |
|
| 72 |
Label { |
| 73 |
Layout.minimumWidth: units.gu(16) |
| 74 |
verticalAlignment: Text.AlignVCenter |
| 75 |
text: shortcutEditor.editing ? i18n.tr("Enter shortcut…") |
| 76 |
: (shortcutEditor.sequence ? shortcutEditor.label |
| 77 |
: i18n.tr("Disabled")) |
| 78 |
elide: Text.ElideRight |
| 79 |
} |
| 80 |
} |
| 81 |
} |