VirtualBox

Changeset 104979 in vbox


Ignore:
Timestamp:
Jun 20, 2024 1:19:45 PM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
163589
Message:

FE/Qt: bugref:10666, bugref:10669: Another part of cleanup for QILineEdit; This is the 2nd step, renaming, wiping unused stuff, adding comments.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp

    r104978 r104979  
    3030#include <QClipboard>
    3131#include <QContextMenuEvent>
    32 #include <QHBoxLayout>
    3332#include <QLabel>
    3433#include <QMenu>
     
    3938#include "UIDesktopWidgetWatchdog.h"
    4039#include "UIIconPool.h"
    41 
    42 /* Other VBox includes: */
    43 #include "iprt/assert.h"
    4440
    4541
     
    5046    , m_fMarkable(false)
    5147    , m_fMarkForError(false)
    52     , m_pIconLabel(0)
     48    , m_pLabelIcon(0)
    5349    , m_iIconMargin(0)
    5450{
     
    6258    , m_fMarkable(false)
    6359    , m_fMarkForError(false)
    64     , m_pIconLabel(0)
     60    , m_pLabelIcon(0)
    6561    , m_iIconMargin(0)
    6662{
     
    8581void QILineEdit::setMarkable(bool fMarkable)
    8682{
     83    /* Sanity check: */
    8784    if (m_fMarkable == fMarkable)
    8885        return;
     86
     87    /* Save new value, show/hide label accordingly: */
    8988    m_fMarkable = fMarkable;
    9089    update();
     
    9392void QILineEdit::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage)
    9493{
    95     AssertPtrReturnVoid(m_pIconLabel);
    96     if (!m_fMarkable)
     94    /* Sanity check: */
     95    if (   !m_pLabelIcon
     96        || !m_fMarkable)
    9797        return;
    9898
     99    /* Assign corresponding icon: */
    99100    const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png");
    100101    const int iIconMetric = qMin((int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625), height());
    101     const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel);
     102    const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pLabelIcon);
    102103    const QString strToolTip = fError ? strErrorMessage : strNoErrorMessage;
    103104    const QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio);
    104     m_pIconLabel->setPixmap(iconPixmap);
    105     m_pIconLabel->resize(m_pIconLabel->minimumSizeHint());
    106     m_pIconLabel->setToolTip(strToolTip);
    107     m_iIconMargin = (height() - m_pIconLabel->height()) / 2;
     105    m_pLabelIcon->setPixmap(iconPixmap);
     106    m_pLabelIcon->resize(m_pLabelIcon->minimumSizeHint());
     107    m_pLabelIcon->setToolTip(strToolTip);
     108    m_iIconMargin = (height() - m_pLabelIcon->height()) / 2;
    108109    update();
    109110}
     
    111112bool QILineEdit::event(QEvent *pEvent)
    112113{
     114    /* Depending on event type: */
    113115    switch (pEvent->type())
    114116    {
     
    131133            break;
    132134    }
     135
     136    /* Call to base-class: */
    133137    return QLineEdit::event(pEvent);
    134138}
     
    140144    if (m_fMarkable)
    141145    {
    142         m_pIconLabel->resize(m_pIconLabel->minimumSizeHint());
    143         m_iIconMargin = (height() - m_pIconLabel->height()) / 2;
     146        m_pLabelIcon->resize(m_pLabelIcon->minimumSizeHint());
     147        m_iIconMargin = (height() - m_pLabelIcon->height()) / 2;
    144148        moveIconLabel();
    145149    }
     
    174178
    175179    /* Prepare icon label: */
    176     m_pIconLabel = new QLabel(this);
     180    m_pLabelIcon = new QLabel(this);
    177181}
    178182
     
    199203void QILineEdit::moveIconLabel()
    200204{
    201     AssertPtrReturnVoid(m_pIconLabel);
    202     m_pIconLabel->move(width() - m_pIconLabel->width() - m_iIconMargin, m_iIconMargin);
    203 }
     205    /* Sanity check: */
     206    if (   !m_pLabelIcon
     207        || !m_fMarkable)
     208        return;
     209
     210    /* We do it cause we have manual layout for the label: */
     211    m_pLabelIcon->move(width() - m_pLabelIcon->width() - m_iIconMargin, m_iIconMargin);
     212}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h

    r104978 r104979  
    3333
    3434/* Qt includes */
    35 #include <QIcon>
    3635#include <QLineEdit>
    3736
     
    3938#include "UILibraryDefs.h"
    4039
     40/* Forward declarations: */
    4141class QLabel;
    4242
     
    104104    bool     m_fMarkForError;
    105105    /** Holds the icon label instance. */
    106     QLabel  *m_pIconLabel;
     106    QLabel  *m_pLabelIcon;
    107107    /** Holds last error message. */
    108108    QString  m_strErrorMessage;
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