VirtualBox

Changeset 93935 in vbox


Ignore:
Timestamp:
Feb 24, 2022 4:40:30 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Global preferences: Reworking General page to utilize labels of editors it uses; This also increases page accessibility.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIDefaultMachineFolderEditor.cpp

    r93115 r93935  
    2626
    2727
    28 UIDefaultMachineFolderEditor::UIDefaultMachineFolderEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     28UIDefaultMachineFolderEditor::UIDefaultMachineFolderEditor(QWidget *pParent /* = 0 */)
    2929    : QIWithRetranslateUI<QWidget>(pParent)
    30     , m_fWithLabel(fWithLabel)
    3130    , m_strValue(QString())
     31    , m_pLayout(0)
    3232    , m_pLabel(0)
    3333    , m_pSelector(0)
     
    5555}
    5656
     57int UIDefaultMachineFolderEditor::minimumLabelHorizontalHint() const
     58{
     59    return m_pLabel->minimumSizeHint().width();
     60}
     61
     62void UIDefaultMachineFolderEditor::setMinimumLayoutIndent(int iIndent)
     63{
     64    if (m_pLayout)
     65        m_pLayout->setColumnMinimumWidth(0, iIndent);
     66}
     67
    5768void UIDefaultMachineFolderEditor::retranslateUi()
    5869{
     
    6071        m_pLabel->setText(tr("Default &Machine Folder:"));
    6172    if (m_pSelector)
    62         m_pSelector->setWhatsThis(tr("Holds the path to the default virtual machine folder. This folder is used, "
    63                                      "if not explicitly specified otherwise, when creating new virtual machines."));
     73        m_pSelector->setToolTip(tr("Holds the path to the default virtual machine folder. This folder is used, "
     74                                   "if not explicitly specified otherwise, when creating new virtual machines."));
    6475}
    6576
     
    7384{
    7485    /* Create main layout: */
    75     QGridLayout *pMainLayout = new QGridLayout(this);
    76     if (pMainLayout)
     86    m_pLayout = new QGridLayout(this);
     87    if (m_pLayout)
    7788    {
    78         pMainLayout->setContentsMargins(0, 0, 0, 0);
    79         int iRow = 0;
     89        m_pLayout->setContentsMargins(0, 0, 0, 0);
     90        m_pLayout->setColumnStretch(1, 1);
    8091
    8192        /* Create label: */
    82         if (m_fWithLabel)
     93        m_pLabel = new QLabel(this);
     94        if (m_pLabel)
    8395        {
    84             m_pLabel = new QLabel(this);
    85             if (m_pLabel)
    86                 pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
     96            m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     97            m_pLayout->addWidget(m_pLabel, 0, 0);
    8798        }
    8899
     
    97108                    this, &UIDefaultMachineFolderEditor::sltHandleSelectorPathChanged);
    98109
    99             pMainLayout->addWidget(m_pSelector, 0, iRow++, 1, 1);
     110            m_pLayout->addWidget(m_pSelector, 0, 1);
    100111        }
    101112    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIDefaultMachineFolderEditor.h

    r93115 r93935  
    3030
    3131/* Forward declarations: */
     32class QGridLayout;
    3233class QLabel;
    3334class UIFilePathSelector;
     
    4546public:
    4647
    47     /** Constructs editor passing @a pParent to the base-class.
    48       * @param  fWithLabel  Brings whether we should add label ourselves. */
    49     UIDefaultMachineFolderEditor(QWidget *pParent = 0, bool fWithLabel = false);
     48    /** Constructs editor passing @a pParent to the base-class. */
     49    UIDefaultMachineFolderEditor(QWidget *pParent = 0);
    5050
    5151    /** Defines editor @a strValue. */
     
    5353    /** Returns editor value. */
    5454    QString value() const;
     55
     56    /** Returns minimum layout hint. */
     57    int minimumLabelHorizontalHint() const;
     58    /** Defines minimum layout @a iIndent. */
     59    void setMinimumLayoutIndent(int iIndent);
    5560
    5661protected:
     
    6974    void prepare();
    7075
    71     /** Holds whether descriptive label should be created. */
    72     bool  m_fWithLabel;
    73 
    7476    /** Holds the value to be set. */
    7577    QString  m_strValue;
    7678
     79    /** Holds the main layout instance. */
     80    QGridLayout        *m_pLayout;
    7781    /** Holds the label instance. */
    7882    QLabel             *m_pLabel;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIVRDEAuthLibraryEditor.cpp

    r93115 r93935  
    2626
    2727
    28 UIVRDEAuthLibraryEditor::UIVRDEAuthLibraryEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     28UIVRDEAuthLibraryEditor::UIVRDEAuthLibraryEditor(QWidget *pParent /* = 0 */)
    2929    : QIWithRetranslateUI<QWidget>(pParent)
    30     , m_fWithLabel(fWithLabel)
    3130    , m_strValue(QString())
    3231    , m_pLabel(0)
     
    5554}
    5655
     56int UIVRDEAuthLibraryEditor::minimumLabelHorizontalHint() const
     57{
     58    return m_pLabel->minimumSizeHint().width();
     59}
     60
     61void UIVRDEAuthLibraryEditor::setMinimumLayoutIndent(int iIndent)
     62{
     63    if (m_pLayout)
     64        m_pLayout->setColumnMinimumWidth(0, iIndent);
     65}
     66
    5767void UIVRDEAuthLibraryEditor::retranslateUi()
    5868{
     
    6070        m_pLabel->setText(tr("V&RDP Authentication Library:"));
    6171    if (m_pSelector)
    62         m_pSelector->setWhatsThis(tr("Holds the path to the library that provides "
    63                                      "authentication for Remote Display (VRDP) clients."));
     72        m_pSelector->setToolTip(tr("Holds the path to the library that provides "
     73                                   "authentication for Remote Display (VRDP) clients."));
    6474}
    6575
     
    7383{
    7484    /* Create main layout: */
    75     QGridLayout *pMainLayout = new QGridLayout(this);
    76     if (pMainLayout)
     85    m_pLayout = new QGridLayout(this);
     86    if (m_pLayout)
    7787    {
    78         pMainLayout->setContentsMargins(0, 0, 0, 0);
    79         int iRow = 0;
     88        m_pLayout->setContentsMargins(0, 0, 0, 0);
     89        m_pLayout->setColumnStretch(1, 1);
    8090
    8191        /* Create label: */
    82         if (m_fWithLabel)
     92        m_pLabel = new QLabel(this);
     93        if (m_pLabel)
    8394        {
    84             m_pLabel = new QLabel(this);
    85             if (m_pLabel)
    86                 pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
     95            m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     96            m_pLayout->addWidget(m_pLabel, 0, 0);
    8797        }
    8898
     
    98108                    this, &UIVRDEAuthLibraryEditor::sltHandleSelectorPathChanged);
    99109
    100             pMainLayout->addWidget(m_pSelector, 0, iRow++, 1, 1);
     110            m_pLayout->addWidget(m_pSelector, 0, 1);
    101111        }
    102112    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIVRDEAuthLibraryEditor.h

    r93115 r93935  
    3030
    3131/* Forward declarations: */
     32class QGridLayout;
    3233class QLabel;
    3334class UIFilePathSelector;
     
    4546public:
    4647
    47     /** Constructs editor passing @a pParent to the base-class.
    48       * @param  fWithLabel  Brings whether we should add label ourselves. */
    49     UIVRDEAuthLibraryEditor(QWidget *pParent = 0, bool fWithLabel = false);
     48    /** Constructs editor passing @a pParent to the base-class. */
     49    UIVRDEAuthLibraryEditor(QWidget *pParent = 0);
    5050
    5151    /** Defines editor @a strValue. */
     
    5353    /** Returns editor value. */
    5454    QString value() const;
     55
     56    /** Returns minimum layout hint. */
     57    int minimumLabelHorizontalHint() const;
     58    /** Defines minimum layout @a iIndent. */
     59    void setMinimumLayoutIndent(int iIndent);
    5560
    5661protected:
     
    6974    void prepare();
    7075
    71     /** Holds whether descriptive label should be created. */
    72     bool  m_fWithLabel;
    73 
    7476    /** Holds the value to be set. */
    7577    QString  m_strValue;
    7678
     79    /** Holds the main layout instance. */
     80    QGridLayout        *m_pLayout;
    7781    /** Holds the label instance. */
    7882    QLabel             *m_pLabel;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.cpp

    r93115 r93935  
    1717
    1818/* Qt includes: */
    19 #include <QGridLayout>
    20 #include <QLabel>
     19#include <QVBoxLayout>
    2120
    2221/* GUI includes: */
     
    6463UIGlobalSettingsGeneral::UIGlobalSettingsGeneral()
    6564    : m_pCache(0)
    66     , m_pLabelDefaultMachineFolder(0)
    6765    , m_pEditorDefaultMachineFolder(0)
    68     , m_pLabelVRDEAuthLibrary(0)
    6966    , m_pEditorVRDEAuthLibrary(0)
    7067{
     
    128125void UIGlobalSettingsGeneral::retranslateUi()
    129126{
    130     m_pLabelDefaultMachineFolder->setText(UIDefaultMachineFolderEditor::tr("Default &Machine Folder:"));
    131     m_pLabelVRDEAuthLibrary->setText(UIVRDEAuthLibraryEditor::tr("V&RDP Authentication Library:"));
     127    /* These editors have own labels, but we want them to be properly layouted according to each other: */
     128    int iMinimumLayoutHint = 0;
     129    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorDefaultMachineFolder->minimumLabelHorizontalHint());
     130    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorVRDEAuthLibrary->minimumLabelHorizontalHint());
     131    m_pEditorDefaultMachineFolder->setMinimumLayoutIndent(iMinimumLayoutHint);
     132    m_pEditorVRDEAuthLibrary->setMinimumLayoutIndent(iMinimumLayoutHint);
    132133}
    133134
     
    148149{
    149150    /* Prepare main layout: */
    150     QGridLayout *pLayoutMain = new QGridLayout(this);
     151    QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
    151152    if (pLayoutMain)
    152153    {
    153         pLayoutMain->setColumnStretch(1, 1);
    154         pLayoutMain->setRowStretch(3, 1);
    155 
    156         /* Prepare 'default machine folder' label: */
    157         m_pLabelDefaultMachineFolder = new QLabel(this);
    158         if (m_pLabelDefaultMachineFolder)
    159         {
    160             m_pLabelDefaultMachineFolder->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    161             pLayoutMain->addWidget(m_pLabelDefaultMachineFolder, 0, 0);
    162         }
    163154        /* Prepare 'default machine folder' editor: */
    164155        m_pEditorDefaultMachineFolder = new UIDefaultMachineFolderEditor(this);
    165156        if (m_pEditorDefaultMachineFolder)
    166         {
    167             if (m_pLabelDefaultMachineFolder)
    168                 m_pLabelDefaultMachineFolder->setBuddy(m_pEditorDefaultMachineFolder);
    169             pLayoutMain->addWidget(m_pEditorDefaultMachineFolder, 0, 1, 1, 2);
    170         }
    171 
    172         /* Prepare 'VRDE auth library' label: */
    173         m_pLabelVRDEAuthLibrary = new QLabel(this);
    174         if (m_pLabelVRDEAuthLibrary)
    175         {
    176             m_pLabelVRDEAuthLibrary->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    177             pLayoutMain->addWidget(m_pLabelVRDEAuthLibrary, 1, 0);
    178         }
     157            pLayoutMain->addWidget(m_pEditorDefaultMachineFolder);
     158
    179159        /* Prepare 'VRDE auth library' editor: */
    180160        m_pEditorVRDEAuthLibrary = new UIVRDEAuthLibraryEditor(this);
    181161        if (m_pEditorVRDEAuthLibrary)
    182         {
    183             if (m_pLabelVRDEAuthLibrary)
    184                 m_pLabelVRDEAuthLibrary->setBuddy(m_pEditorVRDEAuthLibrary);
    185             pLayoutMain->addWidget(m_pEditorVRDEAuthLibrary, 1, 1, 1, 2);
    186         }
     162            pLayoutMain->addWidget(m_pEditorVRDEAuthLibrary);
     163
     164        /* Add stretch to the end: */
     165        pLayoutMain->addStretch();
    187166    }
    188167}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsGeneral.h

    r93115 r93935  
    2626
    2727/* Forward declarations: */
    28 class QLabel;
    2928class UIDefaultMachineFolderEditor;
    3029class UIVRDEAuthLibraryEditor;
     
    8079    /** @name Widgets
    8180     * @{ */
    82         /** Holds 'default machine folder' label instance. */
    83         QLabel                       *m_pLabelDefaultMachineFolder;
    8481        /** Holds 'default machine folder' editor instance. */
    8582        UIDefaultMachineFolderEditor *m_pEditorDefaultMachineFolder;
    86         /** Holds 'VRDE auth library' label instance. */
    87         QLabel                       *m_pLabelVRDEAuthLibrary;
    8883        /** Holds 'VRDE auth library' editor instance. */
    8984        UIVRDEAuthLibraryEditor      *m_pEditorVRDEAuthLibrary;
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