Changeset 72815 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 3, 2018 9:55:30 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123359
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72529 r72815 796 796 src/logviewer/UIVMLogViewerTextEdit.h \ 797 797 src/logviewer/UIVMLogViewerWidget.h \ 798 src/medium/UIFDCreationDialog.h \ 798 799 src/medium/UIMediumEnumerator.h \ 799 800 src/medium/UIMediumSelector.h \ … … 1068 1069 src/logviewer/UIVMLogViewerTextEdit.h \ 1069 1070 src/logviewer/UIVMLogViewerWidget.h \ 1071 src/medium/UIFDCreationDialog.h \ 1070 1072 src/medium/UIMediumEnumerator.h \ 1071 1073 src/medium/UIMediumSelector.h \ … … 1471 1473 src/logviewer/UIVMLogViewerTextEdit.cpp \ 1472 1474 src/logviewer/UIVMLogViewerWidget.cpp \ 1475 src/medium/UIFDCreationDialog.cpp \ 1473 1476 src/medium/UIMedium.cpp \ 1474 1477 src/medium/UIMediumDefs.cpp \ … … 1801 1804 src/logviewer/UIVMLogViewerTextEdit.cpp \ 1802 1805 src/logviewer/UIVMLogViewerWidget.cpp \ 1806 src/medium/UIFDCreationDialog.cpp \ 1803 1807 src/medium/UIMedium.cpp \ 1804 1808 src/medium/UIMediumDefs.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp
r72810 r72815 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI MachineSettingsSFDetailsclass implementation.3 * VBox Qt GUI - UIFDCreationDialog class implementation. 4 4 */ 5 5 … … 21 21 22 22 /* Qt includes */ 23 # include <QDir> 24 # include <QPushButton> 23 # include<QVBoxLayout> 25 24 26 25 /* Other includes */ 27 # include "UIMachineSettingsSFDetails.h" 26 # include "UIFDCreationDialog.h" 27 # include "UIFilePathSelector.h" 28 28 # include "VBoxGlobal.h" 29 29 … … 31 31 32 32 33 UIMachineSettingsSFDetails::UIMachineSettingsSFDetails(DialogType type, 34 bool fEnableSelector, /* for "permanent" checkbox */ 35 const QStringList &usedNames, 36 QWidget *pParent /* = 0 */) 37 : QIWithRetranslateUI2<QIDialog>(pParent) 38 , m_type(type) 39 , m_fUsePermanent(fEnableSelector) 40 , m_usedNames(usedNames) 33 UIFDCreationDialog::UIFDCreationDialog(QWidget *pParent /* = 0 */, 34 const QString &strMachineName /* = QString() */, 35 const QString &strMachineSettingsFilePath /* = QString() */) 36 : QIWithRetranslateUI<QDialog>(pParent) 37 , m_pFilePathselector(0) 38 , m_strMachineName(strMachineName) 39 , m_strMachineSettingsFilePath(strMachineSettingsFilePath) 41 40 { 42 /* Apply UI decorations: */43 Ui::UIMachineSettingsSFDetails::setupUi(this);44 41 45 /* Setup widgets: */ 46 mPsPath->setResetEnabled(false); 47 mPsPath->setHomeDir(QDir::homePath()); 48 mCbPermanent->setHidden(!fEnableSelector); 49 50 /* Setup connections: */ 51 connect(mPsPath, SIGNAL(currentIndexChanged(int)), this, SLOT(sltSelectPath())); 52 connect(mPsPath, SIGNAL(pathChanged(const QString &)), this, SLOT(sltSelectPath())); 53 connect(mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(sltValidate())); 54 if (fEnableSelector) 55 connect(mCbPermanent, SIGNAL(toggled(bool)), this, SLOT(sltValidate())); 56 57 /* Applying language settings: */ 58 retranslateUi(); 59 60 /* Validate the initial field values: */ 61 sltValidate(); 62 42 prepare(); 63 43 /* Adjust dialog size: */ 64 44 adjustSize(); … … 70 50 } 71 51 72 void UI MachineSettingsSFDetails::setPath(const QString &strPath)52 void UIFDCreationDialog::retranslateUi() 73 53 { 74 mPsPath->setPath(strPath); 54 75 55 } 76 56 77 QString UIMachineSettingsSFDetails::path() const 57 void UIFDCreationDialog::prepare() 78 58 { 79 return mPsPath->path(); 80 } 59 setWindowModality(Qt::WindowModal); 81 60 82 void UIMachineSettingsSFDetails::setName(const QString &strName) 83 { 84 mLeName->setText(strName);85 } 61 QVBoxLayout *pMainLayout = new QVBoxLayout; 62 if (!pMainLayout) 63 return; 64 setLayout(pMainLayout); 86 65 87 QString UIMachineSettingsSFDetails::name() const 88 { 89 return mLeName->text(); 90 } 91 92 void UIMachineSettingsSFDetails::setWriteable(bool fWritable) 93 { 94 mCbReadonly->setChecked(!fWritable); 95 } 96 97 bool UIMachineSettingsSFDetails::isWriteable() const 98 { 99 return !mCbReadonly->isChecked(); 100 } 101 102 void UIMachineSettingsSFDetails::setAutoMount(bool fAutoMount) 103 { 104 mCbAutoMount->setChecked(fAutoMount); 105 } 106 107 bool UIMachineSettingsSFDetails::isAutoMounted() const 108 { 109 return mCbAutoMount->isChecked(); 110 } 111 112 void UIMachineSettingsSFDetails::setPermanent(bool fPermanent) 113 { 114 mCbPermanent->setChecked(fPermanent); 115 } 116 117 bool UIMachineSettingsSFDetails::isPermanent() const 118 { 119 return m_fUsePermanent ? mCbPermanent->isChecked() : true; 120 } 121 122 void UIMachineSettingsSFDetails::retranslateUi() 123 { 124 /* Translate uic generated strings: */ 125 Ui::UIMachineSettingsSFDetails::retranslateUi(this); 126 127 switch (m_type) 66 m_pFilePathselector = new UIFilePathSelector; 67 if (m_pFilePathselector) 128 68 { 129 case AddType: 130 setWindowTitle(tr("Add Share")); 131 break; 132 case EditType: 133 setWindowTitle(tr("Edit Share")); 134 break; 135 default: 136 AssertMsgFailed(("Incorrect shared-folders dialog type: %d\n", m_type)); 69 pMainLayout->addWidget(m_pFilePathselector); 70 m_pFilePathselector->setMode(UIFilePathSelector::Mode_File_Save); 137 71 } 138 72 } 139 140 void UIMachineSettingsSFDetails::sltValidate()141 {142 mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!mPsPath->path().isEmpty() &&143 QDir(mPsPath->path()).exists() &&144 !mLeName->text().trimmed().isEmpty() &&145 !mLeName->text().contains(" ") &&146 !m_usedNames.contains(mLeName->text()));147 }148 149 void UIMachineSettingsSFDetails::sltSelectPath()150 {151 if (!mPsPath->isPathSelected())152 return;153 154 QString strFolderName(mPsPath->path());155 #if defined (VBOX_WS_WIN) || defined (Q_OS_OS2)156 if (strFolderName[0].isLetter() && strFolderName[1] == ':' && strFolderName[2] == 0)157 {158 /* UIFilePathSelector returns root path as 'X:', which is invalid path.159 * Append the trailing backslash to get a valid root path 'X:\': */160 strFolderName += "\\";161 mPsPath->setPath(strFolderName);162 }163 #endif /* VBOX_WS_WIN || Q_OS_OS2 */164 QDir folder(strFolderName);165 if (!folder.isRoot())166 {167 /* Processing non-root folder */168 mLeName->setText(folder.dirName().replace(' ', '_'));169 }170 else171 {172 /* Processing root folder: */173 #if defined (VBOX_WS_WIN) || defined (Q_OS_OS2)174 mLeName->setText(strFolderName.toUpper()[0] + "_DRIVE");175 #elif defined (VBOX_WS_X11)176 mLeName->setText("ROOT");177 #endif178 }179 /* Validate the field values: */180 sltValidate();181 }182 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.h
r72810 r72815 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI MachineSettingsSFDetailsclass declaration.3 * VBox Qt GUI - UIFDCreationDialog class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef __UI MachineSettingsSFDetails_h__19 #define __UI MachineSettingsSFDetails_h__18 #ifndef __UIFDCreationDialog_h__ 19 #define __UIFDCreationDialog_h__ 20 20 21 /* Includes */ 22 #include "UIMachineSettingsSFDetails.gen.h" 23 #include "QIDialog.h" 21 /* Qt includes: */ 22 #include <QDialog> 23 24 25 /* GUI Includes */ 24 26 #include "QIWithRetranslateUI.h" 25 #include "UIMachineSettingsSF.h"26 27 27 /* Shared folders details dialog: */ 28 class SHARED_LIBRARY_STUFF UIMachineSettingsSFDetails : public QIWithRetranslateUI2<QIDialog>, 29 public Ui::UIMachineSettingsSFDetails 28 /* Forward declarations: */ 29 class UIFilePathSelector; 30 31 /* A QDialog extension to get necessary setting from the user for floppy disk creation */ 32 class SHARED_LIBRARY_STUFF UIFDCreationDialog : public QIWithRetranslateUI<QDialog> 33 30 34 { 31 35 Q_OBJECT; 32 36 37 33 38 public: 34 39 35 enum DialogType 36 { 37 AddType, 38 EditType 39 }; 40 41 UIMachineSettingsSFDetails(DialogType type, 42 bool fEnableSelector, /* for "permanent" checkbox */ 43 const QStringList &usedNames, 44 QWidget *pParent = 0); 45 46 void setPath(const QString &strPath); 47 QString path() const; 48 49 void setName(const QString &strName); 50 QString name() const; 51 52 void setWriteable(bool fWriteable); 53 bool isWriteable() const; 54 55 void setAutoMount(bool fAutoMount); 56 bool isAutoMounted() const; 57 58 void setPermanent(bool fPermanent); 59 bool isPermanent() const; 40 UIFDCreationDialog(QWidget *pParent = 0, 41 const QString &strMachineName = QString(), 42 const QString &strMachineSettingsFilePath = QString() 43 ); 60 44 61 45 protected: … … 65 49 private slots: 66 50 67 void sltSelectPath();68 void sltValidate();69 51 70 52 private: 71 53 72 DialogType m_type; 73 bool m_fUsePermanent; 74 QStringList m_usedNames; 54 void prepare(); 55 56 UIFilePathSelector *m_pFilePathselector; 57 QString m_strMachineName; 58 QString m_strMachineSettingsFilePath; 75 59 }; 76 60 77 #endif // __UI MachineSettingsSFDetails_h__61 #endif // __UIFDCreationDialog_h__ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r72698 r72815 29 29 # include "QIComboBox.h" 30 30 # include "QIDialogButtonBox.h" 31 # include "QIFileDialog.h" 31 32 # include "QILineEdit.h" 32 33 # include "QIMessageBox.h" … … 36 37 # include "UIDesktopWidgetWatchdog.h" 37 38 # include "UIExtraDataManager.h" 39 # include "UIFDCreationDialog.h" 38 40 # include "UIMediumSelector.h" 41 # include "UIMessageCenter.h" 39 42 # include "UIIconPool.h" 40 43 # include "UIMedium.h" … … 146 149 147 150 148 UIMediumSelector::UIMediumSelector(UIMediumType enmMediumType, QWidget *pParent /* = 0 */) 151 UIMediumSelector::UIMediumSelector(UIMediumType enmMediumType, const QString &machineName /* = QString() */, 152 const QString &machineSettigFilePath /* = QString() */, QWidget *pParent /* = 0 */) 149 153 :QIWithRetranslateUI<QIDialog>(pParent) 150 154 , m_pMainLayout(0) … … 154 158 , m_pToolBar(0) 155 159 , m_pActionAdd(0) 160 , m_pActionCreate(0) 156 161 , m_pActionRefresh(0) 157 162 , m_pAttachedSubTreeRoot(0) … … 159 164 , m_pParent(pParent) 160 165 , m_pSearchWidget(0) 166 , m_strMachineSettingsFilePath(machineSettigFilePath) 167 , m_strMachineName(machineName) 161 168 { 162 169 configure(); … … 188 195 m_pActionAdd->setStatusTip(QApplication::translate("UIMediumManager", "Add disk image file")); 189 196 } 197 198 if (m_pActionCreate) 199 { 200 m_pActionCreate->setText(QApplication::translate("UIMediumManager", "&Create")); 201 m_pActionCreate->setToolTip(QApplication::translate("UIMediumManager", "Create an Empty Disk Image")); 202 m_pActionCreate->setStatusTip(QApplication::translate("UIMediumManager", "Create an Empty Disk Image")); 203 } 204 190 205 if (m_pActionRefresh) 191 206 { … … 218 233 void UIMediumSelector::prepareActions() 219 234 { 235 QString strPrefix("hd"); 236 switch (m_enmMediumType) 237 { 238 case UIMediumType_DVD: 239 strPrefix = "cd"; 240 break; 241 case UIMediumType_Floppy: 242 strPrefix = "fd"; 243 break; 244 case UIMediumType_HardDisk: 245 case UIMediumType_All: 246 case UIMediumType_Invalid: 247 default: 248 strPrefix = "hd"; 249 break; 250 } 251 220 252 m_pActionAdd = new QAction(this); 221 253 if (m_pActionAdd) … … 223 255 /* Configure add-action: */ 224 256 m_pActionAdd->setShortcut(QKeySequence("Ctrl+A")); 225 QString strPrefix("hd");226 switch (m_enmMediumType)227 {228 case UIMediumType_DVD:229 strPrefix = "cd";230 break;231 case UIMediumType_Floppy:232 strPrefix = "fd";233 break;234 case UIMediumType_HardDisk:235 case UIMediumType_All:236 case UIMediumType_Invalid:237 default:238 strPrefix = "hd";239 break;240 }241 257 242 258 m_pActionAdd->setIcon(UIIconPool::iconSetFull(QString(":/%1_add_22px.png").arg(strPrefix), … … 245 261 QString(":/%1_add_disabled_16px.png").arg(strPrefix))); 246 262 } 263 264 /* Currently create is supported only for Floppy: */ 265 if (m_enmMediumType == UIMediumType_Floppy) 266 { 267 m_pActionCreate = new QAction(this); 268 } 269 if (m_pActionCreate) 270 { 271 272 m_pActionCreate->setShortcut(QKeySequence("Ctrl+C")); 273 m_pActionCreate->setIcon(UIIconPool::iconSetFull(QString(":/%1_add_22px.png").arg(strPrefix), 274 QString(":/%1_add_16px.png").arg(strPrefix), 275 QString(":/%1_add_disabled_22px.png").arg(strPrefix), 276 QString(":/%1_add_disabled_16px.png").arg(strPrefix))); 277 } 278 247 279 248 280 m_pActionRefresh = new QAction(this); … … 267 299 if (m_pActionAdd) 268 300 connect(m_pActionAdd, &QAction::triggered, this, &UIMediumSelector::sltAddMedium); 301 if (m_pActionCreate) 302 connect(m_pActionCreate, &QAction::triggered, this, &UIMediumSelector::sltCreateMedium); 269 303 if (m_pActionRefresh) 270 304 connect(m_pActionRefresh, &QAction::triggered, this, &UIMediumSelector::sltHandleRefresh); … … 397 431 if (m_pActionAdd) 398 432 m_pToolBar->addAction(m_pActionAdd); 433 if (m_pActionCreate) 434 m_pToolBar->addAction(m_pActionCreate); 399 435 if (m_pActionRefresh) 400 436 m_pToolBar->addAction(m_pActionRefresh); … … 439 475 QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 440 476 vboxGlobal().openMediumWithFileOpenDialog(m_enmMediumType, this, strDefaultMachineFolder); 477 } 478 479 480 void UIMediumSelector::sltCreateMedium() 481 { 482 483 UIFDCreationDialog *pDialog = new UIFDCreationDialog(this, m_strMachineSettingsFilePath, m_strMachineName); 484 pDialog->exec(); 485 486 // QVector<CMediumFormat> mediumFormats = vboxGlobal().getFormatsForDeviceType(UIMediumDefs::mediumTypeToGlobal(m_enmMediumType)); 487 // if (mediumFormats.isEmpty()) 488 // return; 489 // QString strMachineFolder = QFileInfo(m_strMachineSettingsFilePath).absolutePath(); 490 // QString strMediumPath =vboxGlobal().getNewMediumPath(m_enmMediumType, this, 491 // strMachineFolder, m_strMachineName); 492 // if (strMediumPath.isEmpty()) 493 // return; 494 // // 495 // CVirtualBox vbox = vboxGlobal().virtualBox(); 496 497 // CMedium newMedium = vbox.CreateMedium(mediumFormats[0].GetName(), strMediumPath, 498 // KAccessMode_ReadWrite, UIMediumDefs::mediumTypeToGlobal(m_enmMediumType)); 499 // if (!vbox.isOk()) 500 // { 501 // msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this); 502 // return; 503 // } 504 505 441 506 } 442 507 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h
r72444 r72815 48 48 public: 49 49 50 UIMediumSelector(UIMediumType enmMediumType, QWidget *pParent = 0); 50 UIMediumSelector(UIMediumType enmMediumType, const QString &machineName = QString(), 51 const QString &machineSettigFilePath = QString(), QWidget *pParent = 0); 51 52 QStringList selectedMediumIds() const; 52 53 … … 58 59 59 60 void sltAddMedium(); 61 void sltCreateMedium(); 60 62 void sltHandleItemSelectionChanged(); 61 63 void sltHandleMediumEnumerationStart(); … … 98 100 void saveDefaultForeground(); 99 101 102 100 103 QVBoxLayout *m_pMainLayout; 101 104 QITreeWidget *m_pTreeWidget; … … 104 107 UIToolBar *m_pToolBar; 105 108 QAction *m_pActionAdd; 109 QAction *m_pActionCreate; 106 110 QAction *m_pActionRefresh; 107 111 /** All the known media that are already attached to some vm are added under the following top level tree item */ … … 113 117 QList<UIMediumItem*> m_mediumItemList; 114 118 QBrush m_defaultItemForeground; 115 119 QString m_strMachineSettingsFilePath; 120 QString m_strMachineName; 116 121 }; 117 122 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r72406 r72815 2193 2193 m_strMachineId = m_machine.GetId(); 2194 2194 m_strMachineSettingsFilePath = m_machine.GetSettingsFilePath(); 2195 m_strMachineName = m_machine.GetName(); 2195 2196 m_strMachineGuestOSTypeId = m_machine.GetOSTypeId(); 2196 2197 … … 3797 3798 { 3798 3799 QWidget *pParent = windowManager().realParentWindow(this); 3799 QPointer<UIMediumSelector> pSelector = new UIMediumSelector(enmMediumType, pParent); 3800 QPointer<UIMediumSelector> pSelector = new UIMediumSelector(enmMediumType, m_strMachineName, 3801 m_strMachineSettingsFilePath, pParent); 3800 3802 3801 3803 if (!pSelector) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r72406 r72815 797 797 /** Holds the machine settings file-path. */ 798 798 QString m_strMachineSettingsFilePath; 799 /** Holds the machine settings file-path. */ 800 QString m_strMachineName; 799 801 /** Holds the machine guest OS type ID. */ 800 802 QString m_strMachineGuestOSTypeId;
Note:
See TracChangeset
for help on using the changeset viewer.