VirtualBox

Changeset 91545 in vbox for trunk/src


Ignore:
Timestamp:
Oct 4, 2021 3:13:38 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10100: Layout fixes to make GUI a bit less laggy through ssh, and setting the first column width to length of the longes label to align labels.

File:
1 edited

Legend:

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

    r91437 r91545  
    224224    /** Prepares connections. */
    225225    void prepareConnections();
     226    /** Prepares advanced settings widgets. */
     227    void prepareAdvancedSettingsWidgets(QGridLayout *pLayout);
    226228
    227229    /* Helping stuff: */
     
    249251        /** Holds the adapter settings widget instance. */
    250252        QWidget                   *m_pWidgetAdapterSettings;
     253        /** Holds the adapter settings layout instance. */
     254        QGridLayout               *m_pLayoutAdapterSettings;
     255        /** Holds the advanced settings container widget instance. */
     256        QWidget                   *m_pWidgetAdvancedSettings;
    251257        /** Holds the attachment type label instance. */
    252258        QLabel                    *m_pLabelAttachmentType;
     
    294300    , m_pCheckBoxAdapter(0)
    295301    , m_pWidgetAdapterSettings(0)
     302    , m_pLayoutAdapterSettings(0)
     303    , m_pWidgetAdvancedSettings(0)
    296304    , m_pLabelAttachmentType(0)
    297305    , m_pLabelAdapterName(0)
     
    646654void UIMachineSettingsNetwork::retranslateUi()
    647655{
     656    int iFirstColumnWidth = 0;
    648657    m_pCheckBoxAdapter->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual "
    649658                                                                   "network adapter into the virtual machine."));
    650659    m_pCheckBoxAdapter->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter"));
    651660    m_pLabelAttachmentType->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:"));
     661    iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAttachmentType->minimumSizeHint().width());
    652662    m_pEditorAttachmentType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter "
    653663                                                                  "is attached to the real network of the Host OS."));
    654664    m_pLabelAdapterName->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:"));
     665    iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAdapterName->minimumSizeHint().width());
    655666    m_pButtonAdvanced->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced"));
    656667    m_pButtonAdvanced->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options."));
    657668    m_pLabelAdapterType->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:"));
     669    iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAdapterType->minimumSizeHint().width());
    658670    m_pComboAdapterType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network "
    659671                                                              "adapter. Depending on this value, VirtualBox will provide different "
    660672                                                              "network hardware to the virtual machine."));
    661673    m_pLabelPromiscuousMode->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:"));
     674    iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelPromiscuousMode->minimumSizeHint().width());
    662675    m_pComboPromiscuousMode->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy "
    663676                                                                  "of the network adapter when attached to an internal network, "
    664677                                                                  "host only network or a bridge."));
    665678    m_pLabelMAC->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:"));
     679    iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelMAC->minimumSizeHint().width());
    666680    m_pEditorMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains "
    667681                                                       "exactly 12 characters chosen from {0-9,A-F}. Note that the second character "
     
    685699    /* Translate attachment info: */
    686700    sltHandleAttachmentTypeChange();
     701    /* Set the minimum width of the 1st column to size longest label to align all labels: */
     702    m_pLayoutAdapterSettings->setColumnMinimumWidth(0, iFirstColumnWidth);
    687703}
    688704
     
    805821        {
    806822            /* Prepare adapter settings widget layout: */
    807             QGridLayout *pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings);
    808             if (pLayoutAdapterSettings)
    809             {
    810                 pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0);
    811                 pLayoutAdapterSettings->setColumnStretch(2, 1);
     823            m_pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings);
     824            if (m_pLayoutAdapterSettings)
     825            {
     826                m_pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0);
     827                m_pLayoutAdapterSettings->setColumnStretch(2, 1);
    812828
    813829                /* Prepare attachment type label: */
     
    816832                {
    817833                    m_pLabelAttachmentType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    818                     pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0);
     834                    m_pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0);
    819835                }
    820836                /* Prepare adapter name label: */
     
    823839                {
    824840                    m_pLabelAdapterName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    825                     pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0);
     841                    m_pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0);
    826842                }
    827843                /* Prepare attachment type editor: */
     
    834850                        m_pLabelAdapterName->setBuddy(m_pEditorAttachmentType->focusProxy2());
    835851
    836                     pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3);
     852                    m_pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3);
    837853                }
    838854
     
    847863                                               UIIconPool::iconSet(":/arrow_down_10px.png"));
    848864
    849                     pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0);
     865                    m_pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0);
    850866                }
    851867
    852                 /* Prepare adapter type label: */
    853                 m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings);
    854                 if (m_pLabelAdapterType)
    855                 {
    856                     m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    857                     pLayoutAdapterSettings->addWidget(m_pLabelAdapterType, 3, 0);
    858                 }
    859                 /* Prepare adapter type combo: */
    860                 m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings);
    861                 if (m_pComboAdapterType)
    862                 {
    863                     if (m_pLabelAdapterType)
    864                         m_pLabelAdapterType->setBuddy(m_pComboAdapterType);
    865                     pLayoutAdapterSettings->addWidget(m_pComboAdapterType, 3, 1, 1, 3);
    866                 }
    867 
    868                 /* Prepare promiscuous mode label: */
    869                 m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings);
    870                 if (m_pLabelPromiscuousMode)
    871                 {
    872                     m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    873                     pLayoutAdapterSettings->addWidget(m_pLabelPromiscuousMode, 4, 0);
    874                 }
    875                 /* Prepare promiscuous mode combo: */
    876                 m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings);
    877                 if (m_pComboPromiscuousMode)
    878                 {
    879                     if (m_pLabelPromiscuousMode)
    880                         m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode);
    881                     pLayoutAdapterSettings->addWidget(m_pComboPromiscuousMode, 4, 1, 1, 3);
    882                 }
    883 
    884                 /* Prepare MAC label: */
    885                 m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings);
    886                 if (m_pLabelMAC)
    887                 {
    888                     m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    889                     pLayoutAdapterSettings->addWidget(m_pLabelMAC, 5, 0);
    890                 }
    891                 /* Prepare MAC editor: */
    892                 m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings);
    893                 if (m_pEditorMAC)
    894                 {
    895                     if (m_pLabelMAC)
    896                         m_pLabelMAC->setBuddy(m_pEditorMAC);
    897                     m_pEditorMAC->setAllowToCopyContentsWhenDisabled(true);
    898                     m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
    899                     m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12));
    900 
    901                     pLayoutAdapterSettings->addWidget(m_pEditorMAC, 5, 1, 1, 2);
    902                 }
    903                 /* Prepare MAC button: */
    904                 m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings);
    905                 if (m_pButtonMAC)
    906                 {
    907                     m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
    908                     pLayoutAdapterSettings->addWidget(m_pButtonMAC, 5, 3);
    909                 }
    910 
    911                 /* Prepare MAC label: */
    912                 m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings);
    913                 if (m_pLabelGenericProperties)
    914                 {
    915                     m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop);
    916                     pLayoutAdapterSettings->addWidget(m_pLabelGenericProperties, 6, 0);
    917                 }
    918                 /* Prepare MAC editor: */
    919                 m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings);
    920                 if (m_pEditorGenericProperties)
    921                     pLayoutAdapterSettings->addWidget(m_pEditorGenericProperties, 6, 1, 1, 3);
    922 
    923                 /* Prepare cable connected check-box: */
    924                 m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings);
    925                 if (m_pCheckBoxCableConnected)
    926                     pLayoutAdapterSettings->addWidget(m_pCheckBoxCableConnected, 7, 1, 1, 2);
    927 
    928                 /* Prepare port forwarding button: */
    929                 m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings);
    930                 if (m_pButtonPortForwarding)
    931                     pLayoutAdapterSettings->addWidget(m_pButtonPortForwarding, 8, 1);
    932             }
     868                /* Create the container widget for advanced settings related widgets: */
     869                m_pWidgetAdvancedSettings = new QWidget;
     870                m_pLayoutAdapterSettings->addWidget(m_pWidgetAdvancedSettings, 3, 0, 4, 3, Qt::AlignLeft);
     871                QGridLayout *pLayoutAdvancedSettings = new QGridLayout(m_pWidgetAdvancedSettings);
     872                pLayoutAdvancedSettings->setContentsMargins(0, 0, 0, 0);
     873                prepareAdvancedSettingsWidgets(pLayoutAdvancedSettings);
     874           }
    933875
    934876            pLayoutMain->addWidget(m_pWidgetAdapterSettings, 1, 1);
     
    949891    connect(m_pButtonPortForwarding, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg);
    950892    connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate);
     893}
     894
     895void UIMachineSettingsNetwork::prepareAdvancedSettingsWidgets(QGridLayout *pLayout)
     896{
     897    AssertPtrReturnVoid(pLayout);
     898
     899    /* Prepare adapter type label: */
     900    m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings);
     901    if (m_pLabelAdapterType)
     902    {
     903        m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     904        pLayout->addWidget(m_pLabelAdapterType, 0, 0);
     905    }
     906    /* Prepare adapter type combo: */
     907    m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings);
     908    if (m_pComboAdapterType)
     909    {
     910        if (m_pLabelAdapterType)
     911            m_pLabelAdapterType->setBuddy(m_pComboAdapterType);
     912        pLayout->addWidget(m_pComboAdapterType, 0, 1, 1, 3);
     913    }
     914
     915    /* Prepare promiscuous mode label: */
     916    m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings);
     917    if (m_pLabelPromiscuousMode)
     918    {
     919        m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     920        pLayout->addWidget(m_pLabelPromiscuousMode, 1, 0);
     921    }
     922    /* Prepare promiscuous mode combo: */
     923    m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings);
     924    if (m_pComboPromiscuousMode)
     925    {
     926        if (m_pLabelPromiscuousMode)
     927            m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode);
     928        pLayout->addWidget(m_pComboPromiscuousMode, 1, 1, 1, 3);
     929    }
     930
     931    /* Prepare MAC label: */
     932    m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings);
     933    if (m_pLabelMAC)
     934    {
     935        m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     936        pLayout->addWidget(m_pLabelMAC, 2, 0);
     937    }
     938    /* Prepare MAC editor: */
     939    m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings);
     940    if (m_pEditorMAC)
     941    {
     942        if (m_pLabelMAC)
     943            m_pLabelMAC->setBuddy(m_pEditorMAC);
     944        m_pEditorMAC->setAllowToCopyContentsWhenDisabled(true);
     945        m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
     946        m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12));
     947
     948        pLayout->addWidget(m_pEditorMAC, 2, 1, 1, 2);
     949    }
     950    /* Prepare MAC button: */
     951    m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings);
     952    if (m_pButtonMAC)
     953    {
     954        m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
     955        pLayout->addWidget(m_pButtonMAC, 2, 3);
     956    }
     957
     958    /* Prepare MAC label: */
     959    m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings);
     960    if (m_pLabelGenericProperties)
     961    {
     962        m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop);
     963        pLayout->addWidget(m_pLabelGenericProperties, 3, 0);
     964    }
     965    /* Prepare MAC editor: */
     966    m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings);
     967    if (m_pEditorGenericProperties)
     968        pLayout->addWidget(m_pEditorGenericProperties, 3, 1, 1, 3);
     969
     970    /* Prepare cable connected check-box: */
     971    m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings);
     972    if (m_pCheckBoxCableConnected)
     973        pLayout->addWidget(m_pCheckBoxCableConnected, 4, 1, 1, 2);
     974
     975    /* Prepare port forwarding button: */
     976    m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings);
     977    if (m_pButtonPortForwarding)
     978        pLayout->addWidget(m_pButtonPortForwarding, 5, 1);
    951979}
    952980
     
    10161044{
    10171045    /* Update visibility of advanced options: */
    1018     m_pLabelAdapterType->setVisible(m_pButtonAdvanced->isExpanded());
    1019     m_pComboAdapterType->setVisible(m_pButtonAdvanced->isExpanded());
    1020     m_pLabelPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded());
    1021     m_pComboPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded());
    1022     m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    1023                                           m_pButtonAdvanced->isExpanded());
    1024     m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    1025                                              m_pButtonAdvanced->isExpanded());
    1026     m_pLabelMAC->setVisible(m_pButtonAdvanced->isExpanded());
    1027     m_pEditorMAC->setVisible(m_pButtonAdvanced->isExpanded());
    1028     m_pButtonMAC->setVisible(m_pButtonAdvanced->isExpanded());
    1029     m_pCheckBoxCableConnected->setVisible(m_pButtonAdvanced->isExpanded());
    1030     m_pButtonPortForwarding->setVisible(m_pButtonAdvanced->isExpanded());
     1046    m_pWidgetAdvancedSettings->setVisible(m_pButtonAdvanced->isExpanded());
    10311047}
    10321048
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