VirtualBox

Changeset 75728 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 26, 2018 8:49:55 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Add a context menu to operations panel

Location:
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.cpp

    r75610 r75728  
    2424# include <QHeaderView>
    2525# include <QLabel>
     26# include <QMenu>
    2627# include <QProgressBar>
    2728# include <QTableWidget>
     
    5455    UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent = 0);
    5556    ~UIFileOperationProgressWidget();
     57    bool isCompleted() const;
     58    bool isCanceled() const;
    5659
    5760signals:
     
    104107}
    105108
     109bool UIFileOperationProgressWidget::isCompleted() const
     110{
     111    if (m_comProgress.isNull())
     112        return true;
     113    return m_comProgress.GetCompleted();
     114}
     115
     116bool UIFileOperationProgressWidget::isCanceled() const
     117{
     118    if (m_comProgress.isNull())
     119        return true;
     120    return m_comProgress.GetCanceled();
     121}
     122
    106123void UIFileOperationProgressWidget::retranslateUi()
    107124{
     
    231248    if (m_pTableWidget)
    232249    {
     250        m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    233251        m_pTableWidget->setColumnCount(TableColumn_Max);
    234252        m_pTableWidget->verticalHeader()->hide();
     
    249267{
    250268    UIGuestControlFileManagerPanel::retranslateUi();
    251 
     269}
     270
     271void UIGuestControlFileManagerOperationsPanel::contextMenuEvent(QContextMenuEvent *pEvent)
     272{
     273    QMenu *menu = new QMenu(this);
     274
     275    QAction *pCleanFinished = menu->addAction(UIGuestControlFileManager::tr("Clean Finished"));
     276    QAction *pCleanAll = menu->addAction(UIGuestControlFileManager::tr("Clean All"));
     277
     278    connect(pCleanFinished, &QAction::triggered,
     279            this, &UIGuestControlFileManagerOperationsPanel::sltCleanFinished);
     280    connect(pCleanAll, &QAction::triggered,
     281            this, &UIGuestControlFileManagerOperationsPanel::sltCleanAll);
     282
     283    menu->exec(pEvent->globalPos());
     284    delete menu;
     285}
     286
     287void UIGuestControlFileManagerOperationsPanel::sltCleanFinished()
     288{
     289    QList<int> listOfRowsToRemove;
     290    for (int i = 0; i < m_pTableWidget->rowCount(); ++i)
     291    {
     292        UIFileOperationProgressWidget* pProgressWidget =
     293            qobject_cast<UIFileOperationProgressWidget*>(m_pTableWidget->cellWidget(i, TableColumn_Progress));
     294        if (pProgressWidget)
     295        {
     296            if (pProgressWidget->isCanceled() || pProgressWidget->isCompleted())
     297                listOfRowsToRemove << i;
     298        }
     299    }
     300    foreach (int row, listOfRowsToRemove)
     301    {
     302        /* This will delete the progress widget as well: */
     303        m_pTableWidget->removeRow(row);
     304    }
     305}
     306
     307void UIGuestControlFileManagerOperationsPanel::sltCleanAll()
     308{
     309    m_pTableWidget->clearContents();
     310    m_pTableWidget->setRowCount(0);
    252311}
    253312
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h

    r75610 r75728  
    5858
    5959    /** Handles the translation event. */
    60     void retranslateUi();
     60    virtual void retranslateUi() /* override */;
     61    virtual void contextMenuEvent(QContextMenuEvent *pEvent) /* override */;
    6162
    6263private slots:
    6364
     65    void sltCleanFinished();
     66    void sltCleanAll();
    6467
    6568private:
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