File indexing completed on 2024-05-05 05:57:00
0001 /* 0002 SPDX-FileCopyrightText: 2008-2009 Eike Hein <hein@kde.org> 0003 SPDX-FileCopyrightText: 2009 Juan Carlos Torres <carlosdgtorres@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #ifndef SESSION_H 0009 #define SESSION_H 0010 0011 #include "splitter.h" 0012 0013 #include <QObject> 0014 0015 class Terminal; 0016 0017 class Session : public QObject 0018 { 0019 Q_OBJECT 0020 0021 public: 0022 enum SessionType { 0023 Single, 0024 TwoHorizontal, 0025 TwoVertical, 0026 Quad, 0027 }; 0028 enum GrowthDirection { 0029 Up, 0030 Right, 0031 Down, 0032 Left, 0033 }; 0034 0035 explicit Session(const QString &workingDir, SessionType type = Single, QWidget *parent = nullptr); 0036 ~Session(); 0037 0038 int id() 0039 { 0040 return m_sessionId; 0041 } 0042 const QString title() 0043 { 0044 return m_title; 0045 } 0046 QWidget *widget() 0047 { 0048 return m_baseSplitter; 0049 } 0050 0051 int activeTerminalId() 0052 { 0053 return m_activeTerminalId; 0054 } 0055 const QString terminalIdList(); 0056 int terminalCount() 0057 { 0058 return m_terminals.size(); 0059 } 0060 bool hasTerminal(int terminalId); 0061 Terminal *getTerminal(int terminalId); 0062 0063 bool closable() 0064 { 0065 return m_closable; 0066 } 0067 void setClosable(bool closable) 0068 { 0069 m_closable = closable; 0070 } 0071 0072 bool keyboardInputEnabled(); 0073 void setKeyboardInputEnabled(bool enabled); 0074 bool keyboardInputEnabled(int terminalId); 0075 void setKeyboardInputEnabled(int terminalId, bool enabled); 0076 bool hasTerminalsWithKeyboardInputEnabled(); 0077 bool hasTerminalsWithKeyboardInputDisabled(); 0078 0079 bool monitorActivityEnabled(); 0080 void setMonitorActivityEnabled(bool enabled); 0081 bool monitorActivityEnabled(int terminalId); 0082 void setMonitorActivityEnabled(int terminalId, bool enabled); 0083 bool hasTerminalsWithMonitorActivityEnabled(); 0084 bool hasTerminalsWithMonitorActivityDisabled(); 0085 0086 bool monitorSilenceEnabled(); 0087 void setMonitorSilenceEnabled(bool enabled); 0088 bool monitorSilenceEnabled(int terminalId); 0089 void setMonitorSilenceEnabled(int terminalId, bool enabled); 0090 bool hasTerminalsWithMonitorSilenceEnabled(); 0091 bool hasTerminalsWithMonitorSilenceDisabled(); 0092 0093 bool wantsBlur() const; 0094 0095 public Q_SLOTS: 0096 void closeTerminal(int terminalId = -1); 0097 0098 void focusNextTerminal(); 0099 void focusPreviousTerminal(); 0100 0101 int splitLeftRight(int terminalId = -1); 0102 int splitTopBottom(int terminalId = -1); 0103 0104 int tryGrowTerminal(int terminalId, GrowthDirection direction, uint pixels); 0105 0106 void runCommand(const QString &command, int terminalId = -1); 0107 0108 void manageProfiles(); 0109 void editProfile(); 0110 0111 void reconnectMonitorActivitySignals(); 0112 0113 Q_SIGNALS: 0114 void titleChanged(const QString &title); 0115 void titleChanged(int sessionId, const QString &title); 0116 void terminalManuallyActivated(Terminal *terminal); 0117 void keyboardInputBlocked(Terminal *terminal); 0118 void activityDetected(Terminal *terminal); 0119 void silenceDetected(Terminal *terminal); 0120 void destroyed(int sessionId); 0121 void wantsBlurChanged(); 0122 0123 private Q_SLOTS: 0124 void setActiveTerminal(int terminalId); 0125 void setTitle(int terminalId, const QString &title); 0126 0127 void cleanup(int terminalId); 0128 void cleanup(); 0129 void prepareShutdown(); 0130 0131 private: 0132 void setupSession(SessionType type); 0133 0134 Terminal *addTerminal(QSplitter *parent, QString workingDir = QString()); 0135 int split(Terminal *terminal, Qt::Orientation orientation); 0136 0137 QString m_workingDir; 0138 static int m_availableSessionId; 0139 int m_sessionId; 0140 0141 Splitter *m_baseSplitter; 0142 0143 int m_activeTerminalId; 0144 std::map<int, std::unique_ptr<Terminal>> m_terminals; 0145 0146 QString m_title; 0147 0148 bool m_closable; 0149 }; 0150 0151 #endif