13 Star 39 Fork 6

zjzdy / Offline-small-search

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pkg.qml 24.60 KB
一键复制 编辑 原始数据 按行查看 历史
zjzdy 提交于 2018-09-24 02:06 . Update Permission for Android 6+.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
Rectangle {
id: rectangle2
width: 720
height: 1280
color: "#f6f6f6"
property real a_max: Math.max(width,height)
property real a_min: Math.min(width,height)
property real a_pd: 0
property real a_sqrt: Math.min(Math.sqrt(a_max/1280*a_min/720),a_pd/12)
z: 0
Rectangle {
id: rectangle3
height: 100*Math.min(rectangle2.a_max/1280,a_pd/12)
color: "#f0f0f0"
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
z: 1
Text {
id: text8
text: qsTr("离线包管理")
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 45*Math.min(rectangle2.a_max/1280,a_pd/12)
}
Image {
id: image1
width: height
anchors.left: parent.left
anchors.leftMargin: 10*rectangle2.a_min/720
anchors.bottom: parent.bottom
anchors.top: parent.top
source: "qrc:/image/icon_back.png"
MouseArea {
id: mouseArea1
anchors.leftMargin: -10*rectangle2.a_min/720
anchors.rightMargin: -10*rectangle2.a_min/720
anchors.fill: parent
onClicked: {
main_widget.show_back()
main_widget.offline_pkg_list_to_data_file()
main_widget.init_search_from_offline_pkg_list()
}
}
}
Image {
id: image2
width: height
anchors.right: parent.right
anchors.rightMargin: 10*rectangle2.a_min/720
anchors.bottom: parent.bottom
anchors.top: parent.top
source: "qrc:/image/icon_add_normal.png"
MouseArea {
id: mouseArea2
anchors.leftMargin: -10*rectangle2.a_min/720
anchors.rightMargin: -10*rectangle2.a_min/720
anchors.fill: parent
onClicked: {
(Qt.platform.os == "android") ? choose_dir2.open() : choose_dir.open()
}
}
}
Image {
id: image3
width: height
anchors.right: image2.left
anchors.rightMargin: 20*rectangle2.a_min/720
anchors.bottom: parent.bottom
anchors.top: parent.top
source: "qrc:/image/icon_remove_normal.png"
MouseArea {
id: mouseArea3
anchors.rightMargin: -10*rectangle2.a_min/720
anchors.leftMargin: -10*rectangle2.a_min/720
anchors.fill: parent
onClicked: remove_all.open()
}
}
}
MessageDialog {
id: remove_all
title: qsTr("删除")
text: qsTr("是否从删除列表中全部离线包?")
standardButtons: StandardButton.Yes | StandardButton.No
onYes: main_widget.remove_all_offline_pkg()
}
MessageDialog {
id: remove_this
title: qsTr("删除")
text: qsTr("是否从删除列表中该离线包?")
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
more_info_dialog.close()
main_widget.remove_offline_pkg(path_only.text)
}
}
DefaultFileDialog {
id: choose_dir2
title: qsTr("选择离线包的pkg文件或插件包的oplu文件")
selectMultiple: false
selectExisting: true
//selectFolder: true
folder: "file://"+main_widget.get_sdcard_dir()
nameFilters: [ "离线包和插件包 (*.idx *.zim *.pkg *.oplu)" ,"离线包 (*.idx *.zim *.pkg)" ,"插件包 (*.oplu)" ,"All files (*)"]
onFolderChanged: console.log(choose_dir2.folder)
onAccepted: {
if(choose_dir2.fileUrl.toString().search(/oplu$/i) > 0)
{
var opluState = main_widget.checkOplu(choose_dir2.fileUrl);
if(opluState < 0)
{
switch (opluState)
{
case -1:
pluginError.text = qsTr("插件包文件不存在或无法打开")
break;
case -2:
pluginError.text = qsTr("这不是一个插件包文件")
break;
case -3:
pluginError.text = qsTr("不支持该版本的插件")
break;
case -4:
pluginError.text = qsTr("当前离线小搜版本过低,请升级到最新版本")
break;
default:
pluginError.text = qsTr("检查插件包时发生未知错误")
}
pluginError.open()
}
else
{
pluginWarn.fileUrl = choose_dir2.fileUrl;
switch (opluState)
{
case 0:
pluginWarn.text = qsTr("插件包签名效验失败,插件包可能被篡改、受到破坏或者插件包的签名不受信任.您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 1:
pluginWarn.text = qsTr("插件包数据MD5效验失败,且该插件包并未签名,插件包可能被篡改或者受到破坏.您将要安装的插件极可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 2:
pluginWarn.text = qsTr("插件包数据MD5效验通过,但该插件包未进行签名,插件包可能被篡改且来源未知.您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 5:
pluginWarn.text = qsTr("插件包签名效验成功,该插件经过一定检查,但仍不保证完全安全,如果选择安装,则由您承担所有风险和后果,请问是否确认安装?")
break;
default:
pluginWarn.text = qsTr("您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果,请问是否确认安装?")
}
pluginWarn.open()
}
}
else
main_widget.add_offline_pkg(choose_dir2.folder,true)
}
onVisibleChanged: {
if(!visible)
{
rectangle2.parent.parent.forceActiveFocus()
}
}
}
FileDialog {
id: choose_dir
title: qsTr("选择离线包的pkg文件或插件包的oplu文件")
selectMultiple: false
selectExisting: true
//selectFolder: true
sidebarVisible: false
nameFilters: [ "离线包和插件包 (*.idx *.zim *.pkg *.oplu)" ,"离线包 (*.idx *.zim *.pkg)" ,"插件包 (*.oplu)" ,"All files (*)"]
onAccepted: {
if(choose_dir.fileUrl.search(/oplu$/g) > 0)
{
var opluState = main_widget.checkOplu(choose_dir.fileUrl);
if(opluState < 0)
{
switch (opluState)
{
case -1:
pluginError.text = qsTr("插件包文件不存在或无法打开")
break;
case -2:
pluginError.text = qsTr("这不是一个插件包文件")
break;
case -3:
pluginError.text = qsTr("不支持该版本的插件")
break;
case -4:
pluginError.text = qsTr("当前离线小搜版本过低,请升级到最新版本")
break;
default:
pluginError.text = qsTr("检查插件包时发生未知错误")
}
pluginError.open()
}
else
{
pluginWarn.fileUrl = choose_dir.fileUrl;
switch (opluState)
{
case 0:
pluginWarn.text = qsTr("插件包签名效验失败,插件包可能被篡改、受到破坏或者插件包的签名不受信任.您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 1:
pluginWarn.text = qsTr("插件包数据MD5效验失败,且该插件包并未签名,插件包可能被篡改或者受到破坏.您将要安装的插件极可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 2:
pluginWarn.text = qsTr("插件包数据MD5效验通过,但该插件包未进行签名,插件包可能被篡改且来源未知.您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果(包括但不限于一切经济、道德和法律责任及其连带责任),请问是否确认安装?")
break;
case 5:
pluginWarn.text = qsTr("插件包签名效验成功,该插件经过一定检查,但仍不保证完全安全,如果选择安装,则由您承担所有风险和后果,请问是否确认安装?")
break;
default:
pluginWarn.text = qsTr("您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果,请问是否确认安装?")
}
pluginWarn.open()
}
}
else
main_widget.add_offline_pkg(choose_dir.folder,true)
}
}
MessageDialog {
id: pluginError
text: qsTr("您将要安装的插件发生错误")
standardButtons: StandardButton.Ok
}
MessageDialog {
id: pluginWarn
property string fileUrl: ""
text: qsTr("您将要安装的插件可能不安全,如果选择安装,则由您承担所有风险和后果,请问是否确认安装?")
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
pluginWarn.close()
main_widget.installPlugins(pluginWarn.fileUrl)
}
}
Rectangle {
z: 1
id: rectangle1
width: rectangle2.width
height: 60*Math.min(rectangle2.a_max/1280,a_pd/12)
color: "#ffffff"
anchors.top: rectangle3.bottom
anchors.topMargin: 0
border.width: 0
Row {
id: row2
spacing: 10*rectangle2.width/720
Text {
text: qsTr("离线包名称")
anchors.top: parent.top
anchors.topMargin: 5*Math.min(rectangle2.a_max/1280,a_pd/12)
horizontalAlignment: Text.AlignLeft
width: 450*rectangle2.width/720
verticalAlignment: Text.AlignVCenter
font.pixelSize: 40*Math.min(rectangle2.a_max/1280,a_pd/12)
}
Text {
text: qsTr("启用")
anchors.top: parent.top
anchors.topMargin: 5*Math.min(rectangle2.a_max/1280,a_pd/12)
width: 70*rectangle2.width/720
verticalAlignment: Text.AlignVCenter
font.pixelSize: 40*Math.min(rectangle2.a_max/1280,a_pd/12)
}
Text {
text: qsTr(" 更多信息")
anchors.top: parent.top
anchors.topMargin: 5*Math.min(rectangle2.a_max/1280,a_pd/12)
width: 180*rectangle2.width/720
verticalAlignment: Text.AlignVCenter
font.pixelSize: 40*Math.min(rectangle2.a_max/1280,a_pd/12)
}
}
}
ListView {
id: listView1
anchors.top: rectangle1.bottom
anchors.right: parent.right
anchors.bottom: auto_check_tip.top
anchors.left: parent.left
anchors.topMargin: 0
model: offline_pkg_list
z: 0
delegate: Item {
z: -1
width: rectangle2.width
height: 60*Math.min(rectangle2.a_max/1280,a_pd/12)
Row {
id: row1
spacing: 10*rectangle2.width/720
Text {
text: model.modelData.name
width: 450*rectangle2.width/720
verticalAlignment: Text.AlignVCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 40*Math.min(rectangle2.a_max/1280,a_pd/12)
}
Image {
source: model.modelData.enable ? "qrc:/image/icon_switch_on.png" : "qrc:/image/icon_switch_off.png"
width: height*2
height: 35*Math.min(rectangle2.a_max/1280,a_pd/12)
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
rectangle2.focus = true
main_widget.check_enable_pkg(model.modelData.path)
}
}
}
Button {
anchors.verticalCenter: parent.verticalCenter
width: 180*rectangle2.width/720
text: "●●●"
background: Rectangle {
color: "#00000000"
}
onClicked: {
name_only.text = model.modelData.name
type_only.text = model.modelData.type
count_only.text = model.modelData.count
name_code_only.text = model.modelData.name_code
path_only.text = model.modelData.path
switch2.source = model.modelData.enable ? "qrc:/image/icon_switch_on.png" : "qrc:/image/icon_switch_off.png"
//more_info.visible = true
more_info_dialog.open()
rectangle2.focus = true
}
}
}
}
}
Dialog {
id: more_info_dialog
title: qsTr("离线包详细信息")
visible: false
contentItem: Rectangle {
id: more_info
visible: more_info_dialog.visible
implicitWidth: 540*rectangle2.width/720
implicitHeight: 1100*rectangle2.height/1280
parent: rectangle2
onVisibleChanged: {
if(!visible)
{
rectangle2.parent.parent.forceActiveFocus()
}
}
Keys.onBackPressed: {
more_info_dialog.close()
rectangle2.focus = true
}
Keys.onEscapePressed: {
more_info_dialog.close()
rectangle2.focus = true
}
Button {
id: button1
width: 270*rectangle2.width/720
height: 70*Math.min(rectangle2.a_max/1280,a_pd/12)
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
z: 3
Text {
id: text1
text: qsTr("确定")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 55*rectangle2.a_sqrt
}
onClicked: {
more_info_dialog.close()
rectangle2.focus = true
}
}
Button {
id: button2
width: 270*rectangle2.width/720
height: 70*Math.min(rectangle2.a_max/1280,a_pd/12)
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
z: 3
Text {
id: text2
text: qsTr("删除")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 55*rectangle2.a_sqrt
}
onClicked: {
remove_this.open()
}
}
Text {
id: name
text: qsTr("离线包名称:")
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 20*rectangle2.a_min/720
font.pixelSize: 35*rectangle2.a_sqrt
}
Text {
id: name_only
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: name.bottom
anchors.topMargin: 0
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
Text {
id: enable
text: qsTr("启用: ")
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.top: name_only.bottom
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
}
Image {
objectName: "enable_pkg_img"
id: switch2
width: height*2
height: 70*Math.min(rectangle2.a_max/1280,a_pd/12)
anchors.verticalCenter: enable.verticalCenter
anchors.left: enable.right
anchors.leftMargin: 30*rectangle2.a_min/720
MouseArea {
anchors.fill: parent
onClicked: {
rectangle2.focus = true
main_widget.check_enable_pkg(path_only.text)
}
}
}
Text {
id: type
text: qsTr("离线包类型:")
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: enable.bottom
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
}
Text {
id: type_only
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: type.bottom
anchors.topMargin: 0
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
Text {
id: count
text: qsTr("离线包索引总数:")
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: type_only.bottom
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
}
Text {
id: count_only
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: count.bottom
anchors.topMargin: 0
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
Text {
id: name_code
text: qsTr("离线包标识码:")
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: count_only.bottom
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
}
Text {
id: name_code_only
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720
anchors.right: parent.right
anchors.top: name_code.bottom
anchors.topMargin: 0
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
Text {
id: path
text: qsTr("离线包路径:")
textFormat: Text.PlainText
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720+(rectangle2.height > rectangle2.width ? 0 : 270*rectangle2.width/720)
anchors.right: parent.right
anchors.top: rectangle2.height > rectangle2.width ? name_code_only.bottom : parent.top
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
}
Text {
id: path_only
anchors.left: parent.left
anchors.leftMargin: 5*rectangle2.a_min/720+(rectangle2.height > rectangle2.width ? 0 : 270*rectangle2.width/720)
anchors.right: parent.right
anchors.top: path.bottom
anchors.topMargin: 0
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
Text {
id: type_info
text: qsTr("类型说明:\nST:试题包\nGSW:古诗文\nMod:功能模块\nDevDoc:开发文档,开发者文档\nUserDoc:使用文档,用户文档\nZL:资料\nOther:其他")
textFormat: Text.PlainText
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 5*rectangle2.a_min/720+(rectangle2.height > rectangle2.width ? 0 : 270*rectangle2.width/720)
anchors.top: path_only.bottom
anchors.topMargin: 20*Math.min(rectangle2.a_max/1280,a_pd/12)
font.pixelSize: 35*rectangle2.a_sqrt
wrapMode: Text.Wrap
}
}
}
Text {
id: auto_check_tip
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("提示: 把离线包放在")+main_widget.get_data_dir()+qsTr("目录中可以自动扫描添加")
font.pixelSize: 33*Math.min(rectangle2.a_max/1280,a_pd/12)
elide: Text.ElideLeft
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Text.AlignHCenter
MouseArea {
anchors.fill: parent
onClicked: main_widget.check_data_pkgs()
}
}
}
C++
1
https://gitee.com/zjzdy/Offline-small-search.git
git@gitee.com:zjzdy/Offline-small-search.git
zjzdy
Offline-small-search
Offline-small-search
master

搜索帮助