AccountsSettingsBlock.qml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import QtQuick 2.15
  2. import DMusic 1.0
  3. import QtQuick.Layouts 1.15
  4. import ".."
  5. import "../../components"
  6. SettingsBlock {
  7. title: qsTr("Accounts")
  8. Layout.fillWidth: true
  9. property var switcher
  10. ColumnLayout {
  11. spacing: 10
  12. Layout.maximumWidth: 250
  13. clip: true
  14. DText {
  15. Layout.alignment: Qt.AlignCenter
  16. text: qsTr("Yandex")
  17. color: Style.block.text.categoryColor
  18. font.bold: true
  19. }
  20. Loader {
  21. Layout.alignment: Qt.AlignCenter
  22. Layout.preferredWidth: item.width
  23. sourceComponent: YClient.loggined? _token : _login
  24. Component {
  25. id: _token
  26. Item {
  27. clip: true
  28. height: _token_text.height
  29. width: Math.min(250, _token_text.width)
  30. DText {
  31. id: _token_text
  32. text: Config.ym_email
  33. color: _tokenMouse.containsMouse? Style.block.text.darkColor : Style.block.text.color
  34. Rectangle {
  35. visible: _tokenMouse.containsMouse
  36. height: 1
  37. width: parent.width
  38. anchors.verticalCenter: parent.verticalCenter
  39. anchors.verticalCenterOffset: 1
  40. color: Style.block.text.color
  41. }
  42. MouseArea {
  43. id: _tokenMouse
  44. anchors.fill: parent
  45. cursorShape: Qt.PointingHandCursor
  46. hoverEnabled: true
  47. onClicked: {
  48. Config.ym_token = ""
  49. YClient.unlogin()
  50. }
  51. }
  52. }
  53. Rectangle {
  54. id: _shade
  55. width: 10
  56. height: _token_text.height
  57. anchors.right: parent.right
  58. visible: parent.width >= 250
  59. gradient: Gradient {
  60. orientation: Gradient.Horizontal
  61. GradientStop { position: 0.0; color: "transparent" }
  62. GradientStop { position: 1.0; color: Style.block.background }
  63. }
  64. }
  65. }
  66. }
  67. Component {
  68. id: _login
  69. DButton {
  70. id: _loginButton
  71. text: qsTr("Login")
  72. onPanel: true
  73. onClick: switcher("qrc:/qml/pages/YandexLoginPage.qml")
  74. }
  75. }
  76. }
  77. }
  78. }