ToolWindowManager::ToolWindowManager(QWidget *parent) : QWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); ToolWindowManagerWrapper *wrapper = new ToolWindowManagerWrapper(this, false); wrapper->setWindowFlags(wrapper->windowFlags() & ~Qt::Tool); mainLayout->addWidget(wrapper); m_allowFloatingWindow = true; m_createCallback = NULL; m_lastUsedArea = NULL; m_draggedWrapper = NULL; m_hoverArea = NULL; QPalette pal = palette(); pal.setColor(QPalette::Background, pal.color(QPalette::Highlight)); m_previewOverlay = new QWidget(NULL); m_previewOverlay->setAutoFillBackground(true); m_previewOverlay->setPalette(pal); m_previewOverlay->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); m_previewOverlay->setWindowOpacity(0.3); m_previewOverlay->setAttribute(Qt::WA_ShowWithoutActivating); m_previewOverlay->setAttribute(Qt::WA_AlwaysStackOnTop); m_previewOverlay->hide(); m_previewTabOverlay = new QWidget(NULL); m_previewTabOverlay->setAutoFillBackground(true); m_previewTabOverlay->setPalette(pal); m_previewTabOverlay->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); m_previewTabOverlay->setWindowOpacity(0.3); m_previewTabOverlay->setAttribute(Qt::WA_ShowWithoutActivating); m_previewTabOverlay->setAttribute(Qt::WA_AlwaysStackOnTop); m_previewTabOverlay->hide(); for(int i = 0; i < NumReferenceTypes; i++) m_dropHotspots[i] = NULL; m_dropHotspotDimension = 32; m_dropHotspotMargin = 4; drawHotspotPixmaps(); for(AreaReferenceType type : {AddTo, TopOf, LeftOf, RightOf, BottomOf, TopWindowSide, LeftWindowSide, RightWindowSide, BottomWindowSide}) { m_dropHotspots[type] = new QLabel(NULL); m_dropHotspots[type]->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); m_dropHotspots[type]->setAttribute(Qt::WA_ShowWithoutActivating); m_dropHotspots[type]->setAttribute(Qt::WA_AlwaysStackOnTop); m_dropHotspots[type]->setPixmap(m_pixmaps[type]); m_dropHotspots[type]->setFixedSize(m_dropHotspotDimension, m_dropHotspotDimension); } }
bool ToolWindowManagerTabBar::floatingWindowChild() const { ToolWindowManagerArea *area = qobject_cast<ToolWindowManagerArea *>(parentWidget()); if(area) { ToolWindowManagerWrapper *wrapper = qobject_cast<ToolWindowManagerWrapper *>(area->parentWidget()); if(wrapper && wrapper->floating()) return true; } return false; }
ToolWindowManager::ToolWindowManager(QWidget *parent) : QWidget(parent) { m_borderSensitivity = 12; QSplitter* testSplitter = new QSplitter(); m_rubberBandLineWidth = testSplitter->handleWidth(); delete testSplitter; m_dragIndicator = new QLabel(0, Qt::ToolTip ); m_dragIndicator->setAttribute(Qt::WA_ShowWithoutActivating); QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); ToolWindowManagerWrapper* wrapper = new ToolWindowManagerWrapper(this); wrapper->setWindowFlags(wrapper->windowFlags() & ~Qt::Tool); mainLayout->addWidget(wrapper); connect(&m_dropSuggestionSwitchTimer, SIGNAL(timeout()), this, SLOT(showNextDropSuggestion())); m_dropSuggestionSwitchTimer.setInterval(1000); m_dropCurrentSuggestionIndex = 0; m_allowFloatingWindow = true; m_rectRubberBand = new QRubberBand(QRubberBand::Rectangle, this); m_lineRubberBand = new QRubberBand(QRubberBand::Line, this); }