Changeset 82931 in vbox for trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.cpp
- Timestamp:
- Jan 30, 2020 2:48:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.cpp
r82879 r82931 17 17 18 18 /* Qt includes: */ 19 #include <QApplication>20 19 #include <QFileInfo> 21 20 #include <QIcon> … … 61 60 } 62 61 63 QString UIVirtualMachineItem::machineStateName() const64 {65 return m_fAccessible66 ? gpConverter->toString(m_enmMachineState)67 : QApplication::translate("UIVMListView", "Inaccessible");68 }69 70 QString UIVirtualMachineItem::sessionStateName() const71 {72 return m_fAccessible73 ? gpConverter->toString(m_enmSessionState)74 : QApplication::translate("UIVMListView", "Inaccessible");75 }76 77 QIcon UIVirtualMachineItem::machineStateIcon() const78 {79 return m_fAccessible80 ? gpConverter->toIcon(m_enmMachineState)81 : gpConverter->toIcon(KMachineState_Aborted);82 }83 84 QString UIVirtualMachineItem::toolTipText() const85 {86 QString strToolTip;87 88 const QString strDateTime = (m_lastStateChange.date() == QDate::currentDate())89 ? m_lastStateChange.time().toString(Qt::LocalDate)90 : m_lastStateChange.toString(Qt::LocalDate);91 92 if (m_fAccessible)93 {94 strToolTip = QString("<b>%1</b>").arg(m_strName);95 if (!m_strSnapshotName.isNull())96 strToolTip += QString(" (%1)").arg(m_strSnapshotName);97 strToolTip = QApplication::translate("UIVMListView",98 "<nobr>%1<br></nobr>"99 "<nobr>%2 since %3</nobr><br>"100 "<nobr>Session %4</nobr>",101 "VM tooltip (name, last state change, session state)")102 .arg(strToolTip)103 .arg(gpConverter->toString(m_enmMachineState))104 .arg(strDateTime)105 .arg(gpConverter->toString(m_enmSessionState).toLower());106 }107 else108 {109 strToolTip = QApplication::translate("UIVMListView",110 "<nobr><b>%1</b><br></nobr>"111 "<nobr>Inaccessible since %2</nobr>",112 "Inaccessible VM tooltip (name, last state change)")113 .arg(m_strSettingsFile)114 .arg(strDateTime);115 }116 117 return strToolTip;118 }119 120 62 void UIVirtualMachineItem::recache() 121 63 { … … 144 86 /* Determine VM states: */ 145 87 m_enmMachineState = m_comMachine.GetState(); 88 m_strMachineStateName = gpConverter->toString(m_enmMachineState); 89 m_machineStateIcon = gpConverter->toIcon(m_enmMachineState); 146 90 m_enmSessionState = m_comMachine.GetSessionState(); 91 m_strSessionStateName = gpConverter->toString(m_enmSessionState); 147 92 148 93 /* Determine configuration access level: */ … … 191 136 /* Reset VM states: */ 192 137 m_enmMachineState = KMachineState_Null; 138 m_machineStateIcon = gpConverter->toIcon(KMachineState_Aborted); 193 139 m_enmSessionState = KSessionState_Null; 194 140 … … 205 151 /* Recache item pixmap: */ 206 152 recachePixmap(); 153 154 /* Retranslate finally: */ 155 retranslateUi(); 207 156 } 208 157 … … 228 177 bool UIVirtualMachineItem::canSwitchTo() const 229 178 { 230 return const_cast <CMachine 179 return const_cast <CMachine&>(m_comMachine).CanShowConsoleWindow(); 231 180 } 232 181 … … 354 303 } 355 304 305 void UIVirtualMachineItem::retranslateUi() 306 { 307 /* This is used in tool-tip generation: */ 308 const QString strDateTime = (m_lastStateChange.date() == QDate::currentDate()) 309 ? m_lastStateChange.time().toString(Qt::LocalDate) 310 : m_lastStateChange.toString(Qt::LocalDate); 311 312 /* If machine is accessible: */ 313 if (m_fAccessible) 314 { 315 /* Update tool-tip: */ 316 m_strToolTipText = QString("<b>%1</b>").arg(m_strName); 317 if (!m_strSnapshotName.isNull()) 318 m_strToolTipText += QString(" (%1)").arg(m_strSnapshotName); 319 m_strToolTipText = tr("<nobr>%1<br></nobr>" 320 "<nobr>%2 since %3</nobr><br>" 321 "<nobr>Session %4</nobr>", 322 "VM tooltip (name, last state change, session state)") 323 .arg(m_strToolTipText) 324 .arg(gpConverter->toString(m_enmMachineState)) 325 .arg(strDateTime) 326 .arg(gpConverter->toString(m_enmSessionState).toLower()); 327 } 328 /* Otherwise: */ 329 else 330 { 331 /* Update tool-tip: */ 332 m_strToolTipText = tr("<nobr><b>%1</b><br></nobr>" 333 "<nobr>Inaccessible since %2</nobr>", 334 "Inaccessible VM tooltip (name, last state change)") 335 .arg(m_strSettingsFile) 336 .arg(strDateTime); 337 338 /* We have our own translation for Null states: */ 339 m_strMachineStateName = tr("Inaccessible"); 340 m_strSessionStateName = tr("Inaccessible"); 341 } 342 } 343 356 344 357 345 /*********************************************************************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.