VirtualBox

Ignore:
Timestamp:
Jul 9, 2020 2:41:38 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9722: VirtualBox Manager: Implement action to copy existing console connection key fingerprint.

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

Legend:

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

    r85111 r85151  
    34603460    pMenu->clear();
    34613461
    3462     /* Populate 'Group' / 'Console' menu: */
    3463     pMenu->addAction(action(UIActionIndexST_M_Group_M_Console_S_CreateConnection));
    3464     pMenu->addAction(action(UIActionIndexST_M_Group_M_Console_S_DeleteConnection));
    3465 
    3466     /* Mark menu as valid: */
    3467     m_invalidations.remove(UIActionIndexST_M_Group_M_Console);
     3462    /* This menu always remains invalid.. */
    34683463}
    34693464
     
    34763471    pMenu->clear();
    34773472
    3478     /* Populate 'Machine' / 'Console' menu: */
    3479     pMenu->addAction(action(UIActionIndexST_M_Machine_M_Console_S_CreateConnection));
    3480     pMenu->addAction(action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection));
    3481 
    3482     /* Mark menu as valid: */
    3483     m_invalidations.remove(UIActionIndexST_M_Machine_M_Console);
     3473    /* This menu always remains invalid.. */
    34843474}
    34853475
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r85111 r85151  
    1717
    1818/* Qt includes: */
     19#include <QClipboard>
    1920#include <QFile>
     21#include <QGuiApplication>
    2022#include <QMenuBar>
    2123#include <QPushButton>
     
    3436#include "UIExtraDataManager.h"
    3537#include "UIHostNetworkManager.h"
     38#include "UIIconPool.h"
    3639#include "UIMedium.h"
    3740#include "UIMediumManager.h"
     
    10721075}
    10731076
     1077void UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint()
     1078{
     1079    QAction *pAction = qobject_cast<QAction*>(sender());
     1080    AssertPtrReturnVoid(pAction);
     1081    QClipboard *pClipboard = QGuiApplication::clipboard();
     1082    AssertPtrReturnVoid(pClipboard);
     1083    pClipboard->setText(pAction->property("fingerprint").toString());
     1084}
     1085
    10741086void UIVirtualBoxManager::sltPerformDiscardMachineState()
    10751087{
     
    17171729    m_menuUpdateHandlers[UIActionIndexST_M_Machine] = &UIVirtualBoxManager::updateMenuMachine;
    17181730    m_menuUpdateHandlers[UIActionIndexST_M_Group_M_MoveToGroup] = &UIVirtualBoxManager::updateMenuGroupMoveToGroup;
     1731    m_menuUpdateHandlers[UIActionIndexST_M_Group_M_Console] = &UIVirtualBoxManager::updateMenuGroupConsole;
    17191732    m_menuUpdateHandlers[UIActionIndexST_M_Group_M_Close] = &UIVirtualBoxManager::updateMenuGroupClose;
    17201733    m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_MoveToGroup] = &UIVirtualBoxManager::updateMenuMachineMoveToGroup;
     1734    m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_Console] = &UIVirtualBoxManager::updateMenuMachineConsole;
    17211735    m_menuUpdateHandlers[UIActionIndexST_M_Machine_M_Close] = &UIVirtualBoxManager::updateMenuMachineClose;
    17221736
     
    23192333}
    23202334
     2335void UIVirtualBoxManager::updateMenuGroupConsole(QMenu *pMenu)
     2336{
     2337    /* Get current item: */
     2338    UIVirtualMachineItem *pItem = currentItem();
     2339    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     2340    UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     2341    AssertPtrReturnVoid(pCloudItem);
     2342
     2343    /* Acquire current cloud machine: */
     2344    CCloudMachine comMachine = pCloudItem->machine();
     2345    const QString strFingerprint = comMachine.GetConsoleConnectionFingerprint();
     2346
     2347    /* Populate 'Group' / 'Console' menu: */
     2348    if (strFingerprint.isEmpty())
     2349        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_CreateConnection));
     2350    else
     2351    {
     2352        QAction *pAction = pMenu->addAction(UIIconPool::iconSet(":/file_manager_copy_16px.png"),
     2353                                            QApplication::translate("UIActionPool", "Copy Key Fingerprint (%1)").arg(strFingerprint),
     2354                                            this, &UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint);
     2355        pAction->setProperty("fingerprint", strFingerprint);
     2356        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Console_S_DeleteConnection));
     2357    }
     2358}
     2359
    23212360void UIVirtualBoxManager::updateMenuGroupClose(QMenu *)
    23222361{
     
    23462385        QAction *pAction = pMenu->addAction(strVisibleGroupName, this, &UIVirtualBoxManager::sltPerformMachineMoveToSpecificGroup);
    23472386        pAction->setProperty("actual_group_name", strGroupName);
     2387    }
     2388}
     2389
     2390void UIVirtualBoxManager::updateMenuMachineConsole(QMenu *pMenu)
     2391{
     2392    /* Get current item: */
     2393    UIVirtualMachineItem *pItem = currentItem();
     2394    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     2395    UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     2396    AssertPtrReturnVoid(pCloudItem);
     2397
     2398    /* Acquire current cloud machine: */
     2399    CCloudMachine comMachine = pCloudItem->machine();
     2400    const QString strFingerprint = comMachine.GetConsoleConnectionFingerprint();
     2401
     2402    /* Populate 'Group' / 'Console' menu: */
     2403    if (strFingerprint.isEmpty())
     2404        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_CreateConnection));
     2405    else
     2406    {
     2407        QAction *pAction = pMenu->addAction(UIIconPool::iconSet(":/file_manager_copy_16px.png"),
     2408                                            QApplication::translate("UIActionPool", "Copy Key Fingerprint (%1)").arg(strFingerprint),
     2409                                            this, &UIVirtualBoxManager::sltCopyConsoleConnectionFingerprint);
     2410        pAction->setProperty("fingerprint", strFingerprint);
     2411        pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Console_S_DeleteConnection));
    23482412    }
    23492413}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r85111 r85151  
    242242        /** Handles call to delete console connection. */
    243243        void sltPerformDeleteConsoleConnection();
     244        /** Handles call to copy console connection key fingerprint. */
     245        void sltCopyConsoleConnectionFingerprint();
    244246
    245247        /** Handles call to discard machine state. */
     
    359361        /** Updates 'Group' : 'Move to Group' menu. */
    360362        void updateMenuGroupMoveToGroup(QMenu *pMenu);
     363        /** Updates 'Group' : 'Console' menu. */
     364        void updateMenuGroupConsole(QMenu *pMenu);
    361365        /** Updates 'Group' : 'Close' menu. */
    362366        void updateMenuGroupClose(QMenu *pMenu);
    363367        /** Updates 'Machine' : 'Move to Group' menu. */
    364368        void updateMenuMachineMoveToGroup(QMenu *pMenu);
     369        /** Updates 'Machine' : 'Console' menu. */
     370        void updateMenuMachineConsole(QMenu *pMenu);
    365371        /** Updates 'Machine' : 'Close' menu. */
    366372        void updateMenuMachineClose(QMenu *pMenu);
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