]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/terminal/terminalpanel.h
a1b7af03aa31b43986629a4dbe96100f763166ec
[dolphin.git] / src / panels / terminal / terminalpanel.h
1 /*
2 * SPDX-FileCopyrightText: 2007-2010 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef TERMINALPANEL_H
8 #define TERMINALPANEL_H
9
10 #include "kiofuse_interface.h"
11 #include "panels/panel.h"
12
13 #include <QQueue>
14
15 class TerminalInterface;
16 class KActionCollection;
17 class KMessageWidget;
18 class QVBoxLayout;
19 class QWidget;
20
21 namespace KIO
22 {
23 class StatJob;
24 }
25
26 namespace KParts
27 {
28 class ReadOnlyPart;
29 }
30 class KJob;
31 /**
32 * @brief Shows the terminal which is synchronized with the URL of the
33 * active view.
34 */
35 class TerminalPanel : public Panel
36 {
37 Q_OBJECT
38
39 public:
40 explicit TerminalPanel(QWidget *parent = nullptr);
41 ~TerminalPanel() override;
42
43 /**
44 * @brief This function is used to set the terminal panels's cwd to
45 * home when an unmounting request is received.
46 */
47 void goHome();
48 QString currentWorkingDirectory();
49 bool isHiddenInVisibleWindow() const;
50 bool terminalHasFocus() const;
51 bool hasProgramRunning() const;
52 QString runningProgramName() const;
53 KActionCollection *actionCollection();
54
55 public Q_SLOTS:
56 void terminalExited();
57 void dockVisibilityChanged();
58
59 Q_SIGNALS:
60 void hideTerminalPanel();
61
62 /**
63 * Is emitted if the an URL change is requested.
64 */
65 void changeUrl(const QUrl &url);
66
67 protected:
68 bool urlChanged() override;
69
70 void showEvent(QShowEvent *event) override;
71
72 private Q_SLOTS:
73 void slotMostLocalUrlResult(KJob *job);
74 void slotKonsolePartCurrentDirectoryChanged(const QString &dir);
75
76 private:
77 enum class HistoryPolicy { AddToHistory, SkipHistory };
78
79 void changeDir(const QUrl &url);
80 void sendCdToTerminal(const QString &path, HistoryPolicy addToHistory = HistoryPolicy::AddToHistory);
81 void sendCdToTerminalKIOFuse(const QUrl &url);
82
83 private:
84 bool m_clearTerminal;
85 KIO::StatJob *m_mostLocalUrlJob;
86
87 QVBoxLayout *m_layout;
88 TerminalInterface *m_terminal;
89 QWidget *m_terminalWidget;
90 KMessageWidget *m_konsolePartMissingMessage;
91 KParts::ReadOnlyPart *m_konsolePart;
92 QString m_konsolePartCurrentDirectory;
93 QQueue<QString> m_sendCdToTerminalHistory;
94 org::kde::KIOFuse::VFS m_kiofuseInterface;
95 };
96
97 #endif // TERMINALPANEL_H