Changeset 20200 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 2, 2009 4:18:04 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r19844 r20200 102 102 103 103 QRect desktopGeometry(); 104 105 QRegion lastVisibleRegion() const; 104 106 105 107 bool isAutoresizeGuestActive(); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r20047 r20200 254 254 void mtExitMode(); 255 255 void mtCloseVM(); 256 void mtMaskUpdate(); 256 257 257 258 private: -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxMiniToolBar.h
r20146 r20200 49 49 }; 50 50 51 VBoxMiniToolBar (Alignment aAlignment); 51 VBoxMiniToolBar (QWidget *aParent, Alignment aAlignment); 52 53 void setIsSeamlessMode (bool aIsSeamless); 52 54 53 55 VBoxMiniToolBar& operator<< (QList <QMenu*> aMenus); … … 60 62 void exitAction(); 61 63 void closeAction(); 64 void geometryUpdated(); 62 65 63 66 protected: 64 67 65 void resizeEvent (QResizeEvent *aEvent);66 68 void mouseMoveEvent (QMouseEvent *aEvent); 67 69 void timerEvent (QTimerEvent *aEvent); … … 73 75 74 76 private: 77 78 void recreateMask(); 79 void moveToBase(); 80 QPoint mapFromScreen (const QPoint &aPoint); 75 81 76 82 QAction *mAutoHideAct; … … 88 94 int mPositionX; 89 95 int mPositionY; 96 97 bool mIsSeamless; 90 98 91 99 /* Lists of used spacers */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r20047 r20200 2634 2634 } 2635 2635 2636 QRegion VBoxConsoleView::lastVisibleRegion() const 2637 { 2638 return mLastVisibleRegion; 2639 } 2640 2636 2641 bool VBoxConsoleView::isAutoresizeGuestActive() 2637 2642 { -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r20146 r20200 520 520 mMiniVMMenu->addAction (mVmPauseAction); 521 521 mMiniVMMenu->addAction (mVmACPIShutdownAction); 522 523 /* Mini toolbar */524 QList <QMenu*> menus (QList <QMenu*> () << mMiniVMMenu << mDevicesMenu);525 mMiniToolBar = new VBoxMiniToolBar (VBoxMiniToolBar::AlignBottom);526 *mMiniToolBar << menus;527 connect (mMiniToolBar, SIGNAL (exitAction()), this, SLOT (mtExitMode()));528 connect (mMiniToolBar, SIGNAL (closeAction()), this, SLOT (mtCloseVM()));529 connect (this, SIGNAL (closing()), mMiniToolBar, SLOT (close()));530 522 531 523 ///// Status bar //////////////////////////////////////////////////////// … … 818 810 centralWidget()); 819 811 812 /* Mini toolbar */ 813 QList <QMenu*> menus (QList <QMenu*> () << mMiniVMMenu << mDevicesMenu); 814 mMiniToolBar = new VBoxMiniToolBar (centralWidget(), VBoxMiniToolBar::AlignBottom); 815 *mMiniToolBar << menus; 816 connect (mMiniToolBar, SIGNAL (exitAction()), this, SLOT (mtExitMode())); 817 connect (mMiniToolBar, SIGNAL (closeAction()), this, SLOT (mtCloseVM())); 818 connect (mMiniToolBar, SIGNAL (geometryUpdated()), this, SLOT (mtMaskUpdate())); 819 connect (this, SIGNAL (closing()), mMiniToolBar, SLOT (close())); 820 820 821 activateUICustomizations(); 821 822 … … 2440 2441 if (aOn) 2441 2442 { 2443 mMiniToolBar->setIsSeamlessMode (aSeamless); 2442 2444 mMiniToolBar->updateDisplay (true, true); 2443 2445 } … … 2573 2575 } 2574 2576 2577 void VBoxConsoleWnd::mtMaskUpdate() 2578 { 2579 if (mIsSeamless) 2580 setMask (console->lastVisibleRegion()); 2581 } 2582 2575 2583 void VBoxConsoleWnd::vmFullscreen (bool aOn) 2576 2584 { … … 2989 2997 { 2990 2998 QRegion region = aRegion; 2999 2991 3000 /* The global mask shift cause of toolbars and such things. */ 2992 3001 region.translate (mMaskShift.width(), mMaskShift.height()); 3002 3003 /* Including mini toolbar area */ 3004 QRegion toolBarRegion (mMiniToolBar->mask()); 3005 toolBarRegion.translate (mMiniToolBar->mapToGlobal (toolBarRegion.boundingRect().topLeft()) - QPoint (1, 0)); 3006 region += toolBarRegion; 3007 2993 3008 /* Restrict the drawing to the available space on the screen. 2994 3009 * (The &operator is better than the previous used -operator, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMiniToolBar.cpp
r20146 r20200 35 35 #include <QTimer> 36 36 37 VBoxMiniToolBar::VBoxMiniToolBar ( Alignment aAlignment)38 : VBoxToolBar ( 0)37 VBoxMiniToolBar::VBoxMiniToolBar (QWidget *aParent, Alignment aAlignment) 38 : VBoxToolBar (aParent) 39 39 , mAutoHideCounter (0) 40 40 , mAutoHide (true) … … 42 42 , mHideAfterSlide (false) 43 43 , mPolished (false) 44 , mIsSeamless (false) 44 45 , mAlignment (aAlignment) 45 46 , mAnimated (true) … … 48 49 , mAutoHideTotalCounter (10) 49 50 { 50 /* Play with toolbar mode as child of the main window, rather than top parentless */ 51 //setAllowedAreas (Qt::NoToolBarArea); 52 //mMainWindow->addToolBar (/* Qt::NoToolBarArea, */ this); 53 54 setWindowFlags (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); 51 AssertMsg (parentWidget(), ("Parent widget must be set!!!\n")); 52 53 /* Various options */ 54 setAutoFillBackground (true); 55 55 setIconSize (QSize (16, 16)); 56 56 setMouseTracking (mAutoHide); 57 57 setVisible (false); 58 59 // TODO, we need to hide the tab icon in taskbar when in seamless mode60 setWindowTitle (tr ("VirtualBox Mini Toolbar"));61 58 62 59 /* Left margin of tool-bar */ … … 108 105 } 109 106 107 void VBoxMiniToolBar::setIsSeamlessMode (bool aIsSeamless) 108 { 109 mIsSeamless = aIsSeamless; 110 } 111 110 112 VBoxMiniToolBar& VBoxMiniToolBar::operator<< (QList <QMenu*> aMenus) 111 113 { … … 131 133 if (aShow) 132 134 { 135 if (isHidden()) 136 moveToBase(); 137 133 138 if (mAnimated) 134 139 { … … 174 179 { 175 180 mDisplayLabel->setText (aText); 176 }177 178 void VBoxMiniToolBar::resizeEvent (QResizeEvent*)179 {180 /* Create polygon shaped toolbar */181 int triangular_x = height();182 int points [8];183 switch (mAlignment)184 {185 case AlignTop:186 {187 points [0] = 0;188 points [1] = 0;189 190 points [2] = triangular_x;191 points [3] = height();192 193 points [4] = width() - triangular_x;194 points [5] = height();195 196 points [6] = width();197 points [7] = 0;198 199 break;200 }201 case AlignBottom:202 {203 points [0] = triangular_x;204 points [1] = 0;205 206 points [2] = 0;207 points [3] = height();208 209 points [4] = width();210 points [5] = height();211 212 points [6] = width() - triangular_x;213 points [7] = 0;214 215 break;216 }217 default:218 break;219 }220 QPolygon polygon;221 polygon.setPoints (4, points);222 setMask (polygon);223 224 /* Set the initial position */225 QRect d = QApplication::desktop()->screenGeometry (this);226 mPositionX = d.width() / 2 - width() / 2;227 switch (mAlignment)228 {229 case AlignTop:230 {231 mPositionY = - height() + 1;232 break;233 }234 case AlignBottom:235 {236 mPositionY = d.height() - 1;237 break;238 }239 default:240 {241 mPositionY = 0;242 break;243 }244 }245 move (mPositionX, mPositionY);246 181 } 247 182 … … 282 217 case AlignBottom: 283 218 { 284 QRect d = QApplication::desktop()->screenGeometry (this); 285 if (((mPositionY == d.height() - height()) && mSlideToScreen) || 286 ((mPositionY == d.height() - 1) && !mSlideToScreen)) 219 QRect screen = mIsSeamless ? QApplication::desktop()->availableGeometry (this) : 220 QApplication::desktop()->screenGeometry (this); 221 if (((mPositionY == screen.height() - height()) && mSlideToScreen) || 222 ((mPositionY == screen.height() - 1) && !mSlideToScreen)) 287 223 { 288 224 mScrollTimer.stop(); … … 300 236 break; 301 237 } 302 move (mPositionX, mPositionY); 238 move (mapFromScreen (QPoint (mPositionX, mPositionY))); 239 emit geometryUpdated(); 303 240 } 304 241 else if (aEvent->timerId() == mAutoScrollTimer.timerId()) … … 344 281 resize (sizeHint()); 345 282 283 /* Initialize */ 284 recreateMask(); 285 moveToBase(); 286 346 287 mPolished = true; 347 288 } … … 356 297 } 357 298 299 void VBoxMiniToolBar::recreateMask() 300 { 301 int edgeShift = height(); 302 int points [8]; 303 switch (mAlignment) 304 { 305 case AlignTop: 306 { 307 points [0] = 0; 308 points [1] = 0; 309 310 points [2] = edgeShift; 311 points [3] = height(); 312 313 points [4] = width() - edgeShift; 314 points [5] = height(); 315 316 points [6] = width(); 317 points [7] = 0; 318 319 break; 320 } 321 case AlignBottom: 322 { 323 points [0] = edgeShift; 324 points [1] = 0; 325 326 points [2] = 0; 327 points [3] = height(); 328 329 points [4] = width(); 330 points [5] = height(); 331 332 points [6] = width() - edgeShift; 333 points [7] = 0; 334 335 break; 336 } 337 default: 338 break; 339 } 340 QPolygon polygon; 341 polygon.setPoints (4, points); 342 setMask (polygon); 343 } 344 345 void VBoxMiniToolBar::moveToBase() 346 { 347 QRect screen = mIsSeamless ? QApplication::desktop()->availableGeometry (this) : 348 QApplication::desktop()->screenGeometry (this); 349 mPositionX = screen.width() / 2 - width() / 2; 350 switch (mAlignment) 351 { 352 case AlignTop: 353 { 354 mPositionY = - height() + 1; 355 break; 356 } 357 case AlignBottom: 358 { 359 mPositionY = screen.height() - 1; 360 break; 361 } 362 default: 363 { 364 mPositionY = 0; 365 break; 366 } 367 } 368 move (mapFromScreen (QPoint (mPositionX, mPositionY))); 369 } 370 371 QPoint VBoxMiniToolBar::mapFromScreen (const QPoint &aPoint) 372 { 373 QPoint globalPosition = parentWidget()->mapFromGlobal (aPoint); 374 QRect fullArea = QApplication::desktop()->screenGeometry (this); 375 QRect realArea = mIsSeamless ? QApplication::desktop()->availableGeometry (this) : 376 QApplication::desktop()->screenGeometry (this); 377 QPoint shiftToReal (realArea.topLeft() - fullArea.topLeft()); 378 return globalPosition + shiftToReal; 379 } 380
Note:
See TracChangeset
for help on using the changeset viewer.