Qt's QAbstractAnimation realizes Netease cloud music background wall picture rotation effect (2)

Qt's QAbstractAnimation realizes the picture rotation effect of NetEase cloud music background wall, developed with Qt5.9.1, welcome to download and use, welcome to correct any deficiencies.

File: n459.com/file/25127180-479069053

The following are irrelevant:

-------------------------------------------Dividing line----- ----------------------------------------

IE browser supports direct reading and writing of clipboard content:

1 window.clipboardData.clearData();
2 window.clipboardData.setData('Text','abcd');
But this method is not safe and it is easy to leak the user's privacy, so now browsers such as chrome do not support this Way out.

Read the system clipboard. I
checked a lot of information. If you paste the system clipboard content, the premise is to read the system clipboard content first.

Get the event object: The paste event provides a clipboardData attribute. If the attribute has an items attribute, you can check whether there is picture type data in the items. However, it does not support folders to copy files such as pictures and words. You can assign text content and screenshot content.

     //覆盖浏览器粘贴事件
    document.addEventListener('paste', function (e) {
        var clipboardData = e.clipboardData;
        if (!(clipboardData && clipboardData.items)) {//是否有粘贴内容
            return;
        }
        for (var i = 0, len = clipboardData.items.length; i < len; i++) {
            var item = clipboardData.items[i];
            if (item.kind === "string" && item.type == "text/plain") {
                item.getAsString(function (str) {
                    // str 是获取到的字符串,创建文本框
                    //处理粘贴的文字内容
                })
            } else if (item.kind === "file") {//file 一般是各种截图base64数据
                var pasteFile = item.getAsFile();
                // pasteFile就是获取到的文件
                var reader = new FileReader();
                reader.onload = function (event) {
                    var base64Img = event.target.result;
                }; // data url  
                reader.readAsDataURL(pasteFile);
            }
            var copy_content = e.clipboardData.getData('text/plain');
        }
    })


The resources found by writing to the system clipboard are all setData directly in the event object, but the actual test has no effect.

e.clipboardData.setData('text/plain', defaultText); The
following provides two measured effective setting methods:

1) Monitor the copy event and trigger the copy command

If you set event.clipboardData.setData directly after ctrl+C monitors the keystrokes, it will not take effect. You must write clipboardData after triggering the copy command.

But remember to removeEventListener, otherwise it will affect your copy in other places.

1 document.addEventListener("paste", function (e) { 2 console.log(e.clipboardData.getData("text")); 3 }); 4 document.onkeydown = function (e) { 5 if (e. ctrlKey && e.keyCode == 67) {//ctrl+C 6 function handler(event) { 7 event.clipboardData.setData('text/plain', "Custom Copy Content"); 8 document.removeEventListener('copy ', Handler, to true); . 9 the event.preventDefault (); 10} . 11 document.addEventListener (' copy ', Handler, to true); 12 is document.execCommand (' copy '); 13 is} 14} copy the code 2) by Assign the content to be copied to the text, select the content of the text box, and execute the copy command














1 //复制
2 document.onkeydown = function (e) {
3 if (e.ctrlKey && e.keyCode == 86) {//ctrl+V
4 var cloneActiveElement = “需要复制的内容”;
5 var copyText = document.getElementById(“copy_text”);
6 copyText.innerHTML = cloneActiveElement;
7 copyText.readOnly = false;
8 copyText.select();
9 copyText.setSelectionRange(0, copyText.value.length);
10 document.execCommand(“copy”);
11 copyText.readOnly = true;
12 }

Guess you like

Origin blog.csdn.net/gumenghua_com1/article/details/112601307