]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Using the "document-properties" icon for the Properties entry of the RMB context...
[dolphin.git] / src / dolphinmainwindow.cpp
index c0910e2740cf8b01bfea179b5bade8be2c0a5db7..0151d48b17a273468edbb4e3812d1f63f524361b 100644 (file)
@@ -78,6 +78,7 @@
 #include <kurlnavigator.h>
 #include <kurl.h>
 #include <kurlcombobox.h>
+#include <ktoolinvocation.h>
 
 #include <QDBusMessage>
 #include <QKeyEvent>
@@ -237,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);
     }
 }
@@ -331,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);
@@ -506,7 +510,7 @@ void DolphinMainWindow::restoreClosedTab(QAction* action)
         // action and the separator
         QList<QAction*> 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 {
@@ -739,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) {
@@ -843,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];
@@ -1009,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);
@@ -1104,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);
@@ -1138,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());
@@ -1352,8 +1367,8 @@ 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());
     }