VirtualBox

儲存庫 vbox 的更動 67021


忽略:
時間撮記:
2017-5-22 下午03:08:11 (8 年 以前)
作者:
vboxsync
訊息:

FE/Qt: bugref:8847: Host Network Manager: Moving onto QIManagerDialog rails.

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

圖例:

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

    r66911 r67021  
    10041004
    10051005/*********************************************************************************************************************************
     1006*   Class UIHostNetworkManagerFactory implementation.                                                                            *
     1007*********************************************************************************************************************************/
     1008
     1009void UIHostNetworkManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
     1010{
     1011    pDialog = new UIHostNetworkManager(pCenterWidget);
     1012}
     1013
     1014
     1015/*********************************************************************************************************************************
    10061016*   Class UIHostNetworkManager implementation.                                                                                   *
    10071017*********************************************************************************************************************************/
    10081018
    1009 /* static */
    1010 UIHostNetworkManager *UIHostNetworkManager::s_pInstance = 0;
    1011 UIHostNetworkManager *UIHostNetworkManager::instance() { return s_pInstance; }
    1012 
    10131019UIHostNetworkManager::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{
    10451022}
    10461023
     
    10511028}
    10521029
    1053 void UIHostNetworkManager::prepare()
    1054 {
    1055     /* Prepare this: */
    1056     prepareThis();
     1030void UIHostNetworkManager::prepareDialog()
     1031{
     1032    /* Apply window icons: */
     1033    setWindowIcon(UIIconPool::iconSetFull(":/host_iface_manager_32px.png", ":/host_iface_manager_16px.png"));
    10571034
    10581035    /* Apply language settings: */
    10591036    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 account
    1074      * 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     }
    11081037}
    11091038
     
    11111040{
    11121041    /* 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
    11161051        /* 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  
    2323
    2424/* GUI includes: */
     25#include "QIManagerDialog.h"
    2526#include "QIWithRetranslateUI.h"
    2627
     
    160161
    161162
    162 /** Host Network Manager dialog. */
    163 class UIHostNetworkManager : public QIWithRetranslateUI<QMainWindow>
     163/** Host Network Manager dialog factory. */
     164class UIHostNetworkManagerFactory : public QIManagerDialogFactory
     165{
     166protected:
     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. */
     175class UIHostNetworkManager : public QIWithRetranslateUI<QIManagerDialog>
    164176{
    165177    Q_OBJECT;
    166178
     179protected:
     180
    167181    /** Constructs Host Network Manager dialog.
    168       * @param  pCenterWidget  Brings the pseudo-parent widget to center according to. */
     182      * @param  pCenterWidget  Brings the widget reference to center according to. */
    169183    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:
    181184
    182185    /** @name Event-handling stuff.
     
    186189    /** @} */
    187190
    188 private:
    189 
    190191    /** @name Prepare/cleanup cascade.
    191192      * @{ */
    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();
    198195        /** Prepares widget. */
    199196        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;
    233201};
    234202
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r66681 r67021  
    133133    , m_pGroupMenuAction(0)
    134134    , m_pMachineMenuAction(0)
     135    , m_pManagerHostNetwork(0)
    135136{
    136137    m_spInstance = this;
     
    429430void UISelectorWindow::sltOpenHostNetworkManagerWindow()
    430431{
    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
     446void UISelectorWindow::sltCloseHostNetworkManagerWindow()
     447{
     448    /* Destroy instance if still exists: */
     449    if (m_pManagerHostNetwork)
     450    {
     451        m_pManagerHostNetwork->close();
     452        UIHostNetworkManagerFactory().cleanup(m_pManagerHostNetwork);
     453    }
    433454}
    434455
     
    20102031void UISelectorWindow::cleanup()
    20112032{
     2033    /* Close the sub-dialogs first: */
     2034    sltCloseHostNetworkManagerWindow();
     2035
    20122036    /* Save settings: */
    20132037    saveSettings();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r66681 r67021  
    2828
    2929/* Forward declarations: */
     30class QMenu;
     31class QStackedWidget;
     32class QIManagerDialog;
     33class QISplitter;
    3034class CMachine;
    3135class UIAction;
     
    4044class UIToolBar;
    4145class UIVMItem;
    42 class QISplitter;
    43 class QMenu;
    44 class QStackedWidget;
    4546
    4647/** Singleton QIMainWindow extension
     
    126127        /** Handles call to open Host Network Manager window. */
    127128        void sltOpenHostNetworkManagerWindow();
     129        /** Handles call to close Host Network Manager window. */
     130        void sltCloseHostNetworkManagerWindow();
    128131        /** Handles call to open Import Appliance wizard.
    129132          * @param strFileName can bring the name of file to import appliance from. */
     
    355358    /** Holds the Machine menu parent action. */
    356359    QAction *m_pMachineMenuAction;
     360
     361    /** Holds the Host Network Manager window instance. */
     362    QIManagerDialog *m_pManagerHostNetwork;
    357363};
    358364
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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