Changeset 9382 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 4, 2008 12:00:34 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 31613
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/Makefile.kmk
r9356 r9382 443 443 include/QIMessageBox.h \ 444 444 include/QIRichLabel.h \ 445 include/QIRichLabel_p.h \ 445 446 include/QIAbstractWizard.h \ 446 447 include/QIListView.h \ -
trunk/src/VBox/Frontends/VirtualBox4/include/QIRichLabel.h
r8170 r9382 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 #define __QIRichLabel_h__ 29 29 30 #include "q3frame.h" 31 //Added by qt3to4: 32 #include <Q3Accel> 33 #include <Q3Picture> 34 #include <QPixmap> 35 #include <QResizeEvent> 36 #include <QMouseEvent> 37 #include <QContextMenuEvent> 38 #include <QKeyEvent> 39 #include <Q3PopupMenu> 40 #include <QFocusEvent> 30 /* Qt includes */ 31 #include <QWidget> 41 32 42 class Q3SimpleRichText; 43 class QLabelPrivate; 44 class QAction; 45 class Q3PopupMenu; 33 class QILabelPrivate; 46 34 47 class QIRichLabel : public Q3Frame35 class QIRichLabel: public QWidget 48 36 { 49 Q_OBJECT 50 Q_PROPERTY( QString text READ text WRITE setText ) 51 Q_PROPERTY( Qt::TextFormat textFormat READ textFormat WRITE setTextFormat ) 52 Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap ) 53 Q_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents ) 54 // Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment ) 55 Q_PROPERTY( int indent READ indent WRITE setIndent ) 56 Q_OVERRIDE( Qt::BackgroundMode backgroundMode DESIGNABLE true ) 37 Q_OBJECT; 57 38 58 39 public: 59 QIRichLabel (QWidget *parent, const char* name=0, Qt::WFlags f=0);60 QIRichLabel (const QString &text, QWidget *parent, const char* name=0,61 Qt::WFlags f=0);62 QIRichLabel (QWidget *buddy, const QString &,63 QWidget *parent, const char* name=0, Qt::WFlags f=0 );64 ~QIRichLabel();65 40 66 QString text() const { return ltext; } 67 QPixmap *pixmap() const { return lpixmap; } 68 Q3Picture *picture() const { return lpicture; } 69 QMovie *movie() const; 41 QIRichLabel (QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0); 42 QIRichLabel (const QString &aText, QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0); 70 43 71 Qt::TextFormat textFormat() const; 72 void setTextFormat( Qt::TextFormat ); 44 /* QLabel extensions */ 45 bool fullSizeSelection () const; 46 void setFullSizeSelection (bool bOn); 73 47 74 int alignment() const { return align; } 75 virtual void setAlignment( int ); 76 int indent() const { return extraMargin; } 77 void setIndent( int ); 78 79 bool autoResize() const { return autoresize; } 80 virtual void setAutoResize( bool ); 81 bool hasScaledContents() const; 82 void setScaledContents( bool ); 83 QSize sizeHint() const; 84 QSize minimumSizeHint() const; 85 virtual void setBuddy( QWidget * ); 86 QWidget *buddy() const; 87 int heightForWidth(int) const; 88 89 void setFont( const QFont &f ); 90 void setFixedHeight (int); 91 92 void setMaxHeightMode (bool); 48 /* Default QLabel methods */ 49 Qt::Alignment alignment() const; 50 QWidget * buddy() const; 51 bool hasScaledContents() const; 52 int indent() const; 53 int margin() const; 54 QMovie *movie() const; 55 bool openExternalLinks() const; 56 const QPicture *picture() const; 57 const QPixmap *pixmap() const; 58 void setAlignment (Qt::Alignment aAlignment); 59 void setBuddy (QWidget *aBuddy); 60 void setIndent (int aIndent); 61 void setMargin (int aMargin); 62 void setOpenExternalLinks (bool aOpen); 63 void setScaledContents (bool aOn); 64 void setTextFormat (Qt::TextFormat aFormat); 65 void setTextInteractionFlags (Qt::TextInteractionFlags aFlags); 66 void setWordWrap (bool aOn); 67 QString text() const; 68 Qt::TextFormat textFormat() const; 69 Qt::TextInteractionFlags textInteractionFlags() const; 70 bool wordWrap() const; 93 71 94 72 public slots: 95 virtual void setText( const QString &);96 virtual void setPixmap( const QPixmap & );97 virtual void setPicture( const Q3Picture & );98 virtual void setMovie( const QMovie & );99 virtual void setNum( int );100 virtual void setNum( double );101 void clear();102 73 103 protected slots: 104 void putToClipBoard(); 74 void clear(); 75 void setMovie (QMovie *aMovie); 76 void setNum (int aNum); 77 void setNum (double aNum); 78 void setPicture (const QPicture &aPicture); 79 void setPixmap (const QPixmap &aPixmap); 80 void setText (const QString &aText); 81 82 signals: 83 84 void linkActivated (const QString &); 85 void linkHovered (const QString &); 105 86 106 87 protected: 107 void drawContents ( QPainter * );108 void fontChange ( const QFont & );109 void mouseMoveEvent (QMouseEvent *);110 void mousePressEvent (QMouseEvent *);111 void resizeEvent ( QResizeEvent* );112 void focusInEvent ( QFocusEvent* );113 void keyPressEvent ( QKeyEvent* );114 void contextMenuEvent (QContextMenuEvent*);115 88 116 signals: 117 void clickedOnLink (const QString&); 89 virtual void init(); 118 90 119 private slots: 120 void acceleratorSlot(); 121 void buddyDied(); 122 void movieUpdated(const QRect&); 123 void movieResized(const QSize&); 124 125 private: 126 void init(); 127 void clearContents(); 128 void updateLabel (QSize oldSizeHint); 129 QString compressText (int paneWidth = -1) const; 130 QSize sizeForWidth (int w) const; 131 132 QString ltext; 133 QString mTipText; 134 bool mIsMainTip; 135 QPixmap *lpixmap; 136 Q3Picture *lpicture; 137 QMovie *lmovie; 138 Q3PopupMenu *popupMenu; 139 QString popupBuffer; 140 QWidget *lbuddy; 141 ushort align; 142 short extraMargin; 143 uint autoresize:1; 144 uint scaledcontents :1; 145 uint baseheight; 146 Qt::TextFormat textformat; 147 Q3Accel *accel; 148 QLabelPrivate *d; 149 Q3SimpleRichText *doc; 150 bool mMaxHeightMode; 151 152 friend class QTipLabel; 153 154 QIRichLabel( const QIRichLabel & ); 155 QIRichLabel &operator=( const QIRichLabel & ); 91 /* Protected member vars */ 92 QILabelPrivate *mLabel; 156 93 }; 157 94 -
trunk/src/VBox/Frontends/VirtualBox4/src/QIMessageBox.cpp
r9287 r9382 83 83 84 84 mTextLabel = new QIRichLabel (aText, NULL); 85 mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop | Qt::TextExpandTabs | Qt::TextWordWrap); 86 QSizePolicy sp (QSizePolicy::Preferred, QSizePolicy::Preferred); 85 mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop); 86 mTextLabel->setWordWrap (true); 87 QSizePolicy sp (QSizePolicy::Minimum, QSizePolicy::Minimum); 87 88 sp.setHeightForWidth (true); 88 89 mTextLabel->setSizePolicy (sp); 90 mTextLabel->adjustSize(); 89 91 mTextLabel->setMinimumWidth (mTextLabel->sizeHint().width()); 90 92 messageVBoxLayout->addWidget (mTextLabel); -
trunk/src/VBox/Frontends/VirtualBox4/src/QIRichLabel.cpp
r8170 r9382 6 6 7 7 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.8 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 26 26 27 27 #include "QIRichLabel.h" 28 29 #include <qpainter.h> 30 #include <q3accel.h> 31 #include <qmovie.h> 32 #include <qimage.h> 33 #include <q3picture.h> 34 #include <qapplication.h> 35 #include <q3simplerichtext.h> 36 #include <q3stylesheet.h> 37 #include <qstyle.h> 38 #include <qregexp.h> 39 //#include <qfocusdata.h> 40 #include <qtooltip.h> 41 #include <q3popupmenu.h> 42 #include <qaction.h> 43 #include <qclipboard.h> 44 #include <qcursor.h> 45 //Added by qt3to4: 46 #include <QContextMenuEvent> 47 #include <QKeyEvent> 48 #include <QPixmap> 49 #include <QBitmap> 50 #include <Q3Frame> 51 #include <QResizeEvent> 52 #include <QFocusEvent> 53 #include <QMouseEvent> 54 55 class QLabelPrivate 56 { 57 public: 58 QLabelPrivate() 59 :img (0), pix (0), valid_hints (-1) 60 {} 61 QImage* img; // for scaled contents 62 QPixmap* pix; // for scaled contents 63 QSize sh; 64 QSize msh; 65 int valid_hints; // stores the frameWidth() for the stored size hint, -1 otherwise 66 }; 67 68 69 QIRichLabel::QIRichLabel (QWidget *parent, const char *name, Qt::WFlags f) 70 : Q3Frame (parent, name, f | Qt::WMouseNoMask) 71 { 72 init(); 73 } 74 75 76 QIRichLabel::QIRichLabel (const QString &text, QWidget *parent, const char *name, 77 Qt::WFlags f) 78 : Q3Frame (parent, name, f | Qt::WMouseNoMask) 79 { 80 init(); 81 setText (text); 82 } 83 84 85 QIRichLabel::QIRichLabel (QWidget *buddy, const QString &text, 86 QWidget *parent, const char *name, Qt::WFlags f) 87 : Q3Frame (parent, name, f | Qt::WMouseNoMask) 88 { 89 init(); 90 setBuddy (buddy); 91 setText (text); 92 } 93 94 95 QIRichLabel::~QIRichLabel() 96 { 97 clearContents(); 98 delete d; 99 } 100 28 #include "QIRichLabel_p.h" 29 #include "VBoxGlobal.h" 30 31 /* Qt includes */ 32 #include <QHBoxLayout> 33 #include <QClipboard> 34 #include <QApplication> 35 36 /* @todo: Compare the minimal size behavior in the qt3 & qt4 version. */ 37 38 QIRichLabel::QIRichLabel (QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */) 39 : QWidget (aParent, aFlags) 40 , mLabel (NULL) 41 { 42 init(); 43 } 44 45 QIRichLabel::QIRichLabel (const QString &aText, QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */) 46 : QWidget (aParent, aFlags) 47 , mLabel (NULL) 48 { 49 init(); 50 mLabel->setFullText (aText); 51 } 52 53 bool QIRichLabel::fullSizeSelection () const 54 { 55 mLabel->fullSizeSelection(); 56 } 57 58 void QIRichLabel::setFullSizeSelection (bool bOn) 59 { 60 mLabel->setFullSizeSelection (bOn); 61 } 101 62 102 63 void QIRichLabel::init() 103 64 { 104 mMaxHeightMode = false; 105 mIsMainTip = true; 106 baseheight = 0; 107 lpixmap = 0; 108 lmovie = 0; 109 lbuddy = 0; 110 accel = 0; 111 lpixmap = 0; 112 lpicture = 0; 113 align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs; 114 extraMargin = -1; 115 autoresize = FALSE; 116 scaledcontents = FALSE; 117 textformat = Qt::AutoText; 118 doc = 0; 119 120 d = new QLabelPrivate; 121 122 QAction *copyAction = new QAction (this, "copyAction"); 123 connect (copyAction, SIGNAL (activated()), 124 this, SLOT (putToClipBoard())); 125 copyAction->setMenuText (tr ("Copy to clipboard")); 126 127 popupMenu = new Q3PopupMenu (this, "contextMenu"); 128 copyAction->addTo (popupMenu); 129 130 setMouseTracking (true); 131 } 132 133 134 void QIRichLabel::setFixedHeight (int aHeight) 135 { 136 baseheight = aHeight; 137 Q3Frame::setFixedHeight (baseheight); 138 } 139 140 141 void QIRichLabel::setText (const QString &text) 142 { 143 if (ltext == text) 144 return; 145 QSize osh = sizeHint(); 146 bool hadRichtext = doc != 0; 147 148 clearContents(); 149 ltext = text; 150 151 bool useRichText = (textformat == Qt::RichText || 152 ((textformat == Qt::AutoText) && Q3StyleSheet::mightBeRichText (ltext))); 153 154 // ### Setting accelerators for rich text labels will not work. 155 // Eg. <b>>Hello</b> will return ALT+G which is clearly 156 // not intended. 157 if (!useRichText) { 158 int p = Q3Accel::shortcutKey (ltext); 159 if (p) { 160 if (!accel) 161 accel = new Q3Accel (this, "accel label accel"); 162 accel->connectItem (accel->insertItem (p), 163 this, SLOT (acceleratorSlot())); 164 } 165 } 166 167 if (useRichText) { 168 if (!hadRichtext) 169 align |= Qt::TextWordWrap; 170 QString t = ltext; 171 if (align & Qt::AlignRight) 172 t.prepend ("<div align=\"right\">"); 173 else if (align & Qt::AlignHCenter) 174 t.prepend ("<div align=\"center\">"); 175 if ((align & Qt::TextWordWrap) == 0) 176 t.prepend ("<nobr>"); 177 doc = new Q3SimpleRichText (compressText(0), font()); 178 } 179 180 updateLabel (osh); 181 182 if (mMaxHeightMode && (int)baseheight < heightForWidth (width())) 183 { 184 baseheight = heightForWidth (width()); 185 Q3Frame::setFixedHeight (baseheight); 186 } 187 } 188 65 QHBoxLayout *layout = new QHBoxLayout (this); 66 VBoxGlobal::setLayoutMargin (layout, 0); 67 layout->setSpacing (0); 68 mLabel = new QILabelPrivate (this); 69 layout->addWidget (mLabel); 70 connect (mLabel, SIGNAL (linkActivated (const QString &)), 71 this, SIGNAL (linkActivated (const QString &))); 72 connect (mLabel, SIGNAL (linkHovered (const QString &)), 73 this, SIGNAL (linkHovered (const QString &))); 74 } 75 76 /* Default QLabel methods */ 77 78 Qt::Alignment QIRichLabel::alignment () const 79 { 80 return mLabel->alignment(); 81 } 82 83 QWidget *QIRichLabel::buddy () const 84 { 85 return mLabel->buddy(); 86 } 87 88 bool QIRichLabel::hasScaledContents () const 89 { 90 return mLabel->hasScaledContents(); 91 } 92 93 int QIRichLabel::indent () const 94 { 95 return mLabel->indent(); 96 } 97 98 int QIRichLabel::margin () const 99 { 100 return mLabel->margin(); 101 } 102 103 QMovie *QIRichLabel::movie () const 104 { 105 return mLabel->movie(); 106 } 107 108 bool QIRichLabel::openExternalLinks () const 109 { 110 return mLabel->openExternalLinks(); 111 } 112 113 const QPicture *QIRichLabel::picture () const 114 { 115 return mLabel->picture(); 116 } 117 118 const QPixmap *QIRichLabel::pixmap () const 119 { 120 return mLabel->pixmap(); 121 } 122 123 void QIRichLabel::setAlignment (Qt::Alignment aAlignment) 124 { 125 mLabel->setAlignment (aAlignment); 126 } 127 128 void QIRichLabel::setBuddy (QWidget *aBuddy) 129 { 130 mLabel->setBuddy (aBuddy); 131 } 132 133 void QIRichLabel::setIndent (int aIndent) 134 { 135 mLabel->setIndent (aIndent); 136 } 137 138 void QIRichLabel::setMargin (int aMargin) 139 { 140 mLabel->setMargin (aMargin); 141 } 142 143 void QIRichLabel::setOpenExternalLinks (bool aOpen) 144 { 145 mLabel->setOpenExternalLinks (aOpen); 146 } 147 148 void QIRichLabel::setScaledContents (bool aOn) 149 { 150 mLabel->setScaledContents (aOn); 151 } 152 153 void QIRichLabel::setTextFormat (Qt::TextFormat aFormat) 154 { 155 mLabel->setTextFormat (aFormat); 156 } 157 158 void QIRichLabel::setTextInteractionFlags (Qt::TextInteractionFlags aFlags) 159 { 160 mLabel->setTextInteractionFlags (aFlags); 161 } 162 163 void QIRichLabel::setWordWrap (bool aOn) 164 { 165 mLabel->setWordWrap (aOn); 166 } 167 168 QString QIRichLabel::text () const 169 { 170 return mLabel->fullText(); 171 } 172 173 Qt::TextFormat QIRichLabel::textFormat () const 174 { 175 return mLabel->textFormat(); 176 } 177 178 Qt::TextInteractionFlags QIRichLabel::textInteractionFlags () const 179 { 180 return mLabel->textInteractionFlags(); 181 } 182 183 bool QIRichLabel::wordWrap () const 184 { 185 return mLabel->wordWrap(); 186 } 189 187 190 188 void QIRichLabel::clear() 191 189 { 192 setText (QString::fromLatin1 ("")); 193 } 194 195 196 void QIRichLabel::setPixmap (const QPixmap &pixmap) 197 { 198 QSize osh = sizeHint(); 199 200 if (!lpixmap || lpixmap->serialNumber() != pixmap.serialNumber()) { 201 clearContents(); 202 lpixmap = new QPixmap (pixmap); 203 } 204 205 if (lpixmap->depth() == 1 && !lpixmap->mask()) 206 lpixmap->setMask (*((QBitmap *)lpixmap)); 207 208 updateLabel (osh); 209 } 210 211 212 void QIRichLabel::setPicture (const Q3Picture &picture) 213 { 214 QSize osh = sizeHint(); 215 clearContents(); 216 lpicture = new Q3Picture (picture); 217 218 updateLabel (osh); 219 } 220 221 222 void QIRichLabel::setNum (int num) 223 { 224 QString str; 225 str.setNum (num); 226 setText (str); 227 } 228 229 230 void QIRichLabel::setNum (double num) 231 { 232 QString str; 233 str.setNum (num); 234 setText (str); 235 } 236 237 238 void QIRichLabel::setAlignment (int alignment) 239 { 240 if (alignment == align) 241 return; 242 QSize osh = sizeHint(); 243 244 if (lbuddy) 245 align = alignment | Qt::TextShowMnemonic; 246 else 247 align = alignment; 248 249 QString t = ltext; 250 if (!t.isNull()) { 251 ltext = QString::null; 252 setText (t); 253 } 254 255 updateLabel (osh); 256 } 257 258 259 void QIRichLabel::setIndent (int indent) 260 { 261 extraMargin = indent; 262 updateLabel (QSize (-1, -1)); 263 } 264 265 266 void QIRichLabel::setAutoResize (bool enable) 267 { 268 if ((bool)autoresize != enable) { 269 autoresize = enable; 270 if (autoresize) 271 adjustSize(); // calls resize which repaints 272 } 273 } 274 275 276 void QIRichLabel::setMaxHeightMode (bool aEnabled) 277 { 278 mMaxHeightMode = aEnabled; 279 } 280 281 282 QSize QIRichLabel::sizeForWidth (int w) const 283 { 284 QRect br; 285 QPixmap *pix = pixmap(); 286 Q3Picture *pic = picture(); 287 QMovie *mov = movie(); 288 289 int hextra = 2 * frameWidth(); 290 int vextra = hextra; 291 QFontMetrics fm (fontMetrics()); 292 int xw = fm.width ('x'); 293 if (!mov && !pix && !pic) { 294 int m = indent(); 295 if (m < 0 && hextra) // no indent, but we do have a frame 296 m = xw / 2 - margin(); 297 if (m >= 0) { 298 Qt::Alignment horizAlign = QApplication::horizontalAlignment( (Qt::Alignment)align ); 299 if ((horizAlign & Qt::AlignLeft) || (horizAlign & Qt::AlignRight)) 300 hextra += m; 301 if ((align & Qt::AlignTop) || (align & Qt::AlignBottom)) 302 vextra += m; 303 } 304 } 305 306 if (pix) 307 br = pix->rect(); 308 else if (pic) 309 br = pic->boundingRect(); 310 else if ( mov ) 311 br = mov->framePixmap().rect(); 312 else if (doc) { 313 int oldW = doc->width(); 314 if ( align & Qt::TextWordWrap ) { 315 if (w < 0) 316 doc->adjustSize(); 317 else 318 doc->setWidth (w-hextra - 2*3); 319 } 320 br = QRect (0, 0, doc->widthUsed(), doc->height()); 321 doc->setWidth (oldW); 322 } 323 else { 324 bool tryWidth = (w < 0) && (align & Qt::TextWordWrap); 325 if (tryWidth) 326 w = xw * 80; 327 else if (w < 0) 328 w = 2000; 329 w -= hextra; 330 br = fm.boundingRect (0, 0, w ,2000, alignment(), text()); 331 if (tryWidth && br.height() < 4*fm.lineSpacing() && br.width() > w/2) 332 br = fm.boundingRect (0, 0, w/2, 2000, alignment(), text()); 333 if (tryWidth && br.height() < 2*fm.lineSpacing() && br.width() > w/4) 334 br = fm.boundingRect (0, 0, w/4, 2000, alignment(), text()); 335 } 336 int wid = br.width() + hextra; 337 int hei = br.height() + vextra; 338 339 return QSize (wid, hei); 340 } 341 342 343 int QIRichLabel::heightForWidth (int w) const 344 { 345 if ( 346 doc || 347 (align & Qt::TextWordWrap)) 348 return sizeForWidth (w).height(); 349 return QWidget::heightForWidth(w); 350 } 351 352 353 QSize QIRichLabel::sizeHint() const 354 { 355 if ( d->valid_hints != frameWidth() ) 356 (void) QIRichLabel::minimumSizeHint(); 357 return d->sh; 358 } 359 360 361 QSize QIRichLabel::minimumSizeHint() const 362 { 363 if ( d->valid_hints == frameWidth() ) 364 return d->msh; 365 366 constPolish(); 367 d->valid_hints = frameWidth(); 368 d->sh = sizeForWidth (-1); 369 QSize sz (-1, -1); 370 371 if ( 372 !doc && 373 (align & Qt::TextWordWrap) == 0) { 374 sz = d->sh; 375 } else { 376 // think about caching these for performance 377 sz.rwidth() = sizeForWidth (0).width(); 378 sz.rheight() = sizeForWidth (QWIDGETSIZE_MAX).height(); 379 if (d->sh.height() < sz.height()) 380 sz.rheight() = d->sh.height(); 381 } 382 if (sizePolicy().horData() == QSizePolicy::Ignored) 383 sz.rwidth() = -1; 384 if (sizePolicy().verData() == QSizePolicy::Ignored) 385 sz.rheight() = -1; 386 d->msh = sz; 387 return sz; 388 } 389 390 391 void QIRichLabel::mouseMoveEvent (QMouseEvent *aEvent) 392 { 393 if (!doc) return; 394 395 QString link = doc->anchorAt (aEvent->pos()); 396 if (!link.isEmpty()) /* Mouse cursor above link */ 397 { 398 if (mIsMainTip) 190 mLabel->clearAll(); 191 } 192 193 void QIRichLabel::setMovie (QMovie *aMovie) 194 { 195 mLabel->setMovie (aMovie); 196 } 197 198 void QIRichLabel::setNum (int aNum) 199 { 200 mLabel->setNum (aNum); 201 } 202 203 void QIRichLabel::setNum (double aNum) 204 { 205 mLabel->setNum (aNum); 206 } 207 208 void QIRichLabel::setPicture (const QPicture &aPicture) 209 { 210 mLabel->setPicture (aPicture); 211 } 212 213 void QIRichLabel::setPixmap (const QPixmap &aPixmap) 214 { 215 mLabel->setPixmap (aPixmap); 216 } 217 218 void QIRichLabel::setText (const QString &aText) 219 { 220 mLabel->setFullText (aText); 221 } 222 223 /* QILabelPrivate implementation: */ 224 225 /* Some constant predefines */ 226 const QRegExp QILabelPrivate::mCopyRegExp = QRegExp ("<[^>]*>"); 227 QRegExp QILabelPrivate::mElideRegExp = QRegExp ("(<compact\\s+elipsis=\"(start|middle|end)\"?>([^<]+)</compact>)"); 228 229 bool QILabelPrivate::fullSizeSelection () const 230 { 231 return mFullSizeSeclection; 232 } 233 234 void QILabelPrivate::setFullSizeSelection (bool bOn) 235 { 236 mFullSizeSeclection = bOn; 237 if (mFullSizeSeclection) 238 { 239 /* Enable mouse interaction only */ 240 setTextInteractionFlags (Qt::LinksAccessibleByMouse); 241 /* The label should be able to get the focus */ 242 setFocusPolicy (Qt::StrongFocus); 243 /* Change the appearance in focus state a little bit */ 244 setStyleSheet (QString("QLabel::focus {\ 245 color: palette(highlighted-text);\ 246 background-color: palette(highlight);\ 247 }")); 248 // border: 1px dotted black; 249 } 250 else 251 { 252 /* Text should be selectable/copyable */ 253 setTextInteractionFlags (Qt::TextBrowserInteraction); 254 /* No Focus an the label */ 255 setFocusPolicy (Qt::NoFocus); 256 /* No focus style change */ 257 setStyleSheet (""); 258 } 259 } 260 261 void QILabelPrivate::resizeEvent (QResizeEvent *aEvent) 262 { 263 QLabel::resizeEvent (aEvent); 264 /* Recalculate the elipsis of the text after every resize. */ 265 updateText(); 266 } 267 268 void QILabelPrivate::mousePressEvent (QMouseEvent *aEvent) 269 { 270 if (aEvent->button() == Qt::LeftButton && 271 geometry().contains (aEvent->pos()) && 272 mFullSizeSeclection) 273 { 274 /* Create a drag object out of the given data. */ 275 QDrag *drag = new QDrag (this); 276 QMimeData *mimeData = new QMimeData; 277 mimeData->setText (removeHtmlTags (mText)); 278 drag->setMimeData (mimeData); 279 /* Start the dragging */ 280 drag->exec(); 281 } 282 else 283 QLabel::mousePressEvent (aEvent); 284 } 285 286 void QILabelPrivate::contextMenuEvent (QContextMenuEvent *aEvent) 287 { 288 if (mFullSizeSeclection) 289 { 290 /* Create a context menu for the copy to clipboard action. */ 291 QMenu *menu = new QMenu(); 292 menu->addAction (tr ("&Copy") + "\t" + QString (QKeySequence (QKeySequence::Copy)), this, SLOT (copy())); 293 menu->exec (aEvent->globalPos()); 294 }else 295 QLabel::contextMenuEvent (aEvent); 296 } 297 298 void QILabelPrivate::copy() 299 { 300 QString text = removeHtmlTags (mText); 301 /* Copy the current text to the global and selection clipboard. */ 302 QApplication::clipboard()->setText (text, QClipboard::Clipboard); 303 QApplication::clipboard()->setText (text, QClipboard::Selection); 304 } 305 306 void QILabelPrivate::init() 307 { 308 setFullSizeSelection (false); 309 /* Open links with the QDesktopService */ 310 setOpenExternalLinks (true); 311 } 312 313 void QILabelPrivate::updateText() 314 { 315 QString comp = compressText (mText); 316 317 QLabel::setText (comp); 318 /* Only set the tooltip if the text is shortened in any way. */ 319 if (removeHtmlTags (comp) != removeHtmlTags (mText)) 320 setToolTip (mText); 321 else 322 setToolTip (""); 323 } 324 325 QString QILabelPrivate::compressText (const QString &aText) const 326 { 327 QStringList strResult; 328 QFontMetrics fm = fontMetrics(); 329 /* Split up any multi line text */ 330 QStringList strList = aText.split (QRegExp ("<br */?>")); 331 foreach (QString text, strList) 332 { 333 /* Search for the compact tag */ 334 if (mElideRegExp.indexIn (text) > -1) 399 335 { 400 #warning port me 401 // mTipText = QToolTip::textFor (this); 402 QToolTip::remove (this); 403 QToolTip::add (this, link); 404 mIsMainTip = false; 336 QString workStr = text; 337 /* Grep out the necessary info of the regexp */ 338 QString compactStr = mElideRegExp.cap (1); 339 QString elideModeStr = mElideRegExp.cap (2); 340 QString elideStr = mElideRegExp.cap (3); 341 /* Remove the whole compact tag (also the text) */ 342 QString flatStr = removeHtmlTags (QString (workStr).remove (compactStr)); 343 /* What size will the text have without the compact text */ 344 int flatWidth = fm.width (flatStr); 345 /* Create the shortened text */ 346 QString newStr = fm.elidedText (elideStr, toTextElideMode (elideModeStr), width() - flatWidth); 347 /* Replace the compact part with the shortened text in the initial 348 * string */ 349 text = QString (workStr).replace (compactStr, newStr); 350 /* For debug */ 351 // printf ("%d, %s # %s # %s ## %s\n", pos, 352 // qPrintable (compactStr), 353 // qPrintable (elideModeStr), 354 // qPrintable (elideStr), 355 // qPrintable (newStr)); 405 356 } 406 s etCursor (QCursor (Qt::PointingHandCursor));357 strResult << text; 407 358 } 408 else /* Mouse cursor above non-link */ 409 { 410 if (!mIsMainTip) 411 { 412 QToolTip::remove (this); 413 QToolTip::add (this, mTipText); 414 mIsMainTip = true; 415 } 416 setCursor (QCursor (Qt::ArrowCursor)); 417 } 418 } 419 420 421 void QIRichLabel::mousePressEvent (QMouseEvent *aEvent) 422 { 423 if (!doc) return; 424 425 QString link = doc->anchorAt (aEvent->pos()); 426 /* Check for mouse left button clicked on the link */ 427 if (!link.isEmpty() && aEvent->button() == Qt::LeftButton) 428 emit clickedOnLink (link); 429 } 430 431 432 void QIRichLabel::resizeEvent (QResizeEvent *e) 433 { 434 Q3Frame::resizeEvent (e); 435 436 static const bool doc = FALSE; 437 438 // optimize for standard labels 439 if (frameShape() == NoFrame && (align & Qt::TextWordWrap) == 0 && !doc && 440 (e->oldSize().width() >= e->size().width() && (align & Qt::AlignLeft) == Qt::AlignLeft) 441 && (e->oldSize().height() >= e->size().height() && (align & Qt::AlignTop) == Qt::AlignTop)) { 442 #warning port me 443 // setWFlags (Qt::WResizeNoErase); 444 return; 445 } 446 447 #warning port me 448 // clearWFlags (Qt::WResizeNoErase); 449 QRect cr = contentsRect(); 450 if ( !lpixmap || !cr.isValid() || 451 // masked pixmaps can only reduce flicker when being top/left 452 // aligned and when we do not perform scaled contents 453 (lpixmap->hasAlpha() && (scaledcontents || ((align & (Qt::AlignLeft|Qt::AlignTop)) != (Qt::AlignLeft|Qt::AlignTop))))) 454 return; 455 456 #warning port me 457 // setWFlags (Qt::WResizeNoErase); 458 459 if (!scaledcontents) { 460 // don't we all love QFrame? Reduce pixmap flicker 461 QRegion reg = QRect (QPoint(0, 0), e->size()); 462 reg = reg.subtract (cr); 463 int x = cr.x(); 464 int y = cr.y(); 465 int w = lpixmap->width(); 466 int h = lpixmap->height(); 467 if ((align & Qt::AlignVCenter) == Qt::AlignVCenter) 468 y += cr.height()/2 - h/2; 469 else if ((align & Qt::AlignBottom) == Qt::AlignBottom) 470 y += cr.height() - h; 471 if ((align & Qt::AlignRight) == Qt::AlignRight ) 472 x += cr.width() - w; 473 else if ((align & Qt::AlignHCenter) == Qt::AlignHCenter ) 474 x += cr.width()/2 - w/2; 475 if (x > cr.x()) 476 reg = reg.unite (QRect (cr.x(), cr.y(), x - cr.x(), cr.height())); 477 if (y > cr.y()) 478 reg = reg.unite (QRect (cr.x(), cr.y(), cr.width(), y - cr.y())); 479 480 if (x + w < cr.right()) 481 reg = reg.unite (QRect (x + w, cr.y(), cr.right() - x - w, cr.height())); 482 if (y + h < cr.bottom()) 483 reg = reg.unite (QRect (cr.x(), y + h, cr.width(), cr.bottom() - y - h)); 484 485 erase (reg); 486 } 487 } 488 489 490 void QIRichLabel::focusInEvent (QFocusEvent *aEvent) 491 { 492 Q3Frame::focusInEvent (aEvent); 493 repaint(); 494 } 495 496 497 void QIRichLabel::keyPressEvent (QKeyEvent *aEvent) 498 { 499 #warning port me 500 // switch (aEvent->key()) 501 // { 502 // case Qt::Key_Up: 503 // focusData()->home(); 504 // focusData()->prev()->setFocus(); 505 // break; 506 // case Qt::Key_Down: 507 // focusData()->home(); 508 // focusData()->next()->setFocus(); 509 // break; 510 // default: 511 // aEvent->ignore(); 512 // } 513 } 514 515 516 void QIRichLabel::contextMenuEvent (QContextMenuEvent *aEvent) 517 { 518 popupBuffer = doc->anchorAt (aEvent->pos()); 519 if (hasFocus() || !popupBuffer.isEmpty()) 520 popupMenu->popup (aEvent->globalPos()); 521 } 522 523 524 void QIRichLabel::putToClipBoard() 525 { 526 QString toClipBoard = ltext; 527 528 if (popupBuffer.isEmpty()) 529 toClipBoard.remove (QRegExp ("<[^>]*>")); 530 else 531 toClipBoard = popupBuffer; 532 533 QApplication::clipboard()->setText (toClipBoard); 534 } 535 536 537 QString QIRichLabel::compressText (int aPaneWidth) const 538 { 539 QString allText = ltext; 540 541 if (aPaneWidth == -1) aPaneWidth = width(); 542 int indentSize = fontMetrics().width ("x...x") + frameWidth() * 2; 543 544 QStringList strList = QStringList::split ("<br>", allText); 545 for (QStringList::Iterator it = strList.begin(); it != strList.end(); ++it) 546 { 547 QString oneString = *it; 548 int oldSize = fontMetrics().width (oneString); 549 550 int start = 0; 551 int finish = 0; 552 int position = 0; 553 int textWidth = 0; 554 do { 555 QString filteredString = oneString; 556 filteredString.remove (QRegExp (QString ("<[^>]+>"))); 557 textWidth = fontMetrics().width (filteredString); 558 if (textWidth + indentSize > aPaneWidth) 559 { 560 QRegExp regStart ("(<compact(\\s+elipsis=\"(start|middle|end)\")?>)"); 561 QRegExp regFinish ("</compact>"); 562 start = regStart.search (oneString); 563 finish = regFinish.search (oneString); 564 if (start == -1 || finish == -1 || finish < start) 565 break; 566 567 if (regStart.cap(3) == "start") 568 position = start + regStart.cap(1).length(); 569 else if (regStart.cap(3) == "middle" || regStart.cap(3).isEmpty()) 570 position = start + regStart.cap(1).length() + 571 (finish-start-regStart.cap(1).length())/2; 572 else if (regStart.cap(3) == "end") 573 position = finish - 1; 574 else 575 break; 576 577 if (position == finish || 578 position == start + (int) regStart.cap(1).length() - 1) 579 break; 580 oneString.remove (position, 1); 581 } 582 } while (textWidth + indentSize > aPaneWidth); 583 if (position) oneString.insert (position, "..."); 584 585 int newSize = fontMetrics().width (oneString); 586 if (newSize < oldSize) *it = oneString; 587 } 588 QString result = strList.join ("<br>"); 589 return result; 590 } 591 592 593 void QIRichLabel::drawContents (QPainter *p) 594 { 595 QRect cr = contentsRect(); 596 597 QPixmap *pix = pixmap(); 598 Q3Picture *pic = picture(); 599 QMovie *mov = movie(); 600 601 if (!mov && !pix && !pic) { 602 int m = indent(); 603 if (m < 0 && frameWidth()) // no indent, but we do have a frame 604 m = fontMetrics().width ('x') / 2 - margin(); 605 if (m > 0) { 606 int hAlign = QApplication::horizontalAlignment ((Qt::Alignment)align); 607 if (hAlign & Qt::AlignLeft) 608 cr.setLeft (cr.left() + m); 609 if (hAlign & Qt::AlignRight) 610 cr.setRight (cr.right() - m); 611 if (align & Qt::AlignTop) 612 cr.setTop (cr.top() + m); 613 if (align & Qt::AlignBottom) 614 cr.setBottom (cr.bottom() - m); 615 } 616 } 617 618 if (mov) { 619 #warning port me 620 // ### should add movie to qDrawItem 621 // QRect r = style()->itemRect (p, cr, align, isEnabled(), &(mov->framePixmap()), 622 // QString::null); 623 // ### could resize movie frame at this point 624 // p->drawPixmap (r.x(), r.y(), mov->framePixmap()); 625 } 626 else 627 if (doc) { 628 delete doc; 629 QToolTip::remove (this); 630 QString filteredText = compressText(); 631 doc = new Q3SimpleRichText (filteredText, font()); 632 /* focus indent */ 633 doc->setWidth (p, cr.width() - 2*3); 634 int rh = doc->height(); 635 int yo = 0; 636 if (align & Qt::AlignVCenter) 637 yo = (cr.height()-rh)/2; 638 else if (align & Qt::AlignBottom) 639 yo = cr.height()-rh; 640 #warning port me 641 // if (! isEnabled() && 642 // style().styleHint (QStyle::SH_EtchDisabledText, this)) { 643 // QColorGroup cg = colorGroup(); 644 // cg.setColor (QColorGroup::Text, cg.light()); 645 // doc->draw (p, cr.x()+1, cr.y()+yo+1, cr, cg, 0); 646 // } 647 648 // QSimpleRichText always draws with QColorGroup::Text as with 649 // background mode PaletteBase. QIRichLabel typically has 650 // background mode PaletteBackground, so we create a temporary 651 // color group with the text color adjusted. 652 QColorGroup cg = colorGroup(); 653 QBrush paper; 654 if (isEnabled()) 655 { 656 if (hasFocus()) 657 { 658 const QColorGroup &standartGroup = QApplication::palette().active(); 659 cg.setColor (QColorGroup::Text, 660 standartGroup.color (QColorGroup::HighlightedText)); 661 paper.setColor (standartGroup.color (QColorGroup::Highlight)); 662 paper.setStyle (Qt::SolidPattern); 663 } 664 else 665 cg.setColor (QColorGroup::Text, paletteForegroundColor()); 666 } 667 668 doc->draw (p, cr.x()+3, cr.y()+yo, cr, cg, &paper); 669 #warning port me 670 // if (hasFocus()) 671 // style().drawPrimitive (QStyle::PE_FocusRect, p, cr, cg, 672 // QStyle::State_FocusAtBorder, 673 // cg.highlight()); 674 675 if (filteredText != ltext) 676 QToolTip::add (this, QString (" %1").arg (ltext)); 677 } else 678 if ( pic ) { 679 QRect br = pic->boundingRect(); 680 int rw = br.width(); 681 int rh = br.height(); 682 if ( scaledcontents ) { 683 p->save(); 684 p->translate (cr.x(), cr.y()); 685 p->scale ((double)cr.width()/rw, (double)cr.height()/rh); 686 p->drawPicture (-br.x(), -br.y(), *pic); 687 p->restore(); 688 } else { 689 int xo = 0; 690 int yo = 0; 691 if (align & Qt::AlignVCenter) 692 yo = (cr.height()-rh)/2; 693 else if (align & Qt::AlignBottom) 694 yo = cr.height()-rh; 695 if (align & Qt::AlignRight) 696 xo = cr.width()-rw; 697 else if (align & Qt::AlignHCenter) 698 xo = (cr.width()-rw)/2; 699 p->drawPicture (cr.x()+xo-br.x(), cr.y()+yo-br.y(), *pic); 700 } 701 } else 702 { 703 if (scaledcontents && pix) { 704 if (!d->img) 705 d->img = new QImage (lpixmap->convertToImage()); 706 707 if (!d->pix) 708 d->pix = new QPixmap; 709 if (d->pix->size() != cr.size()) 710 d->pix->convertFromImage (d->img->smoothScale (cr.width(), cr.height())); 711 pix = d->pix; 712 } 713 int alignment = align; 714 #warning port me 715 // if ((align & Qt::TextShowMnemonic) && !style().styleHint(QStyle::SH_UnderlineShortcut, this)) 716 // alignment |= Qt::TextHideMnemonic; 717 // ordinary text or pixmap label 718 // style().drawItem ( p, cr, alignment, colorGroup(), isEnabled(), 719 // pix, ltext ); 720 } 721 } 722 723 724 void QIRichLabel::updateLabel (QSize oldSizeHint) 725 { 726 d->valid_hints = -1; 727 QSizePolicy policy = sizePolicy(); 728 bool wordBreak = align & Qt::TextWordWrap; 729 policy.setHeightForWidth (wordBreak); 730 if (policy != sizePolicy()) 731 setSizePolicy (policy); 732 if (sizeHint() != oldSizeHint) 733 updateGeometry(); 734 if (autoresize) { 735 adjustSize(); 736 update (contentsRect()); 737 } else { 738 update (contentsRect()); 739 } 740 } 741 742 743 void QIRichLabel::acceleratorSlot() 744 { 745 if (!lbuddy) 746 return; 747 QWidget * w = lbuddy; 748 while (w->focusProxy()) 749 w = w->focusProxy(); 750 if (!w->hasFocus() && 751 w->isEnabled() && 752 w->isVisible() && 753 w->focusPolicy() != Qt::NoFocus) { 754 #warning port me 755 // QFocusEvent::setReason (QFocusEvent::Shortcut); 756 w->setFocus(); 757 #warning port me 758 // QFocusEvent::resetReason(); 759 } 760 } 761 762 763 void QIRichLabel::buddyDied() 764 { 765 lbuddy = 0; 766 } 767 768 769 void QIRichLabel::setBuddy (QWidget *buddy) 770 { 771 if (buddy) 772 setAlignment (alignment() | Qt::TextShowMnemonic); 773 else 774 setAlignment (alignment() & ~Qt::TextShowMnemonic); 775 776 if (lbuddy) 777 disconnect (lbuddy, SIGNAL (destroyed()), this, SLOT (buddyDied())); 778 779 lbuddy = buddy; 780 781 if (!lbuddy) 782 return; 783 784 if (!( textformat == Qt::RichText || (textformat == Qt::AutoText && 785 Q3StyleSheet::mightBeRichText(ltext)))) 786 { 787 int p = Q3Accel::shortcutKey (ltext); 788 if (p) { 789 if (!accel) 790 accel = new Q3Accel (this, "accel label accel"); 791 accel->connectItem (accel->insertItem (p), 792 this, SLOT (acceleratorSlot())); 793 } 794 } 795 796 connect (lbuddy, SIGNAL (destroyed()), this, SLOT (buddyDied())); 797 } 798 799 800 QWidget * QIRichLabel::buddy() const 801 { 802 return lbuddy; 803 } 804 805 806 void QIRichLabel::movieUpdated (const QRect &rect) 807 { 808 QMovie *mov = movie(); 809 if (mov && !mov->isNull()) { 810 QRect r = contentsRect(); 811 #warning port me 812 // r = style().itemRect (0, r, align, isEnabled(), &(mov->framePixmap()), 813 // QString::null); 814 r.moveBy (rect.x(), rect.y()); 815 r.setWidth (QMIN (r.width(), rect.width())); 816 r.setHeight (QMIN (r.height(), rect.height())); 817 #warning port me 818 // repaint (r, mov->framePixmap().mask() != 0); 819 } 820 } 821 822 823 void QIRichLabel::movieResized (const QSize &size) 824 { 825 d->valid_hints = -1; 826 if (autoresize) 827 adjustSize(); 828 movieUpdated (QRect (QPoint(0,0), size)); 829 updateGeometry(); 830 } 831 832 833 void QIRichLabel::setMovie (const QMovie &movie) 834 { 835 #warning port me 836 // QSize osh = sizeHint(); 837 // clearContents(); 838 // 839 // lmovie = new QMovie (movie); 840 // lmovie->connectResize (this, SLOT (movieResized (const QSize&))); 841 // lmovie->connectUpdate (this, SLOT (movieUpdated (const QRect&))); 842 // 843 // if (!lmovie->running()) // Assume that if the movie is running, 844 // updateLabel (osh); // resize/update signals will come soon enough 845 } 846 847 848 void QIRichLabel::clearContents() 849 { 850 delete doc; 851 doc = 0; 852 853 delete lpixmap; 854 lpixmap = 0; 855 856 delete lpicture; 857 lpicture = 0; 858 859 delete d->img; 860 d->img = 0; 861 862 delete d->pix; 863 d->pix = 0; 864 865 ltext = QString::null; 866 867 if (accel) 868 accel->clear(); 869 870 if (lmovie) { 871 #warning port me 872 // lmovie->disconnectResize (this, SLOT (movieResized (const QSize&))); 873 // lmovie->disconnectUpdate (this, SLOT (movieUpdated (const QRect&))); 874 delete lmovie; 875 lmovie = 0; 876 } 877 } 878 879 880 QMovie* QIRichLabel::movie() const 881 { 882 return lmovie; 883 } 884 885 886 Qt::TextFormat QIRichLabel::textFormat() const 887 { 888 return textformat; 889 } 890 891 void QIRichLabel::setTextFormat( Qt::TextFormat format ) 892 { 893 if (format != textformat) { 894 textformat = format; 895 QString t = ltext; 896 if (!t.isNull()) { 897 ltext = QString::null; 898 setText (t); 899 } 900 } 901 } 902 903 904 void QIRichLabel::fontChange (const QFont&) 905 { 906 if (!ltext.isEmpty()) { 907 if (doc) 908 doc->setDefaultFont (font()); 909 910 updateLabel (QSize (-1, -1)); 911 } 912 } 913 914 915 bool QIRichLabel::hasScaledContents() const 916 { 917 return scaledcontents; 918 } 919 920 921 void QIRichLabel::setScaledContents (bool enable) 922 { 923 if ((bool)scaledcontents == enable) 924 return; 925 scaledcontents = enable; 926 if (!enable) { 927 delete d->img; 928 d->img = 0; 929 delete d->pix; 930 d->pix = 0; 931 } 932 update (contentsRect()); 933 } 934 935 936 void QIRichLabel::setFont (const QFont &f) 937 { 938 Q3Frame::setFont (f); 939 } 359 return strResult.join ("<br />"); 360 } 361 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp
r9296 r9382 2004 2004 aInfo = new InfoPaneLabel (aRoot, nameLabel); 2005 2005 2006 /* Setup focus policy <strong> default for info pane */2007 aInfo->setF ocusPolicy (Qt::StrongFocus);2006 /* We would the full size selection mode */ 2007 aInfo->setFullSizeSelection (true); 2008 2008 2009 2009 /* Prevent the name columns from being expanded */ -
trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxGlobalSettingsDlg.ui.h
r9227 r9382 302 302 whatsThisCandidate = NULL; 303 303 304 whatsThisLabel = new QIRichLabel (this, "whatsThisLabel");305 304 #warning port me 305 whatsThisLabel = new QIRichLabel (this); 306 306 // VBoxGlobalSettingsDlgLayout->addWidget (whatsThisLabel, 2, 1); 307 307 … … 314 314 * formatting). We want to catch this text because this is how it will look 315 315 * in the whatsthis balloon where we cannot enforce rich text. */ 316 whatsThisLabel->setTextFormat (Qt::RichText);316 // whatsThisLabel->setTextFormat (Qt::RichText); 317 317 #endif 318 318 319 whatsThisLabel->setMaxHeightMode (true);320 whatsThisLabel->setFocusPolicy (Qt::NoFocus);321 whatsThisLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);322 whatsThisLabel->setBackgroundMode (Qt::PaletteMidlight);323 whatsThisLabel->setFrameShape (QLabel::Box);324 whatsThisLabel->setFrameShadow (QLabel::Sunken);325 whatsThisLabel->setMargin (7);326 whatsThisLabel->setScaledContents (FALSE);327 whatsThisLabel->setAlignment (int (Qt::TextWordWrap |328 Qt::AlignJustify |329 Qt::AlignTop));330 331 whatsThisLabel->setFixedHeight (whatsThisLabel->frameWidth() * 2 +332 6 /* seems that RichText adds some margin */ +333 whatsThisLabel->fontMetrics().lineSpacing() * 4);334 whatsThisLabel->setMinimumWidth (whatsThisLabel->frameWidth() * 2 +335 6 /* seems that RichText adds some margin */ +336 whatsThisLabel->fontMetrics().width ('m') * 40);337 319 // whatsThisLabel->setMaxHeightMode (true); 320 // whatsThisLabel->setFocusPolicy (Qt::NoFocus); 321 // whatsThisLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed); 322 // whatsThisLabel->setBackgroundMode (Qt::PaletteMidlight); 323 // whatsThisLabel->setFrameShape (QLabel::Box); 324 // whatsThisLabel->setFrameShadow (QLabel::Sunken); 325 // whatsThisLabel->setMargin (7); 326 // whatsThisLabel->setScaledContents (FALSE); 327 // whatsThisLabel->setAlignment (int (Qt::TextWordWrap | 328 // Qt::AlignJustify | 329 // Qt::AlignTop)); 330 // 331 // whatsThisLabel->setFixedHeight (whatsThisLabel->frameWidth() * 2 + 332 // 6 /* seems that RichText adds some margin */ + 333 // whatsThisLabel->fontMetrics().lineSpacing() * 4); 334 // whatsThisLabel->setMinimumWidth (whatsThisLabel->frameWidth() * 2 + 335 // 6 /* seems that RichText adds some margin */ + 336 // whatsThisLabel->fontMetrics().width ('m') * 40); 337 // 338 338 /* 339 339 * create and layout non-standard widgets
Note:
See TracChangeset
for help on using the changeset viewer.