VirtualBox

Changeset 101719 in vbox


Ignore:
Timestamp:
Nov 2, 2023 3:13:38 PM (13 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10481. Adding a checkbox to the Device/Shared Clipboard menu to toggle clipboard file transfers. To be tested.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r100606 r101719  
    757757{
    758758    return uisession()->setClipboardMode(enmMode);
     759}
     760
     761bool UIMachine::toggleClipboardFileTransfer(bool fEnabled)
     762{
     763    return uisession()->toggleClipboardFileTransfer(fEnabled);
     764}
     765
     766bool UIMachine::isClipboardFileTransferEnabled()
     767{
     768    return uisession()->isClipboardFileTransferEnabled();
    759769}
    760770
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r100606 r101719  
    516516        /** Defines clipboard mode. */
    517517        bool setClipboardMode(KClipboardMode enmMode);
     518        /** En/disables guest clipboard file transfers. */
     519        bool toggleClipboardFileTransfer(bool fEnabled);
     520        /** Returns true if clipboard file transfer is enabled. Returns false otherwise or in case of an error. */
     521        bool isClipboardFileTransferEnabled();
    518522
    519523        /** Acquires D&D mode. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r101035 r101719  
    765765    , m_pRunningOrPausedOrStuckActions(0)
    766766    , m_pSharedClipboardActions(0)
     767    , m_pFileTransferToggleAction(0)
    767768    , m_pDragAndDropActions(0)
    768769    , m_fIsWindowsCreated(false)
     
    22872288}
    22882289
     2290void UIMachineLogic::sltFileTransferToggled(bool fChecked)
     2291{
     2292    uimachine()->toggleClipboardFileTransfer(fChecked);
     2293}
     2294
    22892295void UIMachineLogic::sltToggleNetworkAdapterConnection(bool fChecked)
    22902296{
     
    28352841        /* Connect action-group trigger: */
    28362842        connect(m_pSharedClipboardActions, &QActionGroup::triggered, this, &UIMachineLogic::sltChangeSharedClipboardType);
     2843        m_pFileTransferToggleAction = new QAction(QApplication::translate("UIActionPool", "Enable clipboard file transfers"));
     2844        m_pFileTransferToggleAction->setCheckable(true);
     2845        m_pFileTransferToggleAction->setChecked(uimachine()->isClipboardFileTransferEnabled());
     2846        /* pMenu takes the ownership of the m_pFileTransferToggleAction. */
     2847        pMenu->addAction(m_pFileTransferToggleAction);
     2848        connect(m_pFileTransferToggleAction, &QAction::toggled, this, &UIMachineLogic::sltFileTransferToggled);
    28372849    }
    28382850    /* Subsequent runs: */
    28392851    else
     2852    {
     2853        if (m_pFileTransferToggleAction)
     2854        {
     2855            m_pFileTransferToggleAction->blockSignals(true);
     2856            m_pFileTransferToggleAction->setChecked(uimachine()->isClipboardFileTransferEnabled());
     2857            m_pFileTransferToggleAction->blockSignals(false);
     2858        }
    28402859        foreach (QAction *pAction, m_pSharedClipboardActions->actions())
    28412860            if (pAction->data().value<KClipboardMode>() == enmCurrentMode)
    28422861                pAction->setChecked(true);
     2862    }
    28432863}
    28442864
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r100064 r101719  
    287287    void sltAttachWebcamDevice();
    288288    void sltChangeSharedClipboardType(QAction *pAction);
     289    void sltFileTransferToggled(bool fChecked);
    289290    void sltToggleNetworkAdapterConnection(bool fChecked);
    290291    void sltChangeDragAndDropType(QAction *pAction);
     
    375376    QActionGroup *m_pRunningOrPausedOrStuckActions;
    376377    QActionGroup *m_pSharedClipboardActions;
     378    QAction      *m_pFileTransferToggleAction;
    377379    QActionGroup *m_pDragAndDropActions;
    378380
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r101316 r101719  
    604604        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
    605605    return fSuccess;
     606}
     607
     608bool UISession::toggleClipboardFileTransfer(bool fEnabled)
     609{
     610    CMachine comMachine = machine();
     611    comMachine.SetClipboardFileTransfersEnabled(fEnabled);
     612    const bool fSuccess = comMachine.isOk();
     613    if (!fSuccess)
     614        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     615    return fSuccess;
     616}
     617
     618bool UISession::isClipboardFileTransferEnabled()
     619{
     620    CMachine comMachine = machine();
     621    bool fEnabled = comMachine.GetClipboardFileTransfersEnabled();
     622    const bool fSuccess = comMachine.isOk();
     623    if (!fSuccess)
     624    {
     625        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     626        return false;
     627    }
     628    return fEnabled;
    606629}
    607630
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r100606 r101719  
    315315        /** Defines clipboard mode. */
    316316        bool setClipboardMode(KClipboardMode enmMode);
     317        /** En/disables guest clipboard file transfers. */
     318        bool toggleClipboardFileTransfer(bool fEnabled);
     319        /** Returns true if clipboard file transfer is enabled. Returns false otherwise or in case of an error. */
     320        bool isClipboardFileTransferEnabled();
    317321
    318322        /** Acquires D&D mode. */
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