X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/78e9cc506f90eb862f032154199331b5e5e6dffb..d98f9c673b2f7eb31012ccef98dc8167630ccf1b:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 78e489915..bfdf8dafd 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -86,6 +86,19 @@ #include #include +/* + * Remembers the tab configuration if a tab has been closed. + * Each closed tab can be restored by the menu + * "Go -> Recently Closed Tabs". + */ +struct ClosedTab +{ + KUrl primaryUrl; + KUrl secondaryUrl; + bool isSplit; +}; +Q_DECLARE_METATYPE(ClosedTab) + DolphinMainWindow::DolphinMainWindow(int id) : KXmlGuiWindow(0), m_newMenu(0), @@ -256,11 +269,6 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) compareFilesAction->setEnabled(false); } -#if defined(QUICK_VIEW) - const bool activeViewHasSelection = (activeViewContainer()->view()->selectedItemsCount() > 0); - actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection); -#endif - m_activeViewContainer->updateStatusBar(); emit selectionChanged(selection); @@ -354,7 +362,7 @@ void DolphinMainWindow::openNewTab(const KUrl& url) void DolphinMainWindow::activateNextTab() { - if (m_viewTab.count() == 1 || m_tabBar->count() < 2) { + if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) { return; } @@ -364,7 +372,7 @@ void DolphinMainWindow::activateNextTab() void DolphinMainWindow::activatePrevTab() { - if (m_viewTab.count() == 1 || m_tabBar->count() < 2) { + if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) { return; } @@ -492,21 +500,21 @@ void DolphinMainWindow::slotUndoAvailable(bool available) void DolphinMainWindow::restoreClosedTab(QAction* action) { - //The Clear Recently Closed Tabs List QAction, has it's data set to true, so we can detect it in here, as it's an exception. - if (action->data().toBool() == true) { - // Lets preserve the separator, and the clear action within this menu. - QList actionlist = m_recentTabsMenu->menu()->actions(); - for (int i = 2; i < actionlist.size(); i++) { - m_recentTabsMenu->menu()->removeAction(actionlist.at(i)); + if (action->data().toBool()) { + // clear all actions except the "Empty Recently Closed Tabs" + // action and the separator + QList actions = m_recentTabsMenu->menu()->actions(); + const int count = actions.size(); + for (int i = 2; i < count; i++) { + m_recentTabsMenu->menu()->removeAction(actions.at(i)); } } else { const ClosedTab closedTab = action->data().value(); - openNewTab(closedTab.primaryUrl); m_tabBar->setCurrentIndex(m_viewTab.count() - 1); if (closedTab.isSplit) { - //Create secondary view. + // create secondary view toggleSplitView(); m_viewTab[m_tabIndex].secondaryView->setUrl(closedTab.secondaryUrl); } @@ -724,18 +732,6 @@ void DolphinMainWindow::compareFiles() KRun::runCommand(command, "Kompare", "kompare", this); } -void DolphinMainWindow::quickView() -{ - const KUrl::List urls = activeViewContainer()->view()->selectedUrls(); - Q_ASSERT(urls.count() > 0); - - QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile"); - foreach (const KUrl& url, urls) { - msg.setArguments(QList() << url.prettyUrl()); - QDBusConnection::sessionBus().send(msg); - } -} - void DolphinMainWindow::toggleShowMenuBar() { const bool visible = menuBar()->isVisible(); @@ -798,7 +794,7 @@ void DolphinMainWindow::closeTab(int index) Q_ASSERT(index >= 0); Q_ASSERT(index < m_viewTab.count()); if (m_viewTab.count() == 1) { - // the last tab may never get closed + // the last tab may never get closed return; } @@ -808,7 +804,8 @@ void DolphinMainWindow::closeTab(int index) m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1); } rememberClosedTab(index); - //Delete this tab. + + // delete tab m_viewTab[index].primaryView->deleteLater(); if (m_viewTab[index].secondaryView != 0) { m_viewTab[index].secondaryView->deleteLater(); @@ -887,7 +884,6 @@ void DolphinMainWindow::searchItems(const KUrl& url) m_activeViewContainer->setUrl(url); } - void DolphinMainWindow::init() { DolphinSettings& settings = DolphinSettings::instance(); @@ -927,7 +923,7 @@ void DolphinMainWindow::init() m_tabBar->setTabsClosable(true); connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(setActiveTab(int))); - connect(m_tabBar, SIGNAL(closeRequest(int)), + connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)), this, SLOT(openTabContextMenu(int, const QPoint&))); @@ -1141,16 +1137,6 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles())); - // disabled Quick View -#if defined(QUICK_VIEW) - KAction* quickView = actionCollection()->addAction("quick_view"); - quickView->setText(i18nc("@action:inmenu Tools", "Quick View")); - quickView->setIcon(KIcon("view-preview")); - quickView->setShortcut(Qt::CTRL + Qt::Key_Return); - quickView->setEnabled(false); - connect(quickView, SIGNAL(triggered()), this, SLOT(quickView())); -#endif - // setup 'Settings' menu m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection()); KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); @@ -1355,11 +1341,12 @@ void DolphinMainWindow::rememberClosedTab(int index) action->setData(QVariant::fromValue(closedTab)); action->setIcon(KIcon(iconName)); - //Add our action at the first element, but only do that if it isn't empty, else just append - if (tabsMenu->actions().isEmpty()) { + // add the closed tab menu entry after the separator and + // "Empty Recently Closed Tabs" entry + if (tabsMenu->actions().size() == 2) { tabsMenu->addAction(action); } else { - tabsMenu->insertAction(tabsMenu->actions().first() + 2, action); + tabsMenu->insertAction(tabsMenu->actions().at(2), action); } actionCollection()->action("closed_tabs")->setEnabled(true); }