- Timestamp:
- Jun 6, 2013 2:03:02 PM (12 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/UIMachineSettingsDisplay.cpp
r46413 r46414 31 31 #include "CVRDEServer.h" 32 32 33 /**34 * Calculates a suitable page step size for the given max value. The returned35 * size is so that there will be no more than 32 pages. The minimum returned36 * page size is 4.37 */38 static int calcPageStep (int aMax)39 {40 /* reasonable max. number of page steps is 32 */41 uint page = ((uint) aMax + 31) / 32;42 /* make it a power of 2 */43 uint p = page, p2 = 0x1;44 while ((p >>= 1))45 p2 <<= 1;46 if (page != p2)47 p2 <<= 1;48 if (p2 < 4)49 p2 = 4;50 return (int) p2;51 }52 53 33 UIMachineSettingsDisplay::UIMachineSettingsDisplay() 54 34 : m_pValidator(0) … … 64 44 #endif /* VBOX_WITH_CRHGSMI */ 65 45 { 66 /* Apply UI decorations: */ 67 Ui::UIMachineSettingsDisplay::setupUi(this); 68 69 /* Prepare variables: */ 70 CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); 71 m_iMinVRAM = sys.GetMinGuestVRAM(); 72 m_iMaxVRAM = sys.GetMaxGuestVRAM(); 73 m_iMaxVRAMVisible = m_iMaxVRAM; 74 #if (QT_VERSION >= 0x040600) 75 const uint cHostScreens = QApplication::desktop()->screenCount(); 76 #else /* (QT_VERSION >= 0x040600) */ 77 const uint cHostScreens = QApplication::desktop()->numScreens(); 78 #endif /* !(QT_VERSION >= 0x040600) */ 79 const uint cMinGuestScreens = 1; 80 const uint cMaxGuestScreens = sys.GetMaxGuestMonitors(); 81 82 /* Setup validators: */ 83 m_pEditorMemory->setValidator(new QIntValidator(m_iMinVRAM, m_iMaxVRAMVisible, this)); 84 m_pEditorScreens->setValidator(new QIntValidator(cMinGuestScreens, cMaxGuestScreens, this)); 85 m_pEditorRemoteDisplayPort->setValidator(new QRegExpValidator(QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this)); 86 m_pEditorRemoteDisplayTimeout->setValidator(new QIntValidator(this)); 87 88 /* Setup connections: */ 89 connect(m_pSliderMemory, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedVRAM(int))); 90 connect(m_pEditorMemory, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedVRAM(const QString&))); 91 connect(m_pSliderScreeens, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedScreens(int))); 92 connect(m_pEditorScreens, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedScreens(const QString&))); 93 94 /* Setup widgets: */ 95 m_pSliderMemory->setPageStep(calcPageStep(m_iMaxVRAMVisible)); 96 m_pSliderMemory->setSingleStep(m_pSliderMemory->pageStep() / 4); 97 m_pSliderMemory->setTickInterval(m_pSliderMemory->pageStep()); 98 m_pSliderScreeens->setPageStep(1); 99 m_pSliderScreeens->setSingleStep(1); 100 m_pSliderScreeens->setTickInterval(1); 101 /* Setup the scale so that ticks are at page step boundaries: */ 102 m_pSliderMemory->setMinimum((m_iMinVRAM / m_pSliderMemory->pageStep()) * m_pSliderMemory->pageStep()); 103 m_pSliderMemory->setMaximum(m_iMaxVRAMVisible); 104 m_pSliderMemory->setSnappingEnabled(true); 105 m_pSliderMemory->setErrorHint(0, 1); 106 m_pSliderScreeens->setMinimum(cMinGuestScreens); 107 m_pSliderScreeens->setMaximum(cMaxGuestScreens); 108 m_pSliderScreeens->setErrorHint(0, cMinGuestScreens); 109 m_pSliderScreeens->setOptimalHint(cMinGuestScreens, cHostScreens); 110 m_pSliderScreeens->setWarningHint(cHostScreens, cMaxGuestScreens); 111 /* Limit min/max. size of QLineEdit: */ 112 m_pEditorMemory->setFixedWidthByText(QString().fill('8', 4)); 113 m_pEditorScreens->setFixedWidthByText(QString().fill('8', 4)); 114 /* Ensure value and validation is updated: */ 115 sltValueChangedVRAM(m_pSliderMemory->value()); 116 sltValueChangedScreens(m_pSliderScreeens->value()); 117 #ifndef VBOX_WITH_VIDEOHWACCEL 118 /* Hide check-box if not supported: */ 119 mCb2DVideo->setVisible(false); 120 #endif /* VBOX_WITH_VIDEOHWACCEL */ 121 122 /* Prepare auth-method combo: */ 123 m_pComboRemoteDisplayAuthMethod->insertItem(0, ""); /* KAuthType_Null */ 124 m_pComboRemoteDisplayAuthMethod->insertItem(1, ""); /* KAuthType_External */ 125 m_pComboRemoteDisplayAuthMethod->insertItem(2, ""); /* KAuthType_Guest */ 126 127 /* Translate finally: */ 128 retranslateUi(); 46 /* Prepare: */ 47 prepare(); 129 48 } 130 49 … … 445 364 } 446 365 366 void UIMachineSettingsDisplay::polishPage() 367 { 368 /* Get system data from cache: */ 369 const UIDataSettingsMachineDisplay &displayData = m_cache.base(); 370 371 /* Video tab: */ 372 m_pContainerVideo->setEnabled(isMachineOffline()); 373 #ifdef VBOX_WITH_VIDEOHWACCEL 374 mCb2DVideo->setEnabled(VBoxGlobal::isAcceleration2DVideoAvailable()); 375 #endif /* VBOX_WITH_VIDEOHWACCEL */ 376 377 /* Remote Display tab: */ 378 m_pTabWidget->setTabEnabled(1, displayData.m_fRemoteDisplayServerSupported); 379 m_pContainerRemoteDisplay->setEnabled(isMachineInValidMode()); 380 m_pContainerRemoteDisplayOptions->setEnabled(m_pCheckboxRemoteDisplay->isChecked()); 381 m_pLabelRemoteDisplayOptions->setEnabled(isMachineOffline() || isMachineSaved()); 382 m_pCheckboxMultipleConn->setEnabled(isMachineOffline() || isMachineSaved()); 383 } 384 447 385 void UIMachineSettingsDisplay::sltValueChangedVRAM(int iValue) 448 386 { … … 464 402 { 465 403 m_pSliderScreeens->setValue(strText.toInt()); 404 } 405 406 void UIMachineSettingsDisplay::prepare() 407 { 408 /* Apply UI decorations: */ 409 Ui::UIMachineSettingsDisplay::setupUi(this); 410 411 /* Prepare tabs: */ 412 prepareVideoTab(); 413 prepareRemoteDisplayTab(); 414 415 /* Translate finally: */ 416 retranslateUi(); 417 } 418 419 void UIMachineSettingsDisplay::prepareVideoTab() 420 { 421 /* Prepare variables: */ 422 CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); 423 m_iMinVRAM = sys.GetMinGuestVRAM(); 424 m_iMaxVRAM = sys.GetMaxGuestVRAM(); 425 m_iMaxVRAMVisible = m_iMaxVRAM; 426 #if (QT_VERSION >= 0x040600) 427 const uint cHostScreens = QApplication::desktop()->screenCount(); 428 #else /* (QT_VERSION >= 0x040600) */ 429 const uint cHostScreens = QApplication::desktop()->numScreens(); 430 #endif /* !(QT_VERSION >= 0x040600) */ 431 const uint cMinGuestScreens = 1; 432 const uint cMaxGuestScreens = sys.GetMaxGuestMonitors(); 433 434 /* Setup validators: */ 435 m_pEditorMemory->setValidator(new QIntValidator(m_iMinVRAM, m_iMaxVRAMVisible, this)); 436 m_pEditorScreens->setValidator(new QIntValidator(cMinGuestScreens, cMaxGuestScreens, this)); 437 m_pEditorRemoteDisplayPort->setValidator(new QRegExpValidator(QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this)); 438 m_pEditorRemoteDisplayTimeout->setValidator(new QIntValidator(this)); 439 440 /* Setup connections: */ 441 connect(m_pSliderMemory, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedVRAM(int))); 442 connect(m_pEditorMemory, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedVRAM(const QString&))); 443 connect(m_pSliderScreeens, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedScreens(int))); 444 connect(m_pEditorScreens, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedScreens(const QString&))); 445 446 /* Setup widgets: */ 447 m_pSliderMemory->setPageStep(calcPageStep(m_iMaxVRAMVisible)); 448 m_pSliderMemory->setSingleStep(m_pSliderMemory->pageStep() / 4); 449 m_pSliderMemory->setTickInterval(m_pSliderMemory->pageStep()); 450 m_pSliderScreeens->setPageStep(1); 451 m_pSliderScreeens->setSingleStep(1); 452 m_pSliderScreeens->setTickInterval(1); 453 454 /* Setup the scale so that ticks are at page step boundaries: */ 455 m_pSliderMemory->setMinimum((m_iMinVRAM / m_pSliderMemory->pageStep()) * m_pSliderMemory->pageStep()); 456 m_pSliderMemory->setMaximum(m_iMaxVRAMVisible); 457 m_pSliderMemory->setSnappingEnabled(true); 458 m_pSliderMemory->setErrorHint(0, 1); 459 m_pSliderScreeens->setMinimum(cMinGuestScreens); 460 m_pSliderScreeens->setMaximum(cMaxGuestScreens); 461 m_pSliderScreeens->setErrorHint(0, cMinGuestScreens); 462 m_pSliderScreeens->setOptimalHint(cMinGuestScreens, cHostScreens); 463 m_pSliderScreeens->setWarningHint(cHostScreens, cMaxGuestScreens); 464 465 /* Limit min/max. size of QLineEdit: */ 466 m_pEditorMemory->setFixedWidthByText(QString().fill('8', 4)); 467 m_pEditorScreens->setFixedWidthByText(QString().fill('8', 4)); 468 469 /* Ensure value and validation is updated: */ 470 sltValueChangedVRAM(m_pSliderMemory->value()); 471 sltValueChangedScreens(m_pSliderScreeens->value()); 472 473 #ifndef VBOX_WITH_VIDEOHWACCEL 474 /* Hide check-box if not supported: */ 475 mCb2DVideo->setVisible(false); 476 #endif /* VBOX_WITH_VIDEOHWACCEL */ 477 } 478 479 void UIMachineSettingsDisplay::prepareRemoteDisplayTab() 480 { 481 /* Prepare auth-method combo: */ 482 m_pComboRemoteDisplayAuthMethod->insertItem(0, ""); /* KAuthType_Null */ 483 m_pComboRemoteDisplayAuthMethod->insertItem(1, ""); /* KAuthType_External */ 484 m_pComboRemoteDisplayAuthMethod->insertItem(2, ""); /* KAuthType_Guest */ 466 485 } 467 486 … … 521 540 } 522 541 523 void UIMachineSettingsDisplay::polishPage() 524 { 525 /* Get system data from cache: */ 526 const UIDataSettingsMachineDisplay &displayData = m_cache.base(); 527 528 /* Video tab: */ 529 m_pContainerVideo->setEnabled(isMachineOffline()); 530 #ifdef VBOX_WITH_VIDEOHWACCEL 531 mCb2DVideo->setEnabled(VBoxGlobal::isAcceleration2DVideoAvailable()); 532 #endif /* VBOX_WITH_VIDEOHWACCEL */ 533 534 /* Remote Display tab: */ 535 m_pTabWidget->setTabEnabled(1, displayData.m_fRemoteDisplayServerSupported); 536 m_pContainerRemoteDisplay->setEnabled(isMachineInValidMode()); 537 m_pContainerRemoteDisplayOptions->setEnabled(m_pCheckboxRemoteDisplay->isChecked()); 538 m_pLabelRemoteDisplayOptions->setEnabled(isMachineOffline() || isMachineSaved()); 539 m_pCheckboxMultipleConn->setEnabled(isMachineOffline() || isMachineSaved()); 540 } 541 542 /* static */ 543 int UIMachineSettingsDisplay::calcPageStep(int iMax) 544 { 545 /* Reasonable max. number of page steps is 32. */ 546 uint page = ((uint)iMax + 31) / 32; 547 /* Make it a power of 2: */ 548 uint p = page, p2 = 0x1; 549 while ((p >>= 1)) 550 p2 <<= 1; 551 if (page != p2) 552 p2 <<= 1; 553 if (p2 < 4) 554 p2 = 4; 555 return (int)p2; 556 } 557 558 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.h
r46413 r46414 106 106 protected: 107 107 108 /* API: Cache stuff: */ 109 bool changed() const { return m_cache.wasChanged(); } 110 108 111 /* Load data to cache from corresponding external object(s), 109 112 * this task COULD be performed in other than GUI thread: */ … … 120 123 void saveFromCacheTo(QVariant &data); 121 124 122 /* API: Cache stuff: */123 bool changed() const { return m_cache.wasChanged(); }124 125 125 /* API: Validation stuff: */ 126 126 void setValidator(QIWidgetValidator *pValidator); … … 132 132 /* Helper: Translate stuff: */ 133 133 void retranslateUi(); 134 135 /* Helper: Polish stuff: */ 136 void polishPage(); 134 137 135 138 private slots: … … 143 146 private: 144 147 148 /* Helpers: Prepare stuff: */ 149 void prepare(); 150 void prepareVideoTab(); 151 void prepareRemoteDisplayTab(); 152 145 153 /* Helpers: Video stuff: */ 146 154 void checkVRAMRequirements(); 147 155 bool shouldWeWarnAboutLowVideoMemory(); 148 149 /* Helper: Polish stuff: */ 150 void polishPage(); 156 static int calcPageStep(int iMax); 151 157 152 158 /* Validation stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.