Changeset 100893 in vbox
- Timestamp:
- Aug 17, 2023 10:58:35 AM (16 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r100890 r100893 845 845 src/guestctrl/UIFileManagerGuestTable.h \ 846 846 src/guestctrl/UIFileManagerHostTable.h \ 847 src/guestctrl/UIFileManagerOperationsPanel.h \848 847 src/guestctrl/UIFileManagerPanel.h \ 849 848 src/guestctrl/UIFileManagerTable.h \ … … 1060 1059 src/globals/UIVirtualBoxClientEventHandler.cpp \ 1061 1060 src/guestctrl/UIFileManager.cpp \ 1062 src/guestctrl/UIFileManagerOperationsPanel.cpp \1063 1061 src/guestctrl/UIFileManagerPanel.cpp \ 1064 1062 src/guestctrl/UIFileManagerTable.cpp \ … … 1425 1423 src/guestctrl/UIFileManagerHostTable.cpp \ 1426 1424 src/guestctrl/UIFileManagerPanel.cpp \ 1427 src/guestctrl/UIFileManagerOperationsPanel.cpp \1428 1425 src/guestctrl/UIFileManagerTable.cpp \ 1429 1426 src/helpbrowser/UIHelpBrowserDialog.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp
r100890 r100893 43 43 #include "UIFileManager.h" 44 44 #include "UIFileManagerPanel.h" 45 #include "UIFileManagerOperationsPanel.h"46 45 #include "UIFileManagerGuestTable.h" 47 46 #include "UIFileManagerHostTable.h" … … 135 134 , m_fShowToolbar(fShowToolbar) 136 135 , m_pLogPanel(0) 137 , m_pOperationsPanel(0)138 136 , m_pPanel(0) 139 137 , m_fCommitDataSignalReceived(false) … … 318 316 connect(m_pPanel, &UIFileManagerPanel::sigOptionsChanged, 319 317 this, &UIFileManager::sltHandleOptionsUpdated); 320 } 321 if (m_pOperationsPanel) 322 { 323 connect(m_pOperationsPanel, &UIFileManagerOperationsPanel::sigHidePanel, 324 this, &UIFileManager::sltHandleHidePanel); 325 connect(m_pOperationsPanel, &UIFileManagerOperationsPanel::sigShowPanel, 326 this, &UIFileManager::sltHandleShowPanel); 327 } 318 connect(m_pPanel, &UIFileManagerPanel::sigFileOperationComplete, 319 this, &UIFileManager::sltFileOperationComplete); 320 connect(m_pPanel, &UIFileManagerPanel::sigFileOperationFail, 321 this, &UIFileManager::sltReceieveLogOutput); 322 } 323 328 324 if (m_pHostFileTable) 329 325 { … … 410 406 void UIFileManager::sltReceieveNewFileOperation(const CProgress &comProgress, const QString &strTableName) 411 407 { 412 if (m_p OperationsPanel)413 m_p OperationsPanel->addNewProgress(comProgress, strTableName);408 if (m_pPanel) 409 m_pPanel->addNewProgress(comProgress, strTableName); 414 410 } 415 411 … … 562 558 void UIFileManager::prepareOperationsAndLogPanels(QSplitter *pSplitter) 563 559 { 564 if (!pSplitter) 565 return; 566 m_pOperationsPanel = new UIFileManagerOperationsPanel; 567 if (m_pOperationsPanel) 568 { 569 m_pOperationsPanel->hide(); 570 connect(m_pOperationsPanel, &UIFileManagerOperationsPanel::sigFileOperationComplete, 571 this, &UIFileManager::sltFileOperationComplete); 572 connect(m_pOperationsPanel, &UIFileManagerOperationsPanel::sigFileOperationFail, 573 this, &UIFileManager::sltReceieveLogOutput); 574 m_panelActionMap.insert(m_pOperationsPanel, m_pActionPool->action(UIActionIndex_M_FileManager_T_Operations)); 575 } 576 pSplitter->addWidget(m_pOperationsPanel); 560 Q_UNUSED(pSplitter); 561 // if (!pSplitter) 562 // return; 563 // m_pPanel = new UIFileManagerOperationsPanel; 564 // if (m_pPanel) 565 // { 566 // m_pPanel->hide(); 567 // connect(m_pPanel, &UIFileManagerOperationsPanel::sigFileOperationComplete, 568 // this, &UIFileManager::sltFileOperationComplete); 569 // connect(m_pPanel, &UIFileManagerOperationsPanel::sigFileOperationFail, 570 // this, &UIFileManager::sltReceieveLogOutput); 571 // } 577 572 } 578 573 … … 607 602 /** Make sure the actions are set to not-checked. this prevents an unlikely 608 603 * bug when the extrakey for the visible panels are manually modified: */ 609 foreach(QAction* pAction, m_panelActionMap.values()) 610 { 611 pAction->blockSignals(true); 612 pAction->setChecked(false); 613 pAction->blockSignals(false); 614 } 615 604 // foreach(QAction* pAction, m_panelActionMap.values()) 605 // { 606 // pAction->blockSignals(true); 607 // pAction->setChecked(false); 608 // pAction->blockSignals(false); 609 // } 616 610 /* Load the visible panel list and show them: */ 617 QStringList strNameList = gEDataManager->fileManagerVisiblePanels();618 foreach(const QString strName, strNameList)619 {620 foreach(UIDialogPanel* pPanel, m_panelActionMap.keys())621 {622 if (strName == pPanel->panelName())623 {624 showPanel(pPanel);625 break;626 }627 }628 }611 // QStringList strNameList = gEDataManager->fileManagerVisiblePanels(); 612 // foreach(const QString strName, strNameList) 613 // { 614 // foreach(UIDialogPanel* pPanel, m_panelActionMap.keys()) 615 // { 616 // if (strName == pPanel->panelName()) 617 // { 618 // showPanel(pPanel); 619 // break; 620 // } 621 // } 622 // } 629 623 } 630 624 … … 644 638 void UIFileManager::hidePanel(UIDialogPanel* panel) 645 639 { 646 if (!m_pActionPool) 647 return; 648 if (panel && panel->isVisible()) 649 panel->setVisible(false); 650 QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 651 if (iterator != m_panelActionMap.end()) 652 { 653 if (iterator.value() && iterator.value()->isChecked()) 654 iterator.value()->setChecked(false); 655 } 656 m_visiblePanelsList.removeAll(panel); 657 manageEscapeShortCut(); 658 savePanelVisibility(); 640 Q_UNUSED(panel); 641 // if (!m_pActionPool) 642 // return; 643 // if (panel && panel->isVisible()) 644 // panel->setVisible(false); 645 // QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 646 // if (iterator != m_panelActionMap.end()) 647 // { 648 // if (iterator.value() && iterator.value()->isChecked()) 649 // iterator.value()->setChecked(false); 650 // } 651 // m_visiblePanelsList.removeAll(panel); 652 // manageEscapeShortCut(); 653 // savePanelVisibility(); 659 654 } 660 655 661 656 void UIFileManager::showPanel(UIDialogPanel* panel) 662 657 { 663 if (panel && panel->isHidden()) 664 panel->setVisible(true); 665 QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 666 if (iterator != m_panelActionMap.end()) 667 { 668 if (!iterator.value()->isChecked()) 669 iterator.value()->setChecked(true); 670 } 671 if (!m_visiblePanelsList.contains(panel)) 672 m_visiblePanelsList.push_back(panel); 673 manageEscapeShortCut(); 674 savePanelVisibility(); 658 Q_UNUSED(panel); 659 // if (panel && panel->isHidden()) 660 // panel->setVisible(true); 661 // QMap<UIDialogPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 662 // if (iterator != m_panelActionMap.end()) 663 // { 664 // if (!iterator.value()->isChecked()) 665 // iterator.value()->setChecked(true); 666 // } 667 // if (!m_visiblePanelsList.contains(panel)) 668 // m_visiblePanelsList.push_back(panel); 669 // manageEscapeShortCut(); 670 // savePanelVisibility(); 675 671 } 676 672 … … 678 674 { 679 675 /* if there is no visible panels give the escape shortcut to parent dialog: */ 680 if (m_visiblePanelsList.isEmpty())681 {682 emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape));683 return;684 }685 / * Take the escape shortcut from the dialog: */686 emit sigSetCloseButtonShortCut(QKeySequence());687 / * Just loop thru the visible panel list and set the esc key to the688 panel which made visible latest */689 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)690 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());691 692 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));676 // if (m_visiblePanelsList.isEmpty()) 677 // { 678 // emit sigSetCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 679 // return; 680 // } 681 // /* Take the escape shortcut from the dialog: */ 682 // emit sigSetCloseButtonShortCut(QKeySequence()); 683 // /* Just loop thru the visible panel list and set the esc key to the 684 // panel which made visible latest */ 685 // for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 686 // m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 687 688 // m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 693 689 } 694 690 … … 703 699 if (m_fCommitDataSignalReceived) 704 700 return; 705 / * Save a list of currently visible panels: */706 QStringList strNameList;707 foreach(UIDialogPanel* pPanel, m_visiblePanelsList)708 strNameList.append(pPanel->panelName());709 gEDataManager->setFileManagerVisiblePanels(strNameList);701 // /* Save a list of currently visible panels: */ 702 // QStringList strNameList; 703 // foreach(UIDialogPanel* pPanel, m_visiblePanelsList) 704 // strNameList.append(pPanel->panelName()); 705 // gEDataManager->setFileManagerVisiblePanels(strNameList); 710 706 } 711 707 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.cpp
r100890 r100893 30 30 #include <QHBoxLayout> 31 31 #include <QMenu> 32 #include <QProgressBar> 33 #include <QScrollArea> 34 #include <QScrollBar> 32 35 #include <QSpinBox> 36 #include <QStyle> 33 37 #include <QTabWidget> 34 38 #include <QTextEdit> … … 36 40 37 41 /* GUI includes: */ 42 #include "QILabel.h" 43 #include "QIToolButton.h" 44 #include "UIErrorString.h" 38 45 #include "UIFileManagerPanel.h" 39 46 #include "UIFileManager.h" 47 #include "UIProgressEventHandler.h" 40 48 41 49 /* Other VBox includes: */ 50 #include "CProgress.h" 42 51 #include <iprt/assert.h> 43 52 53 54 /********************************************************************************************************************************* 55 * UIFileOperationProgressWidget definition. * 56 *********************************************************************************************************************************/ 57 58 class UIFileOperationProgressWidget : public QIWithRetranslateUI<QFrame> 59 { 60 61 Q_OBJECT; 62 63 signals: 64 65 void sigProgressComplete(QUuid progressId); 66 void sigProgressFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType); 67 void sigFocusIn(QWidget *pWidget); 68 void sigFocusOut(QWidget *pWidget); 69 70 public: 71 72 UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent = 0); 73 ~UIFileOperationProgressWidget(); 74 bool isCompleted() const; 75 bool isCanceled() const; 76 77 protected: 78 79 virtual void retranslateUi() RT_OVERRIDE; 80 virtual void focusInEvent(QFocusEvent *pEvent) RT_OVERRIDE; 81 virtual void focusOutEvent(QFocusEvent *pEvent) RT_OVERRIDE; 82 83 private slots: 84 85 void sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent); 86 void sltHandleProgressComplete(const QUuid &uProgressId); 87 void sltCancelProgress(); 88 89 private: 90 enum OperationStatus 91 { 92 OperationStatus_NotStarted, 93 OperationStatus_Working, 94 OperationStatus_Paused, 95 OperationStatus_Canceled, 96 OperationStatus_Succeded, 97 OperationStatus_Failed, 98 OperationStatus_Invalid, 99 OperationStatus_Max 100 }; 101 102 void prepare(); 103 void prepareWidgets(); 104 void prepareEventHandler(); 105 void cleanupEventHandler(); 106 107 OperationStatus m_eStatus; 108 CProgress m_comProgress; 109 UIProgressEventHandler *m_pEventHandler; 110 QGridLayout *m_pMainLayout; 111 QProgressBar *m_pProgressBar; 112 QIToolButton *m_pCancelButton; 113 QILabel *m_pStatusLabel; 114 QILabel *m_pOperationDescriptionLabel; 115 /** Name of the table from which this operation has originated. */ 116 QString m_strSourceTableName; 117 }; 118 119 120 /********************************************************************************************************************************* 121 * UIFileOperationProgressWidget implementation. * 122 *********************************************************************************************************************************/ 123 124 UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent /* = 0 */) 125 : QIWithRetranslateUI<QFrame>(pParent) 126 , m_eStatus(OperationStatus_NotStarted) 127 , m_comProgress(comProgress) 128 , m_pEventHandler(0) 129 , m_pMainLayout(0) 130 , m_pProgressBar(0) 131 , m_pCancelButton(0) 132 , m_pStatusLabel(0) 133 , m_pOperationDescriptionLabel(0) 134 , m_strSourceTableName(strSourceTableName) 135 { 136 prepare(); 137 setFocusPolicy(Qt::ClickFocus); 138 setStyleSheet("QFrame:focus { border-width: 1px; border-style: dashed; border-color: black; }"); 139 } 140 141 UIFileOperationProgressWidget::~UIFileOperationProgressWidget() 142 { 143 cleanupEventHandler(); 144 } 145 146 bool UIFileOperationProgressWidget::isCompleted() const 147 { 148 if (m_comProgress.isNull()) 149 return true; 150 return m_comProgress.GetCompleted(); 151 } 152 153 bool UIFileOperationProgressWidget::isCanceled() const 154 { 155 if (m_comProgress.isNull()) 156 return true; 157 return m_comProgress.GetCanceled(); 158 } 159 160 void UIFileOperationProgressWidget::retranslateUi() 161 { 162 if (m_pCancelButton) 163 m_pCancelButton->setToolTip(UIFileManager::tr("Cancel")); 164 165 switch (m_eStatus) 166 { 167 case OperationStatus_NotStarted: 168 m_pStatusLabel->setText(UIFileManager::tr("Not yet started")); 169 break; 170 case OperationStatus_Working: 171 m_pStatusLabel->setText(UIFileManager::tr("Working")); 172 break; 173 case OperationStatus_Paused: 174 m_pStatusLabel->setText(UIFileManager::tr("Paused")); 175 break; 176 case OperationStatus_Canceled: 177 m_pStatusLabel->setText(UIFileManager::tr("Canceled")); 178 break; 179 case OperationStatus_Succeded: 180 m_pStatusLabel->setText(UIFileManager::tr("Succeded")); 181 break; 182 case OperationStatus_Failed: 183 m_pStatusLabel->setText(UIFileManager::tr("Failed")); 184 break; 185 case OperationStatus_Invalid: 186 case OperationStatus_Max: 187 default: 188 m_pStatusLabel->setText(UIFileManager::tr("Invalid")); 189 break; 190 } 191 } 192 193 void UIFileOperationProgressWidget::focusInEvent(QFocusEvent *pEvent) 194 { 195 QFrame::focusInEvent(pEvent); 196 emit sigFocusIn(this); 197 } 198 199 void UIFileOperationProgressWidget::focusOutEvent(QFocusEvent *pEvent) 200 { 201 QFrame::focusOutEvent(pEvent); 202 emit sigFocusOut(this); 203 } 204 205 void UIFileOperationProgressWidget::prepare() 206 { 207 prepareWidgets(); 208 prepareEventHandler(); 209 retranslateUi(); 210 } 211 212 void UIFileOperationProgressWidget::prepareWidgets() 213 { 214 m_pMainLayout = new QGridLayout; 215 if (!m_pMainLayout) 216 return; 217 //m_pMainLayout->setSpacing(0); 218 219 m_pOperationDescriptionLabel = new QILabel; 220 if (m_pOperationDescriptionLabel) 221 { 222 m_pOperationDescriptionLabel->setContextMenuPolicy(Qt::NoContextMenu); 223 m_pMainLayout->addWidget(m_pOperationDescriptionLabel, 0, 0, 1, 3); 224 if (!m_comProgress.isNull()) 225 m_pOperationDescriptionLabel->setText(m_comProgress.GetDescription()); 226 } 227 228 m_pProgressBar = new QProgressBar; 229 if (m_pProgressBar) 230 { 231 m_pProgressBar->setMinimum(0); 232 m_pProgressBar->setMaximum(100); 233 m_pProgressBar->setTextVisible(true); 234 m_pMainLayout->addWidget(m_pProgressBar, 1, 0, 1, 2); 235 } 236 237 m_pCancelButton = new QIToolButton; 238 if (m_pCancelButton) 239 { 240 m_pCancelButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DockWidgetCloseButton)); 241 connect(m_pCancelButton, &QIToolButton::clicked, this, &UIFileOperationProgressWidget::sltCancelProgress); 242 if (!m_comProgress.isNull() && !m_comProgress.GetCancelable()) 243 m_pCancelButton->setEnabled(false); 244 m_pMainLayout->addWidget(m_pCancelButton, 1, 2, 1, 1); 245 } 246 247 m_pStatusLabel = new QILabel; 248 if (m_pStatusLabel) 249 { 250 m_pStatusLabel->setContextMenuPolicy(Qt::NoContextMenu); 251 m_pMainLayout->addWidget(m_pStatusLabel, 1, 3, 1, 1); 252 } 253 254 setLayout(m_pMainLayout); 255 retranslateUi(); 256 } 257 258 void UIFileOperationProgressWidget::prepareEventHandler() 259 { 260 if (m_comProgress.isNull()) 261 return; 262 m_pEventHandler = new UIProgressEventHandler(this, m_comProgress); 263 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressPercentageChange, 264 this, &UIFileOperationProgressWidget::sltHandleProgressPercentageChange); 265 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressTaskComplete, 266 this, &UIFileOperationProgressWidget::sltHandleProgressComplete); 267 m_eStatus = OperationStatus_Working; 268 retranslateUi(); 269 } 270 271 void UIFileOperationProgressWidget::cleanupEventHandler() 272 { 273 delete m_pEventHandler; 274 m_pEventHandler = 0; 275 } 276 277 void UIFileOperationProgressWidget::sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent) 278 { 279 Q_UNUSED(uProgressId); 280 m_pProgressBar->setValue(iPercent); 281 } 282 283 void UIFileOperationProgressWidget::sltHandleProgressComplete(const QUuid &uProgressId) 284 { 285 Q_UNUSED(uProgressId); 286 if (m_pCancelButton) 287 m_pCancelButton->setEnabled(false); 288 289 if (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0) 290 { 291 emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), m_strSourceTableName, FileManagerLogType_Error); 292 m_eStatus = OperationStatus_Failed; 293 } 294 else 295 { 296 emit sigProgressComplete(m_comProgress.GetId()); 297 m_eStatus = OperationStatus_Succeded; 298 } 299 if (m_pProgressBar) 300 m_pProgressBar->setValue(100); 301 302 cleanupEventHandler(); 303 retranslateUi(); 304 } 305 306 void UIFileOperationProgressWidget::sltCancelProgress() 307 { 308 m_comProgress.Cancel(); 309 /* Since we dont have a "progress canceled" event we have to do this here: */ 310 if (m_pCancelButton) 311 m_pCancelButton->setEnabled(false); 312 if (m_pProgressBar) 313 m_pProgressBar->setEnabled(false); 314 m_eStatus = OperationStatus_Canceled; 315 cleanupEventHandler(); 316 retranslateUi(); 317 } 44 318 45 319 /********************************************************************************************************************************* … … 103 377 , m_pShowHiddenObjectsCheckBox(0) 104 378 , m_pFileManagerOptions(pFileManagerOptions) 379 , m_pLogTextEdit(0) 380 , m_pScrollArea(0) 381 , m_pOperationsTabLayout(0) 382 , m_pContainerSpaceItem(0) 383 , m_pWidgetInFocus(0) 105 384 { 106 385 prepare(); … … 149 428 connect(m_pListDirectoriesOnTopCheckBox, &QCheckBox::toggled, 150 429 this, &UIFileManagerPanel::sltListDirectoryCheckBoxToogled); 151 152 430 connect(m_pDeleteConfirmationCheckBox, &QCheckBox::toggled, 153 431 this, &UIFileManagerPanel::sltDeleteConfirmationCheckBoxToogled); 154 155 432 connect(m_pHumanReabableSizesCheckBox, &QCheckBox::toggled, 156 433 this, &UIFileManagerPanel::sltHumanReabableSizesCheckBoxToogled); 157 158 159 434 connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::toggled, 160 435 this, &UIFileManagerPanel::sltShowHiddenObjectsCheckBoxToggled); … … 162 437 QGridLayout *pPreferencesLayout = new QGridLayout(pPreferencesTab); 163 438 AssertReturnVoid(pPreferencesLayout); 164 pPreferencesLayout->setContentsMargins(0, 0, 0, 0);439 //pPreferencesLayout->setContentsMargins(0, 0, 0, 0); 165 440 166 441 pPreferencesLayout->addWidget(m_pListDirectoriesOnTopCheckBox, 0, 0, 1, 1); … … 186 461 } 187 462 463 void UIFileManagerPanel::prepareOperationsTab() 464 { 465 QPalette pal = QApplication::palette(); 466 pal.setColor(QPalette::Active, QPalette::Window, pal.color(QPalette::Active, QPalette::Base)); 467 setPalette(pal); 468 469 m_pScrollArea = new QScrollArea; 470 AssertReturnVoid(m_pScrollArea); 471 QWidget *pOperationsTab = new QWidget; 472 AssertReturnVoid(pOperationsTab); 473 m_pOperationsTabLayout = new QVBoxLayout; 474 AssertReturnVoid(m_pOperationsTabLayout); 475 476 QScrollBar *pVerticalScrollBar = m_pScrollArea->verticalScrollBar(); 477 if (pVerticalScrollBar) 478 QObject::connect(pVerticalScrollBar, &QScrollBar::rangeChanged, this, &UIFileManagerPanel::sltScrollToBottom); 479 480 m_pScrollArea->setBackgroundRole(QPalette::Window); 481 m_pScrollArea->setWidgetResizable(true); 482 483 //mainLayout()->addWidget(m_pScrollArea); 484 485 m_pScrollArea->setWidget(pOperationsTab); 486 pOperationsTab->setLayout(m_pOperationsTabLayout); 487 m_pOperationsTabLayout->addStretch(4); 488 m_pTabWidget->addTab(m_pScrollArea, QApplication::translate("UIFileManager", "Operations")); 489 } 490 188 491 void UIFileManagerPanel::sltListDirectoryCheckBoxToogled(bool bChecked) 189 492 { … … 298 601 } 299 602 603 void UIFileManagerPanel::addNewProgress(const CProgress &comProgress, const QString &strSourceTableName) 604 { 605 if (!m_pOperationsTabLayout) 606 return; 607 608 UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress, strSourceTableName); 609 if (!pOperationsWidget) 610 return; 611 m_widgetSet.insert(pOperationsWidget); 612 m_pOperationsTabLayout->insertWidget(m_pOperationsTabLayout->count() - 1, pOperationsWidget); 613 614 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressComplete, 615 this, &UIFileManagerPanel::sigFileOperationComplete); 616 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressFail, 617 this, &UIFileManagerPanel::sigFileOperationFail); 618 619 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigFocusIn, 620 this, &UIFileManagerPanel::sltHandleWidgetFocusIn); 621 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigFocusOut, 622 this, &UIFileManagerPanel::sltHandleWidgetFocusOut); 623 //sigShowPanel(this); 624 } 625 626 void UIFileManagerPanel::contextMenuEvent(QContextMenuEvent *pEvent) 627 { 628 QMenu *menu = new QMenu(this); 629 630 if (m_pWidgetInFocus) 631 { 632 QAction *pRemoveSelected = menu->addAction(UIFileManager::tr("Remove Selected")); 633 connect(pRemoveSelected, &QAction::triggered, 634 this, &UIFileManagerPanel::sltRemoveSelected); 635 } 636 637 QAction *pRemoveFinished = menu->addAction(UIFileManager::tr("Remove Finished")); 638 QAction *pRemoveAll = menu->addAction(UIFileManager::tr("Remove All")); 639 640 connect(pRemoveFinished, &QAction::triggered, 641 this, &UIFileManagerPanel::sltRemoveFinished); 642 connect(pRemoveAll, &QAction::triggered, 643 this, &UIFileManagerPanel::sltRemoveAll); 644 645 menu->exec(pEvent->globalPos()); 646 delete menu; 647 } 648 649 void UIFileManagerPanel::sltRemoveFinished() 650 { 651 QList<UIFileOperationProgressWidget*> widgetsToRemove; 652 foreach (QWidget *pWidget, m_widgetSet) 653 { 654 UIFileOperationProgressWidget *pProgressWidget = qobject_cast<UIFileOperationProgressWidget*>(pWidget); 655 if (pProgressWidget && pProgressWidget->isCompleted()) 656 { 657 delete pProgressWidget; 658 widgetsToRemove << pProgressWidget; 659 } 660 } 661 foreach (UIFileOperationProgressWidget *pWidget, widgetsToRemove) 662 m_widgetSet.remove(pWidget); 663 } 664 665 void UIFileManagerPanel::sltRemoveAll() 666 { 667 foreach (QWidget *pWidget, m_widgetSet) 668 { 669 if (pWidget) 670 { 671 delete pWidget; 672 } 673 } 674 m_widgetSet.clear(); 675 } 676 677 void UIFileManagerPanel::sltRemoveSelected() 678 { 679 if (!m_pWidgetInFocus) 680 return; 681 delete m_pWidgetInFocus; 682 m_widgetSet.remove(m_pWidgetInFocus); 683 } 684 685 void UIFileManagerPanel::sltHandleWidgetFocusIn(QWidget *pWidget) 686 { 687 if (!pWidget) 688 return; 689 m_pWidgetInFocus = pWidget; 690 } 691 692 void UIFileManagerPanel::sltHandleWidgetFocusOut(QWidget *pWidget) 693 { 694 if (!pWidget) 695 return; 696 m_pWidgetInFocus = 0; 697 } 698 699 void UIFileManagerPanel::sltScrollToBottom(int iMin, int iMax) 700 { 701 Q_UNUSED(iMin); 702 if (m_pScrollArea) 703 m_pScrollArea->verticalScrollBar()->setValue(iMax); 704 } 705 706 300 707 #include "UIFileManagerPanel.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.h
r100890 r100893 32 32 #endif 33 33 34 /* Qt includes */ 35 #include <QWidget> 36 #include <QSet> 37 34 38 /* GUI includes: */ 35 39 #include "UIGuestControlDefs.h" … … 41 45 class UIFileManagerLogViewer; 42 46 class UIFileManagerOptions; 47 class QScrollArea; 48 class QSpacerItem; 49 class QVBoxLayout; 43 50 44 51 class UIFileManagerPanel : public QIWithRetranslateUI<QWidget> … … 48 55 signals: 49 56 57 /* Signal(s) related to preferences tab. */ 50 58 void sigOptionsChanged(); 59 /* Signal(s) related to operations tab. */ 60 void sigFileOperationComplete(QUuid progressId); 61 void sigFileOperationFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType); 51 62 52 63 public: … … 55 66 void updatePreferences(); 56 67 void appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType); 68 void addNewProgress(const CProgress &comProgress, const QString &strSourceTableName); 57 69 58 70 protected: 59 71 60 72 virtual void retranslateUi() final override; 73 virtual void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE; 61 74 62 75 private slots: 63 76 64 void sltListDirectoryCheckBoxToogled(bool bChecked); 65 void sltDeleteConfirmationCheckBoxToogled(bool bChecked); 66 void sltHumanReabableSizesCheckBoxToogled(bool bChecked); 67 void sltShowHiddenObjectsCheckBoxToggled(bool bChecked); 77 /** @name Preferences tab slots 78 * @{ */ 79 void sltListDirectoryCheckBoxToogled(bool bChecked); 80 void sltDeleteConfirmationCheckBoxToogled(bool bChecked); 81 void sltHumanReabableSizesCheckBoxToogled(bool bChecked); 82 void sltShowHiddenObjectsCheckBoxToggled(bool bChecked); 83 /** @} */ 84 85 /** @name Operations tab slots 86 * @{ */ 87 void sltRemoveFinished(); 88 void sltRemoveAll(); 89 void sltRemoveSelected(); 90 void sltHandleWidgetFocusIn(QWidget *pWidget); 91 void sltHandleWidgetFocusOut(QWidget *pWidget); 92 void sltScrollToBottom(int iMin, int iMax); 93 /** @} */ 68 94 69 95 private: … … 72 98 void preparePreferencesTab(); 73 99 void prepareLogTab(); 100 void prepareOperationsTab(); 74 101 75 102 QTabWidget *m_pTabWidget; … … 89 116 /** @} */ 90 117 118 /** @name Operations tab 119 * @{ */ 120 QScrollArea *m_pScrollArea; 121 QVBoxLayout *m_pOperationsTabLayout; 122 QSpacerItem *m_pContainerSpaceItem; 123 QWidget *m_pWidgetInFocus; 124 QSet<QWidget*> m_widgetSet; 125 /** @} */ 91 126 }; 92 127
Note:
See TracChangeset
for help on using the changeset viewer.