VirtualBox

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


Ignore:
Timestamp:
Nov 28, 2018 1:18:29 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Improving file operation panel (just a tiny bit).

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

Legend:

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

    r75776 r75788  
    2222/* Qt includes: */
    2323# include <QHBoxLayout>
    24 # include <QHeaderView>
    2524# include <QLabel>
    2625# include <QMenu>
    2726# include <QProgressBar>
    28 # include <QTableWidget>
     27# include <QScrollArea>
     28# include <QStyle>
     29
    2930
    3031/* GUI includes: */
    3132# include "QIToolButton.h"
     33# include "QILabel.h"
    3234# include "UIErrorString.h"
    3335# include "UIIconPool.h"
     
    4749*********************************************************************************************************************************/
    4850
    49 class UIFileOperationProgressWidget : public QIWithRetranslateUI<QWidget>
     51class UIFileOperationProgressWidget : public QIWithRetranslateUI<QFrame>
    5052{
    5153
     
    6668protected:
    6769
    68     void retranslateUi() /* override */;
     70    virtual void retranslateUi() /* override */;
     71    // virtual void focusInEvent(QFocusEvent *pEvent) /* override */;
     72    // virtual void focusOutEvent(QFocusEvent *pEvent) /* override */;
    6973
    7074private slots:
     
    8690    QProgressBar           *m_pProgressBar;
    8791    QIToolButton           *m_pCancelButton;
     92    QILabel                *m_pStatusLabel;
    8893};
    8994
     
    9499
    95100UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent /* = 0 */)
    96     : QIWithRetranslateUI<QWidget>(pParent)
     101    : QIWithRetranslateUI<QFrame>(pParent)
    97102    , m_comProgress(comProgress)
    98103    , m_pEventHandler(0)
     
    100105    , m_pProgressBar(0)
    101106    , m_pCancelButton(0)
     107    , m_pStatusLabel(0)
    102108{
    103109    prepare();
    104     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
     110    setFocusPolicy(Qt::ClickFocus);
     111    setFrameStyle(QFrame::Panel);
     112    setLineWidth(0);
     113    setStyleSheet("QFrame:focus {  border-width: 1px; border-style: dashed; border-color: black; }");
     114
    105115}
    106116
     
    130140}
    131141
     142// void UIFileOperationProgressWidget::focusInEvent(QFocusEvent *pEvent)
     143// {
     144//     Q_UNUSED(pEvent);
     145//     //setFrameStyle(QFrame::Panel);
     146//     setLineWidth(3);
     147//     printf("booo\n");
     148//     repaint();
     149// }
     150
     151// void UIFileOperationProgressWidget::focusOutEvent(QFocusEvent *pEvent)
     152// {
     153//     Q_UNUSED(pEvent);
     154//     //setFrameStyle(QFrame::NoFrame);
     155//     setLineWidth(0);
     156// }
     157
    132158void UIFileOperationProgressWidget::prepare()
    133159{
     
    141167    if (!m_pMainLayout)
    142168        return;
    143     m_pMainLayout->setSpacing(0);
     169    //m_pMainLayout->setSpacing(0);
    144170
    145171    m_pCancelButton = new QIToolButton;
     
    162188        m_pProgressBar->setMaximum(100);
    163189        m_pProgressBar->setTextVisible(true);
    164         m_pProgressBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
     190        //   m_pProgressBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
    165191        m_pMainLayout->addWidget(m_pProgressBar);
     192    }
     193    m_pStatusLabel = new QILabel;
     194    if (m_pStatusLabel)
     195    {
     196        m_pMainLayout->addWidget(m_pStatusLabel);
     197        m_pStatusLabel->setText(UIGuestControlFileManager::tr("Idle"));
    166198    }
    167199    setLayout(m_pMainLayout);
     
    177209    connect(m_pEventHandler, &UIProgressEventHandler::sigProgressTaskComplete,
    178210            this, &UIFileOperationProgressWidget::sltHandleProgressComplete);
     211    m_pStatusLabel->setText(UIGuestControlFileManager::tr("Working"));
    179212}
    180213
     
    190223    Q_UNUSED(iPercent);
    191224    m_pProgressBar->setValue(iPercent);
     225
    192226}
    193227
     
    199233
    200234    if (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0)
     235    {
    201236        emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), FileManagerLogType_Error);
     237        if (m_pStatusLabel)
     238            m_pStatusLabel->setText(UIGuestControlFileManager::tr("Failed"));
     239    }
    202240    else
     241    {
    203242        emit sigProgressComplete(m_comProgress.GetId());
     243        if (m_pStatusLabel)
     244            m_pStatusLabel->setText(UIGuestControlFileManager::tr("Succeeded"));
     245    }
    204246}
    205247
     
    210252    if (m_pCancelButton)
    211253        m_pCancelButton->setEnabled(false);
     254    if (m_pStatusLabel)
     255        m_pStatusLabel->setText(UIGuestControlFileManager::tr("Canceled"));
     256    if (m_pProgressBar)
     257        m_pProgressBar->setEnabled(false);
    212258}
    213259
     
    220266                                                                                   QWidget *pParent)
    221267    : UIGuestControlFileManagerPanel(pManagerWidget, pParent)
    222     , m_pTableWidget(0)
     268    , m_pScrollArea(0)
     269    , m_pContainerWidget(0)
     270    , m_pContainerLayout(0)
     271    , m_pContainerSpaceItem(0)
    223272{
    224273    prepare();
     
    227276void UIGuestControlFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress)
    228277{
    229     if (!m_pTableWidget)
    230         return;
    231 
    232     /** Insert the row to the top of the table since inserting to the bottom causes a strange stacking
    233      *  effect of the widgets: */
    234     m_pTableWidget->insertRow(0);
     278    if (!m_pContainerLayout)
     279        return;
     280
    235281    UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress);
    236     m_pTableWidget->setCellWidget(0, 0, pOperationsWidget);
     282    if (!pOperationsWidget)
     283        return;
     284    m_pContainerLayout->insertWidget(m_pContainerLayout->count() - 1, pOperationsWidget);
     285
    237286    connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressComplete,
    238287            this, &UIGuestControlFileManagerOperationsPanel::sigFileOperationComplete);
    239288    connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressFail,
    240289            this, &UIGuestControlFileManagerOperationsPanel::sigFileOperationFail);
    241     /* Trying to make the the rows look a bit less shitty */
    242     //m_pTableWidget->resizeRowsToContents();
    243     //m_pTableWidget->horizontalHeader()->setStretchLastSection(true);
    244     m_pTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    245     //m_pTableWidget->scrollToBottom();
    246290}
    247291
     
    255299    if (!mainLayout())
    256300        return;
    257     m_pTableWidget = new QTableWidget();
    258 
    259     if (m_pTableWidget)
    260     {
    261         m_pTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    262         m_pTableWidget->setColumnCount(TableColumn_Max);
    263         m_pTableWidget->verticalHeader()->hide();
    264         m_pTableWidget->horizontalHeader()->hide();
    265         m_pTableWidget->setShowGrid(false);
    266         mainLayout()->addWidget(m_pTableWidget);
    267     }
     301
     302
     303    m_pScrollArea = new QScrollArea;
     304    m_pContainerWidget = new QWidget;
     305    m_pContainerLayout = new QVBoxLayout;
     306    if (!m_pScrollArea || !m_pContainerWidget || !m_pContainerLayout)
     307        return;
     308
     309    m_pScrollArea->setBackgroundRole(QPalette::Window);
     310    m_pScrollArea->setWidgetResizable(true);
     311
     312    mainLayout()->addWidget(m_pScrollArea);
     313
     314    m_pScrollArea->setWidget(m_pContainerWidget);
     315    m_pContainerWidget->setLayout(m_pContainerLayout);
     316    m_pContainerLayout->addStretch(4);
    268317}
    269318
     
    296345void UIGuestControlFileManagerOperationsPanel::sltCleanFinished()
    297346{
    298     QList<int> listOfRowsToRemove;
    299     for (int i = 0; i < m_pTableWidget->rowCount(); ++i)
    300     {
    301         UIFileOperationProgressWidget* pProgressWidget =
    302             qobject_cast<UIFileOperationProgressWidget*>(m_pTableWidget->cellWidget(i, TableColumn_Progress));
    303         if (pProgressWidget)
    304         {
    305             if (pProgressWidget->isCanceled() || pProgressWidget->isCompleted())
    306                 listOfRowsToRemove << i;
    307         }
    308     }
    309     foreach (int row, listOfRowsToRemove)
    310     {
    311         /* This will delete the progress widget as well: */
    312         m_pTableWidget->removeRow(row);
    313     }
     347    // QList<int> listOfRowsToRemove;
     348    // for (int i = 0; i < m_pListView->count(); ++i)
     349    // {
     350    //     UIFileOperationProgressWidget* pProgressWidget =
     351    //         qobject_cast<UIFileOperationProgressWidget*>(m_pListView->itemWidget(m_pListView->item(i)));
     352    //     if (pProgressWidget)
     353    //     {
     354    //         if (pProgressWidget->isCanceled() || pProgressWidget->isCompleted())
     355    //             listOfRowsToRemove << i;
     356    //     }
     357    // }
     358    // foreach (int row, listOfRowsToRemove)
     359    // {
     360    //     /* This will delete the progress widget as well: */
     361    //     QListWidgetItem *pItem = m_pListView->takeItem(row);
     362    //     delete m_pListView->itemWidget(pItem);
     363    //     delete pItem;
     364    // }
    314365}
    315366
    316367void UIGuestControlFileManagerOperationsPanel::sltCleanAll()
    317368{
    318     m_pTableWidget->clearContents();
    319     m_pTableWidget->setRowCount(0);
     369    //m_pListView->clear();
     370    //m_pListView->setRowCount(0);
    320371}
    321372
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h

    r75732 r75788  
    2828/* Forward declarations: */
    2929class CProgress;
    30 class QTableWidget;
     30class QScrollArea;
     31class QSpacerItem;
     32class QVBoxLayout;
     33
     34class UIFileOperationModel;
    3135class UIFileOperationProgressWidget;
    3236class UIGuestControlFileManager;
    3337
    3438
    35 /** UIVMLogViewerPanel extension hosting a QTableWidget which in turn has a special QWidget extension
     39/** UIVMLogViewerPanel extension hosting a QListWidget which in turn has a special QWidget extension
    3640  * to manage multiple CProgress instances. This is particulary used in monitoring file operations. */
    3741class UIGuestControlFileManagerOperationsPanel : public UIGuestControlFileManagerPanel
     
    6973private:
    7074
    71     enum TableColumn
    72     {
    73         TableColumn_Progress,
    74         TableColumn_Info,
    75         TableColumn_Max
    76     };
    77 
    7875    /** @name Member variables.
    7976      * @{ */
    80         QTableWidget *m_pTableWidget;
     77        QScrollArea *m_pScrollArea;
     78        QWidget     *m_pContainerWidget;
     79        QVBoxLayout *m_pContainerLayout;
     80        QSpacerItem *m_pContainerSpaceItem;
    8181    /** @} */
     82
     83
    8284
    8385};
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