[utilities/krusader] krusader: Restore the old behavior for the "Open a new tab" button

Pavel Karelin null at kde.org
Fri Aug 26 09:45:06 BST 2022


Git commit e64a7acfe927f2ba9af61e72d822fc30da4d9d97 by Pavel Karelin.
Committed on 25/08/2022 at 17:59.
Pushed by hkarel into branch 'master'.

Restore the old behavior for the "Open a new tab" button

ADDED: option to select New Tab Button behavior
GUI: option "New tab button duplicates a tab" is added

Discussion: https://invent.kde.org/utilities/krusader/-/merge_requests/97

M  +10   -9    krusader/Konfigurator/kgpanel.cpp
M  +9    -4    krusader/panelmanager.cpp
M  +1    -1    krusader/panelmanager.h

https://invent.kde.org/utilities/krusader/commit/e64a7acfe927f2ba9af61e72d822fc30da4d9d97

diff --git a/krusader/Konfigurator/kgpanel.cpp b/krusader/Konfigurator/kgpanel.cpp
index e84250ad..6b42b387 100644
--- a/krusader/Konfigurator/kgpanel.cpp
+++ b/krusader/Konfigurator/kgpanel.cpp
@@ -114,16 +114,17 @@ void KgPanel::setupGeneralTab()
     gridLayout = createGridLayout(groupBox);
 
     KONFIGURATOR_CHECKBOX_PARAM tabbar_settings[] = {
-    //   cfg_class    cfg_name                      default             text                                restart tooltip
-        {"Look&Feel", "Fullpath Tab Names",         _FullPathTabNames,  i18n("Use full path tab names"),    true,   i18n("Display the full path in the folder tabs. By default only the last part of the path is displayed.") },
-        {"Look&Feel", "Show Close Tab Buttons",     true,               i18n("Show close tab buttons"),     true,   i18n("Show close tab buttons.") },
-        {"Look&Feel", "Expanding Tabs",             true,               i18n("Expanding tabs"),             true,   i18n("Expanding tabs.") },
-        {"Look&Feel", "Show New Tab Button",        true,               i18n("Show new tab button"),        true,   i18n("Show new tab button.") },
-        {"Look&Feel", "Close Tab By Double Click",  false,              i18n("Close tab by double click"),  true,   i18n("Close tab by double click.") },
-        {"Look&Feel", "Show Tab Bar On Single Tab", true,               i18n("Show Tab Bar on single tab"), true,   i18n("Show the tab bar with only one tab.") },
-        {"Look&Feel", "Insert Tabs After Current",  false,              i18n("Insert tabs after current"),  false,  i18n("Insert new tabs to the right of the current one.") }
+    //   cfg_class    cfg_name                      default             text                                     restart tooltip
+        {"Look&Feel", "Fullpath Tab Names",         _FullPathTabNames,  i18n("Use full path tab names"),         true,   i18n("Display the full path in the folder tabs. By default only the last part of the path is displayed.") },
+        {"Look&Feel", "Show Close Tab Buttons",     true,               i18n("Show close tab buttons"),          true,   i18n("Show close tab buttons.") },
+        {"Look&Feel", "Expanding Tabs",             true,               i18n("Expanding tabs"),                  true,   i18n("Expanding tabs.") },
+        {"Look&Feel", "Show New Tab Button",        true,               i18n("Show new tab button"),             true,   i18n("Show new tab button.") },
+        {"Look&Feel", "Insert Tabs After Current",  false,              i18n("Insert tabs after current"),       false,  i18n("Insert new tabs to the right of the current one.") },
+        {"Look&Feel", "Show Tab Bar On Single Tab", true,               i18n("Show Tab Bar on single tab"),      true,   i18n("Show the tab bar with only one tab.") },
+        {"Look&Feel", "Close Tab By Double Click",  false,              i18n("Close tab by double click"),       false,  i18n("Close tab by double click.") },
+        {"Look&Feel", "New Tab Button Duplicates",  false,              i18n("New tab button duplicates a tab"), false,  i18n("If checked, new tab button duplicates a tab, otherwise it opens a tab in home directory.") }
     };
-    cbs = createCheckBoxGroup(2, 0, tabbar_settings, 7 /*count*/, groupBox, PAGE_GENERAL);
+    cbs = createCheckBoxGroup(2, 0, tabbar_settings, 8 /*count*/, groupBox, PAGE_GENERAL);
     gridLayout->addWidget(cbs, 0, 0, 1, 2);
 
     // -------------- Duplicate tab by click --------------------
diff --git a/krusader/panelmanager.cpp b/krusader/panelmanager.cpp
index b7d62be1..9c2bfdff 100644
--- a/krusader/panelmanager.cpp
+++ b/krusader/panelmanager.cpp
@@ -291,13 +291,18 @@ void PanelManager::slotNewTabFromUI()
     int insertIndex = group.readEntry("Insert Tabs After Current", false)
                       ? _tabbar->currentIndex() + 1
                       : _tabbar->count();
-    slotDuplicateTab(currentPanel()->virtualPath(), currentPanel(), insertIndex);
-    _currentPanel->slotFocusOnMe();
+
+    if (group.readEntry("New Tab Button Duplicates", false)) {
+        slotDuplicateTab(currentPanel()->virtualPath(), currentPanel(), insertIndex);
+        _currentPanel->slotFocusOnMe();
+    } else {
+        slotNewTab(insertIndex);
+    }
 }
 
-void PanelManager::slotNewTab()
+void PanelManager::slotNewTab(int insertIndex)
 {
-    slotNewTab(QUrl::fromLocalFile(QDir::home().absolutePath()));
+    slotNewTab(QUrl::fromLocalFile(QDir::home().absolutePath()), true, insertIndex);
     _currentPanel->slotFocusOnMe();
 }
 
diff --git a/krusader/panelmanager.h b/krusader/panelmanager.h
index 77c501f3..fe18ab1a 100644
--- a/krusader/panelmanager.h
+++ b/krusader/panelmanager.h
@@ -107,7 +107,7 @@ public slots:
 
     void slotNewTab(const QUrl &url, bool setCurrent = true, int insertIndex = -1);
     void slotNewTabFromUI();
-    void slotNewTab();
+    void slotNewTab(int insertIndex = -1);
     void slotDuplicateTab(const QUrl &url, KrPanel *nextTo, int insertIndex = -1);
     void slotDuplicateTabLMB();
     void slotLockTab();


More information about the kde-doc-english mailing list