Changeset 52891 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
- Timestamp:
- Sep 29, 2014 4:52:38 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96319
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
r52874 r52891 52 52 bool fAutoHide /* = true */) 53 53 : QWidget(pParent, 54 #if defined 54 #if defined(Q_WS_WIN) 55 55 Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint 56 #elif defined (Q_WS_MAC)56 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 57 57 Qt::Window | Qt::FramelessWindowHint 58 #elif defined (Q_WS_X11) 59 Qt::Widget 60 #endif /* RT_OS_DARWIN */ 58 #endif /* Q_WS_MAC || Q_WS_X11 */ 61 59 ) 62 60 /* Variables: General stuff: */ … … 143 141 void UIRuntimeMiniToolBar::adjustGeometry(int iHostScreen /* = -1 */) 144 142 { 143 #ifndef Q_WS_X11 145 144 /* This method could be called before parent-widget 146 145 * become visible, we should skip everything in that case: */ … … 166 165 default: break; 167 166 } 168 #ifdef Q_WS_X11169 /* Disregard origin under X11,170 * because this is widget, not window: */171 screenRect.moveTopLeft(QPoint(0, 0));172 #endif /* Q_WS_X11 */173 167 iX = screenRect.x() + screenRect.width() / 2 - width() / 2; 174 168 switch (m_alignment) … … 202 196 /* Simulate toolbar auto-hiding: */ 203 197 simulateToolbarAutoHiding(); 198 199 #else /* Q_WS_X11 */ 200 201 /* This method could be called before parent-widget 202 * become visible, we should skip everything in that case: */ 203 if (QApplication::desktop()->screenNumber(parentWidget()) == -1) 204 return; 205 206 /* Determine host-screen number if necessary: */ 207 bool fMoveToHostScreen = true; 208 if (iHostScreen == -1) 209 { 210 fMoveToHostScreen = false; 211 iHostScreen = QApplication::desktop()->screenNumber(this); 212 } 213 214 /* Choose window geometry: */ 215 QRect screenRect; 216 switch (m_geometryType) 217 { 218 case GeometryType_Available: screenRect = QApplication::desktop()->availableGeometry(iHostScreen); break; 219 case GeometryType_Full: screenRect = QApplication::desktop()->screenGeometry(iHostScreen); break; 220 default: break; 221 } 222 223 /* Move to corresponding host-screen: */ 224 if (fMoveToHostScreen) 225 move(screenRect.topLeft()); 226 227 /* Resize embedded-toolbar to minimum size: */ 228 m_pEmbeddedToolbar->resize(m_pEmbeddedToolbar->sizeHint()); 229 230 /* Calculate embedded-toolbar position: */ 231 int iX = 0, iY = 0; 232 iX = screenRect.width() / 2 - m_pEmbeddedToolbar->width() / 2; 233 switch (m_alignment) 234 { 235 case Qt::AlignTop: iY = 0; break; 236 case Qt::AlignBottom: iY = screenRect.height() - m_pEmbeddedToolbar->height(); break; 237 default: break; 238 } 239 240 /* Update auto-hide animation: */ 241 m_shownToolbarPosition = QPoint(iX, iY); 242 switch (m_alignment) 243 { 244 case Qt::AlignTop: m_hiddenToolbarPosition = m_shownToolbarPosition - QPoint(0, m_pEmbeddedToolbar->height() - 3); break; 245 case Qt::AlignBottom: m_hiddenToolbarPosition = m_shownToolbarPosition + QPoint(0, m_pEmbeddedToolbar->height() - 3); break; 246 } 247 m_pAnimation->update(); 248 249 /* Update embedded-toolbar geometry if known: */ 250 const QString strAnimationState = property("AnimationState").toString(); 251 if (strAnimationState == "Start") 252 m_pEmbeddedToolbar->move(m_hiddenToolbarPosition); 253 else if (strAnimationState == "Final") 254 m_pEmbeddedToolbar->move(m_shownToolbarPosition); 255 256 /* Adjust window mask: */ 257 setMask(m_pEmbeddedToolbar->geometry()); 258 259 /* Simulate toolbar auto-hiding: */ 260 simulateToolbarAutoHiding(); 261 #endif /* Q_WS_X11 */ 204 262 } 205 263 … … 238 296 void UIRuntimeMiniToolBar::prepare() 239 297 { 240 #if def Q_WS_MAC298 #if defined(Q_WS_MAC) || defined (Q_WS_X11) 241 299 /* Install own event filter: */ 242 300 installEventFilter(this); 243 #endif /* Q_WS_MAC */301 #endif /* Q_WS_MAC || Q_WS_X11 */ 244 302 245 303 #if defined(Q_WS_MAC) || defined(Q_WS_WIN) … … 259 317 setAttribute(Qt::WA_TranslucentBackground); 260 318 # endif /* Q_WS_WIN */ 261 #endif /* Q_WS_MAC || Q_WS_WIN */ 319 #elif defined(Q_WS_X11) 320 /* Use Qt API to enable translucency if allowed: */ 321 if (QX11Info::isCompositingManagerRunning()) 322 setAttribute(Qt::WA_TranslucentBackground); 323 #endif /* Q_WS_X11 */ 262 324 263 325 /* Make sure we have no focus: */ … … 378 440 } 379 441 442 #ifdef Q_WS_X11 443 void UIRuntimeMiniToolBar::resizeEvent(QResizeEvent*) 444 { 445 /* Adjust mini-toolbar on resize: */ 446 adjustGeometry(); 447 } 448 #endif /* Q_WS_X11 */ 449 380 450 bool UIRuntimeMiniToolBar::eventFilter(QObject *pWatched, QEvent *pEvent) 381 451 { … … 388 458 pEvent->type() == QEvent::FocusIn) 389 459 emit sigNotifyAboutFocusStolen(); 390 #elif defined(Q_WS_MAC) 391 /* Due to Qt bug on Mac OS X window will be activated 392 * even if has Qt::WA_ShowWithoutActivating attribute. */ 460 #elif defined(Q_WS_MAC) || defined(Q_WS_X11) 461 /* Detect if we have window activation stolen. */ 393 462 if (pWatched == this && 394 463 pEvent->type() == QEvent::WindowActivate) 395 464 emit sigNotifyAboutFocusStolen(); 396 #endif /* Q_WS_MAC */465 #endif /* Q_WS_MAC || Q_WS_X11 */ 397 466 398 467 /* Call to base-class: */ … … 423 492 /* Update window mask: */ 424 493 setMask(m_pEmbeddedToolbar->geometry()); 425 426 # ifdef VBOX_WITH_MASKED_SEAMLESS427 /* Notify listeners as well: */428 const QRect windowGeo = geometry();429 emit sigNotifyAboutGeometryChange(windowGeo.intersected(m_pEmbeddedToolbar->geometry().translated(windowGeo.topLeft())));430 # endif /* VBOX_WITH_MASKED_SEAMLESS */431 494 #endif /* Q_WS_X11 */ 432 495 }
Note:
See TracChangeset
for help on using the changeset viewer.