| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542 |
- import QtQml 2.1
- import QtQml.Models 2.1
- import QtQuick 2.9
- import QtQuick.Window 2.2
- import QtQuick.Controls 2.2
- import QtQuick.Layouts 1.2
- import QtGraphicalEffects 1.0
- Window {
- id: trayWindow
- visible: true
- width: 400
- height: 500
- color: "transparent"
- flags: Qt.FramelessWindowHint
- onActiveChanged: {
- if(!active) {
- trayWindow.hide();
- systrayBackend.setClosed();
- }
- }
- onVisibleChanged: {
- currentAccountAvatar.source = ""
- currentAccountAvatar.source = "image://avatars/currentUser"
- currentAccountUser.text = userModelBackend.currentUserName();
- currentAccountServer.text = userModelBackend.currentUserServer();
- trayWindowTalkButton.visible = userModelBackend.currentServerHasTalk() ? true : false;
- currentAccountStateIndicator.source = ""
- currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"
- userLineInstantiator.active = false;
- userLineInstantiator.active = true;
- }
- Connections {
- target: userModelBackend
- onRefreshCurrentUserGui: {
- currentAccountAvatar.source = ""
- currentAccountAvatar.source = "image://avatars/currentUser"
- currentAccountUser.text = userModelBackend.currentUserName();
- currentAccountServer.text = userModelBackend.currentUserServer();
- currentAccountStateIndicator.source = ""
- currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"
- }
- onNewUserSelected: {
- accountMenu.close();
- trayWindowTalkButton.visible = userModelBackend.currentServerHasTalk() ? true : false;
- }
- }
- Connections {
- target: systrayBackend
- onShowWindow: {
- accountMenu.close();
- trayWindow.show();
- trayWindow.raise();
- trayWindow.requestActivate();
- trayWindow.setX( systrayBackend.calcTrayWindowX());
- trayWindow.setY( systrayBackend.calcTrayWindowY());
- systrayBackend.setOpened();
- userModelBackend.fetchCurrentActivityModel();
- }
- onHideWindow: {
- trayWindow.hide();
- systrayBackend.setClosed();
- }
- }
- Rectangle {
- id: trayWindowBackground
- anchors.fill: parent
- radius: 10
- Rectangle {
- id: trayWindowHeaderBackground
- anchors.left: trayWindowBackground.left
- anchors.top: trayWindowBackground.top
- height: 60
- width: parent.width
- radius: 9
- color: "#0082c9"
- Rectangle {
- anchors.left: trayWindowHeaderBackground.left
- anchors.bottom: trayWindowHeaderBackground.bottom
- height: 30
- width: parent.width
- color: "#0082c9"
- }
- RowLayout {
- id: trayWindowHeaderLayout
- spacing: 0
- anchors.fill: parent
- Button {
- id: currentAccountButton
- Layout.preferredWidth: 220
- Layout.preferredHeight: (trayWindowHeaderBackground.height)
- display: AbstractButton.IconOnly
- flat: true
- MouseArea {
- id: accountBtnMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked:
- {
- syncPauseButton.text = systrayBackend.syncIsPaused() ? "Resume sync for all" : "Pause sync for all"
- accountMenu.open()
- }
- Menu {
- id: accountMenu
- x: (currentAccountButton.x + 2)
- y: (currentAccountButton.y + currentAccountButton.height + 2)
- width: (currentAccountButton.width - 2)
- closePolicy: "CloseOnPressOutside"
- background: Rectangle {
- border.color: "#0082c9"
- radius: 2
- }
- onClosed: {
- userLineInstantiator.active = false;
- userLineInstantiator.active = true;
- }
- Instantiator {
- id: userLineInstantiator
- model: userModelBackend
- delegate: UserLine {}
- onObjectAdded: accountMenu.insertItem(index, object)
- onObjectRemoved: accountMenu.removeItem(object)
- }
- MenuItem {
- id: addAccountButton
- height: 60
- RowLayout {
- width: addAccountButton.width
- height: addAccountButton.height
- spacing: 0
- Image {
- Layout.leftMargin: 8
- verticalAlignment: Qt.AlignCenter
- source: "qrc:///client/theme/black/add.svg"
- sourceSize.width: addAccountButton.height - 24
- sourceSize.height: addAccountButton.height - 24
- }
- Label {
- Layout.leftMargin: 10
- text: "Add account"
- color: "black"
- font.pixelSize: 12
- }
- Item {
- Layout.fillWidth: true
- Layout.fillHeight: true
- }
- }
- onClicked: userModelBackend.addAccount()
- }
- MenuSeparator { id: accountMenuSeparator }
- MenuItem {
- id: syncPauseButton
- onClicked: systrayBackend.pauseResumeSync()
- }
- MenuItem {
- text: "Open settings"
- onClicked: systrayBackend.openSettings()
- }
- MenuItem {
- text: "Help"
- onClicked: systrayBackend.openHelp()
- }
- MenuItem {
- text: "Quit Nextcloud"
- onClicked: systrayBackend.shutdown()
- }
- Component.onCompleted: {/*
- if(userModelBackend.numUsers() === 1) {
- accountMenuSeparator.height = 0
- } else {
- accountMenuSeparator.height = 13
- }*/
- }
- }
- }
- background:
- Item {
- id: leftHoverContainer
- height: currentAccountButton.height
- width: currentAccountButton.width
- Rectangle {
- width: currentAccountButton.width / 2
- height: currentAccountButton.height / 2
- color: "transparent"
- clip: true
- Rectangle {
- width: currentAccountButton.width
- height: currentAccountButton.height
- radius: 10
- color: "white"
- opacity: 0.2
- visible: accountBtnMouseArea.containsMouse
- }
- }
- Rectangle {
- width: currentAccountButton.width / 2
- height: currentAccountButton.height / 2
- anchors.bottom: leftHoverContainer.bottom
- color: "white"
- opacity: 0.2
- visible: accountBtnMouseArea.containsMouse
- }
- Rectangle {
- width: currentAccountButton.width / 2
- height: currentAccountButton.height / 2
- anchors.right: leftHoverContainer.right
- color: "white"
- opacity: 0.2
- visible: accountBtnMouseArea.containsMouse
- }
- Rectangle {
- width: currentAccountButton.width / 2
- height: currentAccountButton.height / 2
- anchors.right: leftHoverContainer.right
- anchors.bottom: leftHoverContainer.bottom
- color: "white"
- opacity: 0.2
- visible: accountBtnMouseArea.containsMouse
- }
- }
- RowLayout {
- id: accountControlRowLayout
- height: currentAccountButton.height
- width: currentAccountButton.width
- spacing: 0
- Image {
- id: currentAccountAvatar
- Layout.leftMargin: 8
- verticalAlignment: Qt.AlignCenter
- cache: false
- source: "image://avatars/currentUser"
- Layout.preferredHeight: (trayWindowHeaderBackground.height -16)
- Layout.preferredWidth: (trayWindowHeaderBackground.height -16)
- Image {
- id: currentAccountStateIndicator
- source: userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"
- cache: false
- anchors.bottom: currentAccountAvatar.bottom
- anchors.right: currentAccountAvatar.right
- sourceSize.width: 16
- sourceSize.height: 16
- }
- }
- Column {
- id: accountLabels
- spacing: 4
- Layout.alignment: Qt.AlignLeft
- Layout.leftMargin: 6
- Label {
- id: currentAccountUser
- width: 128
- text: userModelBackend.currentUserName()
- elide: Text.ElideRight
- color: "white"
- font.pixelSize: 12
- font.bold: true
- }
- Label {
- id: currentAccountServer
- width: 128
- text: userModelBackend.currentUserServer()
- elide: Text.ElideRight
- color: "white"
- font.pixelSize: 10
- }
- }
- Image {
- Layout.alignment: Qt.AlignRight
- verticalAlignment: Qt.AlignCenter
- Layout.margins: 8
- source: "qrc:///client/theme/white/caret-down.svg"
- sourceSize.width: 20
- sourceSize.height: 20
- }
- }
- }
- Item {
- id: trayWindowHeaderSpacer
- Layout.fillWidth: true
- }
- Button {
- id: openLocalFolderButton
- Layout.alignment: Qt.AlignRight
- display: AbstractButton.IconOnly
- Layout.preferredWidth: (trayWindowHeaderBackground.height)
- Layout.preferredHeight: (trayWindowHeaderBackground.height)
- flat: true
- icon.source: "qrc:///client/theme/white/folder.svg"
- icon.color: "transparent"
- MouseArea {
- id: folderBtnMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked:
- {
- userModelBackend.openCurrentAccountLocalFolder();
- }
- }
- background:
- Rectangle {
- color: folderBtnMouseArea.containsMouse ? "white" : "transparent"
- opacity: 0.2
- }
- }
- Button {
- id: trayWindowTalkButton
- Layout.alignment: Qt.AlignRight
- display: AbstractButton.IconOnly
- Layout.preferredWidth: (trayWindowHeaderBackground.height)
- Layout.preferredHeight: (trayWindowHeaderBackground.height)
- flat: true
- visible: userModelBackend.currentServerHasTalk() ? true : false
- icon.source: "qrc:///client/theme/white/talk-app.svg"
- icon.color: "transparent"
- MouseArea {
- id: talkBtnMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked:
- {
- userModelBackend.openCurrentAccountTalk();
- }
- }
- background:
- Rectangle {
- color: talkBtnMouseArea.containsMouse ? "white" : "transparent"
- opacity: 0.2
- }
- }
- Button {
- id: trayWindowAppsButton
- Layout.alignment: Qt.AlignRight
- display: AbstractButton.IconOnly
- Layout.preferredWidth: (trayWindowHeaderBackground.height)
- Layout.preferredHeight: (trayWindowHeaderBackground.height)
- flat: true
- icon.source: "qrc:///client/theme/white/more-apps.svg"
- icon.color: "transparent"
- MouseArea {
- id: appsBtnMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked:
- {
- userModelBackend.openCurrentAccountServer();
- }
- }
- background:
- Item {
- id: rightHoverContainer
- height: trayWindowAppsButton.height
- width: trayWindowAppsButton.width
- Rectangle {
- width: trayWindowAppsButton.width / 2
- height: trayWindowAppsButton.height / 2
- color: "white"
- opacity: 0.2
- visible: appsBtnMouseArea.containsMouse
- }
- Rectangle {
- width: trayWindowAppsButton.width / 2
- height: trayWindowAppsButton.height / 2
- anchors.bottom: rightHoverContainer.bottom
- color: "white"
- opacity: 0.2
- visible: appsBtnMouseArea.containsMouse
- }
- Rectangle {
- width: trayWindowAppsButton.width / 2
- height: trayWindowAppsButton.height / 2
- anchors.bottom: rightHoverContainer.bottom
- anchors.right: rightHoverContainer.right
- color: "white"
- opacity: 0.2
- visible: appsBtnMouseArea.containsMouse
- }
- Rectangle {
- id: rightHoverContainerClipper
- anchors.right: rightHoverContainer.right
- width: trayWindowAppsButton.width / 2
- height: trayWindowAppsButton.height / 2
- color: "transparent"
- clip: true
- Rectangle {
- width: trayWindowAppsButton.width
- height: trayWindowAppsButton.height
- anchors.right: rightHoverContainerClipper.right
- radius: 10
- color: "white"
- opacity: 0.2
- visible: appsBtnMouseArea.containsMouse
- }
- }
- }
- }
- }
- } // Rectangle trayWindowHeaderBackground
- ListView {
- id: activityListView
- anchors.top: trayWindowHeaderBackground.bottom
- width: trayWindowBackground.width
- height: trayWindowBackground.height - trayWindowHeaderBackground.height
- clip: true
- model: activityModel
- delegate: RowLayout {
- id: activityItem
- width: activityListView.width
- height: trayWindowHeaderLayout.height
- spacing: 0
- Image {
- id: activityIcon
- Layout.leftMargin: 6
- Layout.preferredWidth: 48
- Layout.preferredHeight: 48
- verticalAlignment: Qt.AlignCenter
- source: "qrc:///client/theme/black/state-sync.svg"
- sourceSize.height: 48
- sourceSize.width: 48
- }
- Column {
- id: activityTextColumn
- Layout.leftMargin: 6
- spacing: 4
- Layout.alignment: Qt.AlignLeft
- Text {
- id: activityTextTitle
- text: subject
- width: 220
- elide: Text.ElideRight
- font.pointSize: 9
- }
- Text {
- id: activityTextInfo
- text: path
- width: 220
- elide: Text.ElideRight
- font.pointSize: 8
- }
- }
- Item {
- id: activityItemFiller
- Layout.fillWidth: true
- }
- Button {
- id: activityButton1
- Layout.preferredWidth: activityItem.height
- Layout.preferredHeight: activityItem.height
- Layout.alignment: Qt.AlignRight
- flat: true
- hoverEnabled: false
- visible: (path === "") ? false : true
- display: AbstractButton.IconOnly
- icon.source: "qrc:///client/resources/files.svg"
- icon.color: "transparent"
- onClicked:
- {
- Qt.openUrlExternally(path)
- }
- }
- Button {
- Layout.preferredWidth: activityItem.height
- Layout.preferredHeight: activityItem.height
- Layout.alignment: Qt.AlignRight
- flat: true
- hoverEnabled: false
- display: AbstractButton.IconOnly
- icon.source: "qrc:///client/resources/public.svg"
- icon.color: "transparent"
- }
- }
- add: Transition {
- NumberAnimation { properties: "y"; from: -60; duration: 100; easing.type: Easing.Linear }
- }
- remove: Transition {
- NumberAnimation { property: "opacity"; from: 1.0; to: 0; duration: 100 }
- }
- removeDisplaced: Transition {
- SequentialAnimation {
- PauseAnimation { duration: 100}
- NumberAnimation { properties: "y"; duration: 100; easing.type: Easing.Linear }
- }
- }
- displaced: Transition {
- NumberAnimation { properties: "y"; duration: 100; easing.type: Easing.Linear }
- }
- focus: true
- }
- } // Rectangle trayWindowBackground
- }
|