Changeset 71905 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 18, 2018 5:02:14 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71901 r71905 570 570 src/widgets/UINameAndSystemEditor.h \ 571 571 src/widgets/UIWarningPane.h \ 572 src/widgets/UIFilmContainer.h \573 572 src/widgets/graphics/UIGraphicsButton.h \ 574 573 src/widgets/graphics/UIGraphicsRotatorButton.h \ … … 685 684 src/widgets/UIBootTable.h \ 686 685 src/widgets/UIFilePathSelector.h \ 686 src/widgets/UIFilmContainer.h \ 687 687 src/widgets/UIHostComboEditor.h \ 688 688 src/widgets/UIPopupBox.h \ … … 775 775 src/widgets/UIBootTable.h \ 776 776 src/widgets/UIFilePathSelector.h \ 777 src/widgets/UIFilmContainer.h \ 777 778 src/widgets/UIHostComboEditor.h \ 778 779 src/widgets/UIPopupBox.h \ … … 856 857 src/selector/UIActionPoolSelector.cpp \ 857 858 src/selector/UIVirtualBoxEventHandler.cpp \ 859 src/widgets/UIFilmContainer.cpp \ 858 860 src/widgets/UIProgressDialog.cpp 859 861 … … 894 896 src/selector/UIActionPoolSelector.cpp \ 895 897 src/selector/UIVirtualBoxEventHandler.cpp \ 898 src/widgets/UIFilmContainer.cpp \ 896 899 src/widgets/UIProgressDialog.cpp 897 900 … … 1056 1059 src/widgets/UINameAndSystemEditor.cpp \ 1057 1060 src/widgets/UIWarningPane.cpp \ 1058 src/widgets/UIFilmContainer.cpp \1059 1061 src/widgets/graphics/UIGraphicsButton.cpp \ 1060 1062 src/widgets/graphics/UIGraphicsRotatorButton.cpp \ … … 1210 1212 src/widgets/UIBootTable.cpp \ 1211 1213 src/widgets/UIFilePathSelector.cpp \ 1214 src/widgets/UIFilmContainer.cpp \ 1212 1215 src/widgets/UIHostComboEditor.cpp \ 1213 1216 src/widgets/UIPopupBox.cpp \ … … 1326 1329 src/widgets/UIBootTable.cpp \ 1327 1330 src/widgets/UIFilePathSelector.cpp \ 1331 src/widgets/UIFilmContainer.cpp \ 1328 1332 src/widgets/UIHostComboEditor.cpp \ 1329 1333 src/widgets/UIPopupBox.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilmContainer.cpp
r71027 r71905 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QCheckBox> 23 24 # include <QHBoxLayout> 24 # include <Q VBoxLayout>25 # include <QPainter> 25 26 # include <QScrollArea> 26 27 # include <QScrollBar> 27 28 # include <QStyle> 28 # include <QCheckBox> 29 # include <QPainter> 29 # include <QVBoxLayout> 30 30 31 31 /* GUI includes: */ … … 35 35 36 36 37 UIFilmContainer::UIFilmContainer(QWidget *pParent /* = 0*/) 38 : QWidget(pParent) 39 , m_pMainLayout(0) 40 , m_pScroller(0) 41 { 42 /* Prepare: */ 43 prepare(); 44 } 45 46 QVector<BOOL> UIFilmContainer::value() const 47 { 48 /* Enumerate all the existing widgets: */ 49 QVector<BOOL> value; 50 foreach (UIFilm *pWidget, m_widgets) 51 value << static_cast<BOOL>(pWidget->checked()); 52 53 /* Return value: */ 54 return value; 55 } 56 57 void UIFilmContainer::setValue(const QVector<BOOL> &value) 58 { 59 /* Cleanup viewport/widget list: */ 60 delete m_pScroller->takeWidget(); 61 m_widgets.clear(); 62 63 /* Create widget: */ 64 if (QWidget *pWidget = new QWidget) 65 { 66 /* Create viewport layout: */ 67 if (QHBoxLayout *pWidgetLayout = new QHBoxLayout(pWidget)) 68 { 69 /* Configure viewport layout: */ 70 pWidgetLayout->setMargin(0); 71 #ifdef VBOX_WS_MAC 72 pWidgetLayout->setSpacing(5); 73 #else 74 pWidgetLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2); 75 #endif 76 /* Create new widgets according passed vector: */ 77 for (int iScreenIndex = 0; iScreenIndex < value.size(); ++iScreenIndex) 78 { 79 /* Create new widget: */ 80 UIFilm *pWidget = new UIFilm(iScreenIndex, value[iScreenIndex]); 81 /* Add widget into the widget list: */ 82 m_widgets << pWidget; 83 /* Add widget into the viewport layout: */ 84 pWidgetLayout->addWidget(pWidget); 85 } 86 } 87 /* Assign scroller with widget: */ 88 m_pScroller->setWidget(pWidget); 89 /* Reconfigure scroller widget: */ 90 m_pScroller->widget()->setAutoFillBackground(false); 91 /* And adjust that widget geometry: */ 92 QSize msh = m_pScroller->widget()->minimumSizeHint(); 93 int iMinimumHeight = msh.height(); 94 m_pScroller->viewport()->setFixedHeight(iMinimumHeight); 95 } 96 } 97 98 void UIFilmContainer::prepare() 99 { 100 /* Prepare layout: */ 101 prepareLayout(); 102 103 /* Prepare scroller: */ 104 prepareScroller(); 105 106 /* Append with 'default' value: */ 107 setValue(QVector<BOOL>() << true); 108 } 109 110 void UIFilmContainer::prepareLayout() 111 { 112 /* Create layout: */ 113 m_pMainLayout = new QVBoxLayout(this); 114 115 /* Configure layout: */ 116 m_pMainLayout->setMargin(0); 117 m_pMainLayout->setSpacing(0); 118 } 119 120 void UIFilmContainer::prepareScroller() 121 { 122 /* Create scroller: */ 123 m_pScroller = new QScrollArea; 124 125 /* Configure scroller: */ 126 m_pScroller->setFrameShape(QFrame::NoFrame); 127 m_pScroller->viewport()->setAutoFillBackground(false); 128 m_pScroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); 129 m_pScroller->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 130 m_pMainLayout->addWidget(m_pScroller); 131 } 37 /** QWidget subclass providing GUI with UIFilmContainer item prototype. 38 * @todo Rename to something more suitable like UIScreenThumbnail. */ 39 class UIFilm : public QIWithRetranslateUI<QWidget> 40 { 41 Q_OBJECT; 42 43 public: 44 45 /** Constructs film widget passing @a pParent to the base-class. 46 * @param iScreenIndex Brings the guest-screen index this film referencing. 47 * @param fEnabled Brings whether the guest-screen mentioned above is enabled. */ 48 UIFilm(int iScreenIndex, BOOL fEnabled, QWidget *pParent = 0); 49 50 /** Returns whether guest-screen is enabled. */ 51 bool checked() const; 52 53 protected: 54 55 /** Handles translation event. */ 56 virtual void retranslateUi() /* override */; 57 58 /** Handles paint @a pEvent. */ 59 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 60 61 /** Returns minimum size-hint. */ 62 virtual QSize minimumSizeHint() const /* override */; 63 64 private: 65 66 /** Prepares all. */ 67 void prepare(); 68 /** Prepares layout. */ 69 void prepareLayout(); 70 /** Prepares check-box. */ 71 void prepareCheckBox(); 72 73 /** Holds the guest-screen index. */ 74 int m_iScreenIndex; 75 /** Holds whether guest-screen was enabled. */ 76 BOOL m_fWasEnabled; 77 78 /** Holds the main-layout instance. */ 79 QVBoxLayout *m_pMainLayout; 80 /** Holds the check-box instance. */ 81 QCheckBox *m_pCheckBox; 82 }; 83 84 85 /********************************************************************************************************************************* 86 * Class UIFilm implementation. * 87 *********************************************************************************************************************************/ 132 88 133 89 UIFilm::UIFilm(int iScreenIndex, BOOL fEnabled, QWidget *pParent /* = 0*/) … … 154 110 } 155 111 156 void UIFilm::prepare() 157 { 158 /* Prepare layout: */ 159 prepareLayout(); 160 161 /* Prepare check-box: */ 162 prepareCheckBox(); 163 164 /* Translate finally: */ 165 retranslateUi(); 166 } 167 168 void UIFilm::prepareLayout() 169 { 170 /* Create layout: */ 171 m_pMainLayout = new QVBoxLayout(this); 172 173 /* Configure layout: */ 174 #ifdef VBOX_WS_MAC 175 m_pMainLayout->setContentsMargins(10, 10, 15, 10); 176 #endif /* VBOX_WS_MAC */ 177 178 /* Add strech: */ 179 m_pMainLayout->addStretch(); 180 } 181 182 void UIFilm::prepareCheckBox() 183 { 184 /* Create check-box: */ 185 m_pCheckBox = new QCheckBox; 186 m_pCheckBox->setChecked(static_cast<bool>(m_fWasEnabled)); 187 188 /* Configure font: */ 189 QFont currentFont = m_pCheckBox->font(); 190 #ifdef VBOX_WS_MAC 191 currentFont.setPointSize(currentFont.pointSize() - 2); 192 #else /* VBOX_WS_MAC */ 193 currentFont.setPointSize(currentFont.pointSize() - 1); 194 #endif /* !VBOX_WS_MAC */ 195 m_pCheckBox->setFont(currentFont); 196 197 /* Insert check-box into layout: */ 198 m_pMainLayout->insertWidget(0, m_pCheckBox); 199 } 200 201 QSize UIFilm::minimumSizeHint() const 202 { 203 /* Return 16:9 aspect-ratio msh: */ 204 QSize msh = QWidget::minimumSizeHint(); 205 return QSize(msh.width(), (msh.width() * 9) / 16); 206 } 207 208 void UIFilm::paintEvent(QPaintEvent*) 112 void UIFilm::paintEvent(QPaintEvent *) 209 113 { 210 114 /* Compose painting rectangle: */ … … 247 151 } 248 152 153 QSize UIFilm::minimumSizeHint() const 154 { 155 /* Return 16:9 aspect-ratio msh: */ 156 QSize msh = QWidget::minimumSizeHint(); 157 return QSize(msh.width(), (msh.width() * 9) / 16); 158 } 159 160 void UIFilm::prepare() 161 { 162 /* Prepare layout: */ 163 prepareLayout(); 164 /* Prepare check-box: */ 165 prepareCheckBox(); 166 167 /* Apply language settings: */ 168 retranslateUi(); 169 } 170 171 void UIFilm::prepareLayout() 172 { 173 /* Create layout: */ 174 m_pMainLayout = new QVBoxLayout(this); 175 if (m_pMainLayout) 176 { 177 /* Configure layout: */ 178 #ifdef VBOX_WS_MAC 179 m_pMainLayout->setContentsMargins(10, 10, 15, 10); 180 #endif 181 182 /* Add strech: */ 183 m_pMainLayout->addStretch(); 184 } 185 } 186 187 void UIFilm::prepareCheckBox() 188 { 189 /* Create check-box: */ 190 m_pCheckBox = new QCheckBox; 191 if (m_pCheckBox) 192 { 193 /* Configure check-box: */ 194 m_pCheckBox->setChecked(static_cast<bool>(m_fWasEnabled)); 195 /* Configure font: */ 196 QFont currentFont = m_pCheckBox->font(); 197 #ifdef VBOX_WS_MAC 198 currentFont.setPointSize(currentFont.pointSize() - 2); 199 #else 200 currentFont.setPointSize(currentFont.pointSize() - 1); 201 #endif 202 m_pCheckBox->setFont(currentFont); 203 204 /* Insert into layout: */ 205 m_pMainLayout->insertWidget(0, m_pCheckBox); 206 } 207 } 208 209 210 /********************************************************************************************************************************* 211 * Class UIFilmContainer implementation. * 212 *********************************************************************************************************************************/ 213 214 UIFilmContainer::UIFilmContainer(QWidget *pParent /* = 0*/) 215 : QWidget(pParent) 216 , m_pMainLayout(0) 217 , m_pScroller(0) 218 { 219 /* Prepare: */ 220 prepare(); 221 } 222 223 QVector<BOOL> UIFilmContainer::value() const 224 { 225 /* Enumerate all the existing widgets: */ 226 QVector<BOOL> value; 227 foreach (UIFilm *pWidget, m_widgets) 228 value << static_cast<BOOL>(pWidget->checked()); 229 230 /* Return value: */ 231 return value; 232 } 233 234 void UIFilmContainer::setValue(const QVector<BOOL> &value) 235 { 236 /* Cleanup viewport/widget list: */ 237 delete m_pScroller->takeWidget(); 238 m_widgets.clear(); 239 240 /* Create widget: */ 241 QWidget *pWidget = new QWidget; 242 if (pWidget) 243 { 244 /* Create widget-layout: */ 245 QHBoxLayout *pWidgetLayout = new QHBoxLayout(pWidget); 246 if (pWidgetLayout) 247 { 248 /* Configure widget-layout: */ 249 pWidgetLayout->setMargin(0); 250 #ifdef VBOX_WS_MAC 251 pWidgetLayout->setSpacing(5); 252 #else 253 pWidgetLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2); 254 #endif 255 256 /* Create new films according passed vector: */ 257 for (int iScreenIndex = 0; iScreenIndex < value.size(); ++iScreenIndex) 258 { 259 /* Create new film: */ 260 UIFilm *pFilm = new UIFilm(iScreenIndex, value[iScreenIndex]); 261 if (pFilm) 262 { 263 /* Add film into the widget list: */ 264 m_widgets << pFilm; 265 266 /* Add into layout: */ 267 pWidgetLayout->addWidget(pFilm); 268 } 269 } 270 } 271 272 /* Assign scroller with widget: */ 273 m_pScroller->setWidget(pWidget); 274 /* Reconfigure scroller widget: */ 275 m_pScroller->widget()->setAutoFillBackground(false); 276 /* And adjust that widget geometry: */ 277 QSize msh = m_pScroller->widget()->minimumSizeHint(); 278 int iMinimumHeight = msh.height(); 279 m_pScroller->viewport()->setFixedHeight(iMinimumHeight); 280 } 281 } 282 283 void UIFilmContainer::prepare() 284 { 285 /* Prepare layout: */ 286 prepareLayout(); 287 /* Prepare scroller: */ 288 prepareScroller(); 289 290 /* Append with 'default' value: */ 291 setValue(QVector<BOOL>() << true); 292 } 293 294 void UIFilmContainer::prepareLayout() 295 { 296 /* Create layout: */ 297 m_pMainLayout = new QVBoxLayout(this); 298 if (m_pMainLayout) 299 { 300 /* Configure layout: */ 301 m_pMainLayout->setMargin(0); 302 m_pMainLayout->setSpacing(0); 303 } 304 } 305 306 void UIFilmContainer::prepareScroller() 307 { 308 /* Create scroller: */ 309 m_pScroller = new QScrollArea; 310 if (m_pScroller) 311 { 312 /* Configure scroller: */ 313 m_pScroller->setFrameShape(QFrame::NoFrame); 314 m_pScroller->viewport()->setAutoFillBackground(false); 315 m_pScroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); 316 m_pScroller->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 317 318 /* Add into layout: */ 319 m_pMainLayout->addWidget(m_pScroller); 320 } 321 } 322 323 324 #include "UIFilmContainer.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilmContainer.h
r71027 r71905 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIFilmContainer_h__19 #define __ UIFilmContainer_h__18 #ifndef ___UIFilmContainer_h___ 19 #define ___UIFilmContainer_h___ 20 20 21 21 /* Qt includes: */ … … 24 24 /* GUI includes: */ 25 25 #include "QIWithRetranslateUI.h" 26 #include "UILibraryDefs.h" 26 27 27 28 /* Other VBox includes: */ … … 29 30 30 31 /* Forward declarations: */ 32 class QCheckBox; 33 class QScrollArea; 31 34 class QVBoxLayout; 32 class QScrollArea;33 35 class UIFilm; 34 class QCheckBox;35 36 36 /* Transparent QScrollArea container for UIFilm widgets: */ 37 class UIFilmContainer : public QWidget 37 /** QWidget subclass providing GUI with QScrollArea-based container for UIFilm widgets. 38 * @todo Rename to something more suitable like UIScreenThumbnailContainer. */ 39 class SHARED_LIBRARY_STUFF UIFilmContainer : public QWidget 38 40 { 39 41 Q_OBJECT; … … 41 43 public: 42 44 43 /* Constructor:*/45 /** Constructs film-container passing @a pParent to the base-class. */ 44 46 UIFilmContainer(QWidget *pParent = 0); 45 47 46 /* API: Value stuff:*/48 /** Returns the film-container check-box values. */ 47 49 QVector<BOOL> value() const; 48 void setValue(const QVector<BOOL> &value); 50 /** Defines the film-container check-box @a values. */ 51 void setValue(const QVector<BOOL> &values); 49 52 50 53 private: 51 54 52 /* Helpers: Prepare stuff:*/55 /** Prepares all. */ 53 56 void prepare(); 57 /** Prepares layout. */ 54 58 void prepareLayout(); 59 /** Prepares scroller. */ 55 60 void prepareScroller(); 56 61 57 /* Variables: */ 58 QVBoxLayout *m_pMainLayout; 59 QScrollArea *m_pScroller; 60 QList<UIFilm*> m_widgets; 62 /** Holds the main layout intance. */ 63 QVBoxLayout *m_pMainLayout; 64 /** Holds the scroller intance. */ 65 QScrollArea *m_pScroller; 66 /** Holds the list of film widgets. */ 67 QList<UIFilm*> m_widgets; 61 68 }; 62 69 63 /* QWidget item prototype for UIFilmContainer: */ 64 class UIFilm : public QIWithRetranslateUI<QWidget> 65 { 66 Q_OBJECT; 67 68 public: 69 70 /* Constructor: */ 71 UIFilm(int iScreenIndex, BOOL fEnabled, QWidget *pParent = 0); 72 73 /* API: Check-box stuff: */ 74 bool checked() const; 75 76 private: 77 78 /* Handler: Translate stuff: */ 79 void retranslateUi(); 80 81 /* Helpers: Prepare stuff: */ 82 void prepare(); 83 void prepareLayout(); 84 void prepareCheckBox(); 85 86 /* Helper: Layout stuff: */ 87 QSize minimumSizeHint() const; 88 89 /* Handler: Paint stuff: */ 90 void paintEvent(QPaintEvent *pEvent); 91 92 /* Variables: */ 93 int m_iScreenIndex; 94 BOOL m_fWasEnabled; 95 QVBoxLayout *m_pMainLayout; 96 QCheckBox *m_pCheckBox; 97 }; 98 99 #endif /* __UIFilmContainer_h__ */ 70 #endif /* !___UIFilmContainer_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.