Changeset 9799 in vbox for trunk/src/VBox
- Timestamp:
- Jun 18, 2008 3:48:16 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/QILabel_p.h
r9779 r9799 92 92 void focusInEvent (QFocusEvent *aEvent); 93 93 void focusOutEvent (QFocusEvent *aEvent); 94 void paintEvent (QPaintEvent *aEvent); 94 95 95 96 protected slots: -
trunk/src/VBox/Frontends/VirtualBox4/src/QILabel.cpp
r9779 r9799 33 33 #include <QClipboard> 34 34 #include <QApplication> 35 #include <QPainter> 36 #include <QStyleOptionFocusRect> 35 37 36 38 /* @todo: Compare the minimal size behavior in the qt3 & qt4 version. */ … … 244 246 QRegExp QILabelPrivate::mElideRegExp = QRegExp ("(<compact\\s+elipsis=\"(start|middle|end)\"?>([^<]+)</compact>)"); 245 247 248 #define HOR_PADDING 1 249 246 250 bool QILabelPrivate::fullSizeSelection () const 247 251 { … … 258 262 /* The label should be able to get the focus */ 259 263 setFocusPolicy (Qt::StrongFocus); 260 /* Change the appearance in focus state a little bit.264 /* Change the appearance in the focus state a little bit. 261 265 * Note: Unfortunately QLabel, precisely the text of a QLabel isn't 262 266 * styleable. The trolls have forgotten the simplest case ... So this 263 * is done by changing the current used palette in the In/Out-focus 264 * events below. */ 267 * is done by changing the currently used palette in the In/Out-focus 268 * events below. Next broken feature is drawing a simple dotted line 269 * around the label. So this is done manually in the paintEvent. Not 270 * sure if the stylesheet stuff is ready for production environments. */ 265 271 setStyleSheet (QString("QLabel::focus {\ 266 272 background-color: palette(highlight);\ 267 }")); 268 // border: 1px dotted black; 273 }\ 274 QLabel {\ 275 padding: 0px %1px 0px %1px;\ 276 }").arg (HOR_PADDING)); 269 277 } 270 278 else … … 348 356 aEvent->reason() != Qt::PopupFocusReason) /* For right mouse click */ 349 357 setPalette (qApp->palette()); 358 } 359 360 void QILabelPrivate::paintEvent (QPaintEvent *aEvent) 361 { 362 QLabel::paintEvent (aEvent); 363 364 if (mFullSizeSeclection && 365 hasFocus()) 366 { 367 QPainter painter(this); 368 /* Paint a focus rect based on the current style. */ 369 QStyleOptionFocusRect option; 370 option.initFrom(this); 371 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this); 372 } 350 373 } 351 374 … … 400 423 int flatWidth = fm.width (flatStr); 401 424 /* Create the shortened text */ 402 QString newStr = fm.elidedText (elideStr, toTextElideMode (elideModeStr), width() - flatWidth);425 QString newStr = fm.elidedText (elideStr, toTextElideMode (elideModeStr), width() - (2 * HOR_PADDING) - flatWidth); 403 426 /* Replace the compact part with the shortened text in the initial 404 427 * string */
Note:
See TracChangeset
for help on using the changeset viewer.