VirtualBox

Changeset 8301 in vbox for trunk/src


Ignore:
Timestamp:
Apr 22, 2008 3:46:25 PM (17 years ago)
Author:
vboxsync
Message:

Switch SATA Settings UI to "edit-on-focus" policy.

File:
1 edited

Legend:

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

    r8282 r8301  
    165165            setListBox (new QListBox (this));
    166166
     167        setFocusPolicy (QWidget::NoFocus);
    167168        refresh();
    168169        mUniq->subscribe (this);
    169         qApp->installEventFilter (this);
    170170        connect (mUniq, SIGNAL (listChanged()), this, SLOT (refresh()));
     171        connect (mUniq, SIGNAL (listChanged()), this, SLOT (updateToolTip()));
    171172        connect (this, SIGNAL (activated (int)), mUniq, SIGNAL (listChanged()));
    172173        connect (this, SIGNAL (textChanged()), mUniq, SIGNAL (listChanged()));
     
    227228    }
    228229
     230    void updateToolTip()
     231    {
     232        QString oldTip = QToolTip::textFor (this);
     233        QString newTip = currentText();
     234
     235        if (newTip != oldTip)
     236        {
     237            QToolTip::remove (this);
     238            QToolTip::add (this, newTip);
     239        }
     240    }
     241
    229242signals:
    230243
     
    232245
    233246private:
    234 
    235     bool eventFilter (QObject *aObject, QEvent *aEvent)
    236     {
    237         if (aObject != listBox())
    238             return false;
    239 
    240         if (aEvent->type() == QEvent::Hide)
    241             hide();
    242 
    243         return QComboBox::eventFilter (aObject, aEvent);
    244     }
    245247
    246248    HDSlotUniquizer *mUniq;
     
    263265        , mItem (aItem)
    264266    {
    265         qApp->installEventFilter (this);
     267        setFocusPolicy (QWidget::NoFocus);
    266268        connect (&vboxGlobal(),
    267269                 SIGNAL (mediaRemoved (VBoxDefs::DiskType, const QUuid &)),
     
    277279
    278280private:
    279 
    280     bool eventFilter (QObject *aObject, QEvent *aEvent)
    281     {
    282         if (aObject != listBox())
    283             return false;
    284 
    285         if (aEvent->type() == QEvent::Hide)
    286             hide();
    287 
    288         return VBoxMediaComboBox::eventFilter (aObject, aEvent);
    289     }
    290281
    291282    QListViewItem *mItem;
     
    415406    {
    416407        if (mVector [mFocusColumn]->count())
    417         {
    418             mVector [mFocusColumn]->show();
    419408            mVector [mFocusColumn]->popup();
    420         }
    421409    }
    422410
     
    482470        cb->resize (wc, hc);
    483471
    484         QColorGroup cg (aColorGroup);
    485         if (aColumn == mFocusColumn)
    486         {
    487             cg.setColor (QColorGroup::Base, aColorGroup.highlight());
    488             cg.setColor (QColorGroup::Text, aColorGroup.highlightedText());
    489         }
    490         QListViewItem::paintCell (aPainter, cg, aColumn, aWidth, aAlign);
    491     }
    492 
    493     void paintFocus (QPainter *aPainter, const QColorGroup &aColorGroup,
    494                      const QRect &aRect)
    495     {
    496         if (mFocusColumn != -1)
    497         {
    498             int indent = 0;
    499             for (int i = 0; i < mFocusColumn; ++ i)
    500                 indent = listView()->columnWidth (i);
    501 
    502             QRect newFocus (QPoint (aRect.x() + indent, aRect.y()),
    503                             QSize (listView()->columnWidth (mFocusColumn),
    504                                    aRect.height()));
    505 
    506             QListViewItem::paintFocus (aPainter, aColorGroup, newFocus);
    507         }
     472        if (aColumn == mFocusColumn && cb->isHidden())
     473            cb->show();
     474        else if (aColumn != mFocusColumn && !cb->isHidden())
     475            cb->hide();
     476
     477        QListViewItem::paintCell (aPainter, aColorGroup, aColumn, aWidth, aAlign);
     478    }
     479
     480    void paintFocus (QPainter *, const QColorGroup &, const QRect &)
     481    {
     482        /* Do not paint focus, because it presented by combo-box */
    508483    }
    509484
     
    920895                static_cast<HDListItem*> (clickedItem) : 0;
    921896
    922             if (item)
    923                 item->showEditor();
    924             else if (mAddAttachmentAct->isEnabled())
     897            if (!item && mAddAttachmentAct->isEnabled())
    925898                addHDItem();
    926899            break;
     
    930903        {
    931904            if (aObject != mLvHD->viewport())
     905            {
     906                if (!QToolTip::textFor (mLvHD->viewport()).isNull())
     907                    QToolTip::remove (mLvHD->viewport());
    932908                break;
     909            }
    933910
    934911            QMouseEvent *e = static_cast<QMouseEvent*> (aEvent);
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