儲存庫 vbox 的更動 67021
- 時間撮記:
- 2017-5-22 下午03:08:11 (8 年 以前)
- 位置:
- trunk/src/VBox/Frontends/VirtualBox/src
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp
r66911 r67021 1004 1004 1005 1005 /********************************************************************************************************************************* 1006 * Class UIHostNetworkManagerFactory implementation. * 1007 *********************************************************************************************************************************/ 1008 1009 void UIHostNetworkManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 1010 { 1011 pDialog = new UIHostNetworkManager(pCenterWidget); 1012 } 1013 1014 1015 /********************************************************************************************************************************* 1006 1016 * Class UIHostNetworkManager implementation. * 1007 1017 *********************************************************************************************************************************/ 1008 1018 1009 /* static */1010 UIHostNetworkManager *UIHostNetworkManager::s_pInstance = 0;1011 UIHostNetworkManager *UIHostNetworkManager::instance() { return s_pInstance; }1012 1013 1019 UIHostNetworkManager::UIHostNetworkManager(QWidget *pCenterWidget) 1014 : m_pPseudoParentWidget(pCenterWidget) 1015 , m_pWidget(0) 1016 , m_pButtonBox(0) 1017 { 1018 /* Prepare instance: */ 1019 s_pInstance = this; 1020 1021 /* Prepare: */ 1022 prepare(); 1023 } 1024 1025 UIHostNetworkManager::~UIHostNetworkManager() 1026 { 1027 /* Cleanup: */ 1028 cleanup(); 1029 1030 /* Cleanup instance: */ 1031 s_pInstance = 0; 1032 } 1033 1034 /* static */ 1035 void UIHostNetworkManager::showModeless(QWidget *pCenterWidget /* = 0 */) 1036 { 1037 /* Create instance if not yet created: */ 1038 if (!s_pInstance) 1039 new UIHostNetworkManager(pCenterWidget); 1040 1041 /* Show instance: */ 1042 s_pInstance->show(); 1043 s_pInstance->setWindowState(s_pInstance->windowState() & ~Qt::WindowMinimized); 1044 s_pInstance->activateWindow(); 1020 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 1021 { 1045 1022 } 1046 1023 … … 1051 1028 } 1052 1029 1053 void UIHostNetworkManager::prepare ()1054 { 1055 /* Prepare this: */1056 prepareThis();1030 void UIHostNetworkManager::prepareDialog() 1031 { 1032 /* Apply window icons: */ 1033 setWindowIcon(UIIconPool::iconSetFull(":/host_iface_manager_32px.png", ":/host_iface_manager_16px.png")); 1057 1034 1058 1035 /* Apply language settings: */ 1059 1036 retranslateUi(); 1060 1061 /* Center according pseudo-parent widget: */1062 VBoxGlobal::centerWidget(this, m_pPseudoParentWidget, false);1063 }1064 1065 void UIHostNetworkManager::prepareThis()1066 {1067 /* Initial size: */1068 resize(620, 460);1069 1070 /* Dialog should delete itself on 'close': */1071 setAttribute(Qt::WA_DeleteOnClose);1072 /* And no need to count it as important for application.1073 * This way it will NOT be taken into account1074 * when other top-level windows will be closed: */1075 setAttribute(Qt::WA_QuitOnClose, false);1076 1077 /* Apply window icons: */1078 setWindowIcon(UIIconPool::iconSetFull(":/host_iface_manager_32px.png", ":/host_iface_manager_16px.png"));1079 1080 /* Prepare central-widget: */1081 prepareCentralWidget();1082 /* Prepare menu-bar: */1083 prepareMenuBar();1084 /* Prepare toolbar: */1085 prepareToolBar();1086 }1087 1088 void UIHostNetworkManager::prepareCentralWidget()1089 {1090 /* Create central-widget: */1091 setCentralWidget(new QWidget);1092 AssertPtrReturnVoid(centralWidget());1093 {1094 /* Create main-layout: */1095 new QVBoxLayout(centralWidget());1096 AssertPtrReturnVoid(centralWidget()->layout());1097 {1098 /* Configure layout: */1099 centralWidget()->layout()->setContentsMargins(5, 5, 5, 5);1100 centralWidget()->layout()->setSpacing(10);1101 1102 /* Prepare widget: */1103 prepareWidget();1104 /* Prepare button-box: */1105 prepareButtonBox();1106 }1107 }1108 1037 } 1109 1038 … … 1111 1040 { 1112 1041 /* Create widget: */ 1113 m_pWidget = new UIHostNetworkManagerWidget(this); 1114 AssertPtrReturnVoid(m_pWidget); 1115 { 1042 UIHostNetworkManagerWidget *pWidget = new UIHostNetworkManagerWidget(this); 1043 AssertPtrReturnVoid(pWidget); 1044 { 1045 /* Configure widget: */ 1046 setWidget(pWidget); 1047 setWidgetMenu(pWidget->menu()); 1048 #ifdef VBOX_WS_MAC 1049 setWidgetToolbar(pWidget->toolbar()); 1050 #endif 1116 1051 /* Add to layout: */ 1117 centralWidget()->layout()->addWidget(m_pWidget); 1118 } 1119 } 1120 1121 void UIHostNetworkManager::prepareButtonBox() 1122 { 1123 /* Create button-box: */ 1124 m_pButtonBox = new QIDialogButtonBox; 1125 AssertPtrReturnVoid(m_pButtonBox); 1126 { 1127 /* Configure button-box: */ 1128 m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Close); 1129 m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 1130 connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 1131 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIHostNetworkManager::close); 1132 1133 /* Add into layout: */ 1134 centralWidget()->layout()->addWidget(m_pButtonBox); 1135 } 1136 } 1137 1138 void UIHostNetworkManager::prepareMenuBar() 1139 { 1140 /* Add 'Network' menu: */ 1141 menuBar()->addMenu(m_pWidget->menu()); 1142 1143 #ifdef VBOX_WS_MAC 1144 /* Prepare 'Window' menu: */ 1145 AssertPtrReturnVoid(gpWindowMenuManager); 1146 menuBar()->addMenu(gpWindowMenuManager->createMenu(this)); 1147 gpWindowMenuManager->addWindow(this); 1148 #endif 1149 } 1150 1151 void UIHostNetworkManager::prepareToolBar() 1152 { 1153 #ifdef VBOX_WS_MAC 1154 /* Enable unified toolbar on macOS: */ 1155 addToolBar(m_pWidget->toolbar()); 1156 m_pWidget->toolbar()->enableMacToolbar(); 1157 #endif 1158 } 1159 1160 void UIHostNetworkManager::cleanupMenuBar() 1161 { 1162 #ifdef VBOX_WS_MAC 1163 /* Cleanup 'Window' menu: */ 1164 AssertPtrReturnVoid(gpWindowMenuManager); 1165 gpWindowMenuManager->removeWindow(this); 1166 gpWindowMenuManager->destroyMenu(this); 1167 #endif 1168 } 1169 1170 void UIHostNetworkManager::cleanup() 1171 { 1172 /* Cleanup menu-bar: */ 1173 cleanupMenuBar(); 1174 } 1175 1052 centralWidget()->layout()->addWidget(pWidget); 1053 } 1054 } 1055 -
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.h
r66915 r67021 23 23 24 24 /* GUI includes: */ 25 #include "QIManagerDialog.h" 25 26 #include "QIWithRetranslateUI.h" 26 27 … … 160 161 161 162 162 /** Host Network Manager dialog. */ 163 class UIHostNetworkManager : public QIWithRetranslateUI<QMainWindow> 163 /** Host Network Manager dialog factory. */ 164 class UIHostNetworkManagerFactory : public QIManagerDialogFactory 165 { 166 protected: 167 168 /** Creates derived @a pDialog instance. 169 * @param pCenterWidget Brings the widget reference to center according to. */ 170 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */; 171 }; 172 173 174 /** QIManagerDialog sub-class used as Host Network Manager dialog. */ 175 class UIHostNetworkManager : public QIWithRetranslateUI<QIManagerDialog> 164 176 { 165 177 Q_OBJECT; 166 178 179 protected: 180 167 181 /** Constructs Host Network Manager dialog. 168 * @param pCenterWidget Brings the pseudo-parent widgetto center according to. */182 * @param pCenterWidget Brings the widget reference to center according to. */ 169 183 UIHostNetworkManager(QWidget *pCenterWidget); 170 /** Destructs Host Network Manager dialog. */171 ~UIHostNetworkManager();172 173 public:174 175 /** Returns Host Network Manager singleton instance. */176 static UIHostNetworkManager *instance();177 /** Shows Host Network Manager singleton instance, creates new if necessary. */178 static void showModeless(QWidget *pCenterWidget);179 180 protected:181 184 182 185 /** @name Event-handling stuff. … … 186 189 /** @} */ 187 190 188 private:189 190 191 /** @name Prepare/cleanup cascade. 191 192 * @{ */ 192 /** Prepares all. */ 193 void prepare(); 194 /** Prepares this. */ 195 void prepareThis(); 196 /** Prepares central-widget. */ 197 void prepareCentralWidget(); 193 /** Prepares dialog. */ 194 void prepareDialog(); 198 195 /** Prepares widget. */ 199 196 void prepareWidget(); 200 /** Prepares button-box. */ 201 void prepareButtonBox(); 202 /** Prepares menu-bar. */ 203 void prepareMenuBar(); 204 /** Prepares toolbar. */ 205 void prepareToolBar(); 206 207 /** Cleanup menu-bar. */ 208 void cleanupMenuBar(); 209 /** Cleanups all. */ 210 void cleanup(); 211 /** @} */ 212 213 /** @name General variables. 214 * @{ */ 215 /** Holds the Host Network Manager singleton instance. */ 216 static UIHostNetworkManager *s_pInstance; 217 218 /** Holds the widget reference to center Host Network Manager according. */ 219 QWidget *m_pPseudoParentWidget; 220 /** @} */ 221 222 /** @name Widget variables. 223 * @{ */ 224 /** Holds the widget instance. */ 225 UIHostNetworkManagerWidget *m_pWidget; 226 /** @} */ 227 228 /** @name Button-box variables. 229 * @{ */ 230 /** Holds the dialog button-box instance. */ 231 QIDialogButtonBox *m_pButtonBox; 232 /** @} */ 197 /** @} */ 198 199 /** Allow factory access to private/protected members: */ 200 friend class UIHostNetworkManagerFactory; 233 201 }; 234 202 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r66681 r67021 133 133 , m_pGroupMenuAction(0) 134 134 , m_pMachineMenuAction(0) 135 , m_pManagerHostNetwork(0) 135 136 { 136 137 m_spInstance = this; … … 429 430 void UISelectorWindow::sltOpenHostNetworkManagerWindow() 430 431 { 431 /* Show modeless Host Network Manager: */ 432 UIHostNetworkManager::showModeless(this); 432 /* Create instance if not yet created: */ 433 if (!m_pManagerHostNetwork) 434 { 435 UIHostNetworkManagerFactory().prepare(m_pManagerHostNetwork, this); 436 connect(m_pManagerHostNetwork, &QIManagerDialog::sigClose, 437 this, &UISelectorWindow::sltCloseHostNetworkManagerWindow); 438 } 439 440 /* Show instance: */ 441 m_pManagerHostNetwork->show(); 442 m_pManagerHostNetwork->setWindowState(m_pManagerHostNetwork->windowState() & ~Qt::WindowMinimized); 443 m_pManagerHostNetwork->activateWindow(); 444 } 445 446 void UISelectorWindow::sltCloseHostNetworkManagerWindow() 447 { 448 /* Destroy instance if still exists: */ 449 if (m_pManagerHostNetwork) 450 { 451 m_pManagerHostNetwork->close(); 452 UIHostNetworkManagerFactory().cleanup(m_pManagerHostNetwork); 453 } 433 454 } 434 455 … … 2010 2031 void UISelectorWindow::cleanup() 2011 2032 { 2033 /* Close the sub-dialogs first: */ 2034 sltCloseHostNetworkManagerWindow(); 2035 2012 2036 /* Save settings: */ 2013 2037 saveSettings(); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r66681 r67021 28 28 29 29 /* Forward declarations: */ 30 class QMenu; 31 class QStackedWidget; 32 class QIManagerDialog; 33 class QISplitter; 30 34 class CMachine; 31 35 class UIAction; … … 40 44 class UIToolBar; 41 45 class UIVMItem; 42 class QISplitter;43 class QMenu;44 class QStackedWidget;45 46 46 47 /** Singleton QIMainWindow extension … … 126 127 /** Handles call to open Host Network Manager window. */ 127 128 void sltOpenHostNetworkManagerWindow(); 129 /** Handles call to close Host Network Manager window. */ 130 void sltCloseHostNetworkManagerWindow(); 128 131 /** Handles call to open Import Appliance wizard. 129 132 * @param strFileName can bring the name of file to import appliance from. */ … … 355 358 /** Holds the Machine menu parent action. */ 356 359 QAction *m_pMachineMenuAction; 360 361 /** Holds the Host Network Manager window instance. */ 362 QIManagerDialog *m_pManagerHostNetwork; 357 363 }; 358 364
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器