VirtualBox

Changeset 94498 in vbox


Ignore:
Timestamp:
Apr 6, 2022 4:03:44 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Machine settings: General page accessibility improvements for Disk Encryption tab; Moving disk encryption stuff to separate editor; Rework encryption types to enum.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r94476 r94498  
    900900        src/settings/editors/UIColorThemeEditor.h \
    901901        src/settings/editors/UIDefaultMachineFolderEditor.h \
     902        src/settings/editors/UIDiskEncryptionSettingsEditor.h \
    902903        src/settings/editors/UIDragAndDropEditor.h \
    903904        src/settings/editors/UIGlobalDisplayFeaturesEditor.h \
     
    14641465        src/settings/editors/UIColorThemeEditor.cpp \
    14651466        src/settings/editors/UIDefaultMachineFolderEditor.cpp \
     1467        src/settings/editors/UIDiskEncryptionSettingsEditor.cpp \
    14661468        src/settings/editors/UIDragAndDropEditor.cpp \
    14671469        src/settings/editors/UIGlobalDisplayFeaturesEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r93408 r94498  
    112112template<> SHARED_LIBRARY_STUFF bool canConvert<DetailsElementType>();
    113113template<> SHARED_LIBRARY_STUFF bool canConvert<PreviewUpdateIntervalType>();
     114template<> SHARED_LIBRARY_STUFF bool canConvert<UIDiskEncryptionCipherType>();
    114115template<> SHARED_LIBRARY_STUFF bool canConvert<GUIFeatureType>();
    115116template<> SHARED_LIBRARY_STUFF bool canConvert<GlobalSettingsPageType>();
     
    243244template<> SHARED_LIBRARY_STUFF int toInternalInteger(const PreviewUpdateIntervalType &previewUpdateIntervalType);
    244245template<> SHARED_LIBRARY_STUFF PreviewUpdateIntervalType fromInternalInteger<PreviewUpdateIntervalType>(const int &iPreviewUpdateIntervalType);
     246template<> SHARED_LIBRARY_STUFF QString toInternalString(const UIDiskEncryptionCipherType &enmDiskEncryptionCipherType);
     247template<> SHARED_LIBRARY_STUFF UIDiskEncryptionCipherType fromInternalString<UIDiskEncryptionCipherType>(const QString &strDiskEncryptionCipherType);
     248template<> SHARED_LIBRARY_STUFF QString toString(const UIDiskEncryptionCipherType &enmDiskEncryptionCipherType);
     249template<> SHARED_LIBRARY_STUFF UIDiskEncryptionCipherType fromString<UIDiskEncryptionCipherType>(const QString &strDiskEncryptionCipherType);
    245250template<> SHARED_LIBRARY_STUFF QString toInternalString(const GUIFeatureType &guiFeatureType);
    246251template<> SHARED_LIBRARY_STUFF GUIFeatureType fromInternalString<GUIFeatureType>(const QString &strGuiFeatureType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r93996 r94498  
    6767template<> bool canConvert<DetailsElementType>() { return true; }
    6868template<> bool canConvert<PreviewUpdateIntervalType>() { return true; }
     69template<> bool canConvert<UIDiskEncryptionCipherType>() { return true; }
    6970template<> bool canConvert<GUIFeatureType>() { return true; }
    7071template<> bool canConvert<GlobalSettingsPageType>() { return true; }
     
    19561957}
    19571958
     1959/* QString <= UIDiskEncryptionCipherType: */
     1960template<> QString toInternalString(const UIDiskEncryptionCipherType &enmDiskEncryptionCipherType)
     1961{
     1962    switch (enmDiskEncryptionCipherType)
     1963    {
     1964        case UIDiskEncryptionCipherType_XTS256: return "AES-XTS256-PLAIN64";
     1965        case UIDiskEncryptionCipherType_XTS128: return "AES-XTS128-PLAIN64";
     1966        default:                                break;
     1967    }
     1968    return QString();
     1969}
     1970
     1971/* UIDiskEncryptionCipherType <= QString: */
     1972template<> UIDiskEncryptionCipherType fromInternalString<UIDiskEncryptionCipherType>(const QString &strDiskEncryptionCipherType)
     1973{
     1974    if (strDiskEncryptionCipherType.compare("AES-XTS256-PLAIN64", Qt::CaseInsensitive) == 0)
     1975        return UIDiskEncryptionCipherType_XTS256;
     1976    if (strDiskEncryptionCipherType.compare("AES-XTS128-PLAIN64", Qt::CaseInsensitive) == 0)
     1977        return UIDiskEncryptionCipherType_XTS128;
     1978    return UIDiskEncryptionCipherType_Unchanged;
     1979}
     1980
     1981/* QString <= UIDiskEncryptionCipherType: */
     1982template<> QString toString(const UIDiskEncryptionCipherType &enmDiskEncryptionCipherType)
     1983{
     1984    switch (enmDiskEncryptionCipherType)
     1985    {
     1986        case UIDiskEncryptionCipherType_XTS256: return "AES-XTS256-PLAIN64";
     1987        case UIDiskEncryptionCipherType_XTS128: return "AES-XTS128-PLAIN64";
     1988        default:                                break;
     1989    }
     1990    return QApplication::translate("UICommon", "Leave Unchanged", "cipher type");
     1991}
     1992
     1993/* UIDiskEncryptionCipherType <= QString: */
     1994template<> UIDiskEncryptionCipherType fromString<UIDiskEncryptionCipherType>(const QString &strDiskEncryptionCipherType)
     1995{
     1996    if (strDiskEncryptionCipherType.compare("AES-XTS256-PLAIN64", Qt::CaseInsensitive) == 0)
     1997        return UIDiskEncryptionCipherType_XTS256;
     1998    if (strDiskEncryptionCipherType.compare("AES-XTS128-PLAIN64", Qt::CaseInsensitive) == 0)
     1999        return UIDiskEncryptionCipherType_XTS128;
     2000    return UIDiskEncryptionCipherType_Unchanged;
     2001}
     2002
    19582003/* QString <= GUIFeatureType: */
    19592004template<> QString toInternalString(const GUIFeatureType &guiFeatureType)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r94005 r94498  
    984984
    985985
     986/** Selector UI: Disk encryption cipher types. */
     987enum UIDiskEncryptionCipherType
     988{
     989    UIDiskEncryptionCipherType_Unchanged,
     990    UIDiskEncryptionCipherType_XTS256,
     991    UIDiskEncryptionCipherType_XTS128,
     992    UIDiskEncryptionCipherType_Max
     993};
     994Q_DECLARE_METATYPE(UIDiskEncryptionCipherType);
     995
     996
    986997/** Runtime UI: Visual-state types. */
    987998enum UIVisualStateType
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIDiskEncryptionSettingsEditor.cpp

    r94497 r94498  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVRDESettingsEditor class implementation.
     3 * VBox Qt GUI - UIDiskEncryptionSettingsEditor class implementation.
    44 */
    55
     
    2525/* GUI includes: */
    2626#include "UIConverter.h"
    27 #include "UIVRDESettingsEditor.h"
    28 
    29 
    30 UIVRDESettingsEditor::UIVRDESettingsEditor(QWidget *pParent /* = 0 */)
     27#include "UIDiskEncryptionSettingsEditor.h"
     28
     29
     30UIDiskEncryptionSettingsEditor::UIDiskEncryptionSettingsEditor(QWidget *pParent /* = 0 */)
    3131    : QIWithRetranslateUI<QWidget>(pParent)
    3232    , m_fFeatureEnabled(false)
    33     , m_enmAuthType(KAuthType_Max)
    34     , m_fMultipleConnectionsAllowed(false)
     33    , m_enmCipherType(UIDiskEncryptionCipherType_Max)
    3534    , m_pCheckboxFeature(0)
    3635    , m_pWidgetSettings(0)
    37     , m_pLabelPort(0)
    38     , m_pEditorPort(0)
    39     , m_pLabelAuthMethod(0)
    40     , m_pComboAuthType(0)
    41     , m_pLabelTimeout(0)
    42     , m_pEditorTimeout(0)
    43     , m_pLabelOptions(0)
    44     , m_pCheckboxMultipleConnections(0)
     36    , m_pLabelCipher(0)
     37    , m_pComboCipher(0)
     38    , m_pLabelEncryptionPassword(0)
     39    , m_pEditorEncryptionPassword(0)
     40    , m_pLabelEncryptionPasswordConfirm(0)
     41    , m_pEditorEncryptionPasswordConfirm(0)
    4542{
    4643    prepare();
    4744}
    4845
    49 void UIVRDESettingsEditor::setFeatureEnabled(bool fEnabled)
     46void UIDiskEncryptionSettingsEditor::setFeatureEnabled(bool fEnabled)
    5047{
    5148    /* Update cached value and
     
    6259}
    6360
    64 bool UIVRDESettingsEditor::isFeatureEnabled() const
     61bool UIDiskEncryptionSettingsEditor::isFeatureEnabled() const
    6562{
    6663    return m_pCheckboxFeature ? m_pCheckboxFeature->isChecked() : m_fFeatureEnabled;
    6764}
    6865
    69 void UIVRDESettingsEditor::setVRDEOptionsAvailable(bool fAvailable)
    70 {
    71     if (m_pLabelOptions)
    72         m_pLabelOptions->setEnabled(fAvailable);
    73     if (m_pCheckboxMultipleConnections)
    74         m_pCheckboxMultipleConnections->setEnabled(fAvailable);
    75 }
    76 
    77 void UIVRDESettingsEditor::setPort(const QString &strPort)
    78 {
    79     /* Update cached value and
    80      * line-edit if value has changed: */
    81     if (m_strPort != strPort)
    82     {
    83         m_strPort = strPort;
    84         if (m_pEditorPort)
    85             m_pEditorPort->setText(m_strPort);
    86     }
    87 }
    88 
    89 QString UIVRDESettingsEditor::port() const
    90 {
    91     return m_pEditorPort ? m_pEditorPort->text() : m_strPort;
    92 }
    93 
    94 void UIVRDESettingsEditor::setAuthType(const KAuthType &enmType)
     66void UIDiskEncryptionSettingsEditor::setCipherType(const UIDiskEncryptionCipherType &enmType)
    9567{
    9668    /* Update cached value and
    9769     * combo if value has changed: */
    98     if (m_enmAuthType != enmType)
    99     {
    100         m_enmAuthType = enmType;
    101         repopulateComboAuthType();
    102     }
    103 }
    104 
    105 KAuthType UIVRDESettingsEditor::authType() const
    106 {
    107     return m_pComboAuthType ? m_pComboAuthType->currentData().value<KAuthType>() : m_enmAuthType;
    108 }
    109 
    110 void UIVRDESettingsEditor::setTimeout(const QString &strTimeout)
    111 {
    112     /* Update cached value and
    113      * line-edit if value has changed: */
    114     if (m_strTimeout != strTimeout)
    115     {
    116         m_strTimeout = strTimeout;
    117         if (m_pEditorTimeout)
    118             m_pEditorTimeout->setText(m_strTimeout);
    119     }
    120 }
    121 
    122 QString UIVRDESettingsEditor::timeout() const
    123 {
    124     return m_pEditorTimeout ? m_pEditorTimeout->text() : m_strTimeout;
    125 }
    126 
    127 void UIVRDESettingsEditor::setMultipleConnectionsAllowed(bool fAllowed)
    128 {
    129     /* Update cached value and
    130      * check-box if value has changed: */
    131     if (m_fMultipleConnectionsAllowed != fAllowed)
    132     {
    133         m_fMultipleConnectionsAllowed = fAllowed;
    134         if (m_pCheckboxMultipleConnections)
    135             m_pCheckboxMultipleConnections->setChecked(m_fMultipleConnectionsAllowed);
    136     }
    137 }
    138 
    139 bool UIVRDESettingsEditor::isMultipleConnectionsAllowed() const
    140 {
    141     return m_pCheckboxMultipleConnections ? m_pCheckboxMultipleConnections->isChecked() : m_fMultipleConnectionsAllowed;
    142 }
    143 
    144 void UIVRDESettingsEditor::retranslateUi()
     70    if (m_enmCipherType != enmType)
     71    {
     72        m_enmCipherType = enmType;
     73        repopulateCombo();
     74    }
     75}
     76
     77UIDiskEncryptionCipherType UIDiskEncryptionSettingsEditor::cipherType() const
     78{
     79    return m_pComboCipher ? m_pComboCipher->currentData().value<UIDiskEncryptionCipherType>() : m_enmCipherType;
     80}
     81
     82QString UIDiskEncryptionSettingsEditor::password1() const
     83{
     84    return m_pEditorEncryptionPassword ? m_pEditorEncryptionPassword->text() : m_strPassword1;
     85}
     86
     87QString UIDiskEncryptionSettingsEditor::password2() const
     88{
     89    return m_pEditorEncryptionPasswordConfirm ? m_pEditorEncryptionPasswordConfirm->text() : m_strPassword2;
     90}
     91
     92void UIDiskEncryptionSettingsEditor::retranslateUi()
    14593{
    14694    if (m_pCheckboxFeature)
    14795    {
    148         m_pCheckboxFeature->setText(tr("&Enable Server"));
    149         m_pCheckboxFeature->setToolTip(tr("When checked, the VM will act as a Remote Desktop Protocol (RDP) server, allowing "
    150                                           "remote clients to connect and operate the VM (when it is running) using a standard "
    151                                           "RDP client."));
    152     }
    153 
    154     if (m_pLabelPort)
    155         m_pLabelPort->setText(tr("Server &Port:"));
    156     if (m_pEditorPort)
    157         m_pEditorPort->setToolTip(tr("Holds the VRDP Server port number. You may specify 0 (zero), to select port 3389, the "
    158                                      "standard port for RDP."));
    159 
    160     if (m_pLabelAuthMethod)
    161         m_pLabelAuthMethod->setText(tr("Authentication &Method:"));
    162     if (m_pComboAuthType)
    163     {
    164         for (int iIndex = 0; iIndex < m_pComboAuthType->count(); ++iIndex)
     96        m_pCheckboxFeature->setText(tr("En&able Disk Encryption"));
     97        m_pCheckboxFeature->setToolTip(tr("When checked, disks attached to this virtual machine will be encrypted."));
     98    }
     99
     100    if (m_pLabelCipher)
     101        m_pLabelCipher->setText(tr("Disk Encryption C&ipher:"));
     102    if (m_pComboCipher)
     103    {
     104        for (int iIndex = 0; iIndex < m_pComboCipher->count(); ++iIndex)
    165105        {
    166             const KAuthType enmType = m_pComboAuthType->itemData(iIndex).value<KAuthType>();
    167             m_pComboAuthType->setItemText(iIndex, gpConverter->toString(enmType));
     106            const UIDiskEncryptionCipherType enmType = m_pComboCipher->itemData(iIndex).value<UIDiskEncryptionCipherType>();
     107            m_pComboCipher->setItemText(iIndex, gpConverter->toString(enmType));
    168108        }
    169         m_pComboAuthType->setToolTip(tr("Selects the VRDP authentication method."));
    170     }
    171 
    172     if (m_pLabelTimeout)
    173         m_pLabelTimeout->setText(tr("Authentication &Timeout:"));
    174     if (m_pEditorTimeout)
    175         m_pEditorTimeout->setToolTip(tr("Holds the timeout for guest authentication, in milliseconds."));
    176 
    177     if (m_pLabelOptions)
    178         m_pLabelOptions->setText(tr("Extended Features:"));
    179     if (m_pCheckboxMultipleConnections)
    180     {
    181         m_pCheckboxMultipleConnections->setText(tr("&Allow Multiple Connections"));
    182         m_pCheckboxMultipleConnections->setToolTip(tr("When checked, multiple simultaneous connections to the VM are "
    183                                                       "permitted."));
    184     }
    185 }
    186 
    187 void UIVRDESettingsEditor::sltHandleFeatureToggled(bool fEnabled)
     109        m_pComboCipher->setToolTip(tr("Holds the cipher to be used for encrypting the virtual machine disks."));
     110    }
     111
     112    if (m_pLabelEncryptionPassword)
     113        m_pLabelEncryptionPassword->setText(tr("E&nter New Password:"));
     114    if (m_pEditorEncryptionPassword)
     115        m_pEditorEncryptionPassword->setToolTip(tr("Holds the encryption password for disks attached to this virtual machine."));
     116    if (m_pLabelEncryptionPasswordConfirm)
     117        m_pLabelEncryptionPasswordConfirm->setText(tr("C&onfirm New Password:"));
     118    if (m_pEditorEncryptionPasswordConfirm)
     119        m_pEditorEncryptionPasswordConfirm->setToolTip(tr("Confirms the disk encryption password."));
     120
     121    /* Translate Cipher type combo: */
     122    m_pComboCipher->setItemText(0, tr("Leave Unchanged", "cipher type"));
     123}
     124
     125void UIDiskEncryptionSettingsEditor::sltHandleFeatureToggled(bool fEnabled)
    188126{
    189127    /* Update widget availability: */
     
    192130
    193131    /* Notify listeners: */
    194     emit sigChanged();
    195 }
    196 
    197 void UIVRDESettingsEditor::prepare()
     132    emit sigStatusChanged();
     133}
     134
     135void UIDiskEncryptionSettingsEditor::prepare()
    198136{
    199137    /* Prepare everything: */
     
    205143}
    206144
    207 void UIVRDESettingsEditor::prepareWidgets()
     145void UIDiskEncryptionSettingsEditor::prepareWidgets()
    208146{
    209147    /* Prepare main layout: */
     
    228166        if (m_pWidgetSettings)
    229167        {
    230             /* Prepare 'settings' layout: */
    231             QGridLayout *pLayoutRemoteDisplaySettings = new QGridLayout(m_pWidgetSettings);
    232             if (pLayoutRemoteDisplaySettings)
     168            /* Prepare encryption settings widget layout: */
     169            QGridLayout *m_pLayoutSettings = new QGridLayout(m_pWidgetSettings);
     170            if (m_pLayoutSettings)
    233171            {
    234                 pLayoutRemoteDisplaySettings->setContentsMargins(0, 0, 0, 0);
    235                 pLayoutRemoteDisplaySettings->setColumnStretch(1, 1);
    236 
    237                 /* Prepare 'port' label: */
    238                 m_pLabelPort = new QLabel(m_pWidgetSettings);
    239                 if (m_pLabelPort)
    240                 {
    241                     m_pLabelPort->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    242                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelPort, 0, 0);
    243                 }
    244                 /* Prepare 'port' editor: */
    245                 m_pEditorPort = new QLineEdit(m_pWidgetSettings);
    246                 if (m_pEditorPort)
    247                 {
    248                     if (m_pLabelPort)
    249                         m_pLabelPort->setBuddy(m_pEditorPort);
    250                     m_pEditorPort->setValidator(new QRegularExpressionValidator(
    251                         QRegularExpression("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
    252 
    253                     pLayoutRemoteDisplaySettings->addWidget(m_pEditorPort, 0, 1, 1, 2);
    254                 }
    255 
    256                 /* Prepare 'auth type' label: */
    257                 m_pLabelAuthMethod = new QLabel(m_pWidgetSettings);
    258                 if (m_pLabelAuthMethod)
    259                 {
    260                     m_pLabelAuthMethod->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    261                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelAuthMethod, 1, 0);
    262                 }
    263                 /* Prepare 'auth type' combo: */
    264                 m_pComboAuthType = new QComboBox(m_pWidgetSettings);
    265                 if (m_pComboAuthType)
    266                 {
    267                     if (m_pLabelAuthMethod)
    268                         m_pLabelAuthMethod->setBuddy(m_pComboAuthType);
    269                     m_pComboAuthType->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    270 
    271                     pLayoutRemoteDisplaySettings->addWidget(m_pComboAuthType, 1, 1, 1, 2);
    272                 }
    273 
    274                 /* Prepare 'timeout' label: */
    275                 m_pLabelTimeout = new QLabel(m_pWidgetSettings);
    276                 if (m_pLabelTimeout)
    277                 {
    278                     m_pLabelTimeout->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    279                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelTimeout, 2, 0);
    280                 }
    281                 /* Prepare 'timeout' editor: */
    282                 m_pEditorTimeout = new QLineEdit(m_pWidgetSettings);
    283                 if (m_pEditorTimeout)
    284                 {
    285                     if (m_pLabelTimeout)
    286                         m_pLabelTimeout->setBuddy(m_pEditorTimeout);
    287                     m_pEditorTimeout->setValidator(new QIntValidator(this));
    288 
    289                     pLayoutRemoteDisplaySettings->addWidget(m_pEditorTimeout, 2, 1, 1, 2);
    290                 }
    291 
    292                 /* Prepare 'options' label: */
    293                 m_pLabelOptions = new QLabel(m_pWidgetSettings);
    294                 if (m_pLabelOptions)
    295                 {
    296                     m_pLabelOptions->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    297                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelOptions, 3, 0);
    298                 }
    299                 /* Prepare 'multiple connections' check-box: */
    300                 m_pCheckboxMultipleConnections = new QCheckBox(m_pWidgetSettings);
    301                 if (m_pCheckboxMultipleConnections)
    302                     pLayoutRemoteDisplaySettings->addWidget(m_pCheckboxMultipleConnections, 3, 1);
     172                m_pLayoutSettings->setContentsMargins(0, 0, 0, 0);
     173
     174                /* Prepare encryption cipher label: */
     175                m_pLabelCipher = new QLabel(m_pWidgetSettings);
     176                if (m_pLabelCipher)
     177                {
     178                    m_pLabelCipher->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     179                    m_pLayoutSettings->addWidget(m_pLabelCipher, 0, 0);
     180                }
     181                /* Prepare encryption cipher combo: */
     182                m_pComboCipher = new QComboBox(m_pWidgetSettings);
     183                if (m_pComboCipher)
     184                {
     185                    if (m_pLabelCipher)
     186                        m_pLabelCipher->setBuddy(m_pComboCipher);
     187                    m_pLayoutSettings->addWidget(m_pComboCipher, 0, 1);
     188                }
     189
     190                /* Prepare encryption password label: */
     191                m_pLabelEncryptionPassword = new QLabel(m_pWidgetSettings);
     192                if (m_pLabelEncryptionPassword)
     193                {
     194                    m_pLabelEncryptionPassword->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     195                    m_pLayoutSettings->addWidget(m_pLabelEncryptionPassword, 1, 0);
     196                }
     197                /* Prepare encryption password editor: */
     198                m_pEditorEncryptionPassword = new QLineEdit(m_pWidgetSettings);
     199                if (m_pEditorEncryptionPassword)
     200                {
     201                    if (m_pLabelEncryptionPassword)
     202                        m_pLabelEncryptionPassword->setBuddy(m_pEditorEncryptionPassword);
     203                    m_pEditorEncryptionPassword->setEchoMode(QLineEdit::Password);
     204
     205                    m_pLayoutSettings->addWidget(m_pEditorEncryptionPassword, 1, 1);
     206                }
     207
     208                /* Prepare encryption confirm password label: */
     209                m_pLabelEncryptionPasswordConfirm = new QLabel(m_pWidgetSettings);
     210                if (m_pLabelEncryptionPasswordConfirm)
     211                {
     212                    m_pLabelEncryptionPasswordConfirm->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     213                    m_pLayoutSettings->addWidget(m_pLabelEncryptionPasswordConfirm, 2, 0);
     214                }
     215                /* Prepare encryption confirm password editor: */
     216                m_pEditorEncryptionPasswordConfirm = new QLineEdit(m_pWidgetSettings);
     217                if (m_pEditorEncryptionPasswordConfirm)
     218                {
     219                    if (m_pLabelEncryptionPasswordConfirm)
     220                        m_pLabelEncryptionPasswordConfirm->setBuddy(m_pEditorEncryptionPasswordConfirm);
     221                    m_pEditorEncryptionPasswordConfirm->setEchoMode(QLineEdit::Password);
     222
     223                    m_pLayoutSettings->addWidget(m_pEditorEncryptionPasswordConfirm, 2, 1);
     224                }
    303225            }
    304226
     
    312234}
    313235
    314 void UIVRDESettingsEditor::prepareConnections()
     236void UIDiskEncryptionSettingsEditor::prepareConnections()
    315237{
    316238    if (m_pCheckboxFeature)
    317         connect(m_pCheckboxFeature, &QCheckBox::toggled, this, &UIVRDESettingsEditor::sltHandleFeatureToggled);
    318     if (m_pEditorPort)
    319         connect(m_pEditorPort, &QLineEdit::textChanged, this, &UIVRDESettingsEditor::sigChanged);
    320     if (m_pEditorTimeout)
    321         connect(m_pEditorTimeout, &QLineEdit::textChanged, this, &UIVRDESettingsEditor::sigChanged);
    322 }
    323 
    324 void UIVRDESettingsEditor::repopulateComboAuthType()
    325 {
    326     if (m_pComboAuthType)
     239        connect(m_pCheckboxFeature, &QCheckBox::toggled,
     240                this, &UIDiskEncryptionSettingsEditor::sltHandleFeatureToggled);
     241    if (m_pComboCipher)
     242        connect(m_pComboCipher, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
     243                this, &UIDiskEncryptionSettingsEditor::sigCipherChanged);
     244    if (m_pEditorEncryptionPassword)
     245        connect(m_pEditorEncryptionPassword, &QLineEdit::textEdited,
     246                this, &UIDiskEncryptionSettingsEditor::sigPasswordChanged);
     247    if (m_pEditorEncryptionPasswordConfirm)
     248        connect(m_pEditorEncryptionPasswordConfirm, &QLineEdit::textEdited,
     249                this, &UIDiskEncryptionSettingsEditor::sigPasswordChanged);
     250}
     251
     252void UIDiskEncryptionSettingsEditor::repopulateCombo()
     253{
     254    if (m_pComboCipher)
    327255    {
    328256        /* Clear combo first of all: */
    329         m_pComboAuthType->clear();
     257        m_pComboCipher->clear();
    330258
    331259        /// @todo get supported auth types (API not implemented), not hardcoded!
    332         QVector<KAuthType> authTypes = QVector<KAuthType>() << KAuthType_Null
    333                                                             << KAuthType_External
    334                                                             << KAuthType_Guest;
     260        QVector<UIDiskEncryptionCipherType> cipherTypes =
     261            QVector<UIDiskEncryptionCipherType>() << UIDiskEncryptionCipherType_Unchanged
     262                                                  << UIDiskEncryptionCipherType_XTS256
     263                                                  << UIDiskEncryptionCipherType_XTS128;
    335264
    336265        /* Take into account currently cached value: */
    337         if (!authTypes.contains(m_enmAuthType))
    338             authTypes.prepend(m_enmAuthType);
     266        if (!cipherTypes.contains(m_enmCipherType))
     267            cipherTypes.prepend(m_enmCipherType);
    339268
    340269        /* Populate combo finally: */
    341         foreach (const KAuthType &enmType, authTypes)
    342             m_pComboAuthType->addItem(gpConverter->toString(enmType), QVariant::fromValue(enmType));
     270        foreach (const UIDiskEncryptionCipherType &enmType, cipherTypes)
     271            m_pComboCipher->addItem(gpConverter->toString(enmType), QVariant::fromValue(enmType));
    343272
    344273        /* Look for proper index to choose: */
    345         const int iIndex = m_pComboAuthType->findData(QVariant::fromValue(m_enmAuthType));
     274        const int iIndex = m_pComboCipher->findData(QVariant::fromValue(m_enmCipherType));
    346275        if (iIndex != -1)
    347             m_pComboAuthType->setCurrentIndex(iIndex);
    348     }
    349 }
     276            m_pComboCipher->setCurrentIndex(iIndex);
     277    }
     278}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIDiskEncryptionSettingsEditor.h

    r94497 r94498  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVRDESettingsEditor class declaration.
     3 * VBox Qt GUI - UIDiskEncryptionSettingsEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIVRDESettingsEditor_h
    19 #define FEQT_INCLUDED_SRC_settings_editors_UIVRDESettingsEditor_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIDiskEncryptionSettingsEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIDiskEncryptionSettingsEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727/* COM includes: */
    28 #include "COMEnums.h"
     28#include "UIExtraDataDefs.h"
    2929
    3030/* Forward declarations: */
     
    3535class QWidget;
    3636
    37 /** QWidget subclass used as a VRDE settings editor. */
    38 class SHARED_LIBRARY_STUFF UIVRDESettingsEditor : public QIWithRetranslateUI<QWidget>
     37/** QWidget subclass used as a disk encryption settings editor. */
     38class SHARED_LIBRARY_STUFF UIDiskEncryptionSettingsEditor : public QIWithRetranslateUI<QWidget>
    3939{
    4040    Q_OBJECT;
     
    4242signals:
    4343
    44     /** Notify listeners about some status changed. */
    45     void sigChanged();
     44    /** Notify listeners about status changed. */
     45    void sigStatusChanged();
     46    /** Notify listeners about cipher changed. */
     47    void sigCipherChanged();
     48    /** Notify listeners about password changed. */
     49    void sigPasswordChanged();
    4650
    4751public:
    4852
    4953    /** Constructs editor passing @a pParent to the base-class. */
    50     UIVRDESettingsEditor(QWidget *pParent = 0);
     54    UIDiskEncryptionSettingsEditor(QWidget *pParent = 0);
    5155
    5256    /** Defines whether feature is @a fEnabled. */
     
    5559    bool isFeatureEnabled() const;
    5660
    57     /** Defines whether VRDE options are @a fAvailable. */
    58     void setVRDEOptionsAvailable(bool fAvailable);
     61    /** Defines cipher @a enmType. */
     62    void setCipherType(const UIDiskEncryptionCipherType &enmType);
     63    /** Returns cipher type. */
     64    UIDiskEncryptionCipherType cipherType() const;
    5965
    60     /** Defines @a strPort. */
    61     void setPort(const QString &strPort);
    62     /** Returns port. */
    63     QString port() const;
    64 
    65     /** Defines auth @a enmType. */
    66     void setAuthType(const KAuthType &enmType);
    67     /** Returns auth type. */
    68     KAuthType authType() const;
    69 
    70     /** Defines @a strTimeout. */
    71     void setTimeout(const QString &strTimeout);
    72     /** Returns timeout. */
    73     QString timeout() const;
    74 
    75     /** Defines whether multiple connections @a fAllowed. */
    76     void setMultipleConnectionsAllowed(bool fAllowed);
    77     /** Returns whether multiple connections allowed. */
    78     bool isMultipleConnectionsAllowed() const;
     66    /** Returns password 1. */
     67    QString password1() const;
     68    /** Returns password 2. */
     69    QString password2() const;
    7970
    8071protected:
     
    9788    void prepareConnections();
    9889
    99     /** Repopulates auth type combo-box. */
    100     void repopulateComboAuthType();
     90    /** Repopulates combo-box. */
     91    void repopulateCombo();
    10192
    10293    /** @name Values
    10394     * @{ */
    10495        /** Holds whether feature is enabled. */
    105         bool       m_fFeatureEnabled;
    106         /** Holds the port. */
    107         QString    m_strPort;
    108         /** Holds the auth type. */
    109         KAuthType  m_enmAuthType;
    110         /** Holds the timeout. */
    111         QString    m_strTimeout;
    112         /** Returns whether multiple connections allowed. */
    113         bool       m_fMultipleConnectionsAllowed;
     96        bool                        m_fFeatureEnabled;
     97        /** Holds the cipher type. */
     98        UIDiskEncryptionCipherType  m_enmCipherType;
     99        /** Holds the password 1. */
     100        QString                     m_strPassword1;
     101        /** Holds the password 2. */
     102        QString                     m_strPassword2;
    114103    /** @} */
    115104
     
    120109        /** Holds the settings widget instance. */
    121110        QWidget   *m_pWidgetSettings;
    122         /** Holds the port label instance. */
    123         QLabel    *m_pLabelPort;
    124         /** Holds the port editor instance. */
    125         QLineEdit *m_pEditorPort;
    126         /** Holds the port auth method label instance. */
    127         QLabel    *m_pLabelAuthMethod;
    128         /** Holds the port auth method combo instance. */
    129         QComboBox *m_pComboAuthType;
    130         /** Holds the timeout label instance. */
    131         QLabel    *m_pLabelTimeout;
    132         /** Holds the timeout editor instance. */
    133         QLineEdit *m_pEditorTimeout;
    134         /** Holds the options label instance. */
    135         QLabel    *m_pLabelOptions;
    136         /** Holds the multiple connection check-box instance. */
    137         QCheckBox *m_pCheckboxMultipleConnections;
     111        /** Holds the cipher type label instance. */
     112        QLabel    *m_pLabelCipher;
     113        /** Holds the cipher type combo instance. */
     114        QComboBox *m_pComboCipher;
     115        /** Holds the enter password label instance. */
     116        QLabel    *m_pLabelEncryptionPassword;
     117        /** Holds the enter password editor instance. */
     118        QLineEdit *m_pEditorEncryptionPassword;
     119        /** Holds the confirm password label instance. */
     120        QLabel    *m_pLabelEncryptionPasswordConfirm;
     121        /** Holds the confirm password editor instance. */
     122        QLineEdit *m_pEditorEncryptionPasswordConfirm;
    138123    /** @} */
    139124};
    140125
    141 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIVRDESettingsEditor_h */
     126#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIDiskEncryptionSettingsEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r94476 r94498  
    2828#include "QITabWidget.h"
    2929#include "QIWidgetValidator.h"
     30#include "UIAddDiskEncryptionPasswordDialog.h"
    3031#include "UICommon.h"
    3132#include "UIConverter.h"
     33#include "UIDiskEncryptionSettingsEditor.h"
    3234#include "UIDragAndDropEditor.h"
    3335#include "UIErrorString.h"
     
    6466        , m_fEncryptionCipherChanged(false)
    6567        , m_fEncryptionPasswordChanged(false)
    66         , m_iEncryptionCipherIndex(-1)
     68        , m_enmEncryptionCipherType(UIDiskEncryptionCipherType_Max)
    6769        , m_strEncryptionPassword(QString())
    6870    {}
     
    108110
    109111    /** Holds whether the encryption is enabled. */
    110     bool                   m_fEncryptionEnabled;
     112    bool                        m_fEncryptionEnabled;
    111113    /** Holds whether the encryption cipher was changed. */
    112     bool                   m_fEncryptionCipherChanged;
     114    bool                        m_fEncryptionCipherChanged;
    113115    /** Holds whether the encryption password was changed. */
    114     bool                   m_fEncryptionPasswordChanged;
     116    bool                        m_fEncryptionPasswordChanged;
    115117    /** Holds the encryption cipher index. */
    116     int                    m_iEncryptionCipherIndex;
     118    UIDiskEncryptionCipherType  m_enmEncryptionCipherType;
    117119    /** Holds the encryption password. */
    118     QString                m_strEncryptionPassword;
     120    QString                     m_strEncryptionPassword;
    119121    /** Holds the encrypted medium ids. */
    120     EncryptedMediumMap     m_encryptedMedia;
     122    EncryptedMediumMap          m_encryptedMedia;
    121123    /** Holds the encryption passwords. */
    122     EncryptionPasswordMap  m_encryptionPasswords;
     124    EncryptionPasswordMap       m_encryptionPasswords;
    123125};
    124126
     
    139141    , m_pEditorDescription(0)
    140142    , m_pTabEncryption(0)
    141     , m_pCheckBoxEncryption(0)
    142     , m_pWidgetEncryptionSettings(0)
    143     , m_pLabelCipher(0)
    144     , m_pComboCipher(0)
    145     , m_pLabelEncryptionPassword(0)
    146     , m_pEditorEncryptionPassword(0)
    147     , m_pLabelEncryptionPasswordConfirm(0)
    148     , m_pEditorEncryptionPasswordConfirm(0)
     143    , m_pEditorDiskEncryptionSettings(0)
    149144{
    150145    prepare();
     
    244239    oldGeneralData.m_fEncryptionPasswordChanged = false;
    245240    if (fEncryptionCipherCommon)
    246         oldGeneralData.m_iEncryptionCipherIndex = m_encryptionCiphers.indexOf(strCipher);
    247     if (oldGeneralData.m_iEncryptionCipherIndex == -1)
    248         oldGeneralData.m_iEncryptionCipherIndex = 0;
     241        oldGeneralData.m_enmEncryptionCipherType = gpConverter->fromInternalString<UIDiskEncryptionCipherType>(strCipher);
    249242    oldGeneralData.m_encryptedMedia = encryptedMedia;
    250243
     
    280273
    281274    /* Load old 'Encryption' data from cache: */
    282     AssertPtrReturnVoid(m_pCheckBoxEncryption);
    283     AssertPtrReturnVoid(m_pComboCipher);
    284     m_pCheckBoxEncryption->setChecked(oldGeneralData.m_fEncryptionEnabled);
    285     m_pComboCipher->setCurrentIndex(oldGeneralData.m_iEncryptionCipherIndex);
     275    AssertPtrReturnVoid(m_pEditorDiskEncryptionSettings);
     276    m_pEditorDiskEncryptionSettings->setFeatureEnabled(oldGeneralData.m_fEncryptionEnabled);
     277    m_pEditorDiskEncryptionSettings->setCipherType(oldGeneralData.m_enmEncryptionCipherType);
    286278    m_fEncryptionCipherChanged = oldGeneralData.m_fEncryptionCipherChanged;
    287279    m_fEncryptionPasswordChanged = oldGeneralData.m_fEncryptionPasswordChanged;
     
    318310
    319311    /* Gather new 'Encryption' data: */
    320     AssertPtrReturnVoid(m_pCheckBoxEncryption);
    321     AssertPtrReturnVoid(m_pComboCipher);
    322     AssertPtrReturnVoid(m_pEditorEncryptionPassword);
    323     newGeneralData.m_fEncryptionEnabled = m_pCheckBoxEncryption->isChecked();
     312    AssertPtrReturnVoid(m_pEditorDiskEncryptionSettings);
     313    newGeneralData.m_fEncryptionEnabled = m_pEditorDiskEncryptionSettings->isFeatureEnabled();
    324314    newGeneralData.m_fEncryptionCipherChanged = m_fEncryptionCipherChanged;
    325315    newGeneralData.m_fEncryptionPasswordChanged = m_fEncryptionPasswordChanged;
    326     newGeneralData.m_iEncryptionCipherIndex = m_pComboCipher->currentIndex();
    327     newGeneralData.m_strEncryptionPassword = m_pEditorEncryptionPassword->text();
     316    newGeneralData.m_enmEncryptionCipherType = m_pEditorDiskEncryptionSettings->cipherType();
     317    newGeneralData.m_strEncryptionPassword = m_pEditorDiskEncryptionSettings->password1();
    328318    newGeneralData.m_encryptedMedia = m_pCache->base().m_encryptedMedia;
    329319    /* If encryption status, cipher or password is changed: */
     
    403393
    404394    /* Encryption validation: */
    405     AssertPtrReturn(m_pCheckBoxEncryption, false);
    406     if (m_pCheckBoxEncryption->isChecked())
     395    AssertPtrReturn(m_pEditorDiskEncryptionSettings, false);
     396    if (m_pEditorDiskEncryptionSettings->isFeatureEnabled())
    407397    {
    408398        /* Encryption Extension Pack presence test: */
     
    418408
    419409        /* Cipher should be chosen if once changed: */
    420         AssertPtrReturn(m_pComboCipher, false);
    421         if (!m_pCache->base().m_fEncryptionEnabled ||
    422             m_fEncryptionCipherChanged)
    423         {
    424             if (m_pComboCipher->currentIndex() == 0)
     410        if (   !m_pCache->base().m_fEncryptionEnabled
     411            || m_fEncryptionCipherChanged)
     412        {
     413            if (m_pEditorDiskEncryptionSettings->cipherType() == UIDiskEncryptionCipherType_Unchanged)
    425414                message.second << tr("Disk encryption cipher type not specified.");
    426415            fPass = false;
     
    428417
    429418        /* Password should be entered and confirmed if once changed: */
    430         AssertPtrReturn(m_pEditorEncryptionPassword, false);
    431         AssertPtrReturn(m_pEditorEncryptionPasswordConfirm, false);
    432419        if (!m_pCache->base().m_fEncryptionEnabled ||
    433420            m_fEncryptionPasswordChanged)
    434421        {
    435             if (m_pEditorEncryptionPassword->text().isEmpty())
     422            if (m_pEditorDiskEncryptionSettings->password1().isEmpty())
    436423                message.second << tr("Disk encryption password empty.");
    437424            else
    438             if (m_pEditorEncryptionPassword->text() !=
    439                 m_pEditorEncryptionPasswordConfirm->text())
     425            if (m_pEditorDiskEncryptionSettings->password1() !=
     426                m_pEditorDiskEncryptionSettings->password2())
    440427                message.second << tr("Disk encryption passwords do not match.");
    441428            fPass = false;
     
    479466    m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabAdvanced), tr("A&dvanced"));
    480467    m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabDescription), tr("D&escription"));
    481     m_pCheckBoxEncryption->setToolTip(tr("When checked, disks attached to this virtual machine will be encrypted."));
    482     m_pCheckBoxEncryption->setText(tr("En&able Disk Encryption"));
    483     m_pLabelCipher->setText(tr("Disk Encryption C&ipher:"));
    484     m_pComboCipher->setToolTip(tr("Selects the cipher to be used for encrypting the virtual machine disks."));
    485     m_pLabelEncryptionPassword->setText(tr("E&nter New Password:"));
    486     m_pEditorEncryptionPassword->setToolTip(tr("Holds the encryption password for disks attached to this virtual machine."));
    487     m_pLabelEncryptionPasswordConfirm->setText(tr("C&onfirm New Password:"));
    488     m_pEditorEncryptionPasswordConfirm->setToolTip(tr("Confirms the disk encryption password."));
    489468    m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabEncryption), tr("Disk Enc&ryption"));
    490 
    491     /* Translate Cipher type combo: */
    492     AssertPtrReturnVoid(m_pComboCipher);
    493     m_pComboCipher->setItemText(0, tr("Leave Unchanged", "cipher type"));
    494469
    495470    /* These editors have own labels, but we want them to be properly layouted according to each other: */
     
    524499
    525500    /* Polish 'Encryption' availability: */
    526     AssertPtrReturnVoid(m_pCheckBoxEncryption);
    527     AssertPtrReturnVoid(m_pWidgetEncryptionSettings);
    528     m_pCheckBoxEncryption->setEnabled(isMachineOffline());
    529     m_pWidgetEncryptionSettings->setEnabled(isMachineOffline() && m_pCheckBoxEncryption->isChecked());
     501    AssertPtrReturnVoid(m_pEditorDiskEncryptionSettings);
     502    m_pEditorDiskEncryptionSettings->setEnabled(isMachineOffline());
     503}
     504
     505void UIMachineSettingsGeneral::sltHandleEncryptionCipherChanged()
     506{
     507    m_fEncryptionCipherChanged = true;
     508    revalidate();
     509}
     510
     511void UIMachineSettingsGeneral::sltHandleEncryptionPasswordChanged()
     512{
     513    m_fEncryptionCipherChanged = true;
     514    m_fEncryptionPasswordChanged = true;
     515    revalidate();
    530516}
    531517
     
    594580    {
    595581        /* Prepare 'Advanced' tab layout: */
    596         QGridLayout *pLayoutAdvanced = new QGridLayout(m_pTabAdvanced);
     582        QVBoxLayout *pLayoutAdvanced = new QVBoxLayout(m_pTabAdvanced);
    597583        if (pLayoutAdvanced)
    598584        {
    599             pLayoutAdvanced->setColumnStretch(2, 1);
    600             pLayoutAdvanced->setRowStretch(3, 1);
    601 
    602585            /* Prepare snapshot folder editor: */
    603586            m_pEditorSnapshotFolder = new UISnapshotFolderEditor(m_pTabAdvanced);
    604587            if (m_pEditorSnapshotFolder)
    605                 pLayoutAdvanced->addWidget(m_pEditorSnapshotFolder, 0, 0);
     588                pLayoutAdvanced->addWidget(m_pEditorSnapshotFolder);
    606589
    607590            /* Prepare clipboard editor: */
    608591            m_pEditorClipboard = new UISharedClipboardEditor(m_pTabAdvanced);
    609592            if (m_pEditorClipboard)
    610                 pLayoutAdvanced->addWidget(m_pEditorClipboard, 1, 0);
     593                pLayoutAdvanced->addWidget(m_pEditorClipboard);
    611594
    612595            /* Prepare drag&drop editor: */
    613596            m_pEditorDragAndDrop = new UIDragAndDropEditor(m_pTabAdvanced);
    614597            if (m_pEditorDragAndDrop)
    615                 pLayoutAdvanced->addWidget(m_pEditorDragAndDrop, 2, 0);
     598                pLayoutAdvanced->addWidget(m_pEditorDragAndDrop);
     599
     600            pLayoutAdvanced->addStretch();
    616601        }
    617602
     
    650635    {
    651636        /* Prepare 'Encryption' tab layout: */
    652         QGridLayout *pLayoutEncryption = new QGridLayout(m_pTabEncryption);
     637        QVBoxLayout *pLayoutEncryption = new QVBoxLayout(m_pTabEncryption);
    653638        if (pLayoutEncryption)
    654639        {
    655             pLayoutEncryption->setRowStretch(2, 1);
    656 
    657             /* Prepare encryption check-box: */
    658             m_pCheckBoxEncryption = new QCheckBox(m_pTabEncryption);
    659             if (m_pCheckBoxEncryption)
    660                 pLayoutEncryption->addWidget(m_pCheckBoxEncryption, 0, 0, 1, 2);
    661 
    662             /* Prepare 20-px shifting spacer: */
    663             QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    664             if (pSpacerItem)
    665                 pLayoutEncryption->addItem(pSpacerItem, 1, 0);
    666 
    667             /* Prepare encryption settings widget: */
    668             m_pWidgetEncryptionSettings = new QWidget(m_pTabEncryption);
    669             if (m_pWidgetEncryptionSettings)
    670             {
    671                 /* Prepare encryption settings widget layout: */
    672                 QGridLayout *m_pLayoutEncryptionSettings = new QGridLayout(m_pWidgetEncryptionSettings);
    673                 if (m_pLayoutEncryptionSettings)
    674                 {
    675                     m_pLayoutEncryptionSettings->setContentsMargins(0, 0, 0, 0);
    676 
    677                     /* Prepare encryption cipher label: */
    678                     m_pLabelCipher = new QLabel(m_pWidgetEncryptionSettings);
    679                     if (m_pLabelCipher)
    680                     {
    681                         m_pLabelCipher->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    682                         m_pLayoutEncryptionSettings->addWidget(m_pLabelCipher, 0, 0);
    683                     }
    684                     /* Prepare encryption cipher combo: */
    685                     m_pComboCipher = new QComboBox(m_pWidgetEncryptionSettings);
    686                     if (m_pComboCipher)
    687                     {
    688                         if (m_pLabelCipher)
    689                             m_pLabelCipher->setBuddy(m_pComboCipher);
    690                         m_encryptionCiphers << QString()
    691                                             << "AES-XTS256-PLAIN64"
    692                                             << "AES-XTS128-PLAIN64";
    693                         m_pComboCipher->addItems(m_encryptionCiphers);
    694                         m_pLayoutEncryptionSettings->addWidget(m_pComboCipher, 0, 1);
    695                     }
    696 
    697                     /* Prepare encryption password label: */
    698                     m_pLabelEncryptionPassword = new QLabel(m_pWidgetEncryptionSettings);
    699                     if (m_pLabelEncryptionPassword)
    700                     {
    701                         m_pLabelEncryptionPassword->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    702                         m_pLayoutEncryptionSettings->addWidget(m_pLabelEncryptionPassword, 1, 0);
    703                     }
    704                     /* Prepare encryption password editor: */
    705                     m_pEditorEncryptionPassword = new QLineEdit(m_pWidgetEncryptionSettings);
    706                     if (m_pEditorEncryptionPassword)
    707                     {
    708                         if (m_pLabelEncryptionPassword)
    709                             m_pLabelEncryptionPassword->setBuddy(m_pEditorEncryptionPassword);
    710                         m_pEditorEncryptionPassword->setEchoMode(QLineEdit::Password);
    711                         m_pLayoutEncryptionSettings->addWidget(m_pEditorEncryptionPassword, 1, 1);
    712                     }
    713 
    714                     /* Prepare encryption confirm password label: */
    715                     m_pLabelEncryptionPasswordConfirm = new QLabel(m_pWidgetEncryptionSettings);
    716                     if (m_pLabelEncryptionPasswordConfirm)
    717                     {
    718                         m_pLabelEncryptionPasswordConfirm->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    719                         m_pLayoutEncryptionSettings->addWidget(m_pLabelEncryptionPasswordConfirm, 2, 0);
    720                     }
    721                     /* Prepare encryption confirm password editor: */
    722                     m_pEditorEncryptionPasswordConfirm = new QLineEdit(m_pWidgetEncryptionSettings);
    723                     if (m_pEditorEncryptionPasswordConfirm)
    724                     {
    725                         if (m_pLabelEncryptionPasswordConfirm)
    726                             m_pLabelEncryptionPasswordConfirm->setBuddy(m_pEditorEncryptionPasswordConfirm);
    727                         m_pEditorEncryptionPasswordConfirm->setEchoMode(QLineEdit::Password);
    728                         m_pLayoutEncryptionSettings->addWidget(m_pEditorEncryptionPasswordConfirm, 2, 1);
    729                     }
    730                 }
    731 
    732                 pLayoutEncryption->addWidget(m_pWidgetEncryptionSettings, 1, 1);
    733             }
     640            /* Prepare disk encryption settings editor: */
     641            m_pEditorDiskEncryptionSettings = new UIDiskEncryptionSettingsEditor(m_pTabEncryption);
     642            if (m_pEditorDiskEncryptionSettings)
     643                pLayoutEncryption->addWidget(m_pEditorDiskEncryptionSettings);
     644
     645            pLayoutEncryption->addStretch();
    734646        }
    735647
     
    747659
    748660    /* Configure 'Encryption' connections: */
    749     connect(m_pCheckBoxEncryption, &QCheckBox::toggled,
    750             m_pWidgetEncryptionSettings, &QWidget::setEnabled);
    751     connect(m_pCheckBoxEncryption, &QCheckBox::toggled,
     661    connect(m_pEditorDiskEncryptionSettings, &UIDiskEncryptionSettingsEditor::sigStatusChanged,
    752662            this, &UIMachineSettingsGeneral::revalidate);
    753     connect(m_pComboCipher, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    754             this, &UIMachineSettingsGeneral::sltMarkEncryptionCipherChanged);
    755     connect(m_pComboCipher, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    756             this, &UIMachineSettingsGeneral::revalidate);
    757     connect(m_pEditorEncryptionPassword, &QLineEdit::textEdited,
    758             this, &UIMachineSettingsGeneral::sltMarkEncryptionPasswordChanged);
    759     connect(m_pEditorEncryptionPassword, &QLineEdit::textEdited,
    760             this, &UIMachineSettingsGeneral::revalidate);
    761     connect(m_pEditorEncryptionPasswordConfirm, &QLineEdit::textEdited,
    762             this, &UIMachineSettingsGeneral::sltMarkEncryptionPasswordChanged);
    763     connect(m_pEditorEncryptionPasswordConfirm, &QLineEdit::textEdited,
    764             this, &UIMachineSettingsGeneral::revalidate);
     663    connect(m_pEditorDiskEncryptionSettings, &UIDiskEncryptionSettingsEditor::sigCipherChanged,
     664            this, &UIMachineSettingsGeneral::sltHandleEncryptionCipherChanged);
     665    connect(m_pEditorDiskEncryptionSettings, &UIDiskEncryptionSettingsEditor::sigPasswordChanged,
     666            this, &UIMachineSettingsGeneral::sltHandleEncryptionPasswordChanged);
    765667}
    766668
     
    991893                    {
    992894                        /* Cipher attribute changed? */
    993                         QString strNewCipher;
    994                         if (newGeneralData.m_fEncryptionCipherChanged)
    995                         {
    996                             strNewCipher = newGeneralData.m_fEncryptionEnabled ?
    997                                            m_encryptionCiphers.at(newGeneralData.m_iEncryptionCipherIndex) : QString();
    998                         }
     895                        const QString strNewCipher
     896                            = newGeneralData.m_fEncryptionCipherChanged && newGeneralData.m_fEncryptionEnabled
     897                            ? gpConverter->toInternalString(newGeneralData.m_enmEncryptionCipherType)
     898                            : QString();
    999899
    1000900                        /* Password attribute changed? */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r94476 r94498  
    2323
    2424/* GUI includes: */
    25 #include "UIAddDiskEncryptionPasswordDialog.h"
    2625#include "UISettingsPage.h"
    2726
    2827/* Forward declarations: */
    29 class QCheckBox;
    30 class QComboBox;
    31 class QLineEdit;
    3228class QITabWidget;
     29class UIDiskEncryptionSettingsEditor;
    3330class UIDragAndDropEditor;
    3431class UIMachineDescriptionEditor;
     
    9289private slots:
    9390
    94     /** Marks the encryption cipher as changed. */
    95     void sltMarkEncryptionCipherChanged() { m_fEncryptionCipherChanged = true; }
    96     /** Marks the encryption cipher and password as changed. */
    97     void sltMarkEncryptionPasswordChanged() { m_fEncryptionCipherChanged = true; m_fEncryptionPasswordChanged = true; }
     91    /** Handles encryption cipher change. */
     92    void sltHandleEncryptionCipherChanged();
     93    /** Handles encryption password change. */
     94    void sltHandleEncryptionPasswordChanged();
    9895
    9996private:
     
    139136    bool  m_fEncryptionPasswordChanged;
    140137
    141     /** Holds the hard-coded encryption cipher list.
    142       * We are hard-coding it because there is no place we can get it from. */
    143     QStringList  m_encryptionCiphers;
    144 
    145138    /** Holds the page data cache instance. */
    146139    UISettingsCacheMachineGeneral *m_pCache;
     
    171164
    172165        /** Holds the 'Encryption' tab instance. */
    173         QWidget   *m_pTabEncryption;
    174         /** Holds the encryption check-box instance. */
    175         QCheckBox *m_pCheckBoxEncryption;
    176         /** Holds the encryption widget instance. */
    177         QWidget   *m_pWidgetEncryptionSettings;
    178         /** Holds the cipher label instance. */
    179         QLabel    *m_pLabelCipher;
    180         /** Holds the cipher combo instance. */
    181         QComboBox *m_pComboCipher;
    182         /** Holds the enter password label instance. */
    183         QLabel    *m_pLabelEncryptionPassword;
    184         /** Holds the enter password editor instance. */
    185         QLineEdit *m_pEditorEncryptionPassword;
    186         /** Holds the confirm password label instance. */
    187         QLabel    *m_pLabelEncryptionPasswordConfirm;
    188         /** Holds the confirm password editor instance. */
    189         QLineEdit *m_pEditorEncryptionPasswordConfirm;
     166        QWidget                        *m_pTabEncryption;
     167        /** Holds the cipher settings editor instance. */
     168        UIDiskEncryptionSettingsEditor *m_pEditorDiskEncryptionSettings;
    190169    /** @} */
    191170};
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