Changeset 66907 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 16, 2017 10:01:18 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115431
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp
r66905 r66907 201 201 , m_pActionRemove(0) 202 202 , m_pActionDetails(0) 203 , m_pActionCommit(0) 203 204 , m_pTreeWidget(0) 204 205 , m_pDetailsWidget(0) … … 241 242 /* Translate menu: */ 242 243 if (m_pMenu) 243 m_pMenu->setTitle(QApplication::translate("UIActionPool", "& File"));244 m_pMenu->setTitle(QApplication::translate("UIActionPool", "&Network")); 244 245 245 246 /* Translate actions: */ … … 261 262 m_pActionDetails->setToolTip(tr("Open Host-only Network Details (%1)").arg(m_pActionDetails->shortcut().toString())); 262 263 m_pActionDetails->setStatusTip(tr("Opens pane with the selected host-only network details.")); 264 } 265 if (m_pActionCommit) 266 { 267 m_pActionCommit->setText(tr("&Apply...")); 268 m_pActionCommit->setToolTip(tr("Apply Changes in Host-only Network Details (%1)").arg(m_pActionCommit->shortcut().toString())); 269 m_pActionCommit->setStatusTip(tr("Applies changes in host-only network details pane.")); 263 270 } 264 271 … … 435 442 } 436 443 437 void UIHostNetworkManager::slt ShowHostNetworkDetails(bool fShow)444 void UIHostNetworkManager::sltToggleHostNetworkDetailsVisibility(bool fShow) 438 445 { 439 446 /* Show/hide details area and Apply button: */ 440 447 m_pDetailsWidget->setVisible(fShow); 441 m_pButtonBox->button(QDialogButtonBox::Apply)->setVisible(fShow); 442 } 443 444 void UIHostNetworkManager::sltHandleButtonClicked(QAbstractButton *pButton) 445 { 446 /* Handle known button (Apply) only: */ 447 if (pButton != m_pButtonBox->button(QDialogButtonBox::Apply)) 448 return; 449 448 m_pActionCommit->setVisible(fShow); 449 } 450 451 void UIHostNetworkManager::sltApplyHostNetworkDetailsChanges() 452 { 450 453 /* Disable button first of all: */ 451 m_p ButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);454 m_pActionCommit->setEnabled(false); 452 455 453 456 /* Get network item: */ … … 685 688 m_pActionRemove->setEnabled(pItem); 686 689 m_pActionDetails->setEnabled(pItem); 690 m_pActionCommit->setEnabled(false); 687 691 688 692 /* If there is an item => update details data: */ … … 693 697 /* Otherwise => clear details and close the area: */ 694 698 m_pDetailsWidget->clearData(); 695 slt ShowHostNetworkDetails(false);699 sltToggleHostNetworkDetailsVisibility(false); 696 700 } 697 701 } … … 789 793 ":/edit_host_iface_disabled_22px.png", 790 794 ":/edit_host_iface_disabled_16px.png")); 791 connect(m_pActionDetails, &QAction::toggled, this, &UIHostNetworkManager::sltShowHostNetworkDetails); 795 connect(m_pActionDetails, &QAction::toggled, this, &UIHostNetworkManager::sltToggleHostNetworkDetailsVisibility); 796 } 797 798 /* Create 'Apply' action: */ 799 m_pActionCommit = new QAction(this); 800 AssertPtrReturnVoid(m_pActionCommit); 801 { 802 /* Configure 'Apply' action: */ 803 m_pActionCommit->setVisible(false); 804 m_pActionCommit->setShortcut(QKeySequence("Ctrl+Return")); 805 m_pActionCommit->setIcon(UIIconPool::iconSetFull(":/edit_host_iface_22px.png", 806 ":/edit_host_iface_16px.png", 807 ":/edit_host_iface_disabled_22px.png", 808 ":/edit_host_iface_disabled_16px.png")); 809 connect(m_pActionDetails, &QAction::toggled, m_pActionCommit, &QAction::setVisible); 810 connect(m_pActionCommit, &QAction::triggered, this, &UIHostNetworkManager::sltApplyHostNetworkDetailsChanges); 792 811 } 793 812 … … 798 817 void UIHostNetworkManager::prepareMenuBar() 799 818 { 800 /* Create ' File' menu: */819 /* Create 'Network' menu: */ 801 820 m_pMenu = menuBar()->addMenu(QString()); 802 821 AssertPtrReturnVoid(m_pMenu); 803 822 { 804 /* Configure 'File'menu: */823 /* Configure menu: */ 805 824 m_pMenu->addAction(m_pActionAdd); 806 825 m_pMenu->addAction(m_pActionRemove); 807 826 m_pMenu->addAction(m_pActionDetails); 827 m_pMenu->addAction(m_pActionCommit); 808 828 } 809 829 … … 854 874 if (m_pActionRemove) 855 875 m_pToolBar->addAction(m_pActionRemove); 876 if ((m_pActionAdd || m_pActionRemove) && (m_pActionDetails || m_pActionCommit)) 877 m_pToolBar->addSeparator(); 856 878 if (m_pActionDetails) 857 879 m_pToolBar->addAction(m_pActionDetails); 880 if (m_pActionCommit) 881 m_pToolBar->addAction(m_pActionCommit); 858 882 /* Integrate tool-bar into dialog: */ 859 883 QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout()); … … 912 936 m_pDetailsWidget->setVisible(false); 913 937 m_pDetailsWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); 938 connect(m_pDetailsWidget, &UIHostNetworkDetailsDialog::sigDataChanged, 939 m_pActionCommit, &QAction::setEnabled); 914 940 915 941 /* Add into layout: */ … … 925 951 { 926 952 /* Configure button-box: */ 927 m_pButtonBox->setStandardButtons(QDialogButtonBox::Close | QDialogButtonBox::Apply);953 m_pButtonBox->setStandardButtons(QDialogButtonBox::Close); 928 954 m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 929 m_pButtonBox->button(QDialogButtonBox::Apply)->hide();930 955 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIHostNetworkManager::close); 931 connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UIHostNetworkManager::sltHandleButtonClicked); 932 connect(m_pDetailsWidget, &UIHostNetworkDetailsDialog::sigDataChanged, 933 m_pButtonBox->button(QDialogButtonBox::Apply), &QWidget::setEnabled); 934 935 /* Add button-box into layout: */ 956 957 /* Add into layout: */ 936 958 centralWidget()->layout()->addWidget(m_pButtonBox); 937 959 } -
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h
r66905 r66907 77 77 /** Handles command to remove host network. */ 78 78 void sltRemoveHostNetwork(); 79 /** Handles command to @a fShow host network details. */ 80 void sltShowHostNetworkDetails(bool fShow); 81 /** @} */ 82 83 /** @name Button-box stuff. 84 * @{ */ 85 /** Handles button-box @a pButton click. */ 86 void sltHandleButtonClicked(QAbstractButton *pButton); 79 /** Handles command to make host network details @a fVisible. */ 80 void sltToggleHostNetworkDetailsVisibility(bool fVisible); 81 /** Handles command to apply host network details changes. */ 82 void sltApplyHostNetworkDetailsChanges(); 87 83 /** @} */ 88 84 … … 166 162 /** Holds the Details action instance. */ 167 163 QAction *m_pActionDetails; 164 /** Holds the Commit action instance. */ 165 QAction *m_pActionCommit; 168 166 /** @} */ 169 167
Note:
See TracChangeset
for help on using the changeset viewer.