Changeset 72856 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 4, 2018 9:28:36 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp
r72678 r72856 77 77 78 78 /** Constructs details element passing @a pParent to the base-class. 79 * @param strName Brings the element name. 80 * @param icon Brings the element icon. 79 81 * @param fLinkSupport Brings whether we should construct text-browser 80 82 * instead of simple text-edit otherwise. */ 81 UISnapshotDetailsElement(bool fLinkSupport, QWidget *pParent = 0); 83 UISnapshotDetailsElement(const QString &strName, const QIcon &icon, 84 bool fLinkSupport, QWidget *pParent = 0); 82 85 83 86 /** Returns underlying text-document. */ … … 92 95 protected: 93 96 97 /** Handles any Qt @a pEvent. */ 98 virtual bool event(QEvent *pEvent) /* override */; 99 94 100 /** Handles paint @a pEvent. */ 95 101 virtual void paintEvent(QPaintEvent *pEvent) /* override */; … … 100 106 void prepare(); 101 107 108 /** Updates pixmap. */ 109 void updatePixmap(); 110 111 /** Holds the element name.*/ 112 QString m_strName; 113 /** Holds the element icon. */ 114 QIcon m_icon; 102 115 /** Holds whether we should construct text-browser 103 116 * instead of simple text-edit otherwise. */ 104 bool m_fLinkSupport;117 bool m_fLinkSupport; 105 118 106 119 /** Holds the text-edit interface instance. */ … … 178 191 *********************************************************************************************************************************/ 179 192 180 UISnapshotDetailsElement::UISnapshotDetailsElement(bool fLinkSupport, QWidget *pParent /* = 0 */) 193 UISnapshotDetailsElement::UISnapshotDetailsElement(const QString &strName, const QIcon &icon, 194 bool fLinkSupport, QWidget *pParent /* = 0 */) 181 195 : QWidget(pParent) 196 , m_strName(strName) 197 , m_icon(icon) 182 198 , m_fLinkSupport(fLinkSupport) 183 199 , m_pTextEdit(0) … … 212 228 const int iIdealHeight = size.height() + 2 * iDocumentMargin + iTop + iBottom; 213 229 return QSize(iIdealWidth, iIdealHeight); 230 } 231 232 bool UISnapshotDetailsElement::event(QEvent *pEvent) 233 { 234 /* Handle know event types: */ 235 switch (pEvent->type()) 236 { 237 case QEvent::Show: 238 case QEvent::ScreenChangeInternal: 239 { 240 /* Update pixmap: */ 241 updatePixmap(); 242 break; 243 } 244 default: 245 break; 246 } 247 248 /* Call to base-class: */ 249 return QWidget::event(pEvent); 214 250 } 215 251 … … 327 363 } 328 364 } 365 366 /* Update pixmap: */ 367 updatePixmap(); 368 } 369 370 void UISnapshotDetailsElement::updatePixmap() 371 { 372 /* Re-register icon in the element's text-document: */ 373 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 374 document()->addResource( 375 QTextDocument::ImageResource, 376 QUrl(QString("details://%1").arg(m_strName)), 377 QVariant(m_icon.pixmap(window()->windowHandle(), QSize(iMetric, iMetric)))); 329 378 } 330 379 … … 1003 1052 /* Create element: */ 1004 1053 const bool fWithHypertextNavigation = enmType == DetailsElementType_Preview; 1005 UISnapshotDetailsElement *pElement = new UISnapshotDetailsElement(fWithHypertextNavigation); 1054 UISnapshotDetailsElement *pElement = new UISnapshotDetailsElement(gpConverter->toInternalString(enmType), 1055 gpConverter->toIcon(enmType), 1056 fWithHypertextNavigation); 1006 1057 AssertPtrReturn(pElement, 0); 1007 1058 { … … 1016 1067 break; 1017 1068 } 1018 1019 /* Register DetailsElementType icon in the element text-document: */1020 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);1021 const QSize iconSize = QSize(iIconMetric, iIconMetric);1022 pElement->document()->addResource(1023 QTextDocument::ImageResource,1024 QUrl(QString("details://%1").arg(gpConverter->toInternalString(enmType))),1025 QVariant(gpConverter->toIcon(enmType).pixmap(iconSize)));1026 1069 } 1027 1070 /* Return element: */
Note:
See TracChangeset
for help on using the changeset viewer.