void UIMachineWindowNormal::loadSettings() { /* Call to base-class: */ UIMachineWindow::loadSettings(); /* Get machine: */ CMachine m = machine(); /* Load extra-data settings: */ { /* Load window position settings: */ QString strPositionAddress = m_uScreenId == 0 ? QString("%1").arg(GUI_LastNormalWindowPosition) : QString("%1%2").arg(GUI_LastNormalWindowPosition).arg(m_uScreenId); QStringList strPositionSettings = m.GetExtraDataStringList(strPositionAddress); bool ok = !strPositionSettings.isEmpty(), max = false; int x = 0, y = 0, w = 0, h = 0; if (ok && strPositionSettings.size() > 0) x = strPositionSettings[0].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 1) y = strPositionSettings[1].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 2) w = strPositionSettings[2].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 3) h = strPositionSettings[3].toInt(&ok); else ok = false; if (ok && strPositionSettings.size() > 4) max = strPositionSettings[4] == GUI_LastWindowState_Max; QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) : QApplication::desktop()->availableGeometry(this); /* If previous parameters were read correctly: */ if (ok) { /* If previous machine state is SAVED: */ if (m.GetState() == KMachineState_Saved) { /* Restore window size and position: */ m_normalGeometry = QRect(x, y, w, h); setGeometry(m_normalGeometry); } /* If previous machine state was not SAVED: */ else { /* Restore only window position: */ m_normalGeometry = QRect(x, y, width(), height()); setGeometry(m_normalGeometry); if (machineView()) machineView()->normalizeGeometry(false); } /* Maximize if needed: */ if (max) setWindowState(windowState() | Qt::WindowMaximized); } else { /* Normalize view early to the optimal size: */ if (machineView()) machineView()->normalizeGeometry(true); /* Move newly created window to the screen center: */ m_normalGeometry = geometry(); m_normalGeometry.moveCenter(ar.center()); setGeometry(m_normalGeometry); } /* Normalize view to the optimal size: */ if (machineView()) #ifdef Q_WS_X11 QTimer::singleShot(0, machineView(), SLOT(sltNormalizeGeometry())); #else /* Q_WS_X11 */ machineView()->normalizeGeometry(true); #endif } /* Load availability settings: */ { /* USB Stuff: */ const CUSBController &usbController = m.GetUSBController(); if ( usbController.isNull() || !usbController.GetEnabled() || !usbController.GetProxyAvailable()) { /* Hide USB menu: */ indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setHidden(true); } else { /* Toggle USB LED: */ indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setState( usbController.GetEnabled() ? KDeviceActivity_Idle : KDeviceActivity_Null); } } /* Load global settings: */ { VBoxGlobalSettings settings = vboxGlobal().settings(); menuBar()->setHidden(settings.isFeatureActive("noMenuBar")); statusBar()->setHidden(settings.isFeatureActive("noStatusBar")); if (statusBar()->isHidden()) m_pIdleTimer->stop(); } }
void UIMachineWindowNormal::loadSettings() { /* Call to base-class: */ UIMachineWindow::loadSettings(); /* Load GUI customizations: */ { #ifndef VBOX_WS_MAC /* Update menu-bar visibility: */ menuBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->isChecked()); #endif /* !VBOX_WS_MAC */ /* Update status-bar visibility: */ statusBar()->setVisible(actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->isChecked()); m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning()); } /* Load window geometry: */ { /* Load extra-data: */ QRect geo = gEDataManager->machineWindowGeometry(machineLogic()->visualStateType(), m_uScreenId, vboxGlobal().managedVMUuid()); /* If we do have proper geometry: */ if (!geo.isNull()) { /* If previous machine-state was SAVED: */ if (machine().GetState() == KMachineState_Saved) { /* Restore window geometry: */ m_normalGeometry = geo; VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); } /* If previous machine-state was NOT SAVED: */ else { /* Restore only window position: */ m_normalGeometry = QRect(geo.x(), geo.y(), width(), height()); VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); /* And normalize to the optimal-size: */ normalizeGeometry(false /* adjust position */); } /* Maximize (if necessary): */ if (gEDataManager->machineWindowShouldBeMaximized(machineLogic()->visualStateType(), m_uScreenId, vboxGlobal().managedVMUuid())) setWindowState(windowState() | Qt::WindowMaximized); } /* If we do NOT have proper geometry: */ else { /* Get available geometry, for screen with (x,y) coords if possible: */ QRect availableGeo = !geo.isNull() ? gpDesktop->availableGeometry(QPoint(geo.x(), geo.y())) : gpDesktop->availableGeometry(this); /* Normalize to the optimal size: */ normalizeGeometry(true /* adjust position */); /* Move newly created window to the screen-center: */ m_normalGeometry = geometry(); m_normalGeometry.moveCenter(availableGeo.center()); VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); } /* Normalize to the optimal size: */ #ifdef VBOX_WS_X11 QTimer::singleShot(0, this, SLOT(sltNormalizeGeometry())); #else /* !VBOX_WS_X11 */ normalizeGeometry(true /* adjust position */); #endif /* !VBOX_WS_X11 */ } }