Warning, /maui/arca/src/controls/NewArchiveDialog.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.15 0002 import QtQuick.Controls 2.15 0003 import QtQuick.Layouts 1.12 0004 0005 import org.mauikit.controls 1.3 as Maui 0006 import org.mauikit.filebrowsing 1.3 as FM 0007 0008 import org.kde.arca 1.0 as Arca 0009 0010 Maui.FileListingDialog 0011 { 0012 id: control 0013 0014 persistent: false 0015 0016 message: i18n("Create a new archive file.") 0017 0018 actions:[ 0019 Action 0020 { 0021 text: i18n("Cancel") 0022 onTriggered: close() 0023 }, 0024 Action 0025 { 0026 text: i18n("Create") 0027 onTriggered: 0028 { 0029 const ok = control.checkExistance(_archiveNameField.text, _locationField.text, control.extensionName(control.type)) 0030 0031 if(!ok) 0032 { 0033 return 0034 }else 0035 { 0036 control.done(control.urls, _locationField.text, _archiveNameField.text, control.type) 0037 // control.close() 0038 } 0039 } 0040 } 0041 ] 0042 0043 onOpened: _archiveNameField.forceActiveFocus() 0044 0045 0046 signal done(var files, string path, string name, int type) 0047 0048 property int type : 0 0049 onTypeChanged: 0050 { 0051 control.checkExistance(_archiveNameField.text, _locationField.text, control.extensionName(control.type)) 0052 } 0053 0054 TextField 0055 { 0056 id: _archiveNameField 0057 Layout.fillWidth: true 0058 placeholderText: i18n("Archive name...") 0059 0060 onTextChanged: 0061 { 0062 control.checkExistance(text, _locationField.text, control.extensionName(control.type)) 0063 } 0064 } 0065 0066 TextField 0067 { 0068 id: _locationField 0069 Layout.fillWidth: true 0070 placeholderText: i18n("Location") 0071 text: Arca.Arc.defaultSaveDir 0072 0073 onTextChanged: 0074 { 0075 control.checkExistance(_archiveNameField.text, text, control.extensionName(control.type)) 0076 } 0077 } 0078 0079 Maui.ToolActions 0080 { 0081 id: compressType 0082 autoExclusive: true 0083 expanded: true 0084 display: ToolButton.TextBesideIcon 0085 0086 Action 0087 { 0088 text: ".ZIP" 0089 icon.name: "application-zip" 0090 checked: control.type === 0 0091 onTriggered: control.type = 0 0092 } 0093 0094 Action 0095 { 0096 text: ".TAR" 0097 icon.name: "application-x-tar" 0098 checked: control.type === 1 0099 onTriggered: control.type = 1 0100 } 0101 0102 Action 0103 { 0104 text: ".7ZIP" 0105 icon.name: "application-x-rar" 0106 checked: control.type === 2 0107 onTriggered: control.type = 2 0108 } 0109 } 0110 0111 function checkExistance(name, path, extension) 0112 { 0113 if(!FM.FM.fileExists(path)) 0114 { 0115 control.alert(i18n("Base location does not exists. Try with a different location."), 2) 0116 return false 0117 } 0118 0119 if(name.length === 0) 0120 { 0121 control.alert(i18n("File name can not be empty."), 2) 0122 return fals 0123 } 0124 0125 var file = path+"/"+name+extension 0126 var exists = FM.FM.fileExists(file) 0127 0128 if(exists) 0129 { 0130 control.alert(i18n("File already exists. Try with another name."), 1) 0131 return false 0132 } 0133 0134 control.alert(i18n("Looks good"), 0) 0135 return true 0136 } 0137 0138 function extensionName(type) 0139 { 0140 var extension = "" 0141 switch(control.type) 0142 { 0143 case 0: extension = ".zip"; break; 0144 case 1: extension = ".tar"; break; 0145 case 2: extension = ".7zip"; break; 0146 } 0147 return extension; 0148 } 0149 } 0150