VirtualBox

Changeset 57627 in vbox for trunk


Ignore:
Timestamp:
Sep 4, 2015 12:54:17 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: 8010: GUI MessageBox: Fixing default focus.

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

Legend:

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

    r52730 r57627  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    257257            /* Add button-box into main-layout: */
    258258            pMainLayout->addWidget(m_pButtonBox);
     259
     260            /* Prepares focus. It is important to prepare focus after adding buttonbox to the layout as,
     261             * parenting the buttonbox to the QDialog changes default button focus by Qt: */
     262            prepareFocus();
    259263        }
     264    }
     265}
     266
     267void QIMessageBox::prepareFocus()
     268{
     269    /* Configure default button and focus: */
     270    if (m_pButton1 && (m_iButton1 & AlertButtonOption_Default))
     271    {
     272        m_pButton1->setDefault(true);
     273        m_pButton1->setFocus();
     274    }
     275    if (m_pButton2 && (m_iButton2 & AlertButtonOption_Default))
     276    {
     277        m_pButton2->setDefault(true);
     278        m_pButton2->setFocus();
     279    }
     280    if (m_pButton3 && (m_iButton3 & AlertButtonOption_Default))
     281    {
     282        m_pButton3->setDefault(true);
     283        m_pButton3->setFocus();
    260284    }
    261285}
     
    285309    QPushButton *pButton = m_pButtonBox->addButton(strText, role);
    286310
    287     /* Configure <default> button: */
    288     if (iButton & AlertButtonOption_Default)
    289     {
    290         pButton->setDefault(true);
    291         pButton->setFocus();
    292     }
    293311    /* Configure <escape> button: */
    294312    if (iButton & AlertButtonOption_Escape)
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h

    r55401 r57627  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626
    2727/* Forward declarations: */
    28 class QLabel;
    29 class QILabel;
    30 class QPushButton;
    3128class QCheckBox;
    3229class QIArrowSplitter;
    3330class QIDialogButtonBox;
     31class QILabel;
     32class QLabel;
     33class QPushButton;
    3434
    3535/** Button types. */
     
    123123private:
    124124
    125     /** Prepare routine. */
     125    /** Prepares message-box. */
    126126    void prepare();
     127
     128    /** Prepares focus. */
     129    void prepareFocus();
    127130
    128131    /** Push-button factory. */
     
    183186
    184187#endif /* !___QIMessageBox_h___ */
     188
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