Changeset 85643 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 7, 2020 11:47:45 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r82968 r85643 41 41 src/settings/machine/UIMachineSettingsUSB.ui \ 42 42 src/settings/machine/UIMachineSettingsUSBFilterDetails.ui \ 43 src/settings/machine/UIMachineSettingsSF.ui \44 43 src/settings/machine/UIMachineSettingsSFDetails.ui \ 45 44 src/settings/machine/UIMachineSettingsInterface.ui -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp
r82968 r85643 22 22 23 23 /* GUI includes: */ 24 #include "QILabelSeparator.h" 25 #include "QITreeWidget.h" 26 #include "UICommon.h" 27 #include "UIErrorString.h" 24 28 #include "UIIconPool.h" 25 29 #include "UIMachineSettingsSF.h" 26 30 #include "UIMachineSettingsSFDetails.h" 27 #include "UIErrorString.h" 28 #include "UICommon.h" 31 #include "UIToolBar.h" 29 32 #include "VBoxUtils.h" 30 33 … … 277 280 : m_pActionAdd(0), m_pActionEdit(0), m_pActionRemove(0) 278 281 , m_pCache(0) 282 , m_pFoldersTreeWidget(0) 283 , m_pNameSeparator(0) 284 , m_pFoldersToolBar(0) 279 285 { 280 286 /* Prepare: */ … … 356 362 { 357 363 /* Clear list initially: */ 358 m TwFolders->clear();364 m_pFoldersTreeWidget->clear(); 359 365 360 366 /* Update root items visibility: */ … … 366 372 367 373 /* Choose first folder as current: */ 368 m TwFolders->setCurrentItem(mTwFolders->topLevelItem(0));369 sltHandleCurrentItemChange(m TwFolders->currentItem());374 m_pFoldersTreeWidget->setCurrentItem(m_pFoldersTreeWidget->topLevelItem(0)); 375 sltHandleCurrentItemChange(m_pFoldersTreeWidget->currentItem()); 370 376 371 377 /* Polish page finally: */ … … 379 385 380 386 /* For each folder type: */ 381 QTreeWidgetItem *pMainRootItem = m TwFolders->invisibleRootItem();387 QTreeWidgetItem *pMainRootItem = m_pFoldersTreeWidget->invisibleRootItem(); 382 388 for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex) 383 389 { … … 410 416 } 411 417 418 412 419 void UIMachineSettingsSF::retranslateUi() 413 420 { 414 /* Translate uic generated strings: */ 415 Ui::UIMachineSettingsSF::retranslateUi(this); 421 m_pNameSeparator->setText(tr("Shared &Folders")); 422 QTreeWidgetItem *pQTreeWidgetItem = m_pFoldersTreeWidget->headerItem(); 423 pQTreeWidgetItem->setText(4, tr("At")); 424 pQTreeWidgetItem->setText(3, tr("Auto Mount")); 425 pQTreeWidgetItem->setText(2, tr("Access")); 426 pQTreeWidgetItem->setText(1, tr("Path")); 427 pQTreeWidgetItem->setText(0, tr("Name")); 428 #ifndef QT_NO_WHATSTHIS 429 m_pFoldersTreeWidget->setWhatsThis(tr("Lists all shared folders accessible to this machine. Use 'net use x: \\\\vboxsvr\\share' to access a shared folder named <i>share</i> from a DOS-like OS, or 'mount -t vboxsf share mount_point' to access it from a Linux OS. This feature requires Guest Additions.")); 430 #endif // QT_NO_WHATSTHIS 431 416 432 417 433 m_pActionAdd->setText(tr("Add Shared Folder")); … … 431 447 { 432 448 /* Polish shared folders page availability: */ 433 m NameSeparator->setEnabled(isMachineInValidMode());449 m_pNameSeparator->setEnabled(isMachineInValidMode()); 434 450 m_pFoldersToolBar->setEnabled(isMachineInValidMode()); 435 451 m_pFoldersToolBar->setEnabled(isMachineInValidMode()); … … 445 461 446 462 /* Connect header-resize signal just before widget is shown after all the items properly loaded and initialized: */ 447 connect(m TwFolders->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields);463 connect(m_pFoldersTreeWidget->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields); 448 464 449 465 /* Adjusting size after all pending show events are processed: */ … … 486 502 487 503 /* Sort tree-widget before adjusting: */ 488 m TwFolders->sortItems(0, Qt::AscendingOrder);504 m_pFoldersTreeWidget->sortItems(0, Qt::AscendingOrder); 489 505 /* Adjust tree-widget finally: */ 490 506 sltAdjustTree(); … … 495 511 { 496 512 /* Check current folder item: */ 497 SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m TwFolders->currentItem());513 SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m_pFoldersTreeWidget->currentItem()); 498 514 AssertPtrReturnVoid(pItem); 499 515 AssertPtrReturnVoid(pItem->parentItem()); … … 538 554 539 555 /* Update tree-widget: */ 540 m TwFolders->scrollToItem(pItem);541 m TwFolders->setCurrentItem(pItem);556 m_pFoldersTreeWidget->scrollToItem(pItem); 557 m_pFoldersTreeWidget->setCurrentItem(pItem); 542 558 sltHandleCurrentItemChange(pItem); 543 559 } 544 560 545 561 /* Sort tree-widget before adjusting: */ 546 m TwFolders->sortItems(0, Qt::AscendingOrder);562 m_pFoldersTreeWidget->sortItems(0, Qt::AscendingOrder); 547 563 /* Adjust tree-widget finally: */ 548 564 sltAdjustTree(); … … 553 569 { 554 570 /* Check current folder item: */ 555 QTreeWidgetItem *pItem = m TwFolders->currentItem();571 QTreeWidgetItem *pItem = m_pFoldersTreeWidget->currentItem(); 556 572 AssertPtrReturnVoid(pItem); 557 573 … … 584 600 { 585 601 QMenu menu; 586 QTreeWidgetItem *pItem = m TwFolders->itemAt(position);587 if (m TwFolders->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable)602 QTreeWidgetItem *pItem = m_pFoldersTreeWidget->itemAt(position); 603 if (m_pFoldersTreeWidget->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable) 588 604 { 589 605 menu.addAction(m_pActionEdit); … … 595 611 } 596 612 if (!menu.isEmpty()) 597 menu.exec(m TwFolders->viewport()->mapToGlobal(position));613 menu.exec(m_pFoldersTreeWidget->viewport()->mapToGlobal(position)); 598 614 } 599 615 … … 611 627 * 4 = Auto mount point 612 628 */ 613 QAbstractItemView *pItemView = m TwFolders;614 QHeaderView *pItemHeader = m TwFolders->header();615 const int iTotal = m TwFolders->viewport()->width();629 QAbstractItemView *pItemView = m_pFoldersTreeWidget; 630 QHeaderView *pItemHeader = m_pFoldersTreeWidget->header(); 631 const int iTotal = m_pFoldersTreeWidget->viewport()->width(); 616 632 617 633 const int mw0 = qMax(pItemView->sizeHintForColumn(0), pItemHeader->sectionSizeHint(0)); … … 651 667 } 652 668 #endif 653 m TwFolders->setColumnWidth(0, w0);654 m TwFolders->setColumnWidth(1, w1);655 m TwFolders->setColumnWidth(2, w2);656 m TwFolders->setColumnWidth(3, w3);657 m TwFolders->setColumnWidth(4, w4);669 m_pFoldersTreeWidget->setColumnWidth(0, w0); 670 m_pFoldersTreeWidget->setColumnWidth(1, w1); 671 m_pFoldersTreeWidget->setColumnWidth(2, w2); 672 m_pFoldersTreeWidget->setColumnWidth(3, w3); 673 m_pFoldersTreeWidget->setColumnWidth(4, w4); 658 674 } 659 675 660 676 void UIMachineSettingsSF::sltAdjustTreeFields() 661 677 { 662 QTreeWidgetItem *pMainRoot = m TwFolders->invisibleRootItem();678 QTreeWidgetItem *pMainRoot = m_pFoldersTreeWidget->invisibleRootItem(); 663 679 for (int i = 0; i < pMainRoot->childCount(); ++i) 664 680 { … … 673 689 } 674 690 691 void UIMachineSettingsSF::prepareWidgets() 692 { 693 if (objectName().isEmpty()) 694 setObjectName(QStringLiteral("UIMachineSettingsSF")); 695 resize(300, 228); 696 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 697 pMainLayout->setObjectName(QStringLiteral("pMainLayout")); 698 pMainLayout->setContentsMargins(0, 0, 0, 0); 699 m_pNameSeparator = new QILabelSeparator(this); 700 m_pNameSeparator->setObjectName(QStringLiteral("m_pNameSeparator")); 701 702 pMainLayout->addWidget(m_pNameSeparator); 703 704 QWidget *m_pFoldersTreeWidgetContainer = new QWidget(this); 705 m_pFoldersTreeWidgetContainer->setObjectName(QStringLiteral("m_pFoldersTreeWidgetContainer")); 706 QHBoxLayout *pFoldersLayout = new QHBoxLayout(m_pFoldersTreeWidgetContainer); 707 pFoldersLayout->setSpacing(3); 708 pFoldersLayout->setObjectName(QStringLiteral("pFoldersLayout")); 709 pFoldersLayout->setContentsMargins(0, 0, 0, 0); 710 m_pFoldersTreeWidget = new QITreeWidget(m_pFoldersTreeWidgetContainer); 711 m_pFoldersTreeWidget->setObjectName(QStringLiteral("m_pFoldersTreeWidget")); 712 m_pFoldersTreeWidget->setMinimumSize(QSize(0, 200)); 713 m_pFoldersTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); 714 m_pFoldersTreeWidget->setUniformRowHeights(true); 715 m_pFoldersTreeWidget->setAllColumnsShowFocus(true); 716 717 pFoldersLayout->addWidget(m_pFoldersTreeWidget); 718 719 m_pFoldersToolBar = new UIToolBar(m_pFoldersTreeWidgetContainer); 720 m_pFoldersToolBar->setObjectName(QStringLiteral("m_pFoldersToolBar")); 721 722 pFoldersLayout->addWidget(m_pFoldersToolBar); 723 pMainLayout->addWidget(m_pFoldersTreeWidgetContainer); 724 m_pNameSeparator->setBuddy(m_pFoldersTreeWidget); 725 } 726 675 727 void UIMachineSettingsSF::prepare() 676 728 { 677 /* Apply UI decorations: */ 678 Ui::UIMachineSettingsSF::setupUi(this); 729 prepareWidgets(); 679 730 680 731 /* Prepare cache: */ … … 699 750 { 700 751 /* Shared Folders tree-widget created in the .ui file. */ 701 AssertPtrReturnVoid(m TwFolders);752 AssertPtrReturnVoid(m_pFoldersTreeWidget); 702 753 { 703 754 /* Configure tree-widget: */ 704 m TwFolders->header()->setSectionsMovable(false);755 m_pFoldersTreeWidget->header()->setSectionsMovable(false); 705 756 } 706 757 } … … 751 802 { 752 803 /* Configure tree-widget connections: */ 753 connect(m TwFolders, &QITreeWidget::currentItemChanged,804 connect(m_pFoldersTreeWidget, &QITreeWidget::currentItemChanged, 754 805 this, &UIMachineSettingsSF::sltHandleCurrentItemChange); 755 connect(m TwFolders, &QITreeWidget::itemDoubleClicked,806 connect(m_pFoldersTreeWidget, &QITreeWidget::itemDoubleClicked, 756 807 this, &UIMachineSettingsSF::sltHandleDoubleClick); 757 connect(m TwFolders, &QITreeWidget::customContextMenuRequested,808 connect(m_pFoldersTreeWidget, &QITreeWidget::customContextMenuRequested, 758 809 this, &UIMachineSettingsSF::sltHandleContextMenuRequest); 759 810 } … … 770 821 /* Search for the corresponding root item among all the top-level items: */ 771 822 SFTreeViewItem *pRootItem = 0; 772 QTreeWidgetItem *pMainRootItem = m TwFolders->invisibleRootItem();823 QTreeWidgetItem *pMainRootItem = m_pFoldersTreeWidget->invisibleRootItem(); 773 824 for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex) 774 825 { … … 792 843 /* Make the used names list: */ 793 844 QStringList list; 794 QTreeWidgetItemIterator it(m TwFolders);845 QTreeWidgetItemIterator it(m_pFoldersTreeWidget); 795 846 while (*it) 796 847 { … … 835 886 { 836 887 /* Create new shared folder type item: */ 837 pRootItem = new SFTreeViewItem(m TwFolders, SFTreeViewItem::FormatType_EllipsisEnd);888 pRootItem = new SFTreeViewItem(m_pFoldersTreeWidget, SFTreeViewItem::FormatType_EllipsisEnd); 838 889 AssertPtrReturnVoid(pRootItem); 839 890 { … … 873 924 if (fChoose) 874 925 { 875 m TwFolders->scrollToItem(pItem);876 m TwFolders->setCurrentItem(pItem);926 m_pFoldersTreeWidget->scrollToItem(pItem); 927 m_pFoldersTreeWidget->setCurrentItem(pItem); 877 928 sltHandleCurrentItemChange(pItem); 878 929 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h
r82968 r85643 24 24 /* GUI includes: */ 25 25 #include "UISettingsPage.h" 26 #include "UIMachineSettingsSF.gen.h"27 26 28 27 /* COM includes: */ … … 30 29 31 30 /* Forward declarations: */ 31 class QTreeWidgetItem; 32 class QITreeWidget; 33 class QILabelSeparator; 32 34 class SFTreeViewItem; 35 class UIToolBar; 36 33 37 struct UIDataSettingsSharedFolder; 34 38 struct UIDataSettingsSharedFolders; … … 37 41 typedef UISettingsCachePool<UIDataSettingsSharedFolders, UISettingsCacheSharedFolder> UISettingsCacheSharedFolders; 38 42 43 39 44 /** Machine settings: Shared Folders page. */ 40 class SHARED_LIBRARY_STUFF UIMachineSettingsSF : public UISettingsPageMachine, 41 public Ui::UIMachineSettingsSF 45 class SHARED_LIBRARY_STUFF UIMachineSettingsSF : public UISettingsPageMachine 42 46 { 43 47 Q_OBJECT; … … 106 110 /** Prepares all. */ 107 111 void prepare(); 112 /** Prepares Widgets. */ 113 void prepareWidgets(); 108 114 /** Prepares shared folders tree. */ 109 115 void prepareFoldersTree(); … … 153 159 /** Holds the page data cache instance. */ 154 160 UISettingsCacheSharedFolders *m_pCache; 161 162 /** @name Widgets 163 * @{ */ 164 QITreeWidget *m_pFoldersTreeWidget; 165 QILabelSeparator *m_pNameSeparator; 166 UIToolBar *m_pFoldersToolBar; 167 /** @} */ 155 168 }; 156 169
Note:
See TracChangeset
for help on using the changeset viewer.