Changeset 72038 in vbox
- Timestamp:
- Apr 26, 2018 12:56:47 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72027 r72038 453 453 src/medium/UIMediumDetailsWidget.h \ 454 454 src/medium/UIMediumManager.h \ 455 src/runtime/UIAddDiskEncryptionPasswordDialog.h \456 455 src/runtime/UIConsoleEventHandler.h \ 457 456 src/runtime/UIFrameBuffer.h \ … … 665 664 src/selector/UIActionPoolSelector.h \ 666 665 src/selector/UIVirtualBoxEventHandler.h \ 666 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 667 667 src/widgets/UIBootTable.h \ 668 668 src/widgets/UIFilePathSelector.h \ … … 775 775 src/selector/UIActionPoolSelector.h \ 776 776 src/selector/UIVirtualBoxEventHandler.h \ 777 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 777 778 src/widgets/UIBootTable.h \ 778 779 src/widgets/UIFilePathSelector.h \ … … 836 837 src/logviewer/UIVMLogViewerSearchPanel.cpp \ 837 838 src/logviewer/UIVMLogViewerTextEdit.cpp \ 838 src/runtime/UIAddDiskEncryptionPasswordDialog.cpp \839 839 src/runtime/UIConsoleEventHandler.cpp \ 840 840 src/runtime/UIFrameBuffer.cpp \ … … 874 874 src/selector/UIActionPoolSelector.cpp \ 875 875 src/selector/UIVirtualBoxEventHandler.cpp \ 876 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 876 877 src/widgets/UIFilmContainer.cpp \ 877 878 src/widgets/UIHotKeyEditor.cpp \ … … 916 917 src/selector/UIActionPoolSelector.cpp \ 917 918 src/selector/UIVirtualBoxEventHandler.cpp \ 919 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 918 920 src/widgets/UIFilmContainer.cpp \ 919 921 src/widgets/UIHotKeyEditor.cpp \ … … 964 966 src/medium/UIMediumManager.cpp \ 965 967 src/objects/UIRichTextString.cpp \ 966 src/runtime/UIAddDiskEncryptionPasswordDialog.cpp \967 968 src/runtime/UIConsoleEventHandler.cpp \ 968 969 src/runtime/UIFrameBuffer.cpp \ … … 1215 1216 src/selector/UIVirtualBoxEventHandler.cpp \ 1216 1217 src/settings/UISettingsDefs.cpp \ 1218 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1217 1219 src/widgets/UIBootTable.cpp \ 1218 1220 src/widgets/UIFilePathSelector.cpp \ … … 1351 1353 src/selector/UIVirtualBoxEventHandler.cpp \ 1352 1354 src/settings/UISettingsDefs.cpp \ 1355 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1353 1356 src/widgets/UIBootTable.cpp \ 1354 1357 src/widgets/UIFilePathSelector.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIAddDiskEncryptionPasswordDialog.cpp
r72037 r72038 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QVBoxLayout> 23 # include <QAbstractTableModel> 24 # include <QHeaderView> 25 # include <QItemEditorFactory> 24 26 # include <QLabel> 25 27 # include <QLineEdit> 28 # include <QPushButton> 29 # include <QStandardItemEditorCreator> 26 30 # include <QTableView> 27 # include <QHeaderView> 28 # include <QPushButton> 29 # include <QItemEditorFactory> 30 # include <QAbstractTableModel> 31 # include <QStandardItemEditorCreator> 31 # include <QVBoxLayout> 32 32 33 33 /* GUI includes: */ 34 # include "QIDialogButtonBox.h" 35 # include "QIStyledItemDelegate.h" 36 # include "QIWithRetranslateUI.h" 37 # include "VBoxGlobal.h" 38 # include "UIAddDiskEncryptionPasswordDialog.h" 39 # include "UIIconPool.h" 34 40 # include "UIMedium.h" 35 # include "UIIconPool.h"36 # include "VBoxGlobal.h"37 41 # include "UIMessageCenter.h" 38 # include "QIDialogButtonBox.h"39 # include "QIWithRetranslateUI.h"40 # include "QIStyledItemDelegate.h"41 # include "UIAddDiskEncryptionPasswordDialog.h"42 42 43 43 /* Other VBox includes: */ … … 45 45 46 46 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 47 47 48 48 49 /** UIEncryptionDataTable field indexes. */ … … 54 55 }; 55 56 56 /** QLineEdit reimplementation used as 57 58 /** QLineEdit extension used as 57 59 * the embedded password editor for the UIEncryptionDataTable. */ 58 60 class UIPasswordEditor : public QLineEdit … … 73 75 public: 74 76 75 /** Constructor. 76 * @param pParent being passed to the base-class. */ 77 /** Constructs password editor passing @a pParent to the base-class. */ 77 78 UIPasswordEditor(QWidget *pParent); 79 80 protected: 81 82 /** Handles key-press @a pEvent. */ 83 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 78 84 79 85 private slots: … … 84 90 private: 85 91 86 /** Prepare routine. */92 /** Prepares all. */ 87 93 void prepare(); 88 89 /** Key press @a pEvent handler. */90 void keyPressEvent(QKeyEvent *pEvent);91 94 92 95 /** Property: Returns the current password of the editor. */ … … 96 99 }; 97 100 98 /** QAbstractTableModel reimplementation used as 101 102 /** QAbstractTableModel extension used as 99 103 * the data representation model for the UIEncryptionDataTable. */ 100 104 class UIEncryptionDataModel : public QAbstractTableModel … … 104 108 public: 105 109 106 /** Constructor. 107 * @param pParent being passed to the base-class, 108 * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */ 110 /** Constructs model passing @a pParent to the base-class. 111 * @param encryptedMediums Brings the lists of medium ids (values) encrypted with passwords with ids (keys). */ 109 112 UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums); 110 113 … … 130 133 private: 131 134 132 /** Prepare routine. */135 /** Prepares all. */ 133 136 void prepare(); 134 137 … … 137 140 138 141 /** Holds the encryption password map instance. */ 139 EncryptionPasswordMap m_encryptionPasswords;142 EncryptionPasswordMap m_encryptionPasswords; 140 143 }; 141 144 142 /** QTableView reimplementation used to 145 146 /** QTableView extension used to 143 147 * allow the UIAddDiskEncryptionPasswordDialog to enter 144 148 * disk encryption passwords for particular password ids. */ … … 154 158 public: 155 159 156 /** Construct or.157 * @param pParent being passed to the base-class. */160 /** Constructs table. 161 * @param encryptedMediums Brings the lists of medium ids (values) encrypted with passwords with ids (keys). */ 158 162 UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums); 159 163 … … 167 171 private: 168 172 169 /** Prepare routine. */173 /** Prepares all. */ 170 174 void prepare(); 171 175 … … 177 181 }; 178 182 183 184 /********************************************************************************************************************************* 185 * Class UIPasswordEditor implementation. * 186 *********************************************************************************************************************************/ 187 179 188 UIPasswordEditor::UIPasswordEditor(QWidget *pParent) 180 189 : QLineEdit(pParent) … … 182 191 /* Prepare: */ 183 192 prepare(); 184 }185 186 void UIPasswordEditor::prepare()187 {188 /* Set echo mode: */189 setEchoMode(QLineEdit::Password);190 /* Listen for the text changes: */191 connect(this, SIGNAL(textChanged(const QString&)),192 this, SLOT(sltCommitData()));193 193 } 194 194 … … 210 210 } 211 211 } 212 213 void UIPasswordEditor::prepare() 214 { 215 /* Set echo mode: */ 216 setEchoMode(QLineEdit::Password); 217 /* Listen for the text changes: */ 218 connect(this, &UIPasswordEditor::textChanged, 219 this, &UIPasswordEditor::sltCommitData); 220 } 221 222 223 /********************************************************************************************************************************* 224 * Class UIEncryptionDataModel implementation. * 225 *********************************************************************************************************************************/ 212 226 213 227 UIEncryptionDataModel::UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums) … … 349 363 } 350 364 365 366 /********************************************************************************************************************************* 367 * Class UIEncryptionDataTable implementation. * 368 *********************************************************************************************************************************/ 369 351 370 UIEncryptionDataTable::UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums) 352 371 : m_encryptedMediums(encryptedMediums) … … 380 399 /* Create encryption-data model: */ 381 400 m_pModelEncryptionData = new UIEncryptionDataModel(this, m_encryptedMediums); 382 AssertPtrReturnVoid(m_pModelEncryptionData);401 if (m_pModelEncryptionData) 383 402 { 384 403 /* Assign configured model to table: */ … … 388 407 /* Create item delegate: */ 389 408 QIStyledItemDelegate *pStyledItemDelegate = new QIStyledItemDelegate(this); 390 AssertPtrReturnVoid(pStyledItemDelegate);409 if (pStyledItemDelegate) 391 410 { 392 411 /* Create item editor factory: */ 393 412 QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory; 394 AssertPtrReturnVoid(pNewItemEditorFactory);413 if (pNewItemEditorFactory) 395 414 { 396 415 /* Create item editor creator: */ 397 416 QStandardItemEditorCreator<UIPasswordEditor> *pQStringItemEditorCreator = new QStandardItemEditorCreator<UIPasswordEditor>(); 398 AssertPtrReturnVoid(pQStringItemEditorCreator);417 if (pQStringItemEditorCreator) 399 418 { 400 419 /* Register UIPasswordEditor as the QString editor: */ 401 420 pNewItemEditorFactory->registerEditor(QVariant::String, pQStringItemEditorCreator); 402 421 } 422 403 423 /* Assign configured item editor factory to table delegate: */ 404 424 pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory); 405 425 } 426 406 427 /* Assign configured item delegate to table: */ 407 428 delete itemDelegate(); 408 429 setItemDelegate(pStyledItemDelegate); 430 409 431 /* Configure item delegate: */ 410 432 pStyledItemDelegate->setWatchForEditorDataCommits(true); 411 433 pStyledItemDelegate->setWatchForEditorEnterKeyTriggering(true); 412 connect(pStyledItemDelegate, SIGNAL(sigEditorEnterKeyTriggered()),413 this, SIGNAL(sigEditorEnterKeyTriggered()));434 connect(pStyledItemDelegate, &QIStyledItemDelegate::sigEditorEnterKeyTriggered, 435 this, &UIEncryptionDataTable::sigEditorEnterKeyTriggered); 414 436 } 415 437 … … 428 450 horizontalHeader()->setSectionResizeMode(UIEncryptionDataTableSection_Password, QHeaderView::Stretch); 429 451 } 452 453 454 /********************************************************************************************************************************* 455 * Class UIAddDiskEncryptionPasswordDialog implementation. * 456 *********************************************************************************************************************************/ 430 457 431 458 UIAddDiskEncryptionPasswordDialog::UIAddDiskEncryptionPasswordDialog(QWidget *pParent, … … 441 468 /* Prepare: */ 442 469 prepare(); 443 /* Translate: */470 /* Apply language settings: */ 444 471 retranslateUi(); 445 472 } … … 449 476 AssertPtrReturn(m_pTableEncryptionData, EncryptionPasswordMap()); 450 477 return m_pTableEncryptionData->encryptionPasswords(); 451 }452 453 void UIAddDiskEncryptionPasswordDialog::accept()454 {455 /* Validate passwords status: */456 foreach (const QString &strPasswordId, m_encryptedMediums.uniqueKeys())457 {458 const QString strMediumId = m_encryptedMediums.values(strPasswordId).first();459 const QString strPassword = m_pTableEncryptionData->encryptionPasswords().value(strPasswordId);460 if (!isPasswordValid(strMediumId, strPassword))461 {462 msgCenter().warnAboutInvalidEncryptionPassword(strPasswordId, this);463 AssertPtrReturnVoid(m_pTableEncryptionData);464 m_pTableEncryptionData->setFocus();465 m_pTableEncryptionData->editFirstIndex();466 return;467 }468 }469 /* Call to base-class: */470 QIWithRetranslateUI<QDialog>::accept();471 }472 473 void UIAddDiskEncryptionPasswordDialog::prepare()474 {475 /* Configure self: */476 setWindowModality(Qt::WindowModal);477 478 /* Create main-layout: */479 QVBoxLayout *pMainLayout = new QVBoxLayout(this);480 AssertPtrReturnVoid(pMainLayout);481 {482 /* Create input-layout: */483 QVBoxLayout *pInputLayout = new QVBoxLayout;484 AssertPtrReturnVoid(pInputLayout);485 {486 /* Create description label: */487 m_pLabelDescription = new QLabel;488 AssertPtrReturnVoid(m_pLabelDescription);489 {490 /* Add label into layout: */491 pInputLayout->addWidget(m_pLabelDescription);492 }493 /* Create encryption-data table: */494 m_pTableEncryptionData = new UIEncryptionDataTable(m_encryptedMediums);495 AssertPtrReturnVoid(m_pTableEncryptionData);496 {497 /* Configure encryption-data table: */498 connect(m_pTableEncryptionData, SIGNAL(sigEditorEnterKeyTriggered()),499 this, SLOT(sltEditorEnterKeyTriggered()));500 m_pTableEncryptionData->setFocus();501 m_pTableEncryptionData->editFirstIndex();502 /* Add label into layout: */503 pInputLayout->addWidget(m_pTableEncryptionData);504 }505 /* Add layout into parent: */506 pMainLayout->addLayout(pInputLayout);507 }508 /* Create button-box: */509 m_pButtonBox = new QIDialogButtonBox;510 AssertPtrReturnVoid(m_pButtonBox);511 {512 /* Configure button-box: */513 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);514 connect(m_pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));515 connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));516 /* Add button-box into layout: */517 pMainLayout->addWidget(m_pButtonBox);518 }519 }520 478 } 521 479 … … 537 495 } 538 496 497 void UIAddDiskEncryptionPasswordDialog::accept() 498 { 499 /* Validate passwords status: */ 500 foreach (const QString &strPasswordId, m_encryptedMediums.uniqueKeys()) 501 { 502 const QString strMediumId = m_encryptedMediums.values(strPasswordId).first(); 503 const QString strPassword = m_pTableEncryptionData->encryptionPasswords().value(strPasswordId); 504 if (!isPasswordValid(strMediumId, strPassword)) 505 { 506 msgCenter().warnAboutInvalidEncryptionPassword(strPasswordId, this); 507 AssertPtrReturnVoid(m_pTableEncryptionData); 508 m_pTableEncryptionData->setFocus(); 509 m_pTableEncryptionData->editFirstIndex(); 510 return; 511 } 512 } 513 /* Call to base-class: */ 514 QIWithRetranslateUI<QDialog>::accept(); 515 } 516 517 void UIAddDiskEncryptionPasswordDialog::prepare() 518 { 519 /* Configure self: */ 520 setWindowModality(Qt::WindowModal); 521 522 /* Create main-layout: */ 523 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 524 if (pMainLayout) 525 { 526 /* Create input-layout: */ 527 QVBoxLayout *pInputLayout = new QVBoxLayout; 528 if (pInputLayout) 529 { 530 /* Create description label: */ 531 m_pLabelDescription = new QLabel; 532 if (m_pLabelDescription) 533 { 534 /* Add label into layout: */ 535 pInputLayout->addWidget(m_pLabelDescription); 536 } 537 538 /* Create encryption-data table: */ 539 m_pTableEncryptionData = new UIEncryptionDataTable(m_encryptedMediums); 540 if (m_pTableEncryptionData) 541 { 542 /* Configure encryption-data table: */ 543 connect(m_pTableEncryptionData, &UIEncryptionDataTable::sigEditorEnterKeyTriggered, 544 this, &UIAddDiskEncryptionPasswordDialog::sltEditorEnterKeyTriggered); 545 m_pTableEncryptionData->setFocus(); 546 m_pTableEncryptionData->editFirstIndex(); 547 /* Add label into layout: */ 548 pInputLayout->addWidget(m_pTableEncryptionData); 549 } 550 551 /* Add layout into parent: */ 552 pMainLayout->addLayout(pInputLayout); 553 } 554 555 /* Create button-box: */ 556 m_pButtonBox = new QIDialogButtonBox; 557 if (m_pButtonBox) 558 { 559 /* Configure button-box: */ 560 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 561 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIAddDiskEncryptionPasswordDialog::accept); 562 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIAddDiskEncryptionPasswordDialog::reject); 563 564 /* Add button-box into layout: */ 565 pMainLayout->addWidget(m_pButtonBox); 566 } 567 } 568 } 569 539 570 /* static */ 540 571 bool UIAddDiskEncryptionPasswordDialog::isPasswordValid(const QString strMediumId, const QString strPassword) … … 557 588 } 558 589 590 559 591 #include "UIAddDiskEncryptionPasswordDialog.moc" 560 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIAddDiskEncryptionPasswordDialog.h
r72037 r72038 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 /* Qt includes: */ 22 22 #include <QDialog> 23 #include <QMap> 23 24 #include <QMultiMap> 24 #include <QMap>25 25 26 26 /* GUI includes: */ 27 27 #include "QIWithRetranslateUI.h" 28 #include "UILibraryDefs.h" 28 29 29 30 /* Forward declarations: */ 31 class QLabel; 32 class QIDialogButtonBox; 30 33 class UIEncryptionDataTable; 31 class QIDialogButtonBox;32 class QLabel;33 34 34 35 /* Type definitions: */ … … 37 38 typedef QMap<QString, bool> EncryptionPasswordStatusMap; 38 39 39 /** QDialog reimplementationused to40 * allow the user to enter disk encryption passwords for particular password ids. */41 class UIAddDiskEncryptionPasswordDialog : public QIWithRetranslateUI<QDialog>40 /** QDialog subclass used to 41 * allow the user to enter disk encryption passwords for particular password IDs. */ 42 class SHARED_LIBRARY_STUFF UIAddDiskEncryptionPasswordDialog : public QIWithRetranslateUI<QDialog> 42 43 { 43 44 Q_OBJECT; … … 45 46 public: 46 47 47 /** Constructor. 48 * @param pParent being passed to the base-class, 49 * @param strMachineName holds the name of the machine we show this dialog for, 50 * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */ 48 /** Constructs dialog passing @a pParent to the base-class. 49 * @param strMachineName Brings the name of the machine we show this dialog for. 50 * @param encryptedMediums Brings the lists of medium ids (values) encrypted with passwords with ids (keys). */ 51 51 UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const QString &strMachineName, const EncryptedMediumMap &encryptedMediums); 52 52 … … 54 54 * acquired from the UIEncryptionDataTable instance. */ 55 55 EncryptionPasswordMap encryptionPasswords() const; 56 57 protected: 58 59 /** Translation routine. */ 60 virtual void retranslateUi() /* override */; 56 61 57 62 private slots: … … 67 72 private: 68 73 69 /** Prepare routine. */74 /** Prepares all. */ 70 75 void prepare(); 71 72 /** Translation routine. */73 void retranslateUi();74 76 75 77 /** Returns whether passed @a strPassword is valid for medium with passed @a strMediumId. */ … … 77 79 78 80 /** Holds the name of the machine we show this dialog for. */ 79 const QString m_strMachineName;81 const QString m_strMachineName; 80 82 81 83 /** Holds the encrypted medium map reference. */ … … 83 85 84 86 /** Holds the description label instance. */ 85 QLabel *m_pLabelDescription;87 QLabel *m_pLabelDescription; 86 88 /** Holds the encryption-data table instance. */ 87 89 UIEncryptionDataTable *m_pTableEncryptionData; 88 90 /** Holds the button-box instance. */ 89 QIDialogButtonBox *m_pButtonBox;91 QIDialogButtonBox *m_pButtonBox; 90 92 }; 91 93
Note:
See TracChangeset
for help on using the changeset viewer.