Changeset 945 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 16, 2007 7:19:52 AM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r815 r945 144 144 145 145 int confirmHardDiskUnregister (QWidget *parent, const QString &src); 146 146 147 147 void cannotCreateHardDiskImage ( 148 148 QWidget *parent, const CVirtualBox &vbox, const QString &src, … … 164 164 void cannotGetMediaAccessibility (const CUnknown &unk); 165 165 166 /// @todo (r=dmik) later 166 /// @todo (r=dmik) later 167 167 // void cannotMountMedia (const CUnknown &unk); 168 168 // void cannotUnmountMedia (const CUnknown &unk); … … 183 183 void cannotAttachUSBDevice (const CConsole &console, const QString &device); 184 184 void cannotDetachUSBDevice (const CConsole &console, const QString &device); 185 186 void cannotCreateSharedFolder (QWidget *, const CMachine &, 187 const QString &, const QString &); 188 void cannotRemoveSharedFolder (QWidget *, const CMachine &, 189 const QString &, const QString &); 185 190 186 191 bool confirmReleaseImage (QWidget*, QString); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r815 r945 548 548 /* preserve the current error info before calling the object again */ 549 549 COMErrorInfo errInfo = machine.errorInfo(); 550 550 551 551 message (parent ? parent : mainWindowShown(), Error, 552 552 tr ("Failed to save the settings of the virtual machine <b>%1</b>.") … … 823 823 QString msg; 824 824 QString name; 825 825 826 826 if (machine.GetAccessible()) 827 827 { … … 844 844 .arg (name); 845 845 } 846 846 847 847 return messageYesNo (&vboxGlobal().selectorWnd(), Question, msg); 848 848 } … … 898 898 "<nobr><b>%1</b>?</nobr></p>" 899 899 "<p>If you select <b>No</b> then the virtual hard disk will be " 900 "unregistered and removed from the collection, but the image file " 900 "unregistered and removed from the collection, but the image file " 901 901 "will be left on your physical disk.</p>" 902 902 "<p>If you select <b>Yes</b> then the image file will be permanently " … … 983 983 984 984 Assert (!media.isNull()); 985 985 986 986 message (parent, Error, 987 987 tr ("Failed to register the %1 <nobr><b>%2</b></nobr>.") … … 1141 1141 .arg (console.GetMachine().GetName()), 1142 1142 formatErrorInfo (errInfo)); 1143 } 1144 1145 void VBoxProblemReporter::cannotCreateSharedFolder (QWidget *aParent, 1146 const CMachine &aMachine, 1147 const QString &aName, 1148 const QString &aPath) 1149 { 1150 /* preserve the current error info before calling the object again */ 1151 COMErrorInfo errInfo = aMachine.errorInfo(); 1152 1153 message (aParent, Error, 1154 tr ("Failed to create shared folder <b>%1</b> " 1155 "with path <b>%2</b> " 1156 "for the virtual machine <b>%3</b>.") 1157 .arg (aName) 1158 .arg (aPath) 1159 .arg (aMachine.GetName()), 1160 formatErrorInfo (errInfo)); 1161 } 1162 1163 void VBoxProblemReporter::cannotRemoveSharedFolder (QWidget *aParent, 1164 const CMachine &aMachine, 1165 const QString &aName, 1166 const QString &aPath) 1167 { 1168 /* preserve the current error info before calling the object again */ 1169 COMErrorInfo errInfo = aMachine.errorInfo(); 1170 1171 message (aParent, Error, 1172 tr ("Failed to remove shared folder <b>%1</b> " 1173 "with path <b>%2</b> " 1174 "from the virtual machine <b>%3</b>.") 1175 .arg (aName) 1176 .arg (aPath) 1177 .arg (aMachine.GetName()), 1178 formatErrorInfo (errInfo)); 1143 1179 } 1144 1180 … … 1339 1375 severity = tr ("<nobr>Warning</nobr>", "runtime error info"); 1340 1376 } 1341 1377 1342 1378 QString formatted; 1343 1379 … … 1359 1395 .arg (tr ("Severity: ", "runtime error info"), 1360 1396 severity); 1361 1397 1362 1398 if (!formatted.isEmpty()) 1363 1399 formatted = "<qt>" + formatted + "</qt>"; 1364 1400 1365 1401 int rc = 0; 1366 1402 … … 1373 1409 "further examination:</p>"), 1374 1410 formatted); 1375 1411 1376 1412 /* always power down after a fatal error */ 1377 1413 console.PowerDown(); -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui
r934 r945 176 176 <include location="local" impldecl="in declaration">VBoxGlobal.h</include> 177 177 <include location="local" impldecl="in implementation">VBoxUtils.h</include> 178 <include location="local" impldecl="in implementation">VBoxProblemReporter.h</include> 178 179 <include location="global" impldecl="in implementation">qfiledialog.h</include> 179 180 <include location="global" impldecl="in implementation">qlabel.h</include> … … 182 183 </includes> 183 184 <variables> 184 <variable access="private">bool isListViewChanged;</variable>185 <variable access="private">bool mIsListViewChanged;</variable> 185 186 </variables> 186 187 <slots> 187 188 <slot>tbAddPressed()</slot> 188 189 <slot>tbRemovePressed()</slot> 189 <slot>processCurrentChanged( QListViewItem * )</slot> 190 <slot>processOnItem( QListViewItem* )</slot> 191 <slot>processCurrentChanged( QListViewItem* )</slot> 190 192 </slots> 191 193 <functions> … … 194 196 <function>getFromMachine( const CMachine & )</function> 195 197 <function>getFromConsole( const CConsole & )</function> 196 <function access="private"> loadFrom( const CSharedFolderEnumerator & )</function>198 <function access="private">getFrom( const CSharedFolderEnumerator & )</function> 197 199 <function>putBackToGlobal()</function> 198 200 <function>putBackToMachine( CMachine & )</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h
r934 r945 101 101 case EllipsisFile: 102 102 { 103 QRegExp regExp ("([\\ /][^\\^/]+[\\/]?$)");103 QRegExp regExp ("([\\\\/][^\\\\^/]+[\\\\/]?$)"); 104 104 int newFinish = regExp.search (oneString); 105 105 if (newFinish != -1) … … 196 196 void showFileDialog() 197 197 { 198 QString folderName = QFileDialog::getExistingDirectory ( 199 QDir::rootDirPath(), 200 this, "AddSharedFolderDialog", 201 tr ("Select a folder to share"), 202 false /* show dir only */); 203 /* compose folder path */ 204 mLePath->setText (folderName); 205 /* compose folder name */ 206 QRegExp regExp ("[\\/]([^\\^/]+)[\\/]?$"); 207 int lastFolderPos = regExp.search (folderName); 208 if (lastFolderPos != -1) 209 mLeName->setText (regExp.cap (1)); 198 QFileDialog dlg (QDir::rootDirPath(), QString::null, this); 199 dlg.setMode (QFileDialog::DirectoryOnly); 200 dlg.setCaption (tr ("Add Share")); 201 if (dlg.exec() == QDialog::Accepted) 202 { 203 QString folderName = QDir::convertSeparators (dlg.selectedFile()); 204 QRegExp commonRule ("[\\\\/]([^\\\\^/]+)[\\\\/]?$"); 205 QRegExp rootRule ("(([a-zA-Z])[^\\\\^/])?[\\\\/]$"); 206 if (commonRule.search (folderName) != -1) 207 { 208 /* processing non-root folder */ 209 mLePath->setText (folderName.remove (QRegExp ("[\\\\/]$"))); 210 mLeName->setText (commonRule.cap (1)); 211 } 212 else if (rootRule.search (folderName) != -1) 213 { 214 /* processing root folder */ 215 mLePath->setText (folderName); 216 #if defined(Q_WS_WIN32) 217 mLeName->setText (rootRule.cap (2) + "_DRIVE"); 218 #elif defined(Q_WS_X11) 219 mLeName->setText ("ROOT"); 220 #endif 221 } 222 else 223 return; /* hm, what type of folder it was? */ 224 } 210 225 } 211 226 … … 227 242 { 228 243 new QIListViewSelectionPreserver (this, listView); 244 listView->setShowToolTips (false); 229 245 tbAdd->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png", 230 246 "select_file_dis_16px.png")); … … 235 251 connect (listView, SIGNAL (currentChanged (QListViewItem *)), 236 252 this, SLOT (processCurrentChanged (QListViewItem *))); 237 238 isListViewChanged = false; 253 connect (listView, SIGNAL (onItem (QListViewItem *)), 254 this, SLOT (processOnItem (QListViewItem *))); 255 256 mIsListViewChanged = false; 239 257 } 240 258 … … 242 260 void VBoxSharedFoldersSettings::getFromGlobal() 243 261 { 244 loadFrom (vboxGlobal().virtualBox().GetSharedFolders().Enumerate());262 getFrom (vboxGlobal().virtualBox().GetSharedFolders().Enumerate()); 245 263 } 246 264 247 265 void VBoxSharedFoldersSettings::getFromMachine (const CMachine &aMachine) 248 266 { 249 loadFrom (aMachine.GetSharedFolders().Enumerate());267 getFrom (aMachine.GetSharedFolders().Enumerate()); 250 268 } 251 269 252 270 void VBoxSharedFoldersSettings::getFromConsole (const CConsole &aConsole) 253 271 { 254 loadFrom (aConsole.GetSharedFolders().Enumerate());255 } 256 257 void VBoxSharedFoldersSettings:: loadFrom (const CSharedFolderEnumerator &aEn)272 getFrom (aConsole.GetSharedFolders().Enumerate()); 273 } 274 275 void VBoxSharedFoldersSettings::getFrom (const CSharedFolderEnumerator &aEn) 258 276 { 259 277 while (aEn.HasMore()) … … 277 295 { 278 296 /* first deleting all existing folders if the list is changed */ 279 if ( isListViewChanged)297 if (mIsListViewChanged) 280 298 { 281 299 CSharedFolderEnumerator en = aMachine.GetSharedFolders().Enumerate(); 282 300 while (en.HasMore()) 283 aMachine.RemoveSharedFolder (en.GetNext().GetName()); 301 { 302 CSharedFolder sf = en.GetNext(); 303 const QString &name = sf.GetName(); 304 const QString &path = sf.GetHostPath(); 305 aMachine.RemoveSharedFolder (name); 306 if (!aMachine.isOk()) 307 vboxProblem().cannotRemoveSharedFolder (this, aMachine, 308 name, path); 309 } 284 310 } 285 311 else return; … … 293 319 item = static_cast<VBoxRichListItem*> (it.current()); 294 320 if (item) 321 { 295 322 aMachine.CreateSharedFolder (item->getText (0), item->getText (1)); 323 if (!aMachine.isOk()) 324 vboxProblem().cannotCreateSharedFolder (this, aMachine, 325 item->getText (0), 326 item->getText (1)); 327 } 296 328 else 297 329 AssertMsgFailed (("Incorrect listview item type\n")); … … 309 341 void VBoxSharedFoldersSettings::tbAddPressed() 310 342 { 343 /* Invoke Add-Box Dialog */ 311 344 VBoxAddSFDialog dlg (this); 312 345 if (dlg.exec() != QDialog::Accepted) … … 319 352 VBoxRichListItem *item = new VBoxRichListItem (VBoxRichListItem::EllipsisFile, 320 353 listView, name, path); 354 listView->ensureItemVisible (item); 321 355 listView->setCurrentItem (item); 322 356 processCurrentChanged (item); 323 357 listView->setFocus(); 324 isListViewChanged = true;358 mIsListViewChanged = true; 325 359 } 326 360 … … 329 363 Assert (listView->selectedItem()); 330 364 delete listView->selectedItem(); 331 isListViewChanged = true; 332 } 333 365 mIsListViewChanged = true; 366 } 367 368 369 void VBoxSharedFoldersSettings::processOnItem (QListViewItem *aItem) 370 { 371 VBoxRichListItem *item = 0; 372 if (aItem->rtti() == VBoxRichListItem::QIRichListItemId) 373 item = static_cast<VBoxRichListItem*> (aItem); 374 Assert (item); 375 QString tip = tr ("<nobr>Name: %1</nobr><br><nobr>Path: %2</nobr>") 376 .arg (item->getText (0)).arg (item->getText (1)); 377 QToolTip::add (listView->viewport(), listView->itemRect (aItem), tip); 378 } 334 379 335 380 void VBoxSharedFoldersSettings::processCurrentChanged (QListViewItem *aItem)
Note:
See TracChangeset
for help on using the changeset viewer.