VirtualBox

Changeset 6811

Show
Ignore:
Timestamp:
02/05/08 17:22:40 (10 months ago)
Author:
vboxsync
Message:

2626: FE/Qt support for readonly shared folders:

Latest updates:
1. "Read-only" and "Create permanent share" checkboxes are one below another (not in one line).
2. Column widths (name & access) in the list are adjusted by minimum.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui

    r6724 r6811  
    231231    <include location="global" impldecl="in implementation">qlineedit.h</include> 
    232232    <include location="global" impldecl="in implementation">qregexp.h</include> 
     233    <include location="global" impldecl="in implementation">qtimer.h</include> 
    233234</includes> 
    234235<variables> 
     
    247248    <slot>processCurrentChanged( QListViewItem* )</slot> 
    248249    <slot>processDoubleClick( QListViewItem* )</slot> 
     250    <slot>adjustList()</slot> 
    249251</slots> 
    250252<functions> 
    251253    <function access="private">init()</function> 
     254    <function access="private">showEvent( QShowEvent* )</function> 
    252255    <function returnType="bool" access="private">eventFilter( QObject*, QEvent* )</function> 
    253256    <function>setDialogType( int )</function> 
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxSharedFoldersSettings.ui.h

    r6763 r6811  
    8585    } 
    8686 
    87     QString getText (int aIndex) 
     87    QString getText (int aIndex) const 
    8888    { 
    8989        return aIndex >= 0 && aIndex < (int)mTextList.size() ? 
     
    104104        processColumn (aColumn, aWidth); 
    105105        QListViewItem::paintCell (aPainter, aColorGroup, aColumn, aWidth, aAlign); 
     106    } 
     107 
     108    int width (const QFontMetrics &aFontMetrics, const QListView *, int aColumn) const 
     109    { 
     110        return aFontMetrics.boundingRect (getText (aColumn)).width() + 
     111               aFontMetrics.width ("...x") /* indent size */ ; 
    106112    } 
    107113 
     
    223229        inputLayout->addMultiCellWidget (mLeName, 1, 1, 1, 2); 
    224230 
    225         QHBoxLayout *cbLayout = new QHBoxLayout (0, "cbLayout"); 
    226         inputLayout->addMultiCellLayout (cbLayout, 2, 2, 0, 2); 
    227231        mCbReadonly = new QCheckBox (tr ("&Read-only"), this); 
    228232        QWhatsThis::add (mCbReadonly, 
    229233            tr ("When checked, the guest OS will not be able to write to the " 
    230234                "specified shared folder.")); 
    231  
    232235        mCbReadonly->setChecked (false); 
    233         cbLayout->addWidget (mCbReadonly); 
     236        inputLayout->addMultiCellWidget (mCbReadonly, 2, 2, 0, 2); 
     237 
    234238        if (aEnableSelector) 
    235239        { 
    236             mCbPermanent = new QCheckBox ( tr ("&Make Permanent"), this); 
     240            mCbPermanent = new QCheckBox (tr ("&Make Permanent"), this); 
    237241            mCbPermanent->setChecked (true); 
    238             cbLayout->addWidget (mCbPermanent); 
     242            inputLayout->addMultiCellWidget (mCbPermanent, 3, 3, 0, 2); 
    239243            connect (mCbPermanent, SIGNAL (toggled (bool)), 
    240244                     this, SLOT (validate())); 
     
    375379} 
    376380 
     381void VBoxSharedFoldersSettings::showEvent (QShowEvent *aEvent) 
     382{ 
     383    QWidget::showEvent (aEvent); 
     384 
     385    /* Adjusting size after all pending show events are processed. */ 
     386    QTimer::singleShot (0, this, SLOT (adjustList())); 
     387} 
     388 
     389 
     390void VBoxSharedFoldersSettings::adjustList() 
     391{ 
     392    /* Adjust two columns size. 
     393     * Watching columns 0&2 to feat 1/3 of total width. */ 
     394    int total = listView->columnWidth (0) + 
     395                listView->columnWidth (1) + 
     396                listView->columnWidth (2); 
     397 
     398    listView->adjustColumn (0); 
     399    int w0 = listView->columnWidth (0) < total / 3 ? 
     400             listView->columnWidth (0) : total / 3; 
     401 
     402    listView->adjustColumn (2); 
     403    int w2 = listView->columnWidth (2) < total / 3 ? 
     404             listView->columnWidth (2) : total / 3; 
     405 
     406    /* We are adjusting columns 0 and 2 and resizing column 1 to feat 
     407     * visible listView' width according two adjusted columns. Due to  
     408     * adjusting column 2 influent column 0 restoring all widths. */ 
     409    listView->setColumnWidth (0, w0); 
     410    listView->setColumnWidth (1, total - w0 - w2); 
     411    listView->setColumnWidth (2, w2); 
     412} 
     413     
    377414bool VBoxSharedFoldersSettings::eventFilter (QObject *aObject, QEvent *aEvent) 
    378415{ 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy