Changeset 75633 in vbox
- Timestamp:
- Nov 21, 2018 10:03:40 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126811
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.cpp
r75619 r75633 23 23 # include <QAction> 24 24 # include <QComboBox> 25 # include <QCheckBox> 25 26 # include <QDateTime> 26 27 # include <QDir> … … 44 45 # include "UIIconPool.h" 45 46 # include "UIGuestControlFileTable.h" 47 # include "UIGuestControlFileManager.h" 46 48 # include "UIGuestControlFileModel.h" 47 49 # include "UIToolBar.h" … … 99 101 100 102 protected: 101 virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {} 103 104 virtual void drawFocus ( QPainter * /*painter*/, const QStyleOptionViewItem & /*option*/, const QRect & /*rect*/ ) const {} 105 102 106 }; 103 107 104 108 105 109 /********************************************************************************************************************************* 106 * U IFileStringInputDialog definition. *110 * UStringInputDialog definition. * 107 111 *********************************************************************************************************************************/ 108 112 … … 121 125 122 126 QILineEdit *m_pLineEdit; 127 128 }; 129 130 131 /********************************************************************************************************************************* 132 * UIFileDeleteConfirmationDialog definition. * 133 *********************************************************************************************************************************/ 134 135 /** A QIDialog child including a line edit whose text exposed when the dialog is accepted */ 136 class UIFileDeleteConfirmationDialog : public QIDialog 137 { 138 139 Q_OBJECT; 140 141 public: 142 143 UIFileDeleteConfirmationDialog(QWidget *pParent = 0, Qt::WindowFlags flags = 0); 144 /** Returns whether m_pAskNextTimeCheckBox is checked or not. */ 145 bool askDeleteConfirmationNextTime() const; 146 147 private: 148 149 QCheckBox *m_pAskNextTimeCheckBox; 150 QLabel *m_pQuestionLabel; 123 151 124 152 }; … … 341 369 new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); 342 370 layout->addWidget(pButtonBox); 343 // {344 // /* Configure button-box: */345 371 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIStringInputDialog::accept); 346 372 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIStringInputDialog::reject); 347 348 373 } 349 374 … … 598 623 { 599 624 return m_isDriveItem; 625 } 626 627 /********************************************************************************************************************************* 628 +* UIFileDeleteConfirmationDialog implementation. * 629 +*********************************************************************************************************************************/ 630 631 UIFileDeleteConfirmationDialog::UIFileDeleteConfirmationDialog(QWidget *pParent /* = 0 */, Qt::WindowFlags flags /* = 0 */) 632 :QIDialog(pParent, flags) 633 , m_pAskNextTimeCheckBox(0) 634 , m_pQuestionLabel(0) 635 { 636 QVBoxLayout *pLayout = new QVBoxLayout(this); 637 638 m_pQuestionLabel = new QLabel; 639 if (m_pQuestionLabel) 640 { 641 pLayout->addWidget(m_pQuestionLabel); 642 m_pQuestionLabel->setText(UIGuestControlFileManager::tr("Delete the selected file(s) and/or folder(s)")); 643 } 644 645 QIDialogButtonBox *pButtonBox = 646 new QIDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); 647 if (pButtonBox) 648 { 649 pLayout->addWidget(pButtonBox, 0, Qt::AlignCenter); 650 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIStringInputDialog::accept); 651 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIStringInputDialog::reject); 652 } 653 654 QCheckBox *m_pAskNextTimeCheckBox = new QCheckBox; 655 656 if (m_pAskNextTimeCheckBox) 657 { 658 pLayout->addWidget(m_pAskNextTimeCheckBox); 659 m_pAskNextTimeCheckBox->setText(UIGuestControlFileManager::tr("Ask for this confirmation next time")); 660 } 661 } 662 663 bool UIFileDeleteConfirmationDialog::askDeleteConfirmationNextTime() const 664 { 665 if (!m_pAskNextTimeCheckBox) 666 return true; 667 return m_pAskNextTimeCheckBox->isChecked(); 600 668 } 601 669 … … 974 1042 void UIGuestControlFileTable::sltDelete() 975 1043 { 1044 if (!checkIfDeleteOK()) 1045 return; 1046 1047 if (!m_pView || !m_pModel) 1048 return; 1049 976 1050 if (!m_pView || !m_pModel) 977 1051 return; … … 1419 1493 } 1420 1494 1495 bool UIGuestControlFileTable::checkIfDeleteOK() 1496 { 1497 UIGuestControlFileManagerSettings *pFileManagerSettings = UIGuestControlFileManagerSettings::instance(); 1498 if (!pFileManagerSettings) 1499 return true; 1500 if (!pFileManagerSettings->bAskDeleteConfirmation) 1501 return true; 1502 UIFileDeleteConfirmationDialog *pDialog = 1503 new UIFileDeleteConfirmationDialog(this); 1504 1505 1506 bool fContinueWithDelete = (pDialog->execute() == QDialog::Accepted); 1507 1508 bool bAskNextTime = pDialog->askDeleteConfirmationNextTime(); 1509 1510 /* Update the file manager settings only if it is necessary: */ 1511 if (pFileManagerSettings->bAskDeleteConfirmation != bAskNextTime) 1512 { 1513 pFileManagerSettings->bAskDeleteConfirmation = bAskNextTime; 1514 /* Notify file manager settings panel so that the check box there is updated: */ 1515 emit sigDeleteConfirmationSettingChanged(); 1516 } 1517 1518 delete pDialog; 1519 1520 return fContinueWithDelete; 1521 1522 } 1523 1421 1524 #include "UIGuestControlFileTable.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.h
r75610 r75633 246 246 247 247 void sigLogOutput(QString strLog, FileManagerLogType eLogType); 248 void sigDeleteConfirmationSettingChanged(); 248 249 249 250 public: … … 363 364 /** Clears the m_pSearchLineEdit and hides it. */ 364 365 void disableSelectionSearch(); 366 /** Checks if delete confirmation dialog is shown and users choice. Returns true 367 * if deletion can continue */ 368 bool checkIfDeleteOK(); 369 365 370 UIGuestControlFileModel *m_pModel; 366 371 UIGuestControlFileView *m_pView;
Note:
See TracChangeset
for help on using the changeset viewer.