VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlConsole.h@ 103982

Last change on this file since 103982 was 103803, checked in by vboxsync, 9 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: UIGuestControlConsole.h 103803 2024-03-12 11:15:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIGuestControlConsole class declaration.
4 */
5
6/*
7 * Copyright (C) 2016-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h
29#define FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35# include <QPlainTextEdit>
36
37/* COM includes: */
38#include "CGuest.h"
39
40class UIGuestControlInterface;
41/** QPlainTextEdit extension to provide a simple terminal like widget. */
42class UIGuestControlConsole : public QPlainTextEdit
43{
44
45 Q_OBJECT;
46
47
48public:
49
50 UIGuestControlConsole(const CGuest &comGuest, QWidget* parent = 0);
51 /* @p strOutput is displayed in the console */
52 void putOutput(const QString &strOutput);
53
54protected:
55
56 void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
57 void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
58 void mouseDoubleClickEvent(QMouseEvent *pEvent) RT_OVERRIDE;
59 void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
60
61private slots:
62
63 void sltOutputReceived(const QString &strOutput);
64
65private:
66
67 typedef QVector<QString> CommandHistory;
68 typedef QMap<QString, int> TabDictionary;
69
70 void reset();
71 void startNextLine();
72 /** Return the text of the curent line */
73 QString getCommandString();
74 /** Replaces the content of the last line with m_strPromt + @p stringNewContent */
75 void replaceLineContent(const QString &stringNewContent);
76 /** Get next/prev command from history. Return @p originalString if history is empty. */
77 QString getNextCommandFromHistory(const QString &originalString = QString());
78 QString getPreviousCommandFromHistory(const QString &originalString = QString());
79 void completeByTab();
80 void commandEntered(const QString &strCommand);
81
82 /* Return a list of words that start with @p strSearch */
83 QList<QString> matchedWords(const QString &strSearch) const;
84 CGuest m_comGuest;
85 const QString m_strGreet;
86 const QString m_strPrompt;
87 TabDictionary m_tabDictinary;
88 /* A vector of entered commands */
89 CommandHistory m_tCommandHistory;
90 unsigned m_uCommandHistoryIndex;
91 UIGuestControlInterface *m_pControlInterface;
92};
93
94#endif /* !FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette