VirtualBox

Changeset 9260 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 30, 2008 4:17:27 PM (17 years ago)
Author:
vboxsync
Message:

Fe/Qt4: Shared Folder VMSettings got it's toolbar & context menu, Fixed tab-order for VRDP VMSettings.

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

Legend:

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

    r9253 r9260  
    2727#include "QIWithRetranslateUI.h"
    2828
    29 /* Qt includes */
    3029#include <QDialog>
     30
     31class VBoxVMSettingsDlg;
     32class SFTreeViewItem;
     33class QIDialogButtonBox;
    3134
    3235class QLineEdit;
    3336class QPushButton;
    3437class QCheckBox;
    35 class SFTreeViewItem;
    36 
    37 class QIDialogButtonBox;
    3838
    3939enum SFDialogType
     
    5454public:
    5555
     56    VBoxVMSettingsSF (QWidget *aParent = 0, int aType = WrongType);
     57
    5658    static void getFromMachineEx (const CMachine &aMachine,
    57                                   QWidget *aParent);
     59                                  QWidget *aParent,
     60                                  VBoxVMSettingsDlg *aDlg);
    5861    static void putBackToMachineEx();
    59 
    60     VBoxVMSettingsSF (QWidget *aParent = 0, int aType = WrongType);
    6162
    6263    int dialogType() { return mDialogType; }
     
    7677private slots:
    7778
    78     void tbAddPressed();
    79     void tbEditPressed();
    80     void tbRemovePressed();
     79    void addTriggered();
     80    void edtTriggered();
     81    void delTriggered();
    8182
    8283    void processCurrentChanged (QTreeWidgetItem *aCurrentItem,
    8384                                QTreeWidgetItem *aPreviousItem = 0);
    8485    void processDoubleClick (QTreeWidgetItem *aItem, int aColumn);
     86    void showContextMenu (const QPoint &aPos);
    8587
    8688    void adjustList();
     
    107109    static VBoxVMSettingsSF *mSettings;
    108110
    109     int      mDialogType;
    110     bool     mIsListViewChanged;
    111     CMachine mMachine;
    112     CConsole mConsole;
    113     QString  mTrFull;
    114     QString  mTrReadOnly;
     111    int       mDialogType;
     112    QMenu    *mMenu;
     113    QAction  *mNewAction;
     114    QAction  *mEdtAction;
     115    QAction  *mDelAction;
     116    bool      mIsListViewChanged;
     117    CMachine  mMachine;
     118    CConsole  mConsole;
     119    QString   mTrFull;
     120    QString   mTrReadOnly;
    115121};
    116122
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsSF.cpp

    r9253 r9260  
    2222
    2323#include "VBoxVMSettingsSF.h"
     24#include "VBoxVMSettingsDlg.h"
    2425#include "VBoxGlobal.h"
    2526#include "VBoxProblemReporter.h"
    2627#include "VBoxUtils.h"
    2728#include "QIDialogButtonBox.h"
    28 
    29 /* Qt includes */
     29#include "VBoxToolBar.h"
     30
    3031#include <QLineEdit>
     32#include <QToolButton>
    3133#include <QPushButton>
    3234#include <QDir>
     
    181183    Ui::VBoxVMSettingsSF::setupUi (this);
    182184
     185    /* Prepare actions */
     186    mNewAction = new QAction (mTreeView);
     187    mEdtAction = new QAction (mTreeView);
     188    mDelAction = new QAction (mTreeView);
     189
     190    mNewAction->setText (tr ("&Add New Shared Folder"));
     191    mEdtAction->setText (tr ("&Edit Selected Shared Folder"));
     192    mDelAction->setText (tr ("&Remove Selected Shared Folder"));
     193
     194    mNewAction->setShortcut (QKeySequence ("Ins"));
     195    mEdtAction->setShortcut (QKeySequence ("Ctrl+Space"));
     196    mDelAction->setShortcut (QKeySequence ("Del"));
     197
     198    mNewAction->setToolTip (mNewAction->text().remove ('&') +
     199        QString (" (%1)").arg (mNewAction->shortcut().toString()));
     200    mEdtAction->setToolTip (mEdtAction->text().remove ('&') +
     201        QString (" (%1)").arg (mEdtAction->shortcut().toString()));
     202    mDelAction->setToolTip (mDelAction->text().remove ('&') +
     203        QString (" (%1)").arg (mDelAction->shortcut().toString()));
     204
     205    mNewAction->setWhatsThis (tr ("Adds a new shared folder definition."));
     206    mEdtAction->setWhatsThis (tr ("Edits the selected shared folder definition."));
     207    mDelAction->setWhatsThis (tr ("Removes the selected shared folder definition."));
     208
     209    mNewAction->setIcon (VBoxGlobal::iconSet (":/add_shared_folder_16px.png",
     210                                              ":/add_shared_folder_disabled_16px.png"));
     211    mEdtAction->setIcon (VBoxGlobal::iconSet (":/edit_shared_folder_16px.png",
     212                                              ":/edit_shared_folder_disabled_16px.png"));
     213    mDelAction->setIcon (VBoxGlobal::iconSet (":/revome_shared_folder_16px.png",
     214                                              ":/revome_shared_folder_disabled_16px.png"));
     215
     216    /* Prepare menu and toolbar */
     217    mMenu = new QMenu (mTreeView);
     218    mMenu->addAction (mNewAction);
     219    mMenu->addAction (mEdtAction);
     220    mMenu->addSeparator();
     221    mMenu->addAction (mDelAction);
     222
     223    /* Prepare toolbar */
     224    VBoxToolBar *toolBar = new VBoxToolBar (mGbSharedFolders);
     225    toolBar->setUsesTextLabel (false);
     226    toolBar->setUsesBigPixmaps (false);
     227    toolBar->setOrientation (Qt::Vertical);
     228    toolBar->addAction (mNewAction);
     229    toolBar->addAction (mEdtAction);
     230    toolBar->addAction (mDelAction);
     231    mGbSharedFolders->layout()->addWidget (toolBar);
     232
     233    /* Setup connections */
    183234    mTreeView->header()->setMovable (false);
    184     mTbAdd->setIcon (VBoxGlobal::iconSet (":/add_shared_folder_16px.png",
    185                                           ":/add_shared_folder_disabled_16px.png"));
    186     mTbEdit->setIcon (VBoxGlobal::iconSet (":/edit_shared_folder_16px.png",
    187                                            ":/edit_shared_folder_disabled_16px.png"));
    188     mTbRemove->setIcon (VBoxGlobal::iconSet (":/revome_shared_folder_16px.png",
    189                                              ":/revome_shared_folder_disabled_16px.png"));
    190     connect (mTbAdd, SIGNAL (clicked()), this, SLOT (tbAddPressed()));
    191     connect (mTbEdit, SIGNAL (clicked()), this, SLOT (tbEditPressed()));
    192     connect (mTbRemove, SIGNAL (clicked()), this, SLOT (tbRemovePressed()));
     235    connect (mNewAction, SIGNAL (triggered (bool)), this, SLOT (addTriggered()));
     236    connect (mEdtAction, SIGNAL (triggered (bool)), this, SLOT (edtTriggered()));
     237    connect (mDelAction, SIGNAL (triggered (bool)), this, SLOT (delTriggered()));
    193238    connect (mTreeView, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
    194239             this, SLOT (processCurrentChanged (QTreeWidgetItem*, QTreeWidgetItem*)));
    195240    connect (mTreeView, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)),
    196241             this, SLOT (processDoubleClick (QTreeWidgetItem*, int)));
     242    connect (mTreeView, SIGNAL (customContextMenuRequested (const QPoint &)),
     243             this, SLOT (showContextMenu (const QPoint &)));
    197244    connect (mTreeView->header(), SIGNAL (sectionResized (int, int, int)),
    198245             this, SLOT (adjustFields()));
     
    230277
    231278void VBoxVMSettingsSF::getFromMachineEx (const CMachine &aMachine,
    232                                          QWidget *aPage)
     279                                         QWidget *aPage,
     280                                         VBoxVMSettingsDlg *aDlg)
    233281{
    234282    mSettings = new VBoxVMSettingsSF (aPage, MachineType);
     
    237285    layout->addWidget (mSettings);
    238286    mSettings->getFromMachine (aMachine);
     287
     288    /* Fixing Tab Order */
     289    setTabOrder (aDlg->mTwSelector, mSettings->mTreeView);
    239290}
    240291
     
    323374}
    324375
    325 void VBoxVMSettingsSF::tbAddPressed()
     376void VBoxVMSettingsSF::addTriggered()
    326377{
    327378    /* Invoke Add-Box Dialog */
     
    356407}
    357408
    358 void VBoxVMSettingsSF::tbEditPressed()
     409void VBoxVMSettingsSF::edtTriggered()
    359410{
    360411    /* Check selected item */
     
    408459}
    409460
    410 void VBoxVMSettingsSF::tbRemovePressed()
     461void VBoxVMSettingsSF::delTriggered()
    411462{
    412463    QTreeWidgetItem *selectedItem = mTreeView->selectedItems().size() == 1 ?
     
    429480    bool addEnabled = aCurrentItem && isEditable (key);
    430481    bool removeEnabled = addEnabled && aCurrentItem->parent();
    431     mTbAdd->setEnabled (addEnabled);
    432     mTbEdit->setEnabled (removeEnabled);
    433     mTbRemove->setEnabled (removeEnabled);
     482    mNewAction->setEnabled (addEnabled);
     483    mEdtAction->setEnabled (removeEnabled);
     484    mDelAction->setEnabled (removeEnabled);
    434485}
    435486
     
    440491        isEditable (aItem->parent()->text (1));
    441492    if (editEnabled)
    442         tbEditPressed();
     493        edtTriggered();
     494}
     495
     496void VBoxVMSettingsSF::showContextMenu (const QPoint &aPos)
     497{
     498    mMenu->exec (mTreeView->mapToGlobal (aPos));
    443499}
    444500
     
    727783
    728784    /* Setup Button layout */
    729     mButtonBox = new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     785    mButtonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    730786    mButtonBox->setCenterButtons (true);
    731787    connect (mButtonBox, SIGNAL (accepted()), this, SLOT (accept()));
  • trunk/src/VBox/Frontends/VirtualBox4/ui/VBoxVMSettingsSF.ui

    r9253 r9260  
    5757      <item>
    5858       <widget class="QTreeWidget" name="mTreeView" >
     59        <property name="contextMenuPolicy" >
     60         <enum>Qt::CustomContextMenu</enum>
     61        </property>
    5962        <property name="whatsThis" >
    6063         <string>&lt;qt>Lists all shared folders accessible to this machine. Use &lt;tt>net use x: \\vboxsvr\share&lt;/tt> to access a shared folder named &lt;i>share&lt;/i> from a DOS-like OS, or &lt;tt>mount -t vboxsf share mount_point&lt;/tt> to access it from a Linux OS. This feature requires Guest Additions.&lt;/qt></string>
     
    8386       </widget>
    8487      </item>
    85       <item>
    86        <layout class="QVBoxLayout" >
    87         <property name="spacing" >
    88          <number>0</number>
    89         </property>
    90         <item>
    91          <widget class="QToolButton" name="mTbAdd" >
    92           <property name="focusPolicy" >
    93            <enum>Qt::TabFocus</enum>
    94           </property>
    95           <property name="toolTip" >
    96            <string>Add a new shared folder (Ins)</string>
    97           </property>
    98           <property name="whatsThis" >
    99            <string>Adds a new shared folder definition.</string>
    100           </property>
    101           <property name="text" >
    102            <string/>
    103           </property>
    104           <property name="shortcut" >
    105            <string>Ins</string>
    106           </property>
    107           <property name="autoRaise" >
    108            <bool>true</bool>
    109           </property>
    110          </widget>
    111         </item>
    112         <item>
    113          <widget class="QToolButton" name="mTbEdit" >
    114           <property name="focusPolicy" >
    115            <enum>Qt::TabFocus</enum>
    116           </property>
    117           <property name="toolTip" >
    118            <string>Edit the selected shared folder (Ctrl+Space)</string>
    119           </property>
    120           <property name="whatsThis" >
    121            <string>Edits the selected shared folder definition.</string>
    122           </property>
    123           <property name="text" >
    124            <string/>
    125           </property>
    126           <property name="shortcut" >
    127            <string>Ctrl+Space</string>
    128           </property>
    129           <property name="autoRaise" >
    130            <bool>true</bool>
    131           </property>
    132          </widget>
    133         </item>
    134         <item>
    135          <widget class="QToolButton" name="mTbRemove" >
    136           <property name="focusPolicy" >
    137            <enum>Qt::TabFocus</enum>
    138           </property>
    139           <property name="toolTip" >
    140            <string>Remove the selected shared folder (Del)</string>
    141           </property>
    142           <property name="whatsThis" >
    143            <string>Removes the selected shared folder definition.</string>
    144           </property>
    145           <property name="text" >
    146            <string/>
    147           </property>
    148           <property name="shortcut" >
    149            <string>Del</string>
    150           </property>
    151           <property name="autoRaise" >
    152            <bool>true</bool>
    153           </property>
    154          </widget>
    155         </item>
    156         <item>
    157          <spacer>
    158           <property name="orientation" >
    159            <enum>Qt::Vertical</enum>
    160           </property>
    161           <property name="sizeType" >
    162            <enum>QSizePolicy::Expanding</enum>
    163           </property>
    164           <property name="sizeHint" >
    165            <size>
    166             <width>21</width>
    167             <height>101</height>
    168            </size>
    169           </property>
    170          </spacer>
    171         </item>
    172        </layout>
    173       </item>
    17488     </layout>
    17589    </widget>
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