Changeset 66755 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 3, 2017 10:47:47 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115163
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/precomp.h
r66678 r66755 109 109 #include <QMainWindow> 110 110 #include <QMap> 111 #include <QMdiArea>112 #include <QMdiSubWindow>113 111 #include <QMenu> 114 112 #include <QMenuBar> -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.cpp
r64334 r66755 5 5 6 6 /* 7 * Copyright (C) 2014-201 6Oracle Corporation7 * Copyright (C) 2014-2017 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 <QMdiSubWindow>24 23 # include <QHBoxLayout> 25 # include <QMdiArea>26 24 27 25 /* GUI includes: */ … … 45 43 , m_fExpanded(false) 46 44 , m_pMainLayout(0) 47 , m_p MdiArea(0)45 , m_pArea(0) 48 46 , m_pWidget(pChildWidget) 49 , m_pEmbeddedWidget(0)50 47 { 51 48 /* Prepare: */ … … 102 99 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 103 100 m_pMainLayout->setSpacing(0); 104 /* Create mdi-area: */105 m_p MdiArea = new QMdiArea;106 AssertPtrReturnVoid(m_p MdiArea);107 { 108 /* Configure mdi-area: */109 m_p MdiArea->setAcceptDrops(true);110 m_p MdiArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);111 QPalette pal1 = m_p MdiArea->palette();101 /* Create area: */ 102 m_pArea = new QWidget; 103 AssertPtrReturnVoid(m_pArea); 104 { 105 /* Configure area: */ 106 m_pArea->setAcceptDrops(true); 107 m_pArea->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 108 QPalette pal1 = m_pArea->palette(); 112 109 pal1.setColor(QPalette::Window, QColor(Qt::transparent)); 113 m_pMdiArea->setPalette(pal1); 114 m_pMdiArea->setBackground(QColor(Qt::transparent)); 110 m_pArea->setPalette(pal1); 115 111 /* Make sure valid child-widget passed: */ 116 112 AssertPtrReturnVoid(m_pWidget); … … 121 117 m_pWidget->setPalette(pal2); 122 118 connect(m_pWidget, SIGNAL(sigCancelClicked()), this, SLOT(close())); 123 /* Add child-widget into mdi-area: */ 124 m_pEmbeddedWidget = m_pMdiArea->addSubWindow(m_pWidget, Qt::Window | Qt::FramelessWindowHint); 125 AssertPtrReturnVoid(m_pEmbeddedWidget); 119 /* Add child-widget into area: */ 120 m_pWidget->setParent(m_pArea); 126 121 } 127 /* Add mdi-area into main-layout: */128 m_pMainLayout->addWidget(m_p MdiArea);122 /* Add area into main-layout: */ 123 m_pMainLayout->addWidget(m_pArea); 129 124 } 130 125 } … … 133 128 void UISlidingToolBar::prepareGeometry() 134 129 { 135 /* Prepare geometry based on parent and mdi-sub-window size-hints,136 * But move mdi-sub-window to initial position: */137 const QSize sh = m_p EmbeddedWidget->sizeHint();130 /* Prepare geometry based on parent and sub-window size-hints, 131 * But move sub-window to initial position: */ 132 const QSize sh = m_pWidget->sizeHint(); 138 133 switch (m_position) 139 134 { … … 142 137 VBoxGlobal::setTopLevelGeometry(this, m_parentRect.x(), m_parentRect.y() + m_indentRect.height(), 143 138 qMax(m_parentRect.width(), sh.width()), sh.height()); 144 m_p EmbeddedWidget->setGeometry(0, -sh.height(), qMax(width(), sh.width()), sh.height());139 m_pWidget->setGeometry(0, -sh.height(), qMax(width(), sh.width()), sh.height()); 145 140 break; 146 141 } … … 149 144 VBoxGlobal::setTopLevelGeometry(this, m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(), 150 145 qMax(m_parentRect.width(), sh.width()), sh.height()); 151 m_p EmbeddedWidget->setGeometry(0, sh.height(), qMax(width(), sh.width()), sh.height());146 m_pWidget->setGeometry(0, sh.height(), qMax(width(), sh.width()), sh.height()); 152 147 break; 153 148 } … … 158 153 { 159 154 /* Use Xshape otherwise: */ 160 setMask(m_p EmbeddedWidget->geometry());155 setMask(m_pWidget->geometry()); 161 156 } 162 157 #endif /* VBOX_WS_X11 */ … … 177 172 void UISlidingToolBar::prepareAnimation() 178 173 { 179 /* Prepare mdi-sub-window geometry animation itself: */174 /* Prepare sub-window geometry animation itself: */ 180 175 connect(this, SIGNAL(sigShown()), this, SIGNAL(sigExpand()), Qt::QueuedConnection); 181 176 m_pAnimation = UIAnimation::installPropertyAnimation(this, … … 191 186 void UISlidingToolBar::adjustGeometry() 192 187 { 193 /* Adjust geometry based on parent and mdi-sub-window size-hints: */194 const QSize sh = m_p EmbeddedWidget->sizeHint();188 /* Adjust geometry based on parent and sub-window size-hints: */ 189 const QSize sh = m_pWidget->sizeHint(); 195 190 switch (m_position) 196 191 { … … 208 203 } 209 204 } 210 /* And move mdi-sub-window to corresponding position: */211 m_p EmbeddedWidget->setGeometry(0, 0, qMax(width(), sh.width()), sh.height());205 /* And move sub-window to corresponding position: */ 206 m_pWidget->setGeometry(0, 0, qMax(width(), sh.width()), sh.height()); 212 207 213 208 #ifdef VBOX_WS_X11 … … 215 210 { 216 211 /* Use Xshape otherwise: */ 217 setMask(m_p EmbeddedWidget->geometry());212 setMask(m_pWidget->geometry()); 218 213 } 219 214 #endif /* VBOX_WS_X11 */ … … 231 226 return; 232 227 233 /* Recalculate mdi-sub-window geometry animation boundaries based on size-hint: */234 const QSize sh = m_p EmbeddedWidget->sizeHint();228 /* Recalculate sub-window geometry animation boundaries based on size-hint: */ 229 const QSize sh = m_pWidget->sizeHint(); 235 230 switch (m_position) 236 231 { … … 300 295 void UISlidingToolBar::setWidgetGeometry(const QRect &rect) 301 296 { 302 /* Apply mdi-sub-window geometry: */303 m_p EmbeddedWidget->setGeometry(rect);297 /* Apply sub-window geometry: */ 298 m_pWidget->setGeometry(rect); 304 299 305 300 #ifdef VBOX_WS_X11 … … 307 302 { 308 303 /* Use Xshape otherwise: */ 309 setMask(m_p EmbeddedWidget->geometry());304 setMask(m_pWidget->geometry()); 310 305 } 311 306 #endif /* VBOX_WS_X11 */ … … 314 309 QRect UISlidingToolBar::widgetGeometry() const 315 310 { 316 /* Return mdi-sub-window geometry: */317 return m_p EmbeddedWidget->geometry();318 } 319 311 /* Return sub-window geometry: */ 312 return m_pWidget->geometry(); 313 } 314 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.h
r62493 r66755 5 5 6 6 /* 7 * Copyright (C) 2014-201 6Oracle Corporation7 * Copyright (C) 2014-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 24 24 /* Forward declarations: */ 25 class QMdiArea;26 class QMdiSubWindow;27 25 class QHBoxLayout; 28 26 class UIAnimation; … … 99 97 #endif /* VBOX_WS_MAC */ 100 98 101 /** Defines mdi-sub-window geometry. */99 /** Defines sub-window geometry. */ 102 100 void setWidgetGeometry(const QRect &rect); 103 /** Returns mdi-sub-window geometry. */101 /** Returns sub-window geometry. */ 104 102 QRect widgetGeometry() const; 105 /** Returns mdi-sub-window start-geometry. */103 /** Returns sub-window start-geometry. */ 106 104 QRect startWidgetGeometry() const { return m_startWidgetGeometry; } 107 /** Returns mdi-sub-window final-geometry. */105 /** Returns sub-window final-geometry. */ 108 106 QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; } 109 107 … … 124 122 /** Holds whether window is expanded. */ 125 123 bool m_fExpanded; 126 /** Holds mdi-sub-window start-geometry. */124 /** Holds sub-window start-geometry. */ 127 125 QRect m_startWidgetGeometry; 128 /** Holds mdi-sub-window final-geometry. */126 /** Holds sub-window final-geometry. */ 129 127 QRect m_finalWidgetGeometry; 130 128 /** @} */ … … 134 132 /** Holds the main-layout instance. */ 135 133 QHBoxLayout *m_pMainLayout; 136 /** Holds the mdi-area instance. */137 Q MdiArea *m_pMdiArea;134 /** Holds the area instance. */ 135 QWidget *m_pArea; 138 136 /** Holds the child-widget reference. */ 139 137 QWidget *m_pWidget; 140 /** Holds the child-widget wrapper instance. */141 QMdiSubWindow *m_pEmbeddedWidget;142 138 /** @} */ 143 139 }; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
r65799 r66755 23 23 # include <QApplication> 24 24 # include <QTimer> 25 # include <QMdiArea>26 # include <QMdiSubWindow>27 25 # include <QLabel> 28 26 # include <QMenu> … … 347 345 m_spacings << widgetForAction(addWidget(new QWidget)); 348 346 #endif /* !VBOX_WS_X11 */ 349 350 /* Resize to sizehint: */351 resize(sizeHint());352 347 } 353 348 … … 439 434 , m_fAutoHide(fAutoHide) 440 435 /* Variables: Contents stuff: */ 441 , m_p MdiArea(0)436 , m_pArea(0) 442 437 , m_pToolbar(0) 443 , m_pEmbeddedToolbar(0)444 438 /* Variables: Hover stuff: */ 445 439 , m_fHovered(false) … … 520 514 void UIMiniToolBar::adjustGeometry() 521 515 { 522 /* Resize embedded-toolbar to minimum size: */523 m_p EmbeddedToolbar->resize(m_pEmbeddedToolbar->sizeHint());524 525 /* Calculate embedded-toolbar position: */516 /* Resize toolbar to minimum size: */ 517 m_pToolbar->resize(m_pToolbar->sizeHint()); 518 519 /* Calculate toolbar position: */ 526 520 int iX = 0, iY = 0; 527 iX = width() / 2 - m_p EmbeddedToolbar->width() / 2;521 iX = width() / 2 - m_pToolbar->width() / 2; 528 522 switch (m_alignment) 529 523 { 530 524 case Qt::AlignTop: iY = 0; break; 531 case Qt::AlignBottom: iY = height() - m_p EmbeddedToolbar->height(); break;525 case Qt::AlignBottom: iY = height() - m_pToolbar->height(); break; 532 526 default: break; 533 527 } … … 537 531 switch (m_alignment) 538 532 { 539 case Qt::AlignTop: m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_p EmbeddedToolbar->height() - 3); break;540 case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_p EmbeddedToolbar->height() - 3); break;533 case Qt::AlignTop: m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_pToolbar->height() - 3); break; 534 case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_pToolbar->height() - 3); break; 541 535 } 542 536 m_pAnimation->update(); 543 537 544 /* Update embedded-toolbar geometry if known: */538 /* Update toolbar geometry if known: */ 545 539 if (property("AnimationState").toString() == "Final") 546 m_p EmbeddedToolbar->move(m_shownToolbarPosition);540 m_pToolbar->move(m_shownToolbarPosition); 547 541 else 548 m_p EmbeddedToolbar->move(m_hiddenToolbarPosition);542 m_pToolbar->move(m_hiddenToolbarPosition); 549 543 550 544 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 551 545 /* Adjust window mask: */ 552 setMask(m_p EmbeddedToolbar->geometry());546 setMask(m_pToolbar->geometry()); 553 547 #endif /* VBOX_WS_WIN || VBOX_WS_X11 */ 554 548 } … … 839 833 setFocusPolicy(Qt::NoFocus); 840 834 841 /* Prepare mdi-area: */842 m_p MdiArea = new QMdiArea;843 { 844 /* Allow any MDIarea size: */845 m_p MdiArea->setMinimumSize(QSize(1, 1));835 /* Prepare area: */ 836 m_pArea = new QWidget; 837 { 838 /* Allow any area size: */ 839 m_pArea->setMinimumSize(QSize(1, 1)); 846 840 /* Configure own background: */ 847 QPalette pal = m_p MdiArea->palette();841 QPalette pal = m_pArea->palette(); 848 842 pal.setColor(QPalette::Window, QColor(Qt::transparent)); 849 m_pMdiArea->setPalette(pal); 850 /* Configure viewport background: */ 851 m_pMdiArea->setBackground(QColor(Qt::transparent)); 852 /* Layout mdi-area according parent-widget: */ 843 m_pArea->setPalette(pal); 844 /* Layout area according parent-widget: */ 853 845 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 854 846 pMainLayout->setContentsMargins(0, 0, 0, 0); 855 pMainLayout->addWidget(m_p MdiArea);847 pMainLayout->addWidget(m_pArea); 856 848 /* Make sure we have no focus: */ 857 m_pMdiArea->setFocusPolicy(Qt::NoFocus); 858 m_pMdiArea->viewport()->setFocusPolicy(Qt::NoFocus); 849 m_pArea->setFocusPolicy(Qt::NoFocus); 859 850 } 860 851 … … 877 868 connect(m_pToolbar, SIGNAL(sigExitAction()), this, SIGNAL(sigExitAction())); 878 869 connect(m_pToolbar, SIGNAL(sigCloseAction()), this, SIGNAL(sigCloseAction())); 879 /* Add child to mdi-area: */880 m_p EmbeddedToolbar = m_pMdiArea->addSubWindow(m_pToolbar, Qt::Window | Qt::FramelessWindowHint);870 /* Add child to area: */ 871 m_pToolbar->setParent(m_pArea); 881 872 /* Make sure we have no focus: */ 882 m_p EmbeddedToolbar->setFocusPolicy(Qt::NoFocus);873 m_pToolbar->setFocusPolicy(Qt::NoFocus); 883 874 } 884 875 … … 922 913 m_pHoverLeaveTimer->stop(); 923 914 924 /* Destroy animation before mdi-toolbar: */915 /* Destroy animation before toolbar: */ 925 916 delete m_pAnimation; 926 917 m_pAnimation = 0; 927 918 928 /* Destroy mdi-toolbar after animation: */929 delete m_p EmbeddedToolbar;930 m_p EmbeddedToolbar = 0;919 /* Destroy toolbar after animation: */ 920 delete m_pToolbar; 921 m_pToolbar = 0; 931 922 } 932 923 … … 1121 1112 { 1122 1113 /* Update position: */ 1123 AssertPtrReturnVoid(m_p EmbeddedToolbar);1124 m_p EmbeddedToolbar->move(point);1114 AssertPtrReturnVoid(m_pToolbar); 1115 m_pToolbar->move(point); 1125 1116 1126 1117 #if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) 1127 1118 /* Update window mask: */ 1128 setMask(m_p EmbeddedToolbar->geometry());1119 setMask(m_pToolbar->geometry()); 1129 1120 #endif /* VBOX_WS_WIN || VBOX_WS_X11 */ 1130 1121 } … … 1133 1124 { 1134 1125 /* Return position: */ 1135 AssertPtrReturn(m_p EmbeddedToolbar, QPoint());1136 return m_p EmbeddedToolbar->pos();1126 AssertPtrReturn(m_pToolbar, QPoint()); 1127 return m_pToolbar->pos(); 1137 1128 } 1138 1129 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h
r65797 r66755 26 26 class QTimer; 27 27 class QLabel; 28 class QMdiArea;29 class QMdiSubWindow;30 28 class UIAnimation; 31 29 class UIMiniToolBarPrivate; … … 169 167 bool m_fAutoHide; 170 168 171 /** Holds the MDI-area. */172 Q MdiArea *m_pMdiArea;169 /** Holds the area. */ 170 QWidget *m_pArea; 173 171 /** Holds the internal widget. */ 174 172 UIMiniToolBarPrivate *m_pToolbar; 175 /** Holds the pointer to the wrapped176 * internal widget inside the MDI-area. */177 QMdiSubWindow *m_pEmbeddedToolbar;178 173 179 174 /** Holds whether we are hovered. */
Note:
See TracChangeset
for help on using the changeset viewer.