VirtualBox

Ignore:
Timestamp:
Feb 22, 2007 11:26:33 AM (18 years ago)
Author:
vboxsync
Message:

1758: Implement Shared Folders UI

  1. Edit button implemented for Shared Folders dialog.
  2. Tooltips added for Shared Folders Dialog buttons.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h

    r973 r1024  
    6969        return aIndex >= 0 && aIndex < (int)mTextList.size() ?
    7070            mTextList [aIndex] : QString::null;
     71    }
     72
     73    void updateText (int aColumn, const QString &aText)
     74    {
     75        if (aColumn >= 0 && aColumn < (int)mTextList.size())
     76            mTextList [aColumn] = aText;
    7177    }
    7278
     
    148154public:
    149155
    150     VBoxAddSFDialog (QWidget *aParent) :
     156    enum DialogType { AddDType, EditDType };
     157
     158    VBoxAddSFDialog (QWidget *aParent, VBoxAddSFDialog::DialogType aType) :
    151159        QDialog (aParent, "VBoxAddSFDialog", true /* modal */),
    152160        mLePath (0), mLeName (0)
    153161    {
    154         setCaption (tr ("Add Share"));
     162        switch (aType)
     163        {
     164            case AddDType:
     165                setCaption (tr ("Add Share"));
     166                break;
     167            case EditDType:
     168                setCaption (tr ("Edit Share"));
     169                break;
     170            default:
     171                AssertMsgFailed (("Incorrect SF Dialog type\n"));
     172        }
    155173        QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10, "mainLayout");
    156174
     
    199217
    200218    QString getPath() { return mLePath->text(); }
    201 
    202219    QString getName() { return mLeName->text(); }
     220
     221    void setPath (const QString &aPath) { mLePath->setText (aPath); }
     222    void setName (const QString &aName) { mLeName->setText (aName); }
    203223
    204224private slots:
     
    262282    tbAdd->setIconSet (VBoxGlobal::iconSet ("select_file_16px.png",
    263283                                            "select_file_dis_16px.png"));
     284    tbEdit->setIconSet (VBoxGlobal::iconSet ("global_settings_16px.png",
     285                                             "global_settings_diasbled_16px.png"));
    264286    tbRemove->setIconSet (VBoxGlobal::iconSet ("eraser_16px.png",
    265287                                               "eraser_disabled_16px.png"));
     288    QToolTip::add (tbAdd, tr ("Add new shared folder"));
     289    QToolTip::add (tbEdit, tr ("Edit selected shared folder"));
     290    QToolTip::add (tbRemove, tr ("Remove selected shared folder"));
    266291    connect (tbAdd, SIGNAL (clicked()), this, SLOT (tbAddPressed()));
     292    connect (tbEdit, SIGNAL (clicked()), this, SLOT (tbEditPressed()));
    267293    connect (tbRemove, SIGNAL (clicked()), this, SLOT (tbRemovePressed()));
    268294    connect (listView, SIGNAL (currentChanged (QListViewItem *)),
     
    483509{
    484510    /* Invoke Add-Box Dialog */
    485     VBoxAddSFDialog dlg (this);
     511    VBoxAddSFDialog dlg (this, VBoxAddSFDialog::AddDType);
    486512    if (dlg.exec() != QDialog::Accepted)
    487513        return;
     
    503529}
    504530
     531void VBoxSharedFoldersSettings::tbEditPressed()
     532{
     533    /* Check selected item */
     534    QListViewItem *selectedItem = listView->selectedItem();
     535    VBoxRichListItem *item = 0;
     536    if (selectedItem->rtti() == VBoxRichListItem::QIRichListItemId)
     537        item = static_cast<VBoxRichListItem*> (selectedItem);
     538    Assert (item);
     539    /* Invoke Add-Box Dialog */
     540    VBoxAddSFDialog dlg (this, VBoxAddSFDialog::EditDType);
     541    dlg.setPath (item->getText (1));
     542    dlg.setName (item->getText (0));
     543    if (dlg.exec() != QDialog::Accepted)
     544        return;
     545    QString name = dlg.getName();
     546    QString path = dlg.getPath();
     547    /* Shared folder's name & path could not be empty */
     548    Assert (!name.isEmpty() && !path.isEmpty());
     549    /* Updating an edited listview item */
     550    item->updateText (1, path);
     551    item->updateText (0, name);
     552    mIsListViewChanged = true;
     553}
     554
    505555void VBoxSharedFoldersSettings::tbRemovePressed()
    506556{
     
    530580    if (aItem && aItem->isSelectable() && listView->selectedItem() != aItem)
    531581        listView->setSelected (aItem, true);
    532     bool removeEnabled = aItem && aItem->parent() &&
    533                          isEditable (aItem->parent()->text (2));
    534582    bool addEnabled = aItem &&
    535583                      (isEditable (aItem->text (2)) ||
    536584                       aItem->parent() && isEditable (aItem->parent()->text (2)));
     585    bool removeEnabled = aItem && aItem->parent() &&
     586                         isEditable (aItem->parent()->text (2));
     587    tbAdd->setEnabled (addEnabled);
     588    tbEdit->setEnabled (removeEnabled);
    537589    tbRemove->setEnabled (removeEnabled);
    538     tbAdd->setEnabled (addEnabled);
    539590}
    540591
     
    554605
    555606#include "VBoxSharedFoldersSettings.ui.moc"
    556 
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