VirtualBox

Ignore:
Timestamp:
Jun 23, 2017 10:36:22 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116336
Message:

FE/Qt: bugref:8847: Host Network Manager: Fixing dialog-button-box layout under macOS, not en easy thing..

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

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

    r67573 r67581  
    140140    {
    141141        /* Configure button-box: */
     142#ifdef VBOX_WS_MAC
     143        m_pButtonBox->setStandardButtons(QDialogButtonBox::Reset | QDialogButtonBox::Apply |  QDialogButtonBox::Close);
     144#else
    142145        m_pButtonBox->setStandardButtons(QDialogButtonBox::Reset | QDialogButtonBox::Save |  QDialogButtonBox::Close);
    143         m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape);
    144         m_pButtonBox->button(QDialogButtonBox::Reset)->hide();
    145         m_pButtonBox->button(QDialogButtonBox::Save)->hide();
    146         m_pButtonBox->button(QDialogButtonBox::Reset)->setEnabled(false);
    147         m_pButtonBox->button(QDialogButtonBox::Save)->setEnabled(false);
     146#endif
     147        m_buttons[ButtonType_Reset] = m_pButtonBox->button(QDialogButtonBox::Reset);
     148#ifdef VBOX_WS_MAC
     149        m_buttons[ButtonType_Apply] = m_pButtonBox->button(QDialogButtonBox::Apply);
     150#else
     151        m_buttons[ButtonType_Apply] = m_pButtonBox->button(QDialogButtonBox::Save);
     152#endif
     153        m_buttons[ButtonType_Close] = m_pButtonBox->button(QDialogButtonBox::Close);
     154        /* Assign shortcuts: */
     155        button(ButtonType_Close)->setShortcut(Qt::Key_Escape);
     156        /* Hide 'Reset' and 'Apply' initially: */
     157        button(ButtonType_Reset)->hide();
     158        button(ButtonType_Apply)->hide();
     159        /* Disable 'Reset' and 'Apply' initially: */
     160        button(ButtonType_Reset)->setEnabled(false);
     161        button(ButtonType_Apply)->setEnabled(false);
    148162        connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &QIManagerDialog::sigClose);
    149163
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.h

    r67573 r67581  
    2121/* Qt includes: */
    2222#include <QMainWindow>
     23#include <QMap>
     24
     25/* Other VBox includes: */
     26#include <iprt/cdefs.h>
    2327
    2428/* Forward declarations: */
     29class QPushButton;
    2530class QIDialogButtonBox;
    2631class QIManagerDialog;
     
    3540    EmbedTo_Dialog,
    3641    EmbedTo_Stack
     42};
     43
     44
     45/** Dialog button types. */
     46enum ButtonType
     47{
     48    ButtonType_Invalid = 0,
     49    ButtonType_Reset   = RT_BIT(0),
     50    ButtonType_Apply   = RT_BIT(1),
     51    ButtonType_Close   = RT_BIT(2),
    3752};
    3853
     
    133148        /** Returns the button-box instance. */
    134149        QIDialogButtonBox *buttonBox() { return m_pButtonBox; }
     150        /** Returns button of passed @a enmType. */
     151        QPushButton *button(ButtonType enmType) { return m_buttons.value(enmType); }
    135152    /** @} */
    136153
     
    166183        /** Holds the dialog button-box instance. */
    167184        QIDialogButtonBox *m_pButtonBox;
     185
     186        /** Holds the button-box button references. */
     187        QMap<ButtonType, QPushButton*> m_buttons;
    168188    /** @} */
    169189
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkManager.cpp

    r67575 r67581  
    10221022{
    10231023    /* Disable buttons first of all: */
    1024     buttonBox()->button(QDialogButtonBox::Reset)->setEnabled(false);
    1025     buttonBox()->button(QDialogButtonBox::Save)->setEnabled(false);
     1024    button(ButtonType_Reset)->setEnabled(false);
     1025    button(ButtonType_Apply)->setEnabled(false);
    10261026
    10271027    /* Compare with known buttons: */
    1028     if (pButton == buttonBox()->button(QDialogButtonBox::Reset))
     1028    if (pButton == button(ButtonType_Reset))
    10291029        emit sigDataChangeRejected();
    10301030
    10311031    else
    10321032
    1033     if (pButton == buttonBox()->button(QDialogButtonBox::Save))
     1033    if (pButton == button(ButtonType_Apply))
    10341034        emit sigDataChangeAccepted();
    10351035}
     
    10411041
    10421042    /* Translate buttons: */
    1043     buttonBox()->button(QDialogButtonBox::Reset)->setText(tr("Reset"));
    1044     buttonBox()->button(QDialogButtonBox::Save)->setText(tr("Apply"));
    1045     buttonBox()->button(QDialogButtonBox::Close)->setText(tr("Close"));
    1046     buttonBox()->button(QDialogButtonBox::Reset)->setStatusTip(tr("Reset changes in current host network details"));
    1047     buttonBox()->button(QDialogButtonBox::Save)->setStatusTip(tr("Apply changes in current host network details"));
    1048     buttonBox()->button(QDialogButtonBox::Close)->setStatusTip(tr("Close dialog without saving"));
    1049     buttonBox()->button(QDialogButtonBox::Reset)->setShortcut(QString("Ctrl+Backspace"));
    1050     buttonBox()->button(QDialogButtonBox::Save)->setShortcut(QString("Ctrl+Return"));
    1051     //buttonBox()->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); /* done in base-class */
    1052     buttonBox()->button(QDialogButtonBox::Reset)->
    1053         setToolTip(tr("Reset Changes (%1)").arg(buttonBox()->button(QDialogButtonBox::Reset)->shortcut().toString()));
    1054     buttonBox()->button(QDialogButtonBox::Save)->
    1055         setToolTip(tr("Apply Changes (%1)").arg(buttonBox()->button(QDialogButtonBox::Save)->shortcut().toString()));
    1056     buttonBox()->button(QDialogButtonBox::Close)->
    1057         setToolTip(tr("Close Window (%1)").arg(buttonBox()->button(QDialogButtonBox::Close)->shortcut().toString()));
     1043    button(ButtonType_Reset)->setText(tr("Reset"));
     1044    button(ButtonType_Apply)->setText(tr("Apply"));
     1045    button(ButtonType_Close)->setText(tr("Close"));
     1046    button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current host network details"));
     1047    button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current host network details"));
     1048    button(ButtonType_Close)->setStatusTip(tr("Close dialog without saving"));
     1049    button(ButtonType_Reset)->setShortcut(QString("Ctrl+Backspace"));
     1050    button(ButtonType_Apply)->setShortcut(QString("Ctrl+Return"));
     1051    //button(ButtonType_Close)->setShortcut(Qt::Key_Escape); /* done in base-class */
     1052    button(ButtonType_Reset)->setToolTip(tr("Reset Changes (%1)").arg(button(ButtonType_Reset)->shortcut().toString()));
     1053    button(ButtonType_Apply)->setToolTip(tr("Apply Changes (%1)").arg(button(ButtonType_Apply)->shortcut().toString()));
     1054    button(ButtonType_Close)->setToolTip(tr("Close Window (%1)").arg(button(ButtonType_Close)->shortcut().toString()));
    10581055}
    10591056
     
    10901087    /* Configure button-box: */
    10911088    connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,
    1092             buttonBox()->button(QDialogButtonBox::Save), &QPushButton::setVisible);
     1089            button(ButtonType_Apply), &QPushButton::setVisible);
    10931090    connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsVisibilityChanged,
    1094             buttonBox()->button(QDialogButtonBox::Reset), &QPushButton::setVisible);
     1091            button(ButtonType_Reset), &QPushButton::setVisible);
    10951092    connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,
    1096             buttonBox()->button(QDialogButtonBox::Save), &QPushButton::setEnabled);
     1093            button(ButtonType_Apply), &QPushButton::setEnabled);
    10971094    connect(widget(), &UIHostNetworkManagerWidget::sigHostNetworkDetailsDataChanged,
    1098             buttonBox()->button(QDialogButtonBox::Reset), &QPushButton::setEnabled);
     1095            button(ButtonType_Reset), &QPushButton::setEnabled);
    10991096    connect(buttonBox(), &QIDialogButtonBox::clicked,
    11001097            this, &UIHostNetworkManager::sltHandleButtonBoxClick);
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