Changeset 75788 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 28, 2018 1:18:29 PM (6 years ago)
- 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 22 22 /* Qt includes: */ 23 23 # include <QHBoxLayout> 24 # include <QHeaderView>25 24 # include <QLabel> 26 25 # include <QMenu> 27 26 # include <QProgressBar> 28 # include <QTableWidget> 27 # include <QScrollArea> 28 # include <QStyle> 29 29 30 30 31 /* GUI includes: */ 31 32 # include "QIToolButton.h" 33 # include "QILabel.h" 32 34 # include "UIErrorString.h" 33 35 # include "UIIconPool.h" … … 47 49 *********************************************************************************************************************************/ 48 50 49 class UIFileOperationProgressWidget : public QIWithRetranslateUI<Q Widget>51 class UIFileOperationProgressWidget : public QIWithRetranslateUI<QFrame> 50 52 { 51 53 … … 66 68 protected: 67 69 68 void retranslateUi() /* override */; 70 virtual void retranslateUi() /* override */; 71 // virtual void focusInEvent(QFocusEvent *pEvent) /* override */; 72 // virtual void focusOutEvent(QFocusEvent *pEvent) /* override */; 69 73 70 74 private slots: … … 86 90 QProgressBar *m_pProgressBar; 87 91 QIToolButton *m_pCancelButton; 92 QILabel *m_pStatusLabel; 88 93 }; 89 94 … … 94 99 95 100 UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent /* = 0 */) 96 : QIWithRetranslateUI<Q Widget>(pParent)101 : QIWithRetranslateUI<QFrame>(pParent) 97 102 , m_comProgress(comProgress) 98 103 , m_pEventHandler(0) … … 100 105 , m_pProgressBar(0) 101 106 , m_pCancelButton(0) 107 , m_pStatusLabel(0) 102 108 { 103 109 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 105 115 } 106 116 … … 130 140 } 131 141 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 132 158 void UIFileOperationProgressWidget::prepare() 133 159 { … … 141 167 if (!m_pMainLayout) 142 168 return; 143 m_pMainLayout->setSpacing(0);169 //m_pMainLayout->setSpacing(0); 144 170 145 171 m_pCancelButton = new QIToolButton; … … 162 188 m_pProgressBar->setMaximum(100); 163 189 m_pProgressBar->setTextVisible(true); 164 m_pProgressBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);190 // m_pProgressBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); 165 191 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")); 166 198 } 167 199 setLayout(m_pMainLayout); … … 177 209 connect(m_pEventHandler, &UIProgressEventHandler::sigProgressTaskComplete, 178 210 this, &UIFileOperationProgressWidget::sltHandleProgressComplete); 211 m_pStatusLabel->setText(UIGuestControlFileManager::tr("Working")); 179 212 } 180 213 … … 190 223 Q_UNUSED(iPercent); 191 224 m_pProgressBar->setValue(iPercent); 225 192 226 } 193 227 … … 199 233 200 234 if (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0) 235 { 201 236 emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), FileManagerLogType_Error); 237 if (m_pStatusLabel) 238 m_pStatusLabel->setText(UIGuestControlFileManager::tr("Failed")); 239 } 202 240 else 241 { 203 242 emit sigProgressComplete(m_comProgress.GetId()); 243 if (m_pStatusLabel) 244 m_pStatusLabel->setText(UIGuestControlFileManager::tr("Succeeded")); 245 } 204 246 } 205 247 … … 210 252 if (m_pCancelButton) 211 253 m_pCancelButton->setEnabled(false); 254 if (m_pStatusLabel) 255 m_pStatusLabel->setText(UIGuestControlFileManager::tr("Canceled")); 256 if (m_pProgressBar) 257 m_pProgressBar->setEnabled(false); 212 258 } 213 259 … … 220 266 QWidget *pParent) 221 267 : UIGuestControlFileManagerPanel(pManagerWidget, pParent) 222 , m_pTableWidget(0) 268 , m_pScrollArea(0) 269 , m_pContainerWidget(0) 270 , m_pContainerLayout(0) 271 , m_pContainerSpaceItem(0) 223 272 { 224 273 prepare(); … … 227 276 void UIGuestControlFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress) 228 277 { 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 235 281 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 237 286 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressComplete, 238 287 this, &UIGuestControlFileManagerOperationsPanel::sigFileOperationComplete); 239 288 connect(pOperationsWidget, &UIFileOperationProgressWidget::sigProgressFail, 240 289 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();246 290 } 247 291 … … 255 299 if (!mainLayout()) 256 300 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); 268 317 } 269 318 … … 296 345 void UIGuestControlFileManagerOperationsPanel::sltCleanFinished() 297 346 { 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 // } 314 365 } 315 366 316 367 void UIGuestControlFileManagerOperationsPanel::sltCleanAll() 317 368 { 318 m_pTableWidget->clearContents();319 m_pTableWidget->setRowCount(0);369 //m_pListView->clear(); 370 //m_pListView->setRowCount(0); 320 371 } 321 372 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManagerOperationsPanel.h
r75732 r75788 28 28 /* Forward declarations: */ 29 29 class CProgress; 30 class QTableWidget; 30 class QScrollArea; 31 class QSpacerItem; 32 class QVBoxLayout; 33 34 class UIFileOperationModel; 31 35 class UIFileOperationProgressWidget; 32 36 class UIGuestControlFileManager; 33 37 34 38 35 /** UIVMLogViewerPanel extension hosting a Q TableWidget which in turn has a special QWidget extension39 /** UIVMLogViewerPanel extension hosting a QListWidget which in turn has a special QWidget extension 36 40 * to manage multiple CProgress instances. This is particulary used in monitoring file operations. */ 37 41 class UIGuestControlFileManagerOperationsPanel : public UIGuestControlFileManagerPanel … … 69 73 private: 70 74 71 enum TableColumn72 {73 TableColumn_Progress,74 TableColumn_Info,75 TableColumn_Max76 };77 78 75 /** @name Member variables. 79 76 * @{ */ 80 QTableWidget *m_pTableWidget; 77 QScrollArea *m_pScrollArea; 78 QWidget *m_pContainerWidget; 79 QVBoxLayout *m_pContainerLayout; 80 QSpacerItem *m_pContainerSpaceItem; 81 81 /** @} */ 82 83 82 84 83 85 };
Note:
See TracChangeset
for help on using the changeset viewer.