| 58 | } |
| 59 | |
| 60 | void QmitkOverlayController::InitializeWidget(QmitkOverlay::DisplayPosition pos) |
| 61 | { |
| 62 | // create a new QWidget as Tool & FramelessWindowHint |
| 63 | m_PositionedOverlays[pos] = new QmitkOverlayContainerWidget(m_RenderWindow, Qt::Tool | Qt::FramelessWindowHint); |
| 64 | |
| 65 | // autoFillBackGround(false) and WA_TranslucentBackground = true are needed to have a translucent background |
| 66 | // transparency does NOT work under Win-XP 32-Bit --> paint black background |
| 67 | |
| 68 | #if !defined(_WIN32) || defined(_WIN64) |
| 69 | m_PositionedOverlays[pos]->setAttribute(Qt::WA_TranslucentBackground, true); |
| 70 | #else |
| 71 | m_PositionedOverlays[pos]->setStyleSheet("QWidget { background: black }"); |
| 72 | m_PositionedOverlays[pos]->setAttribute(Qt::WA_TranslucentBackground, false); |
| 73 | #endif |
| 74 | |
| 75 | // X11 specific attributes |
| 76 | m_PositionedOverlays[pos]->setAttribute(Qt::WA_X11NetWmWindowTypeUtility, true); |
| 77 | |
| 78 | // mac-specific attributes: |
| 79 | // making sure overlays are even visible if RenderWindow does not have the focus (not default for Qt::Tool on mac) |
| 80 | m_PositionedOverlays[pos]->setAttribute(Qt::WA_MacAlwaysShowToolWindow, true); |
| 81 | // testing something |
| 82 | m_PositionedOverlays[pos]->setAttribute(Qt::WA_MacShowFocusRect, false); |
| 83 | |
| 84 | // overlays should not get the focus |
| 85 | m_PositionedOverlays[pos]->setFocusPolicy(Qt::NoFocus); |
| 86 | |
| 87 | // setting the color of the background to transparent - not sure it's needed after the attributes have been set above |
| 88 | QPalette p = QPalette(); |
| 89 | p.setColor(QPalette::Window, Qt::transparent); |
| 90 | m_PositionedOverlays[pos]->setPalette(p); |
| 91 | |
| 92 | // setting position-specific properties |
| 93 | switch (pos) |
| 94 | { |
| 95 | case QmitkOverlay::top_Left: |
| 96 | { |
| 97 | // adding left-aligned top-to-bottom layout |
| 98 | QVBoxLayout *layout = new QVBoxLayout(m_PositionedOverlays[pos]); |
| 99 | layout->setDirection(QBoxLayout::TopToBottom); |
| 100 | layout->setAlignment(Qt::AlignLeft); |
| 101 | m_PositionedOverlays[pos]->layout()->setSpacing(0); |
| 102 | break; |
| 103 | } |
| 104 | case QmitkOverlay::top_Center: |
| 105 | { |
| 106 | // adding center-aligned top-to-bottom layout |
| 107 | QVBoxLayout *layout = new QVBoxLayout(m_PositionedOverlays[pos]); |
| 108 | layout->setDirection(QBoxLayout::TopToBottom); |
| 109 | layout->setAlignment(Qt::AlignCenter); |
| 110 | layout->setAlignment(Qt::AlignLeft); |
| 111 | m_PositionedOverlays[pos]->layout()->setSpacing(0); |
| 112 | break; |
| 113 | } |
| 114 | case QmitkOverlay::top_Right: |
| 115 | { |
| 116 | // adding right-aligned top-to-bottom layout |
| 117 | QVBoxLayout *layout = new QVBoxLayout(m_PositionedOverlays[pos]); |
no test coverage detected