VirtualBox

Changeset 85192 in vbox


Ignore:
Timestamp:
Jul 10, 2020 3:05:54 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139164
Message:

FE/Qt: bugref:9722: VirtualBox Manager: Implement Copy console connection commands for Serial and VNC connections.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r85151 r85192  
    13781378        setStatusTip(QApplication::translate("UIActionPool", "Delete console connection to disconnect ssh/vnc clients"));
    13791379    }
     1380};
     1381
     1382/** Simple action extension, used as 'Copy Command' action class. */
     1383class UIActionSimpleSelectorConsolePerformCopyCommand : public UIActionSimple
     1384{
     1385    Q_OBJECT;
     1386
     1387public:
     1388
     1389    /** Constructs action passing @a pParent to the base-class. */
     1390    UIActionSimpleSelectorConsolePerformCopyCommand(UIActionPool *pParent, bool fSerial)
     1391        : UIActionSimple(pParent, ":/file_manager_copy_16px.png", ":/file_manager_copy_16px.png") /// @todo replace with proper icon
     1392        , m_fSerial(fSerial)
     1393    {}
     1394
     1395protected:
     1396
     1397    /** Returns shortcut extra-data ID. */
     1398    virtual QString shortcutExtraDataID() const /* override */
     1399    {
     1400        return   m_fSerial
     1401               ? QString("CopyConsoleCommandSerial")
     1402               : QString("CopyConsoleCommandVNC");
     1403    }
     1404
     1405    /** Handles translation event. */
     1406    virtual void retranslateUi() /* override */
     1407    {
     1408        if (m_fSerial)
     1409        {
     1410            setName(QApplication::translate("UIActionPool", "&Copy Command (serial)"));
     1411            setStatusTip(QApplication::translate("UIActionPool", "Copy console command for serial connection"));
     1412        }
     1413        else
     1414        {
     1415            setName(QApplication::translate("UIActionPool", "&Copy Command (VNC)"));
     1416            setStatusTip(QApplication::translate("UIActionPool", "Copy console command for VNC connection"));
     1417        }
     1418    }
     1419
     1420private:
     1421
     1422    /** Holds whether this command is of serial type. */
     1423    bool  m_fSerial;
    13801424};
    13811425
     
    30633107    m_pool[UIActionIndexST_M_Machine_M_Console_S_CreateConnection] = new UIActionSimpleSelectorConsolePerformCreateConnection(this);
    30643108    m_pool[UIActionIndexST_M_Machine_M_Console_S_DeleteConnection] = new UIActionSimpleSelectorConsolePerformDeleteConnection(this);
     3109    m_pool[UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial] = new UIActionSimpleSelectorConsolePerformCopyCommand(this, true);
     3110    m_pool[UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC] = new UIActionSimpleSelectorConsolePerformCopyCommand(this, false);
    30653111    m_pool[UIActionIndexST_M_Machine_M_Close] = new UIActionMenuSelectorClose(this);
    30663112    m_pool[UIActionIndexST_M_Machine_M_Close_S_Detach] = new UIActionSimpleSelectorClosePerformDetach(this);
     
    38263872                    << action(UIActionIndexST_M_Machine_M_Console_S_CreateConnection)
    38273873                    << action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection)
     3874                    << action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial)
     3875                    << action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC)
    38283876                    // << action(UIActionIndexST_M_Machine_M_Close_S_Detach)
    38293877                    << action(UIActionIndexST_M_Machine_M_Close_S_SaveState)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r85111 r85192  
    109109    UIActionIndexST_M_Machine_M_Console_S_CreateConnection,
    110110    UIActionIndexST_M_Machine_M_Console_S_DeleteConnection,
     111    UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial,
     112    UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC,
    111113    UIActionIndexST_M_Machine_M_Close,
    112114    UIActionIndexST_M_Machine_M_Close_S_Detach,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r85191 r85192  
    11951195}
    11961196
     1197void UIVirtualBoxManager::sltPerformCopyCommandSerial()
     1198{
     1199    /* Get current item: */
     1200    UIVirtualMachineItem *pItem = currentItem();
     1201    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     1202    UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     1203    AssertPtrReturnVoid(pCloudItem);
     1204
     1205    /* Acquire cloud machine: */
     1206    CCloudMachine comMachine = pCloudItem->machine();
     1207
     1208    /* Put copied serial command to clipboard: */
     1209    QClipboard *pClipboard = QGuiApplication::clipboard();
     1210    AssertPtrReturnVoid(pClipboard);
     1211    pClipboard->setText(comMachine.GetSerialConsoleCommand());
     1212}
     1213
     1214void UIVirtualBoxManager::sltPerformCopyCommandVNC()
     1215{
     1216    /* Get current item: */
     1217    UIVirtualMachineItem *pItem = currentItem();
     1218    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     1219    UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     1220    AssertPtrReturnVoid(pCloudItem);
     1221
     1222    /* Acquire cloud machine: */
     1223    CCloudMachine comMachine = pCloudItem->machine();
     1224
     1225    /* Put copied VNC command to clipboard: */
     1226    QClipboard *pClipboard = QGuiApplication::clipboard();
     1227    AssertPtrReturnVoid(pClipboard);
     1228    pClipboard->setText(comMachine.GetVNCConsoleCommand());
     1229}
     1230
    11971231void UIVirtualBoxManager::sltPerformDiscardMachineState()
    11981232{
     
    20442078    connect(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection), &UIAction::triggered,
    20452079            this, &UIVirtualBoxManager::sltPerformDeleteConsoleConnectionForMachine);
     2080    connect(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial), &UIAction::triggered,
     2081            this, &UIVirtualBoxManager::sltPerformCopyCommandSerial);
     2082    connect(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC), &UIAction::triggered,
     2083            this, &UIVirtualBoxManager::sltPerformCopyCommandVNC);
    20462084
    20472085    /* 'Group/Close' menu connections: */
     
    25042542                                            this, &UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint);
    25052543        pAction->setProperty("fingerprint", strFingerprint);
     2544        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial));
     2545        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC));
    25062546    }
    25072547}
     
    26362676    actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CreateConnection)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Console_S_CreateConnection, items));
    26372677    actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection, items));
     2678    actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial, items));
     2679    actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC, items));
    26382680
    26392681    /* Enable/disable group-close actions: */
     
    29062948        case UIActionIndexST_M_Machine_M_Console_S_CreateConnection:
    29072949        case UIActionIndexST_M_Machine_M_Console_S_DeleteConnection:
     2950        case UIActionIndexST_M_Machine_M_Console_S_CopyCommandSerial:
     2951        case UIActionIndexST_M_Machine_M_Console_S_CopyCommandVNC:
    29082952        {
    29092953            return isAtLeastOneItemStarted(items);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r85191 r85192  
    248248        /** Handles call to copy console connection key fingerprint. */
    249249        void sltCopyConsoleConnectionFingerprint();
     250        /** Handles call to copy serial console command. */
     251        void sltPerformCopyCommandSerial();
     252        /** Handles call to copy VNC console command. */
     253        void sltPerformCopyCommandVNC();
    250254
    251255        /** Handles call to discard machine state. */
Note: See TracChangeset for help on using the changeset viewer.

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