forked from qt-creator/qt-creator
Download textures and materials only by clicking the download icon
Previously, clicking the texture thumbnail itself would start the download. Also, improved the look of the download icon: * added a margin to the right * the inside "arrow" is now black, instead of transparent Task-number: QDS-9398 Change-Id: I58f958493f1c6072a57402288ea155135909e117 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -110,43 +110,51 @@ Item {
|
|||||||
}
|
}
|
||||||
} // IconButton
|
} // IconButton
|
||||||
|
|
||||||
Text { // download icon
|
IconButton {
|
||||||
color: root.downloadState === "unavailable" || root.downloadState === "failed"
|
id: downloadIcon
|
||||||
? StudioTheme.Values.themeRedLight
|
icon: root.downloadState === "unavailable"
|
||||||
: StudioTheme.Values.themeTextColor
|
|
||||||
|
|
||||||
font.family: StudioTheme.Constants.iconFont.family
|
|
||||||
text: root.downloadState === "unavailable"
|
|
||||||
? StudioTheme.Constants.downloadUnavailable
|
? StudioTheme.Constants.downloadUnavailable
|
||||||
: StudioTheme.Constants.download
|
: StudioTheme.Constants.download
|
||||||
|
|
||||||
font.pixelSize: 22
|
iconColor: root.downloadState === "unavailable" || root.downloadState === "failed"
|
||||||
horizontalAlignment: Text.AlignHCenter
|
? StudioTheme.Values.themeRedLight
|
||||||
verticalAlignment: Text.AlignVCenter
|
: StudioTheme.Values.themeTextColor
|
||||||
anchors.bottomMargin: 0
|
|
||||||
|
|
||||||
|
iconSize: 22
|
||||||
|
iconScale: downloadIcon.containsMouse ? 1.2 : 1
|
||||||
|
iconStyle: Text.Outline
|
||||||
|
iconStyleColor: "black"
|
||||||
|
|
||||||
|
tooltip: qsTr("Click to download material")
|
||||||
|
buttonSize: 22
|
||||||
|
|
||||||
|
transparentBg: true
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
style: Text.Outline
|
|
||||||
styleColor: "black"
|
|
||||||
|
|
||||||
visible: root.downloadState !== "downloaded"
|
visible: root.downloadState !== "downloaded"
|
||||||
|
|
||||||
MouseArea {
|
anchors.bottomMargin: 0
|
||||||
anchors.fill: parent
|
anchors.rightMargin: 4
|
||||||
acceptedButtons: Qt.LeftButton
|
|
||||||
|
|
||||||
onClicked: (mouse) => {
|
Rectangle { // arrow fill
|
||||||
if (root.downloadState !== "" && root.downloadState !== "failed")
|
anchors.centerIn: parent
|
||||||
return
|
z: -1
|
||||||
|
|
||||||
downloadPane.beginDownload(Qt.binding(function() { return downloader.progress }))
|
width: parent.width / 2
|
||||||
|
height: parent.height / 2
|
||||||
root.downloadState = ""
|
color: "black"
|
||||||
downloader.start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
onClicked: {
|
||||||
|
if (root.downloadState !== "" && root.downloadState !== "failed")
|
||||||
|
return
|
||||||
|
|
||||||
|
downloadPane.beginDownload(Qt.binding(function() { return downloader.progress }))
|
||||||
|
|
||||||
|
root.downloadState = ""
|
||||||
|
downloader.start()
|
||||||
|
}
|
||||||
|
} // IconButton
|
||||||
} // Image
|
} // Image
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
|
@@ -106,29 +106,60 @@ Item {
|
|||||||
|
|
||||||
property string webUrl: modelData.textureWebUrl
|
property string webUrl: modelData.textureWebUrl
|
||||||
|
|
||||||
Text {
|
IconButton {
|
||||||
id: downloadIcon
|
id: downloadIcon
|
||||||
color: root.downloadState === "unavailable" || root.downloadState === "failed"
|
icon: root.downloadState === "unavailable"
|
||||||
? StudioTheme.Values.themeRedLight
|
|
||||||
: StudioTheme.Values.themeTextColor
|
|
||||||
|
|
||||||
font.family: StudioTheme.Constants.iconFont.family
|
|
||||||
text: root.downloadState === "unavailable"
|
|
||||||
? StudioTheme.Constants.downloadUnavailable
|
? StudioTheme.Constants.downloadUnavailable
|
||||||
: StudioTheme.Constants.download
|
: StudioTheme.Constants.download
|
||||||
|
|
||||||
font.pixelSize: 22
|
iconColor: root.downloadState === "unavailable" || root.downloadState === "failed"
|
||||||
horizontalAlignment: Text.AlignHCenter
|
? StudioTheme.Values.themeRedLight
|
||||||
verticalAlignment: Text.AlignVCenter
|
: StudioTheme.Values.themeTextColor
|
||||||
anchors.bottomMargin: 0
|
|
||||||
|
|
||||||
|
iconSize: 22
|
||||||
|
iconScale: downloadIcon.containsMouse ? 1.2 : 1
|
||||||
|
iconStyle: Text.Outline
|
||||||
|
iconStyleColor: "black"
|
||||||
|
|
||||||
|
tooltip: modelData.textureToolTip + (downloadIcon.visible
|
||||||
|
? "\n\n" + root.statusText()
|
||||||
|
: "")
|
||||||
|
buttonSize: 22
|
||||||
|
|
||||||
|
transparentBg: true
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
style: Text.Outline
|
|
||||||
styleColor: "black"
|
|
||||||
|
|
||||||
visible: root.downloadState !== "downloaded"
|
visible: root.downloadState !== "downloaded"
|
||||||
}
|
|
||||||
|
anchors.bottomMargin: 0
|
||||||
|
anchors.rightMargin: 4
|
||||||
|
|
||||||
|
Rectangle { // Arrow Fill
|
||||||
|
anchors.centerIn: parent
|
||||||
|
z: -1
|
||||||
|
|
||||||
|
width: parent.width / 2
|
||||||
|
height: parent.height / 2
|
||||||
|
color: "black"
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (root.downloadState !== "" && root.downloadState !== "failed")
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ContentLibraryBackend.rootView.markTextureDownloading())
|
||||||
|
return
|
||||||
|
|
||||||
|
progressBar.visible = true
|
||||||
|
tooltip.visible = false
|
||||||
|
root.progressText = qsTr("Downloading...")
|
||||||
|
root.allowCancel = true
|
||||||
|
root.progressValue = Qt.binding(function() { return downloader.progress })
|
||||||
|
|
||||||
|
root.downloadState = ""
|
||||||
|
downloader.start()
|
||||||
|
}
|
||||||
|
} // IconButton
|
||||||
|
|
||||||
ToolTip {
|
ToolTip {
|
||||||
id: tooltip
|
id: tooltip
|
||||||
@@ -153,8 +184,9 @@ Item {
|
|||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
hoverEnabled: !downloadIcon.visible
|
||||||
|
propagateComposedEvents: downloadIcon.visible
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
onEntered: tooltip.visible = image.visible
|
onEntered: tooltip.visible = image.visible
|
||||||
onExited: tooltip.visible = false
|
onExited: tooltip.visible = false
|
||||||
@@ -167,28 +199,6 @@ Item {
|
|||||||
root.showContextMenu()
|
root.showContextMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: (mouse) => {
|
|
||||||
if (mouse.button !== Qt.LeftButton)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (root.downloadState !== "" && root.downloadState !== "failed")
|
|
||||||
return
|
|
||||||
|
|
||||||
if (!ContentLibraryBackend.rootView.markTextureDownloading())
|
|
||||||
return
|
|
||||||
|
|
||||||
progressBar.visible = true
|
|
||||||
tooltip.visible = false
|
|
||||||
root.progressText = qsTr("Downloading...")
|
|
||||||
root.allowCancel = true
|
|
||||||
root.progressValue = Qt.binding(function() { return downloader.progress })
|
|
||||||
|
|
||||||
mouseArea.enabled = false
|
|
||||||
root.downloadState = ""
|
|
||||||
root.downloadStateChanged()
|
|
||||||
downloader.start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDownloader {
|
FileDownloader {
|
||||||
@@ -198,7 +208,6 @@ Item {
|
|||||||
downloadEnabled: true
|
downloadEnabled: true
|
||||||
onDownloadStarting: {
|
onDownloadStarting: {
|
||||||
root.downloadState = "downloading"
|
root.downloadState = "downloading"
|
||||||
root.downloadStateChanged()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFinishedChanged: {
|
onFinishedChanged: {
|
||||||
@@ -214,16 +223,12 @@ Item {
|
|||||||
root.progressValue = 0
|
root.progressValue = 0
|
||||||
|
|
||||||
root.downloadState = ""
|
root.downloadState = ""
|
||||||
root.downloadStateChanged()
|
|
||||||
mouseArea.enabled = true
|
|
||||||
|
|
||||||
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
||||||
}
|
}
|
||||||
|
|
||||||
onDownloadFailed: {
|
onDownloadFailed: {
|
||||||
root.downloadState = "failed"
|
root.downloadState = "failed"
|
||||||
root.downloadStateChanged()
|
|
||||||
mouseArea.enabled = true
|
|
||||||
|
|
||||||
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
||||||
}
|
}
|
||||||
@@ -237,10 +242,8 @@ Item {
|
|||||||
alwaysCreateDir: false
|
alwaysCreateDir: false
|
||||||
clearTargetPathContents: false
|
clearTargetPathContents: false
|
||||||
onFinishedChanged: {
|
onFinishedChanged: {
|
||||||
mouseArea.enabled = true
|
|
||||||
modelData.setDownloaded()
|
modelData.setDownloaded()
|
||||||
root.downloadState = modelData.isDownloaded() ? "downloaded" : "failed"
|
root.downloadState = modelData.isDownloaded() ? "downloaded" : "failed"
|
||||||
root.downloadStateChanged()
|
|
||||||
|
|
||||||
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
ContentLibraryBackend.rootView.markNoTextureDownloading()
|
||||||
}
|
}
|
||||||
|
@@ -14,13 +14,19 @@ Rectangle {
|
|||||||
property alias icon: icon.text
|
property alias icon: icon.text
|
||||||
property alias tooltip: toolTip.text
|
property alias tooltip: toolTip.text
|
||||||
property alias iconSize: icon.font.pixelSize
|
property alias iconSize: icon.font.pixelSize
|
||||||
|
property alias iconScale: icon.scale
|
||||||
|
property alias iconColor: icon.color
|
||||||
|
property alias iconStyle: icon.style
|
||||||
|
property alias iconStyleColor: icon.styleColor
|
||||||
|
|
||||||
property alias containsMouse: mouseArea.containsMouse
|
property alias containsMouse: mouseArea.containsMouse
|
||||||
|
|
||||||
property bool enabled: true
|
property bool enabled: true
|
||||||
|
property bool transparentBg: false
|
||||||
property int buttonSize: StudioTheme.Values.height
|
property int buttonSize: StudioTheme.Values.height
|
||||||
property color normalColor: StudioTheme.Values.themeControlBackground
|
property color normalColor: root.transparentBg ? "transparent" : StudioTheme.Values.themeControlBackground
|
||||||
property color hoverColor: StudioTheme.Values.themeControlBackgroundHover
|
property color hoverColor: root.transparentBg ? "transparent" : StudioTheme.Values.themeControlBackgroundHover
|
||||||
property color pressColor: StudioTheme.Values.themeControlBackgroundInteraction
|
property color pressColor: root.transparentBg ? "transparent" : StudioTheme.Values.themeControlBackgroundInteraction
|
||||||
|
|
||||||
width: buttonSize
|
width: buttonSize
|
||||||
height: buttonSize
|
height: buttonSize
|
||||||
@@ -32,18 +38,18 @@ Rectangle {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: icon
|
id: icon
|
||||||
|
anchors.centerIn: root
|
||||||
|
|
||||||
color: root.enabled ? StudioTheme.Values.themeTextColor : StudioTheme.Values.themeTextColorDisabled
|
color: root.enabled ? StudioTheme.Values.themeTextColor : StudioTheme.Values.themeTextColorDisabled
|
||||||
font.family: StudioTheme.Constants.iconFont.family
|
font.family: StudioTheme.Constants.iconFont.family
|
||||||
font.pixelSize: StudioTheme.Values.baseIconFontSize
|
font.pixelSize: StudioTheme.Values.baseIconFontSize
|
||||||
anchors.centerIn: root
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: root.visible
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// We need to keep mouse area enabled even when button is disabled to make tooltip work
|
// We need to keep mouse area enabled even when button is disabled to make tooltip work
|
||||||
if (root.enabled)
|
if (root.enabled)
|
||||||
|
Reference in New Issue
Block a user