Changeset 37109 in vbox
- Timestamp:
- May 16, 2011 3:31:23 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r36592 r37109 952 952 return; 953 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 SettingsDialogType_Online, 967 sharedMachine, session().GetConsole(), 968 strCategory, QString()); 969 pDlg->loadData(); 970 971 /* Show VM settings dialog: */ 972 if (pDlg->exec() == QDialog::Accepted) 973 { 974 /* If dialog was accepted => save changed settings: */ 975 pDlg->saveData(); 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(); 954 /* Create and execute current VM settings dialog: */ 955 UISettingsDialogMachine dlg(defaultMachineWindow()->machineWindow(), 956 session().GetMachine().GetId(), strCategory, QString()); 957 dlg.execute(); 987 958 } 988 959 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r36592 r37109 592 592 void VBoxSelectorWnd::fileSettings() 593 593 { 594 VBoxGlobalSettings settings = vboxGlobal().settings(); 595 CSystemProperties props = vboxGlobal().virtualBox().GetSystemProperties(); 596 597 UISettingsDialog *dlg = new UISettingsDialogGlobal(this, SettingsDialogType_Offline); 598 dlg->loadData(); 599 600 if (dlg->exec() == QDialog::Accepted) 601 dlg->saveData(); 602 603 delete dlg; 594 /* Create and execute global settings dialog: */ 595 UISettingsDialogGlobal dlg(this); 596 dlg.execute(); 604 597 } 605 598 … … 697 690 * Opens the VM settings dialog. 698 691 */ 699 void VBoxSelectorWnd::vmSettings(const QString & aCategory/* = QString::null */,700 const QString & aControl/* = QString::null */,701 const QString & aUuid /* = QString::null */)702 { 703 if (!aCategory.isEmpty() && aCategory [0] != '#')704 {705 /* Assume it's a href from the Details HTML */706 vboxGlobal().openURL( aCategory);692 void VBoxSelectorWnd::vmSettings(const QString &strCategoryRef /* = QString::null */, 693 const QString &strControlRef /* = QString::null */, 694 const QString &strMachineId /* = QString::null */) 695 { 696 /* Process href from VM details / description: */ 697 if (!strCategoryRef.isEmpty() && strCategoryRef[0] != '#') 698 { 699 vboxGlobal().openURL(strCategoryRef); 707 700 return; 708 701 } 709 QString strCategory = aCategory; 710 QString strControl = aControl; 711 /* Maybe the control is coded into the URL by %% */ 712 if (aControl == QString::null) 713 { 714 QStringList parts = aCategory.split("%%"); 702 703 /* Get category and control: */ 704 QString strCategory = strCategoryRef; 705 QString strControl = strControlRef; 706 /* Check if control is coded into the URL by %%: */ 707 if (strControl.isEmpty()) 708 { 709 QStringList parts = strCategory.split("%%"); 715 710 if (parts.size() == 2) 716 711 { … … 720 715 } 721 716 722 UIVMItem *pItem = aUuid.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(aUuid); 723 AssertMsgReturnVoid(pItem, ("Item must be always selected here")); 724 725 SettingsDialogType dialogType = machineStateToSettingsDialogType(pItem->machineState()); 726 727 CSession session = vboxGlobal().openSession(pItem->id(), dialogType != SettingsDialogType_Offline /* connect to existing? */); 728 AssertMsgReturnVoid(!session.isNull(), ("Session must not be null")); 729 CMachine machine = session.GetMachine(); 730 AssertMsgReturnVoid(!machine.isNull(), ("Machine must not be null")); 731 CConsole console = dialogType == SettingsDialogType_Offline ? CConsole() : session.GetConsole(); 732 733 /* Don't show the inaccessible warning if the user open the vm settings: */ 717 /* Don't show the inaccessible warning if the user tries to open VM settings: */ 734 718 mDoneInaccessibleWarningOnce = true; 735 719 736 UISettingsDialog *pDlg = new UISettingsDialogMachine(this, dialogType, machine, console, strCategory, strControl); 737 pDlg->loadData(); 738 739 if (pDlg->exec() == QDialog::Accepted) 740 { 741 pDlg->saveData(); 742 743 machine.SaveSettings(); 744 if (!machine.isOk()) 745 vboxProblem().cannotSaveMachineSettings(machine); 746 747 /* To check use the result in future: 748 * vboxProblem().cannotApplyMachineSettings(m, res); */ 749 } 750 751 delete pDlg; 752 753 mVMListView->setFocus(); 754 755 session.UnlockMachine(); 720 /* Get corresponding VM item: */ 721 UIVMItem *pItem = strMachineId.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(strMachineId); 722 AssertMsgReturnVoid(pItem, ("Item must be always selected here!\n")); 723 724 /* Create and execute corresponding VM settings dialog: */ 725 UISettingsDialogMachine dlg(this, pItem->id(), strCategory, strControl); 726 dlg.execute(); 756 727 } 757 728 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r37106 r37109 43 43 44 44 /* Settings Dialog Constructor: */ 45 UISettingsDialog::UISettingsDialog(QWidget *pParent , SettingsDialogType settingsDialogType)45 UISettingsDialog::UISettingsDialog(QWidget *pParent) 46 46 /* Parent class: */ 47 47 : QIWithRetranslateUI<QIMainDialog>(pParent) … … 50 50 , m_pStack(0) 51 51 /* Common variables: */ 52 , m_dialogType( settingsDialogType)52 , m_dialogType(SettingsDialogType_Wrong) 53 53 , m_fPolished(false) 54 54 /* Loading/saving stuff: */ … … 150 150 } 151 151 152 void UISettingsDialog::execute() 153 { 154 /* Load data: */ 155 loadData(); 156 157 /* Execute dialog and wait for completion: */ 158 if (exec() != QDialog::Accepted) 159 return; 160 161 /* Save data: */ 162 saveData(); 163 } 164 152 165 void UISettingsDialog::sltRevalidate(QIWidgetValidator *pValidator) 153 166 { … … 254 267 if (!pValidator->isValid()) 255 268 sltRevalidate(pValidator); 269 } 270 } 271 272 void UISettingsDialog::setDialogType(SettingsDialogType settingsDialogType) 273 { 274 m_dialogType = settingsDialogType; 275 for (int iWidgetNumber = 0; iWidgetNumber < m_pStack->count(); ++iWidgetNumber) 276 { 277 UISettingsPage *pPage = static_cast<UISettingsPage*>(m_pStack->widget(iWidgetNumber)); 278 pPage->setDialogType(dialogType()); 256 279 } 257 280 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r37106 r37109 46 46 47 47 /* Settings Dialog Constructor/Destructor: */ 48 UISettingsDialog(QWidget *pParent , SettingsDialogType settingsDialogType);48 UISettingsDialog(QWidget *pParent); 49 49 ~UISettingsDialog(); 50 50 51 /* Save/Load interface: */ 52 virtual void loadData() = 0; 53 virtual void saveData() = 0; 51 /* Execute API: */ 52 void execute(); 54 53 55 54 protected slots: … … 70 69 protected: 71 70 71 /* Save/load API: */ 72 virtual void loadData() = 0; 73 virtual void saveData() = 0; 74 72 75 /* UI translator: */ 73 76 virtual void retranslateUi(); … … 75 78 /* Dialog type: */ 76 79 SettingsDialogType dialogType() { return m_dialogType; } 80 void setDialogType(SettingsDialogType settingsDialogType); 77 81 /* Dialog title: */ 78 82 virtual QString title() const = 0; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp
r37106 r37109 32 32 #include "QIWidgetValidator.h" 33 33 #include "VBoxSettingsSelector.h" 34 #include "UIVirtualBoxEventHandler.h" 34 35 35 36 #include "UIGlobalSettingsGeneral.h" … … 305 306 UISettingsSerializer* UISettingsSerializer::m_pInstance = 0; 306 307 307 UISettingsDialogGlobal::UISettingsDialogGlobal(QWidget *pParent , SettingsDialogType settingsDialogType)308 : UISettingsDialog(pParent , settingsDialogType)308 UISettingsDialogGlobal::UISettingsDialogGlobal(QWidget *pParent) 309 : UISettingsDialog(pParent) 309 310 { 310 311 /* Window icon: */ … … 312 313 setWindowIcon(QIcon(":/global_settings_16px.png")); 313 314 #endif /* !Q_WS_MAC */ 315 316 /* Assign default dialog type: */ 317 setDialogType(SettingsDialogType_Offline); 314 318 315 319 /* Creating settings pages: */ … … 524 528 } 525 529 526 UISettingsDialogMachine::UISettingsDialogMachine(QWidget *pParent, SettingsDialogType settingsDialogType, 527 const CMachine &machine, const CConsole &console, 530 UISettingsDialogMachine::UISettingsDialogMachine(QWidget *pParent, const QString &strMachineId, 528 531 const QString &strCategory, const QString &strControl) 529 : UISettingsDialog(pParent, settingsDialogType) 530 , m_machine(machine) 531 , m_console(console) 532 : UISettingsDialog(pParent) 533 , m_strMachineId(strMachineId) 532 534 , m_fAllowResetFirstRunFlag(false) 533 535 , m_fResetFirstRunFlag(false) … … 540 542 /* Allow to reset first-run flag just when medium enumeration was finished: */ 541 543 connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltAllowResetFirstRunFlag())); 544 545 /* Get corresponding machine (required to determine dialog type): */ 546 m_machine = vboxGlobal().virtualBox().FindMachine(m_strMachineId); 547 AssertMsg(!m_machine.isNull(), ("Can't find corresponding machine!\n")); 548 /* Assign current dialog type: */ 549 setDialogType(machineStateToSettingsDialogType(m_machine.GetState())); 542 550 543 551 /* Creating settings pages: */ … … 663 671 retranslateUi(); 664 672 665 /* Setup Settings Dialog: */673 /* Setup settings dialog: */ 666 674 if (!strCategory.isNull()) 667 675 { … … 695 703 else 696 704 m_pSelector->selectById(0); 705 706 /* Make sure settings dialog will be updated on machine state changes: */ 707 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), 708 this, SLOT(sltMachineStateChanged(QString, KMachineState))); 709 connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), 710 this, SLOT(sltMachineDataChanged(QString))); 697 711 } 698 712 699 713 void UISettingsDialogMachine::loadData() 700 714 { 715 /* Check that session is NOT created: */ 716 if (!m_session.isNull()) 717 return; 718 719 /* Prepare session: */ 720 m_session = dialogType() == SettingsDialogType_Wrong ? CSession() : vboxGlobal().openSession(m_strMachineId, true /* shared */); 721 /* Check that session was created: */ 722 if (m_session.isNull()) 723 return; 724 725 /* Get machine from session: */ 726 m_machine = m_session.GetMachine(); 727 /* Get console from session: */ 728 m_console = dialogType() == SettingsDialogType_Offline ? CConsole() : m_session.GetConsole(); 729 701 730 /* Prepare machine data: */ 702 731 qRegisterMetaType<UISettingsDataMachine>(); … … 719 748 void UISettingsDialogMachine::saveData() 720 749 { 750 /* Check that session is NOT created: */ 751 if (!m_session.isNull()) 752 return; 753 754 /* Prepare session: */ 755 bool fSessionShared = dialogType() != SettingsDialogType_Offline; 756 m_session = dialogType() == SettingsDialogType_Wrong ? CSession() : vboxGlobal().openSession(m_strMachineId, fSessionShared); 757 /* Check that session was created: */ 758 if (m_session.isNull()) 759 return; 760 761 /* Get machine from session: */ 762 m_machine = m_session.GetMachine(); 763 /* Get console from session: */ 764 m_console = dialogType() == SettingsDialogType_Offline ? CConsole() : m_session.GetConsole(); 765 721 766 /* Prepare machine data: */ 722 767 qRegisterMetaType<UISettingsDataMachine>(); … … 734 779 /* Get updated machine: */ 735 780 m_machine = pMachineSettingsSaver->data().value<UISettingsDataMachine>().m_machine; 736 m_console = pMachineSettingsSaver->data().value<UISettingsDataMachine>().m_console;737 781 /* If machine is ok => perform final operations: */ 738 782 if (m_machine.isOk()) … … 770 814 if (m_fResetFirstRunFlag) 771 815 m_machine.SetExtraData(VBoxDefs::GUI_FirstRun, QString::null); 772 } 773 /* If machine is NOT ok => show error message: */ 774 else 775 { 776 /* Show final error message: */ 816 817 /* Save settings finally: */ 818 m_machine.SaveSettings(); 819 } 820 821 /* If machine is NOT ok => show the error message: */ 822 if (!m_machine.isOk()) 777 823 vboxProblem().cannotSaveMachineSettings(m_machine); 778 } 824 825 /* Mark page processed: */ 826 sltMarkProcessed(); 779 827 } 780 828 … … 967 1015 968 1016 return true; 1017 } 1018 1019 void UISettingsDialogMachine::sltMarkProcessed() 1020 { 1021 /* Call for base-class: */ 1022 UISettingsDialog::sltMarkProcessed(); 1023 1024 /* Unlock the session if exists: */ 1025 if (!m_session.isNull()) 1026 { 1027 m_session.UnlockMachine(); 1028 m_session = CSession(); 1029 m_machine = CMachine(); 1030 m_console = CConsole(); 1031 } 1032 } 1033 1034 void UISettingsDialogMachine::sltMachineStateChanged(QString strMachineId, KMachineState machineState) 1035 { 1036 /* Ignore if thats NOT our VM: */ 1037 if (strMachineId != m_strMachineId) 1038 return; 1039 1040 /* Ignore if state was NOT actually changed: */ 1041 if (m_machineState == machineState) 1042 return; 1043 1044 /* Update current machine state: */ 1045 m_machineState = machineState; 1046 1047 /* Get new dialog type: */ 1048 SettingsDialogType newDialogType = machineStateToSettingsDialogType(m_machineState); 1049 1050 /* Ignore if dialog type was NOT actually changed: */ 1051 if (dialogType() == newDialogType) 1052 return; 1053 1054 /* Update current dialog type: */ 1055 setDialogType(newDialogType); 1056 } 1057 1058 void UISettingsDialogMachine::sltMachineDataChanged(QString strMachineId) 1059 { 1060 /* Ignore if thats NOT our VM: */ 1061 if (strMachineId != m_strMachineId) 1062 return; 1063 1064 /* Reload data: */ 1065 loadData(); 969 1066 } 970 1067 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h
r36592 r37109 43 43 }; 44 44 45 UISettingsDialogGlobal(QWidget *pParent , SettingsDialogType settingsDialogType);45 UISettingsDialogGlobal(QWidget *pParent); 46 46 47 47 protected: … … 82 82 }; 83 83 84 UISettingsDialogMachine(QWidget *pParent, SettingsDialogType settingsDialogType, 85 const CMachine &machine, const CConsole &console, 84 UISettingsDialogMachine(QWidget *pParent, const QString &strMachineId, 86 85 const QString &strCategory, const QString &strControl); 87 86 … … 99 98 private slots: 100 99 100 void sltMarkProcessed(); 101 void sltMachineStateChanged(QString strMachineId, KMachineState machineState); 102 void sltMachineDataChanged(QString strMachineId); 101 103 void sltCategoryChanged(int cId); 102 104 void sltAllowResetFirstRunFlag(); … … 108 110 bool isPageAvailable(int iPageId); 109 111 112 QString m_strMachineId; 113 KMachineState m_machineState; 114 115 CSession m_session; 110 116 CMachine m_machine; 111 117 CConsole m_console;
Note:
See TracChangeset
for help on using the changeset viewer.