VirtualBox

Changeset 93697 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 11, 2022 3:48:03 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9371. refactoring.

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  
    5353
    5454/*********************************************************************************************************************************
    55 *   UIGuestSessionCreateWidget definition.                                                                                   *
     55*   UIGuestSessionWidget definition.                                                                                   *
    5656*********************************************************************************************************************************/
    5757/** A QWidget extension containing text entry fields for password and username and buttons to
    5858  *  start/stop a guest session. */
    59 class UIGuestSessionCreateWidget : public QIWithRetranslateUI<QWidget>
     59class UIGuestSessionWidget : public QIWithRetranslateUI<QWidget>
    6060{
    6161    Q_OBJECT;
     
    6363signals:
    6464
    65     void sigCreateSession(QString strUserName, QString strPassword);
     65    void sigOpenSession(QString strUserName, QString strPassword);
    6666    void sigCloseSession();
    6767
    6868public:
    6969
    70     UIGuestSessionCreateWidget(QWidget *pParent = 0);
    71     /** Disables certain widget after a guest session has been created. */
    72     void switchSessionCreateMode();
    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. */
    7474    void switchSessionCloseMode();
    7575    void markForError(bool fMarkForError);
     
    9292    enum ButtonMode
    9393    {
    94         ButtonMode_Create,
     94        ButtonMode_Open,
    9595        ButtonMode_Close
    9696    };
     
    112112
    113113/*********************************************************************************************************************************
    114 *   UIGuestSessionCreateWidget implementation.                                                                                   *
     114*   UIGuestSessionWidget implementation.                                                                                   *
    115115*********************************************************************************************************************************/
    116116
    117 UIGuestSessionCreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */)
     117UIGuestSessionWidget::UIGuestSessionWidget(QWidget *pParent /* = 0 */)
    118118    : QIWithRetranslateUI<QWidget>(pParent)
    119     , m_enmButtonMode(ButtonMode_Create)
     119    , m_enmButtonMode(ButtonMode_Open)
    120120    , m_pUserNameEdit(0)
    121121    , m_pPasswordEdit(0)
     
    128128}
    129129
    130 void UIGuestSessionCreateWidget::prepareWidgets()
     130void UIGuestSessionWidget::prepareWidgets()
    131131{
    132132    m_pMainLayout = new QHBoxLayout(this);
     
    146146                                  0.5 * m_defaultBaseColor.blue());
    147147        connect(m_pUserNameEdit, &QILineEdit::textChanged,
    148                 this, &UIGuestSessionCreateWidget::sltHandleTextChanged);
     148                this, &UIGuestSessionWidget::sltHandleTextChanged);
    149149    }
    150150
     
    156156        m_pPasswordEdit->setEchoMode(QLineEdit::Password);
    157157        connect(m_pPasswordEdit, &UIPasswordLineEdit::textChanged,
    158                 this, &UIGuestSessionCreateWidget::sltHandleTextChanged);
     158                this, &UIGuestSessionWidget::sltHandleTextChanged);
    159159    }
    160160
     
    163163    {
    164164        m_pMainLayout->addWidget(m_pButton);
    165         connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltButtonClick);
     165        connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionWidget::sltButtonClick);
    166166    }
    167167    m_pStatusIconLabel = new QLabel(this);
     
    173173
    174174    m_pMainLayout->insertStretch(-1, 1);
    175     switchSessionCreateMode();
     175    switchSessionOpenMode();
    176176    retranslateUi();
    177177}
    178178
    179 void UIGuestSessionCreateWidget::sltButtonClick()
    180 {
    181     if (m_enmButtonMode == ButtonMode_Create && m_pUserNameEdit && m_pPasswordEdit)
    182         emit sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     179void UIGuestSessionWidget::sltButtonClick()
     180{
     181    if (m_enmButtonMode == ButtonMode_Open && m_pUserNameEdit && m_pPasswordEdit)
     182        emit sigOpenSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
    183183    else if (m_enmButtonMode == ButtonMode_Close)
    184184        emit sigCloseSession();
    185185}
    186186
    187 void UIGuestSessionCreateWidget::sltHandleTextChanged(const QString &strText)
     187void UIGuestSessionWidget::sltHandleTextChanged(const QString &strText)
    188188{
    189189    Q_UNUSED(strText);
     
    191191}
    192192
    193 void UIGuestSessionCreateWidget::retranslateUi()
     193void UIGuestSessionWidget::retranslateUi()
    194194{
    195195    if (m_pUserNameEdit)
     
    207207    if (m_pButton)
    208208    {
    209         if (m_enmButtonMode == ButtonMode_Create)
     209        if (m_enmButtonMode == ButtonMode_Open)
    210210        {
    211             m_pButton->setText(QApplication::translate("UIFileManager", "Create Session"));
    212             m_pButton->setToolTip(QApplication::translate("UIFileManager", "Create Session"));
     211            m_pButton->setText(QApplication::translate("UIFileManager", "Open Session"));
     212            m_pButton->setToolTip(QApplication::translate("UIFileManager", "Open Session"));
    213213        }
    214214        else
     
    220220}
    221221
    222 void UIGuestSessionCreateWidget::keyPressEvent(QKeyEvent * pEvent)
    223 {
    224     /* Emit sigCreateSession upon enter press: */
     222void UIGuestSessionWidget::keyPressEvent(QKeyEvent * pEvent)
     223{
     224    /* Emit sigOpenSession upon enter press: */
    225225    if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return)
    226226    {
    227227        if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) ||
    228228            (m_pPasswordEdit && m_pPasswordEdit->hasFocus()))
    229             sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     229            sigOpenSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
    230230    }
    231231    QWidget::keyPressEvent(pEvent);
    232232}
    233233
    234 void UIGuestSessionCreateWidget::showEvent(QShowEvent *pEvent)
     234void UIGuestSessionWidget::showEvent(QShowEvent *pEvent)
    235235{
    236236    QIWithRetranslateUI<QWidget>::showEvent(pEvent);
     
    239239}
    240240
    241 void UIGuestSessionCreateWidget::switchSessionCreateMode()
     241void UIGuestSessionWidget::switchSessionOpenMode()
    242242{
    243243    if (m_pUserNameEdit)
     
    245245    if (m_pPasswordEdit)
    246246        m_pPasswordEdit->setEnabled(true);
    247     m_enmButtonMode = ButtonMode_Create;
     247    m_enmButtonMode = ButtonMode_Open;
    248248    retranslateUi();
    249249}
    250250
    251 void UIGuestSessionCreateWidget::switchSessionCloseMode()
     251void UIGuestSessionWidget::switchSessionCloseMode()
    252252{
    253253    if (m_pUserNameEdit)
     
    259259}
    260260
    261 void UIGuestSessionCreateWidget::markForError(bool fMarkForError)
     261void UIGuestSessionWidget::markForError(bool fMarkForError)
    262262{
    263263    if (m_fMarkedForError == fMarkForError)
     
    285285}
    286286
    287 void UIGuestSessionCreateWidget::setStatusLabelIconAndToolTip(const QIcon &icon, const QString &strToolTip)
     287void UIGuestSessionWidget::setStatusLabelIconAndToolTip(const QIcon &icon, const QString &strToolTip)
    288288{
    289289    if (!m_pStatusIconLabel)
     
    294294}
    295295
    296 void UIGuestSessionCreateWidget::setLoginWidgetsEnabled(bool fEnabled)
     296void UIGuestSessionWidget::setLoginWidgetsEnabled(bool fEnabled)
    297297{
    298298    if (m_pUserNameEdit)
     
    462462        {
    463463            case State_InvalidMachineReference:
    464                 strWarningText = UIFileManager::tr("Machine reference is invalid.");
     464                strWarningText = UIFileManager::tr("<p>Machine reference is invalid.</p>");
    465465                icon = UIIconPool::iconSet(":/status_error_16px.png");
    466466                break;
    467467            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>");
    469469                icon = UIIconPool::iconSet(":/status_error_16px.png");
    470470                break;
    471471            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>");
    473473                icon = UIIconPool::iconSet(":/status_error_16px.png");
    474474                break;
    475475            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>");
    477477                icon = UIIconPool::iconSet(":/session_info_16px.png");
    478478                break;
    479479            case State_SessionRunning:
    480                 strWarningText = UIFileManager::tr("Guest control session is running.");
     480                strWarningText = UIFileManager::tr("<p>Guest control session is running.</p>");
    481481                icon = UIIconPool::iconSet(":/status_check_16px.png");
    482482                break;
     
    10731073    if (m_pMainLayout)
    10741074    {
    1075         m_pGuestSessionWidget = new UIGuestSessionCreateWidget;
     1075        m_pGuestSessionWidget = new UIGuestSessionWidget;
    10761076        if (m_pGuestSessionWidget)
    10771077        {
    10781078            m_pMainLayout->addWidget(m_pGuestSessionWidget, m_pMainLayout->rowCount(), 0, 1, m_pMainLayout->columnCount());
    10791079            m_pGuestSessionWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    1080             connect(m_pGuestSessionWidget, &UIGuestSessionCreateWidget::sigCreateSession,
    1081                     this, &UIFileManagerGuestTable::sltCreateGuestSession);
    1082             connect(m_pGuestSessionWidget, &UIGuestSessionCreateWidget::sigCloseSession,
     1080            connect(m_pGuestSessionWidget, &UIGuestSessionWidget::sigOpenSession,
     1081                    this, &UIFileManagerGuestTable::sltOpenGuestSession);
     1082            connect(m_pGuestSessionWidget, &UIGuestSessionWidget::sigCloseSession,
    10831083                    this, &UIFileManagerGuestTable::sltHandleCloseSessionRequest);
    10841084        }
     
    13331333}
    13341334
    1335 void UIFileManagerGuestTable::sltCreateGuestSession(QString strUserName, QString strPassword)
     1335void UIFileManagerGuestTable::sltOpenGuestSession(QString strUserName, QString strPassword)
    13361336{
    13371337    if (strUserName.isEmpty())
     
    14111411        m_pGuestSessionWidget->setLoginWidgetsEnabled(m_enmState == State_SessionPossible || m_enmState == State_SessionRunning);
    14121412        if (m_enmState == State_SessionPossible)
    1413             m_pGuestSessionWidget->switchSessionCreateMode();
     1413            m_pGuestSessionWidget->switchSessionOpenMode();
    14141414        else if (m_enmState == State_SessionRunning)
    14151415            m_pGuestSessionWidget->switchSessionCloseMode();
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r93682 r93697  
    4444class UIActionPool;
    4545class UICustomFileSystemItem;
    46 class UIGuestSessionCreateWidget;
     46class UIGuestSessionWidget;
    4747
    4848/** This class scans the guest file system by using the VBox Guest Control API
     
    9898    void sltGuestSessionRegistered(CGuestSession guestSession);
    9999    void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
    100     void sltCreateGuestSession(QString strUserName, QString strPassword);
     100    void sltOpenGuestSession(QString strUserName, QString strPassword);
    101101    void sltHandleCloseSessionRequest();
    102102    void sltMachineStateChange(const QUuid &uMachineId, const KMachineState state);
     
    157157    CEventListener m_comGuestListener;
    158158    CEventListener m_comConsoleListener;
    159     UIGuestSessionCreateWidget *m_pGuestSessionWidget;
     159    UIGuestSessionWidget *m_pGuestSessionWidget;
    160160    /** True if this table is the current table in parents tab widget. */
    161161    bool m_fIsCurrent;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette