VirtualBox

Changeset 45198 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 27, 2013 9:02:56 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84556
Message:

FE/Qt: Settings dialog: Handle session/machine state changes properly.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
3 edited

Legend:

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

    r44528 r45198  
    292292void UISettingsDialog::setDialogType(SettingsDialogType settingsDialogType)
    293293{
     294    /* Remember new dialog-type: */
    294295    m_dialogType = settingsDialogType;
    295     for (int iWidgetNumber = 0; iWidgetNumber < m_pStack->count(); ++iWidgetNumber)
    296     {
    297         UISettingsPage *pPage = static_cast<UISettingsPage*>(m_pStack->widget(iWidgetNumber));
     296
     297    /* Propagate it to settings-page(s): */
     298    foreach (UISettingsPage *pPage, m_pSelector->settingPages())
    298299        pPage->setDialogType(dialogType());
    299     }
    300300}
    301301
     
    350350                               int iParentId /* = -1 */)
    351351{
    352     QWidget *pPage = m_pSelector->addItem(strBigIcon, strBigIconDisabled,
    353                                           strSmallIcon, strSmallIconDisabled,
    354                                           cId, strLink, pSettingsPage, iParentId);
    355     if (pPage)
    356     {
    357 #ifdef Q_WS_MAC
    358         /* On OSX we add a stretch to the vertical end to make sure the page is
    359          * always top aligned. */
    360         QWidget *pW = new QWidget();
    361         pW->setContentsMargins(0, 0, 0, 0);
    362         QVBoxLayout *pBox = new QVBoxLayout(pW);
    363         VBoxGlobal::setLayoutMargin(pBox, 0);
    364         pBox->addWidget(pPage);
    365         pBox->addStretch(0);
    366         m_pages[cId] = m_pStack->addWidget(pW);
    367 #else /* Q_WS_MAC */
     352    /* Add new selector item: */
     353    if (QWidget *pPage = m_pSelector->addItem(strBigIcon, strBigIconDisabled,
     354                                              strSmallIcon, strSmallIconDisabled,
     355                                              cId, strLink, pSettingsPage, iParentId))
     356    {
     357        /* Add stack-widget page if created: */
    368358        m_pages[cId] = m_pStack->addWidget(pPage);
    369 #endif /* !Q_WS_MAC */
    370         /* Update process bar: */
     359        /* Update process-bar: */
    371360        m_pProcessBar->setMinimum(0);
    372361        m_pProcessBar->setMaximum(m_pStack->count());
    373362    }
     363    /* Assign validator if necessary: */
    374364    if (pSettingsPage)
    375365        assignValidator(pSettingsPage);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r44528 r45198  
    575575    m_machine = vboxGlobal().virtualBox().FindMachine(m_strMachineId);
    576576    AssertMsg(!m_machine.isNull(), ("Can't find corresponding machine!\n"));
    577     /* Assign current dialog type: */
    578     setDialogType(determineSettingsDialogType(m_machine.GetSessionState(), m_machine.GetState()));
     577    m_sessionState = m_machine.GetSessionState();
     578    m_machineState = m_machine.GetState();
     579    /* Recalculate current dialog-type: */
     580    updateDialogType();
    579581
    580582    /* Creating settings pages: */
     
    991993
    992994    /* Make sure settings dialog will be updated on machine state/data changes: */
     995    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
     996            this, SLOT(sltSessionStateChanged(QString, KSessionState)));
    993997    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    994998            this, SLOT(sltMachineStateChanged(QString, KMachineState)));
     
    10121016}
    10131017
    1014 void UISettingsDialogMachine::sltMachineStateChanged(QString strMachineId, KMachineState machineState)
     1018void UISettingsDialogMachine::sltSessionStateChanged(QString strMachineId, KSessionState sessionState)
    10151019{
    10161020    /* Ignore if thats NOT our VM: */
     
    10191023
    10201024    /* Ignore if state was NOT actually changed: */
     1025    if (m_sessionState == sessionState)
     1026        return;
     1027
     1028    /* Update current session state: */
     1029    m_sessionState = sessionState;
     1030
     1031    /* Update dialog-type if necessary: */
     1032    updateDialogType();
     1033}
     1034
     1035void UISettingsDialogMachine::sltMachineStateChanged(QString strMachineId, KMachineState machineState)
     1036{
     1037    /* Ignore if thats NOT our VM: */
     1038    if (strMachineId != m_strMachineId)
     1039        return;
     1040
     1041    /* Ignore if state was NOT actually changed: */
    10211042    if (m_machineState == machineState)
    10221043        return;
     
    10251046    m_machineState = machineState;
    10261047
    1027     /* Get new dialog type: */
    1028     SettingsDialogType newDialogType = determineSettingsDialogType(m_machine.GetSessionState(), m_machineState);
    1029 
    1030     /* Ignore if dialog type was NOT actually changed: */
    1031     if (dialogType() == newDialogType)
    1032         return;
    1033 
    1034     /* Should we show a warning about leaving 'offline' state? */
    1035     bool fShouldWe = dialogType() == SettingsDialogType_Offline;
    1036 
    1037     /* Update current dialog type: */
    1038     setDialogType(newDialogType);
    1039 
    1040     /* Show a warning about leaving 'offline' state if we should: */
    1041     if (isSettingsChanged() && fShouldWe)
    1042         msgCenter().warnAboutStateChange(this);
     1048    /* Update dialog-type if necessary: */
     1049    updateDialogType();
    10431050}
    10441051
     
    11301137{
    11311138    bool fIsSettingsChanged = false;
    1132     for (int iWidgetNumber = 0; iWidgetNumber < m_pStack->count() && !fIsSettingsChanged; ++iWidgetNumber)
    1133     {
    1134         UISettingsPage *pPage = static_cast<UISettingsPage*>(m_pStack->widget(iWidgetNumber));
     1139    foreach (UISettingsPage *pPage, m_pSelector->settingPages())
     1140    {
    11351141        pPage->putToCache();
    1136         if (pPage->changed())
     1142        if (!fIsSettingsChanged && pPage->changed())
    11371143            fIsSettingsChanged = true;
    11381144    }
     
    11401146}
    11411147
     1148void UISettingsDialogMachine::updateDialogType()
     1149{
     1150    /* Get new dialog type: */
     1151    SettingsDialogType newDialogType = determineSettingsDialogType(m_sessionState, m_machineState);
     1152
     1153    /* Ignore if dialog type was NOT actually changed: */
     1154    if (dialogType() == newDialogType)
     1155        return;
     1156
     1157    /* Should we show a warning about leaving 'offline' state? */
     1158    bool fShouldWe = dialogType() == SettingsDialogType_Offline;
     1159
     1160    /* Update current dialog type: */
     1161    setDialogType(newDialogType);
     1162
     1163    /* Show a warning about leaving 'offline' state if we should: */
     1164    if (isSettingsChanged() && fShouldWe)
     1165        msgCenter().warnAboutStateChange(this);
     1166}
     1167
    11421168# include "UISettingsDialogSpecific.moc"
    11431169
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h

    r44528 r45198  
    109109    void sltMarkLoaded();
    110110    void sltMarkSaved();
     111    void sltSessionStateChanged(QString strMachineId, KSessionState sessionState);
    111112    void sltMachineStateChanged(QString strMachineId, KMachineState machineState);
    112113    void sltMachineDataChanged(QString strMachineId);
     
    120121    bool isPageAvailable(int iPageId);
    121122    bool isSettingsChanged();
     123    void updateDialogType();
    122124
    123125    QString m_strMachineId;
     126    KSessionState m_sessionState;
    124127    KMachineState m_machineState;
    125128
Note: See TracChangeset for help on using the changeset viewer.

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