VirtualBox

Changeset 51309 in vbox for trunk


Ignore:
Timestamp:
May 20, 2014 4:01:05 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: UIVMInfoDialog: Encapsulating prepare/cleanup stuff.

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

Legend:

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

    r51308 r51309  
    7676UIVMInfoDialog::UIVMInfoDialog(UIMachineWindow *pMachineWindow)
    7777    : QIWithRetranslateUI<QMainWindow>(0)
    78     , m_pPseudoParentWidget(pMachineWindow)
     78    , m_pMachineWindow(pMachineWindow)
    7979    , m_fIsPolished(false)
    8080    , m_iWidth(0), m_iHeight(0), m_fMax(false)
     
    8282    , m_pTimer(new QTimer(this))
    8383{
    84     /* Initialize instance early: */
     84    /* Initialize instance: */
    8585    m_spInstance = this;
    8686
    87     /* Delete dialog on close: */
    88     setAttribute(Qt::WA_DeleteOnClose);
    89 
    90     /* Apply UI decorations */
    91     Ui::UIVMInfoDialog::setupUi(this);
    92 
    93 #ifdef Q_WS_MAC
    94     /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
    95     setWindowIcon(QIcon());
    96 #else /* !Q_WS_MAC */
    97     /* Apply window icons */
    98     setWindowIcon(UIIconPool::iconSetFull(":/session_info_32px.png", ":/session_info_16px.png"));
    99 #endif /* !Q_WS_MAC */
    100 
    101     /* Setup tab icons: */
    102     mInfoStack->setTabIcon(0, UIIconPool::iconSet(":/session_info_details_16px.png"));
    103     mInfoStack->setTabIcon(1, UIIconPool::iconSet(":/session_info_runtime_16px.png"));
    104 
    105     /* Setup focus-proxy for pages: */
    106     mPage1->setFocusProxy(mDetailsText);
    107     mPage2->setFocusProxy(mStatisticText);
    108 
    109     /* Setup browsers: */
    110     mDetailsText->viewport()->setAutoFillBackground(false);
    111     mStatisticText->viewport()->setAutoFillBackground(false);
    112 
    113     /* Setup margins: */
    114     mDetailsText->setViewportMargins(5, 5, 5, 5);
    115     mStatisticText->setViewportMargins(5, 5, 5, 5);
    116 
    117     /* Configure dialog button-box: */
    118     mButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape);
    119 
    120     /* Setup handlers: */
    121     connect(pMachineWindow->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment&)), this, SLOT(sltUpdateDetails()));
    122     connect(pMachineWindow->uisession(), SIGNAL(sigSharedFolderChange()), this, SLOT(sltUpdateDetails()));
    123     /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are more than one screens. */
    124     connect(pMachineWindow->machineView(), SIGNAL(resizeHintDone()), this, SLOT(sltProcessStatistics()));
    125     connect(mInfoStack, SIGNAL(currentChanged(int)), this, SLOT(sltHandlePageChanged(int)));
    126     connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltUpdateDetails()));
    127     connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics()));
    128 
    129     /* Loading language constants: */
    130     retranslateUi();
    131 
    132     /* Details page update: */
    133     sltUpdateDetails();
    134 
    135     /* Statistics page update: */
    136     sltProcessStatistics();
    137     m_pTimer->start(5000);
    138 
    139     /* Load dialog attributes for this VM: */
    140     QString strSize = m_session.GetMachine().GetExtraData(GUI_InfoDlgState);
    141     if (strSize.isEmpty())
    142     {
    143         m_iWidth = 400;
    144         m_iHeight = 450;
    145         m_fMax = false;
    146     }
    147     else
    148     {
    149         QStringList list = strSize.split(',');
    150         m_iWidth = list[0].toInt(), m_iHeight = list[1].toInt();
    151         m_fMax = list[2] == "max";
    152     }
    153 
    154     /* Make statistics page the default one: */
    155     mInfoStack->setCurrentIndex(1);
     87    /* Prepare: */
     88    prepare();
    15689}
    15790
    15891UIVMInfoDialog::~UIVMInfoDialog()
    15992{
    160     /* Save dialog attributes for this VM: */
    161     QString strSize("%1,%2,%3");
    162     m_session.GetMachine().SetExtraData(GUI_InfoDlgState,
    163                                         strSize.arg(m_iWidth).arg(m_iHeight).arg(isMaximized() ? "max" : "normal"));
    164 
    165     /* Deinitialize instance finally: */
     93    /* Cleanup: */
     94    cleanup();
     95
     96    /* Deinitialize instance: */
    16697    m_spInstance = 0;
    16798}
     
    380311        /* Load window size, adjust position and load window state finally: */
    381312        resize(m_iWidth, m_iHeight);
    382         vboxGlobal().centerWidget(this, m_pPseudoParentWidget, false);
     313        vboxGlobal().centerWidget(this, m_pMachineWindow, false);
    383314        if (m_fMax)
    384315            QTimer::singleShot(0, this, SLOT(showMaximized()));
     
    418349    /* Focus the browser on shown page: */
    419350    mInfoStack->widget(iIndex)->setFocus();
     351}
     352
     353void UIVMInfoDialog::prepare()
     354{
     355    /* Prepare dialog: */
     356    prepareThis();
     357    /* Load settings: */
     358    loadSettings();
     359}
     360
     361void UIVMInfoDialog::prepareThis()
     362{
     363    /* Delete dialog on close: */
     364    setAttribute(Qt::WA_DeleteOnClose);
     365    /* Delete dialog on machine-window destruction: */
     366    connect(m_pMachineWindow, SIGNAL(destroyed(QObject*)), this, SLOT(suicide()));
     367
     368#ifdef Q_WS_MAC
     369    /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
     370    setWindowIcon(QIcon());
     371#else /* !Q_WS_MAC */
     372    /* Apply window icons */
     373    setWindowIcon(UIIconPool::iconSetFull(":/session_info_32px.png", ":/session_info_16px.png"));
     374#endif /* !Q_WS_MAC */
     375
     376    /* Apply UI decorations */
     377    Ui::UIVMInfoDialog::setupUi(this);
     378
     379    /* Setup tab icons: */
     380    mInfoStack->setTabIcon(0, UIIconPool::iconSet(":/session_info_details_16px.png"));
     381    mInfoStack->setTabIcon(1, UIIconPool::iconSet(":/session_info_runtime_16px.png"));
     382
     383    /* Setup focus-proxy for pages: */
     384    mPage1->setFocusProxy(mDetailsText);
     385    mPage2->setFocusProxy(mStatisticText);
     386
     387    /* Setup browsers: */
     388    mDetailsText->viewport()->setAutoFillBackground(false);
     389    mStatisticText->viewport()->setAutoFillBackground(false);
     390
     391    /* Setup margins: */
     392    mDetailsText->setViewportMargins(5, 5, 5, 5);
     393    mStatisticText->setViewportMargins(5, 5, 5, 5);
     394
     395    /* Configure dialog button-box: */
     396    mButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape);
     397
     398    /* Setup handlers: */
     399    connect(m_pMachineWindow->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment&)), this, SLOT(sltUpdateDetails()));
     400    connect(m_pMachineWindow->uisession(), SIGNAL(sigSharedFolderChange()), this, SLOT(sltUpdateDetails()));
     401    /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are more than one screens. */
     402    connect(m_pMachineWindow->machineView(), SIGNAL(resizeHintDone()), this, SLOT(sltProcessStatistics()));
     403    connect(mInfoStack, SIGNAL(currentChanged(int)), this, SLOT(sltHandlePageChanged(int)));
     404    connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltUpdateDetails()));
     405    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics()));
     406
     407    /* Loading language constants: */
     408    retranslateUi();
     409
     410    /* Details page update: */
     411    sltUpdateDetails();
     412
     413    /* Statistics page update: */
     414    sltProcessStatistics();
     415    m_pTimer->start(5000);
     416
     417    /* Make statistics page the default one: */
     418    mInfoStack->setCurrentIndex(1);
     419}
     420
     421void UIVMInfoDialog::loadSettings()
     422{
     423    /* Load dialog geometry: */
     424    QString strSize = m_session.GetMachine().GetExtraData(GUI_InfoDlgState);
     425    if (strSize.isEmpty())
     426    {
     427        m_iWidth = 400;
     428        m_iHeight = 450;
     429        m_fMax = false;
     430    }
     431    else
     432    {
     433        QStringList list = strSize.split(',');
     434        m_iWidth = list[0].toInt(), m_iHeight = list[1].toInt();
     435        m_fMax = list[2] == "max";
     436    }
     437}
     438
     439void UIVMInfoDialog::saveSettings()
     440{
     441    /* Save dialog geometry: */
     442    QString strSize("%1,%2,%3");
     443    m_session.GetMachine().SetExtraData(GUI_InfoDlgState,
     444                                        strSize.arg(m_iWidth).arg(m_iHeight).arg(isMaximized() ? "max" : "normal"));
     445}
     446
     447void UIVMInfoDialog::cleanup()
     448{
     449    /* Save settings: */
     450    saveSettings();
    420451}
    421452
  • trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.h

    r51308 r51309  
    7070private slots:
    7171
     72    /** Slot to destroy dialog immediately. */
     73    void suicide() { delete this; }
    7274    /** Slot to update general VM details. */
    7375    void sltUpdateDetails();
     
    7880
    7981private:
     82
     83    /** General prepare helper. */
     84    void prepare();
     85    /** Dialog prepare helper. */
     86    void prepareThis();
     87    /** Load settings helper. */
     88    void loadSettings();
     89
     90    /** Save settings helper. */
     91    void saveSettings();
     92    // /** Dialog cleanup helper. */
     93    // void cleanupThis() {}
     94    /** General cleanup helper. */
     95    void cleanup();
    8096
    8197    /** Helper to parse passed VM statistics @a aText. */
     
    98114    /** Dialog instance pointer. */
    99115    static UIVMInfoDialog *m_spInstance;
    100     /** Widget to center dialog according. */
    101     QWidget               *m_pPseudoParentWidget;
     116    /** Machine-window to center dialog according. */
     117    UIMachineWindow       *m_pMachineWindow;
    102118    /** Whether dialog was polished. */
    103119    bool                   m_fIsPolished;
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