X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/abfa3fff9d899ffd5b0c2ced055f12bcf5bfa6d0..26a75802ebcd74dc9182ff8f2ef9acf8319e0037:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index aa72a2b9b..0151d48b1 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #include #include @@ -85,6 +86,7 @@ #include #include #include +#include /* * Remembers the tab configuration if a tab has been closed. @@ -236,6 +238,8 @@ void DolphinMainWindow::changeUrl(const KUrl& url) if (m_viewTab.count() > 1) { m_tabBar->setTabText(m_tabIndex, tabName(url)); } + const QString iconName = KMimeType::iconNameForUrl(url); + m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName)); emit urlChanged(url); } } @@ -330,14 +334,15 @@ void DolphinMainWindow::openNewTab() void DolphinMainWindow::openNewTab(const KUrl& url) { + const KIcon icon = KIcon(KMimeType::iconNameForUrl(m_activeViewContainer->url())); if (m_viewTab.count() == 1) { // Only one view is open currently and hence no tab is shown at // all. Before creating a tab for 'url', provide a tab for the current URL. - m_tabBar->addTab(KIcon("folder"), tabName(m_activeViewContainer->url())); + m_tabBar->addTab(icon, tabName(m_activeViewContainer->url())); m_tabBar->blockSignals(false); } - m_tabBar->addTab(KIcon("folder"), tabName(url)); + m_tabBar->addTab(icon, tabName(url)); ViewTab viewTab; viewTab.splitter = new QSplitter(this); @@ -505,7 +510,7 @@ void DolphinMainWindow::restoreClosedTab(QAction* action) // action and the separator QList actions = m_recentTabsMenu->menu()->actions(); const int count = actions.size(); - for (int i = 2; i < count; i++) { + for (int i = 2; i < count; ++i) { m_recentTabsMenu->menu()->removeAction(actions.at(i)); } } else { @@ -738,6 +743,11 @@ void DolphinMainWindow::toggleShowMenuBar() menuBar()->setVisible(!visible); } +void DolphinMainWindow::openTerminal() +{ + KToolInvocation::invokeTerminal(QString(), m_activeViewContainer->url().path()); +} + void DolphinMainWindow::editSettings() { if (m_settingsDialog == 0) { @@ -842,7 +852,6 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos) QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab")); closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut()); - QAction* selectedAction = menu.exec(pos); if (selectedAction == newTabAction) { const ViewTab& tab = m_viewTab[index]; @@ -1008,6 +1017,7 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain setCaption(url.fileName()); if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) { m_tabBar->setTabText(m_tabIndex, tabName(url)); + m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url))); } emit urlChanged(url); @@ -1103,13 +1113,13 @@ void DolphinMainWindow::setupActions() backShortcut.setAlternate(Qt::Key_Backspace); backAction->setShortcut(backShortcut); - m_recentTabsMenu = new KActionMenu(i18n("&Recently Closed Tabs"), this); + m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this); m_recentTabsMenu->setIcon(KIcon("edit-undo")); actionCollection()->addAction("closed_tabs", m_recentTabsMenu); connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)), this, SLOT(restoreClosedTab(QAction *))); - QAction* action = new QAction("&Empty Recently Closed Tabs", m_recentTabsMenu); + QAction* action = new QAction("Empty Recently Closed Tabs", m_recentTabsMenu); action->setIcon(KIcon("edit-clear-list")); action->setData(QVariant::fromValue(true)); m_recentTabsMenu->addAction(action); @@ -1137,6 +1147,12 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles())); + KAction* openTerminal = actionCollection()->addAction("open_terminal"); + openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); + openTerminal->setIcon(KIcon("terminal")); + openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4); + connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal())); + // setup 'Settings' menu m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection()); KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); @@ -1326,7 +1342,10 @@ void DolphinMainWindow::rememberClosedTab(int index) const QString primaryPath = m_viewTab[index].primaryView->url().path(); const QString iconName = KMimeType::iconNameForUrl(primaryPath); - QAction* action = new QAction(primaryPath, tabsMenu); + const QFontMetrics fm = fontMetrics(); + const QString actionText = fm.elidedText(primaryPath, Qt::ElideMiddle, fm.maxWidth() * 20); + + QAction* action = new QAction(actionText, tabsMenu); ClosedTab closedTab; closedTab.primaryUrl = m_viewTab[index].primaryView->url(); @@ -1348,12 +1367,13 @@ void DolphinMainWindow::rememberClosedTab(int index) } else { tabsMenu->insertAction(tabsMenu->actions().at(2), action); } - //10 is the limit, remove the oldest one to make room. It's actually 8, since - //the separator and the "Empty Recently Closed Tabs" entry count as one + + // assure that only up to 8 closed tabs are shown in the menu if (tabsMenu->actions().size() > 8) { tabsMenu->removeAction(tabsMenu->actions().last()); } actionCollection()->action("closed_tabs")->setEnabled(true); + KAcceleratorManager::manage(tabsMenu); } void DolphinMainWindow::clearStatusBar()