From: Claudio Cambra Date: Thu, 21 Nov 2024 06:37:29 +0000 (+0800) Subject: Move tray window header component into separate file X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~5^2~28^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=cf2d8956258a63d7517326c4e749cb94a7746ca5;p=nextcloud-desktop.git Move tray window header component into separate file Signed-off-by: Claudio Cambra --- diff --git a/resources.qrc b/resources.qrc index bcebefc77..3733a5a73 100644 --- a/resources.qrc +++ b/resources.qrc @@ -29,6 +29,7 @@ src/gui/tray/AutoSizingMenu.qml src/gui/tray/ActivityList.qml src/gui/tray/CurrentAccountHeaderButton.qml + src/gui/tray/TrayWindowHeader.qml src/gui/tray/UnifiedSearchInputContainer.qml src/gui/tray/UnifiedSearchResultFetchMoreTrigger.qml src/gui/tray/UnifiedSearchResultItem.qml diff --git a/src/gui/tray/CurrentAccountHeaderButton.qml b/src/gui/tray/CurrentAccountHeaderButton.qml index 74d53db3c..44a3653d5 100644 --- a/src/gui/tray/CurrentAccountHeaderButton.qml +++ b/src/gui/tray/CurrentAccountHeaderButton.qml @@ -27,6 +27,7 @@ Button { readonly property alias userLineInstantiator: userLineInstantiator readonly property alias accountMenu: accountMenu + property color parentBackgroundColor: "transparent" display: AbstractButton.IconOnly flat: true @@ -165,7 +166,7 @@ Button { && UserModel.currentUser.serverHasUserStatus width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset height: width - color: trayWindowHeaderBackground.color + color: root.parentBackgroundColor anchors.bottom: currentAccountAvatar.bottom anchors.right: currentAccountAvatar.right radius: width * Style.trayFolderStatusIndicatorRadiusFactor diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index 71742adf4..e01729ed3 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -54,9 +54,9 @@ ApplicationWindow { onVisibleChanged: { // HACK: reload account Instantiator immediately by restting it - could be done better I guess - // see also id:currentAccountHeaderButton.accountMenu below - currentAccountHeaderButton.userLineInstantiator.active = false; - currentAccountHeaderButton.userLineInstantiator.active = true; + // see also id:trayWindowHeader.currentAccountHeaderButton.accountMenu below + trayWindowHeader.currentAccountHeaderButton.userLineInstantiator.active = false; + trayWindowHeader.currentAccountHeaderButton.userLineInstantiator.active = true; syncStatus.model.load(); } @@ -70,7 +70,7 @@ ApplicationWindow { Connections { target: UserModel function onCurrentUserChanged() { - currentAccountHeaderButton.accountMenu.close(); + trayWindowHeader.currentAccountHeaderButton.accountMenu.close(); syncStatus.model.load(); } } @@ -95,8 +95,8 @@ ApplicationWindow { userStatusDrawer.close() fileDetailsDrawer.close(); - if(Systray.isOpen) { - currentAccountHeaderButton.accountMenu.close(); + if (Systray.isOpen) { + trayWindowHeader.currentAccountHeaderButton.accountMenu.close(); appsMenu.close(); openLocalFolderButton.closeMenu() } @@ -237,125 +237,19 @@ ApplicationWindow { Accessible.role: Accessible.Grouping Accessible.name: qsTr("Nextcloud desktop main dialog") - Rectangle { - id: trayWindowHeaderBackground - - anchors.left: trayWindowMainItem.left - anchors.right: trayWindowMainItem.right - anchors.top: trayWindowMainItem.top - height: Style.trayWindowHeaderHeight - color: Style.currentUserHeaderColor - - palette { - text: Style.currentUserHeaderTextColor - windowText: Style.currentUserHeaderTextColor - buttonText: Style.currentUserHeaderTextColor - } - - RowLayout { - id: trayWindowHeaderLayout - - spacing: 0 - anchors.fill: parent - - CurrentAccountHeaderButton { - id: currentAccountHeaderButton - Layout.preferredWidth: Style.currentAccountButtonWidth - Layout.preferredHeight: Style.trayWindowHeaderHeight - } - - // Add space between items - Item { - Layout.fillWidth: true - } - - TrayFoldersMenuButton { - id: openLocalFolderButton - - visible: currentUser.hasLocalFolder - currentUser: UserModel.currentUser - parentBackgroundColor: trayWindowHeaderBackground.color - - onClicked: openLocalFolderButton.userHasGroupFolders ? openLocalFolderButton.toggleMenuOpen() : UserModel.openCurrentAccountLocalFolder() + TrayWindowHeader { + id: trayWindowHeader - onFolderEntryTriggered: isGroupFolder ? UserModel.openCurrentAccountFolderFromTrayInfo(fullFolderPath) : UserModel.openCurrentAccountLocalFolder() - - Accessible.role: Accessible.Graphic - Accessible.name: qsTr("Open local or group folders") - Accessible.onPressAction: openLocalFolderButton.userHasGroupFolders ? openLocalFolderButton.toggleMenuOpen() : UserModel.openCurrentAccountLocalFolder() - - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: Style.trayWindowHeaderHeight - Layout.preferredHeight: Style.trayWindowHeaderHeight - } - - HeaderButton { - id: trayWindowFeaturedAppButton - visible: UserModel.currentUser.isFeaturedAppEnabled - icon.source: UserModel.currentUser.featuredAppIcon + "/" - onClicked: UserModel.openCurrentAccountFeaturedApp() - - Accessible.role: Accessible.Button - Accessible.name: UserModel.currentUser.featuredAppAccessibleName - Accessible.onPressAction: trayWindowFeaturedAppButton.clicked() - - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: Style.trayWindowHeaderHeight - Layout.preferredHeight: Style.trayWindowHeaderHeight - } - - HeaderButton { - id: trayWindowAppsButton - icon.source: "image://svgimage-custom-color/more-apps.svg/" + palette.windowText - - onClicked: { - if(appsMenu.count <= 0) { - UserModel.openCurrentAccountServer() - } else if (appsMenu.visible) { - appsMenu.close() - } else { - appsMenu.open() - } - } - - Accessible.role: Accessible.ButtonMenu - Accessible.name: qsTr("More apps") - Accessible.onPressAction: trayWindowAppsButton.clicked() - - Menu { - id: appsMenu - x: Style.trayWindowMenuOffsetX - y: (trayWindowAppsButton.y + trayWindowAppsButton.height + Style.trayWindowMenuOffsetY) - width: Style.trayWindowWidth * Style.trayWindowMenuWidthFactor - height: implicitHeight + y > Style.trayWindowHeight ? Style.trayWindowHeight - y : implicitHeight - closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape - - Repeater { - model: UserAppsModel - delegate: MenuItem { - id: appEntry - anchors.left: parent.left - anchors.right: parent.right - text: model.appName - font.pixelSize: Style.topLinePixelSize - icon.source: model.appIconUrl - icon.color: palette.windowText - onTriggered: UserAppsModel.openAppUrl(appUrl) - hoverEnabled: true - Accessible.role: Accessible.MenuItem - Accessible.name: qsTr("Open %1 in browser").arg(model.appName) - Accessible.onPressAction: appEntry.triggered() - } - } - } - } - } - } // Rectangle trayWindowHeaderBackground + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: Style.trayWindowHeaderHeight + } UnifiedSearchInputContainer { id: trayWindowUnifiedSearchInputContainer - anchors.top: trayWindowHeaderBackground.bottom + anchors.top: trayWindowHeader.bottom anchors.left: trayWindowMainItem.left anchors.right: trayWindowMainItem.right anchors.topMargin: Style.trayHorizontalMargin diff --git a/src/gui/tray/TrayWindowHeader.qml b/src/gui/tray/TrayWindowHeader.qml new file mode 100644 index 000000000..142a77eee --- /dev/null +++ b/src/gui/tray/TrayWindowHeader.qml @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2020 by Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.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 2 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. + */ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import "../" +import "../filedetails/" + +import Style +import com.nextcloud.desktopclient + +Rectangle { + id: root + + readonly property alias currentAccountHeaderButton: currentAccountHeaderButton + + color: Style.currentUserHeaderColor + + palette { + text: Style.currentUserHeaderTextColor + windowText: Style.currentUserHeaderTextColor + buttonText: Style.currentUserHeaderTextColor + } + + RowLayout { + id: trayWindowHeaderLayout + + spacing: 0 + anchors.fill: parent + + CurrentAccountHeaderButton { + id: currentAccountHeaderButton + parentBackgroundColor: root.color + Layout.preferredWidth: Style.currentAccountButtonWidth + Layout.fillHeight: true + } + + // Add space between items + Item { + Layout.fillWidth: true + } + + TrayFoldersMenuButton { + id: openLocalFolderButton + + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: Style.trayWindowHeaderHeight + Layout.fillHeight: true + + visible: currentUser.hasLocalFolder + currentUser: UserModel.currentUser + parentBackgroundColor: root.color + + onClicked: openLocalFolderButton.userHasGroupFolders ? openLocalFolderButton.toggleMenuOpen() : UserModel.openCurrentAccountLocalFolder() + + onFolderEntryTriggered: isGroupFolder ? UserModel.openCurrentAccountFolderFromTrayInfo(fullFolderPath) : UserModel.openCurrentAccountLocalFolder() + + Accessible.role: Accessible.Graphic + Accessible.name: qsTr("Open local or group folders") + Accessible.onPressAction: openLocalFolderButton.userHasGroupFolders ? openLocalFolderButton.toggleMenuOpen() : UserModel.openCurrentAccountLocalFolder() + } + + HeaderButton { + id: trayWindowFeaturedAppButton + + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: Style.trayWindowHeaderHeight + Layout.fillHeight: true + + visible: UserModel.currentUser.isFeaturedAppEnabled + icon.source: UserModel.currentUser.featuredAppIcon + "/" + onClicked: UserModel.openCurrentAccountFeaturedApp() + + Accessible.role: Accessible.Button + Accessible.name: UserModel.currentUser.featuredAppAccessibleName + Accessible.onPressAction: trayWindowFeaturedAppButton.clicked() + } + + HeaderButton { + id: trayWindowAppsButton + icon.source: "image://svgimage-custom-color/more-apps.svg/" + palette.windowText + + onClicked: { + if(appsMenu.count <= 0) { + UserModel.openCurrentAccountServer() + } else if (appsMenu.visible) { + appsMenu.close() + } else { + appsMenu.open() + } + } + + Accessible.role: Accessible.ButtonMenu + Accessible.name: qsTr("More apps") + Accessible.onPressAction: trayWindowAppsButton.clicked() + + Menu { + id: appsMenu + x: Style.trayWindowMenuOffsetX + y: (trayWindowAppsButton.y + trayWindowAppsButton.height + Style.trayWindowMenuOffsetY) + width: Style.trayWindowWidth * Style.trayWindowMenuWidthFactor + height: implicitHeight + y > Style.trayWindowHeight ? Style.trayWindowHeight - y : implicitHeight + closePolicy: Menu.CloseOnPressOutsideParent | Menu.CloseOnEscape + + Repeater { + model: UserAppsModel + delegate: MenuItem { + id: appEntry + anchors.left: parent.left + anchors.right: parent.right + text: model.appName + font.pixelSize: Style.topLinePixelSize + icon.source: model.appIconUrl + icon.color: palette.windowText + onTriggered: UserAppsModel.openAppUrl(appUrl) + hoverEnabled: true + Accessible.role: Accessible.MenuItem + Accessible.name: qsTr("Open %1 in browser").arg(model.appName) + Accessible.onPressAction: appEntry.triggered() + } + } + } + } + } +}