VirtualBox

儲存庫 vbox 的更動 50165


忽略:
時間撮記:
2014-1-22 下午05:46:16 (11 年 以前)
作者:
vboxsync
訊息:

FE/Qt: 7036: Runtime UI: Devices menu: Network sub-menu: Stuff to connect/disconnect network adapter cable.

位置:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
檔案:
修改 7 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r49333 r50165  
    798798
    799799    UIActionMenuNetworkAdapters(UIActionPool *pParent)
    800         : UIActionMenu(pParent)
    801     {
    802         retranslateUi();
    803     }
    804 
    805 protected:
    806 
    807     void retranslateUi() {}
     800        : UIActionMenu(pParent, ":/nw_16px.png", ":/nw_disabled_16px.png")
     801    {
     802        retranslateUi();
     803    }
     804
     805protected:
     806
     807    void retranslateUi()
     808    {
     809        setName(QApplication::translate("UIActionPool", "Network"));
     810    }
    808811};
    809812
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r49779 r50165  
    7474#include "CHostVideoInputDevice.h"
    7575#include "CEmulatedUSB.h"
     76#include "CNetworkAdapter.h"
    7677#ifdef Q_WS_MAC
    7778# include "CGuest.h"
     
    882883    connect(gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)->menu(), SIGNAL(aboutToShow()),
    883884            this, SLOT(sltPrepareDragAndDropMenu()));
     885    connect(gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu(), SIGNAL(aboutToShow()),
     886            this, SLOT(sltPrepareNetworkMenu()));
    884887    connect(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings), SIGNAL(triggered()),
    885888            this, SLOT(sltOpenNetworkAdaptersDialog()));
     
    20502053}
    20512054
     2055/** Prepares menu content when user hovers <b>Network</b> submenu of the <b>Devices</b> menu. */
     2056void UIMachineLogic::sltPrepareNetworkMenu()
     2057{
     2058    /* Get and check 'the sender' menu object: */
     2059    QMenu *pMenu = qobject_cast<QMenu*>(sender());
     2060    QMenu *pNetworkMenu = gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu();
     2061    AssertReturnVoid(pMenu == pNetworkMenu);
     2062    Q_UNUSED(pNetworkMenu);
     2063
     2064    /* Get and check current machine: */
     2065    const CMachine &machine = session().GetMachine();
     2066    AssertReturnVoid(!machine.isNull());
     2067
     2068    /* Determine how many adapters we should display: */
     2069    KChipsetType chipsetType = machine.GetChipsetType();
     2070    ULONG uCount = qMin((ULONG)4, vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType));
     2071
     2072    /* Enumerate existing network adapters: */
     2073    QMap<int, bool> adapterData;
     2074    for (ULONG uSlot = 0; uSlot < uCount; ++uSlot)
     2075    {
     2076        /* Get and check iterated adapter: */
     2077        const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
     2078        AssertReturnVoid(machine.isOk());
     2079        Assert(!adapter.isNull());
     2080        if (adapter.isNull())
     2081            continue;
     2082
     2083        /* Remember adapter data if it is enabled: */
     2084        if (adapter.GetEnabled())
     2085            adapterData.insert((int)uSlot, (bool)adapter.GetCableConnected());
     2086    }
     2087    AssertReturnVoid(!adapterData.isEmpty());
     2088
     2089    /* Delete all "temporary" actions: */
     2090    QList<QAction*> actions = pMenu->actions();
     2091    foreach (QAction *pAction, actions)
     2092        if (pAction->property("temporary").toBool())
     2093            delete pAction;
     2094
     2095    /* Add new "temporary" actions: */
     2096    foreach (int iSlot, adapterData.keys())
     2097    {
     2098        QAction *pAction = pMenu->addAction(QIcon(adapterData[iSlot] ? ":/connect_16px.png": ":/disconnect_16px.png"),
     2099                                            adapterData.size() == 1 ? tr("Connect Network Adapter") : tr("Connect Network Adapter %1").arg(iSlot + 1),
     2100                                            this, SLOT(sltToggleNetworkAdapterConnection()));
     2101        pAction->setProperty("temporary", true);
     2102        pAction->setProperty("slot", iSlot);
     2103        pAction->setCheckable(true);
     2104        pAction->setChecked(adapterData[iSlot]);
     2105    }
     2106}
     2107
     2108/** Toggles network adapter's <i>Cable Connected</i> state. */
     2109void UIMachineLogic::sltToggleNetworkAdapterConnection()
     2110{
     2111    /* Get and check 'the sender' action object: */
     2112    QAction *pAction = qobject_cast<QAction*>(sender());
     2113    AssertReturnVoid(pAction);
     2114
     2115    /* Get and check current machine: */
     2116    CMachine machine = session().GetMachine();
     2117    AssertReturnVoid(!machine.isNull());
     2118
     2119    /* Get operation target: */
     2120    CNetworkAdapter adapter = machine.GetNetworkAdapter((ULONG)pAction->property("slot").toInt());
     2121    AssertReturnVoid(machine.isOk() && !adapter.isNull());
     2122
     2123    /* Connect/disconnect cable to/from target: */
     2124    adapter.SetCableConnected(!adapter.GetCableConnected());
     2125    machine.SaveSettings();
     2126    if (!machine.isOk())
     2127        msgCenter().cannotSaveMachineSettings(machine);
     2128}
     2129
    20522130void UIMachineLogic::sltChangeDragAndDropType(QAction *pAction)
    20532131{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r49779 r50165  
    209209    void sltChangeSharedClipboardType(QAction *pAction);
    210210    void sltPrepareDragAndDropMenu();
     211    void sltPrepareNetworkMenu();
     212    void sltToggleNetworkAdapterConnection();
    211213    void sltChangeDragAndDropType(QAction *pAction);
    212214    void sltToggleVRDE(bool fEnabled);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r50042 r50165  
    444444    else
    445445        gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)->setEnabled(false);
    446     /* Network Settings action: */
     446    /* Network submenu: */
    447447    if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_NetworkSettings)
    448448    {
    449         pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings));
    450         fSeparator1 = true;
    451     }
    452     else
     449        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Menu_Network));
     450        gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu()->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings));
     451        fSeparator1 = true;
     452    }
     453    else
     454    {
     455        gActionPool->action(UIActionIndexRuntime_Menu_Network)->setEnabled(false);
    453456        gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings)->setEnabled(false);
     457    }
    454458    /* Shared Folders Settings action: */
    455459    if (m_pSession->allowedActionsMenuDevices() & RuntimeMenuDevicesActionType_SharedFoldersSettings)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r50042 r50165  
    15391539        }
    15401540
    1541         /* Show/Hide Network Adapters action depending on overall adapters activity status: */
    1542         gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings)->setVisible(fAtLeastOneAdapterActive);
     1541        /* Show/Hide Network sub-menu depending on overall adapters activity status: */
     1542        gActionPool->action(UIActionIndexRuntime_Menu_Network)->setVisible(fAtLeastOneAdapterActive);
    15431543    }
    15441544
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r49596 r50165  
    6767}
    6868
    69 void UIMachineLogicNormal::sltPrepareNetworkAdaptersMenu()
    70 {
    71     QMenu *menu = qobject_cast<QMenu*>(sender());
    72     AssertMsg(menu, ("This slot should be called only on Network Adapters menu show!\n"));
    73     menu->clear();
    74     menu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings));
    75 }
    76 
    7769void UIMachineLogicNormal::sltPrepareSharedFoldersMenu()
    7870{
     
    114106
    115107    /* "Device" actions connections: */
    116     connect(gActionPool->action(UIActionIndexRuntime_Menu_Network)->menu(), SIGNAL(aboutToShow()),
    117             this, SLOT(sltPrepareNetworkAdaptersMenu()));
    118108    connect(gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders)->menu(), SIGNAL(aboutToShow()),
    119109            this, SLOT(sltPrepareSharedFoldersMenu()));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r49506 r50165  
    4040
    4141    /* Windowed mode functionality: */
    42     void sltPrepareNetworkAdaptersMenu();
    4342    void sltPrepareSharedFoldersMenu();
    4443    void sltPrepareVideoCaptureMenu();
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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