Changeset 9886 in vbox
- Timestamp:
- Jun 23, 2008 3:12:24 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk
r9866 r9886 410 410 VirtualBox_QT_UISRCS3 := $(filter-out ui/VBoxGlobalSettingsInput.ui,$(VirtualBox_QT_UISRCS3)) 411 411 VirtualBox_QT_UISRCS4 += ui/VBoxGlobalSettingsInput.ui 412 413 VirtualBox_QT_UISRCS3 := $(filter-out ui/VBoxGlobalSettingsLanguage.ui,$(VirtualBox_QT_UISRCS3)) 414 VirtualBox_QT_UISRCS4 += ui/VBoxGlobalSettingsLanguage.ui 412 415 413 416 VirtualBox_QT_UISRCS3 := $(filter-out ui/VBoxGlobalSettingsDlg.ui,$(VirtualBox_QT_UISRCS3)) … … 577 580 include/VBoxGlobalSettingsGeneral.h \ 578 581 include/VBoxGlobalSettingsInput.h \ 582 include/VBoxGlobalSettingsLanguage.h \ 579 583 include/VBoxGlobalSettingsDlg.h 580 584 … … 666 670 src/VBoxGlobalSettingsGeneral.cpp \ 667 671 src/VBoxGlobalSettingsInput.cpp \ 672 src/VBoxGlobalSettingsLanguage.cpp \ 668 673 src/VBoxGlobalSettingsDlg.cpp 669 674 -
trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobalSettingsDlg.h
r9783 r9886 69 69 QString pagePath (QWidget *aPage); 70 70 void setWarning (const QString &aWarning); 71 void update MediaShortcuts();71 void updateAvailability(); 72 72 73 73 /* Common */ -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobalSettingsDlg.cpp
r9828 r9886 36 36 #include "VBoxGlobalSettingsInput.h" 37 37 #include "VBoxVMSettingsUSB.h" 38 //#include "VBoxGlobalSettingsLanguage.h"38 #include "VBoxGlobalSettingsLanguage.h" 39 39 40 40 #include "VBoxGlobal.h" … … 44 44 #include <QTimer> 45 45 #include <QPushButton> 46 47 //#define ENABLE_GLOBAL_USB 46 48 47 49 /** … … 72 74 return list.count() ? list [0] : 0; 73 75 } 74 75 // /* Language page */76 // /* Defined in VBoxGlobal.cpp */77 // extern const char *gVBoxLangSubDir;78 // extern const char *gVBoxLangFileBase;79 // extern const char *gVBoxLangFileExt;80 // extern const char *gVBoxLangIDRegExp;81 // extern const char *gVBoxBuiltInLangName;82 // class LanguageItem : public Q3ListViewItem83 // {84 // public:85 //86 // enum { TypeId = 1001 };87 //88 // LanguageItem (Q3ListView *aParent, const QTranslator &aTranslator,89 // const QString &aId, bool aBuiltIn = false)90 // : Q3ListViewItem (aParent), mBuiltIn (aBuiltIn), mInvalid (false)91 // {92 // Assert (!aId.isEmpty());93 //94 // // QTranslatorMessage transMes;95 //96 // /* Note: context/source/comment arguments below must match strings97 // * used in VBoxGlobal::languageName() and friends (the latter are the98 // * source of information for the lupdate tool that generates99 // * translation files) */100 //101 // QString nativeLanguage = tratra (aTranslator,102 // "@@@", "English", "Native language name");103 // QString nativeCountry = tratra (aTranslator,104 // "@@@", "--", "Native language country name "105 // "(empty if this language is for all countries)");106 //107 // QString englishLanguage = tratra (aTranslator,108 // "@@@", "English", "Language name, in English");109 // QString englishCountry = tratra (aTranslator,110 // "@@@", "--", "Language country name, in English "111 // "(empty if native country name is empty)");112 //113 // QString translatorsName = tratra (aTranslator,114 // "@@@", "Sun Microsystems, Inc.", "Comma-separated list of translators");115 //116 // QString itemName = nativeLanguage;117 // QString langName = englishLanguage;118 //119 // if (!aBuiltIn)120 // {121 // if (nativeCountry != "--")122 // itemName += " (" + nativeCountry + ")";123 //124 // if (englishCountry != "--")125 // langName += " (" + englishCountry + ")";126 //127 // if (itemName != langName)128 // langName = itemName + " / " + langName;129 // }130 // else131 // {132 // itemName += VBoxGlobalSettingsDlg::tr (" (built-in)", "Language");133 // langName += VBoxGlobalSettingsDlg::tr (" (built-in)", "Language");134 // }135 //136 // setText (0, itemName);137 // setText (1, aId);138 // setText (2, langName);139 // setText (3, translatorsName);140 // }141 //142 // /* Constructs an item for an invalid language ID (i.e. when a language143 // * file is missing or corrupt). */144 // LanguageItem (Q3ListView *aParent, const QString &aId)145 // : Q3ListViewItem (aParent), mBuiltIn (false), mInvalid (true)146 // {147 // Assert (!aId.isEmpty());148 //149 // setText (0, QString ("<%1>").arg (aId));150 // setText (1, aId);151 // setText (2, VBoxGlobalSettingsDlg::tr ("<unavailable>", "Language"));152 // setText (3, VBoxGlobalSettingsDlg::tr ("<unknown>", "Author(s)"));153 // }154 //155 // /* Constructs an item for the default language ID (column 1 will be set156 // * to QString::null) */157 // LanguageItem (Q3ListView *aParent)158 // : Q3ListViewItem (aParent), mBuiltIn (false), mInvalid (false)159 // {160 // setText (0, VBoxGlobalSettingsDlg::tr ("Default", "Language"));161 // setText (1, QString::null);162 // /* empty strings of some reasonable length to prevent the info part163 // * from being shrinked too much when the list wants to be wider */164 // setText (2, " ");165 // setText (3, " ");166 // }167 //168 // int rtti() const { return TypeId; }169 //170 // int compare (Q3ListViewItem *aItem, int aColumn, bool aAscending) const171 // {172 // QString thisId = text (1);173 // QString thatId = aItem->text (1);174 // if (thisId.isNull())175 // return -1;176 // if (thatId.isNull())177 // return 1;178 // if (mBuiltIn)179 // return -1;180 // if (aItem->rtti() == TypeId && ((LanguageItem *) aItem)->mBuiltIn)181 // return 1;182 // return Q3ListViewItem::compare (aItem, aColumn, aAscending);183 // }184 //185 // void paintCell (QPainter *aPainter, const QColorGroup &aGroup,186 // int aColumn, int aWidth, int aAlign)187 // {188 // QFont font = aPainter->font();189 //190 // if (mInvalid)191 // font.setItalic (true);192 // /* mark the effectively active language */193 // if (text (1) == VBoxGlobal::languageId())194 // font.setBold (true);195 //196 // if (aPainter->font() != font)197 // aPainter->setFont (font);198 //199 // Q3ListViewItem::paintCell (aPainter, aGroup, aColumn, aWidth, aAlign);200 //201 // if (mBuiltIn)202 // {203 // int y = height() - 1;204 // aPainter->setPen (aGroup.mid());205 // aPainter->drawLine (0, y, aWidth - 1, y);206 // }207 // }208 //209 // int width (const QFontMetrics &aFM, const Q3ListView *aLV, int aC) const210 // {211 // QFont font = aLV->font();212 //213 // if (mInvalid)214 // font.setItalic (true);215 // /* mark the effectively active language */216 // if (text (1) == VBoxGlobal::languageId())217 // font.setBold (true);218 //219 // QFontMetrics fm = aFM;220 // if (aLV->font() != font)221 // fm = QFontMetrics (font);222 //223 // return Q3ListViewItem::width (fm, aLV, aC);224 // }225 //226 // void setup ()227 // {228 // Q3ListViewItem::setup();229 // if (mBuiltIn)230 // setHeight (height() + 1);231 // }232 //233 // private:234 //235 // QString tratra (const QTranslator &aTranslator, const char *aCtxt,236 // const char *aSrc, const char *aCmnt)237 // {238 // //#warning port me: check this239 // QString msg = aTranslator.translate (aCtxt, aSrc, aCmnt);240 // // QString msg = aTranslator.findMessage (aCtxt, aSrc, aCmnt).translation();241 // /* return the source text if no translation is found */242 // if (msg.isEmpty())243 // msg = QString (aSrc);244 // return msg;245 // }246 //247 // bool mBuiltIn : 1;248 // bool mInvalid : 1;249 // };250 76 251 77 VBoxGlobalSettingsDlg::VBoxGlobalSettingsDlg (QWidget *aParent) … … 298 124 this, SLOT (settingsGroupChanged (QTreeWidgetItem *, QTreeWidgetItem*))); 299 125 300 // /* Language page */301 // lvLanguages->header()->hide();302 // lvLanguages->setSorting (0);303 //304 // char szNlsPath[RTPATH_MAX];305 // int rc = RTPathAppPrivateNoArch (szNlsPath, sizeof(szNlsPath));306 // AssertRC (rc);307 // QString nlsPath = QString (szNlsPath) + gVBoxLangSubDir;308 // QDir nlsDir (nlsPath);309 // QStringList files = nlsDir.entryList (QString ("%1*%2")310 // .arg (gVBoxLangFileBase, gVBoxLangFileExt),311 // QDir::Files);312 // QTranslator translator;313 // /* add the default language */314 // new LanguageItem (lvLanguages);315 // /* add the built-in language */316 // new LanguageItem (lvLanguages, translator, gVBoxBuiltInLangName, true /* built-in */);317 // /* add all existing languages */318 // for (QStringList::Iterator it = files.begin(); it != files.end(); ++ it)319 // {320 // QString fileName = *it;321 // QRegExp regExp (QString (gVBoxLangFileBase) + gVBoxLangIDRegExp);322 // int pos = regExp.search (fileName);323 // if (pos == -1)324 // continue;325 //326 // bool loadOk = translator.load (fileName, nlsPath);327 // if (!loadOk)328 // continue;329 //330 // new LanguageItem (lvLanguages, translator, regExp.cap (1));331 // }332 // lvLanguages->adjustColumn (0);333 334 126 /* Hide unnecessary columns and header */ 335 127 mTwSelector->header()->hide(); … … 337 129 mTwSelector->hideColumn (listView_Link); 338 130 339 /* Adjust selector list */340 int minWid = 0;341 for (int i = 0; i < mTwSelector->topLevelItemCount(); ++ i)342 {343 QTreeWidgetItem *item = mTwSelector->topLevelItem (i);344 QFontMetrics fm (item->font (0));345 int wid = fm.width (item->text (0)) +346 16 /* icon */ + 2 * 8 /* 2 margins */;347 minWid = wid > minWid ? wid : minWid;348 int hei = fm.height() > 16 ?349 fm.height() /* text height */ :350 16 /* icon */ + 2 * 2 /* 2 margins */;351 item->setSizeHint (0, QSize (wid, hei));352 }353 mTwSelector->setFixedWidth (minWid);354 355 /* Sort selector by the id column (to have pages in the desired order) */356 mTwSelector->sortItems (listView_Id, Qt::AscendingOrder);357 358 131 /* Initially select the first settings page */ 359 132 mTwSelector->setCurrentItem (mTwSelector->topLevelItem (0)); … … 370 143 const VBoxGlobalSettings &aGs) 371 144 { 372 // /* Language page */373 // QString langId = gs.languageId();374 // Q3ListViewItem *item = lvLanguages->findItem (langId, 1);375 // if (!item)376 // {377 // /* add an item for an invalid language to represent it in the list */378 // item = new LanguageItem (lvLanguages, langId);379 // lvLanguages->adjustColumn (0);380 // }381 // Assert (item);382 // if (item)383 // {384 // lvLanguages->setCurrentItem (item);385 // lvLanguages->setSelected (item, true);386 // }387 388 145 /* General Page */ 389 146 VBoxGlobalSettingsGeneral::getFrom (aProps, aGs, mPageGeneral, this); … … 393 150 394 151 /* USB Page */ 395 VBoxVMSettingsUSB::getFrom (mPageUSB, this, pagePath (mPageUSB)); 152 if (mPageUSB->isEnabled()) 153 VBoxVMSettingsUSB::getFrom (mPageUSB, this, pagePath (mPageUSB)); 396 154 397 155 /* Language Page */ 398 //VBoxGlobalSettingsLanguage::getFrom (aProps, aGs, mPageLanguage);156 VBoxGlobalSettingsLanguage::getFrom (aProps, aGs, mPageLanguage, this); 399 157 } 400 158 … … 406 164 VBoxGlobalSettings &aGs) 407 165 { 408 // /* Language Page */409 // Q3ListViewItem *selItem = lvLanguages->selectedItem();410 // Assert (selItem);411 // if (mLanguageChanged && selItem)412 // {413 // gs.setLanguageId (selItem->text (1));414 // VBoxGlobal::loadLanguage (selItem->text (1));415 // }416 417 166 /* General Page */ 418 167 VBoxGlobalSettingsGeneral::putBackTo (aProps, aGs); … … 425 174 426 175 /* Language Page */ 427 //VBoxGlobalSettingsLanguage::putBackTo (aProps, aGs);176 VBoxGlobalSettingsLanguage::putBackTo (aProps, aGs); 428 177 429 178 return COMResult(); … … 439 188 /* Set the old index */ 440 189 mTwSelector->setCurrentItem (mTwSelector->topLevelItem (ci)); 190 191 /* Update QTreeWidget with available items */ 192 updateAvailability(); 193 194 /* Adjust selector list */ 195 mTwSelector->setFixedWidth (static_cast<QAbstractItemView*> (mTwSelector) 196 ->sizeHintForColumn (0) + 2 * mTwSelector->frameWidth()); 197 198 /* Sort selector by the id column (to have pages in the desired order) */ 199 mTwSelector->sortItems (listView_Id, Qt::AscendingOrder); 200 mTwSelector->resizeColumnToContents (0); 441 201 442 202 mWarnIconLabel->setWarningText (tr ("Invalid settings detected")); … … 642 402 } 643 403 644 // /* Language Page */ 645 // void VBoxGlobalSettingsDlg::lvLanguages_currentChanged (Q3ListViewItem *aItem) 646 // { 647 // Assert (aItem); 648 // if (!aItem) return; 649 // 650 // /* disable labels for the Default language item */ 651 // bool enabled = !aItem->text (1).isNull(); 652 // 653 // tlLangName->setEnabled (enabled); 654 // tlAuthorName->setEnabled (enabled); 655 // tlLangData->setText (aItem->text (2)); 656 // tlAuthorData->setText (aItem->text (3)); 657 // 658 // mLanguageChanged = true; 659 // } 660 // 661 // void VBoxGlobalSettingsDlg::fixLanguageChange() 662 // { 663 // /* fix for usb page */ 664 // 665 // #ifdef DEBUG_dmik 666 // CHost host = vboxGlobal().virtualBox().GetHost(); 667 // CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters(); 668 // if (coll.isNull()) 669 // { 670 // #endif 671 // /* disable the USB host filters category if the USB is 672 // * not available (i.e. in VirtualBox OSE) */ 673 // 674 // Q3ListViewItem *usbItem = listView->findItem ("#usb", listView_Link); 675 // Assert (usbItem); 676 // usbItem->setVisible (false); 677 // 678 // /* disable validators if any */ 679 // pageUSB->setEnabled (false); 680 // 681 // #ifdef DEBUG_dmik 682 // } 683 // #endif 684 // } 685 404 void VBoxGlobalSettingsDlg::updateAvailability() 405 { 406 #ifdef ENABLE_GLOBAL_USB 407 CHost host = vboxGlobal().virtualBox().GetHost(); 408 CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters(); 409 410 /* Show an error message (if there is any). 411 * This message box may be suppressed if the user wishes so. */ 412 if (!host.isReallyOk()) 413 vboxProblem().cannotAccessUSB (host); 414 415 if (coll.isNull()) 416 { 417 #endif 418 /* Disable the USB controller category if the USB controller is 419 * not available (i.e. in VirtualBox OSE) */ 420 QList<QTreeWidgetItem*> items = mTwSelector->findItems ( 421 "#usb", Qt::MatchExactly, listView_Link); 422 QTreeWidgetItem *usbItem = items.count() ? items [0] : 0; 423 Assert (usbItem); 424 if (usbItem) 425 usbItem->setHidden (true); 426 mPageUSB->setEnabled (false); 427 #ifdef ENABLE_GLOBAL_USB 428 } 429 #endif 430 } 431 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsUSB.cpp
r9827 r9886 30 30 #include "VBoxProblemReporter.h" 31 31 32 //#define ENABLE_GLOBAL_USB33 34 32 inline static QString emptyToNull (const QString &str) 35 33 { … … 43 41 const QString &aPath) 44 42 { 45 /* USB Page */46 #ifdef ENABLE_GLOBAL_USB47 CHost host = vboxGlobal().virtualBox().GetHost();48 CHostUSBDeviceFilterCollection coll = host.GetUSBDeviceFilters();49 50 /* Show an error message (if there is any).51 * This message box may be suppressed if the user wishes so. */52 if (!host.isReallyOk())53 vboxProblem().cannotAccessUSB (host);54 55 if (coll.isNull())56 {57 #else58 NOREF (aPage);59 NOREF (aPath);60 #endif61 /* Disable the USB controller category if the USB controller is62 * not available (i.e. in VirtualBox OSE) */63 QList<QTreeWidgetItem*> items = aDlg->mTwSelector->findItems (64 "#usb", Qt::MatchExactly, listView_Link);65 QTreeWidgetItem *usbItem = items.count() ? items [0] : 0;66 Assert (usbItem);67 if (usbItem)68 usbItem->setHidden (true);69 return;70 #ifdef ENABLE_GLOBAL_USB71 }72 73 43 mSettings = new VBoxVMSettingsUSB (aPage, HostType, aDlg, aPath); 74 44 QVBoxLayout *layout = new QVBoxLayout (aPage); … … 89 59 setTabOrder (mSettings->mLeSerialNo, mSettings->mLePort); 90 60 setTabOrder (mSettings->mLePort, mSettings->mCbAction); 91 #endif92 61 } 93 62
Note:
See TracChangeset
for help on using the changeset viewer.