Closing a tab can be undone
Note: About this subject, it's useful to read the information written on https://bugs.kde.org/show_bug.cgi?id=397041
After applying the code of this MR:
-
New options are seen in the File menu ("Undo Close Tab"), after right-clicking on a tab ("Undo Close Tab" is also seen) and, as in Dolphin, in the Go menu ("Recently Closed Tabs") so the user can choose which tab to reopen (not only the last closed one) or choose "Empty Recently Closed Tabs".
-
An interface like
slotNewTab(const QUrl &url, bool setCurrent, int insertIndex)
can be used, which enables Krusader to open a tab on a particular location inside a Tab bar. Not only that interface is useful for undoing the closing of a particular tab, but also for allowing e.g. pressing Ctrl+T to add a tab on a preferred position ─like other programs can.
Note: The icon of the action is the same "undo" icon that Dolphin utilizes, in order to make things easier for users.
I've been using the new source code since 4th of June without seeing any problem. When the code of the present merge review was tested, everything seemed to work correctly, but I'm not an expert in Krusader panels and I wanted to ask for other points of view.
INFORMATION THAT CAN BE USEFUL WHEN TESTING
If, after executing sudo make install
and launching Krusader, new menu entries ("File > Undo Close Tab" and "Go > Recently Closed Tabs") aren't shown: close Krusader, execute a command like mv ~/.local/share/kxmlgui5/krusader/krusaderui.rc ~/.local/share/kxmlgui5/krusader/krusaderui.rc.original
and execute Krusader again.
An explanation about the previous steps is: In order to reopen closed tabs and manage the list of recently closed tabs, two new Krusader menu entries can be used ("File > Undo Close Tab" and "Go > Recently Closed Tabs"), and therefore two groups of changes have been made to the krusaderui.rc file of the git repository. After executing sudo make install
, if a file like ~/.local/share/kxmlgui5/krusader/krusaderui.rc
already existed: that file will be utilized and consequently the user won't see the aforementioned new menu entries.
TEST PLAN
Close Krusader if it was opened. Start Krusader, check that pressing Ctrl+Shift+T doesn't do anything and that those options are disabled:
- "File > Undo Close Tab".
- "Go > Recently Closed Tabs".
- The "Undo Close Tab" entry of the context menu when you right-click on a tab.
On the left panel, using the Detailed View (which is the default one):
-
Open a tab and close it. Select on the Go menu, choose "Empty Recently Closed Tabs" and check that no tab can be reopened after that.
-
Make sure that there are at least two tabs opened. In the last one go to "/usr/bin", close that tab. Check that "Go > Undo Close Tab" is enabled and click on it.
-
Check that a new tab has been opened, and that the "/usr/bin" folder is seen there.
-
Check that pressing Ctrl+Shift+T doesn't do anything and that those options are disabled:
- "File > Undo Close Tab".
- "Go > Recently Closed Tabs".
- The "Undo Close Tab" entry of the context menu when you right-click on a tab.
-
Make sure that there are at least three tabs opened. Repeat the same test though using the second tab this time and the "Go > Recently Closed Tabs" way of reopening tabs.
-
Make sure that there are at least three tabs opened. Repeat the same test though using the first tab this time and the "Undo Close Tab" entry of the {context menu when you right-click on a tab}.
-
Place the cursor on a folder, press Ctrl+Alt+Return and check that this folder is opened on a new tab.
-
Open a tab, go to /usr/include, select some folders and files, close that tab, go to the other panel, press Ctrl+Shift+T and check that the tab is opened where it was, with its selected files and folders.
-
Open a tab, go to /usr and browse some folders. Close that tab, undo that, check that its history is the same as the one that it was before closing it.
-
Press Alt+Down Arrow, go to the Tree Panel, move the cursor there, go to the right part of the same panel, move the cursor, close the tab, undo that. Check that the situation is the same as it was before closing it.
-
Go to "View > Custom" and specify that only the x* files have to be seen. Close the tab, use "File > Undo Close Tab". Check that the filter is still applied.
-
Pin a tab, close it, undo that, check that the situation is the same as it was before closing the tab.
-
Lock a tab, close it, undo that, check that the situation is the same as it was before closing the tab.
-
Open and close more than six tabs, check that no more than six entries are seen in the "Go > Recently Closed Tabs" menu, and that they are the tabs that were closed recently. Use that "Go > Recently Closed Tabs" menu to reopen the latest tab that is seen in the list, and repeat that action until no entries are seen there.
-
Go to the last tab. Press Ctrl+T six times, press Ctrl+W six times, go to the "Go > Recently Closed Tabs" menu and choose reopening the latest tab that is seen there. Check that the tab is reopened and that no error is seen. Note: Going to the last tab is useful because if e.g. there is only one tab but in the "Go > Recently Closed Tabs" menu the user chooses to reopen the tab that was in the seventh position, Krusader has to reopen that tab but in the second position.
-
When having three tabs, close the first one, undo that, close tabs until only one is left. Press Ctrl+Shift+T and check that everything has worked as it was expected.
-
Enter a zip file, close the tab. Undo that, check that everything has worked as it was expected.
-
Open a remote folder (FTP, SMB, etc.), close the tab. Undo that, check that everything has worked as it was expected.
-
Open a new tab, create a folder named X, enter that folder, close the tab, delete the folder named X, undo the closing of the last tab, check that in Krusader it's seen the usual error when {the user goes back to a tab when it's folder has been deleted}.
-
Open a new tab, create a file named A, position the cursor on that file, close the tab, delete the file named A, undo the closing of the last tab, check that in Krusader the cursor is on the ".." item.
-
Very quickly: press Ctrl+T six times, press Ctrl+W six times, press Ctrl+Shift+T six times, press Ctrl+W six times. Check that no error has been seen and that no tabs are listed in the "Go > Recently Closed Tabs" menu.
-
Open a tab, sort by date, close the tab, use the "Go > Recently Closed Tabs" menu to reopen the tab, check that items are sorted by date.
-
Perform other tab operations that you consider that are necessary.
The same operations can be repeated but now using the right panel and the Brief View.
[Update: The test plan of !79 (merged) can also be followed]
INFORMATION THAT CAN BE USEFUL WHEN REVIEWING THE SOURCE CODE
-
In order to review the structure of the recentlyclosedtabsmenu.h file, it can be compared with the structure of the krremoteencodingmenu.h file.
-
To review the
RecentlyClosedTabsMenu::RecentlyClosedTabsMenu()
code, it can be compared with the code of:-
KrRemoteEncodingMenu::KrRemoteEncodingMenu(const QString &text, [...] (it can be seen on https://invent.kde.org/utilities/krusader/-/blob/master/krusader/GUI/krremoteencodingmenu.cpp).
-
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) (it can be seen on https://invent.kde.org/system/dolphin/-/blob/master/src/dolphinrecenttabsmenu.cpp).
-
-
To review the
void RecentlyClosedTabsMenu::updateAfterClosingATab(const QUrl &urlClosedTab)
code, it can be compared with the code of:- DolphinRecentTabsMenu::rememberClosedTab(const QUrl& url, const QByteArray& state) (it can be seen on https://invent.kde.org/system/dolphin/-/blob/master/src/dolphinrecenttabsmenu.cpp).
-
To review the
RecentlyClosedTabsMenu::slotTriggered(QAction *action)
code, it can be compared with the code of:-
KrRemoteEncodingMenu::slotTriggered(QAction * act) (it can be seen on https://invent.kde.org/utilities/krusader/-/blob/master/krusader/GUI/krremoteencodingmenu.cpp).
-
DolphinRecentTabsMenu::handleAction(QAction* action) (it can be seen on https://invent.kde.org/system/dolphin/-/blob/master/src/dolphinrecenttabsmenu.cpp).
-
PanelManager::slotDuplicateTab(const QUrl &url, KrPanel *nextTo, int insertIndex) (it can be seen on https://invent.kde.org/utilities/krusader/-/blob/master/krusader/panelmanager.cpp).
-