diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -80,6 +80,7 @@ BrowserWindow* getWindow() const; BrowserWindow* createWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl()); + void createNonPrivateWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl()); AfterLaunch afterLaunch() const; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -452,6 +452,27 @@ return window; } +void MainApplication::createNonPrivateWindow(Qz::BrowserWindowType type, const QUrl& startUrl) +{ + if(isPrivate()){ + QUrl url = startUrl; + if (QAction* act = qobject_cast(sender())) { + url = act->data().toUrl(); + } + + QStringList args({QSL("--new-window"), QSL("--profile=") + ProfileManager::currentProfile()}); + + if (!url.isEmpty()) { + args << url.toEncoded(); + } + + if (!QProcess::startDetached(applicationFilePath(), args)) { + qWarning() << "MainApplication: Cannot start new browser process!" << applicationFilePath() << args; + } + } else createWindow(type, startUrl); +} + + MainApplication::AfterLaunch MainApplication::afterLaunch() const { return static_cast(Settings().value(QSL("Web-URL-Settings/afterLaunch"), RestoreSession).toInt()); @@ -681,21 +702,25 @@ void MainApplication::startPrivateBrowsing(const QUrl &startUrl) { - QUrl url = startUrl; - if (QAction* act = qobject_cast(sender())) { - url = act->data().toUrl(); - } + if(isPrivate()){ + createWindow(Qz::BW_NewWindow, startUrl); + }else{ + QUrl url = startUrl; + if (QAction* act = qobject_cast(sender())) { + url = act->data().toUrl(); + } - QStringList args; - args.append(QSL("--private-browsing")); - args.append(QSL("--profile=") + ProfileManager::currentProfile()); + QStringList args; + args.append(QSL("--private-browsing")); + args.append(QSL("--profile=") + ProfileManager::currentProfile()); - if (!url.isEmpty()) { - args << url.toEncoded(); - } + if (!url.isEmpty()) { + args << url.toEncoded(); + } - if (!QProcess::startDetached(applicationFilePath(), args)) { - qWarning() << "MainApplication: Cannot start new browser process for private browsing!" << applicationFilePath() << args; + if (!QProcess::startDetached(applicationFilePath(), args)) { + qWarning() << "MainApplication: Cannot start new browser process for private browsing!" << applicationFilePath() << args; + } } } diff --git a/src/lib/app/mainmenu.cpp b/src/lib/app/mainmenu.cpp --- a/src/lib/app/mainmenu.cpp +++ b/src/lib/app/mainmenu.cpp @@ -145,7 +145,7 @@ void MainMenu::newWindow() { - mApp->createWindow(Qz::BW_NewWindow); + mApp->createNonPrivateWindow(Qz::BW_NewWindow); } void MainMenu::newPrivateWindow()