VirtualBox

Changeset 92649 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 30, 2021 12:13:11 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9371. Removing one of the push buttons in session panel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestSessionPanel.cpp

    r92648 r92649  
    5757private slots:
    5858
    59     void sltCreateButtonClick();
     59    void sltButtonClick();
    6060    void sltHandleTextChanged(const QString &strText);
    6161
    6262private:
    6363
     64    enum ButtonMode
     65    {
     66        ButtonMode_Create,
     67        ButtonMode_Close
     68    };
     69
    6470    void          prepareWidgets();
     71    void          updateButton();
     72
     73    ButtonMode    m_enmButtonMode;
    6574    QILineEdit   *m_pUserNameEdit;
    6675    UIPasswordLineEdit   *m_pPasswordEdit;
    67     QPushButton  *m_pCreateButton;
    68     QPushButton  *m_pCloseButton;
     76    QPushButton  *m_pButton;
    6977    QHBoxLayout  *m_pMainLayout;
    7078    QColor        m_defaultBaseColor;
     
    8088UIGuestSessionCreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */)
    8189    : QIWithRetranslateUI<QWidget>(pParent)
     90    , m_enmButtonMode(ButtonMode_Create)
    8291    , m_pUserNameEdit(0)
    8392    , m_pPasswordEdit(0)
    84     , m_pCreateButton(0)
    85     , m_pCloseButton(0)
     93    , m_pButton(0)
    8694    , m_pMainLayout(0)
    8795    , m_fMarkedForError(0)
     
    119127    }
    120128
    121     m_pCreateButton = new QPushButton;
    122     if (m_pCreateButton)
    123     {
    124         m_pMainLayout->addWidget(m_pCreateButton);
    125         connect(m_pCreateButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltCreateButtonClick);
    126     }
    127 
    128     m_pCloseButton = new QPushButton;
    129     if (m_pCloseButton)
    130     {
    131         m_pMainLayout->addWidget(m_pCloseButton);
    132         connect(m_pCloseButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sigCloseSession);
    133     }
     129    m_pButton = new QPushButton;
     130    if (m_pButton)
     131    {
     132        m_pMainLayout->addWidget(m_pButton);
     133        connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltButtonClick);
     134    }
     135
     136
    134137    m_pMainLayout->insertStretch(-1, 1);
    135138    switchSessionCreateMode();
     
    137140}
    138141
    139 void UIGuestSessionCreateWidget::sltCreateButtonClick()
    140 {
    141     if (m_pUserNameEdit && m_pPasswordEdit)
     142void UIGuestSessionCreateWidget::sltButtonClick()
     143{
     144    if (m_enmButtonMode == ButtonMode_Create && m_pUserNameEdit && m_pPasswordEdit)
    142145        emit sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     146    else if (m_enmButtonMode == ButtonMode_Close)
     147        emit sigCloseSession();
    143148}
    144149
     
    163168    }
    164169
    165     if (m_pCreateButton)
    166         m_pCreateButton->setText(QApplication::translate("UIFileManager", "Create Session"));
    167     if (m_pCloseButton)
    168         m_pCloseButton->setText(QApplication::translate("UIFileManager", "Close Session"));
     170    if (m_pButton)
     171    {
     172        if (m_enmButtonMode == ButtonMode_Create)
     173            m_pButton->setText(QApplication::translate("UIFileManager", "Create Session"));
     174        else
     175            m_pButton->setText(QApplication::translate("UIFileManager", "Close Session"));
     176    }
    169177}
    170178
     
    194202    if (m_pPasswordEdit)
    195203        m_pPasswordEdit->setEnabled(true);
    196     if (m_pCreateButton)
    197         m_pCreateButton->setEnabled(true);
    198     if (m_pCloseButton)
    199         m_pCloseButton->setEnabled(false);
     204    m_enmButtonMode = ButtonMode_Create;
     205    retranslateUi();
    200206}
    201207
     
    206212    if (m_pPasswordEdit)
    207213        m_pPasswordEdit->setEnabled(false);
    208     if (m_pCreateButton)
    209         m_pCreateButton->setEnabled(false);
    210     if (m_pCloseButton)
    211         m_pCloseButton->setEnabled(true);
     214    m_enmButtonMode = ButtonMode_Close;
     215    retranslateUi();
    212216}
    213217
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