VirtualBox

Changeset 17047 in vbox


Ignore:
Timestamp:
Feb 24, 2009 9:43:09 AM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: Several improvements for the file path selector.

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

Legend:

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

    r13564 r17047  
    5050    Mode mode() const;
    5151
     52    void setEditable (bool aOn);
     53    bool isEditable() const;
     54
    5255    void setResetEnabled (bool aEnabled);
    5356    bool isResetEnabled () const;
    5457
     58    void setFileDialogTitle (const QString& aTitle);
     59    QString fileDialogTitle() const;
     60
     61    void setFileFilters (const QString& aFilters);
     62    QString fileFilters() const;
     63
     64    void resetModified();
    5565    bool isModified() const;
    5666    bool isPathSelected() const;
    5767
    5868    QString path() const;
     69
     70signals:
     71    void pathChanged (const QString &);
    5972
    6073public slots:
     
    92105    QString mPath;
    93106    QString mHomeDir;
     107    QString mFileFilters;
     108    QString mFileDialogTitle;
    94109    QString mNoneStr;
    95110    QString mNoneTip;
     111    bool mIsEditable;
    96112    bool mIsEditableMode;
    97113    bool mIsMouseAwaited;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFilePathSelectorWidget.cpp

    r13564 r17047  
    6262    , mMode (Mode_Folder)
    6363    , mHomeDir (QDir::current().absolutePath())
     64    , mIsEditable (true)
    6465    , mIsEditableMode (false)
    6566    , mIsMouseAwaited (false)
     
    8182
    8283    /* Initial Setup */
    83     setEditable (true);
    84     Assert (lineEdit());
    8584    setInsertPolicy (QComboBox::NoInsert);
    8685    setContextMenuPolicy (Qt::ActionsContextMenu);
     
    8988    /* Setup connections */
    9089    connect (this, SIGNAL (activated (int)), this, SLOT (onActivated (int)));
    91     connect (lineEdit(), SIGNAL (textEdited (const QString &)),
    92              this, SLOT (onTextEdited (const QString &)));
    9390    connect (mCopyAction, SIGNAL (triggered (bool)), this, SLOT (copyToClipboard()));
     91
     92    /* Editable by default */
     93    setEditable (true);
    9494
    9595    /* Applying language settings */
    9696    retranslateUi();
    97 
    98     /* Installing necessary event filters */
    99     lineEdit()->installEventFilter (this);
    10097}
    10198
     
    113110{
    114111    return mMode;
     112}
     113
     114void VBoxFilePathSelectorWidget::setEditable (bool aOn)
     115{
     116    mIsEditable = aOn;
     117
     118    if (mIsEditable)
     119    {
     120        QComboBox::setEditable (true);
     121        Assert (lineEdit());
     122        connect (lineEdit(), SIGNAL (textEdited (const QString &)),
     123                 this, SLOT (onTextEdited (const QString &)));
     124
     125        /* Installing necessary event filters */
     126        lineEdit()->installEventFilter (this);
     127    }else
     128    {
     129        if (lineEdit())
     130        {
     131            /* Installing necessary event filters */
     132            lineEdit()->installEventFilter (this);
     133            disconnect (lineEdit(), SIGNAL (textEdited (const QString &)),
     134                        this, SLOT (onTextEdited (const QString &)));
     135        }
     136        QComboBox::setEditable (false);
     137    }
     138}
     139
     140bool VBoxFilePathSelectorWidget::isEditable() const
     141{
     142    return mIsEditable;
    115143}
    116144
     
    132160}
    133161
     162void VBoxFilePathSelectorWidget::resetModified()
     163{
     164    mModified = false;
     165}
     166
    134167bool VBoxFilePathSelectorWidget::isModified() const
    135168{
    136169    return mModified;
     170}
     171
     172void VBoxFilePathSelectorWidget::setFileDialogTitle (const QString& aTitle)
     173{
     174    mFileDialogTitle = aTitle;
     175}
     176
     177QString VBoxFilePathSelectorWidget::fileDialogTitle() const
     178{
     179    return mFileDialogTitle;
     180}
     181
     182void VBoxFilePathSelectorWidget::setFileFilters (const QString& aFilters)
     183{
     184    mFileFilters = aFilters;
     185}
     186
     187QString VBoxFilePathSelectorWidget::fileFilters() const
     188{
     189    return mFileFilters;
    137190}
    138191
     
    178231    if (isPathSelected())
    179232    {
    180         mIsEditableMode = true;
     233        if (mIsEditable)
     234            mIsEditableMode = true;
    181235        if (aEvent->reason() == Qt::MouseFocusReason)
    182236            mIsMouseAwaited = true;
     
    305359    if (!mModified && mPath != oldPath)
    306360        mModified = true;
     361    emit pathChanged (aPath);
    307362}
    308363
     
    317372    /* Open existing file or directory. */
    318373    QString path = mMode == Mode_File ?
    319         VBoxGlobal::getOpenFileName (initDir, QString::null, parentWidget(), QString::null) :
    320         VBoxGlobal::getExistingDirectory (initDir, parentWidget());
     374        VBoxGlobal::getOpenFileName (initDir, mFileFilters, parentWidget(), mFileDialogTitle) :
     375        VBoxGlobal::getExistingDirectory (initDir, parentWidget(), mFileDialogTitle);
    321376    if (path.isNull())
    322377        return;
     
    399454void VBoxFilePathSelectorWidget::refreshText()
    400455{
    401     if (mIsEditableMode)
     456    if (mIsEditable && mIsEditableMode)
    402457    {
    403458        /* Cursor positioning variables */
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