Changeset 46332 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 30, 2013 1:43:23 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86105
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.cpp
r45223 r46332 49 49 UIGMachinePreview::UIGMachinePreview(QIGraphicsWidget *pParent) 50 50 : QIWithRetranslateUI4<QIGraphicsWidget>(pParent) 51 , m_machineState(KMachineState_Null)52 51 , m_pUpdateTimer(new QTimer(this)) 53 52 , m_pUpdateTimerMenu(0) … … 92 91 connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview())); 93 92 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), 94 this, SLOT(sltMachineStateChange(QString , KMachineState)));93 this, SLOT(sltMachineStateChange(QString))); 95 94 96 95 /* Retranslate the UI */ … … 123 122 } 124 123 125 void UIGMachinePreview::sltMachineStateChange(QString strId , KMachineState state)126 { 127 if (!m_machine.isNull() && m_machine.GetId() == strId)128 {129 /* Cache the machine state: */130 m_machineState = state; 131 restart();132 }124 void UIGMachinePreview::sltMachineStateChange(QString strId) 125 { 126 /* Make sure its the event for our machine: */ 127 if (m_machine.isNull() || m_machine.GetId() != strId) 128 return; 129 130 /* Restart the preview: */ 131 restart(); 133 132 } 134 133 … … 139 138 return; 140 139 141 /* Remove preview if any: */140 /* Cleanup preview first: */ 142 141 if (m_pPreviewImg) 143 142 { … … 146 145 } 147 146 148 /* We are not creating preview for inaccessible VMs: */ 149 if (m_machineState == KMachineState_Null) 150 return; 151 152 if (!m_machine.isNull() && m_vRect.width() > 0 && m_vRect.height() > 0) 147 /* Fetch the latest machine-state: */ 148 KMachineState machineState = m_machine.isNull() ? KMachineState_Null : m_machine.GetState(); 149 150 /* We are creating preview only for assigned and accessible VMs: */ 151 if (!m_machine.isNull() && machineState != KMachineState_Null && 152 m_vRect.width() > 0 && m_vRect.height() > 0) 153 153 { 154 154 QImage image(size().toSize(), QImage::Format_ARGB32); … … 161 161 { 162 162 /* Use the image which may be included in the save state. */ 163 if (m _machineState == KMachineState_Saved || m_machineState == KMachineState_Restoring)163 if (machineState == KMachineState_Saved || machineState == KMachineState_Restoring) 164 164 { 165 165 ULONG width = 0, height = 0; … … 168 168 { 169 169 QImage shot = QImage::fromData(screenData.data(), screenData.size(), "PNG") 170 .scaled(m_vRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);170 .scaled(m_vRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 171 171 dimImage(shot); 172 172 painter.drawImage(m_vRect.x(), m_vRect.y(), shot); … … 175 175 } 176 176 /* Use the current VM output. */ 177 else if (m _machineState == KMachineState_Running || m_machineState == KMachineState_Paused)177 else if (machineState == KMachineState_Running || machineState == KMachineState_Paused) 178 178 { 179 179 if (m_session.GetState() == KSessionState_Locked) … … 210 210 QImage shot = QImage((uchar*)d, m_vRect.width(), m_vRect.height(), QImage::Format_RGB32); 211 211 212 if (m _machineState == KMachineState_Paused)212 if (machineState == KMachineState_Paused) 213 213 dimImage(shot); 214 214 painter.drawImage(m_vRect.x(), m_vRect.y(), shot); … … 220 220 } 221 221 } 222 222 223 if (fDone) 223 224 m_pPreviewImg = new QImage(image); 224 225 } 226 227 /* Redraw preview in any case! */ 225 228 update(); 226 229 } … … 378 381 void UIGMachinePreview::restart() 379 382 { 383 /* Fetch the latest machine-state: */ 384 KMachineState machineState = m_machine.isNull() ? KMachineState_Null : m_machine.GetState(); 385 380 386 /* Reopen session if necessary: */ 381 387 if (m_session.GetState() == KSessionState_Locked) … … 383 389 if (!m_machine.isNull()) 384 390 { 385 /* Fetch the latest machine state: */386 m_machineState = m_machine.GetState();387 391 /* Lock the session for the current machine: */ 388 if (m _machineState == KMachineState_Running || m_machineState == KMachineState_Paused)392 if (machineState == KMachineState_Running || machineState == KMachineState_Paused) 389 393 m_machine.LockMachine(m_session, KLockType_Shared); 390 394 } … … 396 400 if (!m_machine.isNull()) 397 401 { 398 if (m_pUpdateTimer->interval() > 0 && m _machineState == KMachineState_Running)402 if (m_pUpdateTimer->interval() > 0 && machineState == KMachineState_Running) 399 403 m_pUpdateTimer->start(); 400 404 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h
r45223 r46332 73 73 private slots: 74 74 75 /* Handler: Global-event listener : */76 void sltMachineStateChange(QString strId , KMachineState state);75 /* Handler: Global-event listener stuff: */ 76 void sltMachineStateChange(QString strId); 77 77 78 78 /* Handler: Preview recreator: */ … … 105 105 CSession m_session; 106 106 CMachine m_machine; 107 KMachineState m_machineState;108 107 QTimer *m_pUpdateTimer; 109 108 QMenu *m_pUpdateTimerMenu;
Note:
See TracChangeset
for help on using the changeset viewer.