diff --git a/qml.qrc b/qml.qrc index 50e329b37efe98749ac3b1788ba9765855e2023d..ce5c7ae71d07eb42f55ec3d0849e2751b89bed99 100644 --- a/qml.qrc +++ b/qml.qrc @@ -31,6 +31,7 @@ <file>src/settingsview/components/ChatviewSettings.qml</file> <file>src/settingsview/components/FileTransferSettings.qml</file> <file>src/settingsview/components/SettingsMenu.qml</file> + <file>src/settingsview/components/SettingsMenuButton.qml</file> <file>src/settingsview/components/SettingsHeader.qml</file> <file>src/settingsview/components/SystemSettings.qml</file> <file>src/settingsview/components/RecordingSettings.qml</file> diff --git a/src/settingsview/components/SettingsMenu.qml b/src/settingsview/components/SettingsMenu.qml index f9f715fa14745e56d70cc6458bfb363b24d21685..fb73f30a6c1f2bf26d8efe7a13eebcbf7a1c43aa 100644 --- a/src/settingsview/components/SettingsMenu.qml +++ b/src/settingsview/components/SettingsMenu.qml @@ -32,17 +32,6 @@ Rectangle { signal itemSelected(int index) signal buttonSelectedManually(int index) - Component.onCompleted: { - listModel.append({ 'type': SettingsView.Account, 'name': JamiStrings.accountSettingsMenuTitle, - 'iconSource': JamiResources.account_24dp_svg}) - listModel.append({ 'type': SettingsView.General, 'name': JamiStrings.generalSettingsTitle, - 'iconSource': JamiResources.gear_black_24dp_svg}) - listModel.append({ 'type': SettingsView.Media, 'name': JamiStrings.avSettingsMenuTitle, - 'iconSource': JamiResources.media_black_24dp_svg}) - listModel.append({ 'type': SettingsView.Plugin, 'name': JamiStrings.pluginSettingsTitle, - 'iconSource': JamiResources.plugin_settings_black_24dp_svg}) - } - anchors.fill: parent color: JamiTheme.backgroundColor @@ -61,49 +50,69 @@ Rectangle { anchors.right: parent.right height: childrenRect.height - Repeater { - id: repeater - - model: ListModel { id: listModel } - - PushButton { - id: pushButton + SettingsMenuButton { + id: accountPushButton + property int menuType: SettingsView.Account + Connections { + target: root - property int menuType: type - - Connections { - target: root - - function onButtonSelectedManually(index) { - if (pushButton.menuType === index) - buttonGroup.checkedButton = pushButton - } + function onButtonSelectedManually(index) { + if (accountPushButton.menuType === index) + buttonGroup.checkedButton = accountPushButton } + } + checked: true + buttonText: JamiStrings.accountSettingsMenuTitle + source: JamiResources.account_24dp_svg + normalColor: root.color + } - Component.onCompleted: checked = type === SettingsView.Account + SettingsMenuButton { + id: generalPushButton + property int menuType: SettingsView.General + Connections { + target: root - preferredHeight: 64 - preferredWidth: root.width - preferredMargin: 24 + function onButtonSelectedManually(index) { + if (generalPushButton.menuType === index) + buttonGroup.checkedButton = generalPushButton + } + } + buttonText: JamiStrings.generalSettingsTitle + source: JamiResources.gear_black_24dp_svg + normalColor: root.color + } - buttonText: name - buttonTextFont.pointSize: JamiTheme.textFontSize + 2 - textHAlign: Text.AlignLeft + SettingsMenuButton { + id: mediaPushButton + property int menuType: SettingsView.Media + Connections { + target: root - source: iconSource - imageColor: JamiTheme.textColor - imageContainerHeight: 40 - imageContainerWidth: 40 + function onButtonSelectedManually(index) { + if (mediaPushButton.menuType === index) + buttonGroup.checkedButton = mediaPushButton + } + } + buttonText: JamiStrings.avSettingsMenuTitle + source: JamiResources.media_black_24dp_svg + normalColor: root.color + } - normalColor: root.color - pressedColor: Qt.lighter(JamiTheme.pressedButtonColor, 1.25) - checkedColor: JamiTheme.selectedColor - hoveredColor: JamiTheme.hoverColor + SettingsMenuButton { + id: pluginPushButton + property int menuType: SettingsView.Plugin + Connections { + target: root - duration: 0 - checkable: true - radius: 0 + function onButtonSelectedManually(index) { + if (pluginPushButton.menuType === index) + buttonGroup.checkedButton = pluginPushButton + } } + buttonText: JamiStrings.pluginSettingsTitle + source: JamiResources.plugin_settings_black_24dp_svg + normalColor: root.color } } } diff --git a/src/settingsview/components/SettingsMenuButton.qml b/src/settingsview/components/SettingsMenuButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..91a85a3314c494636a77b36c0e699c30d54ab90e --- /dev/null +++ b/src/settingsview/components/SettingsMenuButton.qml @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020-2022 Savoir-faire Linux Inc. + * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> + * Author: Sébastien Blin <sebastien.blin@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 <http://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls + +import net.jami.Models 1.1 +import net.jami.Constants 1.1 + +import "../../commoncomponents" + +PushButton { + id: root + + property int menuType: 0 + + preferredHeight: 64 + preferredMargin: 24 + + anchors.left: parent.left + anchors.right: parent.right + + buttonTextFont.pointSize: JamiTheme.textFontSize + 2 + textHAlign: Text.AlignLeft + + imageColor: JamiTheme.textColor + imageContainerHeight: 40 + imageContainerWidth: 40 + + pressedColor: Qt.lighter(JamiTheme.pressedButtonColor, 1.25) + checkedColor: JamiTheme.selectedColor + hoveredColor: JamiTheme.hoverColor + + duration: 0 + checkable: true + radius: 0 +}