From 060411d863b18f97e37836404a3fb20391017979 Mon Sep 17 00:00:00 2001 From: oltolm Date: Fri, 1 Nov 2024 14:54:10 +0100 Subject: [PATCH] add setting "open tabs in foreground setting" and remove "open tab in background" item --- src/config.cpp | 2 ++ src/config.h | 1 + src/dialog_setup.cpp | 3 +++ src/dialog_setup.ui | 9 ++++++++- src/mainwindow.cpp | 12 +----------- src/mainwindow.h | 1 - src/qtwebengine/viewwindow.cpp | 4 +--- src/qtwebkit/viewwindow.cpp | 7 ++----- 8 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 07ac08f9..9d452b21 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -68,6 +68,7 @@ Config::Config() m_tocOpenAllEntries = settings.value( "browser/tocopenallentries", true ).toBool(); m_tabUseSingleClick = settings.value( "browser/tabusesingleclick", true ).toBool(); + m_tabOpenInForeground = settings.value( "browser/tabopeninforeground", false ).toBool(); QDir dir; dir.setPath (m_datapath); @@ -124,6 +125,7 @@ void Config::save( ) settings.setValue( "browser/tocopenallentries", m_tocOpenAllEntries ); settings.setValue( "browser/tabusesingleclick", m_tabUseSingleClick ); + settings.setValue( "browser/tabopeninforeground", m_tabOpenInForeground ); } QString Config::getEbookSettingFile(const QString& ebookfile ) const diff --git a/src/config.h b/src/config.h index 27082899..aad1f0f4 100644 --- a/src/config.h +++ b/src/config.h @@ -73,6 +73,7 @@ class Config bool m_tocOpenAllEntries; bool m_tabUseSingleClick; + bool m_tabOpenInForeground; bool m_advUseInternalEditor; QString m_advExternalEditorPath; diff --git a/src/dialog_setup.cpp b/src/dialog_setup.cpp index 0578ebfe..9890bdfe 100644 --- a/src/dialog_setup.cpp +++ b/src/dialog_setup.cpp @@ -84,6 +84,7 @@ DialogSetup::DialogSetup(QWidget* parent) m_enableLocalStorage->setChecked( pConfig->browser.enableLocalStorage ); m_openAllTOCEntries->setChecked( pConfig->m_tocOpenAllEntries ); boxUseSingleClick->setChecked( pConfig->m_tabUseSingleClick ); + boxTabOpenInForeground->setChecked( pConfig->m_tabOpenInForeground ); #if defined (USE_WEBENGINE) m_enableOfflineStorage->setChecked( false ); @@ -164,6 +165,8 @@ void DialogSetup::accept() Check_Need_Restart( m_enableLocalStorage, &pConfig->browser.enableLocalStorage, &need_restart ); Check_Need_Restart( boxUseSingleClick, &pConfig->m_tabUseSingleClick, &need_restart ); + pConfig->m_tabOpenInForeground = boxTabOpenInForeground->isChecked(); + Config::ToolbarMode newmode; if ( rbToolbarSmall->isChecked() ) diff --git a/src/dialog_setup.ui b/src/dialog_setup.ui index 34a57437..1aa190a1 100644 --- a/src/dialog_setup.ui +++ b/src/dialog_setup.ui @@ -377,7 +377,14 @@ - + + + + Open tabs in foreground + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f032c2c5..c073a7e8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -707,12 +707,7 @@ QUrl MainWindow::getNewTabLink() const void MainWindow::onOpenPageInNewTab( ) { - openPage( getNewTabLink(), OPF_NEW_TAB | OPF_CONTENT_TREE ); -} - -void MainWindow::onOpenPageInNewBackgroundTab( ) -{ - openPage( getNewTabLink(), OPF_NEW_TAB | OPF_BACKGROUND ); + openPage( getNewTabLink(), OPF_NEW_TAB | (pConfig->m_tabOpenInForeground ? OPF_CONTENT_TREE : OPF_BACKGROUND) ); } void MainWindow::browserChanged(ViewWindow* newbrowser ) @@ -1284,11 +1279,6 @@ void MainWindow::setupActions() m_contextMenu->addAction ( i18n("&Open this link in a new tab"), this, SLOT( onOpenPageInNewTab() ), - QKeySequence( "Shift+Enter" ) ); - - m_contextMenu->addAction ( i18n("&Open this link in a new background tab"), - this, - SLOT( onOpenPageInNewBackgroundTab() ), QKeySequence( "Ctrl+Enter" ) ); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 021e7220..fcf83a05 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -124,7 +124,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindow //! Update state of navigation actions. void onHistoryChanged(); void onOpenPageInNewTab(); - void onOpenPageInNewBackgroundTab(); // Actions void actionOpenFile(); diff --git a/src/qtwebengine/viewwindow.cpp b/src/qtwebengine/viewwindow.cpp index ab41e7ab..28dbcaad 100644 --- a/src/qtwebengine/viewwindow.cpp +++ b/src/qtwebengine/viewwindow.cpp @@ -126,8 +126,7 @@ QMenu* ViewWindow::getContextMenu( const QUrl& link, QWidget* parent ) { m_contextMenuLink = createStandardContextMenu( parent ); m_contextMenuLink->addSeparator(); - m_contextMenuLink->addAction( i18n("&Open this link in a new tab"), ::mainWindow, SLOT(onOpenPageInNewTab()), QKeySequence("Shift+Enter") ); - m_contextMenuLink->addAction( i18n("&Open this link in a new background tab"), ::mainWindow, SLOT(onOpenPageInNewBackgroundTab()), QKeySequence("Ctrl+Enter") ); + m_contextMenuLink->addAction( i18n("&Open this link in a new tab"), ::mainWindow, SLOT(onOpenPageInNewTab()), QKeySequence("Ctrl+Enter") ); } setTabKeeper( link ); @@ -253,7 +252,6 @@ void ViewWindow::contextMenuEvent(QContextMenuEvent* e) if ( !link.isEmpty() ) { m->addAction( i18n("Open Link in a new tab\tShift+LMB"), ::mainWindow, SLOT( onOpenPageInNewTab() ) ); - m->addAction( i18n("Open Link in a new background tab\tCtrl+LMB"), ::mainWindow, SLOT( onOpenPageInNewBackgroundTab() ) ); m->addSeparator(); setTabKeeper( link ); } diff --git a/src/qtwebkit/viewwindow.cpp b/src/qtwebkit/viewwindow.cpp index 3b335bf9..c90958ee 100644 --- a/src/qtwebkit/viewwindow.cpp +++ b/src/qtwebkit/viewwindow.cpp @@ -135,9 +135,7 @@ QMenu* ViewWindow::getContextMenu( const QUrl& link, QWidget* parent ) m_contextMenuLink = createStandardContextMenu( parent ); m_contextMenuLink->addSeparator(); - m_contextMenuLink->addAction( i18n("&Open this link in a new tab"), ::mainWindow, SLOT(onOpenPageInNewTab()), QKeySequence("Shift+Enter") ); - - m_contextMenuLink->addAction( i18n("&Open this link in a new background tab"), ::mainWindow, SLOT(onOpenPageInNewBackgroundTab()), QKeySequence("Ctrl+Enter") ); + m_contextMenuLink->addAction( i18n("&Open this link in a new tab"), ::mainWindow, SLOT(onOpenPageInNewTab()), QKeySequence("Ctrl+Enter") ); } setTabKeeper( link ); @@ -250,7 +248,7 @@ void ViewWindow::mouseReleaseEvent ( QMouseEvent* event ) if ( !link.isEmpty() ) { setTabKeeper( link ); - ::mainWindow->onOpenPageInNewBackgroundTab(); + ::mainWindow->onOpenPageInNewTab(); return; } } @@ -267,7 +265,6 @@ void ViewWindow::contextMenuEvent(QContextMenuEvent* e) if ( !link.isEmpty() ) { m->addAction( i18n("Open Link in a new tab\tShift+LMB"), ::mainWindow, SLOT( onOpenPageInNewTab() ) ); - m->addAction( i18n("Open Link in a new background tab\tCtrl+LMB"), ::mainWindow, SLOT( onOpenPageInNewBackgroundTab() ) ); m->addSeparator(); setTabKeeper( link ); }