VirtualBox

Changeset 37571 in vbox


Ignore:
Timestamp:
Jun 21, 2011 11:34:43 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 5746: Create generic network adapter UI in Machine settings / Network page: Initial version.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r37463 r37571  
    127127        setCurrentIndex(indexOf(m_pErrBox));
    128128    }
     129
    129130signals:
    130131
     
    163164    void createTextPage();
    164165    void createErrPage();
     166
     167    static QString summarizeGenericProperties(const CNetworkAdapter &adapter);
    165168
    166169    /* Private member vars */
     
    461464    vboxGlobal().virtualBox().SetExtraDataStringList(VBoxDefs::GUI_DetailsPageBoxes,
    462465                                                     boxes);
     466}
     467
     468void UIDetailsPagePrivate::retranslateUi()
     469{
     470    if (m_pErrLabel)
     471        m_pErrLabel->setText(tr(
     472            "The selected virtual machine is <i>inaccessible</i>. Please "
     473            "inspect the error message shown below and press the "
     474            "<b>Refresh</b> button if you want to repeat the accessibility "
     475            "check:"));
     476
     477    if (mRefreshAction && mRefreshButton)
     478    {
     479        mRefreshButton->setText(mRefreshAction->text());
     480        mRefreshButton->setIcon(mRefreshAction->icon());
     481        mRefreshButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
     482    }
     483
     484    /* General */
     485    {
     486        m_secBoxes.value(GeneralSec)->setTitle(tr("General", "details report"));
     487        m_actions.value(GeneralSec)->setText(m_secBoxes.value(GeneralSec)->title());
     488    }
     489
     490    /* System */
     491    {
     492        m_secBoxes.value(SystemSec)->setTitle(tr("System", "details report"));
     493        m_actions.value(SystemSec)->setText(m_secBoxes.value(SystemSec)->title());
     494    }
     495
     496    /* Preview */
     497    {
     498        m_secBoxes.value(PreviewSec)->setTitle(tr("Preview", "details report"));
     499        m_actions.value(PreviewSec)->setText(m_secBoxes.value(PreviewSec)->title());
     500    }
     501
     502    /* Display */
     503    {
     504        m_secBoxes.value(DisplaySec)->setTitle(tr("Display", "details report"));
     505        m_actions.value(DisplaySec)->setText(m_secBoxes.value(DisplaySec)->title());
     506    }
     507
     508    /* Storage */
     509    {
     510        m_secBoxes.value(StorageSec)->setTitle(tr("Storage", "details report"));
     511        m_actions.value(StorageSec)->setText(m_secBoxes.value(StorageSec)->title());
     512    }
     513
     514    /* Audio */
     515    {
     516        m_secBoxes.value(AudioSec)->setTitle(tr("Audio", "details report"));
     517        m_actions.value(AudioSec)->setText(m_secBoxes.value(AudioSec)->title());
     518    }
     519
     520    /* Network */
     521    {
     522        m_secBoxes.value(NetworkSec)->setTitle(tr("Network", "details report"));
     523        m_actions.value(NetworkSec)->setText(m_secBoxes.value(NetworkSec)->title());
     524    }
     525
     526    /* Serial Ports */
     527    {
     528        m_secBoxes.value(SerialPortsSec)->setTitle(tr("Serial Ports", "details report"));
     529        m_actions.value(SerialPortsSec)->setText(m_secBoxes.value(SerialPortsSec)->title());
     530    }
     531
     532#ifdef VBOX_WITH_PARALLEL_PORTS
     533    /* Parallel Ports */
     534    {
     535        m_secBoxes.value(ParallelPortsSec)->setTitle(tr("Parallel Ports", "details report"));
     536        m_actions.value(ParallelPortsSec)->setText(m_secBoxes.value(ParallelPortsSec)->title());
     537    }
     538#endif /* VBOX_WITH_PARALLEL_PORTS */
     539
     540    /* USB */
     541    {
     542        m_secBoxes.value(USBSec)->setTitle(tr("USB", "details report"));
     543        m_actions.value(USBSec)->setText(m_secBoxes.value(USBSec)->title());
     544    }
     545
     546    /* Shared Folders */
     547    {
     548        m_secBoxes.value(SharedFoldersSec)->setTitle(tr("Shared Folders", "details report"));
     549        m_actions.value(SharedFoldersSec)->setText(m_secBoxes.value(SharedFoldersSec)->title());
     550    }
     551
     552    /* Description */
     553    {
     554        m_secBoxes.value(DescriptionSec)->setTitle(tr("Description", "details report"));
     555        m_actions.value(DescriptionSec)->setText(m_secBoxes.value(DescriptionSec)->title());
     556    }
    463557}
    464558
     
    716810}
    717811
    718 /**
    719  * Return a text summary of the properties of a generic network adapter
    720  */
    721 QString summarizeGenericProperties(const CNetworkAdapter &adapter)
    722 {
    723     QVector<QString> names;
    724     QVector<QString> props;
    725     props = adapter.GetProperties(QString(), names); // all properties, please
    726 
    727     QString result;
    728     for (int i = 0; i < names.size(); i++)
    729     {
    730         result += names[i] + "=" + props[i];
    731         if (i != names.size() - 1)
    732             result += ", ";
    733     }
    734 
    735     return result;
    736 }
    737 
    738812void UIDetailsPagePrivate::sltUpdateNetwork()
    739813{
     
    10881162}
    10891163
    1090 void UIDetailsPagePrivate::retranslateUi()
    1091 {
    1092     if (m_pErrLabel)
    1093         m_pErrLabel->setText(tr(
    1094             "The selected virtual machine is <i>inaccessible</i>. Please "
    1095             "inspect the error message shown below and press the "
    1096             "<b>Refresh</b> button if you want to repeat the accessibility "
    1097             "check:"));
    1098 
    1099     if (mRefreshAction && mRefreshButton)
    1100     {
    1101         mRefreshButton->setText(mRefreshAction->text());
    1102         mRefreshButton->setIcon(mRefreshAction->icon());
    1103         mRefreshButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    1104     }
    1105 
    1106     /* General */
    1107     {
    1108         m_secBoxes.value(GeneralSec)->setTitle(tr("General", "details report"));
    1109         m_actions.value(GeneralSec)->setText(m_secBoxes.value(GeneralSec)->title());
    1110     }
    1111 
    1112     /* System */
    1113     {
    1114         m_secBoxes.value(SystemSec)->setTitle(tr("System", "details report"));
    1115         m_actions.value(SystemSec)->setText(m_secBoxes.value(SystemSec)->title());
    1116     }
    1117 
    1118     /* Preview */
    1119     {
    1120         m_secBoxes.value(PreviewSec)->setTitle(tr("Preview", "details report"));
    1121         m_actions.value(PreviewSec)->setText(m_secBoxes.value(PreviewSec)->title());
    1122     }
    1123 
    1124     /* Display */
    1125     {
    1126         m_secBoxes.value(DisplaySec)->setTitle(tr("Display", "details report"));
    1127         m_actions.value(DisplaySec)->setText(m_secBoxes.value(DisplaySec)->title());
    1128     }
    1129 
    1130     /* Storage */
    1131     {
    1132         m_secBoxes.value(StorageSec)->setTitle(tr("Storage", "details report"));
    1133         m_actions.value(StorageSec)->setText(m_secBoxes.value(StorageSec)->title());
    1134     }
    1135 
    1136     /* Audio */
    1137     {
    1138         m_secBoxes.value(AudioSec)->setTitle(tr("Audio", "details report"));
    1139         m_actions.value(AudioSec)->setText(m_secBoxes.value(AudioSec)->title());
    1140     }
    1141 
    1142     /* Network */
    1143     {
    1144         m_secBoxes.value(NetworkSec)->setTitle(tr("Network", "details report"));
    1145         m_actions.value(NetworkSec)->setText(m_secBoxes.value(NetworkSec)->title());
    1146     }
    1147 
    1148     /* Serial Ports */
    1149     {
    1150         m_secBoxes.value(SerialPortsSec)->setTitle(tr("Serial Ports", "details report"));
    1151         m_actions.value(SerialPortsSec)->setText(m_secBoxes.value(SerialPortsSec)->title());
    1152     }
    1153 
    1154 #ifdef VBOX_WITH_PARALLEL_PORTS
    1155     /* Parallel Ports */
    1156     {
    1157         m_secBoxes.value(ParallelPortsSec)->setTitle(tr("Parallel Ports", "details report"));
    1158         m_actions.value(ParallelPortsSec)->setText(m_secBoxes.value(ParallelPortsSec)->title());
    1159     }
    1160 #endif /* VBOX_WITH_PARALLEL_PORTS */
    1161 
    1162     /* USB */
    1163     {
    1164         m_secBoxes.value(USBSec)->setTitle(tr("USB", "details report"));
    1165         m_actions.value(USBSec)->setText(m_secBoxes.value(USBSec)->title());
    1166     }
    1167 
    1168     /* Shared Folders */
    1169     {
    1170         m_secBoxes.value(SharedFoldersSec)->setTitle(tr("Shared Folders", "details report"));
    1171         m_actions.value(SharedFoldersSec)->setText(m_secBoxes.value(SharedFoldersSec)->title());
    1172     }
    1173 
    1174     /* Description */
    1175     {
    1176         m_secBoxes.value(DescriptionSec)->setTitle(tr("Description", "details report"));
    1177         m_actions.value(DescriptionSec)->setText(m_secBoxes.value(DescriptionSec)->title());
    1178     }
     1164/**
     1165 *  Return a text summary of the properties of a generic network adapter
     1166 */
     1167/* static */
     1168QString UIDetailsPagePrivate::summarizeGenericProperties(const CNetworkAdapter &adapter)
     1169{
     1170    QVector<QString> names;
     1171    QVector<QString> props;
     1172    props = adapter.GetProperties(QString(), names);
     1173    QString strResult;
     1174    for (int i = 0; i < names.size(); ++i)
     1175    {
     1176        strResult += names[i] + "=" + props[i];
     1177        if (i < names.size() - 1)
     1178            strResult += ", ";
     1179    }
     1180    return strResult;
    11791181}
    11801182
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r37200 r37571  
    8080    m_pPromiscuousModeLabel->setEnabled(m_pParent->isMachineInValidMode() &&
    8181                                        attachmentType() != KNetworkAttachmentType_Null &&
     82                                        attachmentType() != KNetworkAttachmentType_Generic &&
    8283                                        attachmentType() != KNetworkAttachmentType_NAT);
    8384    m_pPromiscuousModeCombo->setEnabled(m_pParent->isMachineInValidMode() &&
    8485                                        attachmentType() != KNetworkAttachmentType_Null &&
     86                                        attachmentType() != KNetworkAttachmentType_Generic &&
    8587                                        attachmentType() != KNetworkAttachmentType_NAT);
    8688    m_pMACLabel->setEnabled(m_pParent->isMachineOffline());
     
    141143    /* Other options: */
    142144    m_pMACEditor->setText(adapterData.m_strMACAddress);
     145    m_pGenericPropertiesTextEdit->setText(adapterData.m_strGenericProperties);
    143146    m_pCableConnectedCheckBox->setChecked(adapterData.m_fCableConnected);
    144147
     
    174177        case KNetworkAttachmentType_Generic:
    175178            adapterData.m_strGenericDriver = alternativeName();
     179            adapterData.m_strGenericProperties = m_pGenericPropertiesTextEdit->toPlainText();
    176180            break;
    177181        default:
     
    335339                                    attachmentType() != KNetworkAttachmentType_NAT);
    336340    m_pPromiscuousModeLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     341                                        attachmentType() != KNetworkAttachmentType_Generic &&
    337342                                        attachmentType() != KNetworkAttachmentType_NAT);
    338343    m_pPromiscuousModeCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     344                                        attachmentType() != KNetworkAttachmentType_Generic &&
    339345                                        attachmentType() != KNetworkAttachmentType_NAT);
    340346
     
    416422    sltUpdateAlternativeName();
    417423
     424    /* Update visibility of "generic" properties editor: */
     425    m_pGenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     426                                          m_pAdvancedArrow->isExpanded());
     427    m_pGenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     428                                             m_pAdvancedArrow->isExpanded());
     429
    418430    /* Update Forwarding rules button availability: */
    419431    m_pPortForwardingButton->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);
     
    489501    m_pPromiscuousModeLabel->setVisible(m_pAdvancedArrow->isExpanded());
    490502    m_pPromiscuousModeCombo->setVisible(m_pAdvancedArrow->isExpanded());
     503    m_pGenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     504                                          m_pAdvancedArrow->isExpanded());
     505    m_pGenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     506                                             m_pAdvancedArrow->isExpanded());
    491507    m_pMACLabel->setVisible(m_pAdvancedArrow->isExpanded());
    492508    m_pMACEditor->setVisible(m_pAdvancedArrow->isExpanded());
     
    774790            adapterData.m_promiscuousMode = adapter.GetPromiscModePolicy();
    775791            adapterData.m_strMACAddress = adapter.GetMACAddress();
     792            adapterData.m_strGenericProperties = summarizeGenericProperties(adapter);
    776793            adapterData.m_fCableConnected = adapter.GetCableConnected();
    777794
     
    898915                            case KNetworkAttachmentType_Generic:
    899916                                adapter.SetGenericDriver(adapterData.m_strGenericDriver);
     917                                updateGenericProperties(adapter, adapterData.m_strGenericProperties);
    900918                                break;
    901919                            default:
     
    9871005}
    9881006
     1007/* static */
     1008QString UIMachineSettingsNetworkPage::summarizeGenericProperties(const CNetworkAdapter &adapter)
     1009{
     1010    /* Prepare formatted string: */
     1011    QVector<QString> names;
     1012    QVector<QString> props;
     1013    props = adapter.GetProperties(QString(), names);
     1014    QString strResult;
     1015    /* Load generic properties: */
     1016    for (int i = 0; i < names.size(); ++i)
     1017    {
     1018        strResult += names[i] + "=" + props[i];
     1019        if (i < names.size() - 1)
     1020          strResult += "\n";
     1021    }
     1022    /* Return formatted string: */
     1023    return strResult;
     1024}
     1025
     1026/* static */
     1027void UIMachineSettingsNetworkPage::updateGenericProperties(CNetworkAdapter &adapter, const QString &strPropText)
     1028{
     1029    /* Parse new properties: */
     1030    QStringList newProps = strPropText.split("\n");
     1031    QHash<QString, QString> hash;
     1032
     1033    /* Save new properties: */
     1034    for (int i = 0; i < newProps.size(); ++i)
     1035    {
     1036        QString strLine = newProps[i];
     1037        int iSplitPos = strLine.indexOf("=");
     1038        if (iSplitPos)
     1039        {
     1040            QString strKey = strLine.left(iSplitPos);
     1041            QString strVal = strLine.mid(iSplitPos+1);
     1042            adapter.SetProperty(strKey, strVal);
     1043            hash[strKey] = strVal;
     1044        }
     1045    }
     1046
     1047    /* Removing deleted properties: */
     1048    QVector<QString> names;
     1049    QVector<QString> props;
     1050    props = adapter.GetProperties(QString(), names);
     1051    for (int i = 0; i < names.size(); ++i)
     1052    {
     1053        QString strName = names[i];
     1054        QString strValue = props[i];
     1055        if (strValue != hash[strName])
     1056            adapter.SetProperty(strName, hash[strName]);
     1057    }
     1058}
     1059
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r37200 r37571  
    4444        , m_strHostInterfaceName(QString())
    4545        , m_strGenericDriver(QString())
     46        , m_strGenericProperties(QString())
    4647        , m_strMACAddress(QString())
    4748        , m_fCableConnected(false)
     
    5960               (m_strHostInterfaceName == other.m_strHostInterfaceName) &&
    6061               (m_strGenericDriver == other.m_strGenericDriver) &&
     62               (m_strGenericProperties == other.m_strGenericProperties) &&
    6163               (m_strMACAddress == other.m_strMACAddress) &&
    6264               (m_fCableConnected == other.m_fCableConnected) &&
     
    7678    QString m_strHostInterfaceName;
    7779    QString m_strGenericDriver;
     80    QString m_strGenericProperties;
    7881    QString m_strMACAddress;
    7982    bool m_fCableConnected;
     
    195198    void polishPage();
    196199
     200    static QString summarizeGenericProperties(const CNetworkAdapter &adapter);
     201    static void updateGenericProperties(CNetworkAdapter &adapter, const QString &strPropText);
     202
    197203    QIWidgetValidator *m_pValidator;
    198204    QITabWidget *m_pTwAdapters;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.ui

    r36104 r37571  
    233233       </widget>
    234234      </item>
     235      <item row="6" column="0">
     236       <widget class="QLabel" name="m_pGenericPropertiesLabel">
     237        <property name="text">
     238         <string>Generic Properties:</string>
     239        </property>
     240        <property name="alignment">
     241         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignTop</set>
     242        </property>
     243       </widget>
     244      </item>
    235245      <item row="6" column="1" colspan="3">
     246       <widget class="QTextEdit" name="m_pGenericPropertiesTextEdit">
     247        <property name="whatsThis">
     248         <string>Allows to specify the generic properties passed to the generic driver.&lt;br&gt;Please use &lt;b&gt;shift-enter&lt;/b&gt; to insert a new line.</string>
     249        </property>
     250       </widget>
     251      </item>
     252      <item row="7" column="1" colspan="3">
    236253       <widget class="QCheckBox" name="m_pCableConnectedCheckBox">
    237254        <property name="whatsThis">
     
    243260       </widget>
    244261      </item>
    245       <item row="7" column="1">
     262      <item row="8" column="1">
    246263       <widget class="QPushButton" name="m_pPortForwardingButton">
    247264        <property name="whatsThis">
     
    253270       </widget>
    254271      </item>
    255       <item row="8" column="0" colspan="4">
     272      <item row="9" column="0" colspan="4">
    256273       <spacer name="m_pVerticalSpacer">
    257274        <property name="orientation">
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