Changeset 70663 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 21, 2018 9:28:37 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/logviewer
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r70647 r70663 49 49 , m_bShowLineNumbers(true) 50 50 , m_bWrapLines(false) 51 , m_iFontSizeInPoints(9) 51 52 { 52 53 prepare(); … … 247 248 if (m_pTextEdit) 248 249 m_pTextEdit->setFocus(); 249 250 applySettings(); 250 251 QWidget::showEvent(pEvent); 251 252 } … … 300 301 return; 301 302 m_bShowLineNumbers = bShowLineNumbers; 302 if (m_pTextEdit)303 m_pTextEdit->setShowLineNumbers(m_bShowLineNumbers);304 update();305 303 } 306 304 … … 310 308 return; 311 309 m_bWrapLines = bWrapLines; 312 if (m_pTextEdit) 313 m_pTextEdit->setWrapLines(m_bWrapLines); 314 update(); 310 applySettings(); 315 311 } 316 312 … … 324 320 } 325 321 322 void UIVMLogPage::setFontSizeInPoints(int fontSize) 323 { 324 if (m_iFontSizeInPoints == fontSize) 325 return; 326 m_iFontSizeInPoints = fontSize; 327 applySettings(); 328 } 329 330 int UIVMLogPage::fontSizeInPoints() const 331 { 332 return m_iFontSizeInPoints; 333 } 334 326 335 int UIVMLogPage::filteredLineCount() const 327 336 { … … 345 354 return false; 346 355 } 356 357 void UIVMLogPage::applySettings() 358 { 359 if (!isVisible()) 360 return; 361 if (!m_pTextEdit) 362 return; 363 if (m_bWrapLines != m_pTextEdit->wrapLines()) 364 m_pTextEdit->setWrapLines(m_bWrapLines); 365 366 if (m_bShowLineNumbers != m_pTextEdit->showLineNumbers()) 367 m_pTextEdit->setShowLineNumbers(m_bShowLineNumbers); 368 369 if (m_iFontSizeInPoints != m_pTextEdit->fontSizeInPoints()) 370 m_pTextEdit->setFontSizeInPoints(m_iFontSizeInPoints); 371 372 update(); 373 374 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.h
r70645 r70663 109 109 bool shouldFilterBeApplied(const QSet<QString> &filterTermSet, int filterOperationType) const; 110 110 111 void setFontSizeInPoints(int fontSize); 112 int fontSizeInPoints() const; 113 111 114 protected: 112 115 … … 126 129 void updateTextEditBookmarkLineSet(); 127 130 void deleteBookmark(LogBookmark bookmark); 131 /** When settings for this changed, they are applied immediately 132 only if this is visible, if not they are applied when this becomes 133 visible. */ 134 void applySettings(); 128 135 129 136 QHBoxLayout *m_pMainLayout; … … 161 168 bool m_bShowLineNumbers; 162 169 bool m_bWrapLines; 170 int m_iFontSizeInPoints; 163 171 }; 164 172 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterPanel.cpp
r70649 r70663 275 275 int hitCount = 0; 276 276 277 for (QSet<QString>::const_iterator iterator = m_filterTermSet.begin();277 for (QSet<QString>::const_iterator iterator = m_filterTermSet.begin(); 278 278 iterator != m_filterTermSet.end(); ++iterator) 279 279 { -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSettingsPanel.cpp
r70617 r70663 27 27 # endif 28 28 # include <QCheckBox> 29 # include <QLabel> 30 # include <QSpinBox> 29 31 30 32 /* GUI includes: */ … … 40 42 , m_pLineNumberCheckBox(0) 41 43 , m_pWrapLinesCheckBox(0) 44 , m_pFontSizeSpinBox(0) 45 , m_pFontSizeLabel(0) 46 , m_iDefaultFontSize(9) 42 47 { 43 48 prepare(); … … 62 67 } 63 68 69 void UIVMLogViewerSettingsPanel::setFontSizeInPoints(int fontSizeInPoints) 70 { 71 if (!m_pFontSizeSpinBox) 72 return; 73 if (m_pFontSizeSpinBox->value() == fontSizeInPoints) 74 return; 75 m_pFontSizeSpinBox->setValue(fontSizeInPoints); 76 } 64 77 65 78 void UIVMLogViewerSettingsPanel::prepareWidgets() … … 68 81 return; 69 82 70 m_pLineNumberCheckBox = new QCheckBox(this); 71 AssertPtrReturnVoid(m_pLineNumberCheckBox); 72 m_pLineNumberCheckBox->setChecked(true); 73 mainLayout()->addWidget(m_pLineNumberCheckBox, 0, Qt::AlignLeft); 83 m_pLineNumberCheckBox = new QCheckBox; 84 if (m_pLineNumberCheckBox) 85 { 86 m_pLineNumberCheckBox->setChecked(true); 87 mainLayout()->addWidget(m_pLineNumberCheckBox, 0, Qt::AlignLeft); 88 } 74 89 75 m_pWrapLinesCheckBox = new QCheckBox(this); 76 AssertPtrReturnVoid(m_pWrapLinesCheckBox); 77 m_pWrapLinesCheckBox->setChecked(false); 78 mainLayout()->addWidget(m_pWrapLinesCheckBox, 0, Qt::AlignLeft); 90 m_pWrapLinesCheckBox = new QCheckBox; 91 if (m_pWrapLinesCheckBox) 92 { 93 m_pWrapLinesCheckBox->setChecked(false); 94 mainLayout()->addWidget(m_pWrapLinesCheckBox, 0, Qt::AlignLeft); 95 } 79 96 97 m_pFontSizeSpinBox = new QSpinBox; 98 if (m_pFontSizeSpinBox) 99 { 100 mainLayout()->addWidget(m_pFontSizeSpinBox, 0, Qt::AlignLeft); 101 m_pFontSizeSpinBox->setValue(m_iDefaultFontSize); 102 m_pFontSizeSpinBox->setMaximum(44); 103 m_pFontSizeSpinBox->setMinimum(6); 104 } 105 106 m_pFontSizeLabel = new QLabel; 107 if (m_pFontSizeLabel) 108 { 109 mainLayout()->addWidget(m_pFontSizeLabel, 0, Qt::AlignLeft); 110 } 80 111 mainLayout()->addStretch(2); 81 112 } … … 87 118 if (m_pWrapLinesCheckBox) 88 119 connect(m_pWrapLinesCheckBox, &QCheckBox::toggled, this, &UIVMLogViewerSettingsPanel::sigWrapLines); 120 if (m_pFontSizeSpinBox) 121 connect(m_pFontSizeSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 122 this, &UIVMLogViewerSettingsPanel::sigFontSizeInPoints); 89 123 } 90 124 … … 97 131 m_pWrapLinesCheckBox->setText(UIVMLogViewerWidget::tr("Wrap Lines")); 98 132 m_pWrapLinesCheckBox->setToolTip(UIVMLogViewerWidget::tr("Wrap Lines")); 133 134 m_pFontSizeLabel->setText(UIVMLogViewerWidget::tr("Font Size")); 135 m_pFontSizeSpinBox->setToolTip(UIVMLogViewerWidget::tr("Log Viewer Font Size")); 99 136 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerSettingsPanel.h
r70581 r70663 24 24 /* Forward declarations: */ 25 25 class QCheckBox; 26 class QSpinBox; 26 27 class UIVMLogViewerWidget; 28 class QLabel; 27 29 28 30 /** UIVMLogViewerPanel extension providing GUI to manage logviewer settings. */ … … 35 37 void sigShowLineNumbers(bool show); 36 38 void sigWrapLines(bool show); 39 void sigFontSizeInPoints(int size); 37 40 38 41 public: … … 42 45 void setShowLineNumbers(bool bShowLineNumbers); 43 46 void setWrapLines(bool bWrapLines); 47 void setFontSizeInPoints(int fontSizeInPoints); 44 48 45 49 public slots: … … 60 64 QCheckBox *m_pLineNumberCheckBox; 61 65 QCheckBox *m_pWrapLinesCheckBox; 66 QSpinBox *m_pFontSizeSpinBox; 67 QLabel *m_pFontSizeLabel; 68 69 /** Default font size in points. */ 70 const int m_iDefaultFontSize; 71 62 72 }; 63 73 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r70655 r70663 466 466 } 467 467 468 bool UIVMLogViewerTextEdit::showLineNumbers() const 469 { 470 return m_bShowLineNumbers; 471 } 472 468 473 void UIVMLogViewerTextEdit::setWrapLines(bool bWrapLines) 469 474 { … … 481 486 setWordWrapMode(QTextOption::NoWrap); 482 487 } 483 484 488 update(); 489 } 490 491 void UIVMLogViewerTextEdit::setFontSizeInPoints(int fontSize) 492 { 493 if (fontSizeInPoints() == fontSize) 494 return; 495 QFont newFont(font()); 496 newFont.setPointSize(fontSize); 497 setFont(newFont); 498 } 499 500 int UIVMLogViewerTextEdit::fontSizeInPoints() const 501 { 502 return font().pointSize(); 503 } 504 505 bool UIVMLogViewerTextEdit::wrapLines() const 506 { 507 return m_bWrapLines; 485 508 } 486 509 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h
r70655 r70663 54 54 55 55 void setShowLineNumbers(bool bShowLineNumbers); 56 bool showLineNumbers() const; 57 56 58 void setWrapLines(bool bWrapLines); 59 bool wrapLines() const; 57 60 58 61 /** currentVerticalScrollBarValue is used by UIVMLogPage to store and restore scrolled … … 60 63 int currentVerticalScrollBarValue() const; 61 64 void setCurrentVerticalScrollBarValue(int value); 65 66 void setFontSizeInPoints(int fontSize); 67 int fontSizeInPoints() const; 62 68 63 69 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70645 r70663 74 74 , m_bShowLineNumbers(true) 75 75 , m_bWrapLines(false) 76 76 , m_iFontSizeInPoints(9) 77 77 { 78 78 /* Prepare VM Log-Viewer: */ … … 327 327 } 328 328 329 void UIVMLogViewerWidget::sltFontSizeChanged(int fontSize) 330 { 331 if (m_iFontSizeInPoints == fontSize) 332 return; 333 m_iFontSizeInPoints = fontSize; 334 for (int i = 0; i < m_logPageList.size(); ++i) 335 { 336 UIVMLogPage* pLogPage = qobject_cast<UIVMLogPage*>(m_logPageList[i]); 337 if (pLogPage) 338 pLogPage->setFontSizeInPoints(m_iFontSizeInPoints); 339 } 340 } 329 341 330 342 void UIVMLogViewerWidget::setMachine(const CMachine &machine) … … 427 439 m_pSettingsPanel->setShowLineNumbers(m_bShowLineNumbers); 428 440 m_pSettingsPanel->setWrapLines(m_bWrapLines); 441 m_pSettingsPanel->setFontSizeInPoints(m_iFontSizeInPoints); 429 442 430 443 m_pMainLayout->insertWidget(5, m_pSettingsPanel); 431 444 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigShowLineNumbers, this, &UIVMLogViewerWidget::sltShowLineNumbers); 432 445 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigWrapLines, this, &UIVMLogViewerWidget::sltWrapLines); 446 connect(m_pSettingsPanel, &UIVMLogViewerSettingsPanel::sigFontSizeInPoints, this, &UIVMLogViewerWidget::sltFontSizeChanged); 433 447 } 434 448 } … … 831 845 pLogPage->setShowLineNumbers(m_bShowLineNumbers); 832 846 pLogPage->setWrapLines(m_bWrapLines); 847 pLogPage->setFontSizeInPoints(m_iFontSizeInPoints); 848 833 849 /* Set the file name only if we really have log file to read. */ 834 850 if (!noLogsToShow) -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70617 r70663 108 108 void sltLogPageFilteredChanged(bool isFiltered); 109 109 110 void sltShowLineNumbers(bool bShowLineNumbers); 111 void sltWrapLines(bool bWrapLine); 110 /** @name Slots to handle signals from settings panel 111 * @{ */ 112 void sltShowLineNumbers(bool bShowLineNumbers); 113 void sltWrapLines(bool bWrapLine); 114 void sltFontSizeChanged(int fontSize); 115 /** @} */ 112 116 113 117 private: … … 201 205 bool m_bShowLineNumbers; 202 206 bool m_bWrapLines; 207 int m_iFontSizeInPoints; 203 208 /** @} */ 204 209
Note:
See TracChangeset
for help on using the changeset viewer.