diff --git a/qml.qrc b/qml.qrc index 9648a60534ea4b71f102f15b0c9ea9ef218b7980..fa1d2ebe32423b143dca4c97456a0ec25ee95e00 100644 --- a/qml.qrc +++ b/qml.qrc @@ -173,5 +173,9 @@ <file>src/commoncomponents/JamiFlickable.qml</file> <file>src/AccountMigrationView.qml</file> <file>src/settingsview/js/logviewwindowcreation.js</file> + <file>src/mainview/js/keyboardshortcuttablecreation.js</file> + <file>src/mainview/components/KeyboardShortcutTable.qml</file> + <file>src/mainview/components/KeyboardShortcutKeyDelegate.qml</file> + <file>src/mainview/components/KeyboardShortcutTabButton.qml</file> </qresource> </RCC> diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index 7e2814fd8436fc3985ad3403277490a6b9f73cf0..b5464e6293c8dcf4f5c77db8c9897c62356354a1 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -418,6 +418,13 @@ Item { // Recording Settings property string tipRecordFolder: qsTr("Select a record directory") + // KeyboardShortCutTable + property string keyboardShortcutTableWindowTitle: qsTr("Keyboard Shortcut Table") + property string generalKeyboardShortcuts: qsTr("General") + property string conversationKeyboardShortcuts: qsTr("Conversation") + property string callKeyboardShortcuts: qsTr("Call") + property string settingsKeyboardShortcuts: qsTr("Settings") + // View Logs property string logsViewTitle: qsTr("Debug") property string logsViewShowStats: qsTr("Show Stats") diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml index e7d0870675e510f0149407bd42d42db60b6eea78..0146b4a7c3da14a1c5b2a18c31072fcb26104ac0 100644 --- a/src/constant/JamiTheme.qml +++ b/src/constant/JamiTheme.qml @@ -346,6 +346,11 @@ Item { // JamiScrollBar property int scrollBarHandleSize: 6 + //KeyboardShortcutTable + property int titleRectMargin: 25 + property int keyboardShortcutTabBarSize: 24 + property int keyboardShortcutDelegateSize: 50 + // Main application spec property real mainViewMinWidth: 332 property real mainViewMinHeight: 500 diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 2138d6a0466a5e7cc84e3bec0ac37dadb1800de3..aa22b3078cdca04e96fc0b86af92ae8d2902b403 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -31,6 +31,8 @@ import "../wizardview" import "../settingsview" import "../settingsview/components" +import "js/keyboardshortcuttablecreation.js" as KeyboardShortcutTableCreation + Rectangle { id: mainView @@ -514,6 +516,15 @@ Rectangle { } } + Shortcut { + sequence: "F10" + context: Qt.ApplicationShortcut + onActivated: { + KeyboardShortcutTableCreation.createKeyboardShortcutTableWindowObject() + KeyboardShortcutTableCreation.showKeyboardShortcutTableWindow() + } + } + Shortcut { sequence: "F11" context: Qt.ApplicationShortcut diff --git a/src/mainview/components/KeyboardShortcutKeyDelegate.qml b/src/mainview/components/KeyboardShortcutKeyDelegate.qml new file mode 100644 index 0000000000000000000000000000000000000000..73c2a9a6c2c126b693a8dcb08f7bfe1dee11ad73 --- /dev/null +++ b/src/mainview/components/KeyboardShortcutKeyDelegate.qml @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Layouts + +import net.jami.Constants 1.1 + +RowLayout { + id: root + + Rectangle { + id: descriptionTextRect + + Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft + Layout.preferredHeight: descriptionText.contentHeight + 10 + Layout.preferredWidth: descriptionText.contentWidth + 10 + Layout.leftMargin: 10 + + color: JamiTheme.transparentColor + + Text { + id: descriptionText + + anchors.centerIn: parent + + text: description + font.pointSize: JamiTheme.textFontSize + font.weight: Font.Bold + color: JamiTheme.textColor + } + } + + Rectangle { + id: shortcutTextRect + + Layout.alignment: Qt.AlignVCenter | Qt.AlignRight + Layout.preferredHeight: shortcutText.contentHeight + 10 + Layout.preferredWidth: shortcutText.contentWidth + 10 + Layout.rightMargin: 10 + + color: JamiTheme.backgroundColor + radius: JamiTheme.primaryRadius + + Text { + id: shortcutText + + anchors.centerIn: parent + + text: shortcut + font.pointSize: JamiTheme.textFontSize + 3 + font.weight: Font.DemiBold + color: JamiTheme.textColor + } + } +} diff --git a/src/mainview/components/KeyboardShortcutTabButton.qml b/src/mainview/components/KeyboardShortcutTabButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..e93d237a43bde3cbf7a9e8cf8ef4c43ea23d70ce --- /dev/null +++ b/src/mainview/components/KeyboardShortcutTabButton.qml @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls + +import net.jami.Constants 1.1 + +TabButton { + id: root + + property int currentIndex + + contentItem: Text { + text: root.text + font.pointSize: JamiTheme.textFontSize + color: JamiTheme.textColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + color: root.hovered ? JamiTheme.hoveredButtonColor : + (root.down || root.currentIndex === index) ? + JamiTheme.pressedButtonColor : + JamiTheme.normalButtonColor + radius: JamiTheme.primaryRadius + } +} diff --git a/src/mainview/components/KeyboardShortcutTable.qml b/src/mainview/components/KeyboardShortcutTable.qml new file mode 100644 index 0000000000000000000000000000000000000000..b75a9cad388e1db3541953d8d46999d53397d6d4 --- /dev/null +++ b/src/mainview/components/KeyboardShortcutTable.qml @@ -0,0 +1,240 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtQuick.Layouts + +import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 + +import "../../commoncomponents" + +Window { + id: root + + title: JamiStrings.keyboardShortcutTableWindowTitle + width: 500 + height: 480 + + ListModel { + id: keyboardGeneralShortcutsModel + + ListElement { + shortcut: "Ctrl + J" + description: qsTr("Open account list") + } + ListElement { + shortcut: "Ctrl + L" + description: qsTr("Focus conversations list") + } + ListElement { + shortcut: "Ctrl + R" + description: qsTr("Requests list") + } + ListElement { + shortcut: "Ctrl + ↑" + description: qsTr("Previous conversation") + } + ListElement { + shortcut: "Ctrl + ↓" + description: qsTr("Next conversation") + } + ListElement { + shortcut: "Ctrl + F" + description: qsTr("Search bar") + } + ListElement { + shortcut: "F11" + description: qsTr("Full screen") + } + } + + ListModel { + id: keyboardConversationShortcutsModel + + ListElement { + shortcut: "Ctrl + Shift + C" + description: qsTr("Start an audio call") + } + ListElement { + shortcut: "Ctrl + Shift + X" + description: qsTr("Start a video call") + } + ListElement { + shortcut: "Ctrl + Shift + L" + description: qsTr("Clear history") + } + ListElement { + shortcut: "Ctrl + Shift + B" + description: qsTr("Block contact") + } + ListElement { + shortcut: "Ctrl + Shift + Delete" + description: qsTr("Remove conversation") + } + ListElement { + shortcut: "Shift + Ctrl + A" + description: qsTr("Accept contact request") + } + } + + ListModel { + id: keyboardSettingsShortcutsModel + + ListElement { + shortcut: "Ctrl + M" + description: qsTr("Media settings") + } + ListElement { + shortcut: "Ctrl + G" + description: qsTr("General settings") + } + ListElement { + shortcut: "Ctrl + I" + description: qsTr("Account settings") + } + ListElement { + shortcut: "Ctrl + P" + description: qsTr("Plugin settings") + } + ListElement { + shortcut: "Ctrl + Shift + N" + description: qsTr("Open account creation wizard") + } + ListElement { + shortcut: "F10" + description: qsTr("Open keyboard shortcut table") + } + } + + ListModel { + id: keyboardCallsShortcutsModel + + ListElement { + shortcut: "Ctrl + Y" + description: qsTr("Answer an incoming call") + } + ListElement { + shortcut: "Ctrl + D" + description: qsTr("End call") + } + ListElement { + shortcut: "Ctrl + Shift + D" + description: qsTr("Decline the call request") + } + } + + Rectangle { + id: windowRect + + anchors.fill: parent + + color: JamiTheme.secondaryBackgroundColor + + Rectangle { + id: titleRect + + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: JamiTheme.titleRectMargin + + height: titleName.contentHeight + JamiTheme.titleRectMargin + width: titleName.contentWidth + JamiTheme.titleRectMargin + + color: JamiTheme.backgroundColor + radius: JamiTheme.primaryRadius + + Text { + id: titleName + + anchors.centerIn: parent + + font.pointSize: JamiTheme.titleFontSize + text: { + switch (selectionBar.currentIndex) { + case 0: + return JamiStrings.generalKeyboardShortcuts + case 1: + return JamiStrings.conversationKeyboardShortcuts + case 2: + return JamiStrings.callKeyboardShortcuts + case 3: + return JamiStrings.settingsKeyboardShortcuts + + } + } + color: JamiTheme.textColor + } + } + + JamiListView { + id: keyboardShortCutList + + anchors.top: titleRect.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + + width: parent.width + height: parent.height - titleRect.height - JamiTheme.titleRectMargin - + keyboardShortCutList.anchors.topMargin - selectionBar.height - + selectionBar.anchors.bottomMargin + + model: { + switch (selectionBar.currentIndex) { + case 0: + return keyboardGeneralShortcutsModel + case 1: + return keyboardConversationShortcutsModel + case 2: + return keyboardCallsShortcutsModel + case 3: + return keyboardSettingsShortcutsModel + + } + } + delegate: KeyboardShortcutKeyDelegate { + width: keyboardShortCutList.width + height: Math.max(JamiTheme.keyboardShortcutDelegateSize, + implicitHeight) + } + } + + TabBar { + id: selectionBar + + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + + width: 96 + height: JamiTheme.keyboardShortcutTabBarSize + contentHeight: JamiTheme.keyboardShortcutTabBarSize + + Repeater { + model: ["1", "2", "3", "4"] + + KeyboardShortcutTabButton { + currentIndex: selectionBar.currentIndex + text: modelData + } + } + } + } +} diff --git a/src/mainview/js/keyboardshortcuttablecreation.js b/src/mainview/js/keyboardshortcuttablecreation.js new file mode 100644 index 0000000000000000000000000000000000000000..67c4404c52553583841cebe2e993be8b1dad6498 --- /dev/null +++ b/src/mainview/js/keyboardshortcuttablecreation.js @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * + * 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 <https://www.gnu.org/licenses/>. + */ + +// Global select screen window component, object variable for creation. +var keyboardShortcutTableWindowComponent +var keyboardShortcutTableWindowObject + +function createKeyboardShortcutTableWindowObject() { + if (keyboardShortcutTableWindowObject) + return + keyboardShortcutTableWindowComponent = Qt.createComponent( + "../components/KeyboardShortcutTable.qml") + if (keyboardShortcutTableWindowComponent.status === Component.Ready) + finishCreation() + else if (keyboardShortcutTableWindowComponent.status === Component.Error) + console.log("Error loading component:", + keyboardShortcutTableWindowComponent.errorString()) +} + +function finishCreation() { + keyboardShortcutTableWindowObject = keyboardShortcutTableWindowComponent.createObject() + if (keyboardShortcutTableWindowObject === null) { + // Error Handling. + console.log("Error creating select screen object") + } + + // Signal connection. + keyboardShortcutTableWindowObject.onClosing.connect(destroyKeyboardShortcutTableWindow) +} + +function showKeyboardShortcutTableWindow() { + keyboardShortcutTableWindowObject.show() + + var screen = keyboardShortcutTableWindowObject.screen + keyboardShortcutTableWindowObject.x = screen.virtualX + + (screen.width - keyboardShortcutTableWindowObject.width) / 2 + keyboardShortcutTableWindowObject.y = screen.virtualY + + (screen.height - keyboardShortcutTableWindowObject.height) / 2 +} + +// Destroy and reset selectScreenWindowObject when window is closed. +function destroyKeyboardShortcutTableWindow() { + if(!keyboardShortcutTableWindowObject) + return + keyboardShortcutTableWindowObject.destroy() + keyboardShortcutTableWindowObject = false +}