VirtualBox

Ignore:
Timestamp:
Mar 22, 2018 4:56:22 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121436
Message:

FE/Qt: bugref:6699 Add a check box to show/hide the password field in file manager

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl
Files:
5 edited

Legend:

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

    r71439 r71467  
    2222/* Qt includes: */
    2323# include <QAbstractItemModel>
     24# include <QCheckBox>
    2425# include <QHBoxLayout>
    2526# include <QHeaderView>
     
    9798
    9899    void sltCreateButtonClick();
     100    void sltShowHidePassword(bool flag);
    99101
    100102private:
     
    102104    QILineEdit   *m_pUserNameEdit;
    103105    QILineEdit   *m_pPasswordEdit;
    104 
    105     QILabel      *m_pUserNameLabel;
    106     QILabel      *m_pPasswordLabel;
    107106    QPushButton  *m_pCreateButton;
    108107    QPushButton  *m_pCloseButton;
    109 
    110     QHBoxLayout *m_pMainLayout;
     108    QHBoxLayout  *m_pMainLayout;
     109    QCheckBox    *m_pShowPasswordCheckBox;
    111110
    112111};
     
    129128    , m_pUserNameEdit(0)
    130129    , m_pPasswordEdit(0)
    131     , m_pUserNameLabel(0)
    132     , m_pPasswordLabel(0)
    133130    , m_pCreateButton(0)
    134131    , m_pCloseButton(0)
    135132    , m_pMainLayout(0)
     133    , m_pShowPasswordCheckBox(0)
    136134{
    137135    prepareWidgets();
     
    143141    if (!m_pMainLayout)
    144142        return;
     143
    145144    m_pUserNameEdit = new QILineEdit;
    146145    if (m_pUserNameEdit)
    147146    {
    148         m_pMainLayout->addWidget(m_pUserNameEdit);
    149     }
    150     m_pUserNameLabel = new QILabel;
    151     if (m_pUserNameLabel)
    152     {
    153         m_pMainLayout->addWidget(m_pUserNameLabel);
    154     }
     147        m_pMainLayout->addWidget(m_pUserNameEdit, 2);
     148        m_pUserNameEdit->setPlaceholderText("User Name");
     149    }
     150
    155151    m_pPasswordEdit = new QILineEdit;
    156152    if (m_pPasswordEdit)
    157153    {
    158         m_pMainLayout->addWidget(m_pPasswordEdit);
    159     }
    160 
    161     m_pPasswordLabel = new QILabel;
    162     if (m_pPasswordLabel)
    163     {
    164         m_pMainLayout->addWidget(m_pPasswordLabel);
     154        m_pMainLayout->addWidget(m_pPasswordEdit, 2);
     155        m_pPasswordEdit->setPlaceholderText("Password");
     156        m_pPasswordEdit->setEchoMode(QLineEdit::Password);
     157    }
     158
     159    m_pShowPasswordCheckBox = new QCheckBox;
     160    if (m_pShowPasswordCheckBox)
     161    {
     162        m_pShowPasswordCheckBox->setText("Show Password");
     163        m_pMainLayout->addWidget(m_pShowPasswordCheckBox);
     164        connect(m_pShowPasswordCheckBox, &QCheckBox::toggled,
     165                this, &UIGuestSessionCreateWidget::sltShowHidePassword);
    165166    }
    166167
     
    178179        connect(m_pCloseButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sigCloseButtonClick);
    179180    }
    180 
     181    m_pMainLayout->insertStretch(-1, 1);
    181182    retranslateUi();
    182183}
     
    188189}
    189190
     191void UIGuestSessionCreateWidget::sltShowHidePassword(bool flag)
     192{
     193    if (!m_pPasswordEdit)
     194        return;
     195    if (flag)
     196        m_pPasswordEdit->setEchoMode(QLineEdit::Normal);
     197    else
     198        m_pPasswordEdit->setEchoMode(QLineEdit::Password);
     199}
     200
    190201void UIGuestSessionCreateWidget::retranslateUi()
    191202{
     
    193204    {
    194205        m_pUserNameEdit->setToolTip(UIVMInformationDialog::tr("User name to authenticate session creation"));
     206        m_pUserNameEdit->setPlaceholderText(UIVMInformationDialog::tr("User Name"));
     207
    195208    }
    196209    if (m_pPasswordEdit)
    197210    {
    198211        m_pPasswordEdit->setToolTip(UIVMInformationDialog::tr("Password to authenticate session creation"));
    199     }
    200     if (m_pUserNameLabel)
    201     {
    202         m_pUserNameLabel->setToolTip(UIVMInformationDialog::tr("User name to authenticate session creation"));
    203         m_pUserNameLabel->setText(UIVMInformationDialog::tr("User name"));
    204     }
    205     if (m_pPasswordLabel)
    206     {
    207         m_pPasswordLabel->setToolTip(UIVMInformationDialog::tr("Password to authenticate session creation"));
    208         m_pPasswordLabel->setText(UIVMInformationDialog::tr("Password"));
    209     }
     212        m_pPasswordEdit->setPlaceholderText(UIVMInformationDialog::tr("Password"));
     213    }
     214
    210215    if (m_pCreateButton)
    211216        m_pCreateButton->setText(UIVMInformationDialog::tr("Create Session"));
     
    228233void UIGuestSessionCreateWidget::switchSessionCreateMode()
    229234{
    230     m_pUserNameEdit->setEnabled(true);
    231     m_pPasswordEdit->setEnabled(true);
    232     m_pUserNameLabel->setEnabled(true);
    233     m_pPasswordLabel->setEnabled(true);
    234     m_pCreateButton->setEnabled(true);
    235     m_pCloseButton->setEnabled(false);
     235    if (m_pUserNameEdit)
     236        m_pUserNameEdit->setEnabled(true);
     237    if (m_pPasswordEdit)
     238        m_pPasswordEdit->setEnabled(true);
     239    if (m_pCreateButton)
     240        m_pCreateButton->setEnabled(true);
     241    if (m_pCloseButton)
     242        m_pCloseButton->setEnabled(false);
    236243}
    237244
    238245void UIGuestSessionCreateWidget::switchSessionCloseMode()
    239246{
    240     m_pUserNameEdit->setEnabled(false);
    241     m_pPasswordEdit->setEnabled(false);
    242     m_pUserNameLabel->setEnabled(false);
    243     m_pPasswordLabel->setEnabled(false);
    244     m_pCreateButton->setEnabled(false);
    245     m_pCloseButton->setEnabled(true);
     247    if (m_pUserNameEdit)
     248        m_pUserNameEdit->setEnabled(false);
     249    if (m_pPasswordEdit)
     250        m_pPasswordEdit->setEnabled(false);
     251    if (m_pCreateButton)
     252        m_pCreateButton->setEnabled(false);
     253    if (m_pCloseButton)
     254        m_pCloseButton->setEnabled(true);
    246255}
    247256
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlFileTable.cpp

    r71439 r71467  
    157157const QChar UIPathOperations::delimiter = QChar('/');
    158158
    159 QString UIPathOperations::removeMultipleDelimiters(const QString &path)
     159/* static */ QString UIPathOperations::removeMultipleDelimiters(const QString &path)
    160160{
    161161    QString newPath(path);
     
    167167}
    168168
    169 QString UIPathOperations::removeTrailingDelimiters(const QString &path)
     169/* static */ QString UIPathOperations::removeTrailingDelimiters(const QString &path)
    170170{
    171171    if (path.isNull() || path.isEmpty())
     
    178178}
    179179
    180 QString UIPathOperations::addStartDelimiter(const QString &path)
     180/* static */ QString UIPathOperations::addStartDelimiter(const QString &path)
    181181{
    182182    if (path.isEmpty())
     
    188188}
    189189
    190 QString UIPathOperations::sanitize(const QString &path)
     190/* static */ QString UIPathOperations::sanitize(const QString &path)
    191191{
    192192    return addStartDelimiter(removeTrailingDelimiters(removeMultipleDelimiters(path)));
    193193}
    194194
    195 QString UIPathOperations::mergePaths(const QString &path, const QString &baseName)
     195/* static */ QString UIPathOperations::mergePaths(const QString &path, const QString &baseName)
    196196{
    197197    QString newBase(baseName);
     
    208208}
    209209
    210 QString UIPathOperations::getObjectName(const QString &path)
     210/* static */ QString UIPathOperations::getObjectName(const QString &path)
    211211{
    212212    if (path.length() <= 1)
     
    222222}
    223223
    224 QString UIPathOperations::getPathExceptObjectName(const QString &path)
     224/* static */ QString UIPathOperations::getPathExceptObjectName(const QString &path)
    225225{
    226226    if (path.length() <= 1)
     
    234234}
    235235
    236 QString UIPathOperations::constructNewItemPath(const QString &previousPath, const QString &newBaseName)
     236/* static */ QString UIPathOperations::constructNewItemPath(const QString &previousPath, const QString &newBaseName)
    237237{
    238238    if (previousPath.length() <= 1)
     
    241241}
    242242
    243 QStringList UIPathOperations::pathTrail(const QString &path)
     243/* static */ QStringList UIPathOperations::pathTrail(const QString &path)
    244244{
    245245    QList<QString> pathList = path.split(UIPathOperations::delimiter, QString::SkipEmptyParts);
     
    944944        return;
    945945    if (currentRoot != m_pModel->rootIndex())
    946         changeLocation(currentRoot.parent());
     946    {
     947        QModelIndex parentIndex = currentRoot.parent();
     948        if (parentIndex.isValid())
     949        {
     950            changeLocation(currentRoot.parent());
     951            m_pView->selectRow(currentRoot.row());
     952        }
     953    }
    947954}
    948955
     
    12551262        sltDelete();
    12561263    }
     1264    else if (pEvent->key() == Qt::Key_Backspace)
     1265    {
     1266        sltGoUp();
     1267    }
     1268
    12571269    QWidget::keyPressEvent(pEvent);
    12581270}
     
    13441356}
    13451357
    1346 QString UIGuestControlFileTable::fileTypeString(FileObjectType type)
     1358/* static */ QString UIGuestControlFileTable::fileTypeString(FileObjectType type)
    13471359{
    13481360    QString strType("Unknown");
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestControlInterface.cpp

    r71195 r71467  
    7373        break;
    7474
    75 QString UIGuestControlInterface::getFsObjTypeString(KFsObjType type)
     75/* static */ QString UIGuestControlInterface::getFsObjTypeString(KFsObjType type)
    7676{
    7777    QString strType;
     
    664664}
    665665
    666 bool UIGuestControlInterface::isGuestAdditionsAvailable(const CGuest &guest)
     666/* static */ bool UIGuestControlInterface::isGuestAdditionsAvailable(const CGuest &guest)
    667667{
    668668    if (!guest.isOk())
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIGuestFileTable.cpp

    r71439 r71467  
    259259}
    260260
    261 FileObjectType UIGuestFileTable::fileType(const CFsObjInfo &fsInfo)
     261/* static */ FileObjectType UIGuestFileTable::fileType(const CFsObjInfo &fsInfo)
    262262{
    263263    if (fsInfo.isNull() || !fsInfo.isOk())
     
    273273}
    274274
    275 FileObjectType UIGuestFileTable::fileType(const CGuestFsObjInfo &fsInfo)
     275/* static */ FileObjectType UIGuestFileTable::fileType(const CGuestFsObjInfo &fsInfo)
    276276{
    277277    if (fsInfo.isNull() || !fsInfo.isOk())
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/guestctrl/UIHostFileTable.cpp

    r71439 r71467  
    168168}
    169169
    170 FileObjectType UIHostFileTable::fileType(const QFileInfo &fsInfo)
     170/* static */ FileObjectType UIHostFileTable::fileType(const QFileInfo &fsInfo)
    171171{
    172172    if (!fsInfo.exists())
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