VirtualBox

Changeset 3802 in vbox for trunk/src


Ignore:
Timestamp:
Jul 24, 2007 9:12:30 AM (17 years ago)
Author:
vboxsync
Message:

2130: Improve Shared Folders UI:

Shared Folders Dialog improvements done:

  1. Dialog made modal (all the title buttons made like in non-modal VDM).
  2. [Help]....[Ok][Cancel] dialog's button configuration.
  3. Permanent shared folder could be created during VM session runtime (through the discussed check-box).
  4. Edit action opens on list-view's item double-click.

Note: Also all the GUI_ constants from the different *.cpp files moved into VBoxDefs.cpp

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r3610 r3802  
    131131        src/QIMessageBox.cpp \
    132132        src/QIRichLabel.cpp \
     133        src/VBoxDefs.cpp \
    133134        src/VBoxGlobalSettings.cpp \
    134135        src/VBoxGlobal.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r3762 r3802  
    144144    void devicesUnmountDVD();
    145145    void devicesSwitchVrdp (bool);
    146     void devicesToggleSFDialog (bool);
     146    void devicesOpenSFDialog();
    147147    void devicesInstallGuestAdditions();
    148148
     
    157157    void activateNetworkMenu (int aId);
    158158    void switchUSB (int aId);
    159     void activateSFMenu();
    160159
    161160    void statusTipChanged (const QString &);
     
    326325public:
    327326
    328     VBoxSFDialog (QWidget*, CSession&, QAction*);
    329     ~VBoxSFDialog();
     327    VBoxSFDialog (QWidget*, CSession&);
    330328
    331329protected slots:
    332330
    333331    virtual void accept();
    334     virtual void suicide (bool);
    335332
    336333protected:
     
    342339    VBoxSharedFoldersSettings *mSettings;
    343340    CSession &mSession;
    344     QAction *mAction;
    345341};
    346342
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r3674 r3802  
    146146#endif
    147147    };
     148
     149    static const char* GUI_LastWindowPosition;
     150    static const char* GUI_LastWindowPosition_Max;
     151    static const char* GUI_Fullscreen;
     152    static const char* GUI_Seamless;
     153    static const char* GUI_AutoresizeGuest;
     154    static const char* GUI_FirstRun;
     155    static const char* GUI_SaveMountedAtRuntime;
     156    static const char* GUI_LastCloseAction;
     157    static const char* GUI_SuppressMessages;
     158    static const char* GUI_PermanentSharedFoldersAtRuntime;
    148159};
    149160
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r3801 r3802  
    340340
    341341    devicesSFDialogAction = new QAction (runningActions, "devicesSFDialogAction");
    342     devicesSFDialogAction->setToggleAction (true);
    343342    devicesSFDialogAction->setIconSet (VBoxGlobal::iconSet ("shared_folder_16px.png",
    344343                                                            "shared_folder_disabled_16px.png"));
     
    583582    connect (devicesUnmountDVDAction, SIGNAL(activated()), this, SLOT(devicesUnmountDVD()));
    584583    connect (devicesSwitchVrdpAction, SIGNAL(toggled (bool)), this, SLOT(devicesSwitchVrdp (bool)));
    585     connect (devicesSFDialogAction, SIGNAL(toggled (bool)), this, SLOT(devicesToggleSFDialog (bool)));
     584    connect (devicesSFDialogAction, SIGNAL(activated()), this, SLOT(devicesOpenSFDialog()));
    586585    connect (devicesInstallGuestToolsAction, SIGNAL(activated()), this, SLOT(devicesInstallGuestAdditions()));
    587586
     
    596595    connect (devicesMountDVDMenu, SIGNAL(activated(int)), this, SLOT(captureDVD(int)));
    597596    connect (devicesUSBMenu, SIGNAL(activated(int)), this, SLOT(switchUSB(int)));
    598     connect (devicesSharedFolders, SIGNAL(activated(int)), this, SLOT(activateSFMenu()));
     597    connect (devicesSharedFolders, SIGNAL(activated(int)), this, SLOT(devicesOpenSFDialog()));
    599598    connect (devicesNetworkMenu, SIGNAL(activated(int)), this, SLOT(activateNetworkMenu(int)));
    600599
     
    699698/////////////////////////////////////////////////////////////////////////////
    700699
    701 static const char *GUI_LastWindowPosition = "GUI/LastWindowPostion";
    702 static const char *GUI_LastWindowPosition_Max = "max";
    703 
    704 static const char *GUI_Fullscreen = "GUI/Fullscreen";
    705 static const char *GUI_Seamless = "GUI/Seamless";
    706 static const char *GUI_AutoresizeGuest = "GUI/AutoresizeGuest";
    707 extern const char *GUI_FirstRun = "GUI/FirstRun";
    708 extern const char *GUI_SaveMountedAtRuntime = "GUI/SaveMountedAtRuntime";
    709 
    710700/**
    711701 *  Opens a new console view to interact with a given VM.
     
    751741    /* restore the position of the window and some options */
    752742    {
    753         QString str = cmachine.GetExtraData (GUI_Fullscreen);
     743        QString str = cmachine.GetExtraData (VBoxDefs::GUI_Fullscreen);
    754744        if (str == "on")
    755745            vmFullscreenAction->setOn (true);
    756746
    757747        vmSeamlessAction->setEnabled (false);
    758         str = cmachine.GetExtraData (GUI_Seamless);
     748        str = cmachine.GetExtraData (VBoxDefs::GUI_Seamless);
    759749        if (str == "on")
    760750            vmSeamlessAction->setOn (true);
    761751
    762         str = cmachine.GetExtraData (GUI_AutoresizeGuest);
     752        str = cmachine.GetExtraData (VBoxDefs::GUI_AutoresizeGuest);
    763753        if (str != "off")
    764754            vmAutoresizeGuestAction->setOn (true);
    765755
    766         str = cmachine.GetExtraData (GUI_FirstRun);
     756        str = cmachine.GetExtraData (VBoxDefs::GUI_FirstRun);
    767757        if (str == "yes")
    768758            mIsFirstTimeStarted = true;
    769759        else if (!str.isEmpty())
    770             cmachine.SetExtraData (GUI_FirstRun, QString::null);
    771 
    772         str = cmachine.GetExtraData (GUI_SaveMountedAtRuntime);
     760            cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);
     761
     762        str = cmachine.GetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime);
    773763        if (str == "no")
    774764            mIsAutoSaveMedia = false;
    775765
    776         str = cmachine.GetExtraData (GUI_LastWindowPosition);
     766        str = cmachine.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
    777767
    778768        QRect ar = QApplication::desktop()->availableGeometry (this);
     
    787777            h = str.section (',', 3, 3).toInt (&ok);
    788778        if (ok)
    789             max = str.section (',', 4, 4) == GUI_LastWindowPosition_Max;
     779            max = str.section (',', 4, 4) == VBoxDefs::GUI_LastWindowPosition_Max;
    790780        if (ok)
    791781        {
     
    950940        /* Remove GUI_FirstRun extra data key from the machine settings
    951941         * file after showing the wizard once. */
    952         cmachine.SetExtraData (GUI_FirstRun, QString::null);
     942        cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);
    953943    }
    954944
     
    10471037        if (isMaximized() || (mIsFullscreen && was_max)
    10481038                          || (mIsSeamless && was_max))
    1049             winPos += QString (",%1").arg (GUI_LastWindowPosition_Max);
    1050 
    1051         machine.SetExtraData (GUI_LastWindowPosition, winPos);
    1052 
    1053         machine.SetExtraData (GUI_Fullscreen,
     1039            winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowPosition_Max);
     1040
     1041        machine.SetExtraData (VBoxDefs::GUI_LastWindowPosition, winPos);
     1042
     1043        machine.SetExtraData (VBoxDefs::GUI_Fullscreen,
    10541044                              vmFullscreenAction->isOn() ? "on" : "off");
    1055         machine.SetExtraData (GUI_Seamless,
     1045        machine.SetExtraData (VBoxDefs::GUI_Seamless,
    10561046                              vmSeamlessAction->isOn() ? "on" : "off");
    1057         machine.SetExtraData (GUI_AutoresizeGuest,
     1047        machine.SetExtraData (VBoxDefs::GUI_AutoresizeGuest,
    10581048                              vmAutoresizeGuestAction->isOn() ? "on" : "off");
    10591049    }
     
    11721162    LogFlowFuncEnter();
    11731163
    1174     static const char *GUI_LastCloseAction = "GUI/LastCloseAction";
    11751164    static const char *Save = "save";
    11761165    static const char *PowerOff = "powerOff";
     
    12341223            /* read the last user's choice for the given VM */
    12351224            QStringList lastAction = QStringList::split (',',
    1236                 cmachine.GetExtraData (GUI_LastCloseAction));
     1225                cmachine.GetExtraData (VBoxDefs::GUI_LastCloseAction));
    12371226            AssertWrapperOk (cmachine);
    12381227            if (lastAction [0] == PowerOff)
     
    13251314                    if (dlg.cbDiscardCurState->isChecked())
    13261315                        (lastAction += ",") += DiscardCurState;
    1327                     cmachine.SetExtraData (GUI_LastCloseAction, lastAction);
     1316                    cmachine.SetExtraData (VBoxDefs::GUI_LastCloseAction, lastAction);
    13281317                    AssertWrapperOk (cmachine);
    13291318                }
     
    22932282}
    22942283
    2295 void VBoxConsoleWnd::devicesToggleSFDialog (bool aOn)
     2284void VBoxConsoleWnd::devicesOpenSFDialog()
    22962285{
    22972286    if (!console) return;
    22982287
    2299     if (aOn)
    2300         (new VBoxSFDialog (console, csession, devicesSFDialogAction))->show();
     2288    VBoxSFDialog dlg (console, csession);
     2289    dlg.exec();
    23012290}
    23022291
     
    26172606        }
    26182607    }
    2619 }
    2620 
    2621 /**
    2622  *  Show Shared Folders list.
    2623  */
    2624 void VBoxConsoleWnd::activateSFMenu()
    2625 {
    2626     if (!devicesSFDialogAction->isOn())
    2627         devicesSFDialogAction->setOn (true);
    26282608}
    26292609
     
    29402920#endif
    29412921
    2942 VBoxSFDialog::VBoxSFDialog (QWidget  *aParent, CSession &aSession, QAction *aAction)
    2943     : QDialog (aParent, "VBoxSFDialog", false /* modal */,
    2944                WStyle_Customize | WStyle_Title | WStyle_SysMenu |
    2945                WStyle_MinMax | WDestructiveClose)
    2946     , mSettings (0), mSession (aSession), mAction (aAction)
    2947 {
    2948     /* Setup Dialog's title */
     2922VBoxSFDialog::VBoxSFDialog (QWidget  *aParent, CSession &aSession)
     2923    : QDialog (aParent, "VBoxSFDialog", true /* modal */,
     2924               WType_Dialog | WShowModal)
     2925    , mSettings (0), mSession (aSession)
     2926{
     2927    /* Setup Dialog's options */
    29492928    setCaption (tr ("Shared Folders"));
    29502929    setIcon (QPixmap::fromMimeSource ("select_file_16px.png"));
     2930    setSizeGripEnabled (true);
    29512931
    29522932    /* Setup main dialog's layout */
     
    29552935    /* Setup settings layout */
    29562936    mSettings = new VBoxSharedFoldersSettings (this, "mSettings");
    2957     mSettings->setDialogType (VBoxSharedFoldersSettings::ConsoleType);
     2937    mSettings->setDialogType (VBoxSharedFoldersSettings::MachineType |
     2938                              VBoxSharedFoldersSettings::ConsoleType);
    29582939    mSettings->getFromMachine (aSession.GetMachine());
    29592940    mSettings->getFromConsole (aSession.GetConsole());
     
    29622943    /* Setup button's layout */
    29632944    QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout");
     2945    QPushButton *pbHelp = new QPushButton (tr ("Help"), this, "pbHelp");
     2946    QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    29642947    QPushButton *pbOk = new QPushButton (tr ("OK"), this, "pbOk");
    2965     QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    29662948    QPushButton *pbCancel = new QPushButton (tr ("Cancel"), this, "pbCancel");
     2949    connect (pbHelp, SIGNAL (clicked()), &vboxProblem(), SLOT (showHelpHelpDialog()));
    29672950    connect (pbOk, SIGNAL (clicked()), this, SLOT (accept()));
    29682951    connect (pbCancel, SIGNAL (clicked()), this, SLOT (reject()));
     2952    buttonLayout->addWidget (pbHelp);
     2953    buttonLayout->addItem (spacer);
    29692954    buttonLayout->addWidget (pbOk);
    2970     buttonLayout->addItem (spacer);
    29712955    buttonLayout->addWidget (pbCancel);
    29722956
    2973     /* Setup destruction handler */
    2974     connect (mAction, SIGNAL (toggled (bool)), this, SLOT (suicide (bool)));
    2975 }
    2976 
    2977 VBoxSFDialog::~VBoxSFDialog()
    2978 {
    2979     mAction->setOn (false);
     2957    /* Setup the default push button */
     2958    pbOk->setAutoDefault (true);
     2959    pbOk->setDefault (true);
    29802960}
    29812961
     
    29832963{
    29842964    mSettings->putBackToConsole();
     2965    mSettings->putBackToMachine();
     2966    CMachine machine = mSession.GetMachine();
     2967    machine.SaveSettings();
     2968    if (!machine.isOk())
     2969        vboxProblem().cannotSaveMachineSettings (machine);
    29852970    QDialog::accept();
    29862971}
    29872972
    2988 void VBoxSFDialog::suicide (bool aNo)
    2989 {
    2990     if (!aNo) close();
    2991 }
    2992 
    29932973void VBoxSFDialog::showEvent (QShowEvent *aEvent)
    29942974{
     2975    resize (600, 500);
     2976    VBoxGlobal::centerWidget (this, parentWidget());
     2977    setMinimumWidth (400);
    29952978    QDialog::showEvent (aEvent);
    2996     setMinimumWidth (400);
    2997     VBoxGlobal::centerWidget (this, parentWidget());
    2998 }
     2979}
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r3718 r3802  
    196196}
    197197
    198 
    199 static const char *GUI_SuppressMessages = "GUI/SuppressMessages";
    200198
    201199/** @class VBoxProblemReporter
     
    291289    {
    292290        vbox = vboxGlobal().virtualBox();
    293         msgs = QStringList::split (',', vbox.GetExtraData (GUI_SuppressMessages));
     291        msgs = QStringList::split (',', vbox.GetExtraData (VBoxDefs::GUI_SuppressMessages));
    294292        if (msgs.findIndex (autoConfirmId) >= 0) {
    295293            int rc = AutoConfirmed;
     
    352350        {
    353351            msgs << autoConfirmId;
    354             vbox.SetExtraData (GUI_SuppressMessages, msgs.join (","));
     352            vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, msgs.join (","));
    355353        }
    356354    }
     
    17451743{
    17461744    CVirtualBox vbox = vboxGlobal().virtualBox();
    1747     vbox.SetExtraData (GUI_SuppressMessages, QString::null);
     1745    vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, QString::null);
    17481746}
    17491747
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r3450 r3802  
    4848#include <qvbox.h>
    4949
    50 
    51 static const char *GUI_LastWindowPosition = "GUI/LastWindowPostion";
    52 static const char *GUI_LastWindowPosition_Max = "max";
    5350
    5451// VBoxVMDetailsView class
     
    529526    {
    530527        CVirtualBox vbox = vboxGlobal().virtualBox();
    531         QString winPos = vbox.GetExtraData (GUI_LastWindowPosition);
     528        QString winPos = vbox.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
    532529
    533530        QRect ar = QApplication::desktop()->availableGeometry (pos());
     
    542539            h = winPos.section (',', 3, 3).toInt (&ok);
    543540        if (ok)
    544             max = winPos.section (',', 4, 4) == GUI_LastWindowPosition_Max;
     541            max = winPos.section (',', 4, 4) == VBoxDefs::GUI_LastWindowPosition_Max;
    545542        if (ok)
    546543        {
     
    621618                                 .arg (normal_size.height());
    622619        if (isMaximized())
    623             winPos += QString (",%1").arg (GUI_LastWindowPosition_Max);
    624 
    625         vbox.SetExtraData (GUI_LastWindowPosition, winPos);
     620            winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowPosition_Max);
     621
     622        vbox.SetExtraData (VBoxDefs::GUI_LastWindowPosition, winPos);
    626623    }
    627624}
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewVMWzd.ui.h

    r3528 r3802  
    3333*****************************************************************************/
    3434
    35 /* defined in VBoxConsoleWnd.cpp */
    36 extern const char *GUI_FirstRun;
    3735
    3836/**
     
    317315        }
    318316        if (uuidHD.isNull() || !chd.isNull())
    319             cmachine.SetExtraData (GUI_FirstRun, "yes");
     317            cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, "yes");
    320318    }
    321319
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui

    r2988 r3802  
    4040    </property>
    4141    <property name="caption">
    42         <string>VBoxUSBFilterSettings</string>
     42        <string>VBoxSharedFoldersSettings</string>
    4343        <comment>don't translate</comment>
    4444    </property>
     
    190190    </vbox>
    191191</widget>
     192<connections>
     193    <connection>
     194        <sender>listView</sender>
     195        <signal>doubleClicked(QListViewItem*)</signal>
     196        <receiver>VBoxSharedFoldersSettings</receiver>
     197        <slot>processDoubleClick(QListViewItem*)</slot>
     198    </connection>
     199</connections>
    192200<includes>
    193201    <include location="local" impldecl="in declaration">VBoxGlobal.h</include>
     
    200208</includes>
    201209<variables>
    202     <variable access="public">enum SFDialogType { WrongType = 0, GlobalType = 1, MachineType = 2, ConsoleType = 3 };</variable>
     210    <variable access="public">enum SFDialogType { WrongType, GlobalType = 0x01, MachineType = 0x02, ConsoleType = 0x04 };</variable>
    203211    <variable access="private">bool mIsListViewChanged;</variable>
    204     <variable access="private">SFDialogType mDialogType;</variable>
     212    <variable access="private">int mDialogType;</variable>
    205213    <variable access="private">CMachine mMachine;</variable>
    206214    <variable access="private">CConsole mConsole;</variable>
     
    212220    <slot>processOnItem( QListViewItem* )</slot>
    213221    <slot>processCurrentChanged( QListViewItem* )</slot>
     222    <slot>processDoubleClick( QListViewItem* )</slot>
    214223</slots>
    215224<functions>
    216225    <function access="private">init()</function>
    217     <function>setDialogType( VBoxSharedFoldersSettings::SFDialogType )</function>
     226    <function>setDialogType( int )</function>
    218227    <function access="private">removeSharedFolder( const QString &amp;, const QString &amp;, VBoxSharedFoldersSettings::SFDialogType )</function>
    219228    <function access="private">createSharedFolder( const QString &amp;, const QString &amp;, VBoxSharedFoldersSettings::SFDialogType )</function>
     
    226235    <function>putBackToConsole()</function>
    227236    <function access="private">putBackTo( CSharedFolderEnumerator &amp;, QListViewItem* )</function>
     237    <function access="private" returnType="QListViewItem*">searchRoot( bool )</function>
    228238    <function access="private" returnType="bool">isEditable( const QString &amp; )</function>
    229239</functions>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h

    r2981 r3802  
    154154public:
    155155
    156     enum DialogType { AddDType, EditDType };
    157 
    158     VBoxAddSFDialog (QWidget *aParent, VBoxAddSFDialog::DialogType aType) :
     156    enum DialogType { AddDialogType, EditDialogType };
     157
     158    VBoxAddSFDialog (QWidget *aParent, VBoxAddSFDialog::DialogType aType,
     159                     bool aEnableSelector /* for "permanent" checkbox */) :
    159160        QDialog (aParent, "VBoxAddSFDialog", true /* modal */),
    160         mLePath (0), mLeName (0)
     161        mLePath (0), mLeName (0), mCbPermanent (0)
    161162    {
    162163        switch (aType)
    163164        {
    164             case AddDType:
     165            case AddDialogType:
    165166                setCaption (tr ("Add Share"));
    166167                break;
    167             case EditDType:
     168            case EditDialogType:
    168169                setCaption (tr ("Edit Share"));
    169170                break;
     
    174175
    175176        /* Setup Input layout */
    176         QGridLayout *inputLayout = new QGridLayout (mainLayout, 2, 3, 10, "inputLayout");
     177        QGridLayout *inputLayout = new QGridLayout (mainLayout, 3, 3, 10, "inputLayout");
    177178        QLabel *lbPath = new QLabel (tr ("Folder Path"), this);
    178179        mLePath = new QLineEdit (this);
     
    199200        inputLayout->addMultiCellWidget (mLeName, 1, 1, 1, 2);
    200201
     202        if (aEnableSelector)
     203        {
     204            mCbPermanent = new QCheckBox ("&Make Permanent", this);
     205            mCbPermanent->setChecked (true);
     206            inputLayout->addMultiCellWidget (mCbPermanent, 2, 2, 0, 2);
     207        }
     208
    201209        /* Setup Button layout */
    202210        QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10, "buttonLayout");
     
    219227    QString getPath() { return mLePath->text(); }
    220228    QString getName() { return mLeName->text(); }
     229    bool getPermanent()
     230    {
     231        return mCbPermanent ? mCbPermanent->isChecked() : true;
     232    }
    221233
    222234    void setPath (const QString &aPath) { mLePath->setText (aPath); }
    223235    void setName (const QString &aName) { mLeName->setText (aName); }
     236    void setPermanent (bool aPermanent)
     237    {
     238        if (mCbPermanent)
     239        {
     240            mCbPermanent->setChecked (aPermanent);
     241            mCbPermanent->setEnabled (!aPermanent);
     242        }
     243    }
    224244
    225245private slots:
     
    272292    QLineEdit *mLePath;
    273293    QLineEdit *mLeName;
     294    QCheckBox *mCbPermanent;
    274295};
    275296
     
    301322}
    302323
    303 void VBoxSharedFoldersSettings::setDialogType (
    304      VBoxSharedFoldersSettings::SFDialogType aType)
     324void VBoxSharedFoldersSettings::setDialogType (int aType)
    305325{
    306326    mDialogType = aType;
     
    456476
    457477    /* This function is only available for MachineType dialog */
    458     Assert (mDialogType == MachineType);
     478    Assert (mDialogType & MachineType);
    459479    /* Searching for MachineType item's root */
    460480    QListViewItem *root = listView->findItem (QString::number (MachineType), 2);
     
    470490
    471491    /* This function is only available for ConsoleType dialog */
    472     Assert (mDialogType == ConsoleType);
     492    Assert (mDialogType & ConsoleType);
    473493    /* Searching for ConsoleType item's root */
    474494    QListViewItem *root = listView->findItem (QString::number (ConsoleType), 2);
     
    507527
    508528
     529QListViewItem* VBoxSharedFoldersSettings::searchRoot (bool aIsPermanent)
     530{
     531    if (!aIsPermanent)
     532        return listView->findItem (QString::number (ConsoleType), 2);
     533    else if (mDialogType & MachineType)
     534        return listView->findItem (QString::number (MachineType), 2);
     535    else
     536        return listView->findItem (QString::number (GlobalType), 2);
     537}
     538
    509539void VBoxSharedFoldersSettings::tbAddPressed()
    510540{
    511541    /* Invoke Add-Box Dialog */
    512     VBoxAddSFDialog dlg (this, VBoxAddSFDialog::AddDType);
     542    VBoxAddSFDialog dlg (this, VBoxAddSFDialog::AddDialogType,
     543                         mDialogType & ConsoleType);
    513544    if (dlg.exec() != QDialog::Accepted)
    514545        return;
    515546    QString name = dlg.getName();
    516547    QString path = dlg.getPath();
     548    bool isPermanent = dlg.getPermanent();
    517549    /* Shared folder's name & path could not be empty */
    518550    Assert (!name.isEmpty() && !path.isEmpty());
    519551    /* Searching root for the new listview item */
    520     QListViewItem *root = listView->findItem (QString::number (mDialogType), 2);
     552    QListViewItem *root = searchRoot (isPermanent);
    521553    Assert (root);
    522554    /* Appending a new listview item to the root */
    523     VBoxRichListItem *item = new VBoxRichListItem (VBoxRichListItem::EllipsisFile,
    524                                                    root, name, path);
     555    VBoxRichListItem *item = new VBoxRichListItem (
     556        VBoxRichListItem::EllipsisFile, root, name, path);
     557    /* Make the created item selected */
    525558    listView->ensureItemVisible (item);
    526559    listView->setCurrentItem (item);
    527560    processCurrentChanged (item);
    528561    listView->setFocus();
     562
    529563    mIsListViewChanged = true;
    530564}
     
    534568    /* Check selected item */
    535569    QListViewItem *selectedItem = listView->selectedItem();
    536     VBoxRichListItem *item = 0;
    537     if (selectedItem->rtti() == VBoxRichListItem::QIRichListItemId)
    538         item = static_cast<VBoxRichListItem*> (selectedItem);
     570    VBoxRichListItem *item =
     571        selectedItem->rtti() == VBoxRichListItem::QIRichListItemId ?
     572        static_cast<VBoxRichListItem*> (selectedItem) : 0;
    539573    Assert (item);
    540     /* Invoke Add-Box Dialog */
    541     VBoxAddSFDialog dlg (this, VBoxAddSFDialog::EditDType);
     574    Assert (item->parent());
     575    /* Invoke Edit-Box Dialog */
     576    VBoxAddSFDialog dlg (this, VBoxAddSFDialog::EditDialogType,
     577                         mDialogType & ConsoleType);
    542578    dlg.setPath (item->getText (1));
    543579    dlg.setName (item->getText (0));
     580    dlg.setPermanent ((SFDialogType)item->parent()->text (2).toInt()
     581                      != ConsoleType);
    544582    if (dlg.exec() != QDialog::Accepted)
    545583        return;
    546584    QString name = dlg.getName();
    547585    QString path = dlg.getPath();
     586    bool isPermanent = dlg.getPermanent();
    548587    /* Shared folder's name & path could not be empty */
    549588    Assert (!name.isEmpty() && !path.isEmpty());
     589    /* Searching new root for the selected listview item */
     590    QListViewItem *root = searchRoot (isPermanent);
     591    Assert (root);
    550592    /* Updating an edited listview item */
    551593    item->updateText (1, path);
    552594    item->updateText (0, name);
     595    if (item->parent() != root)
     596    {
     597        /* Move the selected item into new location */
     598        item->parent()->takeItem (item);
     599        root->insertItem (item);
     600
     601        /* Make the created item selected */
     602        listView->ensureItemVisible (item);
     603        listView->setCurrentItem (item);
     604        processCurrentChanged (item);
     605        listView->setFocus();
     606    }
     607
    553608    mIsListViewChanged = true;
    554609}
     
    591646}
    592647
     648void VBoxSharedFoldersSettings::processDoubleClick (QListViewItem *aItem)
     649{
     650    bool editEnabled = aItem && aItem->parent() &&
     651        isEditable (aItem->parent()->text (2));
     652    if (editEnabled)
     653        tbEditPressed();
     654}
     655
    593656bool VBoxSharedFoldersSettings::isEditable (const QString &aKey)
    594657{
     
    601664    if (!type)
    602665        AssertMsgFailed (("Incorrect listview item key value\n"));
    603     return type == mDialogType;
     666    return mDialogType & type;
    604667}
    605668
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r3490 r3802  
    2929** place of a destructor.
    3030*****************************************************************************/
    31 
    32 
    33 extern const char *GUI_SaveMountedAtRuntime;
    34 extern const char *GUI_FirstRun;
    3531
    3632
     
    15241520
    15251521    /* other features */
    1526     QString saveRtimeImages = cmachine.GetExtraData (GUI_SaveMountedAtRuntime);
     1522    QString saveRtimeImages = cmachine.GetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime);
    15271523    chbRememberMedia->setChecked (saveRtimeImages != "no");
    15281524
     
    18671863
    18681864    /* other features */
    1869     cmachine.SetExtraData (GUI_SaveMountedAtRuntime,
     1865    cmachine.SetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime,
    18701866                           chbRememberMedia->isChecked() ? "yes" : "no");
    18711867
     
    19801976     * and/or disk configuration were changed */
    19811977    if (mResetFirstRunFlag)
    1982         cmachine.SetExtraData (GUI_FirstRun, QString::null);
     1978        cmachine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);
    19831979
    19841980    /* audio */
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