VirtualBox

Changeset 92847 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Dec 9, 2021 12:39:28 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148775
Message:

FE/Qt: bugref:9371. Replacing session create panel with a simple widget.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r92804 r92847  
    821821        src/guestctrl/UIFileManagerOperationsPanel.h \
    822822        src/guestctrl/UIFileManagerOptionsPanel.h \
    823         src/guestctrl/UIFileManagerGuestSessionPanel.h \
    824823        src/guestctrl/UIFileManagerTable.h \
    825824        src/helpbrowser/UIHelpBrowserDialog.h \
     
    10121011        src/guestctrl/UIFileManagerLogPanel.cpp \
    10131012        src/guestctrl/UIFileManagerOperationsPanel.cpp \
    1014         src/guestctrl/UIFileManagerGuestSessionPanel.cpp \
    10151013        src/guestctrl/UIFileManagerTable.cpp \
    10161014        src/guestctrl/UIFileManagerGuestTable.cpp \
     
    13711369        src/guestctrl/UIFileManagerOperationsPanel.cpp \
    13721370        src/guestctrl/UIFileManagerOptionsPanel.cpp \
    1373         src/guestctrl/UIFileManagerGuestSessionPanel.cpp \
    13741371        src/guestctrl/UIFileManagerTable.cpp \
    13751372        src/helpbrowser/UIHelpBrowserDialog.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r92711 r92847  
    17371737        setName(QApplication::translate("UIActionPool", "Session"));
    17381738        setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
    1739         setStatusTip(QApplication::translate("UIActionPool", "Open guest session panel of the file manager"));
    1740         setToolTip(  QApplication::translate("UIActionPool", "Open Guest Session Panel")
     1739        setStatusTip(QApplication::translate("UIActionPool", "Toggle guest session panel of the file manager"));
     1740        setToolTip(  QApplication::translate("UIActionPool", "Toggle Guest Session Panel")
    17411741                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    17421742    }
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r92814 r92847  
    119119    , m_pFileTableSplitter(0)
    120120    , m_pToolBar(0)
    121     , m_pVerticalToolBar(0)\
     121    , m_pVerticalToolBar(0)
    122122    , m_pHostFileTable(0)
    123123    , m_pGuestTablesContainer(0)
     
    663663    {
    664664        UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i));
    665         if (!pTable)
     665        /* Keep the tabs with running guest control session even if the corresponding vm has been de-selected. */
     666        if (!pTable || pTable->isGuestSessionRunning())
    666667            continue;
    667668        if (machineIdsToRemove.contains(pTable->machineId()))
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r92819 r92847  
    2020#include <QFileInfo>
    2121#include <QHBoxLayout>
     22#include <QPushButton>
    2223#include <QUuid>
    2324
     
    3132#include "UIFileManager.h"
    3233#include "UIFileManagerGuestTable.h"
    33 #include "UIFileManagerGuestSessionPanel.h"
    3434#include "UIMessageCenter.h"
    3535#include "UIPathOperations.h"
     36#include "UIUserNamePasswordEditor.h"
    3637#include "UIVirtualBoxEventHandler.h"
     38#include "QILineEdit.h"
    3739#include "QIToolBar.h"
    3840
     
    4648
    4749#include <iprt/path.h>
     50
     51/*********************************************************************************************************************************
     52*   UIGuestSessionCreateWidget definition.                                                                                   *
     53*********************************************************************************************************************************/
     54/** A QWidget extension containing text entry fields for password and username and buttons to
     55 *  start/stop a guest session. */
     56class UIGuestSessionCreateWidget : public QIWithRetranslateUI<QWidget>
     57{
     58    Q_OBJECT;
     59
     60signals:
     61
     62    void sigCreateSession(QString strUserName, QString strPassword);
     63    void sigCloseSession();
     64
     65public:
     66
     67    UIGuestSessionCreateWidget(QWidget *pParent = 0);
     68    /** Disables certain widget after a guest session has been created. */
     69    void switchSessionCreateMode();
     70    /** Makes sure certain widgets are enabled so that a guest session can be created. */
     71    void switchSessionCloseMode();
     72    void markForError(bool fMarkForError);
     73
     74protected:
     75
     76    void retranslateUi() /* override */;
     77    void keyPressEvent(QKeyEvent * pEvent) /* override */;
     78    void showEvent(QShowEvent *pEvent) /* override */;
     79
     80private slots:
     81
     82    void sltButtonClick();
     83    void sltHandleTextChanged(const QString &strText);
     84
     85private:
     86
     87    enum ButtonMode
     88    {
     89        ButtonMode_Create,
     90        ButtonMode_Close
     91    };
     92
     93    void          prepareWidgets();
     94    void          updateButton();
     95
     96    ButtonMode    m_enmButtonMode;
     97    QILineEdit   *m_pUserNameEdit;
     98    UIPasswordLineEdit   *m_pPasswordEdit;
     99    QPushButton  *m_pButton;
     100    QHBoxLayout  *m_pMainLayout;
     101    QColor        m_defaultBaseColor;
     102    QColor        m_errorBaseColor;
     103    bool          m_fMarkedForError;
     104};
     105
     106
     107/*********************************************************************************************************************************
     108*   UIGuestSessionCreateWidget implementation.                                                                                   *
     109*********************************************************************************************************************************/
     110
     111UIGuestSessionCreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */)
     112    : QIWithRetranslateUI<QWidget>(pParent)
     113    , m_enmButtonMode(ButtonMode_Create)
     114    , m_pUserNameEdit(0)
     115    , m_pPasswordEdit(0)
     116    , m_pButton(0)
     117    , m_pMainLayout(0)
     118    , m_fMarkedForError(0)
     119{
     120    prepareWidgets();
     121}
     122
     123void UIGuestSessionCreateWidget::prepareWidgets()
     124{
     125    m_pMainLayout = new QHBoxLayout(this);
     126    if (!m_pMainLayout)
     127        return;
     128
     129    m_pMainLayout->setContentsMargins(0, 0, 0, 0);
     130
     131    m_pUserNameEdit = new QILineEdit;
     132    if (m_pUserNameEdit)
     133    {
     134        m_pMainLayout->addWidget(m_pUserNameEdit, 2);
     135        m_pUserNameEdit->setPlaceholderText(QApplication::translate("UIFileManager", "User Name"));
     136        m_defaultBaseColor = m_pUserNameEdit->palette().color(QPalette::Base);
     137        m_errorBaseColor = QColor(m_defaultBaseColor.red(),
     138                                  0.5 * m_defaultBaseColor.green(),
     139                                  0.5 * m_defaultBaseColor.blue());
     140        connect(m_pUserNameEdit, &QILineEdit::textChanged,
     141                this, &UIGuestSessionCreateWidget::sltHandleTextChanged);
     142    }
     143
     144    m_pPasswordEdit = new UIPasswordLineEdit;
     145    if (m_pPasswordEdit)
     146    {
     147        m_pMainLayout->addWidget(m_pPasswordEdit, 2);
     148        m_pPasswordEdit->setPlaceholderText(QApplication::translate("UIFileManager", "Password"));
     149        m_pPasswordEdit->setEchoMode(QLineEdit::Password);
     150        connect(m_pPasswordEdit, &UIPasswordLineEdit::textChanged,
     151                this, &UIGuestSessionCreateWidget::sltHandleTextChanged);
     152    }
     153
     154    m_pButton = new QPushButton;
     155    if (m_pButton)
     156    {
     157        m_pMainLayout->addWidget(m_pButton);
     158        connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltButtonClick);
     159    }
     160
     161
     162    m_pMainLayout->insertStretch(-1, 1);
     163    switchSessionCreateMode();
     164    retranslateUi();
     165}
     166
     167void UIGuestSessionCreateWidget::sltButtonClick()
     168{
     169    if (m_enmButtonMode == ButtonMode_Create && m_pUserNameEdit && m_pPasswordEdit)
     170        emit sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     171    else if (m_enmButtonMode == ButtonMode_Close)
     172        emit sigCloseSession();
     173}
     174
     175void UIGuestSessionCreateWidget::sltHandleTextChanged(const QString &strText)
     176{
     177    Q_UNUSED(strText);
     178    markForError(false);
     179}
     180
     181void UIGuestSessionCreateWidget::retranslateUi()
     182{
     183    if (m_pUserNameEdit)
     184    {
     185        m_pUserNameEdit->setToolTip(QApplication::translate("UIFileManager", "User name to authenticate session creation"));
     186        m_pUserNameEdit->setPlaceholderText(QApplication::translate("UIFileManager", "User Name"));
     187
     188    }
     189    if (m_pPasswordEdit)
     190    {
     191        m_pPasswordEdit->setToolTip(QApplication::translate("UIFileManager", "Password to authenticate session creation"));
     192        m_pPasswordEdit->setPlaceholderText(QApplication::translate("UIFileManager", "Password"));
     193    }
     194
     195    if (m_pButton)
     196    {
     197        if (m_enmButtonMode == ButtonMode_Create)
     198            m_pButton->setText(QApplication::translate("UIFileManager", "Create Session"));
     199        else
     200            m_pButton->setText(QApplication::translate("UIFileManager", "Close Session"));
     201    }
     202}
     203
     204void UIGuestSessionCreateWidget::keyPressEvent(QKeyEvent * pEvent)
     205{
     206    /* Emit sigCreateSession upon enter press: */
     207    if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return)
     208    {
     209        if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) ||
     210            (m_pPasswordEdit && m_pPasswordEdit->hasFocus()))
     211            sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text());
     212    }
     213    QWidget::keyPressEvent(pEvent);
     214}
     215
     216void UIGuestSessionCreateWidget::showEvent(QShowEvent *pEvent)
     217{
     218    QIWithRetranslateUI<QWidget>::showEvent(pEvent);
     219    if (m_pUserNameEdit)
     220        m_pUserNameEdit->setFocus();
     221}
     222
     223void UIGuestSessionCreateWidget::switchSessionCreateMode()
     224{
     225    if (m_pUserNameEdit)
     226        m_pUserNameEdit->setEnabled(true);
     227    if (m_pPasswordEdit)
     228        m_pPasswordEdit->setEnabled(true);
     229    m_enmButtonMode = ButtonMode_Create;
     230    retranslateUi();
     231}
     232
     233void UIGuestSessionCreateWidget::switchSessionCloseMode()
     234{
     235    if (m_pUserNameEdit)
     236        m_pUserNameEdit->setEnabled(false);
     237    if (m_pPasswordEdit)
     238        m_pPasswordEdit->setEnabled(false);
     239    m_enmButtonMode = ButtonMode_Close;
     240    retranslateUi();
     241}
     242
     243void UIGuestSessionCreateWidget::markForError(bool fMarkForError)
     244{
     245    if (m_fMarkedForError == fMarkForError)
     246        return;
     247    m_fMarkedForError = fMarkForError;
     248
     249        if (m_pUserNameEdit)
     250        {
     251            QPalette mPalette = m_pUserNameEdit->palette();
     252            if (m_fMarkedForError)
     253                mPalette.setColor(QPalette::Base, m_errorBaseColor);
     254            else
     255                mPalette.setColor(QPalette::Base, m_defaultBaseColor);
     256            m_pUserNameEdit->setPalette(mPalette);
     257        }
     258        if (m_pPasswordEdit)
     259        {
     260            QPalette mPalette = m_pPasswordEdit->palette();
     261            if (m_fMarkedForError)
     262                mPalette.setColor(QPalette::Base, m_errorBaseColor);
     263            else
     264                mPalette.setColor(QPalette::Base, m_defaultBaseColor);
     265            m_pPasswordEdit->setPalette(mPalette);
     266        }
     267}
    48268
    49269
     
    425645}
    426646
     647bool UIFileManagerGuestTable::isGuestSessionRunning() const
     648{
     649    if (m_comGuestSession.isNull())
     650        return false;
     651    if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Starting ||
     652        m_comGuestSession.GetStatus() == KGuestSessionStatus_Started)
     653        return true;
     654    return false;
     655}
     656
    427657void UIFileManagerGuestTable::copyGuestToHost(const QString& hostDestinationPath)
    428658{
     
    7911021    if (m_pMainLayout)
    7921022    {
    793         m_pGuestSessionPanel = new UIFileManagerGuestSessionPanel;
     1023        m_pGuestSessionPanel = new UIGuestSessionCreateWidget;
    7941024        if (m_pGuestSessionPanel)
    7951025        {
    7961026            m_pMainLayout->addWidget(m_pGuestSessionPanel, m_pMainLayout->rowCount(), 0, 1, m_pMainLayout->columnCount());
    7971027            m_pGuestSessionPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    798             sltHandleGuestSessionPanelShown();
    799             connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigCreateSession,
     1028            //sltHandleGuestSessionPanelShown();
     1029            connect(m_pGuestSessionPanel, &UIGuestSessionCreateWidget::sigCreateSession,
    8001030                    this, &UIFileManagerGuestTable::sltCreateGuestSession);
    801             connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigCloseSession,
     1031            connect(m_pGuestSessionPanel, &UIGuestSessionCreateWidget::sigCloseSession,
    8021032                    this, &UIFileManagerGuestTable::sltHandleCloseSessionRequest);
    803             connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigHidePanel,
    804                     this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden);
    805             connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigShowPanel,
    806                     this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelShown);
     1033            // connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigHidePanel,
     1034            //         this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden);
     1035            // connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigShowPanel,
     1036            //         this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelShown);
    8071037        }
    8081038    }
     
    8561086}
    8571087
    858 void UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden()
    859 {
    860     if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))
    861         m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(false);
    862 }
    863 
    864 void UIFileManagerGuestTable::sltHandleGuestSessionPanelShown()
    865 {
    866     if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))
    867         m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true);
    868 }
     1088// void UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden()
     1089// {
     1090//     if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))
     1091//         m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(false);
     1092// }
     1093
     1094// void UIFileManagerGuestTable::sltHandleGuestSessionPanelShown()
     1095// {
     1096//     if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))
     1097//         m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true);
     1098// }
    8691099
    8701100void UIFileManagerGuestTable::sltMachineStateChange(const QUuid &uMachineId, const KMachineState enmMachineState)
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r92814 r92847  
    4141
    4242/* Forward declarations: */
     43class CGuestSessionStateChangedEvent;
    4344class UIActionPool;
    4445class UICustomFileSystemItem;
    45 class UIFileManagerGuestSessionPanel;
    46 class CGuestSessionStateChangedEvent;
     46class UIGuestSessionCreateWidget;
    4747
    4848/** This class scans the guest file system by using the VBox Guest Control API
     
    6464                         const QString &strDestination = QString());
    6565    QUuid machineId();
     66    bool isGuestSessionRunning() const;
    6667
    6768protected:
     
    9495
    9596    void sltGuestSessionPanelToggled(bool fChecked);
    96     void sltHandleGuestSessionPanelHidden();
    97     void sltHandleGuestSessionPanelShown();
     97    // void sltHandleGuestSessionPanelHidden();
     98    // void sltHandleGuestSessionPanelShown();
    9899    void sltGuestSessionUnregistered(CGuestSession guestSession);
    99100    void sltGuestSessionRegistered(CGuestSession guestSession);
     
    136137    void prepareGuestSessionPanel();
    137138
    138 
    139139    bool openGuestSession(const QString& strUserName, const QString& strPassword);
    140140    void closeGuestSession();
     
    166166    CEventListener m_comGuestListener;
    167167    CEventListener m_comConsoleListener;
    168     UIFileManagerGuestSessionPanel     *m_pGuestSessionPanel;
     168    UIGuestSessionCreateWidget *m_pGuestSessionPanel;
     169;
    169170    CheckMachine m_enmCheckMachine;
    170171};
Note: See TracChangeset for help on using the changeset viewer.

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