Kaynağa Gözat

Fixed desktop cloning bug, added Ctrl C V support on desktop and fixed file opr dialog bug

Toby Chui 3 yıl önce
ebeveyn
işleme
7c457a59be

+ 5 - 5
web/SystemAO/file_system/file_operation.html

@@ -276,9 +276,8 @@
                         if (progress.Error != ""){
                             //Something went wrong
                             $("#progressbar").css("background-color", "#eb3f28");
-                            $("#opricon").attr("src", "img/error.png");
                             enterErrorMode = true;
-                            alert(progress.Error);
+                            handleFinish({error: progress.Error});
                         }else{
                             //Update the progress display
                             $("#progressbar").css("width", progress.Progress + "%");
@@ -376,7 +375,7 @@
                             //Something went wrong
                             $("#progressbar").css("background-color", "#eb3f28");
                             enterErrorMode = true;
-                            alert(progress.Error);
+                            handleFinish({error: progress.Error});
                         }else{
                             //Update the progress display
                             $("#progressbar").css("width", progress.Progress + "%");
@@ -453,7 +452,7 @@
                         if (progress.Error != ""){
                             $("#progressbar").css("background-color", "#eb3f28");
                             enterErrorMode = true;
-                            alert(progress.Error);
+                            handleFinish({error: progress.Error});
                            
                         }else{
                             $("#progressbar").css("width", progress.Progress + "%");
@@ -534,7 +533,7 @@
                         if (progress.Error != ""){
                             $("#progressbar").css("background-color", "#eb3f28");
                             enterErrorMode = true;
-                            alert(progress.Error);
+                            handleFinish({error: progress.Error});
                         }else{
                             $("#progressbar").css("width", progress.Progress + "%");
                             var currentSrc = truncate(operationConfig.src + "/" + progress.LatestFile, maxPathDisplayLength);
@@ -642,6 +641,7 @@
                     $("#progressbar").css("background-color","#db2828");
                     $("#progressbar").parent().removeClass('active');
                     $(".title").html(`<i class="remove icon"></i>` + applocale.getString("error/" + data.error,data.error));
+                    $("#opricon").attr("src", "img/error.png");
                     enterErrorMode = true;
                     return
                 }else{

+ 9 - 0
web/SystemAO/locale/desktop.json

@@ -48,6 +48,9 @@
                 "contextmenu/Properties": "內容",
                 "contextmenu/Share": "分享",
                 "contextmenu/Download": "下載",
+                "contextmenu/Copy": "複製",
+                "contextmenu/Cut": "剪下",
+                "contextmenu/Paste Here": "貼上至此",
                 "contextmenu/Rename": "重新命名",
                 "contextmenu/Zip here": "壓縮至此",
                 "contextmenu/Open in New Tab": "在新分頁開啟",
@@ -141,6 +144,9 @@
                 "contextmenu/Properties": "內容",
                 "contextmenu/Share": "分享",
                 "contextmenu/Download": "下載",
+                "contextmenu/Copy": "複製",
+                "contextmenu/Cut": "剪下",
+                "contextmenu/Paste Here": "貼上至此",
                 "contextmenu/Rename": "重新命名",
                 "contextmenu/Zip here": "壓縮至此",
                 "contextmenu/Open in New Tab": "在新分頁開啟",
@@ -235,6 +241,9 @@
                 "contextmenu/Properties": "内容",
                 "contextmenu/Share": "分享",
                 "contextmenu/Download": "下载",
+                "contextmenu/Copy": "拷貝",
+                "contextmenu/Cut": "剪切",
+                "contextmenu/Paste Here": "粘贴至此",
                 "contextmenu/Rename": "重新命名",
                 "contextmenu/Zip here": "压缩至此",
                 "contextmenu/Open in New Tab": "在新分页打开",

+ 3 - 0
web/SystemAO/locale/file_operation.json

@@ -25,6 +25,7 @@
                 "title/files":" 個檔案",
                 "error/Access Denied":"存取被拒",
                 "error/Source file not exists":"來源檔案不存在",
+                "error/Source and destination paths are identical.":"目的地與來源資料位置相同",
                 "error/Storage Quota Full":"儲存空間已滿",
                 "error/Dest folder not found":"目標資料夾不存在",
                 "error/Undefined dest location":"目標路徑錯誤",
@@ -63,6 +64,7 @@
                 "title/files":" 個檔案",
                 "error/Access Denied":"存取被拒",
                 "error/Source file not exists":"來源檔案不存在",
+                "error/Source and destination paths are identical.":"目的地與來源資料位置相同",
                 "error/Storage Quota Full":"儲存空間已滿",
                 "error/Dest folder not found":"目標資料夾不存在",
                 "error/Undefined dest location":"目標路徑錯誤",
@@ -101,6 +103,7 @@
                 "title/files":" 个文件",
                 "error/Access Denied":"存取被拒",
                 "error/Source file not exists":"来源文件不存在",
+                "error/Source and destination paths are identical.":"目的地与来源资料位置相同",
                 "error/Storage Quota Full":"储存空间已满",
                 "error/Dest folder not found":"目标资料夹不存在",
                 "error/Undefined dest location":"目标路径错误",

+ 100 - 68
web/desktop.system

@@ -4491,74 +4491,13 @@
             
             }else if (keycode == "67" && ctrlHold){
                 //Ctrl + C, copy
-                var clipboard = [];
-                $(".launchIconWrapper.selected").each(function(){
-                    var object = $(this).parent();
-                    var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
-                    clipboard.push(fd.Filepath);
-                });
-
-                localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
-                localStorage.setItem("ao/file_system/cutmode","false");
+                handleCopyOperation();
              }else if (keycode == "88" && ctrlHold){
                 //Ctrl + X, cut
-                var clipboard = [];
-                $(".launchIconWrapper.selected").each(function(){
-                    var object = $(this).parent();
-                    var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
-                    clipboard.push(fd.Filepath);
-                });
-
-                localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
-                localStorage.setItem("ao/file_system/cutmode","true");
+                handleCutOperation();
             }else if (keycode == "86" && ctrlHold){
                 //Ctrl + V, Paste
-
-                //Check if there are files in clipboard
-                var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
-                var useCutMode = localStorage.getItem("ao/file_system/cutmode");
-                var fileList = [];
-                if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
-                    fileList = JSON.parse(crossFrameClipboard);
-                }
-                if (useCutMode !== "" && useCutMode !== undefined && useCutMode !== null){
-                    thisOprCutMode = (useCutMode == "true");
-                }
-
-                var mode = "copy";
-                var title = "Copying "
-                if (thisOprCutMode){
-                    mode = "move";
-                    title = "Moving "
-                }
-
-                if (fileList.length > 0){
-                    //There are something to move. Start the file operation dialog
-                    var oprConfig = {
-                        opr: mode,
-                        src: fileList,
-                        dest: "user:/Desktop/",
-                        overwriteMode: "ask"
-                    }
-                    var configHash = encodeURIComponent(JSON.stringify(oprConfig));
-
-                    //Genreate window title
-                    var title = title + fileList.length;
-                    if (fileList.length > 1){
-                        title += " files";
-                    }else{
-                        title += " file";
-                    }
-
-                    newFloatWindow({
-                        url: "SystemAO/file_system/file_operation.html#" + configHash,
-                        width: 400,
-                        height: 220,
-                        appicon: "SystemAO/file_system/img/selector.png",
-                        title: title
-                    });
-                }
-
+                handlePasteOperation();
             }else{
                 //console.log(event.which);
             }
@@ -4647,7 +4586,8 @@
                             //addContextMenuItem($("#contextmenu"), 'Share', "<i class='caret right icon'></i>", "handleFileShare", true);
                             addContextMenuSeperator($("#contextmenu"));
                             addContextMenuItem($("#contextmenu"), lcontex('Download in Zip'), "<i class='download icon'></i>", "downloadFile", false);
-                            addContextMenuItem($("#contextmenu"), lcontex('Make a Copy'), "<i class='copy icon'></i>", "handleCloning", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Copy'), "<i class='copy icon'></i>", "handleCopyOperation", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Cut'), "<i class='cut icon'></i>", "handleCutOperation", false);
                             addContextMenuItem($("#contextmenu"), lcontex('Delete'), "<i class='trash icon'></i>", "handleFileDelete", false);
                             addContextMenuSeperator($("#contextmenu"));
                             addContextMenuItem($("#contextmenu"), lcontex('Properties'), undefined, "openObjectProperty", false);
@@ -4660,7 +4600,8 @@
                             addContextMenuItem($("#contextmenu"), lcontex('Share'), "<i class='caret right icon'></i>", "handleFileShare", true);
                             addContextMenuSeperator($("#contextmenu"));
                             addContextMenuItem($("#contextmenu"), lcontex('Download'), "<i class='download icon'></i>", "downloadFile", false);
-                            addContextMenuItem($("#contextmenu"), lcontex('Make a Copy'), "<i class='copy icon'></i>", "handleCloning", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Copy'), "<i class='copy icon'></i>", "handleCopyOperation", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Cut'), "<i class='cut icon'></i>", "handleCutOperation", false);
                             addContextMenuItem($("#contextmenu"), lcontex('Rename'), undefined, "handleRename", false);
                             addContextMenuItem($("#contextmenu"), lcontex('Delete'), "<i class='trash icon'></i>", "handleFileDelete", false);
                             addContextMenuSeperator($("#contextmenu"));
@@ -4672,7 +4613,8 @@
                             addContextMenuItem($("#contextmenu"), lcontex('Share'), "<i class='caret right icon'></i>", "handleFileShare", true);
                             addContextMenuSeperator($("#contextmenu"));
                             addContextMenuItem($("#contextmenu"), lcontex('Download as Zip'), "<i class='download icon'></i>", "downloadFile", false);
-                            addContextMenuItem($("#contextmenu"), lcontex('Make a Copy'), "<i class='caret right icon'></i>", "handleCloning", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Copy'), "<i class='copy icon'></i>", "handleCopyOperation", false);
+                            addContextMenuItem($("#contextmenu"), lcontex('Cut'), "<i class='cut icon'></i>", "handleCutOperation", false);
                             addContextMenuItem($("#contextmenu"), lcontex('Rename'), undefined, "handleRename", false);
                             addContextMenuItem($("#contextmenu"), lcontex('Delete'), "<i class='trash icon'></i>", "handleFileDelete", false);
                             addContextMenuSeperator($("#contextmenu"));
@@ -4713,7 +4655,9 @@
                     addContextMenuItem($("#contextmenu"), lcontex('New'), "<i class='caret right icon'></i>", "newitemmenu", true);
                     addContextMenuItem($("#contextmenu"), lcontex('Refresh'), "<i class='refresh icon'></i>", "handleMenuRefresh", false);
                     addContextMenuItem($("#contextmenu"), lcontex('Open File Manager'), undefined, "openfm", false);
-                    //addContextMenuItem($("#contextmenu"), 'Get File from URL', "<i class='download icon'></i>", "downloadURL", false);
+                    if (checkFileInClipboard()){
+                        addContextMenuItem($("#contextmenu"), lcontex('Paste Here'), "<i class='paste icon'></i>", "handlePasteOperation", false);
+                    }
                     addContextMenuItem($("#contextmenu"), lcontex('Personalization'), "<i class='paint brush icon'></i>", "personalization", false);
                     addContextMenuItem($("#contextmenu"), lcontex('Background'), "<i class='caret right icon'></i>", "background", true);
                     addContextMenuItem($("#contextmenu"), lcontex('Icon Size'), "<i class='caret right icon'></i>", "listIconsize", true);
@@ -5564,6 +5508,94 @@
             hideAllContextMenus();
         }
 
+        function handleCopyOperation(){
+            var clipboard = [];
+            $(".launchIconWrapper.selected").each(function(){
+                var object = $(this).parent();
+                var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
+                clipboard.push(fd.Filepath);
+            });
+
+            localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
+            localStorage.setItem("ao/file_system/cutmode","false");
+
+            hideAllContextMenus();
+        }
+
+        function handleCutOperation(){
+            var clipboard = [];
+            $(".launchIconWrapper.selected").each(function(){
+                var object = $(this).parent();
+                var fd = JSON.parse(decodeURIComponent($(object).attr("filedata")));
+                clipboard.push(fd.Filepath);
+            });
+
+            localStorage.setItem("ao/file_system/clipboard",JSON.stringify(clipboard));
+            localStorage.setItem("ao/file_system/cutmode","true");
+
+            hideAllContextMenus();
+        }
+
+        function checkFileInClipboard(){
+            //Check if there are files in clipboard
+            var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
+            var useCutMode = localStorage.getItem("ao/file_system/cutmode");
+            var fileList = [];
+            if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
+                fileList = JSON.parse(crossFrameClipboard);
+            }
+            
+            return fileList.length > 0;
+        }
+
+        function handlePasteOperation(){
+            //Check if there are files in clipboard
+            var crossFrameClipboard = localStorage.getItem("ao/file_system/clipboard");
+            var useCutMode = localStorage.getItem("ao/file_system/cutmode");
+            var fileList = [];
+            if (crossFrameClipboard !== "" && crossFrameClipboard !== undefined && crossFrameClipboard !== null){
+                fileList = JSON.parse(crossFrameClipboard);
+            }
+            if (useCutMode !== "" && useCutMode !== undefined && useCutMode !== null){
+                thisOprCutMode = (useCutMode == "true");
+            }
+
+            var mode = "copy";
+            var title = "Copying "
+            if (thisOprCutMode){
+                mode = "move";
+                title = "Moving "
+            }
+
+            if (fileList.length > 0){
+                //There are something to move. Start the file operation dialog
+                var oprConfig = {
+                    opr: mode,
+                    src: fileList,
+                    dest: "user:/Desktop/",
+                    overwriteMode: "ask"
+                }
+                var configHash = encodeURIComponent(JSON.stringify(oprConfig));
+
+                //Genreate window title
+                var title = title + fileList.length;
+                if (fileList.length > 1){
+                    title += " files";
+                }else{
+                    title += " file";
+                }
+
+                newFloatWindow({
+                    url: "SystemAO/file_system/file_operation.html#" + configHash,
+                    width: 400,
+                    height: 220,
+                    appicon: "SystemAO/file_system/img/selector.png",
+                    title: title
+                });
+            }
+            hideAllContextMenus();
+        }
+
         //New item menus.
         function newitemmenu(target, event) {
             $("#subcontextmenu").html("");