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