VirtualBox

Changeset 82290 in vbox


Ignore:
Timestamp:
Nov 29, 2019 6:31:38 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9611: UIMachineSettingsGeneral: Get rid of hardcoded shared clipboard mode list, instead acquire this list through CSystemProperties interface; Besides that, using more modern Qt approach to cache enum data directly without casting it to int.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r80700 r82290  
    241241    const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base();
    242242
     243    /* We are doing that *now* because these combos have
     244     * dynamical content which depends on cashed value: */
     245    repopulateComboClipboardMode();
     246
    243247    /* Load old 'Basic' data from the cache: */
    244248    AssertPtrReturnVoid(m_pNameAndSystemEditor);
     
    252256    mPsSnapshot->setPath(oldGeneralData.m_strSnapshotsFolder);
    253257    mPsSnapshot->setHomeDir(oldGeneralData.m_strSnapshotsHomeDir);
    254     mCbClipboard->setCurrentIndex(oldGeneralData.m_clipboardMode);
     258    const int iClipboardModePosition = mCbClipboard->findData(oldGeneralData.m_clipboardMode);
     259    mCbClipboard->setCurrentIndex(iClipboardModePosition == -1 ? 0 : iClipboardModePosition);
    255260    mCbDragAndDrop->setCurrentIndex(oldGeneralData.m_dndMode);
    256261
     
    289294    AssertPtrReturnVoid(mCbDragAndDrop);
    290295    newGeneralData.m_strSnapshotsFolder = mPsSnapshot->path();
    291     newGeneralData.m_clipboardMode = (KClipboardMode)mCbClipboard->currentIndex();
     296    newGeneralData.m_clipboardMode = mCbClipboard->currentData().value<KClipboardMode>();
    292297    newGeneralData.m_dndMode = (KDnDMode)mCbDragAndDrop->currentIndex();
    293298
     
    466471                                 "virtual machine will be stored. Be aware that "
    467472                                 "snapshots can take quite a lot of storage space."));
     473
    468474    /* Translate Shared Clipboard mode combo: */
    469475    AssertPtrReturnVoid(mCbClipboard);
    470     mCbClipboard->setItemText(0, gpConverter->toString(KClipboardMode_Disabled));
    471     mCbClipboard->setItemText(1, gpConverter->toString(KClipboardMode_HostToGuest));
    472     mCbClipboard->setItemText(2, gpConverter->toString(KClipboardMode_GuestToHost));
    473     mCbClipboard->setItemText(3, gpConverter->toString(KClipboardMode_Bidirectional));
     476    for (int iIndex = 0; iIndex < mCbClipboard->count(); ++iIndex)
     477    {
     478        const KClipboardMode enmType = mCbClipboard->currentData().value<KClipboardMode>();
     479        mCbClipboard->setItemText(iIndex, gpConverter->toString(enmType));
     480    }
     481
    474482    /* Translate Drag'n'drop mode combo: */
    475483    AssertPtrReturnVoid(mCbDragAndDrop);
     
    559567    /* Tab and it's layout created in the .ui file. */
    560568    {
    561         /* Shared Clipboard Mode combo-box created in the .ui file. */
    562         AssertPtrReturnVoid(mCbClipboard);
    563         {
    564             /* Configure combo-box: */
    565             mCbClipboard->addItem(""); /* KClipboardMode_Disabled */
    566             mCbClipboard->addItem(""); /* KClipboardMode_HostToGuest */
    567             mCbClipboard->addItem(""); /* KClipboardMode_GuestToHost */
    568             mCbClipboard->addItem(""); /* KClipboardMode_Bidirectional */
    569         }
    570 
    571569        /* Drag&drop Mode combo-box created in the .ui file. */
    572570        AssertPtrReturnVoid(mCbDragAndDrop);
     
    656654    delete m_pCache;
    657655    m_pCache = 0;
     656}
     657
     658void UIMachineSettingsGeneral::repopulateComboClipboardMode()
     659{
     660    /* Shared Clipboard mode combo-box created in the .ui file. */
     661    AssertPtrReturnVoid(mCbClipboard);
     662    {
     663        /* Clear combo first of all: */
     664        mCbClipboard->clear();
     665
     666        /* Load currently supported Shared Clipboard modes: */
     667        CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     668        QVector<KClipboardMode> clipboardModes = comProperties.GetSupportedClipboardModes();
     669        /* Take into account currently cached value: */
     670        const KClipboardMode enmCachedValue = m_pCache->base().m_clipboardMode;
     671        if (!clipboardModes.contains(enmCachedValue))
     672            clipboardModes.prepend(enmCachedValue);
     673
     674        /* Populate combo finally: */
     675        foreach (const KClipboardMode &enmMode, clipboardModes)
     676            mCbClipboard->addItem(gpConverter->toString(enmMode), QVariant::fromValue(enmMode));
     677    }
    658678}
    659679
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r76581 r82290  
    111111    void cleanup();
    112112
     113    /** Repopulates Clipboard mode combo-box. */
     114    void repopulateComboClipboardMode();
     115
    113116    /** Saves existing general data from the cache. */
    114117    bool saveGeneralData();
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