-
Notifications
You must be signed in to change notification settings - Fork 150
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 popup window logic - use CEF built-in popup management #303
Conversation
tishion
commented
Aug 26, 2023
- 重新实现popup browser的逻辑
- 使用CEF内置的popup 生命周期管理逻辑
- onBeforePopup 方法提供允许/禁止弹出窗口的拦截时机,可以重载该函数,返回true/false来控制,以及在该方法内设置一些参数
- onPopupCreated 方法提供自定义已经弹出的popup browser的能力
macOS和Linux没有测试过 |
@L-Super review一下 |
ASAP,我抽时间测试一下Linux 平台 |
QCefSettingPrivate::CopyFromCefBrowserSettings(&s, &settings); | ||
bool cancelPopup = q->onBeforePopup(frameId, url, name, d, rc, s, disableJavascript); | ||
QCefSettingPrivate::CopyToCefBrowserSettings(&s, &settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不理解为什么还要再调用一次CopyToCefBrowserSettings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
先把CefSettings转为QCefSetting,然后吧QCefSetting传给用户,用户可能需要修改setting,然后再把用户的修改copy回CefSetting,再传回给CEF
void | ||
QCefView::onPopupCreated(QWidget* popup, const QString& url, const QString& name) | ||
{ | ||
// create a top level window container | ||
QMainWindow* popupWin = new QMainWindow(); | ||
popupWin->setAttribute(Qt::WA_DeleteOnClose, true); | ||
popupWin->setWindowTitle(name); | ||
popupWin->resize(popup->size()); | ||
|
||
// add the popup browser widget into the window | ||
popupWin->setCentralWidget(popup); | ||
|
||
// show window | ||
popupWin->show(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一段是为了向外提供重写的接口吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数是提供给用户重载用的,内部的默认实现是创建一个顶层窗口来放置popup,用户可能有其他的实现需求,比如放到别的tab里面。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那实际上应该不需要吧,是否可以通过注释告诉用户可以这样重载使用?
这个实现在Linux NCW模式下还是不行,主要是Linux的UI系统问题。 |
通过Qt还是无法隔离Linux UI的问题吗 |