mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Initial step for showing the terminal embedded inside Dolphin instead of opening a separate window. This allows to synchronize the current directory of the terminal with the shown directory in Dolphin.
svn path=/trunk/KDE/kdebase/apps/; revision=661890
This commit is contained in:
parent
aad46935fa
commit
35ee348c45
6 changed files with 136 additions and 25 deletions
|
@ -66,6 +66,7 @@ set(dolphin_SRCS
|
||||||
sidebarpage.cpp
|
sidebarpage.cpp
|
||||||
statusbarspaceinfo.cpp
|
statusbarspaceinfo.cpp
|
||||||
statusbarmessagelabel.cpp
|
statusbarmessagelabel.cpp
|
||||||
|
terminalsidebarpage.cpp
|
||||||
treeviewcontextmenu.cpp
|
treeviewcontextmenu.cpp
|
||||||
treeviewsidebarpage.cpp
|
treeviewsidebarpage.cpp
|
||||||
sidebartreeview.cpp
|
sidebartreeview.cpp
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "infosidebarpage.h"
|
#include "infosidebarpage.h"
|
||||||
#include "metadatawidget.h"
|
#include "metadatawidget.h"
|
||||||
#include "mainwindowadaptor.h"
|
#include "mainwindowadaptor.h"
|
||||||
|
#include "terminalsidebarpage.h"
|
||||||
#include "treeviewsidebarpage.h"
|
#include "treeviewsidebarpage.h"
|
||||||
#include "kurlnavigator.h"
|
#include "kurlnavigator.h"
|
||||||
#include "viewpropertiesdialog.h"
|
#include "viewpropertiesdialog.h"
|
||||||
|
@ -813,7 +814,7 @@ void DolphinMainWindow::toggleShowHiddenFiles()
|
||||||
m_activeView->setShowHiddenFiles(show);
|
m_activeView->setShowHiddenFiles(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::showFilterBar()
|
void DolphinMainWindow::toggleFilterBarVisibility()
|
||||||
{
|
{
|
||||||
const KToggleAction* showFilterBarAction =
|
const KToggleAction* showFilterBarAction =
|
||||||
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
|
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
|
||||||
|
@ -879,15 +880,6 @@ void DolphinMainWindow::goHome()
|
||||||
m_activeView->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()
|
void DolphinMainWindow::findFile()
|
||||||
{
|
{
|
||||||
KRun::run("kfind", m_activeView->url());
|
KRun::run("kfind", m_activeView->url());
|
||||||
|
@ -1237,12 +1229,6 @@ void DolphinMainWindow::setupActions()
|
||||||
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
||||||
|
|
||||||
// setup 'Tools' menu
|
// 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");
|
QAction* findFile = actionCollection()->addAction("find_file");
|
||||||
findFile->setText(i18n("Find File..."));
|
findFile->setText(i18n("Find File..."));
|
||||||
findFile->setShortcut(Qt::CTRL | Qt::Key_F);
|
findFile->setShortcut(Qt::CTRL | Qt::Key_F);
|
||||||
|
@ -1252,7 +1238,7 @@ void DolphinMainWindow::setupActions()
|
||||||
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
|
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
|
||||||
showFilterBar->setText(i18n("Show Filter Bar"));
|
showFilterBar->setText(i18n("Show Filter Bar"));
|
||||||
showFilterBar->setShortcut(Qt::Key_Slash);
|
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");
|
QAction* compareFiles = actionCollection()->addAction("compare_files");
|
||||||
compareFiles->setText(i18n("Compare Files"));
|
compareFiles->setText(i18n("Compare Files"));
|
||||||
|
@ -1273,7 +1259,7 @@ void DolphinMainWindow::setupDockWidgets()
|
||||||
SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
|
SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
|
||||||
infoDock->setWidget(infoWidget);
|
infoDock->setWidget(infoWidget);
|
||||||
|
|
||||||
infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
|
infoDock->toggleViewAction()->setText(i18n("Information"));
|
||||||
actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
|
actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
|
||||||
|
|
||||||
addDockWidget(Qt::RightDockWidgetArea, infoDock);
|
addDockWidget(Qt::RightDockWidgetArea, infoDock);
|
||||||
|
@ -1289,7 +1275,7 @@ void DolphinMainWindow::setupDockWidgets()
|
||||||
TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
|
TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
|
||||||
treeViewDock->setWidget(treeWidget);
|
treeViewDock->setWidget(treeWidget);
|
||||||
|
|
||||||
treeViewDock->toggleViewAction()->setText(i18n("Show Folders Panel"));
|
treeViewDock->toggleViewAction()->setText(i18n("Folders"));
|
||||||
actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
|
actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
|
||||||
|
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
|
addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
|
||||||
|
@ -1302,10 +1288,25 @@ void DolphinMainWindow::setupDockWidgets()
|
||||||
connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
|
connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
|
||||||
this, SLOT(dropUrls(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();
|
const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
|
||||||
if (firstRun) {
|
if (firstRun) {
|
||||||
infoDock->hide();
|
infoDock->hide();
|
||||||
treeViewDock->hide();
|
treeViewDock->hide();
|
||||||
|
terminalDock->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDockWidget *placesDock = new QDockWidget(i18n("Places"));
|
QDockWidget *placesDock = new QDockWidget(i18n("Places"));
|
||||||
|
|
|
@ -309,10 +309,10 @@ private slots:
|
||||||
void toggleShowHiddenFiles();
|
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.
|
* 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. */
|
/** Increases the size of the current set view mode. */
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
|
@ -349,9 +349,6 @@ private slots:
|
||||||
/** Goes to the home URL. */
|
/** Goes to the home URL. */
|
||||||
void goHome();
|
void goHome();
|
||||||
|
|
||||||
/** Opens a terminal for the current shown directory. */
|
|
||||||
void openTerminal();
|
|
||||||
|
|
||||||
/** Opens KFind for the current shown directory. */
|
/** Opens KFind for the current shown directory. */
|
||||||
void findFile();
|
void findFile();
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
<Action name="show_places_panel" />
|
<Action name="show_places_panel" />
|
||||||
<Action name="show_info_panel" />
|
<Action name="show_info_panel" />
|
||||||
<Action name="show_folders_panel" />
|
<Action name="show_folders_panel" />
|
||||||
|
<Action name="show_terminal_panel" />
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu name="navigation_bar">
|
<Menu name="navigation_bar">
|
||||||
<text>Navigation Bar</text>
|
<text>Navigation Bar</text>
|
||||||
|
@ -64,7 +65,6 @@
|
||||||
<Action name="view_properties" />
|
<Action name="view_properties" />
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu name="tools">
|
<Menu name="tools">
|
||||||
<Action name="open_terminal" />
|
|
||||||
<Action name="find_file" />
|
<Action name="find_file" />
|
||||||
<Action name="show_filter_bar" />
|
<Action name="show_filter_bar" />
|
||||||
<Action name="compare_files" />
|
<Action name="compare_files" />
|
||||||
|
|
60
src/terminalsidebarpage.cpp
Normal file
60
src/terminalsidebarpage.cpp
Normal file
|
@ -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"
|
52
src/terminalsidebarpage.h
Normal file
52
src/terminalsidebarpage.h
Normal file
|
@ -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
|
Loading…
Reference in a new issue