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