VirtualBox

Changeset 72182 in vbox for trunk/src


Ignore:
Timestamp:
May 9, 2018 8:03:15 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref: 6769 Set the tooltip of the UIVMNamePathSelector to machine folder as an additional hint to user

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r72177 r72182  
    334334    connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged,
    335335            this, &UINameAndSystemEditor::sigNameChanged);
     336    connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged,
     337            this, &UINameAndSystemEditor::sigPathChanged);
    336338    connect(m_pComboFamily, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    337339            this, &UINameAndSystemEditor::sltFamilyChanged);
     
    346348    m_pNamePathSelector->setNameFieldValidator(strValidatorString);
    347349}
     350
     351void UINameAndSystemEditor::setMachineFilePath(const QString &strPath)
     352{
     353    if (!m_pNamePathSelector)
     354        return;
     355    m_pNamePathSelector->setToolTipText(strPath);
     356}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r72177 r72182  
    4949    /** Notifies listeners about VM name change. */
    5050    void sigNameChanged(const QString &strNewName);
     51    void sigPathChanged(const QString &strName);
    5152
    5253    /** Notifies listeners about VM OS type change. */
     
    7374
    7475    void setNameFieldValidator(const QString &strValidatorString);
     76
     77    /** Forwards the machine name to UIVMNamePathSelector member instance. */
     78    void setMachineFilePath(const QString &strPath);
    7579
    7680protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.cpp

    r72177 r72182  
    9898        connect(m_pName, &QILineEdit::textChanged,
    9999                this, &UIVMNamePathSelector::sigNameChanged);
    100 
    101100    }
    102101
     
    116115    m_pPath->setText(path);
    117116    m_pPath->setFixedWidthByText(path);
     117    emit sigPathChanged(path);
    118118}
    119119
     
    136136void UIVMNamePathSelector::retranslateUi()
    137137{
    138     setToolTip(tr("The Virtual Machine files will be saved under ..."));
     138    if (m_strToolTipText.isEmpty())
     139        return;
     140    QString strToolTip = "The Virtual Machine files will be saved under " + m_strToolTipText;
     141    setToolTip(tr(qPrintable(strToolTip)));
    139142}
    140143
     
    146149    if (!strSelectedPath.isEmpty())
    147150    {
    148         m_pPath->setText(strSelectedPath);
     151        setPath(strSelectedPath);
    149152    }
    150153}
     
    156159    m_pName->setValidator(new QRegExpValidator(QRegExp(strValidatorString), this));
    157160}
     161
     162void UIVMNamePathSelector::setToolTipText(const QString &strToolTipText)
     163{
     164    if (m_strToolTipText == strToolTipText)
     165        return;
     166    m_strToolTipText = strToolTipText;
     167    retranslateUi();
     168}
     169
     170const QString& UIVMNamePathSelector::toolTipText() const
     171{
     172    return m_strToolTipText;
     173}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.h

    r72177 r72182  
    3838
    3939    void sigNameChanged(const QString &strName);
     40    void sigPathChanged(const QString &strName);
    4041
    4142public:
     
    4546public slots:
    4647
    47     QString path() const;
    48     void    setPath(const QString &path);
     48    QString        path() const;
     49    void           setPath(const QString &path);
    4950
    50     QString name() const;
    51     void    setName(const QString &name);
    52     void    setNameFieldValidator(const QString &strValidatorString);
     51    QString        name() const;
     52    void           setName(const QString &name);
     53    void           setNameFieldValidator(const QString &strValidatorString);
     54
     55    void           setToolTipText(const QString &strToolTipText);
     56    const QString& toolTipText() const;
    5357
    5458protected:
     
    6266private:
    6367
    64     void         prepareWidgets();
    65     QString      defaultMachineFolder() const;
     68    void          prepareWidgets();
     69    QString       defaultMachineFolder() const;
    6670
    6771    QHBoxLayout  *m_pMainLayout;
     
    7074    QILabel      *m_pSeparator;
    7175    QIToolButton *m_pFileDialogButton;
    72 
     76    /** Tooltip set is set by clients of this widget. */
     77    QString       m_strToolTipText;
    7378};
    7479
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r72177 r72182  
    215215}
    216216
    217 bool UIWizardNewVMPage1::createMachineFolder()
    218 {
    219     if (!m_pNameAndSystemEditor)
    220         return false;
    221     /* Cleanup previosly created folder if any: */
    222     if (machineFolderCreated() && !cleanupMachineFolder())
    223     {
    224         msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
    225         return false;
    226     }
    227 
     217void UIWizardNewVMPage1::composeMachineFilePath()
     218{
    228219    /* Get VBox: */
    229220    CVirtualBox vbox = vboxGlobal().virtualBox();
    230     /* Get default machine folder: */
    231     //const QString strMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
    232221
    233222    /* Compose machine filename: */
     
    241230    m_strMachineBaseName = fileInfo.completeBaseName();
    242231
     232    if (m_pNameAndSystemEditor)
     233        m_pNameAndSystemEditor->setMachineFilePath(m_strMachineFolder);
     234}
     235
     236bool UIWizardNewVMPage1::createMachineFolder()
     237{
     238    if (!m_pNameAndSystemEditor)
     239        return false;
     240    /* Cleanup previosly created folder if any: */
     241    if (machineFolderCreated() && !cleanupMachineFolder())
     242    {
     243        msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
     244        return false;
     245    }
     246
     247    composeMachineFilePath();
     248
    243249    /* Make sure that folder doesn't exists: */
    244250    if (QDir(m_strMachineFolder).exists())
     
    286292
    287293    /* Setup connections: */
    288     connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
    289     connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged()));
     294    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
     295    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
     296    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
    290297
    291298    /* Register fields: */
     
    301308    /* Call to base-class: */
    302309    onNameChanged(strNewName);
     310    composeMachineFilePath();
     311}
     312
     313void UIWizardNewVMPageBasic1::sltPathChanged(const QString &strNewPath)
     314{
     315    composeMachineFilePath();
    303316}
    304317
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r72177 r72182  
    5656    void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; }
    5757
     58    /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
     59    void composeMachineFilePath();
     60
    5861    /** Full path (including the file name) of the machine's configuration file. */
    5962    QString m_strMachineFilePath;
     
    6669    UINameAndSystemEditor *m_pNameAndSystemEditor;
    6770
    68     /** Variables: */
    6971    QString m_strGroup;
    7072    bool m_fSupportsHWVirtEx;
     
    9496    /* Handlers: */
    9597    void sltNameChanged(const QString &strNewText);
     98    void sltPathChanged(const QString &strNewPath);
    9699    void sltOsTypeChanged();
    97100
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