Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) 2020 by Savoir-faire Linux |
| 4 | * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | import QtQuick 2.14 |
| 20 | import QtQuick.Controls 2.14 |
| 21 | import QtQuick.Layouts 1.14 |
| 22 | import net.jami.Models 1.0 |
| 23 | |
| 24 | import "../../commoncomponents" |
| 25 | |
| 26 | Dialog { |
| 27 | id: aboutPopUp |
| 28 | |
| 29 | |
| 30 | /* |
| 31 | * When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model (model : true is necessary). |
| 32 | */ |
| 33 | modal: true |
| 34 | |
| 35 | |
| 36 | /* |
| 37 | * Content height + margin. |
| 38 | */ |
| 39 | contentHeight: aboutPopUpContentRectColumnLayout.height + 5 * 7 |
| 40 | |
| 41 | ProjectCreditsScrollView { |
| 42 | id: projectCreditsScrollView |
| 43 | |
| 44 | visible: false |
| 45 | } |
| 46 | |
| 47 | ChangeLogScrollView { |
| 48 | id: changeLogScrollView |
| 49 | |
| 50 | visible: false |
| 51 | } |
| 52 | |
| 53 | Rectangle { |
| 54 | id: aboutPopUpContentRect |
| 55 | |
| 56 | anchors.fill: parent |
| 57 | |
| 58 | ColumnLayout { |
| 59 | id: aboutPopUpContentRectColumnLayout |
| 60 | |
| 61 | Image { |
| 62 | id: aboutPopUPJamiLogoImage |
| 63 | |
| 64 | Layout.alignment: Qt.AlignCenter |
| 65 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 66 | Layout.preferredHeight: 100 |
| 67 | |
| 68 | fillMode: Image.PreserveAspectFit |
| 69 | source: "qrc:/images/logo-jami-standard-coul.png" |
| 70 | mipmap: true |
| 71 | } |
| 72 | |
| 73 | Label { |
| 74 | id: jamiVersionText |
| 75 | |
| 76 | Layout.alignment: Qt.AlignCenter |
| 77 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 78 | Layout.preferredHeight: textMetricsjamiVersionText.boundingRect.height |
| 79 | |
| 80 | font.pointSize: JamiTheme.textFontSize - 2 |
| 81 | |
| 82 | horizontalAlignment: Text.AlignHCenter |
| 83 | verticalAlignment: Text.AlignVCenter |
| 84 | |
| 85 | text: textMetricsjamiVersionText.text |
| 86 | |
| 87 | TextMetrics { |
| 88 | id: textMetricsjamiVersionText |
| 89 | font: jamiVersionText.font |
| 90 | text: qsTr("version") + ": " + ClientWrapper.utilsAdaptor.getVersionStr() |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | Label { |
| 95 | id: jamiSlogansText |
| 96 | |
| 97 | Layout.alignment: Qt.AlignCenter |
| 98 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 99 | Layout.preferredHeight: textMetricsjamiSlogansText.boundingRect.height |
| 100 | Layout.topMargin: 5 |
| 101 | |
| 102 | wrapMode: Text.WordWrap |
| 103 | font.pointSize: JamiTheme.textFontSize - 2 |
| 104 | |
| 105 | horizontalAlignment: Text.AlignHCenter |
| 106 | verticalAlignment: Text.AlignVCenter |
| 107 | |
| 108 | text: textMetricsjamiSlogansText.text |
| 109 | |
| 110 | TextMetrics { |
| 111 | id: textMetricsjamiSlogansText |
| 112 | font: jamiSlogansText.font |
Sébastien Blin | 6e3aacf | 2020-08-25 20:44:53 -0400 | [diff] [blame] | 113 | text: qsTr("Together") |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 114 | } |
| 115 | } |
| 116 | |
| 117 | Label { |
| 118 | id: jamiDeclarationText |
| 119 | |
| 120 | Layout.alignment: Qt.AlignCenter |
| 121 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 122 | Layout.preferredHeight: 40 |
| 123 | Layout.topMargin: 5 |
| 124 | |
| 125 | wrapMode: Text.WordWrap |
| 126 | font.pointSize: JamiTheme.textFontSize - 2 |
| 127 | |
| 128 | horizontalAlignment: Text.AlignHCenter |
| 129 | verticalAlignment: Text.AlignVCenter |
| 130 | |
| 131 | |
| 132 | /* |
| 133 | * TextMetrics does not work for multi-line. |
| 134 | */ |
Sébastien Blin | 6e3aacf | 2020-08-25 20:44:53 -0400 | [diff] [blame] | 135 | text: qsTr("The Qt client for Jami.\nJami is a secured and distributed communication software.") |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | Label { |
| 139 | id: jamiDeclarationHyperText |
| 140 | |
| 141 | Layout.alignment: Qt.AlignCenter |
| 142 | |
| 143 | |
| 144 | /* |
| 145 | * Strangely, hoveredLink works badly when width grows too large |
| 146 | */ |
| 147 | Layout.preferredWidth: 50 |
| 148 | Layout.preferredHeight: textMetricsjamiDeclarationHyperText.boundingRect.height |
| 149 | Layout.topMargin: 5 |
| 150 | Layout.bottomMargin: 5 |
| 151 | |
| 152 | font.pointSize: JamiTheme.textFontSize - 2 |
| 153 | |
| 154 | horizontalAlignment: Text.AlignHCenter |
| 155 | verticalAlignment: Text.AlignVCenter |
| 156 | |
| 157 | text: textMetricsjamiDeclarationHyperText.text |
| 158 | onLinkActivated: Qt.openUrlExternally(link) |
| 159 | |
| 160 | TextMetrics { |
| 161 | id: textMetricsjamiDeclarationHyperText |
| 162 | font: jamiDeclarationHyperText.font |
| 163 | text: '<html><style type="text/css"></style><a href="https://jami.net">jami.net</a></html>' |
| 164 | } |
| 165 | |
| 166 | MouseArea { |
| 167 | anchors.fill: parent |
| 168 | |
| 169 | |
| 170 | /* |
| 171 | * We don't want to eat clicks on the Text. |
| 172 | */ |
| 173 | acceptedButtons: Qt.NoButton |
| 174 | cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | Label { |
| 179 | id: jamiDeclarationYearText |
| 180 | |
| 181 | Layout.alignment: Qt.AlignCenter |
| 182 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 183 | Layout.preferredHeight: textMetricsjamiDeclarationYearText.boundingRect.height |
| 184 | Layout.bottomMargin: 5 |
| 185 | |
| 186 | font.pointSize: JamiTheme.textFontSize - 2 |
| 187 | |
| 188 | horizontalAlignment: Text.AlignHCenter |
| 189 | verticalAlignment: Text.AlignVCenter |
| 190 | |
| 191 | text: textMetricsjamiDeclarationYearText.text |
| 192 | |
| 193 | TextMetrics { |
| 194 | id: textMetricsjamiDeclarationYearText |
| 195 | font: jamiDeclarationYearText.font |
| 196 | text: "© 2015-2020 Savoir-faire Linux" |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | Label { |
| 201 | id: jamiNoneWarrantyHyperText |
| 202 | |
| 203 | Layout.alignment: Qt.AlignCenter |
| 204 | Layout.preferredWidth: Math.min(300, |
| 205 | aboutPopUpContentRect.width) |
| 206 | Layout.preferredHeight: textMetricsjamiNoneWarrantyHyperText.boundingRect.height * 2 |
| 207 | Layout.bottomMargin: 10 |
| 208 | |
| 209 | wrapMode: Text.WordWrap |
| 210 | font.pointSize: JamiTheme.textFontSize - 3 |
| 211 | |
| 212 | horizontalAlignment: Text.AlignHCenter |
| 213 | verticalAlignment: Text.AlignVCenter |
| 214 | |
| 215 | text: textMetricsjamiNoneWarrantyHyperText.text |
| 216 | onLinkActivated: Qt.openUrlExternally(link) |
| 217 | |
| 218 | TextMetrics { |
| 219 | id: textMetricsjamiNoneWarrantyHyperText |
| 220 | font: jamiDeclarationHyperText.font |
| 221 | text: '<html><style type="text/css"></style>This program comes with absolutely no warranty.<br\>See the <a href="http://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License, version 3 or later</a> for details.</html>' |
| 222 | } |
| 223 | |
| 224 | MouseArea { |
| 225 | anchors.fill: parent |
| 226 | acceptedButtons: Qt.NoButton |
| 227 | cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | Rectangle { |
| 232 | id: buttonGroupChangeLogAndCredits |
| 233 | |
| 234 | Layout.alignment: Qt.AlignCenter |
| 235 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 236 | Layout.preferredHeight: 30 |
| 237 | Layout.bottomMargin: 10 |
| 238 | |
| 239 | RowLayout { |
| 240 | id: buttonGroupChangeLogAndCreditsRowLayout |
| 241 | |
| 242 | anchors.fill: parent |
| 243 | |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 244 | MaterialButton { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 245 | id: changeLogButton |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 246 | text: qsTr("Changelog") |
| 247 | color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGreyInactive : JamiTheme.buttonTintedGrey |
Sébastien Blin | c2220f8 | 2020-08-25 21:12:14 -0400 | [diff] [blame] | 248 | hoveredColor: JamiTheme.buttonTintedGreyHovered |
| 249 | pressedColor: JamiTheme.buttonTintedGreyPressed |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 250 | Layout.preferredWidth: 100 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 251 | |
| 252 | onClicked: { |
| 253 | if (changeLogOrCreditsStack.depth > 1) { |
| 254 | changeLogOrCreditsStack.pop() |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 259 | MaterialButton { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 260 | id: creditsButton |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 261 | text: qsTr("Credit") |
| 262 | color: projectCreditsScrollView.visible? JamiTheme.buttonTintedGrey : JamiTheme.buttonTintedGreyInactive |
Sébastien Blin | c2220f8 | 2020-08-25 21:12:14 -0400 | [diff] [blame] | 263 | hoveredColor: JamiTheme.buttonTintedGreyHovered |
| 264 | pressedColor: JamiTheme.buttonTintedGreyPressed |
Sébastien Blin | a84e5fd | 2020-08-16 17:39:15 -0400 | [diff] [blame] | 265 | Layout.preferredWidth: 100 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 266 | |
| 267 | onClicked: { |
| 268 | if (changeLogOrCreditsStack.depth == 1) { |
| 269 | changeLogOrCreditsStack.push( |
| 270 | projectCreditsScrollView) |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | StackView { |
| 278 | id: changeLogOrCreditsStack |
| 279 | |
| 280 | Layout.alignment: Qt.AlignCenter |
| 281 | Layout.preferredWidth: aboutPopUpContentRect.width |
| 282 | Layout.preferredHeight: 150 |
| 283 | Layout.bottomMargin: 5 |
| 284 | |
| 285 | initialItem: changeLogScrollView |
| 286 | |
| 287 | clip: true |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | background: Rectangle { |
| 293 | border.width: 0 |
| 294 | radius: 10 |
| 295 | } |
| 296 | } |