Changeset 85961 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 31, 2020 4:30:54 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.cpp
r85679 r85961 32 32 33 33 UIMachineSettingsSFDetails::UIMachineSettingsSFDetails(SFDialogType type, 34 bool f EnableSelector, /* for "permanent" checkbox */34 bool fUsePermanent, 35 35 const QStringList &usedNames, 36 36 QWidget *pParent /* = 0 */) 37 37 : QIWithRetranslateUI2<QIDialog>(pParent) 38 38 , m_type(type) 39 , m_fUsePermanent(f EnableSelector)39 , m_fUsePermanent(fUsePermanent) 40 40 , m_usedNames(usedNames) 41 , m_pPathSelector(0) 42 , m_pPermanentCheckBox(0) 43 , m_pNameLineEdit(0) 41 , m_pCache(0) 42 , m_pLabelPath(0) 43 , m_pSelectorPath(0) 44 , m_pLabelName(0) 45 , m_pEditorName(0) 46 , m_pLabelAutoMountPoint(0) 47 , m_pEditorAutoMountPoint(0) 44 48 , m_pReadonlyCheckBox(0) 45 49 , m_pAutoMountCheckBox(0) 46 , m_pAutoMountPointLineEdit(0) 47 , m_pPathLabel(0) 48 , m_pNameLabel(0) 49 , m_pAutoMountPointLabel(0) 50 , m_pPermanentCheckBox(0) 50 51 , m_pButtonBox(0) 51 52 { 52 prepareWidgets(); 53 54 /* Setup widgets: */ 55 m_pPathSelector->setResetEnabled(false); 56 m_pPathSelector->setHomeDir(QDir::homePath()); 57 m_pPermanentCheckBox->setHidden(!fEnableSelector); 58 59 /* Setup connections: */ 60 connect(m_pPathSelector, static_cast<void(UIFilePathSelector::*)(int)>(&UIFilePathSelector::currentIndexChanged), 61 this, &UIMachineSettingsSFDetails::sltSelectPath); 62 connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIMachineSettingsSFDetails::sltSelectPath); 63 connect(m_pNameLineEdit, &QLineEdit::textChanged, this, &UIMachineSettingsSFDetails::sltValidate); 64 if (fEnableSelector) 65 connect(m_pPermanentCheckBox, &QCheckBox::toggled, this, &UIMachineSettingsSFDetails::sltValidate); 66 67 /* Applying language settings: */ 68 retranslateUi(); 69 70 /* Validate the initial field values: */ 71 sltValidate(); 72 73 /* Adjust dialog size: */ 74 adjustSize(); 75 76 #ifdef VBOX_WS_MAC 77 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 78 setFixedSize(minimumSize()); 79 #endif /* VBOX_WS_MAC */ 80 } 81 82 void UIMachineSettingsSFDetails::prepareWidgets() 83 { 84 if (objectName().isEmpty()) 85 setObjectName(QStringLiteral("UIMachineSettingsSFDetails")); 86 resize(218, 196); 87 QGridLayout *gridLayout = new QGridLayout(this); 88 gridLayout->setObjectName(QStringLiteral("gridLayout")); 89 m_pPathLabel = new QLabel; 90 m_pPathLabel->setObjectName(QStringLiteral("m_pPathLabel")); 91 m_pPathLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 92 93 gridLayout->addWidget(m_pPathLabel, 0, 0, 1, 1); 94 95 m_pPathSelector = new UIFilePathSelector; 96 m_pPathSelector->setObjectName(QStringLiteral("m_pPathSelector")); 97 gridLayout->addWidget(m_pPathSelector, 0, 1, 1, 1); 98 99 m_pNameLabel = new QLabel; 100 m_pNameLabel->setObjectName(QStringLiteral("m_pNameLabel")); 101 m_pNameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 102 gridLayout->addWidget(m_pNameLabel, 1, 0, 1, 1); 103 104 m_pNameLineEdit = new QLineEdit; 105 m_pNameLineEdit->setObjectName(QStringLiteral("m_pNameLineEdit")); 106 gridLayout->addWidget(m_pNameLineEdit, 1, 1, 1, 1); 107 108 m_pReadonlyCheckBox = new QCheckBox; 109 m_pReadonlyCheckBox->setObjectName(QStringLiteral("m_pReadonlyCheckBox")); 110 gridLayout->addWidget(m_pReadonlyCheckBox, 2, 1, 1, 1); 111 112 m_pAutoMountCheckBox = new QCheckBox; 113 m_pAutoMountCheckBox->setObjectName(QStringLiteral("m_pAutoMountCheckBox")); 114 gridLayout->addWidget(m_pAutoMountCheckBox, 3, 1, 1, 1); 115 116 m_pAutoMountPointLabel = new QLabel; 117 m_pAutoMountPointLabel->setObjectName(QStringLiteral("m_pAutoMountPointLabel")); 118 m_pAutoMountPointLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 119 gridLayout->addWidget(m_pAutoMountPointLabel, 4, 0, 1, 1); 120 121 m_pAutoMountPointLineEdit = new QLineEdit; 122 m_pAutoMountPointLineEdit->setObjectName(QStringLiteral("m_pAutoMountPointLineEdit")); 123 gridLayout->addWidget(m_pAutoMountPointLineEdit, 4, 1, 1, 1); 124 125 m_pPermanentCheckBox = new QCheckBox; 126 m_pPermanentCheckBox->setObjectName(QStringLiteral("m_pPermanentCheckBox")); 127 gridLayout->addWidget(m_pPermanentCheckBox, 5, 1, 1, 1); 128 129 QSpacerItem *spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); 130 gridLayout->addItem(spacerItem, 6, 1, 1, 1); 131 132 m_pButtonBox = new QIDialogButtonBox; 133 m_pButtonBox->setObjectName(QStringLiteral("m_pButtonBox")); 134 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok); 135 gridLayout->addWidget(m_pButtonBox, 7, 0, 1, 2); 136 137 138 QObject::connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMachineSettingsSFDetails::accept); 139 QObject::connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMachineSettingsSFDetails::reject); 140 } 141 53 prepare(); 54 } 142 55 143 56 void UIMachineSettingsSFDetails::setPath(const QString &strPath) 144 57 { 145 m_p PathSelector->setPath(strPath);58 m_pSelectorPath->setPath(strPath); 146 59 } 147 60 148 61 QString UIMachineSettingsSFDetails::path() const 149 62 { 150 return m_p PathSelector->path();63 return m_pSelectorPath->path(); 151 64 } 152 65 153 66 void UIMachineSettingsSFDetails::setName(const QString &strName) 154 67 { 155 m_p NameLineEdit->setText(strName);68 m_pEditorName->setText(strName); 156 69 } 157 70 158 71 QString UIMachineSettingsSFDetails::name() const 159 72 { 160 return m_p NameLineEdit->text();73 return m_pEditorName->text(); 161 74 } 162 75 … … 183 96 void UIMachineSettingsSFDetails::setAutoMountPoint(const QString &strAutoMountPoint) 184 97 { 185 m_p AutoMountPointLineEdit->setText(strAutoMountPoint);98 m_pEditorAutoMountPoint->setText(strAutoMountPoint); 186 99 } 187 100 188 101 QString UIMachineSettingsSFDetails::autoMountPoint() const 189 102 { 190 return m_p AutoMountPointLineEdit->text();103 return m_pEditorAutoMountPoint->text(); 191 104 } 192 105 … … 203 116 void UIMachineSettingsSFDetails::retranslateUi() 204 117 { 205 m_p PathLabel->setText(tr("Folder Path:"));206 m_p NameLabel->setText(tr("Folder Name:"));207 m_p NameLineEdit->setToolTip(tr("Holds the name of the shared folder (as it will be seen by the guest OS)."));118 m_pLabelPath->setText(tr("Folder Path:")); 119 m_pLabelName->setText(tr("Folder Name:")); 120 m_pEditorName->setToolTip(tr("Holds the name of the shared folder (as it will be seen by the guest OS).")); 208 121 m_pReadonlyCheckBox->setToolTip(tr("When checked, the guest OS will not be able to write to the specified shared folder.")); 209 122 m_pReadonlyCheckBox->setText(tr("&Read-only")); 210 123 m_pAutoMountCheckBox->setToolTip(tr("When checked, the guest OS will try to automatically mount the shared folder on startup.")); 211 124 m_pAutoMountCheckBox->setText(tr("&Auto-mount")); 212 m_p AutoMountPointLabel->setText(tr("Mount point:"));213 m_p AutoMountPointLineEdit->setToolTip(tr("Where to automatically mount the folder in the guest. A drive letter (e.g. 'G:') for Windows and OS/2 guests, path for the others. If left empty the guest will pick something fitting."));125 m_pLabelAutoMountPoint->setText(tr("Mount point:")); 126 m_pEditorAutoMountPoint->setToolTip(tr("Where to automatically mount the folder in the guest. A drive letter (e.g. 'G:') for Windows and OS/2 guests, path for the others. If left empty the guest will pick something fitting.")); 214 127 m_pPermanentCheckBox->setToolTip(tr("When checked, this shared folder will be permanent.")); 215 128 m_pPermanentCheckBox->setText(tr("&Make Permanent")); … … 230 143 void UIMachineSettingsSFDetails::sltValidate() 231 144 { 232 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!m_p PathSelector->path().isEmpty() &&233 QDir(m_p PathSelector->path()).exists() &&234 !m_p NameLineEdit->text().trimmed().isEmpty() &&235 !m_p NameLineEdit->text().contains(" ") &&236 !m_usedNames.contains(m_p NameLineEdit->text()));145 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!m_pSelectorPath->path().isEmpty() && 146 QDir(m_pSelectorPath->path()).exists() && 147 !m_pEditorName->text().trimmed().isEmpty() && 148 !m_pEditorName->text().contains(" ") && 149 !m_usedNames.contains(m_pEditorName->text())); 237 150 } 238 151 239 152 void UIMachineSettingsSFDetails::sltSelectPath() 240 153 { 241 if (!m_p PathSelector->isPathSelected())154 if (!m_pSelectorPath->isPathSelected()) 242 155 return; 243 156 244 QString strFolderName(m_p PathSelector->path());157 QString strFolderName(m_pSelectorPath->path()); 245 158 #if defined (VBOX_WS_WIN) || defined (Q_OS_OS2) 246 159 if (strFolderName[0].isLetter() && strFolderName[1] == ':' && strFolderName[2] == 0) … … 249 162 * Append the trailing backslash to get a valid root path 'X:\': */ 250 163 strFolderName += "\\"; 251 m_p PathSelector->setPath(strFolderName);164 m_pSelectorPath->setPath(strFolderName); 252 165 } 253 166 #endif /* VBOX_WS_WIN || Q_OS_OS2 */ … … 256 169 { 257 170 /* Processing non-root folder */ 258 m_p NameLineEdit->setText(folder.dirName().replace(' ', '_'));171 m_pEditorName->setText(folder.dirName().replace(' ', '_')); 259 172 } 260 173 else … … 262 175 /* Processing root folder: */ 263 176 #if defined (VBOX_WS_WIN) || defined (Q_OS_OS2) 264 m_p NameLineEdit->setText(strFolderName.toUpper()[0] + "_DRIVE");177 m_pEditorName->setText(strFolderName.toUpper()[0] + "_DRIVE"); 265 178 #elif defined (VBOX_WS_X11) 266 m_p NameLineEdit->setText("ROOT");179 m_pEditorName->setText("ROOT"); 267 180 #endif 268 181 } … … 270 183 sltValidate(); 271 184 } 185 186 void UIMachineSettingsSFDetails::prepare() 187 { 188 /* Prepare everything: */ 189 prepareWidgets(); 190 prepareConnections(); 191 192 /* Apply language settings: */ 193 retranslateUi(); 194 195 /* Validate the initial field values: */ 196 sltValidate(); 197 198 /* Adjust dialog size: */ 199 adjustSize(); 200 201 #ifdef VBOX_WS_MAC 202 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 203 setFixedSize(minimumSize()); 204 #endif /* VBOX_WS_MAC */ 205 } 206 207 void UIMachineSettingsSFDetails::prepareWidgets() 208 { 209 /* Prepare main layout: */ 210 QGridLayout *pLayoutMain = new QGridLayout(this); 211 if (pLayoutMain) 212 { 213 pLayoutMain->setRowStretch(6, 1); 214 215 /* Prepare path label: */ 216 m_pLabelPath = new QLabel; 217 if (m_pLabelPath) 218 { 219 m_pLabelPath->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 220 pLayoutMain->addWidget(m_pLabelPath, 0, 0); 221 } 222 /* Prepare path selector: */ 223 m_pSelectorPath = new UIFilePathSelector; 224 if (m_pSelectorPath) 225 { 226 m_pSelectorPath->setResetEnabled(false); 227 m_pSelectorPath->setHomeDir(QDir::homePath()); 228 229 pLayoutMain->addWidget(m_pSelectorPath, 0, 1); 230 } 231 232 /* Prepare name label: */ 233 m_pLabelName = new QLabel; 234 if (m_pLabelName) 235 { 236 m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 237 pLayoutMain->addWidget(m_pLabelName, 1, 0); 238 } 239 /* Prepare name editor: */ 240 m_pEditorName = new QLineEdit; 241 if (m_pEditorName) 242 pLayoutMain->addWidget(m_pEditorName, 1, 1); 243 244 /* Prepare auto-mount point: */ 245 m_pLabelAutoMountPoint = new QLabel; 246 if (m_pLabelAutoMountPoint) 247 { 248 m_pLabelAutoMountPoint->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 249 pLayoutMain->addWidget(m_pLabelAutoMountPoint, 2, 0); 250 } 251 /* Prepare auto-mount editor: */ 252 m_pEditorAutoMountPoint = new QLineEdit; 253 if (m_pEditorAutoMountPoint) 254 pLayoutMain->addWidget(m_pEditorAutoMountPoint, 2, 1); 255 256 /* Prepare read-only check-box: */ 257 m_pReadonlyCheckBox = new QCheckBox; 258 if (m_pReadonlyCheckBox) 259 pLayoutMain->addWidget(m_pReadonlyCheckBox, 3, 1); 260 /* Prepare auto-mount check-box: */ 261 m_pAutoMountCheckBox = new QCheckBox; 262 if (m_pAutoMountCheckBox) 263 pLayoutMain->addWidget(m_pAutoMountCheckBox, 4, 1); 264 /* Prepare permanent check-box: */ 265 m_pPermanentCheckBox = new QCheckBox; 266 if (m_pPermanentCheckBox) 267 { 268 m_pPermanentCheckBox->setHidden(!m_fUsePermanent); 269 pLayoutMain->addWidget(m_pPermanentCheckBox, 5, 1); 270 } 271 272 /* Prepare button-box: */ 273 m_pButtonBox = new QIDialogButtonBox; 274 if (m_pButtonBox) 275 { 276 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 277 pLayoutMain->addWidget(m_pButtonBox, 7, 0, 1, 2); 278 } 279 } 280 } 281 282 void UIMachineSettingsSFDetails::prepareConnections() 283 { 284 connect(m_pSelectorPath, static_cast<void(UIFilePathSelector::*)(int)>(&UIFilePathSelector::currentIndexChanged), 285 this, &UIMachineSettingsSFDetails::sltSelectPath); 286 connect(m_pSelectorPath, &UIFilePathSelector::pathChanged, this, &UIMachineSettingsSFDetails::sltSelectPath); 287 connect(m_pEditorName, &QLineEdit::textChanged, this, &UIMachineSettingsSFDetails::sltValidate); 288 if (m_fUsePermanent) 289 connect(m_pPermanentCheckBox, &QCheckBox::toggled, this, &UIMachineSettingsSFDetails::sltValidate); 290 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMachineSettingsSFDetails::accept); 291 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMachineSettingsSFDetails::reject); 292 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.h
r85645 r85961 47 47 48 48 UIMachineSettingsSFDetails(SFDialogType type, 49 bool f EnableSelector, /* for "permanent" checkbox */49 bool fUsePermanent, 50 50 const QStringList &usedNames, 51 51 QWidget *pParent = 0); … … 80 80 private: 81 81 82 /** Prepares all. */ 83 void prepare(); 84 /** Prepares widgets. */ 82 85 void prepareWidgets(); 86 /** Prepares connections. */ 87 void prepareConnections(); 83 88 84 89 SFDialogType m_type; … … 89 94 /** @name Widgets 90 95 * @{ */ 91 UIFilePathSelector *m_pPathSelector; 92 QCheckBox *m_pPermanentCheckBox; 93 QLineEdit *m_pNameLineEdit; 94 QCheckBox *m_pReadonlyCheckBox; 95 QCheckBox *m_pAutoMountCheckBox; 96 QLineEdit *m_pAutoMountPointLineEdit; 97 QLabel *m_pPathLabel; 98 QLabel *m_pNameLabel; 99 QLabel *m_pAutoMountPointLabel; 100 QIDialogButtonBox *m_pButtonBox; 96 /** Holds the path label instance. */ 97 QLabel *m_pLabelPath; 98 /** Holds the path selector instance. */ 99 UIFilePathSelector *m_pSelectorPath; 100 /** Holds the name label instance. */ 101 QLabel *m_pLabelName; 102 /** Holds the name editor instance. */ 103 QLineEdit *m_pEditorName; 104 /** Holds the auto-mount point label instance. */ 105 QLabel *m_pLabelAutoMountPoint; 106 /** Holds the auto-mount point editor instance. */ 107 QLineEdit *m_pEditorAutoMountPoint; 108 /** Holds the read-only check-box instance. */ 109 QCheckBox *m_pReadonlyCheckBox; 110 /** Holds the auto-mount check-box instance. */ 111 QCheckBox *m_pAutoMountCheckBox; 112 /** Holds the permanent check-box instance. */ 113 QCheckBox *m_pPermanentCheckBox; 114 /** Holds the button-box instance. */ 115 QIDialogButtonBox *m_pButtonBox; 101 116 /** @} */ 102 117 };
Note:
See TracChangeset
for help on using the changeset viewer.