Warning, /maui/arca/src/controls/ArchivePage.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.15 0002 import QtQml 2.15 0003 import QtQuick.Controls 2.15 0004 import QtQuick.Layouts 1.12 0005 0006 import org.mauikit.controls 1.3 as Maui 0007 import org.mauikit.filebrowsing 1.3 as FM 0008 0009 import org.kde.arca 1.0 as Arca 0010 0011 Maui.Page 0012 { 0013 0014 id: control 0015 title: _manager.model.fileName || root.title 0016 0017 property alias url : _manager.url 0018 0019 showTitle: false 0020 0021 Arca.CompressedFile 0022 { 0023 id: _manager 0024 0025 onCompressionFinished: 0026 { 0027 if(ok) 0028 { 0029 root.notify("dialog-warning", i18n("Archive Ready"), i18n("The new file is now ready.")) 0030 }else 0031 { 0032 root.notify("dialog-error", i18n("Failed"), i18n("The archive could not be created.")) 0033 } 0034 } 0035 0036 onExtractionFinished: 0037 { 0038 if(ok) 0039 { 0040 root.notify("dialog-warning", i18n("Extraction Ready"), i18n("The archive contents have been extracted.")) 0041 }else 0042 { 0043 root.notify("dialog-error", i18n("Failed"), i18n("The extraction has failed.")) 0044 } 0045 } 0046 } 0047 0048 headBar.middleContent: Maui.SearchField 0049 { 0050 Layout.maximumWidth: 500 0051 Layout.fillWidth: true 0052 Layout.alignment: Qt.AlignCenter 0053 enabled: _manager.model.count > 1 0054 0055 placeholderText: i18np("Search", "Search %1 files", _manager.model.count ); 0056 onAccepted: 0057 { 0058 if(text.includes(",")) 0059 { 0060 _archiveModel.filters = text.split(",") 0061 }else 0062 { 0063 _archiveModel.filter = text 0064 } 0065 } 0066 0067 onCleared: _archiveModel.clearFilters() 0068 } 0069 0070 headBar.leftContent: [ 0071 0072 Maui.ToolButtonMenu 0073 { 0074 icon.name: "archive-extract" 0075 enabled: _manager.model.opened 0076 0077 MenuItem 0078 { 0079 text: i18n("Extract") 0080 } 0081 0082 MenuItem 0083 { 0084 text: i18n("Extract to...") 0085 } 0086 }, 0087 0088 ToolButton 0089 { 0090 icon.name: "archive-insert" 0091 enabled: _manager.model.opened 0092 onClicked: control.insertFiles() 0093 } 0094 ] 0095 0096 headBar.rightContent: [ 0097 0098 ToolButton 0099 { 0100 icon.name: "go-up" 0101 onClicked: _manager.model.goUp() 0102 enabled: _manager.model.canGoUp 0103 }, 0104 0105 ToolButton 0106 { 0107 icon.name: "folder-root" 0108 onClicked: _manager.model.goToRoot() 0109 enabled: _manager.model.opened 0110 }, 0111 0112 Maui.ToolButtonMenu 0113 { 0114 icon.name: "view-sort" 0115 0116 MenuItem 0117 { 0118 autoExclusive: true 0119 text: i18n("Name") 0120 checked : _archiveModel.sort === "label" 0121 onTriggered: _archiveModel.sort = "label" 0122 } 0123 0124 MenuItem 0125 { 0126 autoExclusive: true 0127 text: i18n("Date") 0128 checked : _archiveModel.sort === "date" 0129 onTriggered: _archiveModel.sort = "date" 0130 } 0131 0132 MenuItem 0133 { 0134 autoExclusive: true 0135 text: i18n("Size") 0136 checked : _archiveModel.sort === "size" 0137 onTriggered: _archiveModel.sort = "size" 0138 } 0139 0140 } 0141 0142 ] 0143 0144 Maui.ListBrowser 0145 { 0146 id: _browser 0147 anchors.fill: parent 0148 model: Maui.BaseModel 0149 { 0150 id: _archiveModel 0151 sort: "label" 0152 sortOrder: Qt.AscendingOrder 0153 recursiveFilteringEnabled: true 0154 sortCaseSensitivity: Qt.CaseInsensitive 0155 filterCaseSensitivity: Qt.CaseInsensitive 0156 list: _manager.model 0157 } 0158 0159 0160 holder.visible: _browser.count === 0 0161 holder.emoji: "archive-insert" 0162 holder.title: i18n("Compress") 0163 holder.body: i18n("Drop files in here to compress them.") 0164 0165 delegate: Maui.ListBrowserDelegate 0166 { 0167 width: ListView.view.width 0168 0169 label1.text: model.label 0170 // label2.text: model.path 0171 label2.text: Qt.formatDateTime(new Date(model.date), "d MMM yyyy") 0172 // label4.text: Maui.Handy.formatSize(model.size) 0173 iconSource: model.icon 0174 0175 onClicked: 0176 { 0177 if(Maui.Handy.singleClick) 0178 { 0179 _browser.currentIndex = index 0180 openItem(_browser.model.get(index)) 0181 } 0182 0183 } 0184 0185 onDoubleClicked: 0186 { 0187 if(!Maui.Handy.singleClick) 0188 { 0189 _browser.currentIndex = index 0190 openItem(_browser.model.get(index)) 0191 } 0192 } 0193 0194 onRightClicked: 0195 { 0196 _browser.currentIndex = index 0197 _menu.item = _browser.model.get(index) 0198 _menu.show() 0199 } 0200 } 0201 0202 0203 Maui.ContextualMenu 0204 { 0205 id: _menu 0206 0207 property var item 0208 0209 MenuItem 0210 { 0211 text: i18n("Preview") 0212 icon.name: "quickopen" 0213 onTriggered: root.previewFile(_menu.item.path) 0214 } 0215 0216 MenuItem 0217 { 0218 text: i18n("Open") 0219 icon.name: "document-open" 0220 } 0221 0222 MenuItem 0223 { 0224 text: i18n("Open with") 0225 } 0226 0227 MenuSeparator{} 0228 0229 MenuItem 0230 { 0231 text: i18n("Delete") 0232 icon.name: "entry-delete" 0233 } 0234 } 0235 } 0236 0237 Item 0238 { 0239 visible: _dropArea.containsDrag 0240 anchors.fill: parent 0241 0242 Rectangle 0243 { 0244 anchors.fill: parent 0245 color: Maui.Theme.backgroundColor 0246 opacity: 0.8 0247 } 0248 0249 Maui.Holder 0250 { 0251 anchors.fill: parent 0252 visible: true 0253 title: i18n("Add here") 0254 body: i18n("Drop files in here to add them to the archive.") 0255 emoji: "archive-insert" 0256 } 0257 } 0258 0259 DropArea 0260 { 0261 id: _dropArea 0262 anchors.fill: parent 0263 0264 onDropped: 0265 { 0266 if(drop.hasUrls) 0267 { 0268 var urls = drop.urls.join(",").split(",") 0269 console.log("DROP URLS", urls ) 0270 _manager.model.addFiles(urls, _manager.model.currentPath); 0271 } 0272 0273 } 0274 } 0275 0276 function openItem(item) 0277 { 0278 if(item.isdir === "true") 0279 { 0280 _manager.model.openDir(item.path) 0281 0282 }else 0283 { 0284 var url = _manager.model.temporaryFile(item.path) 0285 previewFile(url) 0286 } 0287 } 0288 0289 function insertFiles() 0290 { 0291 _dialogLoader.sourceComponent = _fileDialogComponent 0292 dialog.mode = dialog.modes.OPEN 0293 dialog.settings.filterType= FM.FMList.NONE 0294 dialog.callback = (paths) => { 0295 0296 _manager.model.addFiles(paths, _manager.model.currentPath); 0297 0298 } 0299 0300 dialog.open() 0301 } 0302 0303 function create(files, path, name, type) 0304 { 0305 _manager.compress(files, path, name, type) 0306 } 0307 }