Changeset 28572 in vbox
- Timestamp:
- Apr 21, 2010 7:37:32 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
r28020 r28572 22 22 */ 23 23 24 /* Global includes */ 25 #include <iprt/time.h> 26 #include <QTimer> 27 24 28 /* Local includes */ 25 29 #include "UIIndicatorsPool.h" … … 233 237 : QIWithRetranslateUI<QIStateIndicator>() 234 238 , m_session(session) 239 , m_pUpdateTimer(new QTimer(this)) 235 240 { 236 241 setStateIcon(KDeviceActivity_Idle, QPixmap(":/nw_16px.png")); … … 239 244 setStateIcon(KDeviceActivity_Null, QPixmap(":/nw_disabled_16px.png")); 240 245 241 retranslateUi(); 242 } 243 244 void retranslateUi() 245 { 246 updateAppearance(); 247 } 248 249 void updateAppearance() 250 { 251 const CMachine &machine = m_session.GetMachine(); 246 connect(m_pUpdateTimer, SIGNAL(timeout()), SLOT(sltUpdateNetworkIPs())); 247 m_pUpdateTimer->start(5000); 248 249 retranslateUi(); 250 } 251 252 void retranslateUi() 253 { 254 updateAppearance(); 255 } 256 257 void updateAppearance() 258 { 259 CMachine machine = m_session.GetMachine(); 252 260 253 261 ulong uMaxCount = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); … … 266 274 CNetworkAdapter adapter = machine.GetNetworkAdapter(uSlot); 267 275 if (adapter.GetEnabled()) 268 strFullData += QApplication::translate("VBoxConsoleWnd", "<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", "Network adapters tooltip") 276 { 277 QString strIP; 278 ULONG64 timestamp; 279 RTTIMESPEC time; 280 uint64_t u64Now = RTTimeSpecGetNano(RTTimeNow(&time)); 281 QString strFlags; 282 machine.GetGuestProperty(QString("/VirtualBox/GuestInfo/Net/%1/V4/IP").arg(uSlot), 283 strIP, timestamp, strFlags); 284 strFullData += QApplication::translate("VBoxConsoleWnd", "<br><nobr><b>Adapter %1 (%2)</b>: %3 cable %4</nobr>", "Network adapters tooltip") 269 285 .arg(uSlot + 1) 270 286 .arg(vboxGlobal().toString(adapter.GetAttachmentType())) 287 .arg(strIP.isEmpty() || (u64Now - timestamp > UINT64_C(20000000000)) ? "" : "IP=" + strIP + " - ") 271 288 .arg(adapter.GetCableConnected() ? 272 289 QApplication::translate("VBoxConsoleWnd", "connected", "Network adapters tooltip") : 273 290 QApplication::translate("VBoxConsoleWnd", "disconnected", "Network adapters tooltip")); 291 } 274 292 } 275 293 … … 279 297 setToolTip(strToolTip.arg(strFullData)); 280 298 } 281 282 protected: 283 /* For compatibility reason we do it here, later this should be moved to 284 * QIStateIndicator. */ 285 CSession &m_session; 299 protected slots: 300 301 void sltUpdateNetworkIPs() 302 { 303 updateAppearance(); 304 } 305 306 protected: 307 /* For compatibility reason we do it here, later this should be moved to 308 * QIStateIndicator. */ 309 CSession &m_session; 310 QTimer *m_pUpdateTimer; 286 311 }; 287 312
Note:
See TracChangeset
for help on using the changeset viewer.