VirtualBox

Changeset 10658 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 15, 2008 1:36:57 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4:

  • Renamed VBoxPathSelector to VBoxFilePathSelectorWidget
  • Added VBoxFilePathSelectorWidget to the global general settings
Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
5 edited

Legend:

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

    r10649 r10658  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VirtualBox Qt extensions: VBoxPathSelector class declaration
     4 * VirtualBox Qt extensions: VBoxFilePathSelectorWidget class declaration
    55 */
    66
     
    2121 */
    2222
    23 #ifndef __VBoxPathSelector_h__
    24 #define __VBoxPathSelector_h__
     23#ifndef __VBoxFilePathSelectorWidget_h__
     24#define __VBoxFilePathSelectorWidget_h__
    2525
    2626#include "QIWithRetranslateUI.h"
     
    3939class QComboBox;
    4040
    41 class VBoxPathSelector: public QIWithRetranslateUI<QWidget>
     41class VBoxFilePathSelectorWidget: public QIWithRetranslateUI<QWidget>
    4242{
    4343    Q_OBJECT;
     
    4545public:
    4646
    47     VBoxPathSelector (QWidget *aParent = NULL);
    48     ~VBoxPathSelector();
     47    enum SelectorMode
     48    {
     49        PathMode = 0,
     50        FileMode
     51    };
     52
     53    VBoxFilePathSelectorWidget (QWidget *aParent = NULL);
     54    ~VBoxFilePathSelectorWidget();
     55
     56    void setMode (SelectorMode aMode);
     57    SelectorMode mode() const;
    4958
    5059    void setLineEditWhatsThis (const QString &aText);
     
    7584
    7685    void init();
     86    QIcon defaultIcon() const;
     87    QString filePath (const QString &aName, bool bLast) const;
    7788
    7889    /* Private member vars */
    79     QString mPath;
    80     QString mNoneStr;
     90    SelectorMode mMode;
     91    QString      mPath;
     92    QString      mNoneStr;
     93
    8194#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
    8295    QComboBox   *mCbPath;
     
    91104};
    92105
    93 #endif /* __VBoxPathSelector_h__ */
     106#endif /* __VBoxFilePathSelectorWidget_h__ */
    94107
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGLSettingsGeneral.cpp

    r10212 r10658  
    3131    Ui::VBoxGLSettingsGeneral::setupUi (this);
    3232
     33    mPsVRDP->setMode (VBoxFilePathSelectorWidget::FileMode);
     34
    3335    /* Setup connections */
    34     connect (mTbVdiSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));
    35     connect (mTbMachSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));
    36     connect (mTbVRDPSelect, SIGNAL (clicked()), this, SLOT (onSelectFolderClicked()));
    37     connect (mTbVdiReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));
    38     connect (mTbMachReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));
    39     connect (mTbVRDPReset, SIGNAL (clicked()), this, SLOT (onResetFolderClicked()));
     36    connect (mPsVdi,  SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked()));
     37    connect (mPsMach, SIGNAL (selectPath()), this, SLOT (onSelectFolderClicked()));
     38    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()));
    4042
    4143    /* Applying language settings */
     
    4648                                         const VBoxGlobalSettings &)
    4749{
    48     mLeVdi->setText (aProps.GetDefaultVDIFolder());
    49     mLeMach->setText (aProps.GetDefaultMachineFolder());
    50     mLeVRDP->setText (aProps.GetRemoteDisplayAuthLibrary());
     50    mPsVdi->setPath (aProps.GetDefaultVDIFolder());
     51    mPsMach->setPath (aProps.GetDefaultMachineFolder());
     52    mPsVRDP->setPath (aProps.GetRemoteDisplayAuthLibrary());
    5153}
    5254
     
    5456                                           VBoxGlobalSettings &)
    5557{
    56     if (mLeVdi->isModified())
    57         aProps.SetDefaultVDIFolder (mLeVdi->text());
    58     if (aProps.isOk() && mLeMach->isModified())
    59         aProps.SetDefaultMachineFolder (mLeMach->text());
    60     if (mLeVRDP->isModified())
    61         aProps.SetRemoteDisplayAuthLibrary (mLeVRDP->text());
     58    if (mPsVdi->isModified())
     59        aProps.SetDefaultVDIFolder (mPsVdi->path());
     60    if (aProps.isOk() && mPsMach->isModified())
     61        aProps.SetDefaultMachineFolder (mPsMach->path());
     62    if (mPsVdi->isModified())
     63        aProps.SetRemoteDisplayAuthLibrary (mPsVRDP->path());
    6264}
    6365
    6466void VBoxGLSettingsGeneral::setOrderAfter (QWidget *aWidget)
    6567{
    66     setTabOrder (aWidget, mLeVdi);
    67     setTabOrder (mLeVdi, mTbVdiSelect);
    68     setTabOrder (mTbVdiSelect, mTbVdiReset);
    69     setTabOrder (mTbVdiReset, mLeMach);
    70     setTabOrder (mLeMach, mTbMachSelect);
    71     setTabOrder (mTbMachSelect, mTbMachReset);
    72     setTabOrder (mTbMachReset, mLeVRDP);
    73     setTabOrder (mLeVRDP, mTbVRDPSelect);
    74     setTabOrder (mTbVRDPSelect, mTbVRDPReset);
     68    setTabOrder (aWidget, mPsVdi);
     69    setTabOrder (mPsVdi, mPsMach);
     70    setTabOrder (mPsMach, mPsVRDP);
    7571}
    7672
     
    7975    /* Translate uic generated strings */
    8076    Ui::VBoxGLSettingsGeneral::retranslateUi (this);
     77
     78    mPsVdi->setLineEditWhatsThis (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->setSelectorWhatsThis (tr ("Opens a dialog to select the default VDI folder."));
     80    mPsVdi->setResetWhatsThis (tr ("Resets the VDI folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again."));
     81
     82    mPsMach->setLineEditWhatsThis (tr ("Displays the path to the default virtual machine folder. This folder is used, if not explicitly specified otherwise, when creating new virtual machines."));
     83    mPsMach->setSelectorWhatsThis (tr ("Opens a dialog to select the default virtual machine folder."));
     84    mPsMach->setResetWhatsThis (tr ("Resets the virtual machine folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again."));
     85
     86    mPsVRDP->setLineEditWhatsThis (tr ("Displays the path to the library that provides authentication for Remote Display (VRDP) clients."));
     87    mPsVRDP->setSelectorWhatsThis (tr ("Opens a dialog to select the VRDP authentication library file."));
     88    mPsVRDP->setResetWhatsThis (tr ("Resets the authentication library file to the default value. The actual default library file will be displayed after accepting the changes and opening this dialog again."));
    8189}
    8290
    8391void VBoxGLSettingsGeneral::onResetFolderClicked()
    8492{
    85     QToolButton *tb = qobject_cast<QToolButton*> (sender());
    86     Assert (tb);
    87 
    88     QLineEdit *le = 0;
    89     if (tb == mTbVdiReset) le = mLeVdi;
    90     else if (tb == mTbMachReset) le = mLeMach;
    91     else if (tb == mTbVRDPReset) le = mLeVRDP;
    92     Assert (le);
    93 
    94     /* Do this instead of le->setText (QString::null) to cause
    95      * isModified() return true */
    96     le->selectAll();
    97     le->del();
     93    VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender());
     94    Assert (ps);
     95    ps->setPath ("");
    9896}
    9997
    10098void VBoxGLSettingsGeneral::onSelectFolderClicked()
    10199{
    102     QToolButton *tb = qobject_cast<QToolButton*> (sender());
    103     Assert (tb);
     100    VBoxFilePathSelectorWidget *ps = qobject_cast<VBoxFilePathSelectorWidget*> (sender());
     101    Assert (ps);
    104102
    105     QLineEdit *le = 0;
    106     if (tb == mTbVdiSelect) le = mLeVdi;
    107     else if (tb == mTbMachSelect) le = mLeMach;
    108     else if (tb == mTbVRDPSelect) le = mLeVRDP;
    109     Assert (le);
    110 
    111     QString initDir = VBoxGlobal::getFirstExistingDir (le->text());
     103    QString initDir = VBoxGlobal::getFirstExistingDir (ps->path());
    112104    if (initDir.isNull())
    113105        initDir = vboxGlobal().virtualBox().GetHomeFolder();
    114106
    115     QString path = le == mLeVRDP ?
     107
     108    QString path = ps == mPsVRDP ?
    116109        VBoxGlobal::getOpenFileName (initDir, QString::null, this, QString::null) :
    117110        VBoxGlobal::getExistingDirectory (initDir, this);
     
    123116    path.remove (QRegExp ("[\\\\/]$"));
    124117
    125     /* Do this instead of le->setText (QString::null) to cause
    126      * isModified() return true */
    127     le->selectAll();
    128     le->insert (path);
     118    ps->setPath (path);
    129119}
    130120
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxPathSelector.cpp

    r10649 r10658  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VirtualBox Qt extensions: VBoxPathSelector class implementation
     4 * VirtualBox Qt extensions: VBoxFilePathSelectorWidget class implementation
    55 */
    66
     
    4343};
    4444
    45 VBoxPathSelector::VBoxPathSelector (QWidget *aParent /* = NULL */)
     45VBoxFilePathSelectorWidget::VBoxFilePathSelectorWidget (QWidget *aParent /* = NULL */)
    4646    : QIWithRetranslateUI<QWidget> (aParent)
     47    , mMode (PathMode)
    4748{
    4849    init();
    4950}
    5051
    51 VBoxPathSelector::~VBoxPathSelector()
     52VBoxFilePathSelectorWidget::~VBoxFilePathSelectorWidget()
    5253{
    5354    delete mIconProvider;
    5455}
    5556
    56 void VBoxPathSelector::setLineEditWhatsThis (const QString &aText)
     57void VBoxFilePathSelectorWidget::setMode (SelectorMode aMode)
     58{
     59    mMode = aMode;
     60}
     61
     62VBoxFilePathSelectorWidget::SelectorMode VBoxFilePathSelectorWidget::mode() const
     63{
     64    return mMode;
     65}
     66
     67void VBoxFilePathSelectorWidget::setLineEditWhatsThis (const QString &aText)
    5768{
    5869#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    6374}
    6475
    65 void VBoxPathSelector::setSelectorWhatsThis (const QString &aText)
     76void VBoxFilePathSelectorWidget::setSelectorWhatsThis (const QString &aText)
    6677{
    6778#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    7283}
    7384
    74 void VBoxPathSelector::setResetWhatsThis (const QString &aText)
     85void VBoxFilePathSelectorWidget::setResetWhatsThis (const QString &aText)
    7586{
    7687#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    8192}
    8293
    83 bool VBoxPathSelector::isModified() const
     94bool VBoxFilePathSelectorWidget::isModified() const
    8495{
    8596#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    90101}
    91102
    92 void VBoxPathSelector::setPath (const QString &aPath)
     103void VBoxFilePathSelectorWidget::setPath (const QString &aPath)
    93104{
    94105    mPath = aPath;
     
    99110        icon = mIconProvider->icon (fi);
    100111    else
    101         icon = mIconProvider->icon (QFileIconProvider::Folder);
     112        icon = defaultIcon();
    102113    if (tmpPath.isEmpty())
    103114        tmpPath = mNoneStr;
    104115#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
    105     QDir dir (tmpPath);
    106     mCbPath->setItemText (PathId, dir.dirName());
     116    mCbPath->setItemText (PathId, filePath (tmpPath, true));
    107117    mCbPath->setItemIcon (PathId, icon);
    108118#else /* VBOX_USE_COMBOBOX_PATH_SELECTOR */
     
    110120     * isModified() return true */
    111121    mLePath->selectAll();
    112     mLePath->insert (tmpPath);
     122    mLePath->insert (filePath (tmpPath, false));
    113123    mLbIcon->setPixmap (icon.pixmap (16, 16));
    114124#endif /* !VBOX_USE_COMBOBOX_PATH_SELECTOR */
    115125}
    116126
    117 QString VBoxPathSelector::path() const
     127QString VBoxFilePathSelectorWidget::path() const
    118128{
    119129    return mPath;
    120130}
    121131
    122 void VBoxPathSelector::retranslateUi()
     132void VBoxFilePathSelectorWidget::retranslateUi()
    123133{
    124134#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    129139}
    130140
    131 void VBoxPathSelector::cbActivated (int aIndex)
     141void VBoxFilePathSelectorWidget::cbActivated (int aIndex)
    132142{
    133143#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
     
    151161}
    152162
    153 void VBoxPathSelector::init()
     163void VBoxFilePathSelectorWidget::init()
    154164{
    155165    mIconProvider = new QFileIconProvider();
     
    158168#ifdef VBOX_USE_COMBOBOX_PATH_SELECTOR
    159169    mCbPath = new QComboBox();
     170    mCbPath->setMinimumWidth (200);
    160171    mCbPath->insertItem (PathId, "");
    161172    mCbPath->insertItem (SelectId, "");
     
    167178    mLbIcon = new QLabel();
    168179    mLePath = new QLineEdit();
     180    mLePath->setMinimumWidth (180);
    169181    mLePath->setReadOnly (true);
    170182    mTbSelect = new QToolButton();
     
    188200}
    189201
     202QIcon VBoxFilePathSelectorWidget::defaultIcon() const
     203{
     204    if (mMode == PathMode)
     205        return mIconProvider->icon (QFileIconProvider::Folder);
     206    else
     207        return mIconProvider->icon (QFileIconProvider::File);
     208
     209
     210QString VBoxFilePathSelectorWidget::filePath (const QString &aName, bool bLast) const
     211{
     212    if (mMode == PathMode)
     213    {
     214        QDir dir (aName);
     215        if (bLast)
     216            return dir.dirName();
     217        else
     218            return dir.path();
     219    }
     220    else
     221    {
     222        QFileInfo fi (aName);
     223        if (bLast)
     224            return fi.fileName();
     225        else
     226            return fi.filePath();
     227    }
     228
     229
  • trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxGLSettingsGeneral.ui

    r10536 r10658  
    2323    <x>0</x>
    2424    <y>0</y>
    25     <width>363</width>
    26     <height>144</height>
     25    <width>377</width>
     26    <height>162</height>
    2727   </rect>
    2828  </property>
     
    4949     </property>
    5050     <property name="buddy" >
    51       <cstring>mLeVdi</cstring>
     51      <cstring>mPsVdi</cstring>
    5252     </property>
    5353    </widget>
    5454   </item>
    5555   <item row="0" column="1" >
    56     <widget class="QLineEdit" name="mLeVdi" >
    57      <property name="sizePolicy" >
    58       <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
    59        <horstretch>0</horstretch>
    60        <verstretch>0</verstretch>
    61       </sizepolicy>
    62      </property>
    63      <property name="whatsThis" >
    64       <string>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.</string>
    65      </property>
    66     </widget>
    67    </item>
    68    <item row="0" column="2" >
    69     <widget class="QToolButton" name="mTbVdiSelect" >
    70      <property name="whatsThis" >
    71       <string>Opens a dialog to select the default VDI folder.</string>
    72      </property>
    73      <property name="icon" >
    74       <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset>
    75      </property>
    76      <property name="autoRaise" >
    77       <bool>true</bool>
    78      </property>
    79     </widget>
    80    </item>
    81    <item row="0" column="3" >
    82     <widget class="QToolButton" name="mTbVdiReset" >
    83      <property name="whatsThis" >
    84       <string>Resets the VDI folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string>
    85      </property>
    86      <property name="icon" >
    87       <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset>
    88      </property>
    89      <property name="autoRaise" >
    90       <bool>true</bool>
    91      </property>
    92     </widget>
     56    <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsVdi" />
    9357   </item>
    9458   <item row="1" column="0" >
     
    10165     </property>
    10266     <property name="buddy" >
    103       <cstring>mLeMach</cstring>
     67      <cstring>mPsMach</cstring>
    10468     </property>
    10569    </widget>
    10670   </item>
    10771   <item row="1" column="1" >
    108     <widget class="QLineEdit" name="mLeMach" >
    109      <property name="whatsThis" >
    110       <string>Displays the path to the default virtual machine folder. This folder is used, if not explicitly specified otherwise, when creating new virtual machines.</string>
    111      </property>
    112     </widget>
     72    <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsMach" />
    11373   </item>
    114    <item row="1" column="2" >
    115     <widget class="QToolButton" name="mTbMachSelect" >
    116      <property name="whatsThis" >
    117       <string>Opens a dialog to select the default virtual machine folder.</string>
    118      </property>
    119      <property name="icon" >
    120       <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset>
    121      </property>
    122      <property name="autoRaise" >
    123       <bool>true</bool>
    124      </property>
    125     </widget>
    126    </item>
    127    <item row="1" column="3" >
    128     <widget class="QToolButton" name="mTbMachReset" >
    129      <property name="whatsThis" >
    130       <string>Resets the virtual machine folder path to the default value. The actual default path will be displayed after accepting the changes and opening this dialog again.</string>
    131      </property>
    132      <property name="icon" >
    133       <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset>
    134      </property>
    135      <property name="autoRaise" >
    136       <bool>true</bool>
    137      </property>
    138     </widget>
    139    </item>
    140    <item row="2" column="0" colspan="4" >
     74   <item row="2" column="0" colspan="2" >
    14175    <widget class="Line" name="line" >
    14276     <property name="orientation" >
     
    15488     </property>
    15589     <property name="buddy" >
    156       <cstring>mLeVRDP</cstring>
     90      <cstring>mPsVRDP</cstring>
    15791     </property>
    15892    </widget>
    15993   </item>
    16094   <item row="3" column="1" >
    161     <widget class="QLineEdit" name="mLeVRDP" >
    162      <property name="whatsThis" >
    163       <string>Displays the path to the library that provides authentication for Remote Display (VRDP) clients.</string>
    164      </property>
    165     </widget>
    166    </item>
    167    <item row="3" column="2" >
    168     <widget class="QToolButton" name="mTbVRDPSelect" >
    169      <property name="whatsThis" >
    170       <string>Opens a dialog to select the VRDP authentication library file.</string>
    171      </property>
    172      <property name="icon" >
    173       <iconset resource="../VirtualBox.qrc" >:/select_file_16px.png</iconset>
    174      </property>
    175      <property name="autoRaise" >
    176       <bool>true</bool>
    177      </property>
    178     </widget>
    179    </item>
    180    <item row="3" column="3" >
    181     <widget class="QToolButton" name="mTbVRDPReset" >
    182      <property name="whatsThis" >
    183       <string>Resets the authentication library file to the default value. The actual default library file will be displayed after accepting the changes and opening this dialog again.</string>
    184      </property>
    185      <property name="icon" >
    186       <iconset resource="../VirtualBox.qrc" >:/eraser_16px.png</iconset>
    187      </property>
    188      <property name="autoRaise" >
    189       <bool>true</bool>
    190      </property>
    191     </widget>
     95    <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsVRDP" />
    19296   </item>
    19397   <item row="4" column="1" >
     
    206110  </layout>
    207111 </widget>
     112 <customwidgets>
     113  <customwidget>
     114   <class>VBoxFilePathSelectorWidget</class>
     115   <extends>QWidget</extends>
     116   <header>VBoxPathSelector.h</header>
     117   <container>1</container>
     118  </customwidget>
     119 </customwidgets>
    208120 <resources>
    209121  <include location="../VirtualBox.qrc" />
  • trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMSettingsGeneral.ui

    r10650 r10658  
    852852       </item>
    853853       <item row="4" column="1" >
    854         <widget class="VBoxPathSelector" native="1" name="mPsSnapshot" />
     854        <widget class="VBoxFilePathSelectorWidget" native="1" name="mPsSnapshot" />
    855855       </item>
    856856       <item row="5" column="1" >
     
    977977  </customwidget>
    978978  <customwidget>
    979    <class>VBoxPathSelector</class>
     979   <class>VBoxFilePathSelectorWidget</class>
    980980   <extends>QWidget</extends>
    981    <header>VBoxPathSelector.h</header>
     981   <header>VBoxFilePathSelectorWidget.h</header>
    982982   <container>1</container>
    983983  </customwidget>
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