VirtualBox

Changeset 11427 in vbox for trunk/src


Ignore:
Timestamp:
Aug 14, 2008 3:27:03 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34771
Message:

Fe/Qt4: Fixing 'File Path Selector' widget: added icons for "Other..." & "Reset" actions, "Reset" action becomes internal, trying to fix missed copy-to-clipboard function (missed only on win platform).

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

Legend:

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

    r11361 r11427  
    4444    };
    4545
    46     VBoxFilePathSelectorWidget (QWidget *aParent = 0);
     46    VBoxFilePathSelectorWidget (QWidget *aParent);
    4747   ~VBoxFilePathSelectorWidget();
    4848
     
    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 
    60     void setNoneToolTip (const QString &aText);
    61     void setSelectToolTip (const QString &aText);
    62     void setResetToolTip (const QString &aText);
    63 
    64 #endif /* 0 */
    65 
    6655    bool isModified() const;
    67 
    68 public slots:
    6956
    7057    void setPath (const QString &aPath);
     
    7461
    7562    void selectPath();
    76     void resetPath();
    7763
    7864protected:
     
    8975
    9076    QIcon defaultIcon() const;
    91     QString filePath() const;
     77    QString fullPath (bool aAbsolute = true) const;
    9278    QString shrinkText (int aWidth) const;
    9379    void refreshText();
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGLSettingsGeneral.h

    r10212 r11427  
    4949private slots:
    5050
    51     void onResetFolderClicked();
    5251    void onSelectFolderClicked();
    5352};
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsGeneral.h

    r10167 r11427  
    6464
    6565    void selectSnapshotFolder();
    66     void resetSnapshotFolder();
    6766
    6867private:
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFilePathSelectorWidget.cpp

    r11361 r11427  
    2222
    2323#include "VBoxFilePathSelectorWidget.h"
     24#include "VBoxGlobal.h"
    2425
    2526/* Qt includes */
     
    3031#include <QFileIconProvider>
    3132
    32 #include <VBoxDefs.h>
    33 
    3433enum
    3534{
     
    3938};
    4039
    41 VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent /* = 0 */)
     40VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent)
    4241    : QIWithRetranslateUI<QComboBox> (aParent)
    4342    , mIconProvider (new QFileIconProvider())
     
    5049    insertItem (ResetId, "");
    5150
     51    /* Attaching known icons */
     52    setItemIcon (SelectId, VBoxGlobal::iconSet (":/select_file_16px.png"));
     53    setItemIcon (ResetId, VBoxGlobal::iconSet (":/eraser_16px.png"));
     54
    5255    /* Setup context menu */
    5356    addAction (mCopyAction);
     
    6568    setContextMenuPolicy (Qt::ActionsContextMenu);
    6669    setMinimumWidth (200);
    67     /* Set path to None */
    68     setPath (QString::null);
    6970}
    7071
     
    8990        removeItem (ResetId);
    9091    else if (aEnabled && count() - 1 == ResetId - 1)
     92    {
    9193        insertItem (ResetId, "");
     94        setItemIcon (ResetId, VBoxGlobal::iconSet (":/eraser_16px.png"));
     95    }
    9296    retranslateUi();
    9397}
    9498
    95 bool VBoxFilePathSelectorWidget::isResetEnabled () const
     99bool VBoxFilePathSelectorWidget::isResetEnabled() const
    96100{
    97101    return (count() - 1  == ResetId);
    98102}
    99103
    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 
    105 void VBoxFilePathSelectorWidget::setNoneToolTip (const QString &aText)
    106 {
    107     mNoneTip = aText;
    108     if (mPath.isNull())
    109     {
    110         setItemData (PathId, mNoneTip, Qt::ToolTipRole);
    111         setToolTip (mNoneTip);
    112     }
    113 }
    114 
    115 void VBoxFilePathSelectorWidget::setSelectToolTip (const QString &aText)
    116 {
    117     setItemData (SelectId, aText, Qt::ToolTipRole);
    118 }
    119 
    120 void VBoxFilePathSelectorWidget::setResetToolTip (const QString &aText)
    121 {
    122     setItemData (ResetId, aText, Qt::ToolTipRole);
    123 }
    124 
    125 #endif /* 0 */
    126 
    127104bool VBoxFilePathSelectorWidget::isModified() const
    128105{
     
    133110{
    134111    mPath = aPath.isEmpty() ? QString::null : aPath;
    135 
    136112    refreshText();
    137113}
     
    150126void VBoxFilePathSelectorWidget::retranslateUi()
    151127{
    152     /* how do we interpret the "nothing selected" item? */
     128    /* How do we interpret the "nothing selected" item? */
    153129    if (isResetEnabled())
    154130    {
     
    179155        setItemText (ResetId, tr ("Reset"));
    180156
    181     /* set tooltips of the above two items based on the mode */
     157    /* Set tooltips of the above two items based on the mode */
    182158    switch (mMode)
    183159    {
     
    217193        case ResetId:
    218194        {
    219             emit resetPath();
     195            setPath (QString::null);
    220196            break;
    221197        }
     
    228204void VBoxFilePathSelectorWidget::copyToClipboard()
    229205{
    230     QString text = itemData (PathId, Qt::ToolTipRole).toString();
     206    QString text (fullPath());
     207    /* Copy the current text to the selection and global clipboard. */
     208    if (QApplication::clipboard()->supportsSelection())
     209        QApplication::clipboard()->setText (text, QClipboard::Selection);
    231210    QApplication::clipboard()->setText (text, QClipboard::Clipboard);
    232     QApplication::clipboard()->setText (text, QClipboard::Selection);
    233211}
    234212
     
    241219}
    242220
    243 QString VBoxFilePathSelectorWidget::filePath() const
    244 {
    245     /// @todo (r=dmik) why is it used as if it always returns a full path while
    246     /// it actually may not?
    247 
     221QString VBoxFilePathSelectorWidget::fullPath (bool aAbsolute) const
     222{
    248223    if (!mPath.isNull())
    249224    {
     
    251226        {
    252227            case Mode_Folder:
    253                 return QDir (mPath).path();
     228                return aAbsolute ? QDir (mPath).absolutePath() :
     229                                   QDir (mPath).path();
    254230            case Mode_File:
    255                 return QFileInfo (mPath).filePath();
     231                return aAbsolute ? QFileInfo (mPath).absoluteFilePath() :
     232                                   QFileInfo (mPath).filePath();
    256233            default:
    257234                AssertFailedBreak();
    258235        }
    259236    }
    260 
    261237    return QString::null;
    262238}
     
    264240QString VBoxFilePathSelectorWidget::shrinkText (int aWidth) const
    265241{
    266     QString fullText = filePath();
     242    QString fullText (fullPath (false));
    267243    if (fullText.isEmpty())
    268244        return fullText;
     
    300276    int newSize = fontMetrics().width (fullText);
    301277
    302     return newSize < oldSize ? fullText : filePath();
     278    return newSize < oldSize ? fullText : fullPath (false);
    303279}
    304280
     
    329305                             defaultIcon());
    330306
    331         /* Store full path as tooltip */
    332         setToolTip (filePath());
     307        /* Set the tooltip */
     308        setToolTip (fullPath());
    333309        setItemData (PathId, toolTip(), Qt::ToolTipRole);
    334310    }
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGLSettingsGeneral.cpp

    r11361 r11427  
    3737    connect (mPsMach, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked()));
    3838    connect (mPsVRDP, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked()));
    39     connect (mPsVdi,  SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));
    40     connect (mPsMach, SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));
    41     connect (mPsVRDP, SIGNAL (resetPath()), this, SLOT (onResetFolderClicked()));
    4239
    4340    /* Applying language settings */
     
    8986}
    9087
    91 void VBoxGLSettingsGeneral::onResetFolderClicked()
    92 {
    93     VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender());
    94     Assert (ps);
    95     ps->setPath (QString::null);
    96 }
    97 
    9888void VBoxGLSettingsGeneral::onSelectFolderClicked()
    9989{
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsGeneral.cpp

    r11361 r11427  
    7777    connect (mPsSnapshot, SIGNAL (selectPath()),
    7878             this, SLOT (selectSnapshotFolder()));
    79     connect (mPsSnapshot, SIGNAL (resetPath()),
    80              this, SLOT (resetSnapshotFolder()));
    8179    connect (mTbBootItemUp, SIGNAL (clicked()),
    8280             this, SLOT (moveBootItemUp()));
     
    467465}
    468466
    469 void VBoxVMSettingsGeneral::resetSnapshotFolder()
    470 {
    471     mPsSnapshot->setPath (QString::null);
    472 }
    473 
    474467void VBoxVMSettingsGeneral::adjustBootOrderTWSize()
    475468{
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