Changeset 85959 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 31, 2020 2:50:13 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp
r85645 r85959 279 279 280 280 UIMachineSettingsSF::UIMachineSettingsSF() 281 : m_pActionAdd(0), m_pActionEdit(0), m_pActionRemove(0) 282 , m_pCache(0) 283 , m_pFoldersTreeWidget(0) 284 , m_pNameSeparator(0) 285 , m_pFoldersToolBar(0) 286 { 287 /* Prepare: */ 281 : m_pCache(0) 282 , m_pLabelSeparator(0) 283 , m_pLayoutTree(0) 284 , m_pTreeWidget(0) 285 , m_pToolBar(0) 286 , m_pActionAdd(0) 287 , m_pActionEdit(0) 288 , m_pActionRemove(0) 289 { 288 290 prepare(); 289 291 } … … 363 365 { 364 366 /* Clear list initially: */ 365 m_p FoldersTreeWidget->clear();367 m_pTreeWidget->clear(); 366 368 367 369 /* Update root items visibility: */ … … 373 375 374 376 /* Choose first folder as current: */ 375 m_p FoldersTreeWidget->setCurrentItem(m_pFoldersTreeWidget->topLevelItem(0));376 sltHandleCurrentItemChange(m_p FoldersTreeWidget->currentItem());377 m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0)); 378 sltHandleCurrentItemChange(m_pTreeWidget->currentItem()); 377 379 378 380 /* Polish page finally: */ … … 386 388 387 389 /* For each folder type: */ 388 QTreeWidgetItem *pMainRootItem = m_p FoldersTreeWidget->invisibleRootItem();390 QTreeWidgetItem *pMainRootItem = m_pTreeWidget->invisibleRootItem(); 389 391 for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex) 390 392 { … … 417 419 } 418 420 419 420 421 void UIMachineSettingsSF::retranslateUi() 421 422 { 422 m_p NameSeparator->setText(tr("Shared &Folders"));423 QTreeWidgetItem *pQTreeWidgetItem = m_p FoldersTreeWidget->headerItem();423 m_pLabelSeparator->setText(tr("Shared &Folders")); 424 QTreeWidgetItem *pQTreeWidgetItem = m_pTreeWidget->headerItem(); 424 425 pQTreeWidgetItem->setText(4, tr("At")); 425 426 pQTreeWidgetItem->setText(3, tr("Auto Mount")); … … 428 429 pQTreeWidgetItem->setText(0, tr("Name")); 429 430 #ifndef QT_NO_WHATSTHIS 430 m_p FoldersTreeWidget->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."));431 m_pTreeWidget->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.")); 431 432 #endif // QT_NO_WHATSTHIS 432 433 … … 448 449 { 449 450 /* Polish shared folders page availability: */ 450 m_p NameSeparator->setEnabled(isMachineInValidMode());451 m_p FoldersToolBar->setEnabled(isMachineInValidMode());452 m_p FoldersToolBar->setEnabled(isMachineInValidMode());451 m_pLabelSeparator->setEnabled(isMachineInValidMode()); 452 m_pToolBar->setEnabled(isMachineInValidMode()); 453 m_pToolBar->setEnabled(isMachineInValidMode()); 453 454 454 455 /* Update root items visibility: */ … … 462 463 463 464 /* Connect header-resize signal just before widget is shown after all the items properly loaded and initialized: */ 464 connect(m_p FoldersTreeWidget->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields);465 connect(m_pTreeWidget->header(), &QHeaderView::sectionResized, this, &UIMachineSettingsSF::sltAdjustTreeFields); 465 466 466 467 /* Adjusting size after all pending show events are processed: */ … … 503 504 504 505 /* Sort tree-widget before adjusting: */ 505 m_p FoldersTreeWidget->sortItems(0, Qt::AscendingOrder);506 m_pTreeWidget->sortItems(0, Qt::AscendingOrder); 506 507 /* Adjust tree-widget finally: */ 507 508 sltAdjustTree(); … … 512 513 { 513 514 /* Check current folder item: */ 514 SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m_p FoldersTreeWidget->currentItem());515 SFTreeViewItem *pItem = static_cast<SFTreeViewItem*>(m_pTreeWidget->currentItem()); 515 516 AssertPtrReturnVoid(pItem); 516 517 AssertPtrReturnVoid(pItem->parentItem()); … … 555 556 556 557 /* Update tree-widget: */ 557 m_p FoldersTreeWidget->scrollToItem(pItem);558 m_p FoldersTreeWidget->setCurrentItem(pItem);558 m_pTreeWidget->scrollToItem(pItem); 559 m_pTreeWidget->setCurrentItem(pItem); 559 560 sltHandleCurrentItemChange(pItem); 560 561 } 561 562 562 563 /* Sort tree-widget before adjusting: */ 563 m_p FoldersTreeWidget->sortItems(0, Qt::AscendingOrder);564 m_pTreeWidget->sortItems(0, Qt::AscendingOrder); 564 565 /* Adjust tree-widget finally: */ 565 566 sltAdjustTree(); … … 570 571 { 571 572 /* Check current folder item: */ 572 QTreeWidgetItem *pItem = m_p FoldersTreeWidget->currentItem();573 QTreeWidgetItem *pItem = m_pTreeWidget->currentItem(); 573 574 AssertPtrReturnVoid(pItem); 574 575 … … 601 602 { 602 603 QMenu menu; 603 QTreeWidgetItem *pItem = m_p FoldersTreeWidget->itemAt(position);604 if (m_p FoldersTreeWidget->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable)604 QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(position); 605 if (m_pTreeWidget->isEnabled() && pItem && pItem->flags() & Qt::ItemIsSelectable) 605 606 { 606 607 menu.addAction(m_pActionEdit); … … 612 613 } 613 614 if (!menu.isEmpty()) 614 menu.exec(m_p FoldersTreeWidget->viewport()->mapToGlobal(position));615 menu.exec(m_pTreeWidget->viewport()->mapToGlobal(position)); 615 616 } 616 617 … … 628 629 * 4 = Auto mount point 629 630 */ 630 QAbstractItemView *pItemView = m_p FoldersTreeWidget;631 QHeaderView *pItemHeader = m_p FoldersTreeWidget->header();632 const int iTotal = m_p FoldersTreeWidget->viewport()->width();631 QAbstractItemView *pItemView = m_pTreeWidget; 632 QHeaderView *pItemHeader = m_pTreeWidget->header(); 633 const int iTotal = m_pTreeWidget->viewport()->width(); 633 634 634 635 const int mw0 = qMax(pItemView->sizeHintForColumn(0), pItemHeader->sectionSizeHint(0)); … … 668 669 } 669 670 #endif 670 m_p FoldersTreeWidget->setColumnWidth(0, w0);671 m_p FoldersTreeWidget->setColumnWidth(1, w1);672 m_p FoldersTreeWidget->setColumnWidth(2, w2);673 m_p FoldersTreeWidget->setColumnWidth(3, w3);674 m_p FoldersTreeWidget->setColumnWidth(4, w4);671 m_pTreeWidget->setColumnWidth(0, w0); 672 m_pTreeWidget->setColumnWidth(1, w1); 673 m_pTreeWidget->setColumnWidth(2, w2); 674 m_pTreeWidget->setColumnWidth(3, w3); 675 m_pTreeWidget->setColumnWidth(4, w4); 675 676 } 676 677 677 678 void UIMachineSettingsSF::sltAdjustTreeFields() 678 679 { 679 QTreeWidgetItem *pMainRoot = m_p FoldersTreeWidget->invisibleRootItem();680 QTreeWidgetItem *pMainRoot = m_pTreeWidget->invisibleRootItem(); 680 681 for (int i = 0; i < pMainRoot->childCount(); ++i) 681 682 { … … 690 691 } 691 692 692 void UIMachineSettingsSF::prepareWidgets()693 {694 if (objectName().isEmpty())695 setObjectName(QStringLiteral("UIMachineSettingsSF"));696 resize(300, 220);697 QVBoxLayout *pMainLayout = new QVBoxLayout(this);698 pMainLayout->setObjectName(QStringLiteral("pMainLayout"));699 pMainLayout->setContentsMargins(0, 0, 0, 0);700 m_pNameSeparator = new QILabelSeparator(this);701 m_pNameSeparator->setObjectName(QStringLiteral("m_pNameSeparator"));702 703 pMainLayout->addWidget(m_pNameSeparator);704 705 QWidget *m_pFoldersTreeWidgetContainer = new QWidget(this);706 m_pFoldersTreeWidgetContainer->setObjectName(QStringLiteral("m_pFoldersTreeWidgetContainer"));707 QHBoxLayout *pFoldersLayout = new QHBoxLayout(m_pFoldersTreeWidgetContainer);708 pFoldersLayout->setSpacing(3);709 pFoldersLayout->setObjectName(QStringLiteral("pFoldersLayout"));710 pFoldersLayout->setContentsMargins(0, 0, 0, 0);711 m_pFoldersTreeWidget = new QITreeWidget(m_pFoldersTreeWidgetContainer);712 m_pFoldersTreeWidget->setObjectName(QStringLiteral("m_pFoldersTreeWidget"));713 m_pFoldersTreeWidget->setMinimumSize(QSize(0, 200));714 m_pFoldersTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);715 m_pFoldersTreeWidget->setUniformRowHeights(true);716 m_pFoldersTreeWidget->setAllColumnsShowFocus(true);717 718 pFoldersLayout->addWidget(m_pFoldersTreeWidget);719 720 m_pFoldersToolBar = new UIToolBar(m_pFoldersTreeWidgetContainer);721 m_pFoldersToolBar->setObjectName(QStringLiteral("m_pFoldersToolBar"));722 723 pFoldersLayout->addWidget(m_pFoldersToolBar);724 pMainLayout->addWidget(m_pFoldersTreeWidgetContainer);725 m_pNameSeparator->setBuddy(m_pFoldersTreeWidget);726 }727 728 693 void UIMachineSettingsSF::prepare() 729 694 { 730 prepareWidgets();731 732 695 /* Prepare cache: */ 733 696 m_pCache = new UISettingsCacheSharedFolders; 734 697 AssertPtrReturnVoid(m_pCache); 735 698 736 /* Layout created in the .ui file. */ 737 { 738 /* Prepare shared folders tree: */ 739 prepareFoldersTree(); 740 /* Prepare shared folders toolbar: */ 741 prepareFoldersToolbar(); 742 /* Prepare connections: */ 743 prepareConnections(); 744 } 699 /* Prepare everything: */ 700 prepareWidgets(); 701 prepareConnections(); 745 702 746 703 /* Apply language settings: */ … … 748 705 } 749 706 750 void UIMachineSettingsSF::prepareFoldersTree() 751 { 752 /* Shared Folders tree-widget created in the .ui file. */ 753 AssertPtrReturnVoid(m_pFoldersTreeWidget); 754 { 755 /* Configure tree-widget: */ 756 m_pFoldersTreeWidget->header()->setSectionsMovable(false); 757 } 758 } 759 760 void UIMachineSettingsSF::prepareFoldersToolbar() 761 { 762 /* Shared Folders toolbar created in the .ui file. */ 763 AssertPtrReturnVoid(m_pFoldersToolBar); 764 { 765 /* Configure toolbar: */ 707 void UIMachineSettingsSF::prepareWidgets() 708 { 709 /* Prepare main layout: */ 710 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 711 if (pLayoutMain) 712 { 713 pLayoutMain->setContentsMargins(0, 0, 0, 0); 714 715 /* Prepare separator: */ 716 m_pLabelSeparator = new QILabelSeparator(this); 717 if (m_pLabelSeparator) 718 pLayoutMain->addWidget(m_pLabelSeparator); 719 720 /* Prepare view layout: */ 721 m_pLayoutTree = new QHBoxLayout; 722 if (m_pLayoutTree) 723 { 724 m_pLayoutTree->setContentsMargins(0, 0, 0, 0); 725 m_pLayoutTree->setSpacing(3); 726 727 /* Prepare tree-widget: */ 728 prepareTreeWidget(); 729 /* Prepare toolbar: */ 730 prepareToolbar(); 731 732 pLayoutMain->addLayout(m_pLayoutTree); 733 } 734 } 735 } 736 737 void UIMachineSettingsSF::prepareTreeWidget() 738 { 739 /* Prepare shared folders tree-widget: */ 740 m_pTreeWidget = new QITreeWidget(this); 741 if (m_pTreeWidget) 742 { 743 if (m_pLabelSeparator) 744 m_pLabelSeparator->setBuddy(m_pTreeWidget); 745 m_pTreeWidget->header()->setSectionsMovable(false); 746 m_pTreeWidget->setMinimumSize(QSize(0, 200)); 747 m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); 748 m_pTreeWidget->setUniformRowHeights(true); 749 m_pTreeWidget->setAllColumnsShowFocus(true); 750 751 m_pLayoutTree->addWidget(m_pTreeWidget); 752 } 753 } 754 755 void UIMachineSettingsSF::prepareToolbar() 756 { 757 /* Prepare shared folders toolbar: */ 758 m_pToolBar = new UIToolBar(this); 759 if (m_pToolBar) 760 { 766 761 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 767 m_p FoldersToolBar->setIconSize(QSize(iIconMetric, iIconMetric));768 m_p FoldersToolBar->setOrientation(Qt::Vertical);769 770 /* Create 'Add Shared Folder' action: */771 m_pActionAdd = m_p FoldersToolBar->addAction(UIIconPool::iconSet(":/sf_add_16px.png",762 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 763 m_pToolBar->setOrientation(Qt::Vertical); 764 765 /* Prepare 'Add Shared Folder' action: */ 766 m_pActionAdd = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_add_16px.png", 772 767 ":/sf_add_disabled_16px.png"), 773 768 QString(), this, SLOT(sltAddFolder())); 774 AssertPtrReturnVoid(m_pActionAdd); 775 { 776 /* Configure action: */ 769 if (m_pActionAdd) 777 770 m_pActionAdd->setShortcuts(QList<QKeySequence>() << QKeySequence("Ins") << QKeySequence("Ctrl+N")); 778 } 779 780 /* Create 'Edit Shared Folder' action: */ 781 m_pActionEdit = m_pFoldersToolBar->addAction(UIIconPool::iconSet(":/sf_edit_16px.png", 771 772 /* Prepare 'Edit Shared Folder' action: */ 773 m_pActionEdit = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_edit_16px.png", 782 774 ":/sf_edit_disabled_16px.png"), 783 775 QString(), this, SLOT(sltEditFolder())); 784 AssertPtrReturnVoid(m_pActionEdit); 785 { 786 /* Configure action: */ 776 if (m_pActionEdit) 787 777 m_pActionEdit->setShortcuts(QList<QKeySequence>() << QKeySequence("Space") << QKeySequence("F2")); 788 } 789 790 /* Create 'Remove Shared Folder' action: */ 791 m_pActionRemove = m_pFoldersToolBar->addAction(UIIconPool::iconSet(":/sf_remove_16px.png", 778 779 /* Prepare 'Remove Shared Folder' action: */ 780 m_pActionRemove = m_pToolBar->addAction(UIIconPool::iconSet(":/sf_remove_16px.png", 792 781 ":/sf_remove_disabled_16px.png"), 793 782 QString(), this, SLOT(sltRemoveFolder())); 794 AssertPtrReturnVoid(m_pActionRemove); 795 { 796 /* Configure action: */ 783 if (m_pActionRemove) 797 784 m_pActionRemove->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Ctrl+R")); 798 } 785 786 m_pLayoutTree->addWidget(m_pToolBar); 799 787 } 800 788 } … … 803 791 { 804 792 /* Configure tree-widget connections: */ 805 connect(m_p FoldersTreeWidget, &QITreeWidget::currentItemChanged,793 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 806 794 this, &UIMachineSettingsSF::sltHandleCurrentItemChange); 807 connect(m_p FoldersTreeWidget, &QITreeWidget::itemDoubleClicked,795 connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked, 808 796 this, &UIMachineSettingsSF::sltHandleDoubleClick); 809 connect(m_p FoldersTreeWidget, &QITreeWidget::customContextMenuRequested,797 connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested, 810 798 this, &UIMachineSettingsSF::sltHandleContextMenuRequest); 811 799 } … … 822 810 /* Search for the corresponding root item among all the top-level items: */ 823 811 SFTreeViewItem *pRootItem = 0; 824 QTreeWidgetItem *pMainRootItem = m_p FoldersTreeWidget->invisibleRootItem();812 QTreeWidgetItem *pMainRootItem = m_pTreeWidget->invisibleRootItem(); 825 813 for (int iFolderTypeIndex = 0; iFolderTypeIndex < pMainRootItem->childCount(); ++iFolderTypeIndex) 826 814 { … … 844 832 /* Make the used names list: */ 845 833 QStringList list; 846 QTreeWidgetItemIterator it(m_p FoldersTreeWidget);834 QTreeWidgetItemIterator it(m_pTreeWidget); 847 835 while (*it) 848 836 { … … 887 875 { 888 876 /* Create new shared folder type item: */ 889 pRootItem = new SFTreeViewItem(m_p FoldersTreeWidget, SFTreeViewItem::FormatType_EllipsisEnd);877 pRootItem = new SFTreeViewItem(m_pTreeWidget, SFTreeViewItem::FormatType_EllipsisEnd); 890 878 AssertPtrReturnVoid(pRootItem); 891 879 { … … 925 913 if (fChoose) 926 914 { 927 m_p FoldersTreeWidget->scrollToItem(pItem);928 m_p FoldersTreeWidget->setCurrentItem(pItem);915 m_pTreeWidget->scrollToItem(pItem); 916 m_pTreeWidget->setCurrentItem(pItem); 929 917 sltHandleCurrentItemChange(pItem); 930 918 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.h
r85643 r85959 29 29 30 30 /* Forward declarations: */ 31 class QHBoxLayout; 31 32 class QTreeWidgetItem; 32 33 class QITreeWidget; … … 112 113 /** Prepares Widgets. */ 113 114 void prepareWidgets(); 114 /** Prepares shared folders tree . */115 void prepare FoldersTree();115 /** Prepares shared folders tree-wdget. */ 116 void prepareTreeWidget(); 116 117 /** Prepares shared folders toolbar. */ 117 void prepare FoldersToolbar();118 void prepareToolbar(); 118 119 /** Prepares connections. */ 119 120 void prepareConnections(); … … 150 151 bool createSharedFolder(const UISettingsCacheSharedFolder &folderCache); 151 152 152 /** Holds the Add action instance. */153 QAction *m_pActionAdd;154 /** Holds the Edit action instance. */155 QAction *m_pActionEdit;156 /** Holds the Remove action instance. */157 QAction *m_pActionRemove;158 159 153 /** Holds the page data cache instance. */ 160 154 UISettingsCacheSharedFolders *m_pCache; … … 162 156 /** @name Widgets 163 157 * @{ */ 164 QITreeWidget *m_pFoldersTreeWidget; 165 QILabelSeparator *m_pNameSeparator; 166 UIToolBar *m_pFoldersToolBar; 158 /** Holds the widget separator instance. */ 159 QILabelSeparator *m_pLabelSeparator; 160 /** Holds the tree layout instance. */ 161 QHBoxLayout *m_pLayoutTree; 162 /** Holds the tree-widget instance. */ 163 QITreeWidget *m_pTreeWidget; 164 /** Holds the toolbar instance. */ 165 UIToolBar *m_pToolBar; 166 /** Holds the Add action instance. */ 167 QAction *m_pActionAdd; 168 /** Holds the Edit action instance. */ 169 QAction *m_pActionEdit; 170 /** Holds the Remove action instance. */ 171 QAction *m_pActionRemove; 167 172 /** @} */ 168 173 };
Note:
See TracChangeset
for help on using the changeset viewer.