]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Initial step for showing the terminal embedded inside Dolphin instead of opening...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2007 21:50:24 +0000 (21:50 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 6 May 2007 21:50:24 +0000 (21:50 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=661890

src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinui.rc
src/terminalsidebarpage.cpp [new file with mode: 0644]
src/terminalsidebarpage.h [new file with mode: 0644]

index 123eed3ac9a59e71442b893fc59e58f09d93a071..54e59583d2e616728b0ee125f3fdd2b4c3e7a50b 100644 (file)
@@ -66,6 +66,7 @@ set(dolphin_SRCS
    sidebarpage.cpp
    statusbarspaceinfo.cpp
    statusbarmessagelabel.cpp
+   terminalsidebarpage.cpp
    treeviewcontextmenu.cpp
    treeviewsidebarpage.cpp
    sidebartreeview.cpp
index ee4830785d07a3ea3ce5452d5cc6c53d1ca93b6f..00eadbda9075c94799733b4e0ea2cf3cb0599c46 100644 (file)
@@ -30,6 +30,7 @@
 #include "infosidebarpage.h"
 #include "metadatawidget.h"
 #include "mainwindowadaptor.h"
+#include "terminalsidebarpage.h"
 #include "treeviewsidebarpage.h"
 #include "kurlnavigator.h"
 #include "viewpropertiesdialog.h"
@@ -813,7 +814,7 @@ void DolphinMainWindow::toggleShowHiddenFiles()
     m_activeView->setShowHiddenFiles(show);
 }
 
-void DolphinMainWindow::showFilterBar()
+void DolphinMainWindow::toggleFilterBarVisibility()
 {
     const KToggleAction* showFilterBarAction =
         static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
@@ -879,15 +880,6 @@ void DolphinMainWindow::goHome()
     m_activeView->goHome();
 }
 
-void DolphinMainWindow::openTerminal()
-{
-    QString command("konsole --workdir \"");
-    command.append(m_activeView->url().path());
-    command.append('\"');
-
-    KRun::runCommand(command, "Konsole", "konsole");
-}
-
 void DolphinMainWindow::findFile()
 {
     KRun::run("kfind", m_activeView->url());
@@ -1237,12 +1229,6 @@ void DolphinMainWindow::setupActions()
     KStandardAction::home(this, SLOT(goHome()), actionCollection());
 
     // setup 'Tools' menu
-    QAction* openTerminal = actionCollection()->addAction("open_terminal");
-    openTerminal->setText(i18n("Open Terminal"));
-    openTerminal->setShortcut(Qt::Key_F4);
-    openTerminal->setIcon(KIcon("konsole"));
-    connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
-
     QAction* findFile = actionCollection()->addAction("find_file");
     findFile->setText(i18n("Find File..."));
     findFile->setShortcut(Qt::CTRL | Qt::Key_F);
@@ -1252,7 +1238,7 @@ void DolphinMainWindow::setupActions()
     KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
     showFilterBar->setText(i18n("Show Filter Bar"));
     showFilterBar->setShortcut(Qt::Key_Slash);
-    connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
+    connect(showFilterBar, SIGNAL(triggered()), this, SLOT(toggleFilterBarVisibility()));
 
     QAction* compareFiles = actionCollection()->addAction("compare_files");
     compareFiles->setText(i18n("Compare Files"));
@@ -1273,7 +1259,7 @@ void DolphinMainWindow::setupDockWidgets()
     SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
     infoDock->setWidget(infoWidget);
 
-    infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
+    infoDock->toggleViewAction()->setText(i18n("Information"));
     actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
 
     addDockWidget(Qt::RightDockWidgetArea, infoDock);
@@ -1289,7 +1275,7 @@ void DolphinMainWindow::setupDockWidgets()
     TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
     treeViewDock->setWidget(treeWidget);
 
-    treeViewDock->toggleViewAction()->setText(i18n("Show Folders Panel"));
+    treeViewDock->toggleViewAction()->setText(i18n("Folders"));
     actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
 
     addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
@@ -1302,10 +1288,25 @@ void DolphinMainWindow::setupDockWidgets()
     connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
             this, SLOT(dropUrls(KUrl::List, KUrl)));
 
+    // setup "Terminal"
+    QDockWidget* terminalDock = new QDockWidget(i18n("Terminal"));
+    terminalDock->setObjectName("terminalDock");
+    terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
+    SidebarPage* terminalWidget = new TerminalSidebarPage(terminalDock);
+    terminalDock->setWidget(terminalWidget);
+
+    terminalDock->toggleViewAction()->setText(i18n("Terminal"));
+    actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction());
+
+    addDockWidget(Qt::RightDockWidgetArea, terminalDock);
+    connect(this, SIGNAL(urlChanged(KUrl)),
+            terminalWidget, SLOT(setUrl(KUrl)));
+
     const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
     if (firstRun) {
         infoDock->hide();
         treeViewDock->hide();
+        terminalDock->hide();
     }
 
     QDockWidget *placesDock = new QDockWidget(i18n("Places"));
index e1de7f808e5ba67c35157e3a48d8e56e2cb916eb..297408cc6024415e68aa0f25d8c3bb7460199fc4 100644 (file)
@@ -309,10 +309,10 @@ private slots:
     void toggleShowHiddenFiles();
 
     /**
-     * Switches between showing and hiding of the filter bar dependent
+     * Toggles between showing and hiding of the filter bar dependent
      * from the current state of the 'Show Filter Bar' menu toggle action.
      */
-    void showFilterBar();
+    void toggleFilterBarVisibility();
 
     /** Increases the size of the current set view mode. */
     void zoomIn();
@@ -349,9 +349,6 @@ private slots:
     /** Goes to the home URL. */
     void goHome();
 
-    /** Opens a terminal for the current shown directory. */
-    void openTerminal();
-
     /** Opens KFind for the current shown directory. */
     void findFile();
 
index f7207b2f87f824eefe8934b056ac0d02d4073d74..54c60e15d10b9095fd6355cc7fae17916f74a6d8 100644 (file)
@@ -54,6 +54,7 @@
     <Action name="show_places_panel" />
     <Action name="show_info_panel" />
     <Action name="show_folders_panel" />
+    <Action name="show_terminal_panel" />
    </Menu>
    <Menu name="navigation_bar">
     <text>Navigation Bar</text>
@@ -64,7 +65,6 @@
    <Action name="view_properties" />
   </Menu>
   <Menu name="tools">
-    <Action name="open_terminal" />
     <Action name="find_file" />
     <Action name="show_filter_bar" />
     <Action name="compare_files" />
diff --git a/src/terminalsidebarpage.cpp b/src/terminalsidebarpage.cpp
new file mode 100644 (file)
index 0000000..8c8dced
--- /dev/null
@@ -0,0 +1,60 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "terminalsidebarpage.h"
+
+#include <klibloader.h>
+#include <kde_terminal_interface.h>
+#include <kparts/part.h>
+
+#include <QVBoxLayout>
+
+TerminalSidebarPage::TerminalSidebarPage(QWidget* parent) :
+    SidebarPage(parent),
+    m_layout(0),
+    m_terminal(0)
+{
+    m_layout = new QVBoxLayout(this);
+    m_layout->setMargin(0);
+}
+
+TerminalSidebarPage::~TerminalSidebarPage()
+{
+}
+
+void TerminalSidebarPage::setUrl(const KUrl& url)
+{
+    SidebarPage::setUrl(url);
+    // TODO: synchronize terminal
+}
+
+void TerminalSidebarPage::showEvent(QShowEvent* event)
+{
+    if (m_terminal == 0) {
+        KLibFactory* factory = KLibLoader::self()->factory("libkonsolepart");
+        KParts::Part* part = static_cast<KParts::Part*>(factory->create(this, "KParts::ReadOnlyPart"));
+        if (part != 0) {
+            m_terminal = part->widget();
+            m_layout->addWidget(m_terminal);
+        }
+    }
+    SidebarPage::showEvent(event);
+}
+
+#include "terminalsidebarpage.moc"
diff --git a/src/terminalsidebarpage.h b/src/terminalsidebarpage.h
new file mode 100644 (file)
index 0000000..ddefad9
--- /dev/null
@@ -0,0 +1,52 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef TERMINALSIDEBARPAGE_H
+#define TERMINALSIDEBARPAGE_H
+
+#include <sidebarpage.h>
+
+class QVBoxLayout;
+
+/**
+ * @brief Shows the terminal which is synchronized with the URL of the
+ *        active view.
+ */
+class TerminalSidebarPage : public SidebarPage
+{
+    Q_OBJECT
+
+public:
+    TerminalSidebarPage(QWidget* parent = 0);
+    virtual ~TerminalSidebarPage();
+
+public slots:
+    /** @see SidebarPage::setUrl(). */
+    virtual void setUrl(const KUrl& url);
+
+protected:
+    /** @see QWidget::showEvent() */
+    virtual void showEvent(QShowEvent* event);
+
+private:
+    QVBoxLayout* m_layout;
+    QWidget* m_terminal;
+};
+
+#endif // TERMINALSIDEBARPAGE_H