VirtualBox

Changeset 1281 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Mar 6, 2007 11:24:52 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
19233
Message:

VMSettings -> General page -> Advanced setting:

Some keyboard-work improvements for boot-table:

  1. Boot-items table selection style was changed to WhenCurrent.
  2. Necessary changes were done for combo-box item destroying after table lost focus.

Currently:
Item's combo-box appears then the table got focus (by tab or mouse) and disappears after table lost focus.
During table have focus it is possible to serf through table's items by cursor up-down keys.

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

Legend:

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

    r1215 r1281  
    11461146                                            <cstring>unnamed</cstring>
    11471147                                        </property>
    1148                                         <widget class="QTable">
    1149                                             <property name="name">
    1150                                                 <cstring>tblBootOrder</cstring>
    1151                                             </property>
    1152                                             <property name="sizePolicy">
    1153                                                 <sizepolicy>
    1154                                                     <hsizetype>7</hsizetype>
    1155                                                     <vsizetype>7</vsizetype>
    1156                                                     <horstretch>1</horstretch>
    1157                                                     <verstretch>0</verstretch>
    1158                                                 </sizepolicy>
    1159                                             </property>
    1160                                             <property name="numRows">
    1161                                                 <number>0</number>
    1162                                             </property>
    1163                                             <property name="numCols">
    1164                                                 <number>0</number>
    1165                                             </property>
    1166                                             <property name="showGrid">
    1167                                                 <bool>false</bool>
    1168                                             </property>
    1169                                             <property name="selectionMode">
    1170                                                 <enum>NoSelection</enum>
    1171                                             </property>
    1172                                             <property name="focusStyle">
    1173                                                 <enum>FollowStyle</enum>
    1174                                             </property>
    1175                                             <property name="whatsThis" stdset="0">
    1176                                                 <string>Defines the boot device order. Click
    1177 on the entry and select a desired boot device from the drop-down list.</string>
    1178                                             </property>
    1179                                         </widget>
    11801148                                    </vbox>
    11811149                                </widget>
     
    25982566        <slot>tbUSBFilterDown_clicked()</slot>
    25992567    </connection>
    2600     <connection>
    2601         <sender>tblBootOrder</sender>
    2602         <signal>clicked(int,int,int,const QPoint&amp;)</signal>
    2603         <receiver>VBoxVMSettingsDlg</receiver>
    2604         <slot>bootItemActivate(int,int,int,const QPoint&amp;)</slot>
    2605     </connection>
    26062568</connections>
    26072569<tabstops>
     
    26142576    <tabstop>slVRAM</tabstop>
    26152577    <tabstop>leVRAM</tabstop>
    2616     <tabstop>tblBootOrder</tabstop>
    26172578    <tabstop>chbEnableACPI</tabstop>
    26182579    <tabstop>chbEnableIOAPIC</tabstop>
     
    26642625    <include location="global" impldecl="in implementation">qtimer.h</include>
    26652626    <include location="global" impldecl="in implementation">qpopupmenu.h</include>
     2627    <include location="global" impldecl="in implementation">qtable.h</include>
    26662628    <include location="local" impldecl="in declaration">COMDefs.h</include>
    26672629    <include location="local" impldecl="in declaration">QIWidgetValidator.h</include>
     
    26812643    <forward>class VBoxSharedFoldersSettings</forward>
    26822644    <forward>class QIRichLabel</forward>
     2645    <forward>class BootItemsTable</forward>
    26832646</forwards>
    26842647<variables>
     
    27142677    <variable access="private">VBoxUSBMenu *usbDevicesMenu;</variable>
    27152678    <variable access="private">QIRichLabel *whatsThisLabel;</variable>
     2679    <variable access="private">BootItemsTable *tblBootOrder;</variable>
    27162680</variables>
    27172681<slots>
     
    27432707    <slot>tbUSBFilterUp_clicked()</slot>
    27442708    <slot>tbUSBFilterDown_clicked()</slot>
    2745     <slot>bootItemActivate(int row, int col, int button, const QPoint &amp; mousePos)</slot>
    27462709    <slot>hdaMediaChanged()</slot>
    27472710    <slot>hdbMediaChanged()</slot>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r1243 r1281  
    5151}
    5252
     53
    5354/**
     55 *  Class: BootItemsTable.
     56 *  QTable class reimplementation to use as boot items table.
     57 *  It handles "focus-in" situation creating combo-box for focused item.
     58 *  It also presents wrappers for some hidden functionality.
     59 */
     60class BootItemsTable : public QTable
     61{
     62    Q_OBJECT
     63
     64public:
     65
     66    BootItemsTable (QWidget *aParent, const char *aName)
     67        : QTable (aParent, aName) {}
     68    ~BootItemsTable() {}
     69
     70    void endEdit (int aRow, int aCol)
     71    {
     72        QTable::endEdit (aRow, aCol, true, false);
     73    }
     74
     75protected:
     76
     77    void focusInEvent (QFocusEvent *)
     78    {
     79        int row = currentRow() >= 0 ? currentRow() : 0;
     80        setCurrentCell (row, 0);
     81        editCell (row, 0);
     82    }
     83};
     84
     85
     86/**
     87 *  Class: BootComboBox.
     88 *  QComboBox class reimplementation to use as boot item's editor.
     89 *  This class handles tab/backtab keypress events for boot item re-focusing.
     90 *  It also handles "focus-lost" situation for combo-box control destroying
     91 *  it after focus leaving from the combo-box.
     92 */
     93class BootComboBox : public QComboBox
     94{
     95public:
     96
     97    BootComboBox (QWidget *aParent, QTable *aTable)
     98        : QComboBox (aParent), mParent (0)
     99    {
     100        Assert (aTable->inherits ("BootItemsTable"));
     101        mParent = static_cast<BootItemsTable*> (aTable);
     102    }
     103    ~BootComboBox() {}
     104
     105protected:
     106
     107    void focusOutEvent (QFocusEvent *)
     108    {
     109        if (!listBox()->hasFocus())
     110        {
     111            mParent->endEdit (mParent->currentRow(), mParent->currentColumn());
     112            mParent->clearFocus();
     113        }
     114    }
     115
     116    bool event (QEvent *aEvent)
     117    {
     118        if (aEvent->type() == QEvent::KeyPress)
     119        {
     120            QKeyEvent *event = static_cast<QKeyEvent*> (aEvent);
     121            switch (event->key())
     122            {
     123                case Qt::Key_Backtab:
     124                    focusData()->home();
     125                    focusData()->prev()->setFocus();
     126                    return false;
     127                    break;
     128                case Qt::Key_Tab:
     129                    focusData()->home();
     130                    focusData()->next()->setFocus();
     131                    return false;
     132                    break;
     133                default:
     134                    return QComboBox::event (aEvent);
     135            }
     136        }
     137        else
     138            return QComboBox::event (aEvent);
     139    }
     140
     141    BootItemsTable *mParent;
     142};
     143
     144
     145/**
     146 *  Class: ComboTableItem.
    54147 *  Simple QTableItem subclass to use QComboBox as the cell editor.
    55148 *  This subclass (as opposed to QComboTableItem) allows to specify the
     
    67160public:
    68161
     162    enum { BootItemType = 1001 };
     163
    69164    ComboTableItem (QTable *aTable, EditType aEditType,
    70165                    const QStringList &aList, const QStringList &aUnique,
     
    76171    }
    77172
    78     // reimplemented QTableItem members
    79173    QWidget *createEditor() const
    80174    {
    81         mComboBoxSelector = new QComboBox (table()->viewport());
     175        mComboBoxSelector = (QComboBox*) new BootComboBox (table()->viewport(), table());
    82176        QStringList list = mList;
    83177        if (mUniqueInUse)
     
    93187        mComboBoxSelector->insertStringList (list);
    94188        mComboBoxSelector->setCurrentText (text());
    95         QObject::connect (mComboBoxSelector,   SIGNAL (highlighted (const QString &)),
    96                           this,                SLOT   (doValueChanged (const QString &)));
    97         QObject::connect (mComboBoxSelector,   SIGNAL (activated (const QString &)),
    98                           this,                SLOT   (focusClearing ()));
     189        QObject::connect (table(), SIGNAL (clicked (int, int, int, const QPoint&)),
     190                          this, SLOT (processClicked (int, int, int, const QPoint&)));
    99191
    100192        return mComboBoxSelector;
     
    111203            QTableItem::setContentFromEditor (aWidget);
    112204    }
     205
    113206    void setText (const QString &aText)
    114207    {
     
    130223    /*
    131224     *  Function: rtti()
    132      *  Target:   required for runtime information about ComboTableItem class
    133      *            used for static_cast from QTableItem
     225     *  Required for runtime information about ComboTableItem class
     226     *  used for static_cast from QTableItem
    134227     */
    135     int rtti() const { return 1001; }
     228    int rtti() const { return BootItemType; }
    136229
    137230    /*
    138231     *  Function: getEditor()
    139      *  Target:   returns pointer to stored combo-box
     232     *  Returns pointer to stored combo-box
    140233     */
    141234    QComboBox* getEditor() { return mComboBoxSelector; }
     
    144237
    145238    /*
    146      *  QTable doesn't call endEdit() when item's EditType is WhenCurrent and
    147      *  the table widget loses focus or gets destroyed (assuming the user will
    148      *  hit Enter if he wants to keep the value), so we need to do it ourselves
     239     *  Slot: processClicked(...)
     240     *  Ensures item's combo-box popup in case of it was force-closed
     241     *  with using of endEdit() last time
    149242     */
    150     void doValueChanged (const QString &text) { setText (text); }
    151 
    152     /*
    153      *  Function: focusClearing()
    154      *  Target:   required for removing focus from combo-box
    155      */
    156     void focusClearing() { mComboBoxSelector->clearFocus(); }
     243    void processClicked (int aRow, int aCol, int, const QPoint &)
     244    {
     245        if (aRow == row() && aCol == col())
     246            mComboBoxSelector->popup();
     247    }
    157248
    158249private:
     
    552643    slVRAM_valueChanged (slVRAM->value());
    553644
     645
     646    tblBootOrder = new BootItemsTable ( groupBox12, "tblBootOrder" );
     647    QWhatsThis::add (tblBootOrder,
     648                     tr ("Defines the boot device order. Click on the entry and "
     649                         "select a desired boot device from the drop-down list."));
     650    setTabOrder (leVRAM, tblBootOrder);
     651    setTabOrder (tblBootOrder, chbEnableACPI);
     652    tblBootOrder->setSizePolicy (QSizePolicy ((QSizePolicy::SizeType)7,
     653        (QSizePolicy::SizeType)7, 1, 0,
     654        tblBootOrder->sizePolicy().hasHeightForWidth()));
     655    tblBootOrder->setNumRows (0);
     656    tblBootOrder->setNumCols (0);
     657    tblBootOrder->setShowGrid (FALSE);
     658    tblBootOrder->setSelectionMode (QTable::NoSelection);
     659    tblBootOrder->setFocusStyle (QTable::FollowStyle);
     660    groupBox12Layout->addWidget (tblBootOrder);
     661
    554662    tblBootOrder->horizontalHeader()->hide();
    555663    tblBootOrder->setTopMargin (0);
     
    569677        {
    570678            ComboTableItem *item = new ComboTableItem (
    571                 tblBootOrder, QTableItem::OnTyping,
     679                tblBootOrder, QTableItem::WhenCurrent,
    572680                list, unique, &bootDevicesInUse);
    573681            tblBootOrder->setItem (i, 0, item);
    574682        }
    575683    }
    576     connect (tblBootOrder, SIGNAL (clicked(int, int, int, const QPoint&)),
    577              this,  SLOT (bootItemActivate(int, int, int, const QPoint&)));
    578684
    579685    tblBootOrder->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
     
    686792}
    687793
    688 void VBoxVMSettingsDlg::bootItemActivate (int row, int col, int /* button */,
    689                                           const QPoint &/* mousePos */)
    690 {
    691     tblBootOrder->editCell(row, col);
    692     QTableItem* tableItem = tblBootOrder->item(row, col);
    693     if (tableItem->rtti() == 1001)
    694         (static_cast<ComboTableItem*>(tableItem))->getEditor()->popup();
    695 }
    696794
    697795void VBoxVMSettingsDlg::updateShortcuts()
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette