Changeset 7342 in vbox
- Timestamp:
- Mar 6, 2008 6:35:43 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r7207 r7342 428 428 bool showVirtualBoxLicense(); 429 429 #endif 430 431 void checkForAutoConvertedSettings(); 430 432 431 433 CSession openSession (const QUuid &aId, bool aExisting = false); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r7207 r7342 129 129 130 130 void cannotOpenURL (const QString &aURL); 131 void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC); 131 132 132 133 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath); … … 135 136 void cannotInitCOM (HRESULT rc); 136 137 void cannotCreateVirtualBox (const CVirtualBox &vbox); 138 139 void cannotSaveGlobalSettings (const CVirtualBox &vbox, 140 QWidget *parent = 0); 137 141 138 142 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error); … … 259 263 bool remindAboutPausedVMInput(); 260 264 265 int warnAboutAutoConvertedSettings (const QString &aFormatVersion, 266 const QString &aFileList); 267 261 268 bool remindAboutInaccessibleMedia(); 262 269 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r7239 r7342 24 24 #include "VBoxProblemReporter.h" 25 25 #include "QIHotKeyEdit.h" 26 #include "QIMessageBox.h" 26 27 27 28 #ifdef VBOX_WITH_REGISTRATION … … 76 77 #include <iprt/path.h> 77 78 #include <iprt/env.h> 79 #include <iprt/file.h> 78 80 79 81 #if defined (Q_WS_X11) … … 1824 1826 } 1825 1827 #endif 1828 1829 /** 1830 * Checks if any of the settings files were auto-converted and informs the user 1831 * if so. 1832 */ 1833 void VBoxGlobal::checkForAutoConvertedSettings() 1834 { 1835 QString formatVersion = mVBox.GetSettingsFormatVersion(); 1836 1837 bool isGlobalConverted = false; 1838 QValueList <CMachine> machines; 1839 QString fileList; 1840 QString version; 1841 1842 CMachineVector vec = mVBox.GetMachines2(); 1843 for (CMachineVector::ConstIterator m = vec.begin(); 1844 m != vec.end(); ++ m) 1845 { 1846 if (!m->GetAccessible()) 1847 continue; 1848 1849 version = m->GetSettingsFileVersion(); 1850 if (version != formatVersion) 1851 { 1852 machines.append (*m); 1853 fileList += QString ("<nobr>%1 (<i>%2</i>)</nobr><br>") 1854 .arg (m->GetSettingsFilePath()) 1855 .arg (version); 1856 } 1857 } 1858 1859 version = mVBox.GetSettingsFileVersion(); 1860 if (version != formatVersion) 1861 { 1862 isGlobalConverted = true; 1863 fileList += QString ("<nobr>%1 (<i>%2</i>)</nobr><br>") 1864 .arg (mVBox.GetSettingsFilePath()) 1865 .arg (version); 1866 } 1867 1868 1869 if (!fileList.isNull()) 1870 { 1871 int rc = vboxProblem() 1872 .warnAboutAutoConvertedSettings (formatVersion, fileList); 1873 1874 if (rc == QIMessageBox::No) 1875 { 1876 /* create backup copies */ 1877 for (QValueList <CMachine>::Iterator m = machines.begin(); 1878 /* machines.end() means global config => manual loop break */ ;) 1879 { 1880 QString of, nf; 1881 1882 if (m == machines.end()) 1883 { 1884 if (!isGlobalConverted) 1885 break; 1886 of = mVBox.GetSettingsFilePath(); 1887 nf = QString ("%1.%2.bak").arg (of, mVBox.GetSettingsFileVersion()); 1888 } 1889 else 1890 { 1891 of = (*m).GetSettingsFilePath(); 1892 nf = QString ("%1.%2.bak").arg (of, (*m).GetSettingsFileVersion()); 1893 } 1894 1895 int vrc = RTFileCopyEx (of.utf8(), nf.utf8(), 1896 RTFILECOPY_FLAG_NO_DENY_WRITE, 1897 NULL, NULL); 1898 1899 /* try progressive suffix on failure */ 1900 if (vrc == VERR_ALREADY_EXISTS) 1901 { 1902 QString tmp = nf; 1903 for (int i = 0; i < 9 && RT_FAILURE (vrc); ++ i) 1904 { 1905 nf = QString ("%1.%2"). arg (tmp).arg (i); 1906 vrc = RTFileCopyEx (of.utf8(), nf.utf8(), 1907 RTFILECOPY_FLAG_NO_DENY_WRITE, 1908 NULL, NULL); 1909 } 1910 } 1911 1912 if (RT_FAILURE (vrc)) 1913 { 1914 vboxProblem().cannotCopyFile (of, nf, vrc); 1915 if (m == machines.end()) 1916 { 1917 /* remove from further processing */ 1918 isGlobalConverted = false; 1919 break; 1920 } 1921 else 1922 /* remove from further processing */ 1923 m = machines.remove (m); 1924 } 1925 else 1926 { 1927 if (m == machines.end()) 1928 break; 1929 ++ m; 1930 } 1931 } 1932 } 1933 1934 if (rc == QIMessageBox::Yes || rc == QIMessageBox::No) 1935 { 1936 /* save all settings files */ 1937 for (QValueList <CMachine>::Iterator m = machines.begin(); 1938 /* machines.end() means global config => manual loop break */ ;) 1939 { 1940 if (m == machines.end()) 1941 { 1942 if (isGlobalConverted) 1943 { 1944 mVBox.SaveSettings(); 1945 if (!mVBox.isOk()) 1946 vboxProblem().cannotSaveGlobalSettings (mVBox); 1947 } 1948 } 1949 else 1950 { 1951 CSession session = openSession ((*m).GetId()); 1952 if (!session.isNull()) 1953 { 1954 CMachine sm = session.GetMachine(); 1955 sm.SaveSettings(); 1956 if (!sm.isOk()) 1957 vboxProblem().cannotSaveMachineSettings (sm); 1958 session.Close(); 1959 } 1960 } 1961 1962 if (m == machines.end()) 1963 break; 1964 1965 ++ m; 1966 } 1967 } 1968 } 1969 } 1826 1970 1827 1971 /** … … 3803 3947 } 3804 3948 3805 / / initialize guest OS type vector3949 /* initialize guest OS type vector */ 3806 3950 CGuestOSTypeCollection coll = mVBox.GetGuestOSTypes(); 3807 3951 int osTypeCount = coll.GetCount(); … … 3816 3960 } 3817 3961 3818 / / fill in OS type icon dictionary3962 /* fill in OS type icon dictionary */ 3819 3963 static const char *osTypeIcons[][2] = 3820 3964 { … … 3843 3987 {"l4", "os_l4.png"}, 3844 3988 }; 3845 vm_os_type_icons.setAutoDelete (true); / / takes ownership of elements3989 vm_os_type_icons.setAutoDelete (true); /* takes ownership of elements */ 3846 3990 for (uint n = 0; n < SIZEOF_ARRAY (osTypeIcons); n ++) 3847 3991 { … … 3850 3994 } 3851 3995 3852 / / fill in VM state icon dictionary3996 /* fill in VM state icon dictionary */ 3853 3997 static struct 3854 3998 { … … 3878 4022 } 3879 4023 3880 / / online/offline snapshot icons4024 /* online/offline snapshot icons */ 3881 4025 mOfflineSnapshotIcon = QPixmap::fromMimeSource ("offline_snapshot_16px.png"); 3882 4026 mOnlineSnapshotIcon = QPixmap::fromMimeSource ("online_snapshot_16px.png"); 3883 4027 3884 / / initialize state colors vector3885 / / no ownership of elements, we're passing pointers to existing objects4028 /* initialize state colors vector */ 4029 /* no ownership of elements, we're passing pointers to existing objects */ 3886 4030 vm_state_color.insert (KMachineState_Null, &Qt::red); 3887 4031 vm_state_color.insert (KMachineState_PoweredOff, &Qt::gray); … … 3897 4041 vm_state_color.insert (KMachineState_Discarding, &Qt::green); 3898 4042 4043 /* Redefine default large and small icon sizes. In particular, it is 4044 * necessary to consider both 32px and 22px icon sizes as Large when we 4045 * explicitly define them as Large (seems to be a bug in 4046 * QToolButton::sizeHint()). */ 4047 QIconSet::setIconSize (QIconSet::Small, QSize (16, 16)); 4048 QIconSet::setIconSize (QIconSet::Large, QSize (22, 22)); 4049 3899 4050 qApp->installEventFilter (this); 3900 4051 3901 / / create default non-null global settings4052 /* create default non-null global settings */ 3902 4053 gset = VBoxGlobalSettings (false); 3903 4054 3904 / / try to load global settings4055 /* try to load global settings */ 3905 4056 gset.load (mVBox); 3906 4057 if (!mVBox.isOk() || !gset) … … 3917 4068 languageChange(); 3918 4069 3919 / / process command line4070 /* process command line */ 3920 4071 3921 4072 vm_render_mode_str = 0; … … 3931 4082 int argc = qApp->argc(); 3932 4083 int i = 1; 3933 while ( i < argc ) { 3934 const char *arg = qApp->argv()[i]; 3935 if ( !::strcmp( arg, "-startvm" ) ) { 3936 if ( ++i < argc ) { 3937 QString param = QString (qApp->argv()[i]); 4084 while (i < argc) 4085 { 4086 const char *arg = qApp->argv() [i]; 4087 if ( !::strcmp (arg, "-startvm")) 4088 { 4089 if (++i < argc) 4090 { 4091 QString param = QString (qApp->argv() [i]); 3938 4092 QUuid uuid = QUuid (param); 3939 if (!uuid.isNull()) { 4093 if (!uuid.isNull()) 4094 { 3940 4095 vmUuid = uuid; 3941 } else { 4096 } 4097 else 4098 { 3942 4099 CMachine m = mVBox.FindMachine (param); 3943 if (m.isNull()) { 4100 if (m.isNull()) 4101 { 3944 4102 vboxProblem().cannotFindMachineByName (mVBox, param); 3945 4103 return; … … 3948 4106 } 3949 4107 } 3950 } else if ( !::strcmp( arg, "-comment" ) ) { 4108 } 4109 else if (!::strcmp (arg, "-comment")) 4110 { 3951 4111 ++i; 3952 } else if ( !::strcmp( arg, "-rmode" ) ) { 3953 if ( ++i < argc ) 3954 vm_render_mode_str = qApp->argv()[i]; 4112 } 4113 else if (!::strcmp (arg, "-rmode")) 4114 { 4115 if (++i < argc) 4116 vm_render_mode_str = qApp->argv() [i]; 3955 4117 } 3956 4118 #ifdef VBOX_WITH_DEBUGGER_GUI 3957 else if ( !::strcmp( arg, "-dbg" ) ) { 4119 else if (!::strcmp (arg, "-dbg")) 4120 { 3958 4121 dbg_enabled = true; 3959 4122 } 3960 4123 #ifdef DEBUG 3961 else if ( !::strcmp( arg, "-nodebug" ) ) { 4124 else if (!::strcmp (arg, "-nodebug")) 4125 { 3962 4126 dbg_enabled = false; 3963 4127 dbg_visible_at_startup = false; 3964 4128 } 3965 4129 #else 3966 else if ( !::strcmp( arg, "-debug" ) ) { 4130 else if (!::strcmp( arg, "-debug")) 4131 { 3967 4132 dbg_enabled = true; 3968 4133 dbg_visible_at_startup = true; … … 3973 4138 } 3974 4139 3975 vm_render_mode = vboxGetRenderMode ( vm_render_mode_str);3976 3977 / / setup the callback4140 vm_render_mode = vboxGetRenderMode (vm_render_mode_str); 4141 4142 /* setup the callback */ 3978 4143 callback = CVirtualBoxCallback (new VBoxCallback (*this)); 3979 4144 mVBox.RegisterCallback (callback); … … 3981 4146 if (!mVBox.isOk()) 3982 4147 return; 3983 3984 /*3985 * Redefine default large and small icon sizes. In particular, it is3986 * necessary to consider both 32px and 22px icon sizes as Large when3987 * we explicitly define them as Large (seems to be a bug in3988 * QToolButton::sizeHint()).3989 */3990 QIconSet::setIconSize (QIconSet::Small, QSize (16, 16));3991 QIconSet::setIconSize (QIconSet::Large, QSize (22, 22));3992 4148 3993 4149 mValid = true; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r7207 r7342 487 487 } 488 488 489 void VBoxProblemReporter:: 490 cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC) 491 { 492 PCRTSTATUSMSG msg = RTErrGet (aVRC); 493 Assert (msg); 494 495 QString err = QString ("%1: %2").arg (msg->pszDefine, msg->pszMsgShort); 496 if (err.endsWith (".")) 497 err.truncate (err.length() - 1); 498 499 message (mainWindowShown(), VBoxProblemReporter::Error, 500 tr ("Failed to copy file <b><nobr>%1<nobr></b> to " 501 "<b><nobr>%2<nobr></b> (%3).") 502 .arg (aSrc, aDst, err)); 503 } 504 489 505 void VBoxProblemReporter::cannotFindLanguage (const QString &aLangID, 490 506 const QString &aNlsPath) 491 507 { 492 message 493 (0, VBoxProblemReporter::Error, 494 tr ("<p>Could not find a language file for the language " 495 "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>" 496 "<p>The language will be temporarily reset to the system " 497 "default language. Please go to the <b>Preferences</b> " 498 "dialog which you can open from the <b>File</b> menu of the " 499 "main VirtualBox window, and select one of the existing " 500 "languages on the <b>Language</b> page.</p>") 501 .arg (aLangID).arg (aNlsPath)); 508 message (0, VBoxProblemReporter::Error, 509 tr ("<p>Could not find a language file for the language " 510 "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>" 511 "<p>The language will be temporarily reset to the system " 512 "default language. Please go to the <b>Preferences</b> " 513 "dialog which you can open from the <b>File</b> menu of the " 514 "main VirtualBox window, and select one of the existing " 515 "languages on the <b>Language</b> page.</p>") 516 .arg (aLangID).arg (aNlsPath)); 502 517 } 503 518 504 519 void VBoxProblemReporter::cannotLoadLanguage (const QString &aLangFile) 505 520 { 506 message 507 (0, VBoxProblemReporter::Error, 508 tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. " 509 "<p>The language will be temporarily reset to English (built-in). " 510 "Please go to the <b>Preferences</b> " 511 "dialog which you can open from the <b>File</b> menu of the " 512 "main VirtualBox window, and select one of the existing " 513 "languages on the <b>Language</b> page.</p>") 514 .arg (aLangFile)); 521 message (0, VBoxProblemReporter::Error, 522 tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. " 523 "<p>The language will be temporarily reset to English (built-in). " 524 "Please go to the <b>Preferences</b> " 525 "dialog which you can open from the <b>File</b> menu of the " 526 "main VirtualBox window, and select one of the existing " 527 "languages on the <b>Language</b> page.</p>") 528 .arg (aLangFile)); 515 529 } 516 530 517 531 void VBoxProblemReporter::cannotInitCOM (HRESULT rc) 518 532 { 519 message ( 520 0, 521 Critical, 533 message (0, Critical, 522 534 tr ("<p>Failed to initialize COM or to find the VirtualBox COM server. " 523 535 "Most likely, the VirtualBox server is not running " 524 536 "or failed to start.</p>" 525 537 "<p>The application will now terminate.</p>"), 526 formatErrorInfo (COMErrorInfo(), rc) 527 ); 538 formatErrorInfo (COMErrorInfo(), rc)); 528 539 } 529 540 530 541 void VBoxProblemReporter::cannotCreateVirtualBox (const CVirtualBox &vbox) 531 542 { 532 message ( 533 0, 534 Critical, 543 message (0, Critical, 535 544 tr ("<p>Failed to create the VirtualBox COM object.</p>" 536 545 "<p>The application will now terminate.</p>"), 537 formatErrorInfo (vbox) 538 ); 546 formatErrorInfo (vbox)); 547 } 548 549 void VBoxProblemReporter::cannotSaveGlobalSettings (const CVirtualBox &vbox, 550 QWidget *parent /* = 0 */) 551 { 552 /* preserve the current error info before calling the object again */ 553 COMResult res (vbox); 554 555 message (parent ? parent : mainWindowShown(), Error, 556 tr ("<p>Failed to save the global VirtualBox settings to " 557 "<b><nobr>%1</nobr></b>.</p>") 558 .arg (vbox.GetSettingsFilePath()), 559 formatErrorInfo (res)); 539 560 } 540 561 … … 542 563 const QString &error) 543 564 { 565 /* preserve the current error info before calling the object again */ 566 COMResult res (vbox); 567 544 568 message (mainWindowShown(), Critical, 545 tr ("<p>Failed to load the global GUI configuration.</p>" 546 "<p>The application will now terminate.</p>"), 547 !vbox.isOk() ? formatErrorInfo (vbox) 548 : QString ("<p>%1</p>").arg (VBoxGlobal::highlight (error))); 569 tr ("<p>Failed to load the global GUI configuration from " 570 "<b><nobr>%1</nobr></b>.</p>" 571 "<p>The application will now terminate.</p>") 572 .arg (vbox.GetSettingsFilePath()), 573 !res.isOk() ? formatErrorInfo (res) 574 : QString ("<p>%1</p>").arg (VBoxGlobal::highlight (error))); 549 575 } 550 576 551 577 void VBoxProblemReporter::cannotSaveGlobalConfig (const CVirtualBox &vbox) 552 578 { 553 message ( 554 mainWindowShown(), 555 Critical, 556 tr ("<p>Failed to save the global GUI configuration.<p>"), 557 formatErrorInfo (vbox) 558 ); 579 /* preserve the current error info before calling the object again */ 580 COMResult res (vbox); 581 582 message (mainWindowShown(), Critical, 583 tr ("<p>Failed to save the global GUI configuration to " 584 "<b><nobr>%1</nobr></b>.</p>" 585 "<p>The application will now terminate.</p>") 586 .arg (vbox.GetSettingsFilePath()), 587 formatErrorInfo (res)); 559 588 } 560 589 561 590 void VBoxProblemReporter::cannotSetSystemProperties (const CSystemProperties &props) 562 591 { 563 message ( 564 mainWindowShown(), 565 Critical, 592 message (mainWindowShown(), Critical, 566 593 tr ("Failed to set global VirtualBox properties."), 567 formatErrorInfo (props) 568 ); 594 formatErrorInfo (props)); 569 595 } 570 596 … … 628 654 629 655 message (parent ? parent : mainWindowShown(), Error, 630 tr ("Failed to save the settings of the virtual machine <b>%1</b>.") 631 .arg (machine.GetName()), 656 tr ("Failed to save the settings of the virtual machine " 657 "<b>%1</b> to <b><nobr>%2</nobr></b>.") 658 .arg (machine.GetName(), machine.GetSettingsFilePath()), 632 659 formatErrorInfo (res)); 633 660 } … … 646 673 647 674 message (parent ? parent : mainWindowShown(), Error, 648 tr ("Failed to load the settings of the virtual machine <b>%1</b>.") 649 .arg (machine.GetName()), 675 tr ("Failed to load the settings of the virtual machine " 676 "<b>%1</b> from <b><nobr>%2</nobr></b>.") 677 .arg (machine.GetName(), machine.GetSettingsFilePath()), 650 678 formatErrorInfo (res)); 651 679 } … … 1116 1144 Assert (!vbox.isOk() || progress.isOk()); 1117 1145 1146 QString name = machine.GetName(); 1147 if (name.isEmpty()) 1148 name = QFileInfo (machine.GetSettingsFilePath()).baseName(); 1149 1118 1150 message ( 1119 1151 mainWindowShown(), 1120 1152 Error, 1121 1153 tr ("Failed to open a session for the virtual machine <b>%1</b>.") 1122 .arg ( machine.GetName()),1154 .arg (name), 1123 1155 !vbox.isOk() ? formatErrorInfo (vbox) : 1124 1156 formatErrorInfo (progress.GetErrorInfo()) … … 1602 1634 1603 1635 /** 1636 * Shows a list of auto-converted files and asks the user to either Save, Backup 1637 * or Cancel to leave them as is. 1638 * 1639 * @param aFormatVersion Recent settings file format version. 1640 * @param aFileList List of auto-converted files (may use Qt HTML). 1641 * 1642 * @return QIMessageBox::Yes (Save), QIMessageBox::No (Backup), 1643 * QIMessageBox::Cancel (Leave) 1644 */ 1645 int VBoxProblemReporter::warnAboutAutoConvertedSettings (const QString &aFormatVersion, 1646 const QString &aFileList) 1647 { 1648 return message (mainWindowShown(), Warning, 1649 tr ("<p>The following VirtualBox settings files have been " 1650 "automatically converted to the new settings file format " 1651 "version <b>%1</b>.</p>" 1652 "<p>However, the results of the conversion were not saved back " 1653 "to disk yet. Please press:</p>" 1654 "<ul>" 1655 "<li><b>Save</b> to save all auto-converted files now (it will not " 1656 "be possible to use these settings files with an older version of " 1657 "VirtualBox in the future);</li>" 1658 "<li><b>Backup</b> to create backup copies of settings files in " 1659 "the old format before saving them in the new format;</li>" 1660 "<li><b>Cancel</b> to not save the settings files now.<li>" 1661 "</ul>" 1662 "<p>Note that if you select <b>Cancel</b>, the auto-converted " 1663 "settings files will be implicitly saved in the new format anyway " 1664 "once you change a setting or start a virtual machine.</p>") 1665 .arg (aFormatVersion), 1666 aFileList, 1667 NULL /* aAutoConfirmId */, 1668 QIMessageBox::Yes, 1669 QIMessageBox::No | QIMessageBox::Default, 1670 QIMessageBox::Cancel | QIMessageBox::Escape, 1671 tr ("&Save", "warnAboutAutoConvertedSettings message box"), 1672 tr ("&Backup", "warnAboutAutoConvertedSettings message box"), 1673 tr ("Cancel", "warnAboutAutoConvertedSettings message box")); 1674 } 1675 1676 /** 1604 1677 * @param aHotKey Fullscreen hot key as defined in the menu. 1605 1678 * -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r6851 r7342 236 236 #endif 237 237 238 vboxGlobal().checkForAutoConvertedSettings(); 239 238 240 VBoxGlobalSettings settings = vboxGlobal().settings(); 239 241 /* Process known keys */ -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h
r7334 r7342 431 431 bool showVirtualBoxLicense(); 432 432 #endif 433 434 void checkForAutoConvertedSettings(); 433 435 434 436 CSession openSession (const QUuid &aId, bool aExisting = false); -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxProblemReporter.h
r7220 r7342 129 129 130 130 void cannotOpenURL (const QString &aURL); 131 void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC); 131 132 132 133 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath); … … 135 136 void cannotInitCOM (HRESULT rc); 136 137 void cannotCreateVirtualBox (const CVirtualBox &vbox); 138 139 void cannotSaveGlobalSettings (const CVirtualBox &vbox, 140 QWidget *parent = 0); 137 141 138 142 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error); … … 259 263 bool remindAboutPausedVMInput(); 260 264 265 int warnAboutAutoConvertedSettings (const QString &aFormatVersion, 266 const QString &aFileList); 267 261 268 bool remindAboutInaccessibleMedia(); 262 269 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp
r7308 r7342 24 24 #include "VBoxProblemReporter.h" 25 25 #include "QIHotKeyEdit.h" 26 #include "QIMessageBox.h" 27 26 28 //Added by qt3to4: 27 29 #include <QDesktopWidget> … … 63 65 #include <q3process.h> 64 66 67 #include <QList> 68 65 69 #if defined (Q_WS_MAC) 66 70 #include <Carbon/Carbon.h> // for HIToolbox/InternetConfig … … 87 91 #include <iprt/path.h> 88 92 #include <iprt/env.h> 93 #include <iprt/file.h> 89 94 90 95 #if defined (Q_WS_X11) … … 910 915 static QStringList list; 911 916 if (list.empty()) { 912 for ( uint i = 0; i < vm_os_types.count(); i++) {917 for (int i = 0; i < vm_os_types.count(); i++) { 913 918 list += vm_os_types [i].GetDescription(); 914 919 } … … 1001 1006 static QStringList list; 1002 1007 if (list.empty()) 1003 for ( uint i = 0; i < deviceTypes.count() - 1 /* usb=n/a */; i++)1008 for (int i = 0; i < deviceTypes.count() - 1 /* usb=n/a */; i++) 1004 1009 list += deviceTypes [i]; 1005 1010 return list; … … 1804 1809 QStringList filesList = docDir.entryList(); 1805 1810 double maxVersionNumber = 0; 1806 for ( uint index = 0; index < filesList.count(); ++ index)1811 for (int index = 0; index < filesList.count(); ++ index) 1807 1812 { 1808 1813 QRegExp regExp ("License-([\\d\\.]+).html"); … … 1835 1840 } 1836 1841 #endif 1842 1843 /** 1844 * Checks if any of the settings files were auto-converted and informs the user 1845 * if so. 1846 */ 1847 void VBoxGlobal::checkForAutoConvertedSettings() 1848 { 1849 QString formatVersion = mVBox.GetSettingsFormatVersion(); 1850 1851 bool isGlobalConverted = false; 1852 QList <CMachine> machines; 1853 QString fileList; 1854 QString version; 1855 1856 CMachineVector vec = mVBox.GetMachines2(); 1857 for (CMachineVector::ConstIterator m = vec.begin(); 1858 m != vec.end(); ++ m) 1859 { 1860 if (!m->GetAccessible()) 1861 continue; 1862 1863 version = m->GetSettingsFileVersion(); 1864 if (version != formatVersion) 1865 { 1866 machines.append (*m); 1867 fileList += QString ("<nobr>%1 (<i>%2</i>)</nobr><br>") 1868 .arg (m->GetSettingsFilePath()) 1869 .arg (version); 1870 } 1871 } 1872 1873 version = mVBox.GetSettingsFileVersion(); 1874 if (version != formatVersion) 1875 { 1876 isGlobalConverted = true; 1877 fileList += QString ("<nobr>%1 (<i>%2</i>)</nobr><br>") 1878 .arg (mVBox.GetSettingsFilePath()) 1879 .arg (version); 1880 } 1881 1882 1883 if (!fileList.isNull()) 1884 { 1885 int rc = vboxProblem() 1886 .warnAboutAutoConvertedSettings (formatVersion, fileList); 1887 1888 if (rc == QIMessageBox::No) 1889 { 1890 /* create backup copies */ 1891 for (QList <CMachine>::Iterator m = machines.begin(); 1892 /* machines.end() means global config => manual loop break */ ;) 1893 { 1894 QString of, nf; 1895 1896 if (m == machines.end()) 1897 { 1898 if (!isGlobalConverted) 1899 break; 1900 of = mVBox.GetSettingsFilePath(); 1901 nf = QString ("%1.%2.bak").arg (of, mVBox.GetSettingsFileVersion()); 1902 } 1903 else 1904 { 1905 of = (*m).GetSettingsFilePath(); 1906 nf = QString ("%1.%2.bak").arg (of, (*m).GetSettingsFileVersion()); 1907 } 1908 1909 int vrc = RTFileCopyEx (of.utf8(), nf.utf8(), 1910 RTFILECOPY_FLAG_NO_DENY_WRITE, 1911 NULL, NULL); 1912 1913 /* try progressive suffix on failure */ 1914 if (vrc == VERR_ALREADY_EXISTS) 1915 { 1916 QString tmp = nf; 1917 for (int i = 0; i < 9 && RT_FAILURE (vrc); ++ i) 1918 { 1919 nf = QString ("%1.%2"). arg (tmp).arg (i); 1920 vrc = RTFileCopyEx (of.utf8(), nf.utf8(), 1921 RTFILECOPY_FLAG_NO_DENY_WRITE, 1922 NULL, NULL); 1923 } 1924 } 1925 1926 if (RT_FAILURE (vrc)) 1927 { 1928 vboxProblem().cannotCopyFile (of, nf, vrc); 1929 if (m == machines.end()) 1930 { 1931 /* remove from further processing */ 1932 isGlobalConverted = false; 1933 break; 1934 } 1935 else 1936 /* remove from further processing */ 1937 m = machines.remove (m); 1938 } 1939 else 1940 { 1941 if (m == machines.end()) 1942 break; 1943 ++ m; 1944 } 1945 } 1946 } 1947 1948 if (rc == QIMessageBox::Yes || rc == QIMessageBox::No) 1949 { 1950 /* save all settings files */ 1951 for (QList <CMachine>::Iterator m = machines.begin(); 1952 /* machines.end() means global config => manual loop break */ ;) 1953 { 1954 if (m == machines.end()) 1955 { 1956 if (isGlobalConverted) 1957 { 1958 mVBox.SaveSettings(); 1959 if (!mVBox.isOk()) 1960 vboxProblem().cannotSaveGlobalSettings (mVBox); 1961 } 1962 } 1963 else 1964 { 1965 CSession session = openSession ((*m).GetId()); 1966 if (!session.isNull()) 1967 { 1968 CMachine sm = session.GetMachine(); 1969 sm.SaveSettings(); 1970 if (!sm.isOk()) 1971 vboxProblem().cannotSaveMachineSettings (sm); 1972 session.Close(); 1973 } 1974 } 1975 1976 if (m == machines.end()) 1977 break; 1978 1979 ++ m; 1980 } 1981 } 1982 } 1983 } 1837 1984 1838 1985 /** … … 3900 4047 vm_state_color.insert (KMachineState_Discarding, new QColor(Qt::green)); 3901 4048 4049 /* Redefine default large and small icon sizes. In particular, it is 4050 * necessary to consider both 32px and 22px icon sizes as Large when we 4051 * explicitly define them as Large (seems to be a bug in 4052 * QToolButton::sizeHint()). */ 4053 #warning port me 4054 // QIcon::setIconSize (QIcon::Small, QSize (16, 16)); 4055 // QIcon::setIconSize (QIcon::Large, QSize (22, 22)); 4056 3902 4057 qApp->installEventFilter (this); 3903 4058 … … 3934 4089 int argc = qApp->argc(); 3935 4090 int i = 1; 3936 while ( i < argc ) { 3937 const char *arg = qApp->argv()[i]; 3938 if ( !::strcmp( arg, "-startvm" ) ) { 3939 if ( ++i < argc ) { 3940 QString param = QString (qApp->argv()[i]); 4091 while (i < argc) 4092 { 4093 const char *arg = qApp->argv() [i]; 4094 if ( !::strcmp (arg, "-startvm")) 4095 { 4096 if (++i < argc) 4097 { 4098 QString param = QString (qApp->argv() [i]); 3941 4099 QUuid uuid = QUuid (param); 3942 if (!uuid.isNull()) { 4100 if (!uuid.isNull()) 4101 { 3943 4102 vmUuid = uuid; 3944 } else { 4103 } 4104 else 4105 { 3945 4106 CMachine m = mVBox.FindMachine (param); 3946 if (m.isNull()) { 4107 if (m.isNull()) 4108 { 3947 4109 vboxProblem().cannotFindMachineByName (mVBox, param); 3948 4110 return; … … 3951 4113 } 3952 4114 } 3953 } else if ( !::strcmp( arg, "-comment" ) ) { 4115 } 4116 else if (!::strcmp (arg, "-comment")) 4117 { 3954 4118 ++i; 3955 } else if ( !::strcmp( arg, "-rmode" ) ) { 3956 if ( ++i < argc ) 3957 vm_render_mode_str = qApp->argv()[i]; 4119 } 4120 else if (!::strcmp (arg, "-rmode")) 4121 { 4122 if (++i < argc) 4123 vm_render_mode_str = qApp->argv() [i]; 3958 4124 } 3959 4125 #ifdef VBOX_WITH_DEBUGGER_GUI 3960 else if ( !::strcmp( arg, "-dbg" ) ) { 4126 else if (!::strcmp (arg, "-dbg")) 4127 { 3961 4128 dbg_enabled = true; 3962 4129 } 3963 4130 #ifdef DEBUG 3964 else if ( !::strcmp( arg, "-nodebug" ) ) { 4131 else if (!::strcmp (arg, "-nodebug")) 4132 { 3965 4133 dbg_enabled = false; 3966 4134 dbg_visible_at_startup = false; 3967 4135 } 3968 4136 #else 3969 else if ( !::strcmp( arg, "-debug" ) ) { 4137 else if (!::strcmp( arg, "-debug")) 4138 { 3970 4139 dbg_enabled = true; 3971 4140 dbg_visible_at_startup = true; … … 3984 4153 if (!mVBox.isOk()) 3985 4154 return; 3986 3987 /* Redefine default large and small icon sizes. In particular, it is3988 * necessary to consider both 32px and 22px icon sizes as Large when we3989 * explicitly define them as Large (seems to be a bug in3990 * QToolButton::sizeHint()). */3991 #warning port me3992 // QIcon::setIconSize (QIcon::Small, QSize (16, 16));3993 // QIcon::setIconSize (QIcon::Large, QSize (22, 22));3994 4155 3995 4156 mValid = true; -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxProblemReporter.cpp
r7282 r7342 493 493 } 494 494 495 void VBoxProblemReporter:: 496 cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC) 497 { 498 PCRTSTATUSMSG msg = RTErrGet (aVRC); 499 Assert (msg); 500 501 QString err = QString ("%1: %2").arg (msg->pszDefine, msg->pszMsgShort); 502 if (err.endsWith (".")) 503 err.truncate (err.length() - 1); 504 505 message (mainWindowShown(), VBoxProblemReporter::Error, 506 tr ("Failed to copy file <b><nobr>%1<nobr></b> to " 507 "<b><nobr>%2<nobr></b> (%3).") 508 .arg (aSrc, aDst, err)); 509 } 510 495 511 void VBoxProblemReporter::cannotFindLanguage (const QString &aLangID, 496 512 const QString &aNlsPath) 497 513 { 498 message 499 (0, VBoxProblemReporter::Error, 500 tr ("<p>Could not find a language file for the language " 501 "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>" 502 "<p>The language will be temporarily reset to the system " 503 "default language. Please go to the <b>Preferences</b> " 504 "dialog which you can open from the <b>File</b> menu of the " 505 "main VirtualBox window, and select one of the existing " 506 "languages on the <b>Language</b> page.</p>") 507 .arg (aLangID).arg (aNlsPath)); 514 message (0, VBoxProblemReporter::Error, 515 tr ("<p>Could not find a language file for the language " 516 "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>" 517 "<p>The language will be temporarily reset to the system " 518 "default language. Please go to the <b>Preferences</b> " 519 "dialog which you can open from the <b>File</b> menu of the " 520 "main VirtualBox window, and select one of the existing " 521 "languages on the <b>Language</b> page.</p>") 522 .arg (aLangID).arg (aNlsPath)); 508 523 } 509 524 510 525 void VBoxProblemReporter::cannotLoadLanguage (const QString &aLangFile) 511 526 { 512 message 513 (0, VBoxProblemReporter::Error, 514 tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. " 515 "<p>The language will be temporarily reset to English (built-in). " 516 "Please go to the <b>Preferences</b> " 517 "dialog which you can open from the <b>File</b> menu of the " 518 "main VirtualBox window, and select one of the existing " 519 "languages on the <b>Language</b> page.</p>") 520 .arg (aLangFile)); 527 message (0, VBoxProblemReporter::Error, 528 tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. " 529 "<p>The language will be temporarily reset to English (built-in). " 530 "Please go to the <b>Preferences</b> " 531 "dialog which you can open from the <b>File</b> menu of the " 532 "main VirtualBox window, and select one of the existing " 533 "languages on the <b>Language</b> page.</p>") 534 .arg (aLangFile)); 521 535 } 522 536 523 537 void VBoxProblemReporter::cannotInitCOM (HRESULT rc) 524 538 { 525 message ( 526 0, 527 Critical, 539 message (0, Critical, 528 540 tr ("<p>Failed to initialize COM or to find the VirtualBox COM server. " 529 541 "Most likely, the VirtualBox server is not running " 530 542 "or failed to start.</p>" 531 543 "<p>The application will now terminate.</p>"), 532 formatErrorInfo (COMErrorInfo(), rc) 533 ); 544 formatErrorInfo (COMErrorInfo(), rc)); 534 545 } 535 546 536 547 void VBoxProblemReporter::cannotCreateVirtualBox (const CVirtualBox &vbox) 537 548 { 538 message ( 539 0, 540 Critical, 549 message (0, Critical, 541 550 tr ("<p>Failed to create the VirtualBox COM object.</p>" 542 551 "<p>The application will now terminate.</p>"), 543 formatErrorInfo (vbox) 544 ); 552 formatErrorInfo (vbox)); 553 } 554 555 void VBoxProblemReporter::cannotSaveGlobalSettings (const CVirtualBox &vbox, 556 QWidget *parent /* = 0 */) 557 { 558 /* preserve the current error info before calling the object again */ 559 COMResult res (vbox); 560 561 message (parent ? parent : mainWindowShown(), Error, 562 tr ("<p>Failed to save the global VirtualBox settings to " 563 "<b><nobr>%1</nobr></b>.</p>") 564 .arg (vbox.GetSettingsFilePath()), 565 formatErrorInfo (res)); 545 566 } 546 567 … … 548 569 const QString &error) 549 570 { 571 /* preserve the current error info before calling the object again */ 572 COMResult res (vbox); 573 550 574 message (mainWindowShown(), Critical, 551 tr ("<p>Failed to load the global GUI configuration.</p>" 552 "<p>The application will now terminate.</p>"), 553 !vbox.isOk() ? formatErrorInfo (vbox) 554 : QString ("<p>%1</p>").arg (VBoxGlobal::highlight (error))); 575 tr ("<p>Failed to load the global GUI configuration from " 576 "<b><nobr>%1</nobr></b>.</p>" 577 "<p>The application will now terminate.</p>") 578 .arg (vbox.GetSettingsFilePath()), 579 !res.isOk() ? formatErrorInfo (res) 580 : QString ("<p>%1</p>").arg (VBoxGlobal::highlight (error))); 555 581 } 556 582 557 583 void VBoxProblemReporter::cannotSaveGlobalConfig (const CVirtualBox &vbox) 558 584 { 559 message ( 560 mainWindowShown(), 561 Critical, 562 tr ("<p>Failed to save the global GUI configuration.<p>"), 563 formatErrorInfo (vbox) 564 ); 585 /* preserve the current error info before calling the object again */ 586 COMResult res (vbox); 587 588 message (mainWindowShown(), Critical, 589 tr ("<p>Failed to save the global GUI configuration to " 590 "<b><nobr>%1</nobr></b>.</p>" 591 "<p>The application will now terminate.</p>") 592 .arg (vbox.GetSettingsFilePath()), 593 formatErrorInfo (res)); 565 594 } 566 595 567 596 void VBoxProblemReporter::cannotSetSystemProperties (const CSystemProperties &props) 568 597 { 569 message ( 570 mainWindowShown(), 571 Critical, 598 message (mainWindowShown(), Critical, 572 599 tr ("Failed to set global VirtualBox properties."), 573 formatErrorInfo (props) 574 ); 600 formatErrorInfo (props)); 575 601 } 576 602 … … 634 660 635 661 message (parent ? parent : mainWindowShown(), Error, 636 tr ("Failed to save the settings of the virtual machine <b>%1</b>.") 637 .arg (machine.GetName()), 662 tr ("Failed to save the settings of the virtual machine " 663 "<b>%1</b> to <b><nobr>%2</nobr></b>.") 664 .arg (machine.GetName(), machine.GetSettingsFilePath()), 638 665 formatErrorInfo (res)); 639 666 } … … 652 679 653 680 message (parent ? parent : mainWindowShown(), Error, 654 tr ("Failed to load the settings of the virtual machine <b>%1</b>.") 655 .arg (machine.GetName()), 681 tr ("Failed to load the settings of the virtual machine " 682 "<b>%1</b> from <b><nobr>%2</nobr></b>.") 683 .arg (machine.GetName(), machine.GetSettingsFilePath()), 656 684 formatErrorInfo (res)); 657 685 } … … 1122 1150 Assert (!vbox.isOk() || progress.isOk()); 1123 1151 1152 QString name = machine.GetName(); 1153 if (name.isEmpty()) 1154 name = QFileInfo (machine.GetSettingsFilePath()).baseName(); 1155 1124 1156 message ( 1125 1157 mainWindowShown(), 1126 1158 Error, 1127 1159 tr ("Failed to open a session for the virtual machine <b>%1</b>.") 1128 .arg ( machine.GetName()),1160 .arg (name), 1129 1161 !vbox.isOk() ? formatErrorInfo (vbox) : 1130 1162 formatErrorInfo (progress.GetErrorInfo()) … … 1608 1640 1609 1641 /** 1642 * Shows a list of auto-converted files and asks the user to either Save, Backup 1643 * or Cancel to leave them as is. 1644 * 1645 * @param aFormatVersion Recent settings file format version. 1646 * @param aFileList List of auto-converted files (may use Qt HTML). 1647 * 1648 * @return QIMessageBox::Yes (Save), QIMessageBox::No (Backup), 1649 * QIMessageBox::Cancel (Leave) 1650 */ 1651 int VBoxProblemReporter::warnAboutAutoConvertedSettings (const QString &aFormatVersion, 1652 const QString &aFileList) 1653 { 1654 return message (mainWindowShown(), Warning, 1655 tr ("<p>The following VirtualBox settings files have been " 1656 "automatically converted to the new settings file format " 1657 "version <b>%1</b>.</p>" 1658 "<p>However, the results of the conversion were not saved back " 1659 "to disk yet. Please press:</p>" 1660 "<ul>" 1661 "<li><b>Save</b> to save all auto-converted files now (it will not " 1662 "be possible to use these settings files with an older version of " 1663 "VirtualBox in the future);</li>" 1664 "<li><b>Backup</b> to create backup copies of settings files in " 1665 "the old format before saving them in the new format;</li>" 1666 "<li><b>Cancel</b> to not save the settings files now.<li>" 1667 "</ul>" 1668 "<p>Note that if you select <b>Cancel</b>, the auto-converted " 1669 "settings files will be implicitly saved in the new format anyway " 1670 "once you change a setting or start a virtual machine.</p>") 1671 .arg (aFormatVersion), 1672 aFileList, 1673 NULL /* aAutoConfirmId */, 1674 QIMessageBox::Yes, 1675 QIMessageBox::No | QIMessageBox::Default, 1676 QIMessageBox::Cancel | QIMessageBox::Escape, 1677 tr ("&Save", "warnAboutAutoConvertedSettings message box"), 1678 tr ("&Backup", "warnAboutAutoConvertedSettings message box"), 1679 tr ("Cancel", "warnAboutAutoConvertedSettings message box")); 1680 } 1681 1682 /** 1610 1683 * @param aHotKey Fullscreen hot key as defined in the menu. 1611 1684 * -
trunk/src/VBox/Frontends/VirtualBox4/src/main.cpp
r6851 r7342 236 236 #endif 237 237 238 vboxGlobal().checkForAutoConvertedSettings(); 239 238 240 VBoxGlobalSettings settings = vboxGlobal().settings(); 239 241 /* Process known keys */
Note:
See TracChangeset
for help on using the changeset viewer.