- Timestamp:
- Feb 26, 2016 10:19:23 AM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.cpp
r59498 r59833 48 48 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 49 49 50 50 51 /** QWidget extension 51 52 * providing GUI for search-panel in VM Log-Viewer. */ … … 78 79 void find(int iButton) 79 80 { 81 /* If button-id is 1, findNext: */ 80 82 if (iButton) 81 83 findNext(); 84 /* If button-id is 0, findBack: */ 82 85 else 83 86 findBack(); 84 87 } 85 88 86 /** Handles textchanged eventfrom search-editor.89 /** Handles textchanged signal from search-editor. 87 90 * @param strSearchString Specifies search-string. */ 88 91 void findCurrent(const QString &strSearchString) 89 92 { 93 /* Enable/disable Next-Previous buttons as per search-string validity: */ 90 94 m_pNextPrevButtons->setEnabled(0, strSearchString.length()); 91 95 m_pNextPrevButtons->setEnabled(1, strSearchString.length()); 96 /* Show/hide the warning as per search-string validity: */ 92 97 toggleWarning(!strSearchString.length()); 98 /* If search-string is valid: */ 93 99 if (strSearchString.length()) 94 100 search(true, true); 101 /* If search-string is not valid, reset cursor position: */ 95 102 else 96 103 { 104 /* Get current log-page: */ 97 105 QTextEdit *pBrowser = m_pViewer->currentLogPage(); 106 /* If current log-page is valid and cursor has selection: */ 98 107 if (pBrowser && pBrowser->textCursor().hasSelection()) 99 108 { 109 /* Get cursor and reset position: */ 100 110 QTextCursor cursor = pBrowser->textCursor(); 101 111 cursor.setPosition(cursor.anchor()); … … 110 120 void prepare() 111 121 { 112 /* Prepare main-layout: */113 prepareMainLayout();114 115 122 /* Prepare widgets: */ 116 123 prepareWidgets(); … … 123 130 } 124 131 125 /** Prepares main-layout. */126 void prepare MainLayout()132 /** Prepares widgets. */ 133 void prepareWidgets() 127 134 { 128 135 /* Create main-layout: */ … … 130 137 AssertPtrReturnVoid(m_pMainLayout); 131 138 { 132 /* Prepare main-layout: */139 /* Configure main-layout: */ 133 140 m_pMainLayout->setSpacing(5); 134 141 /* Not sure 0 margins are default, but just to be safe: */ 135 142 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 136 } 137 } 138 139 /** Prepares widgets. */ 140 void prepareWidgets() 141 { 142 /* Create close-button: */ 143 m_pCloseButton = new UIMiniCancelButton(this); 144 AssertPtrReturnVoid(m_pCloseButton); 145 { 146 /* Add close-button to main-layout: */ 147 m_pMainLayout->addWidget(m_pCloseButton); 148 } 149 150 /* Create search-editor: */ 151 m_pSearchEditor = new UISearchField(this); 152 AssertPtrReturnVoid(m_pSearchEditor); 153 { 154 /* Configure search-editor: */ 155 m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 156 /* Add search-editor to main-layout: */ 157 m_pMainLayout->addWidget(m_pSearchEditor); 158 } 159 160 /* Create search-label: */ 161 m_pSearchLabel = new QLabel(this); 162 AssertPtrReturnVoid(m_pSearchLabel); 163 { 164 /* Configure search-label: */ 165 m_pSearchLabel->setBuddy(m_pSearchEditor); 166 /* Prepare font: */ 143 144 /* Create close-button: */ 145 m_pCloseButton = new UIMiniCancelButton; 146 AssertPtrReturnVoid(m_pCloseButton); 147 { 148 /* Add close-button to main-layout: */ 149 m_pMainLayout->addWidget(m_pCloseButton); 150 } 151 152 /* Create search-editor: */ 153 m_pSearchEditor = new UISearchField(this); 154 AssertPtrReturnVoid(m_pSearchEditor); 155 { 156 /* Configure search-editor: */ 157 m_pSearchEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 158 /* Add search-editor to main-layout: */ 159 m_pMainLayout->addWidget(m_pSearchEditor); 160 } 161 162 /* Create search-label: */ 163 m_pSearchLabel = new QLabel; 164 AssertPtrReturnVoid(m_pSearchLabel); 165 { 166 /* Configure search-label: */ 167 m_pSearchLabel->setBuddy(m_pSearchEditor); 168 /* Prepare font: */ 167 169 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 168 QFont font = m_pSearchLabel->font();169 font.setPointSize(::darwinSmallFontSize());170 m_pSearchLabel->setFont(font);170 QFont font = m_pSearchLabel->font(); 171 font.setPointSize(::darwinSmallFontSize()); 172 m_pSearchLabel->setFont(font); 171 173 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 172 /* Add search-label to main-layout: */173 m_pMainLayout->addWidget(m_pSearchLabel);174 }175 176 /* Create Next/Prev button-box: */177 m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2);178 AssertPtrReturnVoid(m_pNextPrevButtons);179 {180 /* Prepare Next/Prev button-box: */181 m_pNextPrevButtons->setEnabled(0, false);182 m_pNextPrevButtons->setEnabled(1, false);174 /* Add search-label to main-layout: */ 175 m_pMainLayout->addWidget(m_pSearchLabel); 176 } 177 178 /* Create Next/Prev button-box: */ 179 m_pNextPrevButtons = new UIRoundRectSegmentedButton(this, 2); 180 AssertPtrReturnVoid(m_pNextPrevButtons); 181 { 182 /* Configure Next/Prev button-box: */ 183 m_pNextPrevButtons->setEnabled(0, false); 184 m_pNextPrevButtons->setEnabled(1, false); 183 185 #ifndef Q_WS_MAC 184 /* No icons on the Mac: */185 m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this));186 m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this));186 /* No icons on the Mac: */ 187 m_pNextPrevButtons->setIcon(0, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack, this)); 188 m_pNextPrevButtons->setIcon(1, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowForward, this)); 187 189 #endif /* !Q_WS_MAC */ 188 /* Add Next/Prev button-box to main-layout: */189 m_pMainLayout->addWidget(m_pNextPrevButtons);190 }191 192 /* Create case-sensitive checkbox: */193 m_pCaseSensitiveCheckBox = new QCheckBox(this);194 AssertPtrReturnVoid(m_pCaseSensitiveCheckBox);195 {196 /* Configure focus for case-sensitive checkbox: */197 setFocusProxy(m_pCaseSensitiveCheckBox);198 /* Prepare font: */190 /* Add Next/Prev button-box to main-layout: */ 191 m_pMainLayout->addWidget(m_pNextPrevButtons); 192 } 193 194 /* Create case-sensitive checkbox: */ 195 m_pCaseSensitiveCheckBox = new QCheckBox; 196 AssertPtrReturnVoid(m_pCaseSensitiveCheckBox); 197 { 198 /* Configure focus for case-sensitive checkbox: */ 199 setFocusProxy(m_pCaseSensitiveCheckBox); 200 /* Configure font: */ 199 201 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 200 QFont font = m_pCaseSensitiveCheckBox->font();201 font.setPointSize(::darwinSmallFontSize());202 m_pCaseSensitiveCheckBox->setFont(font);202 QFont font = m_pCaseSensitiveCheckBox->font(); 203 font.setPointSize(::darwinSmallFontSize()); 204 m_pCaseSensitiveCheckBox->setFont(font); 203 205 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 204 /* Add case-sensitive checkbox to main-layout: */205 m_pMainLayout->addWidget(m_pCaseSensitiveCheckBox);206 }207 208 /* Create warning-spacer: */209 m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);210 AssertPtrReturnVoid(m_pWarningSpacer);211 {212 /* Add warning-spacer to main-layout: */213 m_pMainLayout->addItem(m_pWarningSpacer);214 }215 216 /* Create warning-icon: */217 m_pWarningIcon = new QLabel(this);218 AssertPtrReturnVoid(m_pWarningIcon);219 {220 /* Confifure warning-icon: */221 m_pWarningIcon->hide();222 QIcon icon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning, this);223 if (!icon.isNull())224 m_pWarningIcon->setPixmap(icon.pixmap(16, 16));225 /* Add warning-icon to main-layout: */226 m_pMainLayout->addWidget(m_pWarningIcon);227 }228 229 /* Create warning-label: */230 m_pWarningLabel = new QLabel(this);231 AssertPtrReturnVoid(m_pWarningLabel);232 {233 /* Configure warning-label: */234 m_pWarningLabel->hide();235 /* Prepare font: */206 /* Add case-sensitive checkbox to main-layout: */ 207 m_pMainLayout->addWidget(m_pCaseSensitiveCheckBox); 208 } 209 210 /* Create warning-spacer: */ 211 m_pWarningSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 212 AssertPtrReturnVoid(m_pWarningSpacer); 213 { 214 /* Add warning-spacer to main-layout: */ 215 m_pMainLayout->addItem(m_pWarningSpacer); 216 } 217 218 /* Create warning-icon: */ 219 m_pWarningIcon = new QLabel; 220 AssertPtrReturnVoid(m_pWarningIcon); 221 { 222 /* Confifure warning-icon: */ 223 m_pWarningIcon->hide(); 224 QIcon icon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning, this); 225 if (!icon.isNull()) 226 m_pWarningIcon->setPixmap(icon.pixmap(16, 16)); 227 /* Add warning-icon to main-layout: */ 228 m_pMainLayout->addWidget(m_pWarningIcon); 229 } 230 231 /* Create warning-label: */ 232 m_pWarningLabel = new QLabel; 233 AssertPtrReturnVoid(m_pWarningLabel); 234 { 235 /* Configure warning-label: */ 236 m_pWarningLabel->hide(); 237 /* Prepare font: */ 236 238 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 237 QFont font = m_pWarningLabel->font();238 font.setPointSize(::darwinSmallFontSize());239 m_pWarningLabel->setFont(font);239 QFont font = m_pWarningLabel->font(); 240 font.setPointSize(::darwinSmallFontSize()); 241 m_pWarningLabel->setFont(font); 240 242 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 241 /* Add warning-label to main-layout: */ 242 m_pMainLayout->addWidget(m_pWarningLabel); 243 } 244 245 /* Create spacer-item: */ 246 m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 247 AssertPtrReturnVoid(m_pSpacerItem); 248 { 249 /* Add spacer-item to main-layout: */ 250 m_pMainLayout->addItem(m_pSpacerItem); 243 /* Add warning-label to main-layout: */ 244 m_pMainLayout->addWidget(m_pWarningLabel); 245 } 246 247 /* Create spacer-item: */ 248 m_pSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 249 AssertPtrReturnVoid(m_pSpacerItem); 250 { 251 /* Add spacer-item to main-layout: */ 252 m_pMainLayout->addItem(m_pSpacerItem); 253 } 251 254 } 252 255 } … … 286 289 switch (pEvent->key()) 287 290 { 288 /* Process Enter press as 'search 291 /* Process Enter press as 'search-next', 289 292 * performed for any search panel widget: */ 290 293 case Qt::Key_Enter: … … 294 297 pEvent->modifiers() & Qt::KeypadModifier) 295 298 { 299 /* Animate click on 'Next' button: */ 296 300 m_pNextPrevButtons->animateClick(1); 297 301 return; … … 302 306 break; 303 307 } 308 /* Call to base-class: */ 304 309 QWidget::keyPressEvent(pEvent); 305 310 } … … 320 325 if (pKeyEvent->key() == Qt::Key_F3) 321 326 { 327 /* If there is no modifier 'Key-F3' is pressed: */ 322 328 if (pKeyEvent->QInputEvent::modifiers() == 0) 323 329 { 330 /* Animate click on 'Next' button: */ 324 331 m_pNextPrevButtons->animateClick(1); 325 332 return true; 326 333 } 334 /* If there is 'ShiftModifier' 'Shift + Key-F3' is pressed: */ 327 335 else if (pKeyEvent->QInputEvent::modifiers() == Qt::ShiftModifier) 328 336 { 337 /* Animate click on 'Prev' button: */ 329 338 m_pNextPrevButtons->animateClick(0); 330 339 return true; … … 337 346 if (m_pViewer->currentLogPage()) 338 347 { 348 /* Make sure current log-page is visible: */ 339 349 if (isHidden()) 340 350 show(); 351 /* Set focus on search-editor: */ 341 352 m_pSearchEditor->setFocus(); 342 353 return true; … … 347 358 pKeyEvent->key() >= Qt::Key_Exclam && pKeyEvent->key() <= Qt::Key_AsciiTilde) 348 359 { 360 /* Make sure current log-page is visible: */ 349 361 if (m_pViewer->currentLogPage()) 350 362 { 351 363 if (isHidden()) 352 364 show(); 365 /* Set focus on search-editor: */ 353 366 m_pSearchEditor->setFocus(); 367 /* Insert the text to search-editor, which triggers the search-operation for new text: */ 354 368 m_pSearchEditor->insert(pKeyEvent->text()); 355 369 return true; … … 368 382 void showEvent(QShowEvent *pEvent) 369 383 { 384 /* Call to base-class: */ 370 385 QWidget::showEvent(pEvent); 386 /* Set focus on search-editor: */ 371 387 m_pSearchEditor->setFocus(); 388 /* Select all the text: */ 372 389 m_pSearchEditor->selectAll(); 373 390 } … … 376 393 void hideEvent(QHideEvent *pEvent) 377 394 { 395 /* Get focus-widget: */ 378 396 QWidget *pFocus = QApplication::focusWidget(); 397 /* If focus-widget is valid and child-widget of search-panel, 398 * focus next child-widget in line: */ 379 399 if (pFocus && pFocus->parent() == this) 380 400 focusNextPrevChild(true); 401 /* Call to base-class: */ 381 402 QWidget::hideEvent(pEvent); 382 403 } … … 387 408 void search(bool fForward, bool fStartCurrent = false) 388 409 { 410 /* Get current log-page: */ 389 411 QTextEdit *pBrowser = m_pViewer->currentLogPage(); 390 412 if (!pBrowser) return; 391 413 414 /* Get text-cursor and its attributes: */ 392 415 QTextCursor cursor = pBrowser->textCursor(); 393 416 int iPos = cursor.position(); 394 417 int iAnc = cursor.anchor(); 395 418 419 /* Get the text to be searched: */ 396 420 QString strText = pBrowser->toPlainText(); 397 421 int iDiff = fStartCurrent ? 0 : 1; 398 422 399 423 int iResult = -1; 424 /* If search-direction is forward and cursor position is valid: */ 400 425 if (fForward && (fStartCurrent || iPos < strText.size() - 1)) 401 426 { 427 /* Search and get the index of first match: */ 402 428 iResult = strText.indexOf(m_pSearchEditor->text(), iAnc + iDiff, 403 429 m_pCaseSensitiveCheckBox->isChecked() ? … … 410 436 Qt::CaseSensitive : Qt::CaseInsensitive); 411 437 } 438 /* If search-direction is backward: */ 412 439 else if (!fForward && iAnc > 0) 413 440 iResult = strText.lastIndexOf(m_pSearchEditor->text(), iAnc - 1, … … 415 442 Qt::CaseSensitive : Qt::CaseInsensitive); 416 443 444 /* If the result is valid, move cursor-position: */ 417 445 if (iResult != -1) 418 446 { … … 427 455 } 428 456 457 /* Show/hide the warning as per search-result: */ 429 458 toggleWarning(iResult != -1); 430 459 } … … 439 468 void toggleWarning(bool fHide) 440 469 { 470 /* Adjust size of warning-spacer accordingly: */ 441 471 m_pWarningSpacer->changeSize(fHide ? 0 : 16, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 472 /* If visible mark the error for search-editor (changes text-color): */ 442 473 if (!fHide) 443 474 m_pSearchEditor->markError(); 475 /* If hidden unmark the error for search-editor (changes text-color): */ 444 476 else 445 477 m_pSearchEditor->unmarkError(); 478 /* Show/hide the warning-icon: */ 446 479 m_pWarningIcon->setHidden(fHide); 480 /* Show/hide the warning-label: */ 447 481 m_pWarningLabel->setHidden(fHide); 448 482 } … … 472 506 }; 473 507 508 474 509 /** QWidget extension 475 510 * providing GUI for filter panel in VM Log Viewer. */ … … 551 586 void prepare() 552 587 { 553 /* Prepare main-layout: */554 prepareMainLayout();555 556 588 /* Prepare widgets: */ 557 589 prepareWidgets(); … … 564 596 } 565 597 566 /** Prepares main-layout. */567 void prepare MainLayout()598 /** Prepares widgets. */ 599 void prepareWidgets() 568 600 { 569 601 /* Create main-layout: */ … … 575 607 /* Not sure 0 margins are default, but just to be safe: */ 576 608 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 577 } 578 } 579 580 /** Prepares widgets. */ 581 void prepareWidgets() 582 { 583 /* Create close-button: */ 584 m_pCloseButton = new UIMiniCancelButton(this); 585 AssertPtrReturnVoid(m_pCloseButton); 586 { 587 /* Add close-button to main-layout: */ 588 m_pMainLayout->addWidget(m_pCloseButton); 589 } 590 591 /* Create filter-combobox: */ 592 m_pFilterComboBox = new QComboBox(this); 593 AssertPtrReturnVoid(m_pFilterComboBox); 594 { 595 /* Configure filter-combobox: */ 596 m_pFilterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 597 m_pFilterComboBox->setEditable(true); 598 QStringList strFilterPresets; 599 strFilterPresets << "" << "GUI" << "NAT" << "AHCI" << "VD" << "Audio" << "VUSB" << "SUP" << "PGM" << "HDA" 600 << "HM" << "VMM" << "GIM" << "CPUM"; 601 strFilterPresets.sort(); 602 m_pFilterComboBox->addItems(strFilterPresets); 603 /* Add filter-combobox to main-layout: */ 604 m_pMainLayout->addWidget(m_pFilterComboBox); 605 } 606 607 /* Create filter-label: */ 608 m_pFilterLabel = new QLabel(this); 609 AssertPtrReturnVoid(m_pFilterLabel); 610 { 611 /* Configure filter-label: */ 612 m_pFilterLabel->setBuddy(m_pFilterComboBox); 609 610 /* Create close-button: */ 611 m_pCloseButton = new UIMiniCancelButton; 612 AssertPtrReturnVoid(m_pCloseButton); 613 { 614 /* Add close-button to main-layout: */ 615 m_pMainLayout->addWidget(m_pCloseButton); 616 } 617 618 /* Create filter-combobox: */ 619 m_pFilterComboBox = new QComboBox; 620 AssertPtrReturnVoid(m_pFilterComboBox); 621 { 622 /* Configure filter-combobox: */ 623 m_pFilterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 624 m_pFilterComboBox->setEditable(true); 625 QStringList strFilterPresets; 626 strFilterPresets << "" << "GUI" << "NAT" << "AHCI" << "VD" << "Audio" << "VUSB" << "SUP" << "PGM" << "HDA" 627 << "HM" << "VMM" << "GIM" << "CPUM"; 628 strFilterPresets.sort(); 629 m_pFilterComboBox->addItems(strFilterPresets); 630 /* Add filter-combobox to main-layout: */ 631 m_pMainLayout->addWidget(m_pFilterComboBox); 632 } 633 634 /* Create filter-label: */ 635 m_pFilterLabel = new QLabel; 636 AssertPtrReturnVoid(m_pFilterLabel); 637 { 638 /* Configure filter-label: */ 639 m_pFilterLabel->setBuddy(m_pFilterComboBox); 613 640 #ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS 614 QFont font = m_pFilterLabel->font();615 font.setPointSize(::darwinSmallFontSize());616 m_pFilterLabel->setFont(font);641 QFont font = m_pFilterLabel->font(); 642 font.setPointSize(::darwinSmallFontSize()); 643 m_pFilterLabel->setFont(font); 617 644 #endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */ 618 /* Add filter-label to main-layout: */ 619 m_pMainLayout->addWidget(m_pFilterLabel); 645 /* Add filter-label to main-layout: */ 646 m_pMainLayout->addWidget(m_pFilterLabel); 647 } 620 648 } 621 649 } … … 674 702 void showEvent(QShowEvent *pEvent) 675 703 { 704 /* Call to base-class: */ 676 705 QWidget::showEvent(pEvent); 706 /* Set focus to combo-box: */ 677 707 m_pFilterComboBox->setFocus(); 678 708 } … … 681 711 void hideEvent(QHideEvent *pEvent) 682 712 { 713 /* Get focused widget: */ 683 714 QWidget *pFocus = QApplication::focusWidget(); 715 /* If focus-widget is valid and child-widget of search-panel, 716 * focus next child-widget in line: */ 684 717 if (pFocus && pFocus->parent() == this) 685 718 focusNextPrevChild(true); 719 /* Call to base-class: */ 686 720 QWidget::hideEvent(pEvent); 687 721 } … … 700 734 QString m_strFilterText; 701 735 }; 736 737 738 /********************************************************************************************************************************* 739 * Class UIVMLogViewer implementation. * 740 *********************************************************************************************************************************/ 702 741 703 742 /** Holds the VM Log-Viewer array. */ … … 899 938 loadSettings(); 900 939 901 /* Loading language constants */940 /* Loading language constants: */ 902 941 retranslateUi(); 903 942 } … … 909 948 AssertPtrReturnVoid(m_pViewerContainer); 910 949 { 911 /* Layout VM Log-Viewer container: */950 /* Add VM Log-Viewer container to main-layout: */ 912 951 m_pMainLayout->insertWidget(0, m_pViewerContainer); 913 952 } … … 920 959 centralWidget()->installEventFilter(m_pSearchPanel); 921 960 m_pSearchPanel->hide(); 922 /* Layout VM Log-Viewer search-panel: */961 /* Add VM Log-Viewer search-panel to main-layout: */ 923 962 m_pMainLayout->insertWidget(1, m_pSearchPanel); 924 963 } … … 931 970 centralWidget()->installEventFilter(m_pFilterPanel); 932 971 m_pFilterPanel->hide(); 933 /* Layout VM Log-Viewer filter-panel: */972 /* Add VM Log-Viewer filter-panel to main-layout: */ 934 973 m_pMainLayout->insertWidget(2, m_pFilterPanel); 935 974 } … … 966 1005 } 967 1006 1007 void UIVMLogViewer::loadSettings() 1008 { 1009 /* Restore window geometry: */ 1010 { 1011 /* Getting available geometry to calculate default geometry: */ 1012 const QRect desktopRect = vboxGlobal().availableGeometry(this); 1013 int iDefaultWidth = desktopRect.width() / 2; 1014 int iDefaultHeight = desktopRect.height() * 3 / 4; 1015 1016 /* Calculate default width to fit 132 characters: */ 1017 QTextEdit *pCurrentLogPage = currentLogPage(); 1018 if (pCurrentLogPage) 1019 { 1020 iDefaultWidth = pCurrentLogPage->fontMetrics().width(QChar('x')) * 132 + 1021 pCurrentLogPage->verticalScrollBar()->width() + 1022 pCurrentLogPage->frameWidth() * 2 + 1023 10 * 2 /* m_pViewerContainer margin */ + 1024 10 * 2 /* CentralWidget margin */; 1025 } 1026 QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight); 1027 defaultGeometry.moveCenter(parentWidget()->geometry().center()); 1028 1029 /* Load geometry: */ 1030 m_geometry = gEDataManager->logWindowGeometry(this, defaultGeometry); 1031 #ifdef Q_WS_MAC 1032 move(m_geometry.topLeft()); 1033 resize(m_geometry.size()); 1034 #else /* !Q_WS_MAC */ 1035 setGeometry(m_geometry); 1036 #endif /* !Q_WS_MAC */ 1037 LogRel2(("GUI: UIVMLogViewer: Geometry loaded to: Origin=%dx%d, Size=%dx%d\n", 1038 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height())); 1039 1040 /* Maximize (if necessary): */ 1041 if (gEDataManager->logWindowShouldBeMaximized()) 1042 showMaximized(); 1043 } 1044 } 1045 1046 void UIVMLogViewer::saveSettings() 1047 { 1048 /* Save window geometry: */ 1049 { 1050 /* Save geometry: */ 1051 const QRect saveGeometry = geometry(); 1052 #ifdef Q_WS_MAC 1053 gEDataManager->setLogWindowGeometry(saveGeometry, ::darwinIsWindowMaximized(this)); 1054 #else /* !Q_WS_MAC */ 1055 gEDataManager->setLogWindowGeometry(saveGeometry, isMaximized()); 1056 #endif /* !Q_WS_MAC */ 1057 LogRel2(("GUI: UIVMLogViewer: Geometry saved as: Origin=%dx%d, Size=%dx%d\n", 1058 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height())); 1059 } 1060 } 1061 968 1062 void UIVMLogViewer::cleanup() 969 1063 { … … 1006 1100 return; 1007 1101 1008 m_fIsPolished = true; 1102 m_fIsPolished = true; 1009 1103 1010 1104 /* Make sure the log view widget has the focus: */ … … 1053 1147 QTextEdit* UIVMLogViewer::currentLogPage() 1054 1148 { 1149 /* If viewer-container is enabled: */ 1055 1150 if (m_pViewerContainer->isEnabled()) 1056 1151 { 1152 /* Get and return current log-page: */ 1057 1153 QWidget *pContainer = m_pViewerContainer->currentWidget(); 1058 1154 QTextEdit *pBrowser = pContainer->findChild<QTextEdit*>(); … … 1060 1156 return pBrowser ? pBrowser : 0; 1061 1157 } 1062 else1063 1158 /* Return NULL by default: */ 1159 return 0; 1064 1160 } 1065 1161 … … 1101 1197 } 1102 1198 1103 void UIVMLogViewer::loadSettings()1104 {1105 /* Restore window geometry: */1106 {1107 /* Getting available geometry to calculate default geometry: */1108 const QRect desktopRect = vboxGlobal().availableGeometry(this);1109 int iDefaultWidth = desktopRect.width() / 2;1110 int iDefaultHeight = desktopRect.height() * 3 / 4;1111 1112 /* Calculate default width to fit 132 characters: */1113 QTextEdit *pCurrentLogPage = currentLogPage();1114 if (pCurrentLogPage)1115 {1116 iDefaultWidth = pCurrentLogPage->fontMetrics().width(QChar('x')) * 132 +1117 pCurrentLogPage->verticalScrollBar()->width() +1118 pCurrentLogPage->frameWidth() * 2 +1119 /* m_pViewerContainer margin */ 10 * 2 +1120 /* CentralWidget margin */ 10 * 2;1121 }1122 QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);1123 defaultGeometry.moveCenter(parentWidget()->geometry().center());1124 1125 /* Load geometry: */1126 m_geometry = gEDataManager->logWindowGeometry(this, defaultGeometry);1127 #ifdef Q_WS_MAC1128 move(m_geometry.topLeft());1129 resize(m_geometry.size());1130 #else /* Q_WS_MAC */1131 setGeometry(m_geometry);1132 #endif /* !Q_WS_MAC */1133 LogRel2(("GUI: UIVMLogViewer: Geometry loaded to: Origin=%dx%d, Size=%dx%d\n",1134 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height()));1135 1136 /* Maximize (if necessary): */1137 if (gEDataManager->logWindowShouldBeMaximized())1138 showMaximized();1139 }1140 }1141 1142 void UIVMLogViewer::saveSettings()1143 {1144 /* Save window geometry: */1145 {1146 /* Save geometry: */1147 const QRect saveGeometry = geometry();1148 #ifdef Q_WS_MAC1149 gEDataManager->setLogWindowGeometry(saveGeometry, ::darwinIsWindowMaximized(this));1150 #else /* Q_WS_MAC */1151 gEDataManager->setLogWindowGeometry(saveGeometry, isMaximized());1152 #endif /* !Q_WS_MAC */1153 LogRel2(("GUI: UIVMLogViewer: Geometry saved as: Origin=%dx%d, Size=%dx%d\n",1154 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height()));1155 }1156 }1157 1158 1199 #include "UIVMLogViewer.moc" 1159 1200 -
trunk/src/VBox/Frontends/VirtualBox/src/UIVMLogViewer.h
r59498 r59833 73 73 /** Handles search action triggering. */ 74 74 void search(); 75 /** Handles search action triggering. */75 /** Handles refresh action triggering. */ 76 76 void refresh(); 77 77 /** Handles close action triggering. */ … … 84 84 private: 85 85 86 /** Prepares VM Log-Viewer. */ 87 void prepare(); 86 /** @name Prepare/Cleanup 87 * @{ */ 88 /** Prepares VM Log-Viewer. */ 89 void prepare(); 90 /** Prepares widgets. */ 91 void prepareWidgets(); 92 /** Prepares connections. */ 93 void prepareConnections(); 94 /** Load settings helper. */ 95 void loadSettings(); 88 96 89 /** Prepares widgets. */ 90 void prepareWidgets(); 97 /** Save settings helper. */ 98 void saveSettings(); 99 /** Cleanups VM Log-Viewer. */ 100 void cleanup(); 101 /** @} */ 91 102 92 /** Prepares connections. */ 93 void prepareConnections(); 103 /** @name Event handling stuff. 104 * @{ */ 105 /** Handles translation event. */ 106 void retranslateUi(); 94 107 95 /** Cleanups VM Log-Viewer. */ 96 void cleanup(); 97 98 /** Handles translation event. */ 99 void retranslateUi(); 100 101 /** Handles Qt show @a pEvent. */ 102 void showEvent(QShowEvent *pEvent); 103 104 /** Handles Qt key-press @a pEvent. */ 105 void keyPressEvent(QKeyEvent *pEvent); 108 /** Handles Qt show @a pEvent. */ 109 void showEvent(QShowEvent *pEvent); 110 /** Handles Qt key-press @a pEvent. */ 111 void keyPressEvent(QKeyEvent *pEvent); 112 /** @} */ 106 113 107 114 /** Returns the current log-page. */ … … 111 118 /** Returns the content of current log-page. */ 112 119 const QString& currentLog(); 113 114 /** Load settings helper. */115 void loadSettings();116 117 /** Save settings helper. */118 void saveSettings();119 120 120 121 /** Holds the list of all VM Log Viewers. */ … … 142 143 VMLogMap m_logMap; 143 144 144 /** Current dialog geometry. */145 /** Holds the current dialog geometry. */ 145 146 QRect m_geometry; 146 147
Note:
See TracChangeset
for help on using the changeset viewer.