Changeset 40043 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 9, 2012 8:32:22 AM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r39932 r40043 250 250 src/extensions/QIMainDialog.h \ 251 251 src/extensions/QIMessageBox.h \ 252 src/extensions/QIRichTextLabel.h \ 252 253 src/extensions/QIRichToolButton.h \ 253 254 src/extensions/QISplitter.h \ … … 417 418 src/extensions/QIMainDialog.cpp \ 418 419 src/extensions/QIMessageBox.cpp \ 420 src/extensions/QIRichTextLabel.cpp \ 419 421 src/extensions/QIRichToolButton.cpp \ 420 422 src/extensions/QISplitter.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichTextLabel.cpp
r40042 r40043 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VirtualBox Qt extensions: QI TextEditclass implementation5 * VirtualBox Qt extensions: QIRichTextLabel class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 201 1Oracle Corporation9 * Copyright (C) 2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes: */ 21 #include <QVBoxLayout> 22 20 23 /* Local includes: */ 21 #include "QI TextEdit.h"24 #include "QIRichTextLabel.h" 22 25 23 26 /* Constructor: */ 24 QITextEdit::QITextEdit(QWidget *pParent) 25 : QTextEdit(pParent) 27 QIRichTextLabel::QIRichTextLabel(QWidget *pParent) 28 : QWidget(pParent) 29 , m_pTextEdit(new QTextEdit(this)) 26 30 { 31 /* Setup text-edit: */ 32 m_pTextEdit->setReadOnly(true); 33 m_pTextEdit->setFrameShape(QFrame::NoFrame); 34 m_pTextEdit->viewport()->setAutoFillBackground(false); 35 m_pTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 36 m_pTextEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 37 /* Add into parent: */ 38 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 39 pMainLayout->setMargin(0); 40 pMainLayout->addWidget(m_pTextEdit); 27 41 } 28 42 29 QSize QITextEdit::sizeHint() const 43 /* Minimum text-width setter: */ 44 void QIRichTextLabel::setMinimumTextWidth(int iMinimumTextWidth) 30 45 { 31 return document()->size().toSize(); 46 /* Get corresponding QTextDocument: */ 47 QTextDocument *pTextDocument = m_pTextEdit->document(); 48 /* Bug in QTextDocument (?) : setTextWidth doesn't work from the first time. */ 49 for (int iTry = 0; pTextDocument->textWidth() != iMinimumTextWidth && iTry < 3; ++iTry) 50 pTextDocument->setTextWidth(iMinimumTextWidth); 32 51 } 33 52 53 /* Text setter: */ 54 void QIRichTextLabel::setText(const QString &strText) 55 { 56 /* Set text: */ 57 m_pTextEdit->setText(strText); 58 /* Get corresponding QTextDocument: */ 59 QTextDocument *pTextDocument = m_pTextEdit->document(); 60 /* Get corresponding QTextDocument size: */ 61 QSize size = pTextDocument->size().toSize(); 62 /* Check if current size is valid, otherwise adjust it: */ 63 if (!size.isValid()) 64 { 65 pTextDocument->adjustSize(); 66 size = pTextDocument->size().toSize(); 67 } 68 /* Resize to content size: */ 69 m_pTextEdit->setMinimumSize(size); 70 } 71 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichTextLabel.h
r40042 r40043 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * VirtualBox Qt extensions: QI TextEditclass declaration4 * VirtualBox Qt extensions: QIRichTextLabel class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 201 1Oracle Corporation8 * Copyright (C) 2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __QI TextEdit_h__20 #define __QI TextEdit_h__19 #ifndef __QIRichTextLabel_h__ 20 #define __QIRichTextLabel_h__ 21 21 22 22 /* Global includes: */ 23 23 #include <QTextEdit> 24 24 25 /* QTextEdit class extension: */ 26 class QITextEdit : public QTextEdit 25 /* QLabel analog to reflect rich-text, 26 * Based on private QTextEdit functionality: */ 27 class QIRichTextLabel : public QWidget 27 28 { 28 29 Q_OBJECT; … … 31 32 32 33 /* Constructor: */ 33 QI TextEdit(QWidget *pParent = 0);34 QIRichTextLabel(QWidget *pParent = 0); 34 35 35 /* Size hint: */ 36 QSize sizeHint() const; 36 public slots: 37 38 /* Minimum text-width setter: */ 39 void setMinimumTextWidth(int iMinimumTextWidth); 40 41 /* Text setter: */ 42 void setText(const QString &strText); 43 44 private: 45 46 /* QTextEdit private member: */ 47 QTextEdit *m_pTextEdit; 37 48 }; 38 49 39 #endif // __QI TextEdit_h__50 #endif // __QIRichTextLabel_h__
Note:
See TracChangeset
for help on using the changeset viewer.