@@ -33,7 +33,9 @@ CFrmWebBrowser::CFrmWebBrowser(CParameterWebBrowser *pPara, QWidget *parent)
3333 , m_pFavAction(nullptr )
3434 , m_pGo(nullptr )
3535 , m_pAddPage(nullptr )
36+ , m_pAddPageIncognito(nullptr )
3637 , m_pAddWindow(nullptr )
38+ , m_pAddWindowIncognito(nullptr )
3739 , m_pDownload(nullptr )
3840 , m_pInspector(nullptr )
3941 , m_pUrl(nullptr )
@@ -118,7 +120,7 @@ CFrmWebBrowser::CFrmWebBrowser(CParameterWebBrowser *pPara, QWidget *parent)
118120
119121 m_pAddPage = m_pToolBar->addAction (QIcon::fromTheme (" add" ), tr (" Add tab page" ),
120122 this , [&](){
121- auto pView = createWindow (QWebEnginePage::WebBrowserTab);
123+ CreateWindow (QWebEnginePage::WebBrowserTab);
122124 if (!m_pPara->GetTabUrl ().isEmpty ()) {
123125 m_pUrlLineEdit->setText (m_pPara->GetTabUrl ());
124126 slotReturnPressed ();
@@ -185,34 +187,37 @@ CFrmWebBrowser::~CFrmWebBrowser()
185187 }
186188}
187189
188- QWebEngineView* CFrmWebBrowser::createWindow (QWebEnginePage::WebWindowType type)
190+ QWebEngineView* CFrmWebBrowser::CreateWindow (
191+ QWebEnginePage::WebWindowType type, bool offTheRecord)
189192{
190193 qDebug (log) << " Create window:" << type;
191194
192195 CFrmWebView* pView = nullptr ;
193196 switch (type) {
194197 case QWebEnginePage::WebBrowserTab: {
195- auto pTab = CreateTab (&pView);
198+ auto pTab = CreateTab (&pView, offTheRecord );
196199 int index = m_pTab->addTab (pTab, pView->favIcon (), tr (" New page" ));
197200 if (-1 < index)
198201 m_pTab->setCurrentIndex (index);
199202 break ;
200203 }
201204 case QWebEnginePage::WebBrowserBackgroundTab: {
202- auto pTab = CreateTab (&pView);
205+ auto pTab = CreateTab (&pView, offTheRecord );
203206 int index = m_pTab->currentIndex ();
204207 m_pTab->addTab (pTab, pView->favIcon (), tr (" New page" ));
205208 if (-1 < index)
206209 m_pTab->setCurrentIndex (index);
207210 break ;
208211 }
209212 case QWebEnginePage::WebBrowserWindow: {
210- auto pWin = CreateTab (&pView);
213+ auto pWin = CreateTab (&pView, offTheRecord );
211214 pWin->show ();
212215 break ;
213216 }
214217 case QWebEnginePage::WebDialog: {
215218 qDebug (log) << " Don't support type:" << type;
219+ auto pWin = CreateTab (&pView, offTheRecord);
220+ pWin->show ();
216221 }
217222 }
218223
@@ -298,9 +303,9 @@ void CFrmWebBrowser::SetConnect(CFrmWebView* pWeb)
298303 m_pProgressBar->setValue (pWeb->progress ());
299304}
300305
301- QWebEngineProfile* CFrmWebBrowser::GetProfile ()
306+ QWebEngineProfile* CFrmWebBrowser::GetProfile (bool offTheRecord )
302307{
303- if (!g_profile) {
308+ if (!offTheRecord && ! g_profile) {
304309
305310#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
306311 const QString name = " io.github.KangLin.RabbitRemoteControl."
@@ -330,14 +335,14 @@ QWebEngineProfile* CFrmWebBrowser::GetProfile()
330335 << " Storage name:" << g_profile->storageName ()
331336 << " Is off the Record:" << g_profile->isOffTheRecord ();
332337 }
333- return g_profile? g_profile. get () : QWebEngineProfile::defaultProfile ();
338+ return offTheRecord ? QWebEngineProfile::defaultProfile () : g_profile. get ();
334339}
335340
336- CFrmWebView *CFrmWebBrowser::CreateWebView ()
341+ CFrmWebView *CFrmWebBrowser::CreateWebView (bool offTheRecord )
337342{
338343 auto pView = new CFrmWebView (this );
339344 if (pView) {
340- auto profile = GetProfile ();
345+ auto profile = GetProfile (offTheRecord );
341346#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
342347 profile->setPersistentPermissionsPolicy (QWebEngineProfile::PersistentPermissionsPolicy::AskEveryTime);
343348#endif
@@ -347,7 +352,7 @@ CFrmWebView *CFrmWebBrowser::CreateWebView()
347352 return pView;
348353}
349354
350- QWidget* CFrmWebBrowser::CreateTab (CFrmWebView **view)
355+ QWidget* CFrmWebBrowser::CreateTab (CFrmWebView **view, bool offTheRecord )
351356{
352357 QSplitter *pSplitter = new QSplitter (Qt::Vertical, this );
353358 if (pSplitter) {
@@ -357,16 +362,16 @@ QWidget* CFrmWebBrowser::CreateTab(CFrmWebView **view)
357362 if (*view) {
358363 pWeb = *view;
359364 } else {
360- pWeb = CreateWebView ();
365+ pWeb = CreateWebView (offTheRecord );
361366 *view = pWeb;
362367 }
363368 } else {
364- pWeb = CreateWebView ();
369+ pWeb = CreateWebView (offTheRecord );
365370 }
366371 if (pWeb) {
367372 pSplitter->addWidget (pWeb);
368373 SetConnect (pWeb);
369- auto pDevTools = CreateWebView ();
374+ auto pDevTools = CreateWebView (offTheRecord );
370375 if (pDevTools) {
371376 pDevTools->hide ();
372377 pSplitter->addWidget (pDevTools);
@@ -440,13 +445,30 @@ int CFrmWebBrowser::InitMenu(QMenu *pMenu)
440445
441446 pMenu->addSeparator ();
442447 pMenu->addAction (m_pAddPage);
448+ m_pAddPageIncognito = pMenu->addAction (
449+ QIcon::fromTheme (" add" ), tr (" Add incognito tab" ),
450+ this , [&](){
451+ CreateWindow (QWebEnginePage::WebBrowserTab, true );
452+ if (!m_pPara->GetTabUrl ().isEmpty ()) {
453+ m_pUrlLineEdit->setText (m_pPara->GetTabUrl ());
454+ slotReturnPressed ();
455+ }
456+ });
457+ m_pAddPageIncognito->setStatusTip (m_pAddPageIncognito->text ());
443458 m_pAddWindow = pMenu->addAction (
444459 QIcon::fromTheme (" add" ), tr (" Add window" ),
445460 this , [&](){
446- createWindow (QWebEnginePage::WebBrowserWindow);
461+ CreateWindow (QWebEnginePage::WebBrowserWindow);
447462 });
448463 m_pAddWindow->setVisible (false );
449464 m_pAddWindow->setStatusTip (m_pAddWindow->text ());
465+ m_pAddWindowIncognito = pMenu->addAction (
466+ QIcon::fromTheme (" add" ), tr (" Add Incognito Window" ),
467+ this , [&](){
468+ CreateWindow (QWebEnginePage::WebBrowserWindow, true );
469+ });
470+ m_pAddWindowIncognito->setVisible (false );
471+ m_pAddWindowIncognito->setStatusTip (m_pAddWindowIncognito->text ());
450472
451473 pMenu->addSeparator ();
452474 m_pFind = pMenu->addAction (
@@ -660,7 +682,7 @@ void CFrmWebBrowser::slotReturnPressed()
660682 emit sigInformation (u.toString ());
661683 CFrmWebView* pWeb = CurrentView ();
662684 if (!pWeb)
663- pWeb = qobject_cast<CFrmWebView*>(createWindow (QWebEnginePage::WebBrowserTab));
685+ pWeb = qobject_cast<CFrmWebView*>(CreateWindow (QWebEnginePage::WebBrowserTab));
664686 pWeb->load (u);
665687 if (m_pGo->isVisible ())
666688 m_pGo->setVisible (false );
@@ -691,7 +713,7 @@ int CFrmWebBrowser::Load(QSettings &set)
691713 for (int i = 0 ; i < nCount; i++)
692714 {
693715 QString u = set.value (QString::number (i)).toString ();
694- auto pView = createWindow (QWebEnginePage::WebBrowserTab);
716+ auto pView = CreateWindow (QWebEnginePage::WebBrowserTab);
695717 pView->load (QUrl (u));
696718 }
697719 if (-1 < nCurrent && m_pTab->count () > nCurrent)
0 commit comments