]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Call updatePasteAction() in DolphinPart::openUrl(). Fixes the problem that the paste...
[dolphin.git] / src / dolphinmainwindow.cpp
index aa72a2b9b6dd6798aed070940af39d25362cf333..31f3f48a9ed482673ce76afd05f111276ce1dfc5 100644 (file)
@@ -85,6 +85,7 @@
 #include <QLineEdit>
 #include <QSplitter>
 #include <QDockWidget>
+#include <kacceleratormanager.h>
 
 /*
  * Remembers the tab configuration if a tab has been closed.
@@ -236,6 +237,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 +333,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);
@@ -1008,6 +1012,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);
@@ -1326,7 +1331,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();
@@ -1354,6 +1362,7 @@ void DolphinMainWindow::rememberClosedTab(int index)
         tabsMenu->removeAction(tabsMenu->actions().last());
     }
     actionCollection()->action("closed_tabs")->setEnabled(true);
+    KAcceleratorManager::manage(tabsMenu);
 }
 
 void DolphinMainWindow::clearStatusBar()