VirtualBox

Changeset 77822 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 21, 2019 8:23:11 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Adding guest control console to machine's debug menu.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r76606 r77822  
    807807    switch (runtimeMenuDebuggerActionType)
    808808    {
    809         case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Statistics:  strResult = "Statistics"; break;
    810         case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_CommandLine: strResult = "CommandLine"; break;
    811         case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Logging:     strResult = "Logging"; break;
    812         case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_LogDialog:   strResult = "LogDialog"; break;
    813         case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All:         strResult = "All"; break;
     809        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Statistics:            strResult = "Statistics"; break;
     810        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_CommandLine:           strResult = "CommandLine"; break;
     811        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Logging:               strResult = "Logging"; break;
     812        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_LogDialog:             strResult = "LogDialog"; break;
     813        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_GuestControlConsole:   strResult = "GuestControlConsole"; break;
     814        case UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All:                   strResult = "All"; break;
    814815        default:
    815816        {
     
    827828     * to search through the keys using 'case-insensitive' rule: */
    828829    QStringList keys;      QList<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType> values;
    829     keys << "Statistics";  values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Statistics;
    830     keys << "CommandLine"; values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_CommandLine;
    831     keys << "Logging";     values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Logging;
    832     keys << "LogDialog";   values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_LogDialog;
    833     keys << "All";         values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All;
     830    keys << "Statistics";           values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Statistics;
     831    keys << "CommandLine";          values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_CommandLine;
     832    keys << "Logging";              values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Logging;
     833    keys << "LogDialog";            values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_LogDialog;
     834    keys << "GuestControlConsole";  values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_GuestControlConsole;
     835    keys << "All";                  values << UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_All;
    834836    /* Invalid type for unknown words: */
    835837    if (!keys.contains(strRuntimeMenuDebuggerActionType, Qt::CaseInsensitive))
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r77377 r77822  
    606606    enum RuntimeMenuDebuggerActionType
    607607    {
    608         RuntimeMenuDebuggerActionType_Invalid     = 0,
    609         RuntimeMenuDebuggerActionType_Statistics  = RT_BIT(0),
    610         RuntimeMenuDebuggerActionType_CommandLine = RT_BIT(1),
    611         RuntimeMenuDebuggerActionType_Logging     = RT_BIT(2),
    612         RuntimeMenuDebuggerActionType_LogDialog   = RT_BIT(3),
    613         RuntimeMenuDebuggerActionType_All         = 0xFFFF
     608        RuntimeMenuDebuggerActionType_Invalid              = 0,
     609        RuntimeMenuDebuggerActionType_Statistics           = RT_BIT(0),
     610        RuntimeMenuDebuggerActionType_CommandLine          = RT_BIT(1),
     611        RuntimeMenuDebuggerActionType_Logging              = RT_BIT(2),
     612        RuntimeMenuDebuggerActionType_LogDialog            = RT_BIT(3),
     613        RuntimeMenuDebuggerActionType_GuestControlConsole  = RT_BIT(4),
     614        RuntimeMenuDebuggerActionType_All                  = 0xFFFF
    614615    };
    615616#endif /* VBOX_WITH_DEBUGGER_GUI */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.cpp

    r77584 r77822  
    28992899    {
    29002900        setName(QApplication::translate("UIActionPool", "Show &Log...", "debug action"));
     2901    }
     2902};
     2903
     2904/** Simple action extension, used as 'Guest Control Terminal' action class. */
     2905class UIActionSimpleRuntimeGuestControlConsole : public UIActionSimple
     2906{
     2907    Q_OBJECT;
     2908
     2909public:
     2910
     2911    /** Constructs action passing @a pParent to the base-class. */
     2912    UIActionSimpleRuntimeGuestControlConsole(UIActionPool *pParent)
     2913        : UIActionSimple(pParent, true)
     2914    {}
     2915
     2916protected:
     2917
     2918    /** Returns action extra-data ID. */
     2919    virtual int extraDataID() const /* override */
     2920    {
     2921        return UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_GuestControlConsole;
     2922    }
     2923    /** Returns action extra-data key. */
     2924    virtual QString extraDataKey() const /* override */
     2925    {
     2926        return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_GuestControlConsole);
     2927    }
     2928    /** Returns whether action is allowed. */
     2929    virtual bool isAllowed() const /* override */
     2930    {
     2931        return actionPool()->toRuntime()->isAllowedInMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_GuestControlConsole);
     2932    }
     2933
     2934    /** Returns shortcut extra-data ID. */
     2935    virtual QString shortcutExtraDataID() const /* override */
     2936    {
     2937        return QString("GuestControlConsole");
     2938    }
     2939
     2940    /** Handles translation event. */
     2941    virtual void retranslateUi() /* override */
     2942    {
     2943        setName(QApplication::translate("UIActionPool", "Guest Control Terminal...", "debug action"));
    29012944    }
    29022945};
     
    33423385    m_pool[UIActionIndexRT_M_Debug_T_Logging] = new UIActionToggleRuntimeLogging(this);
    33433386    m_pool[UIActionIndexRT_M_Debug_S_ShowLogDialog] = new UIActionSimpleRuntimeShowLogs(this);
     3387    m_pool[UIActionIndexRT_M_Debug_S_GuestControlConsole] = new UIActionSimpleRuntimeGuestControlConsole(this);
    33443388#endif /* VBOX_WITH_DEBUGGER_GUI */
    33453389
     
    42544298    /* 'Log Dialog' action: */
    42554299    addAction(pMenu, action(UIActionIndexRT_M_Debug_S_ShowLogDialog));
     4300    /* 'Guest Control Terminal' action: */
     4301    addAction(pMenu, action(UIActionIndexRT_M_Debug_S_GuestControlConsole));
    42564302
    42574303    /* Mark menu as valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolRuntime.h

    r77584 r77822  
    122122    UIActionIndexRT_M_Debug_T_Logging,
    123123    UIActionIndexRT_M_Debug_S_ShowLogDialog,
     124    UIActionIndexRT_M_Debug_S_GuestControlConsole,
    124125#endif
    125126
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlConsole.cpp

    r76606 r77822  
    2323/* GUI includes: */
    2424#include "UIGuestControlConsole.h"
    25 
    26 
    27 UIGuestControlConsole::UIGuestControlConsole(QWidget* parent /* = 0 */)
     25#include "UIGuestControlInterface.h"
     26
     27UIGuestControlConsole::UIGuestControlConsole(const CGuest &comGuest, QWidget* parent /* = 0 */)
    2828    :QPlainTextEdit(parent)
     29    , m_comGuest(comGuest)
    2930    , m_strGreet("Welcome to 'Guest Control Console'. Type 'help' for help\n")
    3031    , m_strPrompt("$>")
    3132    , m_uCommandHistoryIndex(0)
    32 {
     33    , m_pControlInterface(0)
     34{
     35    m_pControlInterface = new UIGuestControlInterface(this, m_comGuest);
     36
     37    connect(m_pControlInterface, &UIGuestControlInterface::sigOutputString,
     38            this, &UIGuestControlConsole::sltOutputReceived);
     39
    3340    /* Configure this: */
    3441    setUndoRedoEnabled(false);
     
    4855}
    4956
     57void UIGuestControlConsole::commandEntered(const QString &strCommand)
     58{
     59    if (m_pControlInterface)
     60        m_pControlInterface->putCommand(strCommand);
     61}
     62
     63void UIGuestControlConsole::sltOutputReceived(const QString &strOutput)
     64{
     65    putOutput(strOutput);
     66}
     67
    5068void UIGuestControlConsole::reset()
    5169{
     
    124142                if (!strCommand.isEmpty())
    125143                {
    126                     emit commandEntered(strCommand);
     144                    commandEntered(strCommand);
    127145                    if (!m_tCommandHistory.contains(strCommand))
    128146                        m_tCommandHistory.push_back(strCommand);
     
    297315    return list;
    298316}
    299 
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlConsole.h

    r76581 r77822  
    2525# include <QPlainTextEdit>
    2626
     27/* COM includes: */
     28#include "COMEnums.h"
     29#include "CGuest.h"
     30
     31class UIGuestControlInterface;
    2732/** QPlainTextEdit extension to provide a simple terminal like widget. */
    2833class UIGuestControlConsole : public QPlainTextEdit
     
    3136    Q_OBJECT;
    3237
    33 signals:
    34     /* This is emitted when return key is pressed */
    35     void commandEntered(QString command);
    3638
    3739public:
    3840
    39     UIGuestControlConsole(QWidget* parent = 0);
     41    UIGuestControlConsole(const CGuest &comGuest, QWidget* parent = 0);
    4042    /* @p strOutput is displayed in the console */
    4143    void putOutput(const QString &strOutput);
     
    5052private slots:
    5153
     54    void sltOutputReceived(const QString &strOutput);
    5255
    5356private:
     
    6669    QString        getPreviousCommandFromHistory(const QString &originalString = QString());
    6770    void           completeByTab();
     71    void           commandEntered(const QString &strCommand);
     72
    6873    /* Return a list of words that start with @p strSearch */
    6974    QList<QString> matchedWords(const QString &strSearch) const;
     75    CGuest         m_comGuest;
    7076    const QString  m_strGreet;
    7177    const QString  m_strPrompt;
     
    7480    CommandHistory m_tCommandHistory;
    7581    unsigned       m_uCommandHistoryIndex;
     82    UIGuestControlInterface  *m_pControlInterface;
    7683};
    7784
    7885#endif /* !FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h */
    79 
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlInterface.cpp

    r76606 r77822  
    168168    , m_comGuest(comGuest)
    169169    , m_strHelp("[common-options]               [--username <name>] [--domain <domain>]\n"
    170                 "                                   [--passwordfile <file> | --password <password>]\n"
     170                "                               [--passwordfile <file> | --password <password>]\n"
    171171                "start                           [common-options]\n"
    172172                "                                   [--exe <path to executable>] [--timeout <msec>]\n"
     
    179179                "                                   [-P|--parents] [<guest directory>\n"
    180180                "                                   [--sessionid <id> |  [sessionname <name>]]\n"
    181                 "[stat|ls                          [common-options]\n"
     181                "stat|ls                          [common-options]\n"
    182182                "                                   [--sessionid <id> |  [sessionname <name>]]\n"
    183183                )
     
    540540    if (!isGuestAdditionsAvailable(m_comGuest))
    541541    {
    542         emit sigOutputString("No guest addtions detected. Guest control needs guest additions");
     542        emit sigOutputString("No guest addtions detected. Guest control requires guest additions");
    543543        return;
    544544    }
     
    676676    return strObjectInfo;
    677677}
    678 
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlInterface.h

    r76581 r77822  
    6161    /** @} */
    6262
    63 
    6463private slots:
    6564
     
    9392    QString getFsObjInfoString(const T &fsObjectInfo) const;
    9493
    95 
    9694    CGuest        m_comGuest;
    9795    const QString m_strHelp;
     
    102100
    103101#endif /* !FEQT_INCLUDED_SRC_guestctrl_UIGuestControlInterface_h */
    104 
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestProcessControlDialog.cpp

    r77647 r77822  
    2424#include "UIExtraDataManager.h"
    2525#include "UIIconPool.h"
     26#include "UIGuestControlConsole.h"
    2627#include "UIGuestProcessControlDialog.h"
    27 #include "UIGuestProcessControlWidget.h"
    2828#include "VBoxGlobal.h"
    2929#ifdef VBOX_WS_MAC
     
    7171    setWindowTitle(tr("%1 - Guest Control").arg(m_strMachineName));
    7272    /* Translate buttons: */
    73     button(ButtonType_Close)->setText(UIGuestProcessControlWidget::tr("Close"));
     73    button(ButtonType_Close)->setText(tr("Close"));
    7474}
    7575
     
    8383{
    8484    /* Create widget: */
    85     UIGuestProcessControlWidget *pWidget = new UIGuestProcessControlWidget(EmbedTo_Dialog, m_comGuest, this, m_strMachineName);
     85    UIGuestControlConsole *pConsole = new UIGuestControlConsole(m_comGuest);
    8686
    87     if (pWidget)
     87    if (pConsole)
    8888    {
    8989        /* Configure widget: */
    90         setWidget(pWidget);
     90        setWidget(pConsole);
    9191        //setWidgetMenu(pWidget->menu());
    9292#ifdef VBOX_WS_MAC
     
    9494#endif
    9595        /* Add into layout: */
    96         centralWidget()->layout()->addWidget(pWidget);
     96        centralWidget()->layout()->addWidget(pConsole);
    9797    }
    9898}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestProcessControlWidget.cpp

    r77784 r77822  
    298298    , m_pSplitter(0)
    299299    , m_pTreeWidget(0)
    300     , m_pConsole(0)
    301     , m_pControlInterface(0)
    302300    , m_enmEmbedding(enmEmbedding)
    303301    , m_pToolBar(0)
     
    333331void UIGuestProcessControlWidget::prepareObjects()
    334332{
    335     m_pControlInterface = new UIGuestControlInterface(this, m_comGuest);
    336 
    337333    /* Create layout: */
    338334    m_pMainLayout = new QVBoxLayout(this);
     
    361357    }
    362358
    363     /* Disable the CLI for now (and maybe forever): */
    364 #ifdef WITH_GUEST_CONTROL_CLI
    365     m_pConsole = new UIGuestControlConsole;
    366 #endif
    367 
    368     if (m_pConsole)
    369     {
    370         m_pSplitter->addWidget(m_pConsole);
    371         setFocusProxy(m_pConsole);
    372     }
    373 
    374359    m_pSplitter->setStretchFactor(0, 2);
    375360    m_pSplitter->setStretchFactor(1, 1);
     
    391376{
    392377    qRegisterMetaType<QVector<int> >();
    393     connect(m_pControlInterface, &UIGuestControlInterface::sigOutputString,
    394             this, &UIGuestProcessControlWidget::sltConsoleOutputReceived);
    395     if (m_pConsole)
    396         connect(m_pConsole, &UIGuestControlConsole::commandEntered,
    397                 this, &UIGuestProcessControlWidget::sltConsoleCommandEntered);
    398378
    399379    if (m_pTreeWidget)
     
    417397{
    418398    updateTreeWidget();
    419 }
    420 
    421 void UIGuestProcessControlWidget::sltConsoleCommandEntered(const QString &strCommand)
    422 {
    423     if (m_pControlInterface)
    424     {
    425         m_pControlInterface->putCommand(strCommand);
    426     }
    427 }
    428 
    429 void UIGuestProcessControlWidget::sltConsoleOutputReceived(const QString &strOutput)
    430 {
    431     if (m_pConsole)
    432     {
    433         m_pConsole->putOutput(strOutput);
    434     }
    435399}
    436400
     
    588552    connect(sessionTreeItem, &UIGuestSessionTreeItem::sigGuessSessionUpdated,
    589553            this, &UIGuestProcessControlWidget::sltTreeItemUpdated);
    590     connect(sessionTreeItem, &UIGuestSessionTreeItem::sigGuestSessionErrorText,
    591             this, &UIGuestProcessControlWidget::sltGuestControlErrorText);
    592 }
    593 
    594 void UIGuestProcessControlWidget::sltGuestControlErrorText(QString strError)
    595 {
    596     if (m_pConsole)
    597     {
    598         m_pConsole->putOutput(strError);
    599     }
    600554}
    601555
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestProcessControlWidget.h

    r77647 r77822  
    6666
    6767    void sltGuestSessionsUpdated();
    68     void sltConsoleCommandEntered(const QString &strCommand);
    69     void sltConsoleOutputReceived(const QString &strOutput);
    7068    void sltGuestSessionRegistered(CGuestSession guestSession);
    7169    void sltGuestSessionUnregistered(CGuestSession guestSession);
    72     void sltGuestControlErrorText(QString strError);
    7370    void sltTreeItemUpdated();
    7471    void sltCloseSessionOrProcess();
     
    9289    QSplitter                *m_pSplitter;
    9390    UIGuestControlTreeWidget *m_pTreeWidget;
    94     UIGuestControlConsole    *m_pConsole;
    95     UIGuestControlInterface  *m_pControlInterface;
    9691    const EmbedTo             m_enmEmbedding;
    9792    UIToolBar                *m_pToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r77584 r77822  
    11801180    connect(actionPool()->action(UIActionIndexRT_M_Debug_S_ShowLogDialog), SIGNAL(triggered()),
    11811181            this, SLOT(sltShowLogDialog()));
     1182    connect(actionPool()->action(UIActionIndexRT_M_Debug_S_GuestControlConsole), SIGNAL(triggered()),
     1183            this, SLOT(sltShowGuestControlConsoleDialog()));
    11821184#endif /* VBOX_WITH_DEBUGGER_GUI */
    11831185
     
    24822484}
    24832485
     2486void UIMachineLogic::sltShowGuestControlConsoleDialog()
     2487{
     2488    if (machine().isNull() || !activeMachineWindow())
     2489        return;
     2490
     2491    /* Create a logviewer only if we don't have one already */
     2492    if (m_pProcessControlDialog)
     2493        return;
     2494
     2495    QIManagerDialog *pProcessControlDialog;
     2496    UIGuestProcessControlDialogFactory dialogFactory(actionPool(), console().GetGuest(), machine().GetName());
     2497    dialogFactory.prepare(pProcessControlDialog, activeMachineWindow());
     2498    if (pProcessControlDialog)
     2499    {
     2500        m_pProcessControlDialog = pProcessControlDialog;
     2501
     2502        /* Show instance: */
     2503        pProcessControlDialog->show();
     2504        pProcessControlDialog->setWindowState(pProcessControlDialog->windowState() & ~Qt::WindowMinimized);
     2505        pProcessControlDialog->activateWindow();
     2506        connect(pProcessControlDialog, &QIManagerDialog::sigClose,
     2507                this, &UIMachineLogic::sltCloseGuestControlConsoleDialog);
     2508    }
     2509}
     2510
     2511void UIMachineLogic::sltCloseGuestControlConsoleDialog()
     2512{
     2513    QIManagerDialog* pDialog = qobject_cast<QIManagerDialog*>(sender());
     2514    if (m_pProcessControlDialog != pDialog || !pDialog)
     2515        return;
     2516
     2517    /* Set the m_pLogViewerDialog to NULL before closing the dialog. or we will have redundant deletes*/
     2518    m_pProcessControlDialog = 0;
     2519    pDialog->close();
     2520    UIGuestProcessControlDialogFactory().cleanup(pDialog);
     2521}
    24842522#endif /* VBOX_WITH_DEBUGGER_GUI */
    24852523
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r77584 r77822  
    320320    /** Handles close signal from the log viewer dialog. */
    321321    void sltCloseLogViewerWindow();
     322    void sltShowGuestControlConsoleDialog();
     323    void sltCloseGuestControlConsoleDialog();
    322324#endif /* VBOX_WITH_DEBUGGER_GUI */
    323325
Note: See TracChangeset for help on using the changeset viewer.

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