VirtualBox

Ignore:
Timestamp:
Jul 14, 2008 3:16:10 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: Tabs as subpages in the settings dialog if the ToolBar style is used.
In the classical view nothing has changed.

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

Legend:

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

    r10474 r10604  
    5353
    5454    virtual void revalidate (QIWidgetValidator * /* aWval */) {}
     55    void categoryChanged (int aId);
    5556
    5657protected:
     
    7172    void updateWhatsThis (bool aGotFocus = false);
    7273    void whatsThisCandidateDestroyed (QObject *aObj = 0);
    73 
    74     void categoryChanged (int aId);
    7574
    7675private:
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSettingsDialogSpecific.h

    r10515 r10604  
    6363
    6464    void updateAvailability();
    65     VBoxSettingsPage* attachPage (VBoxSettingsPage *aPage);
    6665};
    6766
     
    7978    {
    8079        GeneralId = 0,
     80        StorageId,
    8181        HDId,
    8282        CDId,
     
    8484        AudioId,
    8585        NetworkId,
     86        PortsId,
    8687        SerialId,
    8788        ParallelId,
     
    114115private:
    115116
     117    void addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPrefPage = NULL, int aParentId = -1);
    116118    void updateAvailability();
    117     VBoxSettingsPage* attachPage (VBoxSettingsPage *aPage);
     119    VBoxSettingsPage* attachValidator (VBoxSettingsPage *aPage);
    118120
    119121    CMachine mMachine;
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSettingsSelector.h

    r10475 r10604  
    2929class QITreeWidget;
    3030class VBoxToolBar;
    31 class SelectorAction;
     31class VBoxSettingsPage;
     32class SelectorItem;
     33class SelectorActionItem;
    3234
    3335class QTreeWidget;
     
    3638class QAction;
    3739class QActionGroup;
     40template <class Key, class T> class QMap;
     41class QTabWidget;
    3842
    3943class VBoxSettingsSelector: public QObject
     
    4751    virtual QWidget *widget() const = 0;
    4852
    49     virtual void addItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink) = 0;
     53    virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1) = 0;
     54
     55    virtual void setItemText (int aId, const QString &aText);
    5056    virtual QString itemText (int aId) const = 0;
    51     virtual QString itemTextByIndex (int aIndex) const { return itemText (indexToId (aIndex)); }
     57    virtual QString itemTextByPage (VBoxSettingsPage *aPage) const;
    5258
    5359    virtual int currentId () const = 0;
    54     virtual int idToIndex (int aId) const = 0;
    55     virtual int indexToId (int aIndex) const = 0;
    5660    virtual int linkToId (const QString &aLink) const = 0;
     61
     62    virtual QWidget *idToPage (int aId) const;
     63    virtual QWidget *rootPage (int aId) const { return idToPage (aId); }
     64
    5765    virtual void selectById (int aId) = 0;
    5866    virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); }
     67
    5968    virtual void setVisibleById (int aId, bool aShow) = 0;
    6069
    61     virtual void clear() = 0;
     70    virtual QList<VBoxSettingsPage*> settingPages() const;
     71    virtual QList<QWidget*> rootPages() const;
    6272
    6373    virtual void polish() {};
     74
    6475    virtual int minWidth () const { return 0; }
    6576
     
    6879    void categoryChanged (int);
    6980
     81protected:
     82
     83    virtual void clear() = 0;
     84
     85    SelectorItem* findItem (int aId) const;
     86    SelectorItem* findItemByLink (const QString &aLink) const;
     87    SelectorItem* findItemByPage (VBoxSettingsPage* aPage) const;
     88
     89    QList<SelectorItem*> mItemList;
    7090};
    7191
     
    80100    virtual QWidget *widget() const;
    81101
    82     virtual void addItem (const QIcon &aIcon, const QString &aText, int aIndex, const QString &aLink);
     102    virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
     103    virtual void setItemText (int aId, const QString &aText);
    83104    virtual QString itemText (int aId) const;
    84105
    85106    virtual int currentId() const;
    86     virtual int idToIndex (int aId) const;
    87     virtual int indexToId (int aIndex) const;
    88107    virtual int linkToId (const QString &aLink) const;
     108
    89109    virtual void selectById (int aId);
     110
    90111    virtual void setVisibleById (int aId, bool aShow);
    91 
    92     virtual void clear();
    93112
    94113    virtual void polish();
     
    99118
    100119private:
     120
     121    virtual void clear();
    101122
    102123    QString pagePath (const QString &aMatch) const;
     
    115136
    116137    VBoxSettingsToolBarSelector (QWidget *aParent = NULL);
     138    ~VBoxSettingsToolBarSelector();
    117139
    118140    virtual QWidget *widget() const;
    119141
    120     virtual void addItem (const QIcon &aIcon, const QString &aText, int aIndex, const QString &aLink);
     142    virtual QWidget *addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
     143    virtual void setItemText (int aId, const QString &aText);
    121144    virtual QString itemText (int aId) const;
    122145
    123146    virtual int currentId() const;
    124     virtual int idToIndex (int aId) const;
    125     virtual int indexToId (int aIndex) const;
    126147    virtual int linkToId (const QString &aLink) const;
     148
     149    virtual QWidget *idToPage (int aId) const;
     150    virtual QWidget *rootPage (int aId) const;
     151
    127152    virtual void selectById (int aId);
     153
    128154    virtual void setVisibleById (int aId, bool aShow);
     155
     156    virtual int minWidth() const;
     157
     158    virtual QList<QWidget*> rootPages() const;
     159private slots:
     160
     161    void settingsGroupChanged (QAction *aAction);
     162    void settingsGroupChanged (int aIndex);
     163
     164private:
    129165
    130166    virtual void clear();
    131167
    132     virtual int minWidth() const;
    133 
    134 private slots:
    135 
    136     void settingsGroupChanged (QAction *aAction);
    137 
    138 private:
    139 
    140     SelectorAction* findAction (int aId) const;
     168    SelectorActionItem *findActionItem (int aId) const;
     169    SelectorActionItem *findActionItemByAction (QAction *aAction) const;
     170    SelectorActionItem *findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const;
    141171
    142172    /* Private member vars */
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSettingsDialog.cpp

    r10536 r10604  
    2727#include "QIWidgetValidator.h"
    2828#include "VBoxSettingsSelector.h"
     29#include "VBoxSettingsPage.h"
    2930#include "VBoxToolBar.h"
    3031
     
    193194void VBoxSettingsDialog::categoryChanged (int aId)
    194195{
    195     int index = mSelector->idToIndex (aId);
     196    QWidget *rootPage = mSelector->rootPage (aId);
    196197#ifndef Q_WS_MAC
    197198    mLbTitle->setText (mSelector->itemText (aId));
    198     mStack->setCurrentIndex (index);
     199    mStack->setCurrentIndex (mStack->indexOf (rootPage));
    199200#else /* Q_WS_MAC */
    200     if (isVisible())
    201     {
    202         int index = mSelector->idToIndex (aId);
    203         /* We will update at once later */
    204         setUpdatesEnabled (false);
    205         setMinimumSize (QSize (minimumWidth(), 0));
    206         setMaximumSize (QSize (minimumWidth(), QWIDGETSIZE_MAX));
    207         /* Set all tab size policies to ignored */
    208         for (int i = 0; i < mStack->count(); ++i)
    209             mStack->widget (i)->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Ignored);
    210         /* Set the size policy of the current tab to preferred */
    211         if (mStack->widget (index))
    212             mStack->widget (index)->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
    213         /* Set the new current tab */
    214         mLbTitle->setText (mSelector->itemText (aId));
    215         mStack->setCurrentIndex (index);
    216         /* Activate the new layout */
    217         layout()->activate();
    218         setUpdatesEnabled (true);
    219         //        mAllWidget->hide();
    220         QSize s = minimumSize();
    221         int minWidth = mSelector->minWidth();
    222         if (minWidth > s.width())
    223             s.setWidth (minWidth);
    224         /* Play the resize animation */
    225         ::darwinWindowAnimateResize (this, QRect (x(), y(),
    226                                                   s.width(), s.height()));
    227         //        mAllWidget->show();
    228         /* Set the new size to Qt also */
    229         setFixedSize (s);
    230     }else
    231     {
    232         mLbTitle->setText (mSelector->itemText (aId));
    233         mStack->setCurrentIndex (index);
    234     }
     201    /* We will update at once later */
     202    setUpdatesEnabled (false);
     203    setMinimumSize (QSize (minimumWidth(), 0));
     204    setMaximumSize (QSize (minimumWidth(), QWIDGETSIZE_MAX));
     205    /* Set all tab size policies to ignored */
     206    QList<QWidget*> list = mSelector->rootPages ();
     207    for (int i = 0; i < list.count(); ++i)
     208        list.at (i)->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Ignored);
     209    /* Set the size policy of the current tab to preferred */
     210    if (mStack->widget (mStack->indexOf (rootPage)))
     211        mStack->widget (mStack->indexOf (rootPage))->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
     212    /* Set the new current tab */
     213    mLbTitle->setText (mSelector->itemText (aId));
     214    mStack->setCurrentIndex (mStack->indexOf (rootPage));
     215    /* Activate the new layout */
     216    layout()->activate();
     217    setUpdatesEnabled (true);
     218    //        mAllWidget->hide();
     219    QSize s = minimumSize();
     220    int minWidth = mSelector->minWidth();
     221    if (minWidth > s.width())
     222        s.setWidth (minWidth);
     223    /* Play the resize animation */
     224    ::darwinWindowAnimateResize (this, QRect (x(), y(),
     225                                              s.width(), s.height()));
     226    //        mAllWidget->show();
     227    /* Set the new size to Qt also */
     228    setFixedSize (s);
     229#endif /* !Q_WS_MAC */
    235230# ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS
    236231    setWindowTitle (dialogTitle());
    237232# endif
    238 #endif /* !Q_WS_MAC */
    239233}
    240234
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSettingsDialogSpecific.cpp

    r10515 r10604  
    5757
    5858    /* Creating settings pages */
    59     attachPage (new VBoxGLSettingsGeneral());
    60 
    61     attachPage (new VBoxGLSettingsInput());
    62 
    63     attachPage (new VBoxGLSettingsUpdate());
    64 
    65     attachPage (new VBoxGLSettingsLanguage());
     59    QWidget *page = NULL;
     60    VBoxSettingsPage *prefPage = NULL;
     61
     62    /* General page */
     63    prefPage = new VBoxGLSettingsGeneral();
     64    page = mSelector->addItem (VBoxGlobal::iconSet (":/machine_16px.png"),
     65                               GeneralId, "#general",
     66                               prefPage);
     67    if (page)
     68        mStack->addWidget (page);
     69    prefPage->setOrderAfter (mSelector->widget());
     70
     71    /* Input page */
     72    prefPage = new VBoxGLSettingsInput();
     73    page = mSelector->addItem (VBoxGlobal::iconSet (":/hostkey_16px.png"),
     74                               InputId, "#input",
     75                               prefPage);
     76    if (page)
     77        mStack->addWidget (page);
     78    prefPage->setOrderAfter (mSelector->widget());
     79
     80    /* Update page */
     81    prefPage = new VBoxGLSettingsUpdate();
     82    page = mSelector->addItem (VBoxGlobal::iconSet (":/refresh_16px.png"),
     83                               UpdateId, "#update",
     84                               prefPage);
     85    if (page)
     86        mStack->addWidget (page);
     87    prefPage->setOrderAfter (mSelector->widget());
     88
     89    /* Language page */
     90    prefPage = new VBoxGLSettingsLanguage();
     91    page = mSelector->addItem (VBoxGlobal::iconSet (":/site_16px.png"),
     92                               LanguageId, "#language",
     93                               prefPage);
     94    if (page)
     95        mStack->addWidget (page);
     96    prefPage->setOrderAfter (mSelector->widget());
    6697
    6798#ifdef ENABLE_GLOBAL_USB
    68     attachPage (new VBoxVMSettingsUSB (VBoxVMSettingsUSB::HostType));
     99    /* USB page */
     100    prefPage = VBoxVMSettingsUSB (VBoxVMSettingsUSB::HostType);
     101    page = mSelector->addItem (VBoxGlobal::iconSet (":/usb_16px.png"),
     102                               USBId, "#usb",
     103                               prefPage);
     104    if (page)
     105        mStack->addWidget (page);
     106    prefPage->setOrderAfter (mSelector->widget());
    69107#endif
    70108
     
    74112    /* Applying language settings */
    75113    retranslateUi();
     114
     115    /* First item as default */
     116    mSelector->selectById (0);
    76117}
    77118
     
    81122    VBoxGlobalSettings sett = vboxGlobal().settings();
    82123
    83     QList<VBoxSettingsPage*> pages = mStack->findChildren<VBoxSettingsPage*>();
     124    QList<VBoxSettingsPage*> pages = mSelector->settingPages();
    84125    foreach (VBoxSettingsPage *page, pages)
    85126        if (page->isEnabled())
     
    93134    VBoxGlobalSettings newsett = sett;
    94135
    95     QList<VBoxSettingsPage*> pages = mStack->findChildren<VBoxSettingsPage*>();
     136    QList<VBoxSettingsPage*> pages = mSelector->settingPages();
    96137    foreach (VBoxSettingsPage *page, pages)
    97138        if (page->isEnabled())
     
    112153    setWindowTitle (dialogTitle());
    113154
    114     /* Remember old index */
    115     int cid = mSelector->currentId();
    116     /* Remove all items */
    117     mSelector->clear();
    118 
    119155    /* General page */
    120     mSelector->addItem (VBoxGlobal::iconSet (":/machine_16px.png"),
    121                         tr ("General"), GeneralId, "#general");
     156    mSelector->setItemText (GeneralId, tr ("General"));
    122157
    123158    /* Input page */
    124     mSelector->addItem (VBoxGlobal::iconSet (":/hostkey_16px.png"),
    125                         tr ("Input"), InputId, "#input");
     159    mSelector->setItemText (InputId, tr ("Input"));
    126160
    127161    /* Update page */
    128     mSelector->addItem (VBoxGlobal::iconSet (":/refresh_16px.png"),
    129                         tr ("Update"), UpdateId, "#update");
     162    mSelector->setItemText (UpdateId, tr ("Update"));
    130163
    131164    /* Language page */
    132     mSelector->addItem (VBoxGlobal::iconSet (":/site_16px.png"),
    133                         tr ("Language"), LanguageId, "#language");
     165    mSelector->setItemText (LanguageId, tr ("Language"));
    134166
    135167#ifdef ENABLE_GLOBAL_USB
    136168    /* USB page */
    137     mSelector->addItem (VBoxGlobal::iconSet (":/usb_16px.png"),
    138                         tr ("USB"), USBId, "#usb");
     169    mSelector->setItemText (USBId, tr ("USB"));
    139170#endif
    140171
     
    144175    VBoxSettingsDialog::retranslateUi();
    145176
    146     /* Select old remembered category */
    147     mSelector->selectById (cid == -1 ? 0 : cid);
    148 
    149177    /* Update Selector with available items */
    150178    updateAvailability();
     
    154182{
    155183    return tr ("VirtualBox - %1").arg (titleExtension());
    156 }
    157 
    158 VBoxSettingsPage* VBoxGLSettingsDlg::attachPage (VBoxSettingsPage *aPage)
    159 {
    160     mStack->addWidget (aPage);
    161 
    162     aPage->setOrderAfter (mSelector->widget());
    163 
    164     return aPage;
    165184}
    166185
     
    180199         * not available (i.e. in VirtualBox OSE) */
    181200        mSelector->setVisibleById (USBId, false);
    182         int index = mSelector->idToIndex (USBId);
    183         if (index > -1)
    184         {
    185             if (mStack->widget (index))
    186                 mStack->widget (index)->setEnabled (false);
    187         }
    188201    }
    189202}
     
    206219
    207220    /* Creating settings pages */
    208     VBoxSettingsPage *page = 0;
    209 
    210     page = attachPage (new VBoxVMSettingsGeneral());
    211     connect (page, SIGNAL (tableChanged()), this, SLOT (resetFirstRunFlag()));
    212 
    213     page = attachPage (new VBoxVMSettingsHD());
    214     connect (page, SIGNAL (hdChanged()), this, SLOT (resetFirstRunFlag()));
    215 
    216     page = attachPage (new VBoxVMSettingsCD());
    217     connect (page, SIGNAL (cdChanged()), this, SLOT (resetFirstRunFlag()));
    218 
    219     page = attachPage (new VBoxVMSettingsFD());
    220     connect (page, SIGNAL (fdChanged()), this, SLOT (resetFirstRunFlag()));
    221 
    222     attachPage (new VBoxVMSettingsAudio());
    223 
    224     attachPage (new VBoxVMSettingsNetworkPage());
    225 
    226     attachPage (new VBoxVMSettingsSerialPage());
    227 
    228     attachPage (new VBoxVMSettingsParallelPage());
    229 
    230     attachPage (new VBoxVMSettingsUSB (VBoxVMSettingsUSB::MachineType));
    231 
    232     attachPage (new VBoxVMSettingsSF (MachineType));
    233 
    234     attachPage (new VBoxVMSettingsVRDP());
     221    VBoxSettingsPage *prefPage = NULL;
     222
     223    /* General page */
     224    prefPage = new VBoxVMSettingsGeneral();
     225    connect (prefPage, SIGNAL (tableChanged()), this, SLOT (resetFirstRunFlag()));
     226    addItem (VBoxGlobal::iconSet (":/machine_16px.png"),
     227             GeneralId, "#general",
     228             prefPage);
     229
     230    /* Storage page */
     231    addItem (VBoxGlobal::iconSet (":/hd_16px.png"),
     232             StorageId, "#storage");
     233
     234    /* HD page */
     235    prefPage = new VBoxVMSettingsHD();
     236    connect (prefPage, SIGNAL (hdChanged()), this, SLOT (resetFirstRunFlag()));
     237    addItem (VBoxGlobal::iconSet (":/hd_16px.png"),
     238             HDId, "#hdds",
     239             prefPage, StorageId);
     240
     241    /* CD page */
     242    prefPage = new VBoxVMSettingsCD();
     243    connect (prefPage, SIGNAL (cdChanged()), this, SLOT (resetFirstRunFlag()));
     244    addItem (VBoxGlobal::iconSet (":/cd_16px.png"),
     245             CDId, "#dvd",
     246             prefPage, StorageId);
     247
     248    /* FD page */
     249    prefPage = new VBoxVMSettingsFD();
     250    connect (prefPage, SIGNAL (fdChanged()), this, SLOT (resetFirstRunFlag()));
     251    addItem (VBoxGlobal::iconSet (":/fd_16px.png"),
     252             FDId, "#floppy",
     253             prefPage, StorageId);
     254
     255    /* Audio page */
     256    prefPage = new VBoxVMSettingsAudio();
     257    addItem (VBoxGlobal::iconSet (":/sound_16px.png"),
     258             AudioId, "#audio",
     259             prefPage);
     260
     261    /* Network page */
     262    prefPage = new VBoxVMSettingsNetworkPage();
     263    addItem (VBoxGlobal::iconSet (":/nw_16px.png"),
     264             NetworkId, "#network",
     265             prefPage);
     266
     267    /* Ports page */
     268    addItem (VBoxGlobal::iconSet (":/serial_port_16px.png"),
     269             PortsId, "#ports");
     270
     271    /* Serial page */
     272    prefPage = new VBoxVMSettingsSerialPage();
     273    addItem (VBoxGlobal::iconSet (":/serial_port_16px.png"),
     274             SerialId, "#serialPorts",
     275             prefPage, PortsId);
     276
     277    /* Parallel page */
     278    prefPage = new VBoxVMSettingsParallelPage();
     279    addItem (VBoxGlobal::iconSet (":/parallel_port_16px.png"),
     280             ParallelId, "#parallelPorts",
     281             prefPage, PortsId);
     282
     283    /* USB page */
     284    prefPage = new VBoxVMSettingsUSB (VBoxVMSettingsUSB::MachineType);
     285    addItem (VBoxGlobal::iconSet (":/usb_16px.png"),
     286             USBId, "#usb",
     287             prefPage, PortsId);
     288
     289    /* SFolders page */
     290    prefPage = new VBoxVMSettingsSF (MachineType);
     291    addItem (VBoxGlobal::iconSet (":/shared_folder_16px.png"),
     292             SFId, "#sfolders",
     293             prefPage);
     294
     295    /* VRDP page */
     296    prefPage = new VBoxVMSettingsVRDP();
     297    addItem (VBoxGlobal::iconSet (":/vrdp_16px.png"),
     298             VRDPId, "#vrdp",
     299             prefPage);
    235300
    236301    /* Applying language settings */
    237302    retranslateUi();
     303   
     304    /* First item as default */
    238305
    239306    /* Setup Settings Dialog */
     
    266333            }
    267334        }
    268     }
     335    }else
     336        mSelector->selectById (0);
     337}
     338
     339void VBoxVMSettingsDlg::addItem (const QIcon &aIcon, int aId, const QString &aLink, VBoxSettingsPage* aPrefPage /* = NULL*/, int aParentId /* = -1 */)
     340{
     341    QWidget *page = mSelector->addItem (aIcon,
     342                                        aId, aLink,
     343                                        aPrefPage, aParentId);
     344    if (page)
     345        mStack->addWidget (page);
     346    if (aPrefPage)
     347        attachValidator (aPrefPage);
    269348}
    270349
     
    277356    QString warningText;
    278357
    279     QString pageTitle = mSelector->itemTextByIndex (mStack->indexOf (pg));
    280 
    281358    VBoxSettingsPage *page = static_cast<VBoxSettingsPage*> (pg);
     359    QString pageTitle = mSelector->itemTextByPage (page);
     360
    282361    valid = page->revalidate (warningText, pageTitle);
    283362
     
    291370void VBoxVMSettingsDlg::getFrom()
    292371{
    293     QList<VBoxSettingsPage*> pages = mStack->findChildren<VBoxSettingsPage*>();
     372    QList<VBoxSettingsPage*> pages = mSelector->settingPages();
    294373    foreach (VBoxSettingsPage *page, pages)
    295374        page->getFrom (mMachine);
     
    303382void VBoxVMSettingsDlg::putBackTo()
    304383{
    305     QList<VBoxSettingsPage*> pages = mStack->findChildren<VBoxSettingsPage*>();
     384    QList<VBoxSettingsPage*> pages = mSelector->settingPages();
    306385    foreach (VBoxSettingsPage *page, pages)
    307386        page->putBackTo();
     
    322401     * vboxGlobal which is retranslated at that point already. */
    323402    QEvent event (QEvent::LanguageChange);
    324 
    325     /* Populate selector list */
    326     QWidget *curpage = 0;
    327 
    328     /* Remember old index */
    329     int cid = mSelector->currentId();
    330     /* Remove all items */
    331     mSelector->clear();
     403    QWidget *page = NULL;
    332404
    333405    /* General page */
    334     mSelector->addItem (VBoxGlobal::iconSet (":/machine_16px.png"),
    335                         tr ("General"), GeneralId, "#general");
     406    mSelector->setItemText (GeneralId, tr ("General"));
     407
     408    /* Storage page */
     409    mSelector->setItemText (StorageId, tr ("Storage"));
    336410
    337411    /* HD page */
    338     mSelector->addItem (VBoxGlobal::iconSet (":/hd_16px.png"),
    339                         tr ("Hard Disks"), HDId, "#hdds");
     412    mSelector->setItemText (HDId, tr ("Hard Disks"));
    340413
    341414    /* CD page */
    342     mSelector->addItem (VBoxGlobal::iconSet (":/cd_16px.png"),
    343                         tr ("CD/DVD-ROM"), CDId, "#dvd");
     415    mSelector->setItemText (CDId, tr ("CD/DVD-ROM"));
    344416
    345417    /* FD page */
    346     mSelector->addItem (VBoxGlobal::iconSet (":/fd_16px.png"),
    347                         tr ("Floppy"), FDId, "#floppy");
     418    mSelector->setItemText (FDId, tr ("Floppy"));
    348419
    349420    /* Audio page */
    350     mSelector->addItem (VBoxGlobal::iconSet (":/sound_16px.png"),
    351                         tr ("Audio"), AudioId, "#audio");
     421    mSelector->setItemText (AudioId, tr ("Audio"));
    352422
    353423    /* Network page */
    354     mSelector->addItem (VBoxGlobal::iconSet (":/nw_16px.png"),
    355                         tr ("Network"), NetworkId, "#network");
    356 
    357     curpage = mStack->widget (mSelector->idToIndex (NetworkId));
    358     if (curpage)
    359         qApp->sendEvent (curpage, &event);
     424    mSelector->setItemText (NetworkId, tr ("Network"));
     425    if ((page = mSelector->idToPage (NetworkId)))
     426        qApp->sendEvent (page, &event);
     427
     428    /* Ports page */
     429    mSelector->setItemText (PortsId, tr ("Ports"));
    360430
    361431    /* Serial page */
    362     mSelector->addItem (VBoxGlobal::iconSet (":/serial_port_16px.png"),
    363                         tr ("Serial Ports"), SerialId, "#serialPorts");
    364 
    365     curpage = mStack->widget (mSelector->idToIndex (SerialId));
    366     if (curpage)
    367         qApp->sendEvent (curpage, &event);
     432    mSelector->setItemText (SerialId, tr ("Serial Ports"));
     433    if ((page = mSelector->idToPage (SerialId)))
     434        qApp->sendEvent (page, &event);
    368435
    369436    /* Parallel page */
    370     mSelector->addItem (VBoxGlobal::iconSet (":/parallel_port_16px.png"),
    371                         tr ("Parallel Ports"), ParallelId, "#parallelPorts");
    372 
    373     curpage = mStack->widget (mSelector->idToIndex (ParallelId));
    374     if (curpage)
    375         qApp->sendEvent (curpage, &event);
     437    mSelector->setItemText (ParallelId, tr ("Parallel Ports"));
     438    if ((page = mSelector->idToPage (ParallelId)))
     439        qApp->sendEvent (page, &event);
    376440
    377441    /* USB page */
    378     mSelector->addItem (VBoxGlobal::iconSet (":/usb_16px.png"),
    379                         tr ("USB"), USBId, "#usb");
     442    mSelector->setItemText (USBId, tr ("USB"));
    380443
    381444    /* SFolders page */
    382     mSelector->addItem (VBoxGlobal::iconSet (":/shared_folder_16px.png"),
    383                         tr ("Shared Folders"), SFId, "#sfolders");
     445    mSelector->setItemText (SFId, tr ("Shared Folders"));
    384446
    385447    /* VRDP page */
    386     mSelector->addItem (VBoxGlobal::iconSet (":/vrdp_16px.png"),
    387                         tr ("Remote Display"), VRDPId, "#vrdp");
     448    mSelector->setItemText (VRDPId, tr ("Remote Display"));
    388449
    389450    /* Translate the selector */
     
    391452
    392453    VBoxSettingsDialog::retranslateUi();
    393 
    394     /* Select old remembered category */
    395     mSelector->selectById (cid == -1 ? 0 : cid);
    396454
    397455    /* Update QTreeWidget with available items */
     
    425483}
    426484
    427 VBoxSettingsPage* VBoxVMSettingsDlg::attachPage (VBoxSettingsPage *aPage)
    428 {
    429     mStack->addWidget (aPage);
    430 
    431     QIWidgetValidator *wval = new QIWidgetValidator (mSelector->itemTextByIndex (mStack->indexOf (aPage)),
     485VBoxSettingsPage* VBoxVMSettingsDlg::attachValidator (VBoxSettingsPage *aPage)
     486{
     487    QIWidgetValidator *wval = new QIWidgetValidator (mSelector->itemTextByPage (aPage),
    432488                                                     aPage, this);
    433489    connect (wval, SIGNAL (validityChanged (const QIWidgetValidator*)),
     
    449505    /* Parallel Port Page (currently disabled) */
    450506    mSelector->setVisibleById (ParallelId, false);
    451     int index = mSelector->idToIndex (ParallelId);
    452     if (index > -1)
    453     {
    454         if (mStack->widget (index))
    455             mStack->widget (index)->setEnabled (false);
    456     }
    457507
    458508    /* USB Stuff */
     
    468518         * not available (i.e. in VirtualBox OSE) */
    469519        mSelector->setVisibleById (USBId, false);
    470         int index = mSelector->idToIndex (USBId);
    471         if (index > -1)
    472         {
    473             if (mStack->widget (index))
    474                 mStack->widget (index)->setEnabled (false);
    475         }
    476520    }
    477521
     
    483527         * not available (i.e. in VirtualBox OSE) */
    484528        mSelector->setVisibleById (VRDPId, false);
    485         int index = mSelector->idToIndex (VRDPId);
    486         if (index > -1)
    487         {
    488             if (mStack->widget (index))
    489                 mStack->widget (index)->setEnabled (false);
    490         }
    491529        /* If mMachine has something to say, show the message */
    492530        vboxProblem().cannotLoadMachineSettings (mMachine, false /* strict */);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSettingsSelector.cpp

    r10475 r10604  
    2323#include "VBoxSettingsSelector.h"
    2424#include "VBoxSettingsUtils.h"
     25#include "VBoxSettingsPage.h"
    2526#include "QITreeWidget.h"
    2627#include "VBoxToolBar.h"
     28
     29/* Qt includes */
     30#include <QTabWidget>
    2731
    2832enum
     
    3438};
    3539
     40class SelectorItem
     41{
     42public:
     43    SelectorItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink, VBoxSettingsPage* aPage, int aParentId)
     44        : mIcon (aIcon)
     45        , mText (aText)
     46        , mId (aId)
     47        , mLink (aLink)
     48        , mPage (aPage)
     49        , mParentId (aParentId)
     50    {}
     51
     52    QIcon icon() const { return mIcon; }
     53    QString text() const { return mText; }
     54    void setText (const QString &aText) { mText = aText; }
     55    int id() const { return mId; }
     56    QString link() const { return mLink; }
     57    VBoxSettingsPage *page() const { return mPage; }
     58    int parentId() const { return mParentId; }
     59
     60protected:
     61
     62    QIcon mIcon;
     63    QString mText;
     64    int mId;
     65    QString mLink;
     66    VBoxSettingsPage* mPage;
     67    int mParentId;
     68};
     69
    3670VBoxSettingsSelector::VBoxSettingsSelector (QWidget *aParent /* = NULL */)
    3771    :QObject (aParent)
    3872{
     73}
     74
     75void VBoxSettingsSelector::setItemText (int aId, const QString &aText)
     76{
     77    if (SelectorItem *item = findItem (aId))
     78        item->setText (aText);
     79}
     80
     81QString VBoxSettingsSelector::itemTextByPage (VBoxSettingsPage *aPage) const
     82{
     83    QString text;
     84    if (SelectorItem *item = findItemByPage (aPage))
     85        text = item->text();
     86    return text;
     87}
     88
     89QWidget *VBoxSettingsSelector::idToPage (int aId) const
     90{
     91    VBoxSettingsPage *page = NULL;
     92    if (SelectorItem *item = findItem (aId))
     93        page = item->page();
     94    return page;
     95}
     96
     97QList<VBoxSettingsPage*> VBoxSettingsSelector::settingPages() const
     98{
     99    QList<VBoxSettingsPage*> list;
     100    foreach (SelectorItem *item, mItemList)
     101        if (item->page())
     102            list << item->page();
     103    return list;
     104}
     105
     106QList<QWidget*> VBoxSettingsSelector::rootPages() const
     107{
     108    QList<QWidget*> list;
     109    foreach (SelectorItem *item, mItemList)
     110        if (item->page())
     111            list << item->page();
     112    return list;
     113}
     114
     115
     116SelectorItem *VBoxSettingsSelector::findItem (int aId) const
     117{
     118    SelectorItem *result = NULL;
     119    foreach (SelectorItem *item, mItemList)
     120        if (item->id() == aId)
     121        {
     122            result = item;
     123            break;
     124        }
     125    return result;
     126}
     127
     128SelectorItem *VBoxSettingsSelector::findItemByLink (const QString &aLink) const
     129{
     130    SelectorItem *result = NULL;
     131    foreach (SelectorItem *item, mItemList)
     132        if (item->link() == aLink)
     133        {
     134            result = item;
     135            break;
     136        }
     137    return result;
     138}
     139
     140SelectorItem *VBoxSettingsSelector::findItemByPage (VBoxSettingsPage* aPage) const
     141{
     142    SelectorItem *result = NULL;
     143    foreach (SelectorItem *item, mItemList)
     144        if (item->page() == aPage)
     145        {
     146            result = item;
     147            break;
     148        }
     149    return result;
    39150}
    40151
     
    90201}
    91202
    92 void VBoxSettingsTreeViewSelector::addItem (const QIcon &aIcon,
    93                                         const QString &aText,
    94                                         int aId,
    95                                         const QString &aLink)
    96 {
    97     QTreeWidgetItem *item = new QTreeWidgetItem (mTwSelector, QStringList() << QString (" %1 ").arg (aText)
    98                                                                             << idToString (aId)
    99                                                                             << aLink);
    100     item->setIcon (treeWidget_Category, aIcon);
     203QWidget *VBoxSettingsTreeViewSelector::addItem (const QIcon &aIcon,
     204                                                int aId,
     205                                                const QString &aLink,
     206                                                VBoxSettingsPage* aPage /* = NULL */,
     207                                                int aParentId /* = -1 */)
     208{
     209    QWidget *result = NULL;
     210    if (aPage != NULL)
     211    {
     212        SelectorItem *item = new SelectorItem (aIcon, "", aId, aLink, aPage, aParentId);
     213        mItemList.append (item);
     214
     215        QTreeWidgetItem *twitem = new QTreeWidgetItem (mTwSelector, QStringList() << QString ("")
     216                                                                                  << idToString (aId)
     217                                                                                  << aLink);
     218        twitem->setIcon (treeWidget_Category, aIcon);
     219        result = aPage;
     220    }
     221    return result;
     222}
     223
     224void VBoxSettingsTreeViewSelector::setItemText (int aId, const QString &aText)
     225{
     226    VBoxSettingsSelector::setItemText (aId, aText);
     227    QTreeWidgetItem *item = findItem (mTwSelector, idToString (aId), treeWidget_Id);
     228    if (item)
     229        item->setText (treeWidget_Category, QString (" %1 ").arg (aText));
    101230}
    102231
     
    115244}
    116245
    117 int VBoxSettingsTreeViewSelector::idToIndex (int aId) const
    118 {
    119     int index = -1;
    120     QTreeWidgetItem *item = findItem (mTwSelector, idToString (aId), treeWidget_Id);
    121     if (item)
    122         index = mTwSelector->indexOfTopLevelItem (item);
    123     return index;
    124 }
    125 
    126 int VBoxSettingsTreeViewSelector::indexToId (int aIndex) const
     246int VBoxSettingsTreeViewSelector::linkToId (const QString &aLink) const
    127247{
    128248    int id = -1;
    129     QTreeWidgetItem *item = mTwSelector->topLevelItem (aIndex);
     249    QTreeWidgetItem *item = findItem (mTwSelector, aLink, treeWidget_Link);
    130250    if (item)
    131251        id = item->text (treeWidget_Id).toInt();
     
    133253}
    134254
    135 int VBoxSettingsTreeViewSelector::linkToId (const QString &aLink) const
    136 {
    137     int id = -1;
    138     QTreeWidgetItem *item = findItem (mTwSelector, aLink, treeWidget_Link);
    139     if (item)
    140         id = item->text (treeWidget_Id).toInt();
    141     return id;
    142 }
    143 
    144255
    145256void VBoxSettingsTreeViewSelector::selectById (int aId)
     
    155266    if (item)
    156267        item->setHidden (aShow);
    157 }
    158 
    159 void VBoxSettingsTreeViewSelector::clear()
    160 {
    161     mTwSelector->clear();
    162268}
    163269
     
    184290        emit categoryChanged (id);
    185291    }
     292}
     293
     294void VBoxSettingsTreeViewSelector::clear()
     295{
     296    mTwSelector->clear();
    186297}
    187298
     
    202313 * searching the 'aColumn' column. */
    203314QTreeWidgetItem* VBoxSettingsTreeViewSelector::findItem (QTreeWidget *aView,
    204                                                      const QString &aMatch,
    205                                                      int aColumn) const
     315                                                         const QString &aMatch,
     316                                                         int aColumn) const
    206317{
    207318    QList<QTreeWidgetItem*> list =
     
    218329/* VBoxSettingsToolBarSelector */
    219330
    220 class SelectorAction: public QAction
     331
     332class SelectorActionItem: public SelectorItem
    221333{
    222334public:
    223     SelectorAction (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink, QObject *aParent)
    224         : QAction (aIcon, aText, aParent)
    225         , mId (aId)
    226         , mLink (aLink)
    227     {
    228         setCheckable (true);
    229     }
    230 
    231     int id() const { return mId; }
    232     QString link() const { return mLink; }
    233 
    234 private:
    235     int mId;
    236     QString mLink;
     335    SelectorActionItem (const QIcon &aIcon, const QString &aText, int aId, const QString &aLink, VBoxSettingsPage* aPage, int aParentId, QObject *aParent)
     336        : SelectorItem (aIcon, aText, aId, aLink, aPage, aParentId)
     337        , mAction (new QAction (aIcon, aText, aParent))
     338        , mTabWidget (NULL)
     339    {
     340        mAction->setCheckable (true);
     341    }
     342
     343    QAction *action() const { return mAction; }
     344
     345    void setTabWidget (QTabWidget *aTabWidget) { mTabWidget = aTabWidget; }
     346    QTabWidget *tabWidget() const { return mTabWidget; }
     347
     348protected:
     349
     350    QAction *mAction;
     351    QTabWidget *mTabWidget;
    237352};
    238353
    239354VBoxSettingsToolBarSelector::VBoxSettingsToolBarSelector (QWidget *aParent /* = NULL */)
    240     :VBoxSettingsSelector (aParent)
     355    : VBoxSettingsSelector (aParent)
    241356{
    242357    /* Init the toolbar */
     
    251366}
    252367
     368VBoxSettingsToolBarSelector::~VBoxSettingsToolBarSelector()
     369{
     370}
     371
    253372QWidget *VBoxSettingsToolBarSelector::widget() const
    254373{
     
    256375}
    257376
    258 void VBoxSettingsToolBarSelector::addItem (const QIcon &aIcon,
    259                                         const QString &aText,
    260                                         int aId,
    261                                         const QString &aLink)
    262 {
    263     SelectorAction *action = new SelectorAction (aIcon, aText, aId, aLink, this);
    264 
    265     mActionGroup->addAction (action);
    266     mTbSelector->addAction (action);
     377QWidget *VBoxSettingsToolBarSelector::addItem (const QIcon &aIcon,
     378                                               int aId,
     379                                               const QString &aLink,
     380                                               VBoxSettingsPage* aPage /* = NULL */,
     381                                               int aParentId /* = -1 */)
     382{
     383    QWidget *result = NULL;
     384    SelectorActionItem *item = new SelectorActionItem (aIcon, "", aId, aLink, aPage, aParentId, this);
     385    mItemList.append (item);
     386
     387    if (aParentId == -1 &&
     388        aPage != NULL)
     389    {
     390        mActionGroup->addAction (item->action());
     391        mTbSelector->addAction (item->action());
     392        result = aPage;
     393    }
     394    else if (aParentId == -1 &&
     395             aPage == NULL)
     396    {
     397        mActionGroup->addAction (item->action());
     398        mTbSelector->addAction (item->action());
     399        QTabWidget *tabWidget= new QTabWidget ();
     400//        connect (tabWidget, SIGNAL (currentChanged (int)),
     401//                 this, SLOT (settingsGroupChanged (int)));
     402        item->setTabWidget (tabWidget);
     403        result = tabWidget;
     404    }else
     405    {
     406        SelectorActionItem *parent = findActionItem (aParentId);
     407        if (parent)
     408        {
     409            QTabWidget *tabWidget = parent->tabWidget();
     410            if (tabWidget)
     411                tabWidget->addTab (aPage, aIcon, "");
     412        }
     413    }
     414    return result;
     415}
     416
     417void VBoxSettingsToolBarSelector::setItemText (int aId, const QString &aText)
     418{
     419    if (SelectorActionItem *item = findActionItem (aId))
     420    {
     421        item->setText (aText);
     422        if (item->action())
     423            item->action()->setText (aText);
     424        if (item->parentId() &&
     425            item->page())
     426        {
     427            SelectorActionItem *parent = findActionItem (item->parentId());
     428            if (parent &&
     429                parent->tabWidget())
     430                parent->tabWidget()->setTabText (
     431                    parent->tabWidget()->indexOf (item->page()), aText);
     432        }
     433    }
    267434}
    268435
     
    270437{
    271438    QString result;
    272     SelectorAction *action = findAction (aId);
    273     if (action)
    274         result = action->text();
     439    if (SelectorItem *item = findItem (aId))
     440        result = item->text();
    275441    return result;
    276442}
     
    278444int VBoxSettingsToolBarSelector::currentId () const
    279445{
    280     SelectorAction *action = static_cast<SelectorAction*> (mActionGroup->checkedAction());
     446    SelectorActionItem *action = findActionItemByAction (mActionGroup->checkedAction());
    281447    int id = -1;
    282448    if (action)
     
    285451}
    286452
    287 int VBoxSettingsToolBarSelector::idToIndex (int aId) const
    288 {
    289     int index = -1;
    290     QList<QAction*> list = mActionGroup->actions();
    291     for (int a = 0; a < list.count(); ++a)
    292     {
    293         SelectorAction *sa = static_cast<SelectorAction*> (list.at(a));
    294         if (sa &&
    295             sa->id() == aId)
    296         {
    297             index = a;
    298             break;
    299         }
    300     }
    301     return index;
    302 }
    303 
    304 int VBoxSettingsToolBarSelector::indexToId (int aIndex) const
     453int VBoxSettingsToolBarSelector::linkToId (const QString &aLink) const
    305454{
    306455    int id = -1;
    307     QList<QAction*> list = mActionGroup->actions();
    308     if (aIndex > -1 &&
    309         aIndex < list.count())
    310     {
    311         SelectorAction *sa = static_cast<SelectorAction*> (list.at (aIndex));
    312         if (sa)
    313             id = sa->id();
    314     }
     456    SelectorItem *item = VBoxSettingsSelector::findItemByLink (aLink);
     457    if (item)
     458        id = item->id();
    315459    return id;
    316460}
    317461
    318 int VBoxSettingsToolBarSelector::linkToId (const QString &aLink) const
    319 {
    320     int id = -1;
    321     QList<QAction*> list = mActionGroup->actions();
    322     for (int a = 0; a < list.count(); ++a)
    323     {
    324         SelectorAction *sa = static_cast<SelectorAction*> (list.at(a));
    325         if (sa &&
    326             sa->link() == aLink)
    327         {
    328             id = sa->id();
    329             break;
    330         }
    331     }
    332     return id;
    333 }
    334 
     462QWidget *VBoxSettingsToolBarSelector::idToPage (int aId) const
     463{
     464    QWidget *page = NULL;
     465    if (SelectorActionItem *item = findActionItem (aId))
     466    {
     467        page = item->page();
     468        if (!page)
     469            page = item->tabWidget();
     470    }
     471    return page;
     472}
     473
     474QWidget *VBoxSettingsToolBarSelector::rootPage (int aId) const
     475{
     476    QWidget *page = NULL;
     477    if (SelectorActionItem *item = findActionItem (aId))
     478    {
     479        if (item->parentId() > -1)
     480            page = rootPage (item->parentId());
     481        else if (item->page())
     482            page = item->page();
     483        else
     484            page = item->tabWidget();
     485    }
     486    return page;
     487}
    335488
    336489void VBoxSettingsToolBarSelector::selectById (int aId)
    337490{
    338     SelectorAction *action = findAction (aId);
    339 
    340     if (action)
    341         action->trigger();
    342 }
     491    if (SelectorActionItem *item = findActionItem (aId))
     492    {
     493        if (item->parentId() != -1)
     494        {
     495            SelectorActionItem *parent = findActionItem (item->parentId());
     496            if (parent &&
     497                parent->tabWidget())
     498            {
     499                parent->action()->trigger();
     500                parent->tabWidget()->setCurrentIndex (
     501                    parent->tabWidget()->indexOf (item->page()));
     502            }
     503        }
     504        else
     505            item->action()->trigger();
     506    }
     507}
     508
    343509
    344510void VBoxSettingsToolBarSelector::setVisibleById (int aId, bool aShow)
    345511{
    346     SelectorAction *action = findAction (aId);
    347 
    348     if (action)
    349         action->setVisible (aShow);
     512    SelectorActionItem *item = findActionItem (aId);
     513
     514    if (item)
     515    {
     516        item->action()->setVisible (aShow);
     517        if (item->parentId() > -1 &&
     518            item->page())
     519        {
     520            SelectorActionItem *parent = findActionItem (item->parentId());
     521            if (parent &&
     522                parent->tabWidget())
     523            {
     524                if (aShow &&
     525                    parent->tabWidget()->indexOf (item->page()) == -1)
     526                    parent->tabWidget()->addTab (item->page(), item->text());
     527                else if (!aShow &&
     528                         parent->tabWidget()->indexOf (item->page()) > -1)
     529                    parent->tabWidget()->removeTab (
     530                        parent->tabWidget()->indexOf (item->page()));
     531            }
     532        }
     533    }
     534
    350535}
    351536
     
    364549void VBoxSettingsToolBarSelector::settingsGroupChanged (QAction *aAction)
    365550{
    366     SelectorAction *action = static_cast<SelectorAction*> (aAction);
    367     if (action)
    368         emit categoryChanged (action->id());
    369 }
    370 
    371 SelectorAction* VBoxSettingsToolBarSelector::findAction (int aId) const
    372 {
    373     int index = idToIndex (aId);
    374     SelectorAction *sa = NULL;
    375     QList<QAction*> list = mActionGroup->actions();
    376     if (index > -1 &&
    377         index < list.count())
    378         sa = static_cast<SelectorAction*> (list.at (index));
    379     return sa;
    380 }
    381 
     551    SelectorActionItem *item = findActionItemByAction (aAction);
     552    if (item)
     553    {
     554        emit categoryChanged (item->id());
     555//        if (item->page() &&
     556//            !item->tabWidget())
     557//            emit categoryChanged (item->id());
     558//        else
     559//        {
     560//
     561//            item->tabWidget()->blockSignals (true);
     562//            item->tabWidget()->setCurrentIndex (0);
     563//            item->tabWidget()->blockSignals (false);
     564//            printf ("%s\n", qPrintable(item->text()));
     565//            SelectorActionItem *child = static_cast<SelectorActionItem*> (
     566//                findItemByPage (static_cast<VBoxSettingsPage*> (item->tabWidget()->currentWidget())));
     567//            if (child)
     568//                emit categoryChanged (child->id());
     569//        }
     570    }
     571}
     572
     573void VBoxSettingsToolBarSelector::settingsGroupChanged (int aIndex)
     574{
     575    SelectorActionItem *item = findActionItemByTabWidget (qobject_cast<QTabWidget*> (sender()), aIndex);
     576    if (item)
     577    {
     578        if (item->page() &&
     579            !item->tabWidget())
     580            emit categoryChanged (item->id());
     581        else
     582        {
     583            SelectorActionItem *child = static_cast<SelectorActionItem*> (
     584                findItemByPage (static_cast<VBoxSettingsPage*> (item->tabWidget()->currentWidget())));
     585            if (child)
     586                emit categoryChanged (child->id());
     587        }
     588    }
     589}
     590
     591SelectorActionItem* VBoxSettingsToolBarSelector::findActionItem (int aId) const
     592{
     593    return static_cast<SelectorActionItem*> (VBoxSettingsSelector::findItem (aId));
     594}
     595
     596SelectorActionItem *VBoxSettingsToolBarSelector::findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const
     597{
     598    SelectorActionItem *result = NULL;
     599    foreach (SelectorItem *item, mItemList)
     600        if (static_cast<SelectorActionItem*> (item)->tabWidget() == aTabWidget)
     601        {
     602            QTabWidget *tw = static_cast<SelectorActionItem*> (item)->tabWidget();
     603            result = static_cast<SelectorActionItem*> (
     604                findItemByPage (static_cast<VBoxSettingsPage*> (tw->widget (aIndex))));
     605            break;
     606        }
     607
     608    return result;
     609
     610}
     611
     612QList<QWidget*> VBoxSettingsToolBarSelector::rootPages() const
     613{
     614    QList<QWidget*> list;
     615    foreach (SelectorItem *item, mItemList)
     616    {
     617        SelectorActionItem *ai = static_cast<SelectorActionItem*> (item);
     618        if (ai->parentId() == -1 &&
     619            ai->page())
     620            list << ai->page();
     621        else if (ai->tabWidget())
     622            list << ai->tabWidget();
     623    }
     624    return list;
     625}
     626
     627SelectorActionItem *VBoxSettingsToolBarSelector::findActionItemByAction (QAction *aAction) const
     628{
     629    SelectorActionItem *result = NULL;
     630    foreach (SelectorItem *item, mItemList)
     631        if (static_cast<SelectorActionItem*> (item)->action() == aAction)
     632        {
     633            result = static_cast<SelectorActionItem*> (item);
     634            break;
     635        }
     636
     637    return result;
     638}
     639
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsHD.cpp

    r10167 r10604  
    889889    QWidget *current = QApplication::focusWidget();
    890890    mTwAts->setFocus (Qt::TabFocusReason);
    891     current->setFocus (Qt::TabFocusReason);
    892 }
    893 
     891    if (current)
     892        current->setFocus (Qt::TabFocusReason);
     893}
     894
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