Skip to content
Snippets Groups Projects
Commit d1d466aa authored by Aline Gondim Santos's avatar Aline Gondim Santos
Browse files

Revert "issue: Maximize and then Restore `Select a screen to share` window"

This reverts commit ab8c3645.

Reason for revert: It breaks the sharing functionality in windows

Change-Id: Ia031bec6d82462115e3086ab9300b3aef99d9bab
parent ab8c3645
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2023 Savoir-faire Linux Inc.
* Author: Nicolas Vengeon <Nicolas.vengeon@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 <https://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import net.jami.Adapters 1.1
import net.jami.Models 1.1
import net.jami.Constants 1.1
import "../../commoncomponents"
Rectangle {
id: root
color: JamiTheme.secondaryBackgroundColor
border.color: selectedScreenNumber === elementIndex ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor
width: elementWidth
height: 3 * width / 4
property var elementIndex
property string rectTitle
property var rId
property bool isSelectAllScreens
Text {
id: textTitle
anchors.top: root.top
anchors.topMargin: marginSize
anchors.horizontalCenter: root.horizontalCenter
width: root.width - 2 * marginSize
font.pointSize: JamiTheme.textFontSize
text: rectTitle
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
color: JamiTheme.textColor
}
VideoView {
anchors.top: textTitle.bottom
anchors.topMargin: 10
anchors.horizontalCenter: root.horizontalCenter
height: root.height - 50
width: root.width - 50
Component.onDestruction: {
VideoDevices.stopDevice(rendererId)
}
Component.onCompleted: {
if (root.rId !== "") {
rendererId = VideoDevices.startDevice(root.rId)
}
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
if (selectedScreenNumber !== root.elementIndex) {
selectedScreenNumber = root.elementIndex
}
}
}
}
/* /*
* Copyright (C) 2020-2023 Savoir-faire Linux Inc. * Copyright (C) 2020-2022 Savoir-faire Linux Inc.
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
* Author: Nicolas Vengeon <Nicolas.vengeon@savoirfairelinux.com> *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
...@@ -36,203 +35,371 @@ import "../../commoncomponents" ...@@ -36,203 +35,371 @@ import "../../commoncomponents"
Window { Window {
id: root id: root
minimumHeight: minimumWidth * 3 / 4
minimumWidth: componentMinWidth + 2 * marginSize
modality: Qt.ApplicationModal
title: window ? JamiStrings.selectWindow : JamiStrings.selectScreen
property bool window: false property bool window: false
property int selectedScreenNumber: -2
property bool selectAllScreens: selectedScreenNumber == -1 property int selectedScreenNumber: -1
property bool selectAllScreens: false
property string currentPreview: "" property string currentPreview: ""
property var listModel: [] property var screens: []
property real componentMinWidth: 350 property real componentMinWidth: 200
property real marginSize: JamiTheme.preferredMarginSize property real componentWidthDoubleColumn: screenSelectionScrollView.width / 2 -
property real elementWidth: { screenSelectionScrollViewFlow.spacing / 2 - JamiTheme.preferredMarginSize
var layoutWidth = selectScreenWindowLayout.width property real componentWidthSingleColumn: screenSelectionScrollView.width -
var minSize = componentMinWidth + 2 * marginSize 2 * JamiTheme.preferredMarginSize
var numberElementPerRow = Math.floor(layoutWidth / minSize)
if (numberElementPerRow == 1 && layoutWidth > componentMinWidth * 1.5) {
numberElementPerRow = 2
}
if (window)
numberElementPerRow = Math.min(listModel.length, numberElementPerRow)
else
numberElementPerRow = Math.min(listModel.length + 1, numberElementPerRow)
var spacingLength = marginSize * (numberElementPerRow + 2)
return (layoutWidth - spacingLength) / numberElementPerRow modality: Qt.ApplicationModal
} title: window ? JamiStrings.selectWindow : JamiStrings.selectScreen
// How many rows the ScrollView should have.
function calculateRepeaterModel() { function calculateRepeaterModel() {
listModel = [] screens = []
var idx var idx
if (!root.window) { for (idx in Qt.application.screens) {
for (idx in Qt.application.screens) { screens.push(JamiStrings.screen.arg(idx))
listModel.push(JamiStrings.screen.arg(idx)) }
} AvAdapter.getListWindows()
} else { for (idx in AvAdapter.windowsNames) {
AvAdapter.getListWindows() screens.push(AvAdapter.windowsNames[idx])
for (idx in AvAdapter.windowsNames) {
listModel.push(AvAdapter.windowsNames[idx])
}
} }
return screens.length
} }
onVisibleChanged: { onVisibleChanged: {
if (!visible) if (!visible)
return return
if (!active) { if (!active) {
selectedScreenNumber = -2 selectedScreenNumber = -1
selectAllScreens = false
} }
screenInfo.model = {} screenInfo.model = {}
screenInfo2.model = {}
calculateRepeaterModel() calculateRepeaterModel()
screenInfo.model = root.listModel screenInfo.model = screens.length
screenInfo2.model = screens.length
windowsText.visible = root.window
} }
Rectangle { Rectangle {
id: selectScreenWindowRect id: selectScreenWindowRect
anchors.fill: parent anchors.fill: parent
color: JamiTheme.backgroundColor color: JamiTheme.backgroundColor
ColumnLayout { ScrollView {
id: selectScreenWindowLayout id: screenSelectionScrollView
anchors.fill: parent anchors.topMargin: JamiTheme.preferredMarginSize
anchors.horizontalCenter: selectScreenWindowRect.horizontalCenter
Text { width: selectScreenWindowRect.width
font.pointSize: JamiTheme.menuFontSize height: selectScreenWindowRect.height -
font.bold: true (selectButton.height + JamiTheme.preferredMarginSize * 4)
text: root.window ? JamiStrings.windows : JamiStrings.screens
verticalAlignment: Text.AlignBottom
color: JamiTheme.textColor
Layout.margins: marginSize
}
ScrollView { clip: true
id: screenSelectionScrollView ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
Layout.alignment: Qt.AlignCenter Flow {
Layout.preferredWidth: selectScreenWindowLayout.width id: screenSelectionScrollViewFlow
Layout.fillHeight: true
clip: true anchors.fill: parent
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff topPadding: JamiTheme.preferredMarginSize
ScrollBar.vertical.policy: ScrollBar.AsNeeded rightPadding: JamiTheme.preferredMarginSize
leftPadding: JamiTheme.preferredMarginSize
Flow { spacing: JamiTheme.preferredMarginSize
id: screenSelectionScrollViewFlow
// https://bugreports.qt.io/browse/QTBUG-110323 Text {
width: screenSelectionScrollView.width width: screenSelectionScrollView.width
height: screenSelectionScrollView.height height: JamiTheme.preferredFieldHeight
font.pointSize: JamiTheme.menuFontSize
font.bold: true
text: JamiStrings.screens
verticalAlignment: Text.AlignBottom
color: JamiTheme.textColor
visible: !root.window
}
Repeater {
id: screenInfo
topPadding: marginSize model: screens ? screens.length : 0
rightPadding: marginSize
leftPadding: marginSize
spacing: marginSize
ScreensharingElementPreview { delegate: Rectangle {
id: screenSelectionRectAll id: screenItem
visible: !root.window && Qt.application.screens.length > 1 && Qt.platform.os.toString() !== "windows" color: JamiTheme.secondaryBackgroundColor
elementIndex: -1
rectTitle: JamiStrings.allScreens
rId: AvAdapter.getSharingResource(-1, "")
isSelectAllScreens: true
}
width: componentWidthDoubleColumn > componentMinWidth ? componentWidthDoubleColumn : componentWidthSingleColumn
height: 3 * width / 4
Repeater { border.color: selectedScreenNumber === index ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor
id: screenInfo visible: !root.window && JamiStrings.selectScreen !== screens[index] && index < Qt.application.screens.length
model: listModel.length Text {
id: screenName
anchors.top: screenItem.top
anchors.topMargin: 10
anchors.horizontalCenter: screenItem.horizontalCenter
width: parent.width
font.pointSize: JamiTheme.textFontSize
text: screens[index] ? screens[index] : ""
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignHCenter
color: JamiTheme.textColor
}
delegate: ScreensharingElementPreview { VideoView {
id: screenItem id: screenPreview
visible: JamiStrings.selectScreen !== listModel[index] anchors.top: screenName.bottom
elementIndex: index anchors.topMargin: 10
rectTitle: listModel[index] ? listModel[index] : "" anchors.horizontalCenter: screenItem.horizontalCenter
rId: { height: screenItem.height - 50
if (root.window) width: screenItem.width - 50
return rId = AvAdapter.getSharingResource(-2, AvAdapter.windowsIds[index])
return rId = AvAdapter.getSharingResource(index, "") Component.onDestruction: {
VideoDevices.stopDevice(rendererId)
}
Component.onCompleted: {
if (visible) {
const rId = AvAdapter.getSharingResource(index)
if (rId !== "") {
rendererId = VideoDevices.startDevice(rId)
}
}
} }
isSelectAllScreens: false }
Connections { MouseArea {
target: AvAdapter anchors.fill: screenItem
acceptedButtons: Qt.LeftButton
function onScreenCaptured(screenNumber, source) { onClicked: {
if (screenNumber === -1 && !root.window) selectAllScreens = false
screenShotAll.source = JamiQmlUtils.base64StringTitle + source if (selectedScreenNumber == -1
|| selectedScreenNumber !== index) {
selectedScreenNumber = index
} }
} }
} }
Connections {
target: AvAdapter
function onScreenCaptured(screenNumber, source) {
if (screenNumber === -1)
screenShotAll.source = JamiQmlUtils.base64StringTitle + source
}
}
} }
} }
}
RowLayout { Rectangle {
Layout.margins: marginSize id: screenSelectionRectAll
Layout.preferredWidth: selectScreenWindowLayout.width
Layout.preferredHeight: childrenRect.height color: JamiTheme.secondaryBackgroundColor
spacing: marginSize
width: componentWidthDoubleColumn > componentMinWidth ? componentWidthDoubleColumn : componentWidthSingleColumn
MaterialButton { height: 3 * width / 4
id: selectButton
border.color: selectAllScreens ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor
Layout.maximumWidth: 200
Layout.fillWidth: true visible: !root.window && Qt.application.screens.length > 1 && Qt.platform.os.toString() !== "windows"
Layout.alignment: Qt.AlignHCenter
Layout.leftMargin: marginSize Text {
id: screenNameAll
enabled: selectedScreenNumber != -2
opacity: enabled ? 1.0 : 0.5 anchors.top: screenSelectionRectAll.top
anchors.topMargin: 10
color: JamiTheme.buttonTintedBlack anchors.horizontalCenter: screenSelectionRectAll.horizontalCenter
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed font.pointSize: JamiTheme.textFontSize
secondary: true text: JamiStrings.allScreens
autoAccelerator: true color: JamiTheme.textColor
}
text: window ? JamiStrings.shareWindow : JamiStrings.shareScreen
VideoView {
onClicked: { id: screenShotAll
if (selectAllScreens)
AvAdapter.shareAllScreens() anchors.top: screenNameAll.bottom
else { anchors.topMargin: 10
if (!root.window) anchors.horizontalCenter: screenSelectionRectAll.horizontalCenter
AvAdapter.shareEntireScreen(selectedScreenNumber) height: screenSelectionRectAll.height - 50
else { width: screenSelectionRectAll.width - 50
AvAdapter.shareWindow(AvAdapter.windowsIds[selectedScreenNumber])
Component.onDestruction: {
VideoDevices.stopDevice(rendererId)
}
Component.onCompleted: {
if (visible) {
const rId = AvAdapter.getSharingResource(-1)
if (rId !== "") {
rendererId = VideoDevices.startDevice(rId)
}
} }
} }
root.close()
} }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
selectedScreenNumber = -1
selectAllScreens = true
}
}
}
Text {
id: windowsText
width: screenSelectionScrollView.width
height: JamiTheme.preferredFieldHeight
font.pointSize: JamiTheme.menuFontSize
font.bold: true
text: JamiStrings.windows
verticalAlignment: Text.AlignBottom
color: JamiTheme.textColor
visible: root.window
} }
MaterialButton { Repeater {
id: cancelButton id: screenInfo2
Layout.maximumWidth: 200 model: screens ? screens.length : 0
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.rightMargin: marginSize
color: JamiTheme.buttonTintedBlack delegate: Rectangle {
hoveredColor: JamiTheme.buttonTintedBlackHovered id: screenItem2
pressedColor: JamiTheme.buttonTintedBlackPressed
secondary: true
autoAccelerator: true
text: JamiStrings.optionCancel color: JamiTheme.secondaryBackgroundColor
onClicked: root.close() width: componentWidthDoubleColumn > componentMinWidth ? componentWidthDoubleColumn : componentWidthSingleColumn
height: 3 * width / 4
border.color: selectedScreenNumber === index ? JamiTheme.screenSelectionBorderColor : JamiTheme.tabbarBorderColor
visible: root.window && JamiStrings.selectScreen !== screens[index] && index >= Qt.application.screens.length
Text {
id: screenName2
anchors.top: screenItem2.top
anchors.topMargin: 10
anchors.horizontalCenter: screenItem2.horizontalCenter
width: parent.width
font.pointSize: JamiTheme.textFontSize
text: screens[index] ? screens[index] : ""
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignHCenter
color: JamiTheme.textColor
}
VideoView {
id: screenPreview2
anchors.top: screenName2.bottom
anchors.topMargin: 10
anchors.horizontalCenter: screenItem2.horizontalCenter
anchors.leftMargin: 25
anchors.rightMargin: 25
height: screenItem2.height - 60
width: screenItem2.width - 50
Component.onDestruction: {
VideoDevices.stopDevice(rendererId)
}
Component.onCompleted: {
if (visible) {
const rId = AvAdapter.getSharingResource(-2, AvAdapter.windowsIds[index - Qt.application.screens.length], AvAdapter.windowsNames[index - Qt.application.screens.length])
if (rId !== "") {
rendererId = VideoDevices.startDevice(rId)
}
}
}
}
MouseArea {
anchors.fill: screenItem2
acceptedButtons: Qt.LeftButton
onClicked: {
selectAllScreens = false
if (selectedScreenNumber == -1
|| selectedScreenNumber !== index) {
selectedScreenNumber = index
}
}
}
}
} }
} }
} }
} }
RowLayout {
anchors.bottom: selectScreenWindowRect.bottom
anchors.bottomMargin: JamiTheme.preferredMarginSize
anchors.horizontalCenter: selectScreenWindowRect.horizontalCenter
width: parent.width
height: childrenRect.height
spacing: JamiTheme.preferredMarginSize
MaterialButton {
id: selectButton
Layout.maximumWidth: 200
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.leftMargin: JamiTheme.preferredMarginSize
enabled: selectedScreenNumber != -1 || selectAllScreens
opacity: enabled ? 1.0 : 0.5
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
secondary: true
autoAccelerator: true
text: window ? JamiStrings.shareWindow : JamiStrings.shareScreen
onClicked: {
if (selectAllScreens)
AvAdapter.shareAllScreens()
else {
if (selectedScreenNumber < Qt.application.screens.length)
AvAdapter.shareEntireScreen(selectedScreenNumber)
else {
AvAdapter.shareWindow(AvAdapter.windowsIds[selectedScreenNumber - Qt.application.screens.length], AvAdapter.windowsNames[selectedScreenNumber - Qt.application.screens.length])
}
}
root.close()
}
}
MaterialButton {
id: cancelButton
Layout.maximumWidth: 200
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.rightMargin: JamiTheme.preferredMarginSize
color: JamiTheme.buttonTintedBlack
hoveredColor: JamiTheme.buttonTintedBlackHovered
pressedColor: JamiTheme.buttonTintedBlackPressed
secondary: true
autoAccelerator: true
text: JamiStrings.optionCancel
onClicked: root.close()
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment