1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "terminalsidebarpage.h"
22 #include <klibloader.h>
23 #include <kde_terminal_interface.h>
24 #include <kparts/part.h>
27 #include <QVBoxLayout>
29 TerminalSidebarPage::TerminalSidebarPage(QWidget
* parent
) :
34 m_layout
= new QVBoxLayout(this);
35 m_layout
->setMargin(0);
38 TerminalSidebarPage::~TerminalSidebarPage()
42 void TerminalSidebarPage::setUrl(const KUrl
& url
)
44 if (!SidebarPage::url().equals(url
, KUrl::CompareWithoutTrailingSlash
)) {
45 SidebarPage::setUrl(url
);
46 if ((m_terminal
!= 0) && isVisible()) {
47 m_terminal
->showShellInDir(url
.path());
52 void TerminalSidebarPage::showEvent(QShowEvent
* event
)
54 if (m_terminal
== 0) {
55 KLibFactory
* factory
= KLibLoader::self()->factory("libkonsolepart");
56 KParts::Part
* part
= static_cast<KParts::Part
*>(factory
->create(this, "KParts::ReadOnlyPart"));
58 m_layout
->addWidget(part
->widget());
60 // TODO: in KDE3 the following code worked:
61 // m_terminal = static_cast<TerminalInterface*>(part->qt_cast("TerminalInterface"));
62 // which does not work anymore in Qt4. As temporary workaround <konsole_part.h> is
64 m_terminal
= static_cast<TerminalInterface
*>(reinterpret_cast<Konsole::Part
*>(part
));
67 if (m_terminal
!= 0) {
68 m_terminal
->showShellInDir(url().path());
69 m_terminal
->sendInput("clear\n");
72 SidebarPage::showEvent(event
);
75 #include "terminalsidebarpage.moc"