Changeset 78024 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 5, 2019 10:19:23 AM (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/UIFileManagerTable.cpp
r78010 r78024 83 83 84 84 UIFileManagerBreadCrumbs(QWidget *pParent = 0); 85 void setPath(const QString &strPath , bool fUnderlineLast = false);85 void setPath(const QString &strPath); 86 86 }; 87 87 … … 90 90 * UIFileManagerNavigationWidget definition. * 91 91 *********************************************************************************************************************************/ 92 92 /** UIFileManagerNavigationWidget contains a UIFileManagerBreadCrumbs, QComboBox for history and a QToolButton. 93 * basically it is a container for these mentioned widgets. */ 93 94 class UIFileManagerNavigationWidget : public QWidget 94 95 { … … 105 106 void reset(); 106 107 108 protected: 109 110 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 111 107 112 private slots: 108 113 … … 115 120 void prepare(); 116 121 117 QStackedWidget *m_pContainer;118 UIFileManagerBreadCrumbs *m_pBreadCrumbs;122 QStackedWidget *m_pContainer; 123 UIFileManagerBreadCrumbs *m_pBreadCrumbs; 119 124 UIFileManagerHistoryComboBox *m_pHistoryComboBox; 120 QToolButton *m_pSwitchButton; 125 QToolButton *m_pSwitchButton; 126 QString m_strPath; 121 127 }; 122 128 … … 238 244 :QWidget(pParent) 239 245 , m_pContainer(0) 246 , m_pBreadCrumbs(0) 247 , m_pHistoryComboBox(0) 240 248 , m_pSwitchButton(0) 241 249 { … … 245 253 void UIFileManagerNavigationWidget::setPath(const QString &strLocation) 246 254 { 255 m_strPath = strLocation; 256 247 257 if (m_pBreadCrumbs) 248 258 m_pBreadCrumbs->setPath(strLocation); … … 265 275 if (m_pHistoryComboBox) 266 276 { 267 /** @todo disconnect here. */ 277 disconnect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), 278 this, &UIFileManagerNavigationWidget::sigPathChanged); 268 279 m_pHistoryComboBox->clear(); 269 } 280 connect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), 281 this, &UIFileManagerNavigationWidget::sigPathChanged); 282 } 283 284 if (m_pBreadCrumbs) 285 m_pBreadCrumbs->setPath(QString()); 286 } 287 288 void UIFileManagerNavigationWidget::resizeEvent(QResizeEvent *pEvent) 289 { 290 if (m_pBreadCrumbs) 291 m_pBreadCrumbs->setPath(m_strPath); 292 293 QWidget::resizeEvent(pEvent); 270 294 } 271 295 … … 279 303 280 304 m_pContainer = new QStackedWidget; 281 282 305 if (m_pContainer) 283 306 { … … 285 308 m_pHistoryComboBox = new UIFileManagerHistoryComboBox; 286 309 287 connect(m_pBreadCrumbs, &UIFileManagerBreadCrumbs::linkActivated, 288 this, &UIFileManagerNavigationWidget::sigPathChanged); 289 290 connect(m_pHistoryComboBox, &UIFileManagerHistoryComboBox::sigHidePopup, 291 this, &UIFileManagerNavigationWidget::sltHandleHidePopup); 292 293 connect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), 294 this, &UIFileManagerNavigationWidget::sigPathChanged); 295 296 m_pContainer->addWidget(m_pBreadCrumbs); 297 m_pContainer->addWidget(m_pHistoryComboBox); 298 m_pContainer->setCurrentIndex(0); 299 310 if (m_pBreadCrumbs && m_pHistoryComboBox) 311 { 312 m_pBreadCrumbs->setIndent(0.5 * qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin)); 313 314 connect(m_pBreadCrumbs, &UIFileManagerBreadCrumbs::linkActivated, 315 this, &UIFileManagerNavigationWidget::sigPathChanged); 316 connect(m_pHistoryComboBox, &UIFileManagerHistoryComboBox::sigHidePopup, 317 this, &UIFileManagerNavigationWidget::sltHandleHidePopup); 318 connect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged), 319 this, &UIFileManagerNavigationWidget::sigPathChanged); 320 321 m_pContainer->addWidget(m_pBreadCrumbs); 322 m_pContainer->addWidget(m_pHistoryComboBox); 323 m_pContainer->setCurrentIndex(0); 324 } 300 325 pLayout->addWidget(m_pContainer); 301 326 } 302 327 303 328 m_pSwitchButton = new QToolButton; 304 305 329 if (m_pSwitchButton) 306 330 { … … 318 342 this, &UIFileManagerNavigationWidget::sltHandleSwitch); 319 343 } 320 321 344 setLayout(pLayout); 322 345 } … … 357 380 setFont(mFont); 358 381 359 } 360 361 void UIFileManagerBreadCrumbs::setPath(const QString &strPath, bool fUnderlineLast /* = false */) 382 setFrameShape(QFrame::Box); 383 setLineWidth(1); 384 //setFixedHeight(10); 385 setAutoFillBackground(true); 386 QPalette newPalette = palette(); 387 newPalette.setColor(QPalette::Background, qApp->palette().color(QPalette::Light)); 388 389 setPalette(newPalette); 390 } 391 392 void UIFileManagerBreadCrumbs::setPath(const QString &strPath) 362 393 { 363 394 const QChar separator('/'); … … 365 396 QStringList folderList = UIPathOperations::pathTrail(strPath); 366 397 folderList.push_front(separator); 398 367 399 QString strLabelText; 368 QString strPathUpto; 400 QVector<QString> strPathUpto; 401 strPathUpto.resize(folderList.size()); 402 369 403 for (int i = 0; i < folderList.size(); ++i) 370 404 { 371 405 QString strFolder = UIPathOperations::removeTrailingDelimiters(folderList.at(i)); 406 if (i != 0) 407 strPathUpto[i] = strPathUpto[i - 1]; 372 408 if (i == 0 || i == folderList.size() - 1) 373 strPathUpto .append(QString("%1").arg(strFolder));409 strPathUpto[i].append(QString("%1").arg(strFolder)); 374 410 else 375 strPathUpto.append(QString("%1%2").arg(strFolder).arg(separator)); 376 if (fUnderlineLast && i == folderList.size() - 1) 377 strLabelText.append(QString("<a href=\"%1\" style=\"color:black;text-decoration:underline;\">%2</a>").arg(strPathUpto).arg(strFolder)); 378 else 379 strLabelText.append(QString("<a href=\"%1\" style=\"color:black;text-decoration:none;\">%2</a>").arg(strPathUpto).arg(strFolder)); 411 strPathUpto[i].append(QString("%1%2").arg(strFolder).arg(separator)); 412 } 413 414 int iWidth = 0; 415 for (int i = folderList.size() - 1; i >= 0; --i) 416 { 417 QString strFolder = UIPathOperations::removeTrailingDelimiters(folderList.at(i)); 418 QString strWord = QString("<a href=\"%1\" style=\"color:black;text-decoration:none;\">%2</a>").arg(strPathUpto[i]).arg(strFolder); 419 380 420 if (i < folderList.size() - 1) 381 strLabelText.append("<b> > </b>"); 421 { 422 iWidth += fontMetrics().width(" > "); 423 strWord.append("<b> > </b>"); 424 } 425 iWidth += fontMetrics().width(strFolder); 426 427 if (iWidth < width()) 428 strLabelText.prepend(strWord); 429 382 430 } 383 431 setText(strLabelText); 384 385 432 } 386 433 … … 612 659 *********************************************************************************************************************************/ 613 660 const unsigned UIFileManagerTable::m_iKiloByte = 1024; /**< Our kilo bytes are a power of two! (bird) */ 661 614 662 UIFileManagerTable::UIFileManagerTable(UIActionPool *pActionPool, QWidget *pParent /* = 0 */) 615 663 :QIWithRetranslateUI<QWidget>(pParent) … … 659 707 if (m_pToolBar) 660 708 { 661 m_pMainLayout->addWidget(m_pToolBar, 0, 0, 1, 5);709 m_pMainLayout->addWidget(m_pToolBar, 0, 0, 1, 7); 662 710 } 663 711 664 712 m_pLocationLabel = new QILabel; 665 713 if (m_pLocationLabel) 666 {667 714 m_pMainLayout->addWidget(m_pLocationLabel, 1, 0, 1, 1); 668 }669 715 670 716 m_pNavigationWidget = new UIFileManagerNavigationWidget; 671 717 if (m_pNavigationWidget) 672 718 { 673 m_pNavigationWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy:: Fixed);719 m_pNavigationWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); 674 720 connect(m_pNavigationWidget, &UIFileManagerNavigationWidget::sigPathChanged, 675 721 this, &UIFileManagerTable::sltHandleNavigationWidgetPathChange); 676 m_pMainLayout->addWidget(m_pNavigationWidget, 1, 1, 1, 4);722 m_pMainLayout->addWidget(m_pNavigationWidget, 1, 1, 1, 6); 677 723 } 678 724 … … 691 737 if (m_pView) 692 738 { 693 m_pMainLayout->addWidget(m_pView, 2, 0, 5, 5);739 m_pMainLayout->addWidget(m_pView, 2, 0, 5, 7); 694 740 695 741 QHeaderView *pHorizontalHeader = m_pView->horizontalHeader(); … … 719 765 if (m_pWarningLabel) 720 766 { 721 m_pMainLayout->addWidget(m_pWarningLabel, 2, 0, 5, 5);767 m_pMainLayout->addWidget(m_pWarningLabel, 2, 0, 5, 7); 722 768 QFont labelFont = m_pWarningLabel->font(); 723 769 float fSizeMultiplier = 1.5f; … … 737 783 if (m_pSearchLineEdit) 738 784 { 739 m_pMainLayout->addWidget(m_pSearchLineEdit, 8, 0, 1, 5);785 m_pMainLayout->addWidget(m_pSearchLineEdit, 8, 0, 1, 7); 740 786 m_pSearchLineEdit->hide(); 741 787 m_pSearchLineEdit->setClearButtonEnabled(true); -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r78010 r78024 239 239 UIActionPool *m_pActionPool; 240 240 UIToolBar *m_pToolBar; 241 242 241 /** Stores the drive letters the file system has (for windows system). For non-windows 243 242 * systems this is empty and for windows system it should at least contain C:/ */
Note:
See TracChangeset
for help on using the changeset viewer.