VirtualBox

Ignore:
Timestamp:
Mar 23, 2011 9:36:05 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 3887: Make certain VM settings editable during runtime (initial commit).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r35940 r36357  
    55
    66#
    7 # Copyright (C) 2006-2010 Oracle Corporation
     7# Copyright (C) 2006-2011 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
     
    393393        src/runtime/UIIndicatorsPool.cpp \
    394394        src/runtime/UIMachine.cpp \
    395         src/runtime/UIMachineLogic.cpp \
    396395        src/runtime/UIMachineMenuBar.cpp
    397396
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h

    r35897 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2009 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9999    };
    100100
     101    /** Settings dialog types: */
     102    enum SettingsDialogType
     103    {
     104        SettingsDialogType_Wrong,
     105        SettingsDialogType_Offline,
     106        SettingsDialogType_Runtime
     107    };
     108
    101109    static const char* GUI_LastWindowPosition;
    102110    static const char* GUI_LastNormalWindowPosition;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp

    r36083 r36357  
    223223};
    224224
     225class ShowSettingsDialogAction : public UISimpleAction
     226{
     227    Q_OBJECT;
     228
     229public:
     230
     231    ShowSettingsDialogAction(QObject *pParent)
     232        : UISimpleAction(pParent,
     233                         ":/settings_16px.png", ":/settings_dis_16px.png")
     234    {
     235        retranslateUi();
     236    }
     237
     238protected:
     239
     240    void retranslateUi()
     241    {
     242        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Settings..."), gMS->shortcut(UIMachineShortcuts::SettingsDialogShortcut)));
     243        setStatusTip(QApplication::translate("UIActionsPool", "Manage the virtual machine settings"));
     244    }
     245};
     246
    225247class PerformTakeSnapshotAction : public UISimpleAction
    226248{
     
    262284    void retranslateUi()
    263285    {
    264         setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Session I&nformation"), gMS->shortcut(UIMachineShortcuts::InformationDialogShortcut)));
     286        setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Session I&nformation..."), gMS->shortcut(UIMachineShortcuts::InformationDialogShortcut)));
    265287        setStatusTip(QApplication::translate("UIActionsPool", "Show Session Information Dialog"));
    266288    }
     
    11141136{
    11151137    /* "Machine" menu actions: */
     1138    m_actionsPool[UIActionIndex_Simple_SettingsDialog] = new ShowSettingsDialogAction(this);
    11161139    m_actionsPool[UIActionIndex_Simple_TakeSnapshot] = new PerformTakeSnapshotAction(this);
    11171140    m_actionsPool[UIActionIndex_Simple_InformationDialog] = new ShowInformationDialogAction(this);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.h

    r36355 r36357  
    5252    /* "Machine" menu actions: */
    5353    UIActionIndex_Menu_Machine,
     54    UIActionIndex_Simple_SettingsDialog,
    5455    UIActionIndex_Simple_TakeSnapshot,
    5556    UIActionIndex_Simple_InformationDialog,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r35133 r36357  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3838#include "VBoxTakeSnapshotDlg.h"
    3939#include "VBoxVMInformationDlg.h"
    40 #include "UIMachineSettingsNetwork.h"
    41 #include "UIMachineSettingsSF.h"
     40#include "UISettingsDialogSpecific.h"
    4241#ifdef Q_WS_MAC
    4342# include "DockIconPreview.h"
     
    102101};
    103102Q_DECLARE_METATYPE(USBTarget);
    104 
    105 class UINetworkAdaptersDialog : public QIWithRetranslateUI<QDialog>
    106 {
    107     Q_OBJECT;
    108 
    109 public:
    110 
    111     UINetworkAdaptersDialog(QWidget *pParent, CSession &session)
    112         : QIWithRetranslateUI<QDialog>(pParent)
    113         , m_pSettings(0)
    114         , m_session(session)
    115     {
    116         /* Setup Dialog's options */
    117         setModal(true);
    118         setWindowIcon(QIcon(":/nw_16px.png"));
    119         setSizeGripEnabled(true);
    120 
    121         /* Setup main dialog's layout */
    122         QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    123         VBoxGlobal::setLayoutMargin(pMainLayout, 10);
    124         pMainLayout->setSpacing(10);
    125 
    126         /* Setup settings layout */
    127         m_pSettings = new UIMachineSettingsNetworkPage(true);
    128         m_pSettings->setOrderAfter(this);
    129         VBoxGlobal::setLayoutMargin(m_pSettings->layout(), 0);
    130         m_pSettings->loadDirectlyFrom(m_session.GetMachine());
    131         pMainLayout->addWidget(m_pSettings);
    132 
    133         /* Setup button's layout */
    134         QIDialogButtonBox *pButtonBox = new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
    135 
    136         connect(pButtonBox, SIGNAL(helpRequested()), &vboxProblem(), SLOT(showHelpHelpDialog()));
    137         connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
    138         connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
    139         pMainLayout->addWidget(pButtonBox);
    140 
    141         retranslateUi();
    142     }
    143 
    144 protected:
    145 
    146     void retranslateUi()
    147     {
    148         setWindowTitle(QApplication::translate("VBoxNetworkDialog", "Network Adapters"));
    149     }
    150 
    151 protected slots:
    152 
    153     virtual void accept()
    154     {
    155         CMachine machine = m_session.GetMachine();
    156         m_pSettings->saveDirectlyTo(machine);
    157         machine.SaveSettings();
    158         if (!machine.isOk())
    159             vboxProblem().cannotSaveMachineSettings(machine);
    160         QDialog::accept();
    161     }
    162 
    163 protected:
    164 
    165     void showEvent(QShowEvent *pEvent)
    166     {
    167         resize(450, 300);
    168         VBoxGlobal::centerWidget(this, parentWidget());
    169         setMinimumWidth(400);
    170         QDialog::showEvent(pEvent);
    171     }
    172 
    173 private:
    174 
    175     UIMachineSettingsNetworkPage *m_pSettings;
    176     CSession &m_session;
    177 };
    178 
    179 class UISharedFoldersDialog : public QIWithRetranslateUI<QDialog>
    180 {
    181     Q_OBJECT;
    182 
    183 public:
    184 
    185     UISharedFoldersDialog(QWidget *pParent, CSession &session)
    186         : QIWithRetranslateUI<QDialog>(pParent)
    187         , m_pSettings(0)
    188         , m_session(session)
    189     {
    190         /* Setup Dialog's options */
    191         setModal(true);
    192         setWindowIcon(QIcon(":/select_file_16px.png"));
    193         setSizeGripEnabled(true);
    194 
    195         /* Setup main dialog's layout */
    196         QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    197         VBoxGlobal::setLayoutMargin(pMainLayout, 10);
    198         pMainLayout->setSpacing(10);
    199 
    200         /* Setup settings layout */
    201         m_pSettings = new UIMachineSettingsSF;
    202         VBoxGlobal::setLayoutMargin(m_pSettings->layout(), 0);
    203         m_pSettings->loadDirectlyFrom(m_session.GetConsole());
    204         pMainLayout->addWidget(m_pSettings);
    205 
    206         /* Setup button's layout */
    207         QIDialogButtonBox *pButtonBox = new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
    208 
    209         connect(pButtonBox, SIGNAL(helpRequested()), &vboxProblem(), SLOT(showHelpHelpDialog()));
    210         connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
    211         connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
    212         pMainLayout->addWidget(pButtonBox);
    213 
    214         retranslateUi();
    215     }
    216 
    217 protected:
    218 
    219     void retranslateUi()
    220     {
    221         setWindowTitle(QApplication::translate("VBoxSFDialog", "Shared Folders"));
    222     }
    223 
    224 protected slots:
    225 
    226     virtual void accept()
    227     {
    228         CMachine machine = m_session.GetMachine();
    229         CConsole console = m_session.GetConsole();
    230         m_pSettings->saveDirectlyTo(console);
    231         machine.SaveSettings();
    232         if (!machine.isOk())
    233             vboxProblem().cannotSaveMachineSettings(machine);
    234         QDialog::accept();
    235     }
    236 
    237 protected:
    238 
    239     void showEvent (QShowEvent *aEvent)
    240     {
    241         resize(450, 300);
    242         VBoxGlobal::centerWidget(this, parentWidget());
    243         setMinimumWidth(400);
    244         QDialog::showEvent(aEvent);
    245     }
    246 
    247 private:
    248 
    249     UIMachineSettingsSF *m_pSettings;
    250     CSession &m_session;
    251 };
    252103
    253104UIMachineLogic* UIMachineLogic::create(QObject *pParent,
     
    474325{
    475326    /* "Machine" actions connections: */
    476     connect(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize), SIGNAL(toggled(bool)),
    477             this, SLOT(sltToggleGuestAutoresize(bool)));
    478     connect(actionsPool()->action(UIActionIndex_Simple_AdjustWindow), SIGNAL(triggered()),
    479             this, SLOT(sltAdjustWindow()));
     327    connect(actionsPool()->action(UIActionIndex_Simple_SettingsDialog), SIGNAL(triggered()),
     328            this, SLOT(sltOpenVMSettingsDialog()));
     329    connect(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot), SIGNAL(triggered()),
     330            this, SLOT(sltTakeSnapshot()));
     331    connect(actionsPool()->action(UIActionIndex_Simple_InformationDialog), SIGNAL(triggered()),
     332            this, SLOT(sltShowInformationDialog()));
    480333    connect(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration), SIGNAL(toggled(bool)),
    481334            this, SLOT(sltToggleMouseIntegration(bool)));
     
    486339            this, SLOT(sltTypeCABS()));
    487340#endif
    488     connect(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot), SIGNAL(triggered()),
    489             this, SLOT(sltTakeSnapshot()));
    490     connect(actionsPool()->action(UIActionIndex_Simple_InformationDialog), SIGNAL(triggered()),
    491             this, SLOT(sltShowInformationDialog()));
    492341    connect(actionsPool()->action(UIActionIndex_Toggle_Pause), SIGNAL(toggled(bool)),
    493342            this, SLOT(sltPause(bool)));
     
    498347    connect(actionsPool()->action(UIActionIndex_Simple_Close), SIGNAL(triggered()),
    499348            this, SLOT(sltClose()));
     349
     350    /* "View" actions connections: */
     351    connect(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize), SIGNAL(toggled(bool)),
     352            this, SLOT(sltToggleGuestAutoresize(bool)));
     353    connect(actionsPool()->action(UIActionIndex_Simple_AdjustWindow), SIGNAL(triggered()),
     354            this, SLOT(sltAdjustWindow()));
    500355
    501356    /* "Devices" actions connections: */
     
    550405
    551406    /* Move actions into running actions group: */
    552     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
    553     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Seamless));
    554     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Scale));
    555     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
    556     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
    557407    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_TypeCAD));
    558408#ifdef Q_WS_X11
     
    561411    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_Reset));
    562412    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_Shutdown));
     413    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
     414    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Seamless));
     415    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Scale));
     416    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
     417    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
    563418
    564419    /* Move actions into running-n-paused actions group: */
     420    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Simple_SettingsDialog));
     421    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
     422    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Simple_InformationDialog));
    565423    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Menu_MouseIntegration));
    566424    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
    567     m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
    568     m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Simple_InformationDialog));
    569425    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Pause));
    570426    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Menu_OpticalDevices));
     
    1088944    /* Propose to close default machine window: */
    1089945    defaultMachineWindow()->sltTryClose();
     946}
     947
     948void UIMachineLogic::sltOpenVMSettingsDialog(const QString &strCategory /* = QString() */)
     949{
     950    /* Do not process if window(s) missed! */
     951    if (!isMachineWindowsCreated())
     952        return;
     953
     954    /* Open shared session: */
     955    CSession sharedSession = vboxGlobal().openSession(session().GetMachine().GetId(), true);
     956    if (sharedSession.isNull())
     957        return;
     958
     959    /* Get machine: */
     960    CMachine sharedMachine = sharedSession.GetMachine();
     961    if (sharedMachine.isNull())
     962        return;
     963
     964    /* Prepare VM settings dialog: */
     965    UISettingsDialog *pDlg = new UISettingsDialogMachine(defaultMachineWindow()->machineWindow(),
     966                                                         VBoxDefs::SettingsDialogType_Runtime,
     967                                                         sharedMachine, session().GetConsole(),
     968                                                         strCategory, QString());
     969    pDlg->getFrom();
     970
     971    /* Show VM settings dialog: */
     972    if (pDlg->exec() == QDialog::Accepted)
     973    {
     974        /* If dialog was accepted => save changed settings: */
     975        pDlg->putBackTo();
     976        sharedMachine.SaveSettings();
     977        /* If settings were failed to be saved => show the error: */
     978        if (!sharedMachine.isOk())
     979            vboxProblem().cannotSaveMachineSettings(sharedMachine);
     980    }
     981
     982    /* Delete VM settings dialog: */
     983    delete pDlg;
     984
     985    /* Unlock machine: */
     986    sharedSession.UnlockMachine();
     987}
     988
     989void UIMachineLogic::sltOpenNetworkAdaptersDialog()
     990{
     991    /* Open VM settings : Network page: */
     992    sltOpenVMSettingsDialog("#network");
     993}
     994
     995void UIMachineLogic::sltOpenSharedFoldersDialog()
     996{
     997    /* Do not process if additions are not loaded! */
     998    if (!uisession()->isGuestAdditionsActive())
     999        vboxProblem().remindAboutGuestAdditionsAreNotActive(defaultMachineWindow()->machineWindow());
     1000
     1001    /* Open VM settings : Shared folders page: */
     1002    sltOpenVMSettingsDialog("#sfolders");
    10901003}
    10911004
     
    15141427}
    15151428
    1516 void UIMachineLogic::sltOpenNetworkAdaptersDialog()
    1517 {
    1518     /* Do not process if window(s) missed! */
    1519     if (!isMachineWindowsCreated())
    1520         return;
    1521 
    1522     /* Show network settings dialog: */
    1523     UINetworkAdaptersDialog dlg(defaultMachineWindow()->machineWindow(), session());
    1524     dlg.exec();
    1525 }
    1526 
    1527 void UIMachineLogic::sltOpenSharedFoldersDialog()
    1528 {
    1529     /* Do not process if window(s) missed! */
    1530     if (!isMachineWindowsCreated())
    1531         return;
    1532 
    1533     /* Show shared folders settings dialog: */
    1534     UISharedFoldersDialog dlg(defaultMachineWindow()->machineWindow(), session());
    1535     if (!uisession()->isGuestAdditionsActive())
    1536         vboxProblem().remindAboutGuestAdditionsAreNotActive(defaultMachineWindow()->machineWindow());
    1537     dlg.exec();
    1538 }
    1539 
    15401429void UIMachineLogic::sltSwitchVrde(bool fOn)
    15411430{
     
    17791668#endif
    17801669
    1781 #include "UIMachineLogic.moc"
    1782 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r34961 r36357  
    66
    77/*
    8  * Copyright (C) 2010 Oracle Corporation
     8 * Copyright (C) 2010-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    169169
    170170    /* "Device" menu functionality */
     171    void sltOpenVMSettingsDialog(const QString &strCategory = QString());
     172    void sltOpenNetworkAdaptersDialog();
     173    void sltOpenSharedFoldersDialog();
    171174    void sltPrepareStorageMenu();
    172175    void sltMountStorageMedium();
     
    174177    void sltPrepareUSBMenu();
    175178    void sltAttachUSBDevice();
    176     void sltOpenNetworkAdaptersDialog();
    177     void sltOpenSharedFoldersDialog();
    178179    void sltSwitchVrde(bool fOn);
    179180    void sltInstallGuestAdditions();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r36083 r36357  
    190190
    191191    /* Machine submenu: */
     192    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_SettingsDialog));
    192193    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_TakeSnapshot));
    193194    pMenu->addAction(pActionsPool->action(UIActionIndex_Simple_InformationDialog));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineShortcuts.cpp

    r36356 r36357  
    2626{
    2727    /* Defaults */
    28     m_Shortcuts[TakeSnapshotShortcut]          = UIKeySequence("TakeSnapshot",          "S");
     28    m_Shortcuts[SettingsDialogShortcut]        = UIKeySequence("SettingsDialog",        "S");
     29    m_Shortcuts[TakeSnapshotShortcut]          = UIKeySequence("TakeSnapshot",          "T");
    2930    m_Shortcuts[InformationDialogShortcut]     = UIKeySequence("InformationDialog",     "N");
    3031    m_Shortcuts[MouseIntegrationShortcut]      = UIKeySequence("MouseIntegration" ,     "I");
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineShortcuts.h

    r36356 r36357  
    2828    enum MachineShortcutType
    2929    {
     30        SettingsDialogShortcut,
    3031        TakeSnapshotShortcut,
    3132        InformationDialogShortcut,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r35761 r36357  
    982982{
    983983    m_machine = machine;
    984     if (m_machine.isNull())
    985         m_fChangeable = false;
    986     else
    987     {
    988         KMachineState state = m_machine.GetState();
    989         bool running = m_machine.GetSessionState() != KSessionState_Unlocked;
    990         m_fChangeable = !running && state != KMachineState_Saved;
    991     }
     984    m_fChangeable = m_machine.isNull() ? false : m_machine.GetState() != KMachineState_Stuck;
    992985
    993986    sltUpdateGeneral();
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r36323 r36357  
    595595    CSystemProperties props = vboxGlobal().virtualBox().GetSystemProperties();
    596596
    597     UISettingsDialog *dlg = new UISettingsDialogGlobal(this);
     597    UISettingsDialog *dlg = new UISettingsDialogGlobal(this, VBoxDefs::SettingsDialogType_Offline);
    598598    dlg->getFrom();
    599599
     
    720720    }
    721721
    722     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    723                        mVMModel->itemById(aUuid);
    724 
    725     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    726 
    727     // open a direct session to modify VM settings
    728     QString id = item->id();
    729     CSession session = vboxGlobal().openSession(id);
    730     if (session.isNull())
    731         return;
    732 
    733     CMachine m = session.GetMachine();
    734     AssertMsgReturn(!m.isNull(), ("Machine must not be null"), (void) 0);
    735 
    736     /* Don't show the inaccessible warning if the user open the vm settings. */
     722    UIVMItem *pItem = aUuid.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(aUuid);
     723    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     724
     725    bool fMachineOffline = pItem->sessionState() == KSessionState_Unlocked;
     726    VBoxDefs::SettingsDialogType dialogType = fMachineOffline ? VBoxDefs::SettingsDialogType_Offline : VBoxDefs::SettingsDialogType_Runtime;
     727
     728    CSession session = vboxGlobal().openSession(pItem->id(), !fMachineOffline /* connect to existing? */);
     729    AssertMsgReturn(!session.isNull(), ("Session must not be null"), (void)0);
     730    CMachine machine = session.GetMachine();
     731    AssertMsgReturn(!machine.isNull(), ("Machine must not be null"), (void)0);
     732    CConsole console = fMachineOffline ? CConsole() : session.GetConsole();
     733
     734    /* Don't show the inaccessible warning if the user open the vm settings: */
    737735    mDoneInaccessibleWarningOnce = true;
    738736
    739     UISettingsDialog *dlg = new UISettingsDialogMachine(this, m, strCategory, strControl);
    740     dlg->getFrom();
    741 
    742     if (dlg->exec() == QDialog::Accepted)
    743     {
    744         QString oldName = m.GetName();
    745         dlg->putBackTo();
    746 
    747         m.SaveSettings();
    748         if (!m.isOk())
    749             vboxProblem().cannotSaveMachineSettings(m);
    750 
    751         /* To check use the result in future
     737    UISettingsDialog *pDlg = new UISettingsDialogMachine(this, dialogType, machine, console, strCategory, strControl);
     738    pDlg->getFrom();
     739
     740    if (pDlg->exec() == QDialog::Accepted)
     741    {
     742        pDlg->putBackTo();
     743
     744        machine.SaveSettings();
     745        if (!machine.isOk())
     746            vboxProblem().cannotSaveMachineSettings(machine);
     747
     748        /* To check use the result in future:
    752749         * vboxProblem().cannotApplyMachineSettings(m, res); */
    753750    }
    754751
    755     delete dlg;
     752    delete pDlg;
    756753
    757754    mVMListView->setFocus();
     
    13281325        KMachineState state = item->machineState();
    13291326        bool running = item->sessionState() != KSessionState_Unlocked;
    1330         bool modifyEnabled = !running && state != KMachineState_Saved;
     1327        bool modifyEnabled = state != KMachineState_Stuck;
    13311328
    13321329        if (   aRefreshDetails
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r36323 r36357  
    4242
    4343/* Settings Dialog Constructor: */
    44 UISettingsDialog::UISettingsDialog(QWidget *pParent)
     44UISettingsDialog::UISettingsDialog(QWidget *pParent, VBoxDefs::SettingsDialogType dialogType)
    4545    /* Parent class: */
    4646    : QIWithRetranslateUI<QIMainDialog>(pParent)
     
    4949    , m_pStack(0)
    5050    /* Common variables: */
     51    , m_dialogType(dialogType)
    5152    , m_fPolished(false)
    5253    /* Loading stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r36323 r36357  
    2424#include "QIWithRetranslateUI.h"
    2525#include "UISettingsDialog.gen.h"
     26#include "VBoxDefs.h"
    2627
    2728/* Forward declarations */
     
    4142
    4243    /* Settings Dialog Constructor/Destructor: */
    43     UISettingsDialog(QWidget *pParent);
     44    UISettingsDialog(QWidget *pParent, VBoxDefs::SettingsDialogType dialogType);
    4445   ~UISettingsDialog();
    4546
     
    6465    virtual void retranslateUi();
    6566
     67    /* Dialog type: */
     68    VBoxDefs::SettingsDialogType dialogType() { return m_dialogType; }
    6669    /* Dialog title: */
    6770    virtual QString title() const = 0;
     
    107110
    108111    /* Global Flags: */
     112    VBoxDefs::SettingsDialogType m_dialogType;
    109113    bool m_fPolished;
    110114
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r36323 r36357  
    288288UISettingsSerializer* UISettingsSerializer::m_pInstance = 0;
    289289
    290 UISettingsDialogGlobal::UISettingsDialogGlobal(QWidget *pParent)
    291     : UISettingsDialog(pParent)
     290UISettingsDialogGlobal::UISettingsDialogGlobal(QWidget *pParent, VBoxDefs::SettingsDialogType type)
     291    : UISettingsDialog(pParent, type)
    292292{
    293293    /* Window icon: */
     
    371371            }
    372372            if (pSettingsPage)
     373            {
     374                pSettingsPage->setDialogType(dialogType());
    373375                pSettingsPage->setId(iPageIndex);
     376            }
    374377        }
    375378    }
     
    504507}
    505508
    506 UISettingsDialogMachine::UISettingsDialogMachine(QWidget *pParent,
    507                                                  const CMachine &machine,
    508                                                  const QString &strCategory,
    509                                                  const QString &strControl)
    510     : UISettingsDialog(pParent)
     509UISettingsDialogMachine::UISettingsDialogMachine(QWidget *pParent, VBoxDefs::SettingsDialogType type,
     510                                                 const CMachine &machine, const CConsole &console,
     511                                                 const QString &strCategory, const QString &strControl)
     512    : UISettingsDialog(pParent, type)
    511513    , m_machine(machine)
     514    , m_console(console)
    512515    , m_fAllowResetFirstRunFlag(false)
    513516    , m_fResetFirstRunFlag(false)
     
    633636            }
    634637            if (pSettingsPage)
     638            {
     639                pSettingsPage->setDialogType(dialogType());
    635640                pSettingsPage->setId(iPageIndex);
     641            }
    636642        }
    637643    }
     
    678684    /* Prepare machine data: */
    679685    qRegisterMetaType<UISettingsDataMachine>();
    680     UISettingsDataMachine data(m_machine);
     686    UISettingsDataMachine data(m_machine, m_console);
    681687    /* Create machine settings loader,
    682688     * it will load machine settings & delete itself in the appropriate time: */
     
    698704    /* Prepare machine data: */
    699705    qRegisterMetaType<UISettingsDataMachine>();
    700     UISettingsDataMachine data(m_machine);
     706    UISettingsDataMachine data(m_machine, m_console);
    701707    /* Create machine settings saver,
    702708     * it will save machine settings & delete itself in the appropriate time: */
     
    711717    /* Get updated machine: */
    712718    m_machine = pMachineSettingsSaver->data().value<UISettingsDataMachine>().m_machine;
     719    m_console = pMachineSettingsSaver->data().value<UISettingsDataMachine>().m_console;
    713720    /* If machine is ok => perform final operations: */
    714721    if (m_machine.isOk())
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h

    r36323 r36357  
    4343    };
    4444
    45     UISettingsDialogGlobal(QWidget *pParent);
     45    UISettingsDialogGlobal(QWidget *pParent, VBoxDefs::SettingsDialogType type);
    4646
    4747protected:
     
    8282    };
    8383
    84     UISettingsDialogMachine(QWidget *pParent, const CMachine &machine,
     84    UISettingsDialogMachine(QWidget *pParent, VBoxDefs::SettingsDialogType type,
     85                            const CMachine &machine, const CConsole &console,
    8586                            const QString &strCategory, const QString &strControl);
    8687
     
    108109
    109110    CMachine m_machine;
     111    CConsole m_console;
    110112    bool m_fAllowResetFirstRunFlag;
    111113    bool m_fResetFirstRunFlag;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.cpp

    r36324 r36357  
    2424UISettingsPage::UISettingsPage(UISettingsPageType pageType)
    2525    : m_pageType(pageType)
     26    , m_dialogType(VBoxDefs::SettingsDialogType_Wrong)
    2627    , m_cId(-1)
     28    , m_fPolished(false)
    2729    , m_fProcessed(false)
    2830    , m_fFailed(false)
    2931    , m_pFirstWidget(0)
    3032{
     33}
     34
     35void UISettingsPage::showEvent(QShowEvent *pEvent)
     36{
     37    /* Polish page if necessary: */
     38    if (!m_fPolished)
     39    {
     40        m_fPolished = true;
     41        polishPage();
     42    }
     43    /* Call for base-class: */
     44    QIWithRetranslateUI<QWidget>::showEvent(pEvent);
    3145}
    3246
     
    5670}
    5771
    58 /* Fetch data to m_machine: */
     72/* Fetch data to m_machine & m_console: */
    5973void UISettingsPageMachine::fetchData(const QVariant &data)
    6074{
    6175    m_machine = data.value<UISettingsDataMachine>().m_machine;
     76    m_console = data.value<UISettingsDataMachine>().m_console;
    6277}
    6378
    64 /* Upload m_machine to data: */
     79/* Upload m_machine & m_console to data: */
    6580void UISettingsPageMachine::uploadData(QVariant &data) const
    6681{
    67     data = QVariant::fromValue(UISettingsDataMachine(m_machine));
     82    data = QVariant::fromValue(UISettingsDataMachine(m_machine, m_console));
    6883}
    6984
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h

    r36324 r36357  
    2727#include "QIWithRetranslateUI.h"
    2828#include "COMDefs.h"
     29#include "VBoxDefs.h"
    2930#include "VBoxGlobalSettings.h"
    3031
    3132/* Forward declarations */
    3233class QIWidgetValidator;
     34class QShowEvent;
    3335
    3436/* Settings page types: */
     
    5456{
    5557    UISettingsDataMachine() {}
    56     UISettingsDataMachine(const CMachine &machine)
    57         : m_machine(machine) {}
     58    UISettingsDataMachine(const CMachine &machine, const CConsole &console)
     59        : m_machine(machine), m_console(console) {}
    5860    CMachine m_machine;
     61    CConsole m_console;
    5962};
    6063Q_DECLARE_METATYPE(UISettingsDataMachine);
     
    9295    UISettingsPageType pageType() const { return m_pageType; }
    9396
     97    /* Settings dialog type stuff: */
     98    VBoxDefs::SettingsDialogType dialogType() const { return m_dialogType; }
     99    virtual void setDialogType(VBoxDefs::SettingsDialogType dialogType) { m_dialogType = dialogType; }
     100
    94101    /* Page 'ID' stuff: */
    95102    int id() const { return m_cId; }
     
    109116    UISettingsPage(UISettingsPageType type);
    110117
     118    /* Show event: */
     119    void showEvent(QShowEvent *pEvent);
     120
     121    /* Virtual function to polish page content: */
     122    virtual void polishPage() {}
     123
    111124private:
    112125
    113126    /* Private variables: */
    114127    UISettingsPageType m_pageType;
     128    VBoxDefs::SettingsDialogType m_dialogType;
    115129    int m_cId;
     130    bool m_fPolished;
    116131    bool m_fProcessed;
    117132    bool m_fFailed;
     
    158173    /* Machine data source: */
    159174    CMachine m_machine;
     175    CConsole m_console;
    160176};
    161177
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

    r33882 r36357  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7373    UISettingsPageMachine::fetchData(data);
    7474
    75     /* Gather corresponding values from internal variables: */
    76     CAudioAdapter audio = m_machine.GetAudioAdapter();
    77     audio.SetEnabled(m_cache.m_fAudioEnabled);
    78     audio.SetAudioDriver(m_cache.m_audioDriverType);
    79     audio.SetAudioController(m_cache.m_audioControllerType);
     75    /* Save settings depending on dialog type: */
     76    switch (dialogType())
     77    {
     78        /* Here come the properties which could be changed only in offline state: */
     79        case VBoxDefs::SettingsDialogType_Offline:
     80        {
     81            CAudioAdapter audio = m_machine.GetAudioAdapter();
     82            audio.SetEnabled(m_cache.m_fAudioEnabled);
     83            audio.SetAudioDriver(m_cache.m_audioDriverType);
     84            audio.SetAudioController(m_cache.m_audioControllerType);
     85            break;
     86        }
     87        /* Here come the properties which could be changed at runtime too: */
     88        case VBoxDefs::SettingsDialogType_Runtime:
     89            break;
     90        default:
     91            break;
     92    }
    8093
    8194    /* Upload machine to data: */
     
    150163}
    151164
     165void UIMachineSettingsAudio::polishPage()
     166{
     167    /* Polish page depending on dialog type: */
     168    switch (dialogType())
     169    {
     170        case VBoxDefs::SettingsDialogType_Offline:
     171            break;
     172        case VBoxDefs::SettingsDialogType_Runtime:
     173            mGbAudio->setEnabled(false);
     174            mLbAudioDriver->setEnabled(false);
     175            mCbAudioDriver->setEnabled(false);
     176            mLbAudioController->setEnabled(false);
     177            mCbAudioController->setEnabled(false);
     178            break;
     179        default:
     180            break;
     181    }
     182}
     183
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6666    void prepareComboboxes();
    6767
     68    void polishPage();
     69
    6870    /* Cache: */
    6971    UISettingsCacheMachineAudio m_cache;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r34860 r36357  
    77
    88/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     9 * Copyright (C) 2008-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    232232    UISettingsPageMachine::fetchData(data);
    233233
    234     /* Gather corresponding values from internal variables: */
    235     m_machine.SetVRAMSize(m_cache.m_iCurrentVRAM);
    236     m_machine.SetMonitorCount(m_cache.m_cMonitorCount);
    237     m_machine.SetAccelerate3DEnabled(m_cache.m_f3dAccelerationEnabled);
    238 #ifdef VBOX_WITH_VIDEOHWACCEL
    239     m_machine.SetAccelerate2DVideoEnabled(m_cache.m_f2dAccelerationEnabled);
    240 #endif
    241     CVRDEServer vrdeServer = m_machine.GetVRDEServer();
    242     if (!vrdeServer.isNull())
    243     {
    244         vrdeServer.SetEnabled(m_cache.m_fVRDEServerEnabled);
    245         vrdeServer.SetVRDEProperty("TCP/Ports", m_cache.m_strVRDEPort);
    246         vrdeServer.SetAuthType(m_cache.m_iVRDEAuthType);
    247         vrdeServer.SetAuthTimeout(m_cache.m_uVRDETimeout);
    248         vrdeServer.SetAllowMultiConnection(m_cache.m_fMultipleConnectionsAllowed);
     234    /* Save settings depending on dialog type: */
     235    switch (dialogType())
     236    {
     237        /* Here come the properties which could be changed only in offline state: */
     238        case VBoxDefs::SettingsDialogType_Offline:
     239        {
     240            /* Video tab: */
     241            m_machine.SetVRAMSize(m_cache.m_iCurrentVRAM);
     242            m_machine.SetMonitorCount(m_cache.m_cMonitorCount);
     243            m_machine.SetAccelerate3DEnabled(m_cache.m_f3dAccelerationEnabled);
     244#ifdef VBOX_WITH_VIDEOHWACCEL
     245            m_machine.SetAccelerate2DVideoEnabled(m_cache.m_f2dAccelerationEnabled);
     246#endif /* VBOX_WITH_VIDEOHWACCEL */
     247            /* After that come the properties which could be changed at runtime too: */
     248        }
     249        /* Here come the properties which could be changed at runtime too: */
     250        case VBoxDefs::SettingsDialogType_Runtime:
     251        {
     252            /* VRDE tab: */
     253            CVRDEServer vrdeServer = m_machine.GetVRDEServer();
     254            if (!vrdeServer.isNull())
     255            {
     256                vrdeServer.SetEnabled(m_cache.m_fVRDEServerEnabled);
     257                vrdeServer.SetVRDEProperty("TCP/Ports", m_cache.m_strVRDEPort);
     258                vrdeServer.SetAuthType(m_cache.m_iVRDEAuthType);
     259                vrdeServer.SetAuthTimeout(m_cache.m_uVRDETimeout);
     260                vrdeServer.SetAllowMultiConnection(m_cache.m_fMultipleConnectionsAllowed);
     261            }
     262            break;
     263        }
     264        default:
     265            break;
    249266    }
    250267
     
    417434}
    418435
     436void UIMachineSettingsDisplay::polishPage()
     437{
     438    /* Polish page depending on dialog type: */
     439    switch (dialogType())
     440    {
     441        case VBoxDefs::SettingsDialogType_Offline:
     442            break;
     443        case VBoxDefs::SettingsDialogType_Runtime:
     444            /* Video tab: */
     445            mLbMemory->setEnabled(false);
     446            mLbMemoryMin->setEnabled(false);
     447            mLbMemoryMax->setEnabled(false);
     448            mLbMemoryUnit->setEnabled(false);
     449            mSlMemory->setEnabled(false);
     450            mLeMemory->setEnabled(false);
     451            mLbMonitors->setEnabled(false);
     452            mLbMonitorsMin->setEnabled(false);
     453            mLbMonitorsMax->setEnabled(false);
     454            mLbMonitorsUnit->setEnabled(false);
     455            mSlMonitors->setEnabled(false);
     456            mLeMonitors->setEnabled(false);
     457            mLbOptions->setEnabled(false);
     458            mCb3D->setEnabled(false);
     459#ifdef VBOX_WITH_VIDEOHWACCEL
     460            mCb2DVideo->setEnabled(false);
     461#endif /* VBOX_WITH_VIDEOHWACCEL */
     462            break;
     463        default:
     464            break;
     465    }
     466}
     467
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2008-2010 Oracle Corporation
     8 * Copyright (C) 2008-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9191    void checkVRAMRequirements();
    9292
     93    void polishPage();
     94
    9395    QIWidgetValidator *mValidator;
    9496
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r36229 r36357  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    136136    UISettingsPageMachine::fetchData(data);
    137137
    138     /* Gather corresponding values from internal variables: */
    139     m_machine.SetOSTypeId(m_cache.m_strGuestOsTypeId);
    140     m_machine.SetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime, m_cache.m_fSaveMountedAtRuntime ? "yes" : "no");
    141     m_machine.SetExtraData(VBoxDefs::GUI_ShowMiniToolBar, m_cache.m_fShowMiniToolBar ? "yes" : "no");
    142     m_machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAlignment, m_cache.m_fMiniToolBarAtTop ? "top" : "bottom");
    143     m_machine.SetSnapshotFolder(m_cache.m_strSnapshotsFolder);
    144     m_machine.SetClipboardMode(m_cache.m_clipboardMode);
    145     m_machine.SetDescription(m_cache.m_strDescription);
    146     /* Must be last as otherwise its VM rename magic can collide with other
    147      * settings in the config, especially with the snapshot folder. */
    148     m_machine.SetName(m_cache.m_strName);
     138    /* Save settings depending on dialog type: */
     139    switch (dialogType())
     140    {
     141        /* Here come the properties which could be changed only in offline state: */
     142        case VBoxDefs::SettingsDialogType_Offline:
     143        {
     144            /* Basic tab: */
     145            m_machine.SetOSTypeId(m_cache.m_strGuestOsTypeId);
     146            /* Advanced tab: */
     147            m_machine.SetSnapshotFolder(m_cache.m_strSnapshotsFolder);
     148            m_machine.SetClipboardMode(m_cache.m_clipboardMode);
     149            m_machine.SetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime, m_cache.m_fSaveMountedAtRuntime ? "yes" : "no");
     150            m_machine.SetExtraData(VBoxDefs::GUI_ShowMiniToolBar, m_cache.m_fShowMiniToolBar ? "yes" : "no");
     151            m_machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAlignment, m_cache.m_fMiniToolBarAtTop ? "top" : "bottom");
     152            /* Description tab: */
     153            m_machine.SetDescription(m_cache.m_strDescription);
     154            /* VM name must be last as otherwise its VM rename magic can collide with other settings in the config,
     155             * especially with the snapshot folder: */
     156            m_machine.SetName(m_cache.m_strName);
     157            break;
     158        }
     159        /* Here come the properties which could be changed at runtime too: */
     160        case VBoxDefs::SettingsDialogType_Runtime:
     161        {
     162            /* Advanced tab: */
     163            m_machine.SetClipboardMode(m_cache.m_clipboardMode);
     164            m_machine.SetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime, m_cache.m_fSaveMountedAtRuntime ? "yes" : "no");
     165            m_machine.SetExtraData(VBoxDefs::GUI_ShowMiniToolBar, m_cache.m_fShowMiniToolBar ? "yes" : "no");
     166            m_machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAlignment, m_cache.m_fMiniToolBarAtTop ? "top" : "bottom");
     167            /* Description tab: */
     168            m_machine.SetDescription(m_cache.m_strDescription);
     169            break;
     170        }
     171        default:
     172            break;
     173    }
    149174
    150175    /* Upload machine to data: */
     
    194219}
    195220
     221void UIMachineSettingsGeneral::polishPage()
     222{
     223    /* Polish page depending on dialog type: */
     224    switch (dialogType())
     225    {
     226        case VBoxDefs::SettingsDialogType_Offline:
     227            break;
     228        case VBoxDefs::SettingsDialogType_Runtime:
     229            /* Basic tab: */
     230            mLbName->setEnabled(false);
     231            mLeName->setEnabled(false);
     232            mOSTypeSelector->setEnabled(false);
     233            /* Advanced tab: */
     234            mLbSnapshot->setEnabled(false);
     235            mPsSnapshot->setEnabled(false);
     236            break;
     237        default:
     238            break;
     239    }
     240}
     241
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r35476 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8282private:
    8383
     84    void polishPage();
     85
    8486    QIWidgetValidator *mValidator;
    8587
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r36324 r36357  
    4343    , m_iSlot(-1)
    4444    , m_fPolished(false)
    45     , m_fDisableStaticControls(fDisableStaticControls)
    4645{
    4746    /* Apply UI decorations: */
     
    6261}
    6362
     63void UIMachineSettingsNetwork::polishTab()
     64{
     65    /* Polish tab depending on dialog type: */
     66    switch (m_pParent->dialogType())
     67    {
     68        case VBoxDefs::SettingsDialogType_Offline:
     69            sltToggleAdvanced();
     70            break;
     71        case VBoxDefs::SettingsDialogType_Runtime:
     72            mCbEnableAdapter->setEnabled(false);
     73            m_pAdapterTypeLabel->setEnabled(false);
     74            m_pAdapterTypeCombo->setEnabled(false);
     75            m_pMACLabel->setEnabled(false);
     76            m_pMACEditor->setEnabled(false);
     77            m_pMACButton->setEnabled(false);
     78            m_pAdvancedArrow->animateClick();
     79            break;
     80        default:
     81            break;
     82    }
     83}
     84
    6485void UIMachineSettingsNetwork::fetchAdapterData(const UINetworkAdapterData &data)
    6586{
     
    166187    m_pValidator = pValidator;
    167188
    168     if (!m_fDisableStaticControls)
    169         connect(mCbEnableAdapter, SIGNAL(toggled(bool)), m_pValidator, SLOT(revalidate()));
     189    connect(mCbEnableAdapter, SIGNAL(toggled(bool)), m_pValidator, SLOT(revalidate()));
    170190    connect(m_pAttachmentTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(sltUpdateAttachmentAlternative()));
    171191    connect(m_pAdapterNameCombo, SIGNAL(activated(const QString&)), this, SLOT(sltUpdateAlternativeName()));
    172192    connect(m_pAdapterNameCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(sltUpdateAlternativeName()));
    173193
    174     if (!m_fDisableStaticControls)
    175         m_pValidator->revalidate();
     194    m_pValidator->revalidate();
    176195}
    177196
     
    271290void UIMachineSettingsNetwork::showEvent(QShowEvent *pEvent)
    272291{
     292    /* Polish page if necessary: */
    273293    if (!m_fPolished)
    274294    {
    275295        m_fPolished = true;
    276 
    277296        /* Give the minimum size hint to the first layout column: */
    278297        m_pNetworkChildGridLayout->setColumnMinimumWidth (0, m_pAttachmentTypeLabel->width());
    279 
    280         if (m_fDisableStaticControls)
    281         {
    282             /* Disable controls for dynamically displayed page: */
    283             mCbEnableAdapter->setEnabled(false);
    284             m_pAdapterTypeCombo->setEnabled(false);
    285             m_pPromiscuousModeCombo->setEnabled(false);
    286             m_pMACEditor->setEnabled(false);
    287             m_pMACButton->setEnabled(false);
    288             m_pAdapterTypeLabel->setEnabled(false);
    289             m_pPromiscuousModeLabel->setEnabled(false);
    290             m_pMACLabel->setEnabled(false);
    291             m_pAdvancedArrow->animateClick();
    292         }
    293         else
    294         {
    295             /* Hide advanced items initially: */
    296             sltToggleAdvanced();
    297         }
    298     }
     298    }
     299    /* Call for base-class: */
    299300    QWidget::showEvent(pEvent);
    300301}
     
    318319
    319320    /* Update alternative-name combo-box availability: */
     321    m_pAdapterNameLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     322                                    attachmentType() != KNetworkAttachmentType_NAT);
    320323    m_pAdapterNameCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    321324                                    attachmentType() != KNetworkAttachmentType_NAT);
     325    m_pPromiscuousModeLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     326                                        attachmentType() != KNetworkAttachmentType_NAT);
    322327    m_pPromiscuousModeCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    323328                                        attachmentType() != KNetworkAttachmentType_NAT);
     
    616621
    617622/* UIMachineSettingsNetworkPage Stuff */
    618 UIMachineSettingsNetworkPage::UIMachineSettingsNetworkPage(bool fDisableStaticControls)
     623UIMachineSettingsNetworkPage::UIMachineSettingsNetworkPage()
    619624    : m_pValidator(0)
    620625    , m_pTwAdapters(0)
    621     , m_fDisableStaticControls(fDisableStaticControls)
    622626{
    623627    /* Setup main layout: */
     
    635639    {
    636640        /* Creating adapter's page: */
    637         UIMachineSettingsNetwork *pPage = new UIMachineSettingsNetwork(this, m_fDisableStaticControls);
     641        UIMachineSettingsNetwork *pPage = new UIMachineSettingsNetwork(this);
    638642        /* Attach adapter's page to Tab Widget: */
    639643        m_pTwAdapters->addTab(pPage, pPage->pageTitle());
    640644    }
    641 }
    642 
    643 void UIMachineSettingsNetworkPage::loadDirectlyFrom(const CMachine &machine)
    644 {
    645     qRegisterMetaType<UISettingsDataMachine>();
    646     UISettingsDataMachine data(machine);
    647     QVariant wrapper = QVariant::fromValue(data);
    648     loadToCacheFrom(wrapper);
    649     getFromCache();
    650 }
    651 
    652 void UIMachineSettingsNetworkPage::saveDirectlyTo(CMachine &machine)
    653 {
    654     qRegisterMetaType<UISettingsDataMachine>();
    655     UISettingsDataMachine data(machine);
    656     QVariant wrapper = QVariant::fromValue(data);
    657     putToCache();
    658     saveFromCacheTo(wrapper);
    659645}
    660646
     
    836822        pPage->fetchAdapterData(m_cache.m_items[iSlot]);
    837823
    838         /* Disable tab page of disabled adapter if it is being configured dynamically: */
    839         if (m_fDisableStaticControls && !m_cache.m_items[iSlot].m_fAdapterEnabled)
    840             m_pTwAdapters->setTabEnabled(iSlot, false);
    841 
    842824        /* Setup page validation: */
    843825        pPage->setValidator(m_pValidator);
     
    885867        const UINetworkAdapterData &data = m_cache.m_items[iSlot];
    886868
    887         /* Save main options: */
    888         adapter.SetEnabled(data.m_fAdapterEnabled);
    889         switch (data.m_attachmentType)
    890         {
    891             case KNetworkAttachmentType_Null:
    892                 adapter.Detach();
    893                 break;
    894             case KNetworkAttachmentType_NAT:
    895                 adapter.AttachToNAT();
    896                 break;
    897             case KNetworkAttachmentType_Bridged:
    898                 adapter.SetHostInterface(data.m_strBridgedAdapterName);
    899                 adapter.AttachToBridgedInterface();
    900                 break;
    901             case KNetworkAttachmentType_Internal:
    902                 adapter.SetInternalNetwork(data.m_strInternalNetworkName);
    903                 adapter.AttachToInternalNetwork();
    904                 break;
    905             case KNetworkAttachmentType_HostOnly:
    906                 adapter.SetHostInterface(data.m_strHostInterfaceName);
    907                 adapter.AttachToHostOnlyInterface();
    908                 break;
     869        /* Save settings depending on dialog type: */
     870        switch (dialogType())
     871        {
     872            /* Here come the properties which could be changed only in offline state: */
     873            case VBoxDefs::SettingsDialogType_Offline:
     874            {
     875                /* Basic attributes: */
     876                adapter.SetEnabled(data.m_fAdapterEnabled);
     877                adapter.SetAdapterType(data.m_adapterType);
     878                adapter.SetMACAddress(data.m_strMACAddress);
     879                /* After that come the properties which could be changed at runtime too: */
     880            }
     881            /* Here come the properties which could be changed at runtime too: */
     882            case VBoxDefs::SettingsDialogType_Runtime:
     883            {
     884                /* Attachment type: */
     885                switch (data.m_attachmentType)
     886                {
     887                    case KNetworkAttachmentType_Null:
     888                        adapter.Detach();
     889                        break;
     890                    case KNetworkAttachmentType_NAT:
     891                        adapter.AttachToNAT();
     892                        break;
     893                    case KNetworkAttachmentType_Bridged:
     894                        adapter.SetHostInterface(data.m_strBridgedAdapterName);
     895                        adapter.AttachToBridgedInterface();
     896                        break;
     897                    case KNetworkAttachmentType_Internal:
     898                        adapter.SetInternalNetwork(data.m_strInternalNetworkName);
     899                        adapter.AttachToInternalNetwork();
     900                        break;
     901                    case KNetworkAttachmentType_HostOnly:
     902                        adapter.SetHostInterface(data.m_strHostInterfaceName);
     903                        adapter.AttachToHostOnlyInterface();
     904                        break;
    909905#ifdef VBOX_WITH_VDE
    910             case KNetworkAttachmentType_VDE:
    911                 adapter.SetVDENetwork(data.m_strVDENetworkName);
    912                 adapter.AttachToVDE();
    913                 break;
     906                    case KNetworkAttachmentType_VDE:
     907                        adapter.SetVDENetwork(data.m_strVDENetworkName);
     908                        adapter.AttachToVDE();
     909                        break;
    914910#endif /* VBOX_WITH_VDE */
     911                    default:
     912                        break;
     913                }
     914                /* Advanced attributes: */
     915                adapter.SetPromiscModePolicy(data.m_promiscuousMode);
     916                /* Cable connected flag: */
     917                adapter.SetCableConnected(data.m_fCableConnected);
     918                /* Redirect options: */
     919                QVector<QString> oldRedirects = adapter.GetNatDriver().GetRedirects();
     920                for (int i = 0; i < oldRedirects.size(); ++i)
     921                    adapter.GetNatDriver().RemoveRedirect(oldRedirects[i].section(',', 0, 0));
     922                UIPortForwardingDataList newRedirects = data.m_redirects;
     923                for (int i = 0; i < newRedirects.size(); ++i)
     924                {
     925                    UIPortForwardingData newRedirect = newRedirects[i];
     926                    adapter.GetNatDriver().AddRedirect(newRedirect.name, newRedirect.protocol,
     927                                                       newRedirect.hostIp, newRedirect.hostPort.value(),
     928                                                       newRedirect.guestIp, newRedirect.guestPort.value());
     929                }
     930                break;
     931            }
    915932            default:
    916933                break;
    917         }
    918 
    919         /* Save advanced options: */
    920         adapter.SetAdapterType(data.m_adapterType);
    921         adapter.SetPromiscModePolicy(data.m_promiscuousMode);
    922         adapter.SetMACAddress(data.m_strMACAddress);
    923         adapter.SetCableConnected(data.m_fCableConnected);
    924 
    925         /* Save redirect options: */
    926         QVector<QString> oldRedirects = adapter.GetNatDriver().GetRedirects();
    927         for (int i = 0; i < oldRedirects.size(); ++i)
    928             adapter.GetNatDriver().RemoveRedirect(oldRedirects[i].section(',', 0, 0));
    929         UIPortForwardingDataList newRedirects = data.m_redirects;
    930         for (int i = 0; i < newRedirects.size(); ++i)
    931         {
    932             UIPortForwardingData newRedirect = newRedirects[i];
    933             adapter.GetNatDriver().AddRedirect(newRedirect.name, newRedirect.protocol,
    934                                                newRedirect.hostIp, newRedirect.hostPort.value(),
    935                                                newRedirect.guestIp, newRedirect.guestPort.value());
    936934        }
    937935    }
     
    985983    }
    986984}
     985
     986void UIMachineSettingsNetworkPage::polishPage()
     987{
     988    /* Get the count of network adapter tabs: */
     989    int iCount = qMin(m_pTwAdapters->count(), m_cache.m_items.size());
     990    for (int iSlot = 0; iSlot < iCount; ++iSlot)
     991    {
     992        /* Polish iterated tab depending on dialog type: */
     993        switch (dialogType())
     994        {
     995            case VBoxDefs::SettingsDialogType_Offline:
     996                break;
     997            case VBoxDefs::SettingsDialogType_Runtime:
     998            {
     999                if (!m_cache.m_items[iSlot].m_fAdapterEnabled)
     1000                    m_pTwAdapters->setTabEnabled(iSlot, false);
     1001                break;
     1002            }
     1003            default:
     1004                break;
     1005        }
     1006        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTwAdapters->widget(iSlot));
     1007        Assert(pTab);
     1008        pTab->polishTab();
     1009    }
     1010}
     1011
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r36104 r36357  
    6767    UIMachineSettingsNetwork(UIMachineSettingsNetworkPage *pParent, bool fDisableStaticControls = false);
    6868
     69    void polishTab();
     70
    6971    void fetchAdapterData(const UINetworkAdapterData &data);
    7072    void uploadAdapterData(UINetworkAdapterData &data);
     
    111113
    112114    bool m_fPolished;
    113     bool m_fDisableStaticControls;
    114115    UIPortForwardingDataList m_portForwardingRules;
    115116};
     
    122123public:
    123124
    124     UIMachineSettingsNetworkPage(bool fDisableStaticControls = false);
    125 
    126     void loadDirectlyFrom(const CMachine &machine);
    127     void saveDirectlyTo(CMachine &machine);
     125    UIMachineSettingsNetworkPage();
    128126
    129127    QStringList brgList(bool aRefresh = false);
     
    159157private:
    160158
     159    void polishPage();
     160
    161161    QIWidgetValidator *m_pValidator;
    162162    QITabWidget *m_pTwAdapters;
     
    166166    QStringList m_hoiList;
    167167
    168     bool m_fDisableStaticControls;
    169 
    170168    /* Cache: */
    171169    UISettingsCacheMachineNetwork m_cache;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp

    r36324 r36357  
    2626
    2727/* UIMachineSettingsParallel stuff */
    28 UIMachineSettingsParallel::UIMachineSettingsParallel()
     28UIMachineSettingsParallel::UIMachineSettingsParallel(UIMachineSettingsParallelPage *pParent)
    2929    : QIWithRetranslateUI<QWidget> (0)
     30    , m_pParent(pParent)
    3031    , mValidator(0)
    3132    , m_iSlot(-1)
     
    5657    /* Applying language settings */
    5758    retranslateUi();
     59}
     60
     61void UIMachineSettingsParallel::polishTab()
     62{
     63    /* Polish tab depending on dialog type: */
     64    switch (m_pParent->dialogType())
     65    {
     66        case VBoxDefs::SettingsDialogType_Offline:
     67            break;
     68        case VBoxDefs::SettingsDialogType_Runtime:
     69            mGbParallel->setEnabled(false);
     70            mLbNumber->setEnabled(false);
     71            mCbNumber->setEnabled(false);
     72            mLbIRQ->setEnabled(false);
     73            mLeIRQ->setEnabled(false);
     74            mLbIOPort->setEnabled(false);
     75            mLeIOPort->setEnabled(false);
     76            mLbPath->setEnabled(false);
     77            mLePath->setEnabled(false);
     78            break;
     79        default:
     80            break;
     81    }
    5882}
    5983
     
    204228    {
    205229        /* Creating port's page: */
    206         UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel;
     230        UIMachineSettingsParallel *pPage = new UIMachineSettingsParallel(this);
    207231
    208232        /* Loading port's data into page: */
     
    248272    UISettingsPageMachine::fetchData(data);
    249273
    250     /* Gather corresponding values from internal variables: */
    251     for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
    252     {
    253         /* Get adapter: */
    254         CParallelPort port = m_machine.GetParallelPort(iSlot);
    255 
    256         /* Get cached data for this slot: */
    257         const UIParallelPortData &data = m_cache.m_items[iSlot];
    258 
    259         /* Save options: */
    260         port.SetIRQ(data.m_uIRQ);
    261         port.SetIOBase(data.m_uIOBase);
    262         port.SetPath(data.m_strPath);
    263         port.SetEnabled(data.m_fPortEnabled);
     274    /* Save settings depending on dialog type: */
     275    switch (dialogType())
     276    {
     277        /* Here come the properties which could be changed only in offline state: */
     278        case VBoxDefs::SettingsDialogType_Offline:
     279        {
     280            /* Gather corresponding values from internal variables: */
     281            for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
     282            {
     283                /* Get adapter: */
     284                CParallelPort port = m_machine.GetParallelPort(iSlot);
     285
     286                /* Get cached data for this slot: */
     287                const UIParallelPortData &data = m_cache.m_items[iSlot];
     288
     289                /* Save options: */
     290                port.SetIRQ(data.m_uIRQ);
     291                port.SetIOBase(data.m_uIOBase);
     292                port.SetPath(data.m_strPath);
     293                port.SetEnabled(data.m_fPortEnabled);
     294            }
     295            break;
     296        }
     297        /* Here come the properties which could be changed at runtime too: */
     298        case VBoxDefs::SettingsDialogType_Runtime:
     299            break;
     300        default:
     301            break;
    264302    }
    265303
     
    332370}
    333371
     372void UIMachineSettingsParallelPage::polishPage()
     373{
     374    /* Get the count of parallel port tabs: */
     375    for (int iTabIndex = 0; iTabIndex < mTabWidget->count(); ++iTabIndex)
     376    {
     377        /* Polish iterated tab depending on dialog type: */
     378        switch (dialogType())
     379        {
     380            case VBoxDefs::SettingsDialogType_Offline:
     381                break;
     382            case VBoxDefs::SettingsDialogType_Runtime:
     383            {
     384                if (!m_cache.m_items[iTabIndex].m_fPortEnabled)
     385                    mTabWidget->setTabEnabled(iTabIndex, false);
     386                break;
     387            }
     388            default:
     389                break;
     390        }
     391        UIMachineSettingsParallel *pTab = qobject_cast<UIMachineSettingsParallel*>(mTabWidget->widget(iTabIndex));
     392        Assert(pTab);
     393        pTab->polishTab();
     394    }
     395}
     396
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#include "COMDefs.h"
    2525
     26/* Forward declarations */
     27class UIMachineSettingsParallelPage;
    2628class QITabWidget;
    2729
     
    4850public:
    4951
    50     UIMachineSettingsParallel();
     52    UIMachineSettingsParallel(UIMachineSettingsParallelPage *pParent);
     53
     54    void polishTab();
    5155
    5256    void fetchPortData(const UIParallelPortData &data);
     
    7175private:
    7276
     77    UIMachineSettingsParallelPage *m_pParent;
    7378    QIWidgetValidator *mValidator;
    7479    int m_iSlot;
     
    107112private:
    108113
     114    void polishPage();
     115
    109116    QIWidgetValidator *mValidator;
    110117    QITabWidget *mTabWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp

    r35475 r36357  
    77
    88/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     9 * Copyright (C) 2008-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    166166
    167167UIMachineSettingsSF::UIMachineSettingsSF()
    168     : m_type(WrongType)
     168    : m_type(MachineType)
    169169    , mNewAction(0), mEdtAction(0), mDelAction(0)
    170170    , mIsListViewChanged(false)
     
    212212}
    213213
    214 void UIMachineSettingsSF::loadDirectlyFrom(const CConsole &console)
    215 {
    216     loadToCacheFromMachine(console.GetMachine());
    217     loadToCacheFromConsole(console);
    218     getFromCache();
    219 }
    220 
    221 void UIMachineSettingsSF::saveDirectlyTo(CConsole &console)
    222 {
    223     putToCache();
    224     saveFromCacheToConsole(console);
    225     CMachine machine = console.GetMachine();
    226     saveFromCacheToMachine(machine);
    227 }
    228 
    229214void UIMachineSettingsSF::resizeEvent (QResizeEvent *aEvent)
    230215{
     
    241226
    242227    /* Fill internal variables with corresponding values: */
    243     loadToCacheFromMachine(m_machine);
     228    if (!m_machine.isNull())
     229        loadToCacheFromMachine();
     230    if (!m_console.isNull())
     231        loadToCacheFromConsole();
    244232
    245233    /* Upload machine to data: */
     
    247235}
    248236
    249 void UIMachineSettingsSF::loadToCacheFromMachine(const CMachine &machine)
    250 {
    251     /* Update dialog type: */
    252     if (m_type == WrongType)
    253         m_type = MachineType;
     237void UIMachineSettingsSF::loadToCacheFromMachine()
     238{
    254239    /* Load machine items into internal cache: */
    255     loadToCacheFromVector(machine.GetSharedFolders(), MachineType);
    256 }
    257 
    258 void UIMachineSettingsSF::loadToCacheFromConsole(const CConsole &console)
    259 {
    260     /* Update dialog type: */
    261     if (m_type == WrongType || m_type == MachineType)
    262         m_type = ConsoleType;
     240    loadToCacheFromVector(m_machine.GetSharedFolders(), MachineType);
     241}
     242
     243void UIMachineSettingsSF::loadToCacheFromConsole()
     244{
    263245    /* Load console items into internal cache: */
    264     loadToCacheFromVector(console.GetSharedFolders(), ConsoleType);
     246    loadToCacheFromVector(m_console.GetSharedFolders(), ConsoleType);
    265247}
    266248
     
    324306        SFTreeViewItem *pFolderTypeRoot = static_cast<SFTreeViewItem*>(pMainRootItem->child(iFodlersTypeIndex));
    325307        UISharedFolderType type = (UISharedFolderType)pFolderTypeRoot->text(1).toInt();
    326         AssertMsg(type != WrongType, ("Incorrent folders type!"));
    327308        /* Iterate other all the folder items: */
    328309        for (int iFoldersIndex = 0; iFoldersIndex < pFolderTypeRoot->childCount(); ++iFoldersIndex)
     
    348329
    349330    /* Gather corresponding values from internal variables: */
    350     saveFromCacheToMachine(m_machine);
     331    if (!m_machine.isNull())
     332        saveFromCacheToMachine();
     333    if (!m_console.isNull())
     334        saveFromCacheToConsole();
    351335
    352336    /* Upload machine to data: */
     
    354338}
    355339
    356 void UIMachineSettingsSF::saveFromCacheToMachine(CMachine &machine)
     340void UIMachineSettingsSF::saveFromCacheToMachine()
    357341{
    358342    /* Check if items were NOT changed: */
     
    361345
    362346    /* Delete all machine folders first: */
    363     const CSharedFolderVector &folders = machine.GetSharedFolders();
     347    const CSharedFolderVector &folders = m_machine.GetSharedFolders();
    364348    for (int iFolderIndex = 0; iFolderIndex < folders.size() && !failed(); ++iFolderIndex)
    365349    {
     
    367351        QString strFolderName = folder.GetName();
    368352        QString strFolderPath = folder.GetHostPath();
    369         machine.RemoveSharedFolder(strFolderName);
    370         if (!machine.isOk())
     353        m_machine.RemoveSharedFolder(strFolderName);
     354        if (!m_machine.isOk())
    371355        {
    372356            /* Mark the page as failed: */
    373357            setFailed(true);
    374358            /* Show error message: */
    375             vboxProblem().cannotRemoveSharedFolder(machine, strFolderName, strFolderPath);
     359            vboxProblem().cannotRemoveSharedFolder(m_machine, strFolderName, strFolderPath);
    376360        }
    377361    }
     
    383367        if (data.m_type == MachineType)
    384368        {
    385             machine.CreateSharedFolder(data.m_strName, data.m_strHostPath, data.m_fWritable, data.m_fAutoMount);
    386             if (!machine.isOk())
     369            m_machine.CreateSharedFolder(data.m_strName, data.m_strHostPath, data.m_fWritable, data.m_fAutoMount);
     370            if (!m_machine.isOk())
    387371            {
    388372                /* Mark the page as failed: */
    389373                setFailed(true);
    390374                /* Show error message: */
    391                 vboxProblem().cannotCreateSharedFolder(machine, data.m_strName, data.m_strHostPath);
     375                vboxProblem().cannotCreateSharedFolder(m_machine, data.m_strName, data.m_strHostPath);
    392376            }
    393377        }
     
    395379}
    396380
    397 void UIMachineSettingsSF::saveFromCacheToConsole(CConsole &console)
     381void UIMachineSettingsSF::saveFromCacheToConsole()
    398382{
    399383    /* Check if items were NOT changed: */
     
    402386
    403387    /* Delete all console folders first: */
    404     const CSharedFolderVector &folders = console.GetSharedFolders();
     388    const CSharedFolderVector &folders = m_console.GetSharedFolders();
    405389    for (int iFolderIndex = 0; iFolderIndex < folders.size() && !failed(); ++iFolderIndex)
    406390    {
     
    408392        QString strFolderName = folder.GetName();
    409393        QString strFolderPath = folder.GetHostPath();
    410         console.RemoveSharedFolder(strFolderName);
    411         if (!console.isOk())
     394        m_console.RemoveSharedFolder(strFolderName);
     395        if (!m_console.isOk())
    412396        {
    413397            /* Mark the page as failed: */
    414398            setFailed(true);
    415399            /* Show error message: */
    416             vboxProblem().cannotRemoveSharedFolder(console, strFolderName, strFolderPath);
     400            vboxProblem().cannotRemoveSharedFolder(m_console, strFolderName, strFolderPath);
    417401        }
    418402    }
     
    424408        if (data.m_type == ConsoleType)
    425409        {
    426             console.CreateSharedFolder(data.m_strName, data.m_strHostPath, data.m_fWritable, data.m_fAutoMount);
    427             if (!console.isOk())
     410            m_console.CreateSharedFolder(data.m_strName, data.m_strHostPath, data.m_fWritable, data.m_fAutoMount);
     411            if (!m_console.isOk())
    428412            {
    429413                /* Mark the page as failed: */
    430414                setFailed(true);
    431415                /* Show error message: */
    432                 vboxProblem().cannotCreateSharedFolder(console, data.m_strName, data.m_strHostPath);
     416                vboxProblem().cannotCreateSharedFolder(m_console, data.m_strName, data.m_strHostPath);
    433417            }
    434418        }
     
    717701}
    718702
     703void UIMachineSettingsSF::setDialogType(VBoxDefs::SettingsDialogType settingsDialogType)
     704{
     705    UISettingsPageMachine::setDialogType(settingsDialogType);
     706    m_type = dialogType() == VBoxDefs::SettingsDialogType_Runtime ? ConsoleType : MachineType;
     707}
     708
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2008-2010 Oracle Corporation
     8 * Copyright (C) 2008-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2727class SFTreeViewItem;
    2828
    29 enum UISharedFolderType
    30 {
    31     WrongType   = 0x00,
    32     MachineType = 0x01,
    33     ConsoleType = 0x02
    34 };
     29enum UISharedFolderType { MachineType, ConsoleType };
    3530typedef QPair <QString, UISharedFolderType> SFolderName;
    3631typedef QList <SFolderName> SFoldersNameList;
     
    6257    UIMachineSettingsSF();
    6358
    64     void loadDirectlyFrom(const CConsole &console);
    65     void saveDirectlyTo(CConsole &console);
    66 
    6759protected:
    6860
     
    7062     * this task COULD be performed in other than GUI thread: */
    7163    void loadToCacheFrom(QVariant &data);
    72     void loadToCacheFromMachine(const CMachine &machine);
    73     void loadToCacheFromConsole(const CConsole &console);
     64    void loadToCacheFromMachine();
     65    void loadToCacheFromConsole();
    7466    void loadToCacheFromVector(const CSharedFolderVector &vector, UISharedFolderType type);
    7567    /* Load data to corresponding widgets from cache,
     
    8375     * this task COULD be performed in other than GUI thread: */
    8476    void saveFromCacheTo(QVariant &data);
    85     void saveFromCacheToMachine(CMachine &machine);
    86     void saveFromCacheToConsole(CConsole &console);
     77    void saveFromCacheToMachine();
     78    void saveFromCacheToConsole();
    8779
    8880    void setOrderAfter (QWidget *aWidget);
     
    112104    SFoldersNameList usedList (bool aIncludeSelected);
    113105
     106    void setDialogType(VBoxDefs::SettingsDialogType settingsDialogType);
     107
    114108    UISharedFolderType m_type;
    115109
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r36324 r36357  
    2626
    2727/* UIMachineSettingsSerial stuff */
    28 UIMachineSettingsSerial::UIMachineSettingsSerial()
     28UIMachineSettingsSerial::UIMachineSettingsSerial(UIMachineSettingsSerialPage *pParent)
    2929    : QIWithRetranslateUI<QWidget> (0)
     30    , m_pParent(pParent)
    3031    , mValidator(0)
    3132    , m_iSlot(-1)
     
    6364    /* Applying language settings */
    6465    retranslateUi();
     66}
     67
     68void UIMachineSettingsSerial::polishTab()
     69{
     70    /* Polish tab depending on dialog type: */
     71    switch (m_pParent->dialogType())
     72    {
     73        case VBoxDefs::SettingsDialogType_Offline:
     74            break;
     75        case VBoxDefs::SettingsDialogType_Runtime:
     76            mGbSerial->setEnabled(false);
     77            mLbNumber->setEnabled(false);
     78            mCbNumber->setEnabled(false);
     79            mLbIRQ->setEnabled(false);
     80            mLeIRQ->setEnabled(false);
     81            mLbIOPort->setEnabled(false);
     82            mLeIOPort->setEnabled(false);
     83            mLbMode->setEnabled(false);
     84            mCbMode->setEnabled(false);
     85            mCbPipe->setEnabled(false);
     86            mLbPath->setEnabled(false);
     87            mLePath->setEnabled(false);
     88            break;
     89        default:
     90            break;
     91    }
    6592}
    6693
     
    195222    {
    196223        /* Creating port's page: */
    197         UIMachineSettingsSerial *pPage = new UIMachineSettingsSerial;
     224        UIMachineSettingsSerial *pPage = new UIMachineSettingsSerial(this);
    198225
    199226        /* Attach port's page to Tab Widget: */
     
    294321    UISettingsPageMachine::fetchData(data);
    295322
    296     /* Gather corresponding values from internal variables: */
    297     for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
    298     {
    299         /* Get adapter: */
    300         CSerialPort port = m_machine.GetSerialPort(iSlot);
    301 
    302         /* Get cached data for this slot: */
    303         const UISerialPortData &data = m_cache.m_items[iSlot];
    304 
    305         /* Save options: */
    306         port.SetEnabled(data.m_fPortEnabled);
    307         port.SetIRQ(data.m_uIRQ);
    308         port.SetIOBase(data.m_uIOBase);
    309         port.SetServer(data.m_fServer);
    310         port.SetPath(data.m_strPath);
    311         /* This *must* be last. The host mode will be changed to disconnected if
    312          * some of the necessary settings above will not meet the requirements for
    313          * the selected mode. */
    314         port.SetHostMode(data.m_hostMode);
     323    /* Save settings depending on dialog type: */
     324    switch (dialogType())
     325    {
     326        /* Here come the properties which could be changed only in offline state: */
     327        case VBoxDefs::SettingsDialogType_Offline:
     328        {
     329            /* Gather corresponding values from internal variables: */
     330            for (int iSlot = 0; iSlot < m_cache.m_items.size(); ++iSlot)
     331            {
     332                /* Get adapter: */
     333                CSerialPort port = m_machine.GetSerialPort(iSlot);
     334
     335                /* Get cached data for this slot: */
     336                const UISerialPortData &data = m_cache.m_items[iSlot];
     337
     338                /* Save options: */
     339                port.SetEnabled(data.m_fPortEnabled);
     340                port.SetIRQ(data.m_uIRQ);
     341                port.SetIOBase(data.m_uIOBase);
     342                port.SetServer(data.m_fServer);
     343                port.SetPath(data.m_strPath);
     344                /* This *must* be last. The host mode will be changed to disconnected if
     345                 * some of the necessary settings above will not meet the requirements for
     346                 * the selected mode. */
     347                port.SetHostMode(data.m_hostMode);
     348            }
     349            break;
     350        }
     351        /* Here come the properties which could be changed at runtime too: */
     352        case VBoxDefs::SettingsDialogType_Runtime:
     353            break;
     354        default:
     355            break;
    315356    }
    316357
     
    393434}
    394435
     436void UIMachineSettingsSerialPage::polishPage()
     437{
     438    /* Get the count of serial port tabs: */
     439    for (int iTabIndex = 0; iTabIndex < mTabWidget->count(); ++iTabIndex)
     440    {
     441        /* Polish iterated tab depending on dialog type: */
     442        switch (dialogType())
     443        {
     444            case VBoxDefs::SettingsDialogType_Offline:
     445                break;
     446            case VBoxDefs::SettingsDialogType_Runtime:
     447            {
     448                if (!m_cache.m_items[iTabIndex].m_fPortEnabled)
     449                    mTabWidget->setTabEnabled(iTabIndex, false);
     450                break;
     451            }
     452            default:
     453                break;
     454        }
     455        UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(mTabWidget->widget(iTabIndex));
     456        Assert(pTab);
     457        pTab->polishTab();
     458    }
     459}
     460
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#include "COMDefs.h"
    2525
     26/* Forward declarations */
     27class UIMachineSettingsSerialPage;
    2628class QITabWidget;
    2729
     
    5153public:
    5254
    53     UIMachineSettingsSerial();
     55    UIMachineSettingsSerial(UIMachineSettingsSerialPage *pParent);
     56
     57    void polishTab();
    5458
    5559    void fetchPortData(const UISerialPortData &data);
     
    7579private:
    7680
     81    UIMachineSettingsSerialPage *m_pParent;
    7782    QIWidgetValidator *mValidator;
    7883    int m_iSlot;
     
    111116private:
    112117
     118    void polishPage();
     119
    113120    QIWidgetValidator *mValidator;
    114121    QITabWidget *mTabWidget;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r35475 r36357  
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    766766    , mToolTipType (DefaultToolTip)
    767767    , m_chipsetType(KChipsetType_PIIX3)
     768    , m_dialogType(VBoxDefs::SettingsDialogType_Wrong)
    768769{
    769770}
     
    935936        case R_IsMoreIDEControllersPossible:
    936937        {
    937             return static_cast <RootItem*> (mRootItem)->childCount (KStorageBus_IDE) <
    938                     vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus (chipsetType(), KStorageBus_IDE);
     938            return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     939                   (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_IDE) <
     940                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_IDE));
    939941        }
    940942        case R_IsMoreSATAControllersPossible:
    941943        {
    942             return static_cast <RootItem*> (mRootItem)->childCount (KStorageBus_SATA) <
    943                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus (chipsetType(), KStorageBus_SATA);
     944            return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     945                   (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SATA) <
     946                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SATA));
    944947        }
    945948        case R_IsMoreSCSIControllersPossible:
    946949        {
    947             return static_cast <RootItem*> (mRootItem)->childCount (KStorageBus_SCSI) <
    948                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus (chipsetType(), KStorageBus_SCSI);
     950            return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     951                   (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SCSI) <
     952                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SCSI));
    949953        }
    950954        case R_IsMoreFloppyControllersPossible:
    951955        {
    952             return static_cast <RootItem*> (mRootItem)->childCount (KStorageBus_Floppy) <
    953                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus (chipsetType(), KStorageBus_Floppy);
     956            return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     957                   (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_Floppy) <
     958                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_Floppy));
    954959        }
    955960        case R_IsMoreSASControllersPossible:
    956961        {
    957             return static_cast <RootItem*> (mRootItem)->childCount (KStorageBus_SAS) <
    958                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus (chipsetType(), KStorageBus_SAS);
     962            return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     963                   (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SAS) <
     964                    vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SAS));
    959965        }
    960966        case R_IsMoreAttachmentsPossible:
     
    966972                    ControllerItem *ctr = static_cast <ControllerItem*> (item);
    967973                    CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties();
    968                     return (uint) rowCount (aIndex) < sp.GetMaxPortCountForStorageBus (ctr->ctrBusType()) *
    969                                                       sp.GetMaxDevicesPerPortForStorageBus (ctr->ctrBusType());
     974                    return (m_dialogType == VBoxDefs::SettingsDialogType_Offline) &&
     975                           ((uint)rowCount(aIndex) < sp.GetMaxPortCountForStorageBus(ctr->ctrBusType()) *
     976                                                     sp.GetMaxDevicesPerPortForStorageBus(ctr->ctrBusType()));
    970977                }
    971978            }
     
    14111418{
    14121419    m_chipsetType = type;
     1420}
     1421
     1422void StorageModel::setDialogType(VBoxDefs::SettingsDialogType dialogType)
     1423{
     1424    m_dialogType = dialogType;
    14131425}
    14141426
     
    18851897    UISettingsPageMachine::fetchData(data);
    18861898
    1887     /* Remove currently present controllers & attachments */
    1888     const CStorageControllerVector &controllers = m_machine.GetStorageControllers();
    1889     for (int iControllerIndex = 0; iControllerIndex < controllers.size(); ++iControllerIndex)
    1890     {
    1891         const CStorageController &controller = controllers[iControllerIndex];
    1892         QString strControllerName(controller.GetName());
    1893         const CMediumAttachmentVector &attachments = m_machine.GetMediumAttachmentsOfController(strControllerName);
    1894         for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex)
    1895         {
    1896             const CMediumAttachment &attachment = attachments[iAttachmentIndex];
    1897             m_machine.DetachDevice(strControllerName, attachment.GetPort(), attachment.GetDevice());
    1898         }
    1899         m_machine.RemoveStorageController(strControllerName);
    1900     }
    1901     /* Save created controllers: */
    1902     for (int iControllerIndex = 0; iControllerIndex < m_cache.m_items.size() && !failed(); ++iControllerIndex)
    1903     {
    1904         const UIStorageControllerData &controllerData = m_cache.m_items[iControllerIndex];
    1905         CStorageController controller = m_machine.AddStorageController(controllerData.m_strControllerName, controllerData.m_controllerBus);
    1906         controller.SetControllerType(controllerData.m_controllerType);
    1907         controller.SetUseHostIOCache(controllerData.m_fUseHostIOCache);
    1908         int cMaxUsedPort = -1;
    1909         /* Save created attachments: */
    1910         for (int iAttachmentIndex = 0; iAttachmentIndex < controllerData.m_items.size() && !failed(); ++iAttachmentIndex)
    1911         {
    1912             const UIStorageAttachmentData &attachmentData = controllerData.m_items[iAttachmentIndex];
    1913             VBoxMedium vboxMedium = vboxGlobal().findMedium(attachmentData.m_strAttachmentMediumId);
    1914             CMedium comMedium = vboxMedium.medium();
    1915             m_machine.AttachDevice(controllerData.m_strControllerName,
    1916                                    attachmentData.m_iAttachmentPort, attachmentData.m_iAttachmentDevice,
    1917                                    attachmentData.m_attachmentType, comMedium);
    1918             if (m_machine.isOk())
     1899    /* Save settings depending on dialog type: */
     1900    switch (dialogType())
     1901    {
     1902        /* Here come the properties which could be changed only in offline state: */
     1903        case VBoxDefs::SettingsDialogType_Offline:
     1904        {
     1905            /* Remove currently present controllers & attachments */
     1906            const CStorageControllerVector &controllers = m_machine.GetStorageControllers();
     1907            for (int iControllerIndex = 0; iControllerIndex < controllers.size(); ++iControllerIndex)
    19191908            {
    1920                 if (attachmentData.m_attachmentType == KDeviceType_DVD)
    1921                     m_machine.PassthroughDevice(controllerData.m_strControllerName,
    1922                                                 attachmentData.m_iAttachmentPort, attachmentData.m_iAttachmentDevice,
    1923                                                 attachmentData.m_fAttachmentPassthrough);
    1924                 cMaxUsedPort = attachmentData.m_iAttachmentPort > cMaxUsedPort ? attachmentData.m_iAttachmentPort : cMaxUsedPort;
     1909                /* Get iterated controller: */
     1910                const CStorageController &controller = controllers[iControllerIndex];
     1911                QString strControllerName(controller.GetName());
     1912                const CMediumAttachmentVector &attachments = m_machine.GetMediumAttachmentsOfController(strControllerName);
     1913                /* Remove all the attachments first: */
     1914                for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex)
     1915                {
     1916                    /* Get iterated attachment: */
     1917                    const CMediumAttachment &attachment = attachments[iAttachmentIndex];
     1918                    m_machine.DetachDevice(strControllerName, attachment.GetPort(), attachment.GetDevice());
     1919                }
     1920                /* Remove the controller itself finally: */
     1921                m_machine.RemoveStorageController(strControllerName);
    19251922            }
    1926             else
     1923            /* Save created controllers: */
     1924            for (int iControllerIndex = 0; iControllerIndex < m_cache.m_items.size() && !failed(); ++iControllerIndex)
    19271925            {
    1928                 /* Mark the page as failed: */
    1929                 setFailed(true);
    1930                 /* Show error message: */
    1931                 vboxProblem().cannotAttachDevice(m_machine, VBoxDefs::MediumType_HardDisk, vboxMedium.location(),
    1932                                                  StorageSlot(controllerData.m_controllerBus,
    1933                                                              attachmentData.m_iAttachmentPort,
    1934                                                              attachmentData.m_iAttachmentDevice), this);
     1926                /* Get iterated controller's data: */
     1927                const UIStorageControllerData &controllerData = m_cache.m_items[iControllerIndex];
     1928                CStorageController controller = m_machine.AddStorageController(controllerData.m_strControllerName, controllerData.m_controllerBus);
     1929                controller.SetControllerType(controllerData.m_controllerType);
     1930                controller.SetUseHostIOCache(controllerData.m_fUseHostIOCache);
     1931                int cMaxUsedPort = -1;
     1932                /* Save created attachments: */
     1933                for (int iAttachmentIndex = 0; iAttachmentIndex < controllerData.m_items.size() && !failed(); ++iAttachmentIndex)
     1934                {
     1935                    /* Get iterated attachment: */
     1936                    const UIStorageAttachmentData &attachmentData = controllerData.m_items[iAttachmentIndex];
     1937                    /* Search for newly assigned medium in GUI cache: */
     1938                    VBoxMedium vboxMedium = vboxGlobal().findMedium(attachmentData.m_strAttachmentMediumId);
     1939                    /* Get corresponding COM-wrapped medium object: */
     1940                    CMedium comMedium = vboxMedium.medium();
     1941                    /* Add corresponding attachment: */
     1942                    m_machine.AttachDevice(controllerData.m_strControllerName,
     1943                                           attachmentData.m_iAttachmentPort, attachmentData.m_iAttachmentDevice,
     1944                                           attachmentData.m_attachmentType, comMedium);
     1945                    if (m_machine.isOk())
     1946                    {
     1947                        if (attachmentData.m_attachmentType == KDeviceType_DVD)
     1948                            m_machine.PassthroughDevice(controllerData.m_strControllerName,
     1949                                                        attachmentData.m_iAttachmentPort, attachmentData.m_iAttachmentDevice,
     1950                                                        attachmentData.m_fAttachmentPassthrough);
     1951                        cMaxUsedPort = attachmentData.m_iAttachmentPort > cMaxUsedPort ? attachmentData.m_iAttachmentPort : cMaxUsedPort;
     1952                    }
     1953                    else
     1954                    {
     1955                        /* Mark the page as failed: */
     1956                        setFailed(true);
     1957                        /* Show error message: */
     1958                        vboxProblem().cannotAttachDevice(m_machine,
     1959                                                         vboxGlobal().mediumTypeToLocal(attachmentData.m_attachmentType),
     1960                                                         vboxMedium.location(),
     1961                                                         StorageSlot(controllerData.m_controllerBus,
     1962                                                                     attachmentData.m_iAttachmentPort,
     1963                                                                     attachmentData.m_iAttachmentDevice),
     1964                                                         this);
     1965                    }
     1966                }
     1967                if (!failed() && controllerData.m_controllerBus == KStorageBus_SATA)
     1968                {
     1969                    ULONG uSataPortsCount = cMaxUsedPort + 1;
     1970                    uSataPortsCount = qMax(uSataPortsCount, controller.GetMinPortCount());
     1971                    uSataPortsCount = qMin(uSataPortsCount, controller.GetMaxPortCount());
     1972                    controller.SetPortCount(uSataPortsCount);
     1973                }
    19351974            }
    1936         }
    1937         if (!failed() && controllerData.m_controllerBus == KStorageBus_SATA)
    1938         {
    1939             ULONG uSataPortsCount = cMaxUsedPort + 1;
    1940             uSataPortsCount = qMax(uSataPortsCount, controller.GetMinPortCount());
    1941             uSataPortsCount = qMin(uSataPortsCount, controller.GetMaxPortCount());
    1942             controller.SetPortCount(uSataPortsCount);
    1943         }
     1975            break;
     1976        }
     1977        /* Here come the properties which could be changed at runtime too: */
     1978        case VBoxDefs::SettingsDialogType_Runtime:
     1979        {
     1980            /* Iterate all the controllers and update changed CD/DVD and floppy attachments: */
     1981            for (int iControllerIndex = 0; iControllerIndex < m_cache.m_items.size() && !failed(); ++iControllerIndex)
     1982            {
     1983                /* Get iterated controller: */
     1984                const UIStorageControllerData &controllerData = m_cache.m_items[iControllerIndex];
     1985                CStorageController controller = m_machine.GetStorageControllerByName(controllerData.m_strControllerName);
     1986                AssertMsg(!controller.isNull(), ("Corresponding storage controller must be present!\n"));
     1987                /* Save changed attachments: */
     1988                for (int iAttachmentIndex = 0; iAttachmentIndex < controllerData.m_items.size() && !failed(); ++iAttachmentIndex)
     1989                {
     1990                    /* Get iterated attachment: */
     1991                    const UIStorageAttachmentData &attachmentData = controllerData.m_items[iAttachmentIndex];
     1992                    /* Update only DVD and floppy attachments: */
     1993                    if (attachmentData.m_attachmentType != KDeviceType_DVD &&
     1994                        attachmentData.m_attachmentType != KDeviceType_Floppy)
     1995                        continue;
     1996                    /* Search for newly assigned medium in GUI cache: */
     1997                    VBoxMedium vboxMedium = vboxGlobal().findMedium(attachmentData.m_strAttachmentMediumId);
     1998                    /* Get corresponding COM-wrapped medium object: */
     1999                    CMedium comMedium = vboxMedium.medium();
     2000                    /* Update corresponding medium: */
     2001                    m_machine.MountMedium(controllerData.m_strControllerName,
     2002                                          attachmentData.m_iAttachmentPort, attachmentData.m_iAttachmentDevice,
     2003                                          comMedium, true /* may the force be with you */);
     2004                    if (!m_machine.isOk())
     2005                    {
     2006                        /* Mark the page as failed: */
     2007                        setFailed(true);
     2008                        /* Show error message: */
     2009                        vboxProblem().cannotAttachDevice(m_machine,
     2010                                                         vboxGlobal().mediumTypeToLocal(attachmentData.m_attachmentType),
     2011                                                         vboxMedium.location(),
     2012                                                         StorageSlot(controllerData.m_controllerBus,
     2013                                                                     attachmentData.m_iAttachmentPort,
     2014                                                                     attachmentData.m_iAttachmentDevice),
     2015                                                         this);
     2016                    }
     2017                }
     2018            }
     2019            break;
     2020        }
     2021        default:
     2022            break;
    19442023    }
    19452024
     
    23012380                m_pMediumIdHolder->setType(vboxGlobal().mediumTypeToLocal(device));
    23022381                m_pMediumIdHolder->setId(mStorageModel->data(index, StorageModel::R_AttMediumId).toString());
     2382                mLbMedium->setEnabled(dialogType() == VBoxDefs::SettingsDialogType_Offline || device != KDeviceType_HardDisk);
     2383                mTbOpen->setEnabled(dialogType() == VBoxDefs::SettingsDialogType_Offline || device != KDeviceType_HardDisk);
    23032384
    23042385                /* Getting Passthrough state */
     
    25212602    mAddFDAttAction->setEnabled (isController && isAttachmentsPossible);
    25222603
    2523     mDelCtrAction->setEnabled (isController);
    2524     mDelAttAction->setEnabled (isAttachment);
     2604    mDelCtrAction->setEnabled (dialogType() == VBoxDefs::SettingsDialogType_Offline && isController);
     2605    mDelAttAction->setEnabled (dialogType() == VBoxDefs::SettingsDialogType_Offline && isAttachment);
    25252606}
    25262607
     
    29853066}
    29863067
     3068void UIMachineSettingsStorage::setDialogType(VBoxDefs::SettingsDialogType settingsDialogType)
     3069{
     3070    UISettingsPageMachine::setDialogType(settingsDialogType);
     3071    mStorageModel->setDialogType(dialogType());
     3072}
     3073
     3074void UIMachineSettingsStorage::polishPage()
     3075{
     3076    /* Polish page depending on dialog type: */
     3077    switch (dialogType())
     3078    {
     3079        case VBoxDefs::SettingsDialogType_Offline:
     3080            break;
     3081        case VBoxDefs::SettingsDialogType_Runtime:
     3082            /* Controller stuff: */
     3083            mLbName->setEnabled(false);
     3084            mLeName->setEnabled(false);
     3085            mLbType->setEnabled(false);
     3086            mCbType->setEnabled(false);
     3087            mCbIoCache->setEnabled(false);
     3088            /* Attachment stuff: */
     3089            mCbSlot->setEnabled(false);
     3090            mCbPassthrough->setEnabled(false);
     3091            break;
     3092        default:
     3093            break;
     3094    }
     3095}
     3096
    29873097#include "UIMachineSettingsStorage.moc"
    29883098
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r34961 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    503503    void setChipsetType(KChipsetType type);
    504504
     505    void setDialogType(VBoxDefs::SettingsDialogType dialogType);
     506
    505507    QMap<KStorageBus, int> currentControllerTypes() const;
    506508    QMap<KStorageBus, int> maximumControllerTypes() const;
     
    521523
    522524    KChipsetType m_chipsetType;
     525    VBoxDefs::SettingsDialogType m_dialogType;
    523526};
    524527Q_DECLARE_METATYPE (StorageModel::ToolTipType);
     
    669672    void addChooseHostDriveActions(QMenu *pOpenMediumMenu);
    670673    void addRecentMediumActions(QMenu *pOpenMediumMenu, VBoxDefs::MediumType recentMediumType);
     674
     675    void setDialogType(VBoxDefs::SettingsDialogType settingsDialogType);
     676    void polishPage();
    671677
    672678    QIWidgetValidator *mValidator;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r34063 r36357  
    77
    88/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     9 * Copyright (C) 2008-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    286286    UISettingsPageMachine::fetchData(data);
    287287
    288     /* Gather corresponding values from internal variables: */
    289     int iBootIndex = 0;
    290     /* Save boot-items of current VM: */
    291     for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
    292     {
    293         if (m_cache.m_bootItems[i].m_fEnabled)
    294             m_machine.SetBootOrder(++iBootIndex, m_cache.m_bootItems[i].m_type);
    295     }
    296     /* Save other unique boot-items: */
    297     for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
    298     {
    299         if (!m_cache.m_bootItems[i].m_fEnabled)
    300             m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null);
    301     }
    302     m_machine.GetBIOSSettings().SetIOAPICEnabled(m_cache.m_fIoApicEnabled);
    303     m_machine.SetFirmwareType(m_cache.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);
    304     m_machine.SetRTCUseUTC(m_cache.m_fUTCEnabled);
    305     m_machine.SetPointingHidType(m_cache.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse);
    306     m_machine.SetCPUProperty(KCPUPropertyType_PAE, m_cache.m_fPAEEnabled);
    307     m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, m_cache.m_fHwVirtExEnabled);
    308     m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, m_cache.m_fNestedPagingEnabled);
    309     m_machine.SetMemorySize(m_cache.m_iRAMSize);
    310     m_machine.SetCPUCount(m_cache.m_cCPUCount);
    311     m_machine.SetChipsetType(m_cache.m_chipsetType);
     288    /* Save settings depending on dialog type: */
     289    switch (dialogType())
     290    {
     291        /* Here come the properties which could be changed only in offline state: */
     292        case VBoxDefs::SettingsDialogType_Offline:
     293        {
     294            /* Motherboard tab: */
     295            m_machine.SetMemorySize(m_cache.m_iRAMSize);
     296            int iBootIndex = 0;
     297            /* Save boot-items of current VM: */
     298            for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
     299            {
     300                if (m_cache.m_bootItems[i].m_fEnabled)
     301                    m_machine.SetBootOrder(++iBootIndex, m_cache.m_bootItems[i].m_type);
     302            }
     303            /* Save other unique boot-items: */
     304            for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
     305            {
     306                if (!m_cache.m_bootItems[i].m_fEnabled)
     307                    m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null);
     308            }
     309            m_machine.SetChipsetType(m_cache.m_chipsetType);
     310            m_machine.GetBIOSSettings().SetIOAPICEnabled(m_cache.m_fIoApicEnabled);
     311            m_machine.SetFirmwareType(m_cache.m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);
     312            m_machine.SetRTCUseUTC(m_cache.m_fUTCEnabled);
     313            m_machine.SetPointingHidType(m_cache.m_fUseAbsHID ? KPointingHidType_USBTablet : KPointingHidType_PS2Mouse);
     314            /* Processor tab: */
     315            m_machine.SetCPUCount(m_cache.m_cCPUCount);
     316            m_machine.SetCPUProperty(KCPUPropertyType_PAE, m_cache.m_fPAEEnabled);
     317            /* Acceleration tab: */
     318            m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, m_cache.m_fHwVirtExEnabled);
     319            m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, m_cache.m_fNestedPagingEnabled);
     320            break;
     321        }
     322        /* Here come the properties which could be changed at runtime too: */
     323        case VBoxDefs::SettingsDialogType_Runtime:
     324            break;
     325        default:
     326            break;
     327    }
    312328
    313329    /* Upload machine to data: */
     
    532548}
    533549
     550void UIMachineSettingsSystem::polishPage()
     551{
     552    /* Polish page depending on dialog type: */
     553    switch (dialogType())
     554    {
     555        case VBoxDefs::SettingsDialogType_Offline:
     556            break;
     557        case VBoxDefs::SettingsDialogType_Runtime:
     558            /* Motherboard tab: */
     559            mLbMemory->setEnabled(false);
     560            mLbMemoryMin->setEnabled(false);
     561            mLbMemoryMax->setEnabled(false);
     562            mLbMemoryUnit->setEnabled(false);
     563            mSlMemory->setEnabled(false);
     564            mLeMemory->setEnabled(false);
     565            mLbBootOrder->setEnabled(false);
     566            mTwBootOrder->setEnabled(false);
     567            mTbBootItemUp->setEnabled(false);
     568            mTbBootItemDown->setEnabled(false);
     569            mLbChipset->setEnabled(false);
     570            mCbChipset->setEnabled(false);
     571            mLbMotherboardExtended->setEnabled(false);
     572            mCbApic->setEnabled(false);
     573            mCbEFI->setEnabled(false);
     574            mCbTCUseUTC->setEnabled(false);
     575            mCbUseAbsHID->setEnabled(false);
     576            /* Processor tab: */
     577            mLbCPU->setEnabled(false);
     578            mLbCPUMin->setEnabled(false);
     579            mLbCPUMax->setEnabled(false);
     580            mSlCPU->setEnabled(false);
     581            mLeCPU->setEnabled(false);
     582            mLbProcessorExtended->setEnabled(false);
     583            mCbPae->setEnabled(false);
     584            /* Acceleration tab: */
     585            mLbVirt->setEnabled(false);
     586            mCbVirt->setEnabled(false);
     587            mCbNestedPaging->setEnabled(false);
     588            break;
     589        default:
     590            break;
     591    }
     592}
     593
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r34063 r36357  
    66
    77/*
    8  * Copyright (C) 2008-2010 Oracle Corporation
     8 * Copyright (C) 2008-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    107107    void adjustBootOrderTWSize();
    108108
     109    void polishPage();
     110
    109111    QIWidgetValidator *mValidator;
    110112
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r36324 r36357  
    106106             this, SLOT (usbAdapterToggled (bool)));
    107107    connect (mTwFilters, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
    108              this, SLOT (currentChanged (QTreeWidgetItem*, QTreeWidgetItem*)));
     108             this, SLOT (currentChanged (QTreeWidgetItem*)));
    109109    connect (mTwFilters, SIGNAL (customContextMenuRequested (const QPoint &)),
    110110             this, SLOT (showContextMenu (const QPoint &)));
     
    296296    fetchData(data);
    297297
    298     /* Depending on page type: */
     298    /* Save settings depending on page type: */
    299299    switch (pageType())
    300300    {
     301        /* Here come the global USB properties: */
    301302        case UISettingsPageType_Global:
    302303        {
    303             /* Gather corresponding values from internal variables: */
    304             if (mUSBFilterListModified)
     304            /* Save settings depending on dialog type: */
     305            switch (dialogType())
    305306            {
    306                 /* Get host: */
    307                 CHost host = vboxGlobal().virtualBox().GetHost();
    308                 /* First, remove all old filters: */
    309                 for (ulong count = host.GetUSBDeviceFilters().size(); count; --count)
    310                     host.RemoveUSBDeviceFilter(0);
    311                 /* Then add all new filters: */
    312                 for (int iFilterIndex = 0; iFilterIndex < m_cache.m_items.size(); ++iFilterIndex)
     307                /* Here come the properties which could be changed only in offline state: */
     308                case VBoxDefs::SettingsDialogType_Offline:
     309                /* Here come the properties which could be changed at runtime too: */
     310                case VBoxDefs::SettingsDialogType_Runtime:
    313311                {
    314                     UIUSBFilterData data = m_cache.m_items[iFilterIndex];
    315                     CHostUSBDeviceFilter hostFilter = host.CreateUSBDeviceFilter(data.m_strName);
    316                     hostFilter.SetActive(data.m_fActive);
    317                     hostFilter.SetVendorId(data.m_strVendorId);
    318                     hostFilter.SetProductId(data.m_strProductId);
    319                     hostFilter.SetRevision(data.m_strRevision);
    320                     hostFilter.SetManufacturer(data.m_strManufacturer);
    321                     hostFilter.SetProduct(data.m_strProduct);
    322                     hostFilter.SetSerialNumber(data.m_strSerialNumber);
    323                     hostFilter.SetPort(data.m_strPort);
    324                     hostFilter.SetRemote(data.m_strRemote);
    325                     hostFilter.SetAction(data.m_action);
    326                     host.InsertUSBDeviceFilter(host.GetUSBDeviceFilters().size(), hostFilter);
     312                    /* Gather corresponding values from internal variables: */
     313                    if (mUSBFilterListModified)
     314                    {
     315                        /* Get host: */
     316                        CHost host = vboxGlobal().virtualBox().GetHost();
     317                        /* First, remove all old filters: */
     318                        for (ulong count = host.GetUSBDeviceFilters().size(); count; --count)
     319                            host.RemoveUSBDeviceFilter(0);
     320                        /* Then add all new filters: */
     321                        for (int iFilterIndex = 0; iFilterIndex < m_cache.m_items.size(); ++iFilterIndex)
     322                        {
     323                            UIUSBFilterData data = m_cache.m_items[iFilterIndex];
     324                            CHostUSBDeviceFilter hostFilter = host.CreateUSBDeviceFilter(data.m_strName);
     325                            hostFilter.SetActive(data.m_fActive);
     326                            hostFilter.SetVendorId(data.m_strVendorId);
     327                            hostFilter.SetProductId(data.m_strProductId);
     328                            hostFilter.SetRevision(data.m_strRevision);
     329                            hostFilter.SetManufacturer(data.m_strManufacturer);
     330                            hostFilter.SetProduct(data.m_strProduct);
     331                            hostFilter.SetSerialNumber(data.m_strSerialNumber);
     332                            hostFilter.SetPort(data.m_strPort);
     333                            hostFilter.SetRemote(data.m_strRemote);
     334                            hostFilter.SetAction(data.m_action);
     335                            host.InsertUSBDeviceFilter(host.GetUSBDeviceFilters().size(), hostFilter);
     336                        }
     337                    }
     338                    break;
    327339                }
     340                default:
     341                    break;
    328342            }
    329343            break;
    330344        }
     345        /* Here come VM USB properties: */
    331346        case UISettingsPageType_Machine:
    332347        {
     
    338353            if (!ctl.isNull())
    339354            {
    340                 ctl.SetEnabled(m_cache.m_fUSBEnabled);
    341                 ctl.SetEnabledEhci(m_cache.m_fEHCIEnabled);
    342                 if (mUSBFilterListModified)
     355                /* Save settings depending on dialog type: */
     356                switch (dialogType())
    343357                {
    344                     /* First, remove all old filters: */
    345                     for (ulong count = ctl.GetDeviceFilters().size(); count; --count)
    346                         ctl.RemoveDeviceFilter(0);
    347                     /* Then add all new filters: */
    348                     for (int iFilterIndex = 0; iFilterIndex < m_cache.m_items.size(); ++iFilterIndex)
     358                    /* Here come the properties which could be changed only in offline state: */
     359                    case VBoxDefs::SettingsDialogType_Offline:
    349360                    {
    350                         const UIUSBFilterData &data = m_cache.m_items[iFilterIndex];
    351                         CUSBDeviceFilter filter = ctl.CreateDeviceFilter(data.m_strName);
    352                         filter.SetActive(data.m_fActive);
    353                         filter.SetVendorId(data.m_strVendorId);
    354                         filter.SetProductId(data.m_strProductId);
    355                         filter.SetRevision(data.m_strRevision);
    356                         filter.SetManufacturer(data.m_strManufacturer);
    357                         filter.SetProduct(data.m_strProduct);
    358                         filter.SetSerialNumber(data.m_strSerialNumber);
    359                         filter.SetPort(data.m_strPort);
    360                         filter.SetRemote(data.m_strRemote);
    361                         ctl.InsertDeviceFilter(~0, filter);
     361                        ctl.SetEnabled(m_cache.m_fUSBEnabled);
     362                        ctl.SetEnabledEhci(m_cache.m_fEHCIEnabled);
     363                        /* And after that come the properties which could be changed at runtime too: */
    362364                    }
     365                    /* Here come the properties which could be changed at runtime too: */
     366                    case VBoxDefs::SettingsDialogType_Runtime:
     367                    {
     368                        if (mUSBFilterListModified)
     369                        {
     370                            /* First, remove all old filters: */
     371                            for (ulong count = ctl.GetDeviceFilters().size(); count; --count)
     372                                ctl.RemoveDeviceFilter(0);
     373                            /* Then add all new filters: */
     374                            for (int iFilterIndex = 0; iFilterIndex < m_cache.m_items.size(); ++iFilterIndex)
     375                            {
     376                                const UIUSBFilterData &data = m_cache.m_items[iFilterIndex];
     377                                CUSBDeviceFilter filter = ctl.CreateDeviceFilter(data.m_strName);
     378                                filter.SetActive(data.m_fActive);
     379                                filter.SetVendorId(data.m_strVendorId);
     380                                filter.SetProductId(data.m_strProductId);
     381                                filter.SetRevision(data.m_strRevision);
     382                                filter.SetManufacturer(data.m_strManufacturer);
     383                                filter.SetProduct(data.m_strProduct);
     384                                filter.SetSerialNumber(data.m_strSerialNumber);
     385                                filter.SetPort(data.m_strPort);
     386                                filter.SetRemote(data.m_strRemote);
     387                                ctl.InsertDeviceFilter(~0, filter);
     388                            }
     389                        }
     390                        break;
     391                    }
     392                    default:
     393                        break;
    363394                }
    364395            }
     
    431462}
    432463
    433 void UIMachineSettingsUSB::currentChanged (QTreeWidgetItem *aItem,
    434                                         QTreeWidgetItem *)
    435 {
    436     /* Make sure only the current item if present => selected */
    437     if (mTwFilters->selectedItems().count() != 1 ||
    438         mTwFilters->selectedItems() [0] != aItem)
    439     {
    440         QList<QTreeWidgetItem*> list = mTwFilters->selectedItems();
    441         for (int i = 0; i < list.size(); ++ i)
    442             list [i]->setSelected (false);
    443         if (aItem)
    444             aItem->setSelected (true);
    445     }
    446 
    447     /* Enable/disable operational buttons */
    448     mEdtAction->setEnabled (aItem);
    449     mDelAction->setEnabled (aItem);
    450     mMupAction->setEnabled (aItem && mTwFilters->itemAbove (aItem));
    451     mMdnAction->setEnabled (aItem && mTwFilters->itemBelow (aItem));
     464void UIMachineSettingsUSB::currentChanged(QTreeWidgetItem *aItem)
     465{
     466    if (mTwFilters->isEnabled())
     467    {
     468        /* Make sure only the current item selected (if present): */
     469        if (mTwFilters->selectedItems().count() != 1 || mTwFilters->selectedItems()[0] != aItem)
     470        {
     471            QList<QTreeWidgetItem*> list = mTwFilters->selectedItems();
     472            for (int i = 0; i < list.size(); ++i)
     473                list[i]->setSelected(false);
     474            if (aItem)
     475                aItem->setSelected(true);
     476        }
     477    }
     478    else
     479        mTwFilters->setCurrentItem(0);
     480
     481    /* Update corresponding action states: */
     482    mEdtAction->setEnabled(aItem);
     483    mDelAction->setEnabled(aItem);
     484    mMupAction->setEnabled(aItem && mTwFilters->itemAbove(aItem));
     485    mMdnAction->setEnabled(aItem && mTwFilters->itemBelow(aItem));
    452486}
    453487
     
    721755}
    722756
    723 /* Fetch data to m_properties & m_settings or m_machine: */
     757/* Fetch data to m_properties & m_settings or m_machine & m_console: */
    724758void UIMachineSettingsUSB::fetchData(const QVariant &data)
    725759{
     
    735769        {
    736770            m_machine = data.value<UISettingsDataMachine>().m_machine;
    737             break;
    738         }
    739         default:
    740             break;
    741     }
    742 }
    743 
    744 /* Upload m_properties & m_settings or m_machine to data: */
     771            m_console = data.value<UISettingsDataMachine>().m_console;
     772            break;
     773        }
     774        default:
     775            break;
     776    }
     777}
     778
     779/* Upload m_properties & m_settings or m_machine & m_console to data: */
    745780void UIMachineSettingsUSB::uploadData(QVariant &data) const
    746781{
     
    754789        case UISettingsPageType_Machine:
    755790        {
    756             data = QVariant::fromValue(UISettingsDataMachine(m_machine));
     791            data = QVariant::fromValue(UISettingsDataMachine(m_machine, m_console));
    757792            break;
    758793        }
     
    805840}
    806841
     842void UIMachineSettingsUSB::polishPage()
     843{
     844    /* Polish page depending on dialog type: */
     845    switch (dialogType())
     846    {
     847        case VBoxDefs::SettingsDialogType_Offline:
     848            break;
     849        case VBoxDefs::SettingsDialogType_Runtime:
     850            mGbUSB->setEnabled(false);
     851            mCbUSB2->setEnabled(false);
     852            break;
     853        default:
     854            break;
     855    }
     856}
     857
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.h

    r33882 r36357  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    9999
    100100    void usbAdapterToggled (bool aOn);
    101     void currentChanged (QTreeWidgetItem *aItem = 0,
    102                          QTreeWidgetItem *aPrev = 0);
     101    void currentChanged (QTreeWidgetItem *aItem = 0);
    103102
    104103    void newClicked();
     
    126125    static QString toolTipFor(const UIUSBFilterData &data);
    127126
     127    void polishPage();
     128
    128129    /* Global data source: */
    129130    CSystemProperties m_properties;
     
    132133    /* Machine data source: */
    133134    CMachine m_machine;
     135    CConsole m_console;
    134136
    135137    /* Other variables: */
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