Changeset View
Changeset View
Standalone View
Standalone View
krusader/tabactions.cpp
Show All 14 Lines | |||||
15 | * * | 15 | * * | ||
16 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * | ||
17 | * along with this package; if not, write to the Free Software * | 17 | * along with this package; if not, write to the Free Software * | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | ||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | 20 | | |||
21 | #include "tabactions.h" | 21 | #include "tabactions.h" | ||
22 | 22 | | |||
23 | #include "filemanagerwindow.h" | 23 | #include "krmainwindow.h" | ||
24 | #include "panelmanager.h" | 24 | #include "panelmanager.h" | ||
25 | #include "Panel/listpanel.h" | 25 | #include "Panel/listpanel.h" | ||
26 | 26 | | |||
27 | // QtWidgets | 27 | // QtWidgets | ||
28 | #include <QAction> | 28 | #include <QAction> | ||
29 | 29 | | |||
30 | #include <KI18n/KLocalizedString> | 30 | #include <KI18n/KLocalizedString> | ||
31 | 31 | | |||
32 | TabActions::TabActions(QObject *parent, FileManagerWindow *mainWindow) : ActionsBase(parent, mainWindow) | 32 | TabActions::TabActions(QObject *parent, KrMainWindow *mainWindow) : ActionsBase(parent, mainWindow) | ||
33 | { | 33 | { | ||
34 | actNewTab = action(i18n("New Tab"), "tab-new", QKeySequence::keyBindings(QKeySequence::AddTab), this, SLOT(newTab()), "new tab"); | 34 | actNewTab = action(i18n("New Tab"), "tab-new", QKeySequence::keyBindings(QKeySequence::AddTab), this, SLOT(newTab()), "new tab"); | ||
35 | actDupTab = action(i18n("Duplicate Current Tab"), "tab-duplicate", Qt::ALT + Qt::CTRL + Qt::SHIFT + Qt::Key_N, SLOT(duplicateTab()), "duplicate tab"); | 35 | actDupTab = action(i18n("Duplicate Current Tab"), "tab-duplicate", Qt::ALT + Qt::CTRL + Qt::SHIFT + Qt::Key_N, SLOT(duplicateTab()), "duplicate tab"); | ||
36 | actMoveTabToOtherSide = action(i18n("Move Current Tab to Other Side"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_O, SLOT(moveTabToOtherSide()), "move_tab_to_other_side"); | 36 | actMoveTabToOtherSide = action(i18n("Move Current Tab to Other Side"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_O, SLOT(moveTabToOtherSide()), "move_tab_to_other_side"); | ||
37 | actCloseTab = action(i18n("Close Current Tab"), "tab-close", KStandardShortcut::close(), this, SLOT(closeTab()), "close tab"); | 37 | actCloseTab = action(i18n("Close Current Tab"), "tab-close", KStandardShortcut::close(), this, SLOT(closeTab()), "close tab"); | ||
38 | actNextTab = action(i18n("Next Tab"), QString(), KStandardShortcut::tabNext(), this, SLOT(nextTab()), "next tab"); | 38 | actNextTab = action(i18n("Next Tab"), QString(), KStandardShortcut::tabNext(), this, SLOT(nextTab()), "next tab"); | ||
39 | actPreviousTab = action(i18n("Previous Tab"), QString(), KStandardShortcut::tabPrev(), this, SLOT(previousTab()), "previous tab"); | 39 | actPreviousTab = action(i18n("Previous Tab"), QString(), KStandardShortcut::tabPrev(), this, SLOT(previousTab()), "previous tab"); | ||
40 | actCloseInactiveTabs = action(i18n("Close Inactive Tabs"), 0, 0, SLOT(closeInactiveTabs()), "close inactive tabs"); | 40 | actCloseInactiveTabs = action(i18n("Close Inactive Tabs"), 0, 0, SLOT(closeInactiveTabs()), "close inactive tabs"); | ||
41 | actCloseDuplicatedTabs = action(i18n("Close Duplicated Tabs"), 0, 0, SLOT(closeDuplicatedTabs()), "close duplicated tabs"); | 41 | actCloseDuplicatedTabs = action(i18n("Close Duplicated Tabs"), 0, 0, SLOT(closeDuplicatedTabs()), "close duplicated tabs"); | ||
42 | actLockTab = action(i18n("Lock Tab"), 0, 0, SLOT(lockTab()), "lock tab"); | 42 | actLockTab = action(i18n("Lock Tab"), 0, 0, SLOT(lockTab()), "lock tab"); | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | inline PanelManager *TabActions::activeManager() | 45 | inline PanelManager *TabActions::activeManager() | ||
46 | { | 46 | { | ||
47 | return static_cast<PanelManager*>( | 47 | return static_cast<PanelManager*>( | ||
48 | static_cast<FileManagerWindow*>(_mainWindow)->activeManager()); | 48 | static_cast<KrMainWindow*>(_mainWindow)->activeManager()); | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | void TabActions::refreshActions() | 51 | void TabActions::refreshActions() | ||
52 | { | 52 | { | ||
53 | if (!activeManager()) | 53 | if (!activeManager()) | ||
54 | return; | 54 | return; | ||
55 | int tabCount = activeManager()->tabCount(); | 55 | int tabCount = activeManager()->tabCount(); | ||
56 | actCloseTab->setEnabled(tabCount > 1); | 56 | actCloseTab->setEnabled(tabCount > 1); | ||
57 | actCloseInactiveTabs->setEnabled(tabCount > 1); | 57 | actCloseInactiveTabs->setEnabled(tabCount > 1); | ||
58 | actCloseDuplicatedTabs->setEnabled(tabCount > 1); | 58 | actCloseDuplicatedTabs->setEnabled(tabCount > 1); | ||
59 | actMoveTabToOtherSide->setEnabled(tabCount > 1); | 59 | actMoveTabToOtherSide->setEnabled(tabCount > 1); | ||
60 | actNextTab->setEnabled(tabCount > 1); | 60 | actNextTab->setEnabled(tabCount > 1); | ||
61 | actPreviousTab->setEnabled(tabCount > 1); | 61 | actPreviousTab->setEnabled(tabCount > 1); | ||
62 | bool locked = activeManager()->currentPanel()->gui->isLocked(); | 62 | bool locked = activeManager()->currentPanel()->gui->isLocked(); | ||
63 | actLockTab->setText(locked ? i18n("Unlock Tab") : i18n("Lock Tab")); | 63 | actLockTab->setText(locked ? i18n("Unlock Tab") : i18n("Lock Tab")); | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | void TabActions::newTab() | 66 | void TabActions::newTab() | ||
67 | { | 67 | { | ||
68 | activeManager()->slotNewTab(); | 68 | activeManager()->slotNewTab(); | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | void TabActions::duplicateTab() | 71 | void TabActions::duplicateTab() | ||
72 | { | 72 | { | ||
73 | KrPanel *activePanel = static_cast<FileManagerWindow*>(_mainWindow)->activePanel(); | 73 | KrPanel *activePanel = static_cast<KrMainWindow*>(_mainWindow)->activePanel(); | ||
74 | activeManager()->newTab(activePanel->virtualPath(), activePanel); | 74 | activeManager()->newTab(activePanel->virtualPath(), activePanel); | ||
75 | } | 75 | } | ||
76 | 76 | | |||
77 | void TabActions::moveTabToOtherSide() | 77 | void TabActions::moveTabToOtherSide() | ||
78 | { | 78 | { | ||
79 | activeManager()->moveTabToOtherSide(); | 79 | activeManager()->moveTabToOtherSide(); | ||
80 | } | 80 | } | ||
81 | 81 | | |||
Show All 29 Lines |