mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 09:50:12 +00:00
make CTRL+SHIFT+T reopen last closed tab
BUG: 336818 FEATURE: 118994
This commit is contained in:
parent
0f2f9fd5b8
commit
9a69506572
|
@ -1220,6 +1220,11 @@ void DolphinMainWindow::activeViewChanged()
|
||||||
setActiveViewContainer(tabPage->activeViewContainer());
|
setActiveViewContainer(tabPage->activeViewContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
|
||||||
|
{
|
||||||
|
actionCollection()->action("undo_close_tab")->setEnabled(count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
|
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
|
||||||
{
|
{
|
||||||
Q_ASSERT(viewContainer);
|
Q_ASSERT(viewContainer);
|
||||||
|
@ -1350,6 +1355,15 @@ void DolphinMainWindow::setupActions()
|
||||||
recentTabsMenu, SLOT(rememberClosedTab(KUrl,KUrl)));
|
recentTabsMenu, SLOT(rememberClosedTab(KUrl,KUrl)));
|
||||||
connect(recentTabsMenu, SIGNAL(restoreClosedTab(KUrl,KUrl)),
|
connect(recentTabsMenu, SIGNAL(restoreClosedTab(KUrl,KUrl)),
|
||||||
this, SLOT(openNewActivatedTab(KUrl,KUrl)));
|
this, SLOT(openNewActivatedTab(KUrl,KUrl)));
|
||||||
|
connect(recentTabsMenu, SIGNAL(closedTabsCountChanged(uint)),
|
||||||
|
this, SLOT(closedTabsCountChanged(uint)));
|
||||||
|
|
||||||
|
KAction* undoCloseTab = actionCollection()->addAction("undo_close_tab");
|
||||||
|
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
|
||||||
|
undoCloseTab->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_T);
|
||||||
|
undoCloseTab->setIcon(KIcon("edit-undo"));
|
||||||
|
undoCloseTab->setEnabled(false);
|
||||||
|
connect(undoCloseTab, SIGNAL(triggered()), recentTabsMenu, SLOT(undoCloseTab()));
|
||||||
|
|
||||||
KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
|
KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
|
||||||
connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
|
connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
|
||||||
|
|
|
@ -468,6 +468,8 @@ private slots:
|
||||||
|
|
||||||
void activeViewChanged();
|
void activeViewChanged();
|
||||||
|
|
||||||
|
void closedTabsCountChanged(unsigned int count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Activates the given view, which means that
|
* Activates the given view, which means that
|
||||||
|
|
|
@ -60,7 +60,7 @@ void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& primaryUrl, const KUrl
|
||||||
} else {
|
} else {
|
||||||
insertAction(menu()->actions().at(2), action);
|
insertAction(menu()->actions().at(2), action);
|
||||||
}
|
}
|
||||||
|
emit closedTabsCountChanged(menu()->actions().size() - 2);
|
||||||
// Assure that only up to 6 closed tabs are shown in the menu.
|
// Assure that only up to 6 closed tabs are shown in the menu.
|
||||||
// 8 because of clear action + separator + 6 closed tabs
|
// 8 because of clear action + separator + 6 closed tabs
|
||||||
if (menu()->actions().size() > 8) {
|
if (menu()->actions().size() > 8) {
|
||||||
|
@ -70,6 +70,12 @@ void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& primaryUrl, const KUrl
|
||||||
KAcceleratorManager::manage(menu());
|
KAcceleratorManager::manage(menu());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinRecentTabsMenu::undoCloseTab()
|
||||||
|
{
|
||||||
|
Q_ASSERT(menu()->actions().size() > 2);
|
||||||
|
handleAction(menu()->actions().at(2));
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinRecentTabsMenu::handleAction(QAction* action)
|
void DolphinRecentTabsMenu::handleAction(QAction* action)
|
||||||
{
|
{
|
||||||
if (action == m_clearListAction) {
|
if (action == m_clearListAction) {
|
||||||
|
@ -80,14 +86,16 @@ void DolphinRecentTabsMenu::handleAction(QAction* action)
|
||||||
for (int i = 2; i < count; ++i) {
|
for (int i = 2; i < count; ++i) {
|
||||||
removeAction(actions.at(i));
|
removeAction(actions.at(i));
|
||||||
}
|
}
|
||||||
|
emit closedTabsCountChanged(0);
|
||||||
} else {
|
} else {
|
||||||
const KUrl::List urls = action->data().value<KUrl::List>();
|
const KUrl::List urls = action->data().value<KUrl::List>();
|
||||||
if (urls.count() == 2) {
|
|
||||||
emit restoreClosedTab(urls.first(), urls.last());
|
|
||||||
}
|
|
||||||
removeAction(action);
|
removeAction(action);
|
||||||
delete action;
|
delete action;
|
||||||
action = 0;
|
action = 0;
|
||||||
|
if (urls.count() == 2) {
|
||||||
|
emit restoreClosedTab(urls.first(), urls.last());
|
||||||
|
}
|
||||||
|
emit closedTabsCountChanged(menu()->actions().size() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu()->actions().count() <= 2) {
|
if (menu()->actions().count() <= 2) {
|
||||||
|
|
|
@ -35,9 +35,11 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
|
void rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
|
||||||
|
void undoCloseTab();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void restoreClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
|
void restoreClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
|
||||||
|
void closedTabsCountChanged(unsigned int count);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleAction(QAction* action);
|
void handleAction(QAction* action);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<Action name="new_window" />
|
<Action name="new_window" />
|
||||||
<Action name="new_tab" />
|
<Action name="new_tab" />
|
||||||
<Action name="close_tab" />
|
<Action name="close_tab" />
|
||||||
|
<Action name="undo_close_tab" />
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<Action name="rename" />
|
<Action name="rename" />
|
||||||
<Action name="move_to_trash" />
|
<Action name="move_to_trash" />
|
||||||
|
|
Loading…
Reference in a new issue