VirtualBox

Changeset 11361 in vbox for trunk/src


Ignore:
Timestamp:
Aug 12, 2008 2:34:05 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: VBoxFilePathSelectorWidget: Disable methods altering the tooltips for predefined items.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxFilePathSelectorWidget.h

    r11229 r11361  
    3838public:
    3939
    40     enum SelectorMode
     40    enum Mode
    4141    {
    42         PathMode = 0,
    43         FileMode
     42        Mode_Folder = 0,
     43        Mode_File
    4444    };
    4545
     
    4747   ~VBoxFilePathSelectorWidget();
    4848
    49     void setMode (SelectorMode aMode);
    50     SelectorMode mode() const;
     49    void setMode (Mode aMode);
     50    Mode mode() const;
    5151
    5252    void setResetEnabled (bool aEnabled);
    5353    bool isResetEnabled () const;
    5454
     55#if 0
     56
     57    /// @todo enabling this requires to allow to customize the names of the
     58    /// "Other..." and "Reset" items too which is not yet done.
     59
    5560    void setNoneToolTip (const QString &aText);
    5661    void setSelectToolTip (const QString &aText);
    5762    void setResetToolTip (const QString &aText);
     63
     64#endif /* 0 */
    5865
    5966    bool isModified() const;
     
    8996    QFileIconProvider *mIconProvider;
    9097    QAction *mCopyAction;
    91     SelectorMode mMode;
     98    Mode mMode;
    9299    QString mPath;
    93100    QString mNoneStr;
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFilePathSelectorWidget.cpp

    r11229 r11361  
    3030#include <QFileIconProvider>
    3131
     32#include <VBoxDefs.h>
     33
    3234enum
    3335{
     
    4143    , mIconProvider (new QFileIconProvider())
    4244    , mCopyAction (new QAction (this))
    43     , mMode (PathMode)
     45    , mMode (Mode_Folder)
    4446{
    4547    /* Populate items */
     
    7274}
    7375
    74 void VBoxFilePathSelectorWidget::setMode (SelectorMode aMode)
     76void VBoxFilePathSelectorWidget::setMode (Mode aMode)
    7577{
    7678    mMode = aMode;
    7779}
    7880
    79 VBoxFilePathSelectorWidget::SelectorMode VBoxFilePathSelectorWidget::mode() const
     81VBoxFilePathSelectorWidget::Mode VBoxFilePathSelectorWidget::mode() const
    8082{
    8183    return mMode;
     
    9698}
    9799
     100#if 0
     101
     102/// @todo enabling this requires to allow to customize the names of the
     103/// "Other..." and "Reset" items too which is not yet done.
     104
    98105void VBoxFilePathSelectorWidget::setNoneToolTip (const QString &aText)
    99106{
     
    116123}
    117124
     125#endif /* 0 */
     126
    118127bool VBoxFilePathSelectorWidget::isModified() const
    119128{
     
    124133{
    125134    mPath = aPath.isEmpty() ? QString::null : aPath;
    126 
    127     /* Attach corresponding icon */
    128     setItemIcon (PathId, QFileInfo (mPath).exists() ?
    129                          mIconProvider->icon (QFileInfo (mPath)) :
    130                          defaultIcon());
    131 
    132     /* Store full path as tooltip */
    133     setToolTip (filePath());
    134     setItemData (PathId, toolTip(), Qt::ToolTipRole);
    135135
    136136    refreshText();
     
    150150void VBoxFilePathSelectorWidget::retranslateUi()
    151151{
     152    /* how do we interpret the "nothing selected" item? */
     153    if (isResetEnabled())
     154    {
     155        mNoneStr = tr ("<reset to default>");
     156        mNoneTip = tr ("The actual default path value will be displayed after "
     157                       "accepting the changes and opening this dialog again.");
     158    }
     159    else
     160    {
     161        mNoneStr = tr ("<not selected>");
     162        mNoneTip = tr ("Please use the <b>Other...</b> item from the drop-down "
     163                       "list to select a desired path.");
     164    }
     165
    152166    /* Retranslate 'path' item */
    153     mNoneStr = tr ("None");
    154167    if (mPath.isNull())
    155168    {
     
    166179        setItemText (ResetId, tr ("Reset"));
    167180
     181    /* set tooltips of the above two items based on the mode */
     182    switch (mMode)
     183    {
     184        case Mode_Folder:
     185            setItemData (SelectId,
     186                         tr ("Opens a dialog to select a different folder."),
     187                         Qt::ToolTipRole);
     188            setItemData (ResetId,
     189                         tr ("Resets the folder path to the default value."),
     190                         Qt::ToolTipRole);
     191            break;
     192        case Mode_File:
     193            setItemData (SelectId,
     194                         tr ("Opens a dialog to select a different file."),
     195                         Qt::ToolTipRole);
     196            setItemData (ResetId,
     197                         tr ("Resets the file path to the default value."),
     198                         Qt::ToolTipRole);
     199            break;
     200        default:
     201            AssertFailedBreak();
     202    }
     203
    168204    /* Retranslate copy action */
    169205    mCopyAction->setText (tr ("&Copy"));
     
    199235QIcon VBoxFilePathSelectorWidget::defaultIcon() const
    200236{
    201     if (mMode == PathMode)
     237    if (mMode == Mode_Folder)
    202238        return mIconProvider->icon (QFileIconProvider::Folder);
    203239    else
     
    207243QString VBoxFilePathSelectorWidget::filePath() const
    208244{
     245    /// @todo (r=dmik) why is it used as if it always returns a full path while
     246    /// it actually may not?
     247
    209248    if (!mPath.isNull())
    210249    {
    211         if (mMode == PathMode)
    212             return QDir (mPath).path();
    213         else
    214             return QFileInfo (mPath).filePath();
    215     }
    216 
    217     return mNoneTip;
     250        switch (mMode)
     251        {
     252            case Mode_Folder:
     253                return QDir (mPath).path();
     254            case Mode_File:
     255                return QFileInfo (mPath).filePath();
     256            default:
     257                AssertFailedBreak();
     258        }
     259    }
     260
     261    return QString::null;
    218262}
    219263
    220264QString VBoxFilePathSelectorWidget::shrinkText (int aWidth) const
    221265{
    222     /* Full text stored in toolTip */
    223     QString fullText = toolTip();
     266    QString fullText = filePath();
    224267    if (fullText.isEmpty())
    225268        return fullText;
     
    257300    int newSize = fontMetrics().width (fullText);
    258301
    259     return newSize < oldSize ? fullText : toolTip();
     302    return newSize < oldSize ? fullText : filePath();
    260303}
    261304
     
    265308    {
    266309        if (itemText (PathId) != mNoneStr)
     310        {
    267311            setItemText (PathId, mNoneStr);
     312            setItemIcon (PathId, QIcon());
     313            setItemData (PathId, mNoneTip, Qt::ToolTipRole);
     314            setToolTip (mNoneTip);
     315        }
    268316    }
    269317    else
     
    275323            QStyle::CC_ComboBox, &options, QStyle::SC_ComboBoxEditField);
    276324        setItemText (PathId, shrinkText (rect.width() - iconSize().width()));
    277     }
    278 }
    279 
     325
     326        /* Attach corresponding icon */
     327        setItemIcon (PathId, QFileInfo (mPath).exists() ?
     328                             mIconProvider->icon (QFileInfo (mPath)) :
     329                             defaultIcon());
     330
     331        /* Store full path as tooltip */
     332        setToolTip (filePath());
     333        setItemData (PathId, toolTip(), Qt::ToolTipRole);
     334    }
     335}
     336
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGLSettingsGeneral.cpp

    r11229 r11361  
    3131    Ui::VBoxGLSettingsGeneral::setupUi (this);
    3232
    33     mPsVRDP->setMode (VBoxFilePathSelectorWidget::FileMode);
     33    mPsVRDP->setMode (VBoxFilePathSelectorWidget::Mode_File);
    3434
    3535    /* Setup connections */
     
    7676    Ui::VBoxGLSettingsGeneral::retranslateUi (this);
    7777
    78     mPsVdi->setWhatsThis (tr ("Displays the path to the default VDI folder. This folder is used, if not explicitly specified otherwise, when adding existing or creating new virtual hard disks."));
    79     mPsVdi->setNoneToolTip (tr ("The actual default path will be displayed after accepting the changes and opening this dialog again."));
    80     mPsVdi->setSelectToolTip (tr ("Opens a dialog to select the default VDI folder."));
    81     mPsVdi->setResetToolTip (tr ("Resets the VDI folder path to the default value."));
    82 
    83     mPsMach->setWhatsThis (tr ("Displays the path to the default virtual machine folder. This folder is used, if not explicitly specified otherwise, when creating new virtual machines."));
    84     mPsMach->setNoneToolTip (tr ("The actual default path will be displayed after accepting the changes and opening this dialog again."));
    85     mPsMach->setSelectToolTip (tr ("Opens a dialog to select the default virtual machine folder."));
    86     mPsMach->setResetToolTip (tr ("Resets the virtual machine folder path to the default value."));
    87 
    88     mPsVRDP->setWhatsThis (tr ("Displays the path to the library that provides authentication for Remote Display (VRDP) clients."));
    89     mPsVRDP->setNoneToolTip (tr ("The actual default library file will be displayed after accepting the changes and opening this dialog again."));
    90     mPsVRDP->setSelectToolTip (tr ("Opens a dialog to select the VRDP authentication library file."));
    91     mPsVRDP->setResetToolTip (tr ("Resets the authentication library file to the default value."));
     78    mPsVdi->setWhatsThis (tr ("Displays the path to the default VDI folder. "
     79                              "This folder is used, if not explicitly "
     80                              "specified otherwise, when adding existing or "
     81                              "creating new virtual hard disks."));
     82    mPsMach->setWhatsThis (tr ("Displays the path to the default virtual "
     83                               "machine folder. This folder is used, if not "
     84                               "explicitly specified otherwise, when creating "
     85                               "new virtual machines."));
     86    mPsVRDP->setWhatsThis (tr ("Displays the path to the library that "
     87                               "provides authentication for Remote Display "
     88                               "(VRDP) clients."));
    9289}
    9390
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsGeneral.cpp

    r11229 r11361  
    377377
    378378    /* Path selector */
    379     mPsSnapshot->setWhatsThis (tr ("Displays the path where snapshots of this virtual machine will be stored. Note that snapshots can take quite a lot of disk space."));
    380     mPsSnapshot->setNoneToolTip (tr ("The actual default path will be displayed after accepting the changes and opening this dialog again."));
    381     mPsSnapshot->setSelectToolTip (tr ("Selects the snapshot folder path."));
    382     mPsSnapshot->setResetToolTip (tr ("Resets the snapshot folder path to the default value."));
     379    mPsSnapshot->setWhatsThis (tr ("Displays the path where snapshots of this "
     380                                   "virtual machine will be stored. Note that "
     381                                   "snapshots can take quite a lot of disk "
     382                                   "space."));
    383383}
    384384
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsSFDetails.cpp

    r11229 r11361  
    115115    Ui::VBoxVMSettingsSFDetails::retranslateUi (this);
    116116
    117     mPsPath->setNoneToolTip (tr ("No shared folder path is currently selected."));
    118     mPsPath->setSelectToolTip (tr ("Selects shared folder path."));
    119 
    120117    switch (mType)
    121118    {
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