void UIVMPreviewWindow::restart() { /* Reopen session if necessary: */ if (m_session.GetState() == KSessionState_Locked) m_session.UnlockMachine(); if (!m_machine.isNull()) { /* Fetch the latest machine state: */ m_machineState = m_machine.GetState(); /* Lock the session for the current machine: */ if (m_machineState == KMachineState_Running // || m_machineState == KMachineState_Saving /* Not sure if this is valid */ || m_machineState == KMachineState_Paused) m_machine.LockMachine(m_session, KLockType_Shared); } /* Recreate the preview image: */ sltRecreatePreview(); /* Start the timer if necessary: */ if (!m_machine.isNull()) { if (m_pUpdateTimer->interval() > 0 && m_machineState == KMachineState_Running) m_pUpdateTimer->start(); } }
UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) , m_machineState(KMachineState_Null) , m_pUpdateTimer(new QTimer(this)) , m_vMargin(10) , m_pbgImage(0) , m_pPreviewImg(0) , m_pGlossyImg(0) { m_session.createInstance(CLSID_Session); setContentsMargins(0, 5, 0, 5); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* Connect the update timer */ connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview())); /* Connect the machine state event */ connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString, KMachineState))); /* Create the context menu */ setContextMenuPolicy(Qt::DefaultContextMenu); m_pUpdateTimerMenu = new QMenu(this); QActionGroup *pUpdateTimeG = new QActionGroup(this); pUpdateTimeG->setExclusive(true); for(int i = 0; i < UpdateEnd; ++i) { QAction *pUpdateTime = new QAction(pUpdateTimeG); pUpdateTime->setData(i); pUpdateTime->setCheckable(true); pUpdateTimeG->addAction(pUpdateTime); m_pUpdateTimerMenu->addAction(pUpdateTime); m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime; } m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(Update500ms)]); /* Default value */ UpdateInterval interval = Update1000ms; QString strInterval = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PreviewUpdate); if (strInterval == "disabled") interval = UpdateDisabled; else if (strInterval == "500") interval = Update500ms; else if (strInterval == "1000") interval = Update1000ms; else if (strInterval == "2000") interval = Update2000ms; else if (strInterval == "5000") interval = Update5000ms; else if (strInterval == "10000") interval = Update10000ms; /* Initialize with the new update interval */ setUpdateInterval(interval, false); /* Retranslate the UI */ retranslateUi(); }
/* Constructor: */ UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent) : QIWithRetranslateUI<QWidget>(pParent) , m_machineState(KMachineState_Null) , m_pUpdateTimer(new QTimer(this)) , m_vMargin(10) , m_pbgImage(0) , m_pPreviewImg(0) , m_pGlossyImg(0) { /* Setup contents: */ setContentsMargins(0, 5, 0, 5); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); /* Create session instance: */ m_session.createInstance(CLSID_Session); /* Create the context menu: */ setContextMenuPolicy(Qt::DefaultContextMenu); m_pUpdateTimerMenu = new QMenu(this); QActionGroup *pUpdateTimeG = new QActionGroup(this); pUpdateTimeG->setExclusive(true); for(int i = 0; i < UpdateInterval_Max; ++i) { QAction *pUpdateTime = new QAction(pUpdateTimeG); pUpdateTime->setData(i); pUpdateTime->setCheckable(true); pUpdateTimeG->addAction(pUpdateTime); m_pUpdateTimerMenu->addAction(pUpdateTime); m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime; } m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(UpdateInterval_500ms)]); /* Load preview update interval: */ QString strInterval = vboxGlobal().virtualBox().GetExtraData(GUI_PreviewUpdate); /* Parse loaded value: */ UpdateInterval interval = m_intervals.key(strInterval, UpdateInterval_1000ms); /* Initialize with the new update interval: */ setUpdateInterval(interval, false); /* Setup connections: */ connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview())); connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString, KMachineState))); /* Retranslate the UI */ retranslateUi(); }
void UIVMPreviewWindow::resizeEvent(QResizeEvent *pEvent) { repaintBGImages(); sltRecreatePreview(); QWidget::resizeEvent(pEvent); }
void UIGMachinePreview::resizeEvent(QGraphicsSceneResizeEvent *pEvent) { repaintBGImages(); sltRecreatePreview(); QIGraphicsWidget::resizeEvent(pEvent); }