void UIMachineLogicSeamless::notifyAbout3DOverlayVisibilityChange(bool) { /* If active machine-window is defined now: */ if (activeMachineWindow()) { /* Reinstall corresponding popup-stack and make sure it has proper type: */ popupCenter().hidePopupStack(activeMachineWindow()); popupCenter().setPopupStackType(activeMachineWindow(), UIPopupStackType_Separate); popupCenter().showPopupStack(activeMachineWindow()); } }
/* Machine state-change handler: */ void UIMouseHandler::sltMachineStateChanged() { /* Get machine state: */ KMachineState state = uisession()->machineState(); /* Handle particular machine states: */ switch (state) { case KMachineState_Paused: case KMachineState_TeleportingPausedVM: case KMachineState_Stuck: { /* Release the mouse: */ releaseMouse(); break; } default: break; } /* Recall reminder about paused VM input * if we are not in paused VM state already: */ if (machineLogic()->activeMachineWindow() && state != KMachineState_Paused && state != KMachineState_TeleportingPausedVM) popupCenter().forgetAboutPausedVMInput(machineLogic()->activeMachineWindow()); // TODO: Is it really required? /* Notify all listeners: */ emit mouseStateChanged(mouseState()); }
UISettingsDialog::~UISettingsDialog() { /* Delete serializer if exists: */ if (serializeProcess()) { delete m_pSerializeProcess; m_pSerializeProcess = 0; } /* Recall popup-pane if any: */ popupCenter().recall(m_pStack, "SettingsDialogWarning"); /* Delete selector early! */ delete m_pSelector; }
void UIFrameBufferQImage::resizeEvent(UIResizeEvent *pEvent) { /* Invalidate visible-region if necessary: */ if (m_pMachineView->machineLogic()->visualStateType() == UIVisualStateType_Seamless && (m_width != pEvent->width() || m_height != pEvent->height())) { lock(); m_syncVisibleRegion = QRegion(); m_asyncVisibleRegion = QRegion(); unlock(); } /* Remember new width/height: */ m_width = pEvent->width(); m_height = pEvent->height(); /* Check if we support the pixel format and can use the guest VRAM directly: */ bool bRemind = false; bool bFallback = false; ulong bitsPerLine = pEvent->bytesPerLine() * 8; if (pEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB) { QImage::Format format; switch (pEvent->bitsPerPixel()) { /* 32-, 8- and 1-bpp are the only depths supported by QImage: */ case 32: format = QImage::Format_RGB32; break; case 8: format = QImage::Format_Indexed8; bRemind = true; break; case 1: format = QImage::Format_Mono; bRemind = true; break; default: format = QImage::Format_Invalid; bRemind = true; bFallback = true; break; } if (!bFallback) { /* QImage only supports 32-bit aligned scan lines... */ Assert((pEvent->bytesPerLine() & 3) == 0); bFallback = ((pEvent->bytesPerLine() & 3) != 0); } if (!bFallback) { /* ...and the scan lines ought to be a whole number of pixels. */ Assert((bitsPerLine & (pEvent->bitsPerPixel() - 1)) == 0); bFallback = ((bitsPerLine & (pEvent->bitsPerPixel() - 1)) != 0); } if (!bFallback) { /* Make sure constraints are also passed: */ Assert(bitsPerLine / pEvent->bitsPerPixel() >= m_width); bFallback = RT_BOOL(bitsPerLine / pEvent->bitsPerPixel() < m_width); } if (!bFallback) { /* Finally compose image using VRAM directly: */ m_img = QImage((uchar *)pEvent->VRAM(), m_width, m_height, bitsPerLine / 8, format); m_uPixelFormat = FramebufferPixelFormat_FOURCC_RGB; m_bUsesGuestVRAM = true; } } else bFallback = true; /* Fallback if requested: */ if (bFallback) { LogRelFlow(("UIFrameBufferQImage::resizeEvent: " "Going fallback due to frame-buffer format become invalid: " "Format=%lu, BitsPerPixel=%lu, BytesPerLine=%lu, Size=%lux%lu\n", (unsigned long)pEvent->pixelFormat(), (unsigned long)pEvent->bitsPerPixel(), (unsigned long)pEvent->bytesPerLine(), (unsigned long)pEvent->width(), (unsigned long)pEvent->height())); goFallback(); } /* Remind if requested: */ if (bRemind) popupCenter().remindAboutWrongColorDepth(m_pMachineView->machineWindow(), pEvent->bitsPerPixel(), 32); else popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow()); }
void UIFrameBufferQuartz2D::resizeEvent(UIResizeEvent *aEvent) { #if 0 printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n", aEvent->pixelFormat(), (unsigned int)aEvent->VRAM(), aEvent->bitsPerPixel(), aEvent->bytesPerLine(), aEvent->width(), aEvent->height()); #endif /* Clean out old stuff */ clean(m_width == aEvent->width() && m_height == aEvent->height()); m_width = aEvent->width(); m_height = aEvent->height(); bool remind = false; /* We need a color space in any case */ CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB(); /* Check if we support the pixel format/colordepth and can use the guest VRAM directly. * Mac OS X supports 16 bit also but not in the 565 mode. So we could use * 32 bit only. */ if ( aEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB && aEvent->bitsPerPixel() == 32) { m_fUsesGuestVRAM = true; // printf ("VRAM\n"); /* Create the image copy of the framebuffer */ CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bytesPerLine() * m_height, NULL); m_image = CGImageCreate(m_width, m_height, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, kCGRenderingIntentDefault); m_pDataAddress = aEvent->VRAM(); CGDataProviderRelease (dp); } else { m_fUsesGuestVRAM = false; remind = true; // printf ("No VRAM\n"); /* Create the memory we need for our image copy * Read somewhere that an alignment of 16 is * best for optimal performance. So why not. */ // int bitmapBytesPerRow = RT_ALIGN (m_width * 4, 16); int bitmapBytesPerRow = m_width * 4; int bitmapByteCount = (bitmapBytesPerRow * m_height); m_pBitmapData = RTMemAllocZ(bitmapByteCount); CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, m_pBitmapData, bitmapByteCount, NULL); m_image = CGImageCreate(m_width, m_height, 8, 32, bitmapBytesPerRow, cs, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false, kCGRenderingIntentDefault); m_pDataAddress = static_cast<uchar*>(m_pBitmapData); CGDataProviderRelease(dp); } CGColorSpaceRelease(cs); #ifdef VBOX_WITH_ICHAT_THEATER setImageRef(m_image); #endif if (remind && m_pMachineView->uisession()->isGuestAdditionsActive()) popupCenter().remindAboutWrongColorDepth(m_pMachineView->machineWindow(), aEvent->bitsPerPixel(), 32); else popupCenter().forgetAboutWrongColorDepth(m_pMachineView->machineWindow()); }
/* Settings Dialog Constructor: */ UISettingsDialog::UISettingsDialog(QWidget *pParent) /* Parent class: */ : QIWithRetranslateUI<QIMainDialog>(pParent) /* Protected variables: */ , m_pSelector(0) , m_pStack(0) /* Common variables: */ , m_configurationAccessLevel(ConfigurationAccessLevel_Null) , m_fPolished(false) /* Serialization stuff: */ , m_pSerializeProcess(0) , m_fSerializationIsInProgress(false) /* Status-bar stuff: */ , m_pStatusBar(0) /* Process-bar stuff: */ , m_pProcessBar(0) /* Warning-pane stuff: */ , m_pWarningPane(0) , m_fValid(true) , m_fSilent(true) /* Whats-this stuff: */ , m_pWhatsThisTimer(new QTimer(this)) , m_pWhatsThisCandidate(0) { /* Apply UI decorations: */ Ui::UISettingsDialog::setupUi(this); /* Page-title font is derived from the system font: */ QFont pageTitleFont = font(); pageTitleFont.setBold(true); pageTitleFont.setPointSize(pageTitleFont.pointSize() + 2); m_pLbTitle->setFont(pageTitleFont); /* Prepare selector: */ QGridLayout *pMainLayout = static_cast<QGridLayout*>(centralWidget()->layout()); #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS /* No page-title with tool-bar: */ m_pLbTitle->hide(); /* Create modern tool-bar selector: */ m_pSelector = new UISettingsSelectorToolBar(this); static_cast<UIToolBar*>(m_pSelector->widget())->enableMacToolbar(); addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget())); /* No title in this mode, we change the title of the window: */ pMainLayout->setColumnMinimumWidth(0, 0); pMainLayout->setHorizontalSpacing(0); #else /* Create classical tree-view selector: */ m_pSelector = new UISettingsSelectorTreeView(this); pMainLayout->addWidget(m_pSelector->widget(), 0, 0, 2, 1); m_pSelector->widget()->setFocus(); pMainLayout->setSpacing(10); #endif /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */ connect(m_pSelector, SIGNAL(sigCategoryChanged(int)), this, SLOT(sltCategoryChanged(int))); /* Prepare page-stack: */ m_pStack = new QStackedWidget(m_pWtStackHandler); popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); QVBoxLayout *pStackLayout = new QVBoxLayout(m_pWtStackHandler); pStackLayout->setContentsMargins(0, 0, 0, 0); pStackLayout->addWidget(m_pStack); /* Prepare button-box: */ m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); /* Prepare process-bar: */ m_pProcessBar = new QProgressBar; m_pProcessBar->setMaximum(100); m_pProcessBar->setMinimum(0); /* Prepare warning-pane: */ m_pWarningPane = new UIWarningPane; connect(m_pWarningPane, SIGNAL(sigHoverEnter(UIPageValidator*)), this, SLOT(sltHandleWarningPaneHovered(UIPageValidator*))); connect(m_pWarningPane, SIGNAL(sigHoverLeave(UIPageValidator*)), this, SLOT(sltHandleWarningPaneUnhovered(UIPageValidator*))); /* Prepare status-bar: */ m_pStatusBar = new QStackedWidget; /* Add empty widget: */ m_pStatusBar->addWidget(new QWidget); /* Add process-bar widget: */ m_pStatusBar->addWidget(m_pProcessBar); /* Add warning-pane: */ m_pStatusBar->addWidget(m_pWarningPane); /* Add status-bar to button-box: */ m_pButtonBox->addExtraWidget(m_pStatusBar); /* Setup whatsthis stuff: */ qApp->installEventFilter(this); m_pWhatsThisTimer->setSingleShot(true); connect(m_pWhatsThisTimer, SIGNAL(timeout()), this, SLOT(sltUpdateWhatsThis())); /* Translate UI: */ retranslateUi(); }