VirtualBox

Changeset 100893 in vbox


Ignore:
Timestamp:
Aug 17, 2023 10:58:35 AM (16 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10496, bugref:6699. Replacing operations panel of the file manager.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 deleted
4 edited

Legend:

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

    r100890 r100893  
    845845        src/guestctrl/UIFileManagerGuestTable.h \
    846846        src/guestctrl/UIFileManagerHostTable.h \
    847         src/guestctrl/UIFileManagerOperationsPanel.h \
    848847        src/guestctrl/UIFileManagerPanel.h \
    849848        src/guestctrl/UIFileManagerTable.h \
     
    10601059        src/globals/UIVirtualBoxClientEventHandler.cpp \
    10611060        src/guestctrl/UIFileManager.cpp \
    1062         src/guestctrl/UIFileManagerOperationsPanel.cpp \
    10631061        src/guestctrl/UIFileManagerPanel.cpp \
    10641062        src/guestctrl/UIFileManagerTable.cpp \
     
    14251423        src/guestctrl/UIFileManagerHostTable.cpp \
    14261424        src/guestctrl/UIFileManagerPanel.cpp \
    1427         src/guestctrl/UIFileManagerOperationsPanel.cpp \
    14281425        src/guestctrl/UIFileManagerTable.cpp \
    14291426        src/helpbrowser/UIHelpBrowserDialog.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r100890 r100893  
    4343#include "UIFileManager.h"
    4444#include "UIFileManagerPanel.h"
    45 #include "UIFileManagerOperationsPanel.h"
    4645#include "UIFileManagerGuestTable.h"
    4746#include "UIFileManagerHostTable.h"
     
    135134    , m_fShowToolbar(fShowToolbar)
    136135    , m_pLogPanel(0)
    137     , m_pOperationsPanel(0)
    138136    , m_pPanel(0)
    139137    , m_fCommitDataSignalReceived(false)
     
    318316        connect(m_pPanel, &UIFileManagerPanel::sigOptionsChanged,
    319317                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
    328324    if (m_pHostFileTable)
    329325    {
     
    410406void UIFileManager::sltReceieveNewFileOperation(const CProgress &comProgress, const QString &strTableName)
    411407{
    412     if (m_pOperationsPanel)
    413         m_pOperationsPanel->addNewProgress(comProgress, strTableName);
     408    if (m_pPanel)
     409        m_pPanel->addNewProgress(comProgress, strTableName);
    414410}
    415411
     
    562558void UIFileManager::prepareOperationsAndLogPanels(QSplitter *pSplitter)
    563559{
    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    // }
    577572}
    578573
     
    607602    /** Make sure the actions are set to not-checked. this prevents an unlikely
    608603     *  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    // }
    616610    /* 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    // }
    629623}
    630624
     
    644638void UIFileManager::hidePanel(UIDialogPanel* panel)
    645639{
    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();
    659654}
    660655
    661656void UIFileManager::showPanel(UIDialogPanel* panel)
    662657{
    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();
    675671}
    676672
     
    678674{
    679675    /* 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 the
    688        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));
    693689}
    694690
     
    703699    if (m_fCommitDataSignalReceived)
    704700        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);
    710706}
    711707
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.cpp

    r100890 r100893  
    3030#include <QHBoxLayout>
    3131#include <QMenu>
     32#include <QProgressBar>
     33#include <QScrollArea>
     34#include <QScrollBar>
    3235#include <QSpinBox>
     36#include <QStyle>
    3337#include <QTabWidget>
    3438#include <QTextEdit>
     
    3640
    3741/* GUI includes: */
     42#include "QILabel.h"
     43#include "QIToolButton.h"
     44#include "UIErrorString.h"
    3845#include "UIFileManagerPanel.h"
    3946#include "UIFileManager.h"
     47#include "UIProgressEventHandler.h"
    4048
    4149/* Other VBox includes: */
     50#include "CProgress.h"
    4251#include <iprt/assert.h>
    4352
     53
     54/*********************************************************************************************************************************
     55*   UIFileOperationProgressWidget definition.                                                                                    *
     56*********************************************************************************************************************************/
     57
     58class UIFileOperationProgressWidget : public QIWithRetranslateUI<QFrame>
     59{
     60
     61    Q_OBJECT;
     62
     63signals:
     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
     70public:
     71
     72    UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent = 0);
     73    ~UIFileOperationProgressWidget();
     74    bool isCompleted() const;
     75    bool isCanceled() const;
     76
     77protected:
     78
     79    virtual void retranslateUi() RT_OVERRIDE;
     80    virtual void focusInEvent(QFocusEvent *pEvent) RT_OVERRIDE;
     81    virtual void focusOutEvent(QFocusEvent *pEvent) RT_OVERRIDE;
     82
     83private slots:
     84
     85    void sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent);
     86    void sltHandleProgressComplete(const QUuid &uProgressId);
     87    void sltCancelProgress();
     88
     89private:
     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
     124UIFileOperationProgressWidget::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
     141UIFileOperationProgressWidget::~UIFileOperationProgressWidget()
     142{
     143    cleanupEventHandler();
     144}
     145
     146bool UIFileOperationProgressWidget::isCompleted() const
     147{
     148    if (m_comProgress.isNull())
     149        return true;
     150    return m_comProgress.GetCompleted();
     151}
     152
     153bool UIFileOperationProgressWidget::isCanceled() const
     154{
     155    if (m_comProgress.isNull())
     156        return true;
     157    return m_comProgress.GetCanceled();
     158}
     159
     160void 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
     193void UIFileOperationProgressWidget::focusInEvent(QFocusEvent *pEvent)
     194{
     195    QFrame::focusInEvent(pEvent);
     196    emit sigFocusIn(this);
     197}
     198
     199void UIFileOperationProgressWidget::focusOutEvent(QFocusEvent *pEvent)
     200{
     201    QFrame::focusOutEvent(pEvent);
     202    emit sigFocusOut(this);
     203}
     204
     205void UIFileOperationProgressWidget::prepare()
     206{
     207    prepareWidgets();
     208    prepareEventHandler();
     209    retranslateUi();
     210}
     211
     212void 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
     258void 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
     271void UIFileOperationProgressWidget::cleanupEventHandler()
     272{
     273    delete m_pEventHandler;
     274    m_pEventHandler = 0;
     275}
     276
     277void UIFileOperationProgressWidget::sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent)
     278{
     279    Q_UNUSED(uProgressId);
     280    m_pProgressBar->setValue(iPercent);
     281}
     282
     283void 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
     306void 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}
    44318
    45319/*********************************************************************************************************************************
     
    103377    , m_pShowHiddenObjectsCheckBox(0)
    104378    , m_pFileManagerOptions(pFileManagerOptions)
     379    , m_pLogTextEdit(0)
     380    , m_pScrollArea(0)
     381    , m_pOperationsTabLayout(0)
     382    , m_pContainerSpaceItem(0)
     383    , m_pWidgetInFocus(0)
    105384{
    106385    prepare();
     
    149428    connect(m_pListDirectoriesOnTopCheckBox, &QCheckBox::toggled,
    150429            this, &UIFileManagerPanel::sltListDirectoryCheckBoxToogled);
    151 
    152430    connect(m_pDeleteConfirmationCheckBox, &QCheckBox::toggled,
    153431            this, &UIFileManagerPanel::sltDeleteConfirmationCheckBoxToogled);
    154 
    155432    connect(m_pHumanReabableSizesCheckBox, &QCheckBox::toggled,
    156433            this, &UIFileManagerPanel::sltHumanReabableSizesCheckBoxToogled);
    157 
    158 
    159434    connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::toggled,
    160435            this, &UIFileManagerPanel::sltShowHiddenObjectsCheckBoxToggled);
     
    162437    QGridLayout *pPreferencesLayout = new QGridLayout(pPreferencesTab);
    163438    AssertReturnVoid(pPreferencesLayout);
    164     pPreferencesLayout->setContentsMargins(0, 0, 0, 0);
     439    //pPreferencesLayout->setContentsMargins(0, 0, 0, 0);
    165440
    166441    pPreferencesLayout->addWidget(m_pListDirectoriesOnTopCheckBox, 0, 0, 1, 1);
     
    186461}
    187462
     463void 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
    188491void UIFileManagerPanel::sltListDirectoryCheckBoxToogled(bool bChecked)
    189492{
     
    298601}
    299602
     603void 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
     626void 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
     649void 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
     665void 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
     677void UIFileManagerPanel::sltRemoveSelected()
     678{
     679    if (!m_pWidgetInFocus)
     680        return;
     681    delete m_pWidgetInFocus;
     682    m_widgetSet.remove(m_pWidgetInFocus);
     683}
     684
     685void UIFileManagerPanel::sltHandleWidgetFocusIn(QWidget *pWidget)
     686{
     687    if (!pWidget)
     688        return;
     689    m_pWidgetInFocus = pWidget;
     690}
     691
     692void UIFileManagerPanel::sltHandleWidgetFocusOut(QWidget *pWidget)
     693{
     694    if (!pWidget)
     695        return;
     696    m_pWidgetInFocus = 0;
     697}
     698
     699void UIFileManagerPanel::sltScrollToBottom(int iMin, int iMax)
     700{
     701    Q_UNUSED(iMin);
     702    if (m_pScrollArea)
     703    m_pScrollArea->verticalScrollBar()->setValue(iMax);
     704}
     705
     706
    300707#include "UIFileManagerPanel.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.h

    r100890 r100893  
    3232#endif
    3333
     34/* Qt includes */
     35#include <QWidget>
     36#include <QSet>
     37
    3438/* GUI includes: */
    3539#include "UIGuestControlDefs.h"
     
    4145class UIFileManagerLogViewer;
    4246class UIFileManagerOptions;
     47class QScrollArea;
     48class QSpacerItem;
     49class QVBoxLayout;
    4350
    4451class UIFileManagerPanel : public QIWithRetranslateUI<QWidget>
     
    4855signals:
    4956
     57    /* Signal(s) related to preferences tab. */
    5058    void sigOptionsChanged();
     59    /* Signal(s) related to operations tab. */
     60    void sigFileOperationComplete(QUuid progressId);
     61    void sigFileOperationFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType);
    5162
    5263public:
     
    5566    void updatePreferences();
    5667    void appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType);
     68    void addNewProgress(const CProgress &comProgress, const QString &strSourceTableName);
    5769
    5870protected:
    5971
    6072    virtual void retranslateUi() final override;
     73    virtual void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
    6174
    6275private slots:
    6376
    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    /** @} */
    6894
    6995private:
     
    7298    void preparePreferencesTab();
    7399    void prepareLogTab();
     100    void prepareOperationsTab();
    74101
    75102    QTabWidget   *m_pTabWidget;
     
    89116    /** @} */
    90117
     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    /** @} */
    91126};
    92127
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