Changeset 82931 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 30, 2020 2:48:06 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 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 /********************************************************************************************************************************* -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.h
r82878 r82931 24 24 /* Qt includes: */ 25 25 #include <QDateTime> 26 #include <QIcon> 26 27 #include <QMimeData> 27 28 #include <QPixmap> 28 29 29 30 /* GUI includes: */ 31 #include "QIWithRetranslateUI.h" 30 32 #include "UISettingsDefs.h" 31 33 … … 38 40 using namespace UISettingsDefs; 39 41 40 /** Virtual Machine item interface. 41 * A wrapper caching data about local VM. */ 42 class UIVirtualMachineItem 42 /** Virtual Machine item interface. A wrapper caching VM data. */ 43 class UIVirtualMachineItem : public QIWithRetranslateUI3<QObject> 43 44 { 45 Q_OBJECT; 46 44 47 public: 45 48 … … 55 58 /** @} */ 56 59 60 /** @name VM access attributes. 61 * @{ */ 62 /** Returns whether VM was accessible. */ 63 bool accessible() const { return m_fAccessible; } 64 /** Returns the last cached access error. */ 65 const CVirtualBoxErrorInfo &accessError() const { return m_comAccessError; } 66 /** @} */ 67 57 68 /** @name Basic attributes. 58 69 * @{ */ … … 61 72 /** Returns cached machine settings file name. */ 62 73 QString settingsFile() const { return m_strSettingsFile; } 63 /** @} */64 65 /** @name VM access attributes.66 * @{ */67 /** Returns whether VM was accessible. */68 bool accessible() const { return m_fAccessible; }69 /** Returns the last cached access error. */70 const CVirtualBoxErrorInfo &accessError() const { return m_comAccessError; }71 /** @} */72 73 /** @name Advanced attributes.74 * @{ */75 74 /** Returns cached machine name. */ 76 75 QString name() const { return m_strName; } … … 96 95 /** Returns cached machine state. */ 97 96 KMachineState machineState() const { return m_enmMachineState; } 97 /** Returns cached machine state name. */ 98 QString machineStateName() const { return m_strMachineStateName; } 99 /** Returns cached machine state icon. */ 100 QIcon machineStateIcon() const { return m_machineStateIcon; } 101 98 102 /** Returns cached session state. */ 99 103 KSessionState sessionState() const { return m_enmSessionState; } 100 /** Returns cached machine state name. */101 QString machineStateName() const;102 104 /** Returns cached session state name. */ 103 QString sessionStateName() const; 104 /** Returns cached machine state icon. */ 105 QIcon machineStateIcon() const; 105 QString sessionStateName() const { return m_strSessionStateName; } 106 106 107 /** Returns cached configuration access level. */ 107 108 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; } … … 111 112 * @{ */ 112 113 /** Returns cached machine tool-tip. */ 113 QString toolTipText() const ;114 QString toolTipText() const { return m_strToolTipText; } 114 115 /** @} */ 115 116 … … 157 158 /** @} */ 158 159 160 protected: 161 162 /** @name Event handling. 163 * @{ */ 164 /** Handles translation event. */ 165 virtual void retranslateUi() /* override */; 166 /** @} */ 167 159 168 private: 160 169 … … 163 172 /** Holds cached machine object reference. */ 164 173 CMachine m_comMachine; 165 /** @} */166 167 /** @name Basic attributes.168 * @{ */169 /** Holds cached machine id. */170 QUuid m_uId;171 /** Holds cached machine settings file name. */172 QString m_strSettingsFile;173 174 /** @} */ 174 175 … … 181 182 /** @} */ 182 183 183 /** @name Advanced attributes. 184 * @{ */ 184 /** @name Basic attributes. 185 * @{ */ 186 /** Holds cached machine id. */ 187 QUuid m_uId; 188 /** Holds cached machine settings file name. */ 189 QString m_strSettingsFile; 185 190 /** Holds cached machine name. */ 186 191 QString m_strName; … … 209 214 /** Holds cached machine state. */ 210 215 KMachineState m_enmMachineState; 216 /** Holds cached machine state name. */ 217 QString m_strMachineStateName; 218 /** Holds cached machine state name. */ 219 QIcon m_machineStateIcon; 220 211 221 /** Holds cached session state. */ 212 222 KSessionState m_enmSessionState; 223 /** Holds cached session state name. */ 224 QString m_strSessionStateName; 225 213 226 /** Holds configuration access level. */ 214 227 ConfigurationAccessLevel m_enmConfigurationAccessLevel; 228 /** @} */ 229 230 /** @name Visual attributes. 231 * @{ */ 232 /** Holds cached machine tool-tip. */ 233 QString m_strToolTipText; 215 234 /** @} */ 216 235
Note:
See TracChangeset
for help on using the changeset viewer.