Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: When saving a file in Linux, the file name extension is not … #402

Merged
merged 1 commit into from
May 28, 2024

Conversation

mogoweb
Copy link
Contributor

@mogoweb mogoweb commented May 25, 2024

There are two problems when downloading file under Linux:

  1. The default file name is not given.
  2. The saved file name does not have a suffix. For example, the file name specifies "test", the file filter is "(*.pptx)", and the last saved file name does not add ".pptx". In the Linux file manager, it will be recognized as a zip package, and double-clicking it will open the compression manager.
    qcefview_save_bug

@L-Super
Copy link
Member

L-Super commented May 25, 2024

I‘m working well on Linux. And you will not receive the path from the CEF correctly

@mogoweb
Copy link
Contributor Author

mogoweb commented May 26, 2024

I‘m working well on Linux. And you will not receive the path from the CEF correctly
The path is given by the server. You can try the web: https://ai.zhongshu.tech/ai-assistant/#/?key=AI , After finishing the ppt, the server gave a Chinese ppt name.

@mogoweb
Copy link
Contributor Author

mogoweb commented May 26, 2024

I‘m working well on Linux. And you will not receive the path from the CEF correctly

qcefview_save_bug2
qcefview_save_bug3
qcefview_save_bug4
qcefview_save_bug5
qcefview_save_bug6
qcefview_save_bug7
It can be seen that the default file name given by the web page is not set to the save dialog box. If the pptx suffix is not added to the save dialog box, the last file name saved will not have a suffix and will be considered a compressed file by the system.

@L-Super
Copy link
Member

L-Super commented May 26, 2024

image
And on Deepin:
image
image

@mogoweb
Copy link
Contributor Author

mogoweb commented May 27, 2024

image And on Deepin: image image

image And on Deepin: image image

I have tested it on Ubuntu 20.04, Kylin OS v10, and UOS V20 systems, and there are problems in all of them. As shown in the first picture, although the filters are pptx, the final saved file does not have the pptx suffix. You can also review the implementation logic of QCefViewPrivate::onFileDialog.

In fact, judging from your screenshot, there is also a problem. The save dialog box does not automatically fill in the suggested file name. Also, try forcibly removing the suffix from the file name and see if the suffix is automatically added after saving.

@tishion
Copy link
Member

tishion commented May 27, 2024

hi @mogoweb, thanks for the contribution to QCefView, this PR seems to be a good workaround of QT bugs.
https://bugreports.qt.io/browse/QTBUG-27186?focusedCommentId=438699&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

bu as of the QCefView, I think we'd better not add this logic into the under-layer implementation. I suggest we expose a new virtual method

QCefView::onFileDialog

to the consumer.
With this capability the consumer of QCefView can implement their own preferred logic in their own code scope as they need.

Do you think this is better solution?

@mogoweb
Copy link
Contributor Author

mogoweb commented May 27, 2024

hi @mogoweb, thanks for the contribution to QCefView, this PR seems to be a good workaround of QT bugs. https://bugreports.qt.io/browse/QTBUG-27186?focusedCommentId=438699&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

bu as of the QCefView, I think we'd better not add this logic into the under-layer implementation. I suggest we expose a new virtual method

QCefView::onFileDialog

to the consumer. With this capability the consumer of QCefView can implement their own preferred logic in their own code scope as they need.

Do you think this is better solution?

Sounds like very good advice. I'm actually a little confused, why is this behavior of saving files only implemented by users under Linux?

image

如果由用户来实现保存逻辑,这个保存逻辑应该在所有平台下都可以给用户自己实现的机会。

@tishion
Copy link
Member

tishion commented May 27, 2024

hi @mogoweb, thanks for the contribution to QCefView, this PR seems to be a good workaround of QT bugs. https://bugreports.qt.io/browse/QTBUG-27186?focusedCommentId=438699&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel
bu as of the QCefView, I think we'd better not add this logic into the under-layer implementation. I suggest we expose a new virtual method

QCefView::onFileDialog

to the consumer. With this capability the consumer of QCefView can implement their own preferred logic in their own code scope as they need.
Do you think this is better solution?

Sounds like very good advice. I'm actually a little confused, why is this behavior of saving files only implemented by users under Linux?

image

如果由用户来实现保存逻辑,这个保存逻辑应该在所有平台下都可以给用户自己实现的机会。

CEF offers a callback method for managing dialog processing logic, allowing users to present their own file dialog with custom logic.

https://github.com/chromiumembedded/cef/blob/bc1b856b96067c59fa51bc3498b2a6597dc4af44/include/cef_dialog_handler.h#L75-L99

If users prefer to utilize CEF's built-in file dialog logic, they simply need to return false in this callback.

Regrettably, the default implementation is missing on the Linux platform, so QCefView just provide a default Implementation with Qt.

@mogoweb
Copy link
Contributor Author

mogoweb commented May 27, 2024

hi @mogoweb, thanks for the contribution to QCefView, this PR seems to be a good workaround of QT bugs. https://bugreports.qt.io/browse/QTBUG-27186?focusedCommentId=438699&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel
bu as of the QCefView, I think we'd better not add this logic into the under-layer implementation. I suggest we expose a new virtual method

QCefView::onFileDialog

to the consumer. With this capability the consumer of QCefView can implement their own preferred logic in their own code scope as they need.
Do you think this is better solution?

Sounds like very good advice. I'm actually a little confused, why is this behavior of saving files only implemented by users under Linux?
image
如果由用户来实现保存逻辑,这个保存逻辑应该在所有平台下都可以给用户自己实现的机会。

CEF offers a callback method for managing dialog processing logic, allowing users to present their own file dialog with custom logic.

https://github.com/chromiumembedded/cef/blob/bc1b856b96067c59fa51bc3498b2a6597dc4af44/include/cef_dialog_handler.h#L75-L99

If users prefer to utilize CEF's built-in file dialog logic, they simply need to return false in this callback.

Regrettably, the default implementation is missing on the Linux platform, so QCefView just provide a default Implementation with Qt.

If the onFileDialog method is added to QCefView, how to handle the callback? The CefRefPtr callback also needs to be encapsulated, which feels a bit troublesome.

Are you sure you want to do this?

@tishion
Copy link
Member

tishion commented May 28, 2024

Hi @mogoweb I will complete this PR currently, maybe I will address a PR to reform the code as we discussed above.
Thanks

@tishion tishion merged commit 57aac89 into CefView:main May 28, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants