aboutsummaryrefslogtreecommitdiff
path: root/webengine.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'webengine.hpp')
-rw-r--r--webengine.hpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/webengine.hpp b/webengine.hpp
index dc73d97..38bacf4 100644
--- a/webengine.hpp
+++ b/webengine.hpp
@@ -17,6 +17,8 @@
#error "(The moc has changed too much.)"
#endif
+#include <unistd.h>
+
class WebEnginePage: public QWebEnginePage {
Q_OBJECT
public:
@@ -24,7 +26,7 @@ public:
virtual ~WebEnginePage() = default;
protected:
- QWebEnginePage *createWindow(WebWindowType){
+ QWebEnginePage *createWindow(WebWindowType type){
WebEnginePage *page = new WebEnginePage(this->profile());
connect(page, &QWebEnginePage::urlChanged, this, &WebEnginePage::onUrlChanged);
return page;
@@ -33,7 +35,24 @@ protected:
private:
void onUrlChanged(const QUrl & url){
if(WebEnginePage *page = qobject_cast<WebEnginePage *>(sender())){
- setUrl(url);
+ if (fork() == 0) {
+ std::string surl = url.toString().toStdString();
+ std::string parent_id_str = std::to_string(parent_id);
+ const char *exec[5] = { 0 };
+ exec[0] = "sb";
+ exec[1] = surl.c_str();
+
+ if (parent_id != 0) {
+ exec[2] = "-e";
+ exec[3] = parent_id_str.c_str();
+ }
+
+ fprintf(stderr, "spawn url: %s", exec[1]);
+ execvp((char*)exec[0], (char**)exec);
+ fprintf(stderr, "failed to open new sb instance\n");
+ perror(" failed");
+ exit(-1);
+ }
page->deleteLater();
}
}