Changeset 93697 in vbox for trunk/src/VBox
- Timestamp:
- Feb 11, 2022 3:48:03 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r93696 r93697 53 53 54 54 /********************************************************************************************************************************* 55 * UIGuestSession CreateWidget definition. *55 * UIGuestSessionWidget definition. * 56 56 *********************************************************************************************************************************/ 57 57 /** A QWidget extension containing text entry fields for password and username and buttons to 58 58 * start/stop a guest session. */ 59 class UIGuestSession CreateWidget : public QIWithRetranslateUI<QWidget>59 class UIGuestSessionWidget : public QIWithRetranslateUI<QWidget> 60 60 { 61 61 Q_OBJECT; … … 63 63 signals: 64 64 65 void sig CreateSession(QString strUserName, QString strPassword);65 void sigOpenSession(QString strUserName, QString strPassword); 66 66 void sigCloseSession(); 67 67 68 68 public: 69 69 70 UIGuestSession CreateWidget(QWidget *pParent = 0);71 /** Disables certain widget after a guest session has been created. */72 void switchSession CreateMode();73 /** Makes sure certain widgets are enabled so that a guest session can be created. */70 UIGuestSessionWidget(QWidget *pParent = 0); 71 /** Disables certain widget after a guest session has been opened. */ 72 void switchSessionOpenMode(); 73 /** Makes sure certain widgets are enabled so that a guest session can be opened. */ 74 74 void switchSessionCloseMode(); 75 75 void markForError(bool fMarkForError); … … 92 92 enum ButtonMode 93 93 { 94 ButtonMode_ Create,94 ButtonMode_Open, 95 95 ButtonMode_Close 96 96 }; … … 112 112 113 113 /********************************************************************************************************************************* 114 * UIGuestSession CreateWidget implementation. *114 * UIGuestSessionWidget implementation. * 115 115 *********************************************************************************************************************************/ 116 116 117 UIGuestSession CreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */)117 UIGuestSessionWidget::UIGuestSessionWidget(QWidget *pParent /* = 0 */) 118 118 : QIWithRetranslateUI<QWidget>(pParent) 119 , m_enmButtonMode(ButtonMode_ Create)119 , m_enmButtonMode(ButtonMode_Open) 120 120 , m_pUserNameEdit(0) 121 121 , m_pPasswordEdit(0) … … 128 128 } 129 129 130 void UIGuestSession CreateWidget::prepareWidgets()130 void UIGuestSessionWidget::prepareWidgets() 131 131 { 132 132 m_pMainLayout = new QHBoxLayout(this); … … 146 146 0.5 * m_defaultBaseColor.blue()); 147 147 connect(m_pUserNameEdit, &QILineEdit::textChanged, 148 this, &UIGuestSession CreateWidget::sltHandleTextChanged);148 this, &UIGuestSessionWidget::sltHandleTextChanged); 149 149 } 150 150 … … 156 156 m_pPasswordEdit->setEchoMode(QLineEdit::Password); 157 157 connect(m_pPasswordEdit, &UIPasswordLineEdit::textChanged, 158 this, &UIGuestSession CreateWidget::sltHandleTextChanged);158 this, &UIGuestSessionWidget::sltHandleTextChanged); 159 159 } 160 160 … … 163 163 { 164 164 m_pMainLayout->addWidget(m_pButton); 165 connect(m_pButton, &QPushButton::clicked, this, &UIGuestSession CreateWidget::sltButtonClick);165 connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionWidget::sltButtonClick); 166 166 } 167 167 m_pStatusIconLabel = new QLabel(this); … … 173 173 174 174 m_pMainLayout->insertStretch(-1, 1); 175 switchSession CreateMode();175 switchSessionOpenMode(); 176 176 retranslateUi(); 177 177 } 178 178 179 void UIGuestSession CreateWidget::sltButtonClick()180 { 181 if (m_enmButtonMode == ButtonMode_ Create&& m_pUserNameEdit && m_pPasswordEdit)182 emit sig CreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());179 void UIGuestSessionWidget::sltButtonClick() 180 { 181 if (m_enmButtonMode == ButtonMode_Open && m_pUserNameEdit && m_pPasswordEdit) 182 emit sigOpenSession(m_pUserNameEdit->text(), m_pPasswordEdit->text()); 183 183 else if (m_enmButtonMode == ButtonMode_Close) 184 184 emit sigCloseSession(); 185 185 } 186 186 187 void UIGuestSession CreateWidget::sltHandleTextChanged(const QString &strText)187 void UIGuestSessionWidget::sltHandleTextChanged(const QString &strText) 188 188 { 189 189 Q_UNUSED(strText); … … 191 191 } 192 192 193 void UIGuestSession CreateWidget::retranslateUi()193 void UIGuestSessionWidget::retranslateUi() 194 194 { 195 195 if (m_pUserNameEdit) … … 207 207 if (m_pButton) 208 208 { 209 if (m_enmButtonMode == ButtonMode_ Create)209 if (m_enmButtonMode == ButtonMode_Open) 210 210 { 211 m_pButton->setText(QApplication::translate("UIFileManager", " CreateSession"));212 m_pButton->setToolTip(QApplication::translate("UIFileManager", " CreateSession"));211 m_pButton->setText(QApplication::translate("UIFileManager", "Open Session")); 212 m_pButton->setToolTip(QApplication::translate("UIFileManager", "Open Session")); 213 213 } 214 214 else … … 220 220 } 221 221 222 void UIGuestSession CreateWidget::keyPressEvent(QKeyEvent * pEvent)223 { 224 /* Emit sig CreateSession upon enter press: */222 void UIGuestSessionWidget::keyPressEvent(QKeyEvent * pEvent) 223 { 224 /* Emit sigOpenSession upon enter press: */ 225 225 if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return) 226 226 { 227 227 if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) || 228 228 (m_pPasswordEdit && m_pPasswordEdit->hasFocus())) 229 sig CreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());229 sigOpenSession(m_pUserNameEdit->text(), m_pPasswordEdit->text()); 230 230 } 231 231 QWidget::keyPressEvent(pEvent); 232 232 } 233 233 234 void UIGuestSession CreateWidget::showEvent(QShowEvent *pEvent)234 void UIGuestSessionWidget::showEvent(QShowEvent *pEvent) 235 235 { 236 236 QIWithRetranslateUI<QWidget>::showEvent(pEvent); … … 239 239 } 240 240 241 void UIGuestSession CreateWidget::switchSessionCreateMode()241 void UIGuestSessionWidget::switchSessionOpenMode() 242 242 { 243 243 if (m_pUserNameEdit) … … 245 245 if (m_pPasswordEdit) 246 246 m_pPasswordEdit->setEnabled(true); 247 m_enmButtonMode = ButtonMode_ Create;247 m_enmButtonMode = ButtonMode_Open; 248 248 retranslateUi(); 249 249 } 250 250 251 void UIGuestSession CreateWidget::switchSessionCloseMode()251 void UIGuestSessionWidget::switchSessionCloseMode() 252 252 { 253 253 if (m_pUserNameEdit) … … 259 259 } 260 260 261 void UIGuestSession CreateWidget::markForError(bool fMarkForError)261 void UIGuestSessionWidget::markForError(bool fMarkForError) 262 262 { 263 263 if (m_fMarkedForError == fMarkForError) … … 285 285 } 286 286 287 void UIGuestSession CreateWidget::setStatusLabelIconAndToolTip(const QIcon &icon, const QString &strToolTip)287 void UIGuestSessionWidget::setStatusLabelIconAndToolTip(const QIcon &icon, const QString &strToolTip) 288 288 { 289 289 if (!m_pStatusIconLabel) … … 294 294 } 295 295 296 void UIGuestSession CreateWidget::setLoginWidgetsEnabled(bool fEnabled)296 void UIGuestSessionWidget::setLoginWidgetsEnabled(bool fEnabled) 297 297 { 298 298 if (m_pUserNameEdit) … … 462 462 { 463 463 case State_InvalidMachineReference: 464 strWarningText = UIFileManager::tr(" Machine reference is invalid.");464 strWarningText = UIFileManager::tr("<p>Machine reference is invalid.</p>"); 465 465 icon = UIIconPool::iconSet(":/status_error_16px.png"); 466 466 break; 467 467 case State_MachineNotRunning: 468 strWarningText = UIFileManager::tr(" File manager cannot work since the selected guest is not currently running.");468 strWarningText = UIFileManager::tr("<p>File manager cannot work since the selected guest is not currently running.</p>"); 469 469 icon = UIIconPool::iconSet(":/status_error_16px.png"); 470 470 break; 471 471 case State_NoGuestAdditions: 472 strWarningText = UIFileManager::tr(" File manager cannot work since the selected guest does not have the guest additions.");472 strWarningText = UIFileManager::tr("<p>File manager cannot work since the selected guest does not have the guest additions.</p>"); 473 473 icon = UIIconPool::iconSet(":/status_error_16px.png"); 474 474 break; 475 475 case State_SessionPossible: 476 strWarningText = UIFileManager::tr(" Enter a valid user name and password to initiate the file manager.");476 strWarningText = UIFileManager::tr("<p>Enter a valid user name and password to initiate the file manager.</p>"); 477 477 icon = UIIconPool::iconSet(":/session_info_16px.png"); 478 478 break; 479 479 case State_SessionRunning: 480 strWarningText = UIFileManager::tr(" Guest control session is running.");480 strWarningText = UIFileManager::tr("<p>Guest control session is running.</p>"); 481 481 icon = UIIconPool::iconSet(":/status_check_16px.png"); 482 482 break; … … 1073 1073 if (m_pMainLayout) 1074 1074 { 1075 m_pGuestSessionWidget = new UIGuestSession CreateWidget;1075 m_pGuestSessionWidget = new UIGuestSessionWidget; 1076 1076 if (m_pGuestSessionWidget) 1077 1077 { 1078 1078 m_pMainLayout->addWidget(m_pGuestSessionWidget, m_pMainLayout->rowCount(), 0, 1, m_pMainLayout->columnCount()); 1079 1079 m_pGuestSessionWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 1080 connect(m_pGuestSessionWidget, &UIGuestSession CreateWidget::sigCreateSession,1081 this, &UIFileManagerGuestTable::slt CreateGuestSession);1082 connect(m_pGuestSessionWidget, &UIGuestSession CreateWidget::sigCloseSession,1080 connect(m_pGuestSessionWidget, &UIGuestSessionWidget::sigOpenSession, 1081 this, &UIFileManagerGuestTable::sltOpenGuestSession); 1082 connect(m_pGuestSessionWidget, &UIGuestSessionWidget::sigCloseSession, 1083 1083 this, &UIFileManagerGuestTable::sltHandleCloseSessionRequest); 1084 1084 } … … 1333 1333 } 1334 1334 1335 void UIFileManagerGuestTable::slt CreateGuestSession(QString strUserName, QString strPassword)1335 void UIFileManagerGuestTable::sltOpenGuestSession(QString strUserName, QString strPassword) 1336 1336 { 1337 1337 if (strUserName.isEmpty()) … … 1411 1411 m_pGuestSessionWidget->setLoginWidgetsEnabled(m_enmState == State_SessionPossible || m_enmState == State_SessionRunning); 1412 1412 if (m_enmState == State_SessionPossible) 1413 m_pGuestSessionWidget->switchSession CreateMode();1413 m_pGuestSessionWidget->switchSessionOpenMode(); 1414 1414 else if (m_enmState == State_SessionRunning) 1415 1415 m_pGuestSessionWidget->switchSessionCloseMode(); -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r93682 r93697 44 44 class UIActionPool; 45 45 class UICustomFileSystemItem; 46 class UIGuestSession CreateWidget;46 class UIGuestSessionWidget; 47 47 48 48 /** This class scans the guest file system by using the VBox Guest Control API … … 98 98 void sltGuestSessionRegistered(CGuestSession guestSession); 99 99 void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent); 100 void slt CreateGuestSession(QString strUserName, QString strPassword);100 void sltOpenGuestSession(QString strUserName, QString strPassword); 101 101 void sltHandleCloseSessionRequest(); 102 102 void sltMachineStateChange(const QUuid &uMachineId, const KMachineState state); … … 157 157 CEventListener m_comGuestListener; 158 158 CEventListener m_comConsoleListener; 159 UIGuestSession CreateWidget *m_pGuestSessionWidget;159 UIGuestSessionWidget *m_pGuestSessionWidget; 160 160 /** True if this table is the current table in parents tab widget. */ 161 161 bool m_fIsCurrent;
Note:
See TracChangeset
for help on using the changeset viewer.