提交 3a6d997f 编写于 作者: P peterq

fix pc: crash in mac

上级 0cbc8172
import QtQuick 2.0
import "../comps"
Item {
id: root
property var tasbs: Object.keys(tasbsMap)
property var tasbsMap: {
"newest": '最新',
"hottest": '最热',
"official": '官方'
}
property string currentTab: 'newest'
signal active
onCurrentTabChanged: {
listRepeater.itemAt(tasbs.indexOf(currentTab)).active()
}
onActive: {
listRepeater.itemAt(tasbs.indexOf(currentTab)).active()
}
DataSaver {
$key: 'page-explorer'
property alias showTip: tip.showTip
}
Column {
anchors.fill: parent
Rectangle {
id: tip
property string showTip: 'show'
visible: showTip === 'show'
color: '#409EFF'
width: parent.width
height: visible ? textTip.implicitHeight + 20 : 0
Text {
id: textTip
color: 'white'
width: parent.width - 40
anchors.centerIn: parent
wrapMode: Text.WrapAnywhere
text: '开放型的资源广场, 突破版权文件分享限制(被和谐的违规文件除外).实验性功能, 暂只支持分享大于256k的文件.'
}
IconButton {
iconType: 'close'
color: 'red'
anchors.right: parent.right
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
onClicked: {
tip.showTip = ''
}
}
}
Rectangle {
id: tabsBar
width: parent.width
height: 60
Rectangle {
width: parent.width
height: 1
color: '#ddd'
anchors.bottom: parent.bottom
}
Item {
id: typeTab
property int padding: 4
property int tabWidth: 80
width: tabWidth * tabs.length + 2 * padding
height: parent.height * 0.7
anchors.verticalCenter: parent.verticalCenter
x: 10
Rectangle {
anchors.fill: parent
radius: 3
color: '#eee'
}
Rectangle {
radius: 3
width: typeTab.tabWidth
height: typeTab.height - 2 * typeTab.padding
color: '#fff'
anchors.verticalCenter: parent.verticalCenter
x: typeTab.padding + root.tasbs.indexOf(
root.currentTab) * typeTab.tabWidth
Behavior on x {
PropertyAnimation {
duration: 400
easing.type: Easing.OutCubic
}
}
}
Repeater {
model: root.tasbs
delegate: Item {
width: typeTab.tabWidth
height: typeTab.height - 2 * typeTab.padding
anchors.verticalCenter: parent.verticalCenter
x: typeTab.padding + index * typeTab.tabWidth
Text {
text: root.tasbsMap[modelData]
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
root.currentTab = modelData
}
}
}
}
}
}
Repeater {
id: listRepeater
model: root.tasbs
ShareList {
id: shareList
type: modelData
height: parent.height - tip.height - tabsBar.height
width: parent.width
visible: root.currentTab == type
}
}
}
}
import QtQuick 2.0
import '../videoPlayer'
import '../js/app.js' as App
import '../js/util.js' as Util
import '../comps'
import './left-panel'
Rectangle {
id: root
signal active
// 左侧信息栏
LeftPanel {
id: leftPanel
height: parent.height
width: 250
// 右侧border
Rectangle {
color: 'gray'
width: 2
height: parent.height
anchors.right: parent.right
}
}
// 头部加列表
Rectangle {
anchors.left: leftPanel.right
width: root.width - leftPanel.width
height: parent.height
PathNav {
id: pathNav
width: parent.width
height: 40
// 下侧border
Rectangle {
color: 'gray'
width: parent.width
height: 2
anchors.bottom: parent.bottom
}
}
FileList {
width: parent.width
height: parent.height - pathNav.height
anchors.top: pathNav.bottom
color: "#fff"
Rectangle {
id: loading
anchors.fill: parent
visible: false
color: Qt.rgba(1,1,1,.6)
Component {
id: iconComp
IconFont {
type: 'loading'
width: Math.min(loading.width, loading.height) * 0.3
}
}
Loader {
id: iconLoader
focus: true
anchors.centerIn: parent
}
Component.onCompleted: {
// 监听进入path, 延时500ms显示加载动画
App.appState.enterPathPromiseChanged.connect(function() {
if (!App.appState.enterPathPromise) {
loading.visible = false
iconLoader.sourceComponent = null
return
}
var p = App.appState.enterPathPromise
Util.sleep(500)
.then(function(){
if (App.appState.enterPathPromise === p) {
iconLoader.sourceComponent = iconComp
loading.visible = true
}
})
})
}
}
LoadDirError{}
}
}
}
import QtQuick 2.0
import "../js/app.js" as App
import "../js/util.js" as Util
Item {
id: root
signal sumSpeed(var data)
signal active
HeaderBar {
id: headerBar
}
Rectangle {
width: parent.width
height: 2
color: 'gray'
anchors.bottom: headerBar.bottom
}
DownloadList {
id: downloadingList
visible: headerBar.currentTab == '下载中'
isFinish: false
anchors.top: headerBar.bottom
width: parent.width
height: parent.height - headerBar.height
}
DownloadList {
id: downloadedList
visible: headerBar.currentTab == '已完成'
isFinish: true
anchors.top: headerBar.bottom
width: parent.width
height: parent.height - headerBar.height
}
Component.onCompleted: {
App.appState.transferComp = root
}
function addDownload(meta, useVip) {
return Util.Promise.resolve().then(function () {
var evt = {
"fid": meta.fs_id + '',
"exist": false
}
downloadingList.checkFid(evt)
if (evt.exist)
return Util.confirm()
return true
}).then(function () {
if (App.appState.settings.defaultDownloadPath)
return App.appState.settings.defaultDownloadPath
return Util.pickSavePath({
"fileName": meta.server_filename,
"defaultFolder": App.appState.settings.lastDownloadPath
})
}).then(function (savePath) {
savePath = savePath.toString()
var newFid = (useVip ? 'vip' : 'direct') + '.' + meta.fs_id
var id = Util.callGoSync('download.new', {
"fid": newFid,
"savePath": savePath
})
var obj = JSON.parse(JSON.stringify(meta))
obj.downloadId = id
var sep = Qt.platform.os == "windows" ? '\\' : '/'
var t = String.prototype.split.call(savePath, sep)
obj.newFid = newFid
obj.saveName = t.pop()
obj.savePath = savePath
obj.useVip = !!useVip
downloadingList.add(obj)
})
}
function addDownloadShare(md5, sliceMd5, fileSize, fileName) {
var fid = ['share', md5, sliceMd5, fileSize].join('.')
return Util.Promise.resolve().then(function () {
return Util.pickSavePath({
"fileName": fileName,
"defaultFolder": App.appState.settings.lastDownloadPath
})
}).then(function (savePath) {
var id = Util.callGoSync('download.new', {
"fid": fid,
"savePath": savePath
})
var obj = {
"size": fileSize,
"downloadId": id,
"newFid": fid,
"savePath": savePath,
"useVip": true,
"fileName": fileName,
"isShare": true
}
var sep = Qt.platform.os == "windows" ? '\\' : '/'
var t = String.prototype.split.call(savePath, sep)
obj.saveName = t.pop()
downloadingList.add(obj)
})
}
function deleteItem(idx, isFinish) {
var c = isFinish ? downloadedList : downloadingList
c.remove(idx)
}
function itemCompleted(idx) {
var data = JSON.parse(JSON.stringify(downloadingList.get(idx)))
downloadingList.remove(idx)
downloadedList.add(data)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册