Changeset 77308 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 14, 2019 10:39:39 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128834
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r77174 r77308 978 978 src/medium/viso/UIVisoContentBrowser.cpp \ 979 979 src/medium/viso/UIVisoHostBrowser.cpp \ 980 src/medium/viso/UIVisoBrowserBase.cpp \ 980 981 src/settings/global/UIGlobalSettingsExtension.cpp \ 981 982 src/settings/global/UIGlobalSettingsInput.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.cpp
r76950 r77308 124 124 { 125 125 QFrame *pSeparator = new QFrame(); 126 if (!pSeparator) 127 return; 126 128 pSeparator->setFrameShape(QFrame::VLine); 127 129 pSeparator->setFrameShadow(QFrame::Sunken); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoBrowserBase.cpp
r76826 r77308 20 20 #include <QGridLayout> 21 21 #include <QLabel> 22 #include <QLineEdit> 22 23 #include <QSplitter> 23 24 #include <QTableView> … … 26 27 27 28 /* GUI includes: */ 29 #include "QIToolButton.h" 30 #include "UIIconPool.h" 31 #include "UIToolBar.h" 28 32 #include "UIVisoBrowserBase.h" 29 #include "UIToolBar.h" 33 34 35 /********************************************************************************************************************************* 36 * UILocationSelector definition. * 37 *********************************************************************************************************************************/ 38 39 class UILocationSelector : public QIWithRetranslateUI<QWidget> 40 { 41 Q_OBJECT; 42 public: 43 44 UILocationSelector(QWidget *pParent = 0); 45 int lineEditWidth() const; 46 void updateLineEditText(const QString &strText); 47 48 signals: 49 50 void sigExpandCollapseTreeView(); 51 52 protected: 53 54 virtual void retranslateUi() /* override */; 55 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 56 virtual bool eventFilter(QObject *pObj, QEvent *pEvent) /* override */; 57 58 private: 59 60 void prepareWidget(); 61 QLineEdit *m_pLineEdit; 62 QGridLayout *m_pMainLayout; 63 QIToolButton *m_pExpandButton; 64 bool m_fExpanded; 65 QDialog *m_pDialog; 66 67 }; 68 69 /********************************************************************************************************************************* 70 * UILocationSelector implementation. * 71 *********************************************************************************************************************************/ 72 73 UILocationSelector::UILocationSelector(QWidget *pParent /* = 0 */) 74 :QIWithRetranslateUI<QWidget>(pParent) 75 , m_pLineEdit(0) 76 , m_pMainLayout(0) 77 , m_pExpandButton(0) 78 , m_fExpanded(false) 79 , m_pDialog(0) 80 { 81 prepareWidget(); 82 } 83 84 int UILocationSelector::lineEditWidth() const 85 { 86 if (!m_pLineEdit) 87 return 0; 88 return m_pLineEdit->width(); 89 } 90 91 void UILocationSelector::updateLineEditText(const QString &strText) 92 { 93 if (!m_pLineEdit) 94 return; 95 m_pLineEdit->setText(strText); 96 } 97 98 void UILocationSelector::paintEvent(QPaintEvent *pEvent) 99 { 100 QIWithRetranslateUI<QWidget>::paintEvent(pEvent); 101 } 102 103 void UILocationSelector::retranslateUi() 104 { 105 } 106 107 bool UILocationSelector::eventFilter(QObject *pObj, QEvent *pEvent) 108 { 109 if (pObj == m_pLineEdit && pEvent->type() == QEvent::MouseButtonPress) 110 { 111 emit sigExpandCollapseTreeView(); 112 } 113 /* Pass the events to event system for further processing: */ 114 return false; 115 } 116 void UILocationSelector::prepareWidget() 117 { 118 m_pMainLayout = new QGridLayout; 119 if (!m_pMainLayout) 120 return; 121 m_pMainLayout->setSpacing(0); 122 m_pMainLayout->setContentsMargins(0,0,0,0); 123 124 m_pLineEdit = new QLineEdit; 125 if (m_pLineEdit) 126 { 127 m_pMainLayout->addWidget(m_pLineEdit, 0, 0, 1, 4); 128 m_pLineEdit->setReadOnly(true); 129 m_pLineEdit->installEventFilter(this); 130 } 131 132 m_pExpandButton = new QIToolButton; 133 if (m_pExpandButton) 134 { 135 m_pMainLayout->addWidget(m_pExpandButton, 0, 4, 1, 1); 136 m_pExpandButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png")); 137 connect(m_pExpandButton, &QIToolButton::clicked, 138 this, &UILocationSelector::sigExpandCollapseTreeView); 139 140 } 141 setLayout(m_pMainLayout); 142 } 143 144 /********************************************************************************************************************************* 145 * UIVisoBrowserBase implementation. * 146 *********************************************************************************************************************************/ 30 147 31 148 UIVisoBrowserBase::UIVisoBrowserBase(QWidget *pParent /* = 0 */, QMenu *pMenu /*= 0*/) 32 149 : QIWithRetranslateUI<QWidget>(pParent) 33 150 , m_pTreeView(0) 34 , m_pTitleLabel(0)35 , m_pRightContainerWidget(0)36 , m_pRightContainerLayout(0)37 151 , m_pVerticalToolBar(0) 38 152 , m_pMenu(pMenu) 39 153 , m_pMainLayout(0) 40 , m_p HorizontalSplitter(0)154 , m_pLocationSelector(0) 41 155 { 42 156 } … … 51 165 setLayout(m_pMainLayout); 52 166 53 QWidget *pLeftContainerWidget = new QWidget; 54 m_pRightContainerWidget = new QWidget; 55 56 QVBoxLayout *pLeftContainerLayout = new QVBoxLayout; 57 m_pRightContainerLayout = new QGridLayout; 58 59 pLeftContainerLayout->setSpacing(1); 60 pLeftContainerLayout->setContentsMargins(0, 0, 0, 0); 61 m_pRightContainerLayout->setSpacing(1); 62 m_pRightContainerLayout->setContentsMargins(0, 0, 0, 0); 63 64 if (!m_pMainLayout || !pLeftContainerLayout || !m_pRightContainerLayout) 65 return; 66 if (!pLeftContainerWidget || !m_pRightContainerWidget) 67 return; 68 69 pLeftContainerWidget->setLayout(pLeftContainerLayout); 70 m_pRightContainerWidget->setLayout(m_pRightContainerLayout); 71 72 m_pHorizontalSplitter = new QSplitter; 73 if (!m_pHorizontalSplitter) 74 return; 75 76 m_pMainLayout->addWidget(m_pHorizontalSplitter, 1, 0); 77 m_pHorizontalSplitter->setOrientation(Qt::Horizontal); 78 m_pHorizontalSplitter->setHandleWidth(2); 79 80 m_pTitleLabel = new QLabel; 81 if (m_pTitleLabel) 82 { 83 pLeftContainerLayout->addWidget(m_pTitleLabel); 84 } 85 86 m_pTreeView = new QTreeView; 167 if (!m_pMainLayout) 168 return; 169 170 m_pMainLayout->setRowStretch(1, 2); 171 m_pLocationSelector = new UILocationSelector; 172 if (m_pLocationSelector) 173 { 174 m_pMainLayout->addWidget(m_pLocationSelector, 0, 0, 1, 4); 175 } 176 177 m_pTreeView = new QTreeView(this); 87 178 if (m_pTreeView) 88 179 { 89 pLeftContainerLayout->addWidget(m_pTreeView);180 m_pTreeView->hide(); 90 181 m_pTreeView->setSelectionMode(QAbstractItemView::SingleSelection); 91 m_pTreeView->setAlternatingRowColors(true);182 //m_pTreeView->setAlternatingRowColors(true); 92 183 m_pTreeView->header()->hide(); 93 184 m_pTreeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); 94 }95 185 m_pTreeView->setFrameStyle(QFrame::Panel | QFrame::Plain); 186 } 96 187 97 188 m_pVerticalToolBar = new UIToolBar; … … 99 190 { 100 191 m_pVerticalToolBar->setOrientation(Qt::Vertical); 101 m_pRightContainerLayout->addWidget(m_pVerticalToolBar, 0, 5, 6, 1); 102 } 103 104 m_pHorizontalSplitter->addWidget(pLeftContainerWidget); 105 m_pHorizontalSplitter->addWidget(m_pRightContainerWidget); 106 m_pHorizontalSplitter->setCollapsible(m_pHorizontalSplitter->indexOf(pLeftContainerWidget), false); 107 m_pHorizontalSplitter->setCollapsible(m_pHorizontalSplitter->indexOf(m_pRightContainerWidget), false); 108 m_pHorizontalSplitter->setStretchFactor(0, 1); 109 m_pHorizontalSplitter->setStretchFactor(1, 3); 192 m_pMainLayout->addWidget(m_pVerticalToolBar, 0, 5, 6, 1); 193 } 110 194 } 111 195 … … 119 203 this, &UIVisoBrowserBase::sltHandleTreeItemClicked); 120 204 } 205 if (m_pLocationSelector) 206 connect(m_pLocationSelector, &UILocationSelector::sigExpandCollapseTreeView, 207 this, &UIVisoBrowserBase::sltExpandCollapseTreeView); 208 } 209 210 void UIVisoBrowserBase::updateLocationSelectorText(const QString &strText) 211 { 212 if (!m_pLocationSelector) 213 return; 214 m_pLocationSelector->updateLineEditText(strText); 215 } 216 217 void UIVisoBrowserBase::resizeEvent(QResizeEvent *pEvent) 218 { 219 QIWithRetranslateUI<QWidget>::resizeEvent(pEvent); 220 if (m_pTreeView) 221 updateTreeViewGeometry(m_pTreeView->isVisible()); 121 222 } 122 223 … … 142 243 return; 143 244 m_pTreeView->setExpanded(modelIndex, true); 144 } 145 146 147 //#include "UIVisoBrowserBase.moc" 245 m_pTreeView->hide(); 246 } 247 248 void UIVisoBrowserBase::sltExpandCollapseTreeView() 249 { 250 if (!m_pTreeView) 251 return; 252 updateTreeViewGeometry(!m_pTreeView->isVisible()); 253 } 254 255 void UIVisoBrowserBase::updateTreeViewGeometry(bool fShow) 256 { 257 if (!m_pTreeView) 258 return; 259 260 if (!fShow) 261 { 262 m_pTreeView->hide(); 263 return; 264 } 265 if (!m_pLocationSelector) 266 return; 267 268 int iy = m_pLocationSelector->y() + m_pLocationSelector->height(); 269 int ix = m_pLocationSelector->x(); 270 int iWidth = m_pLocationSelector->lineEditWidth(); 271 272 m_pTreeView-> move(ix, iy); 273 m_pTreeView->raise(); 274 m_pTreeView->resize(iWidth, 0.75 * height()); 275 m_pTreeView->show(); 276 277 //m_pTreeView->scrollTo(m_pTreeView->currentIndex(), QAbstractItemView::PositionAtTop); 278 } 279 280 #include "UIVisoBrowserBase.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoBrowserBase.h
r76826 r77308 38 38 class QTableView; 39 39 class QTreeView; 40 class UILocationSelector; 40 41 class UIToolBar; 41 42 … … 59 60 void prepareObjects(); 60 61 void prepareConnections(); 62 void updateLocationSelectorText(const QString &strText); 61 63 62 64 virtual void tableViewItemDoubleClick(const QModelIndex &index) = 0; … … 65 67 virtual void setTreeCurrentIndex(QModelIndex index = QModelIndex()) = 0; 66 68 69 virtual void resizeEvent(QResizeEvent *pEvent) /* override */; 67 70 68 71 QTreeView *m_pTreeView; 69 QLabel *m_pTitleLabel;70 QWidget *m_pRightContainerWidget;71 QGridLayout *m_pRightContainerLayout;72 72 UIToolBar *m_pVerticalToolBar; 73 73 QMenu *m_pMenu; 74 QGridLayout *m_pMainLayout; 75 74 76 private: 75 QGridLayout *m_pMainLayout;76 QSplitter *m_pHorizontalSplitter;77 77 78 78 private slots: … … 80 80 void sltHandleTreeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); 81 81 void sltHandleTreeItemClicked(const QModelIndex &modelIndex); 82 void sltExpandCollapseTreeView(); 82 83 83 84 private: 84 85 86 void updateTreeViewGeometry(bool fShow); 87 UILocationSelector *m_pLocationSelector; 85 88 }; 86 89 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.cpp
r76947 r77308 89 89 addVerticalSeparator(); 90 90 91 92 91 /* Cutom Viso options stuff: */ 93 92 m_pCustomOptionsLabel = new QILabel(QApplication::translate("UIVisoCreator", "Custom VISO options:")); … … 123 122 { 124 123 /* Process key press only: */ 125 case QEvent::KeyPress:124 case QEvent::KeyPress: 126 125 { 127 126 /* Cast to corresponding key press event: */ … … 133 132 break; 134 133 } 135 default:134 default: 136 135 break; 137 136 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp
r76826 r77308 246 246 void UIVisoContentBrowser::retranslateUi() 247 247 { 248 if (m_pTitleLabel)249 m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "VISO content"));250 248 if (m_pRemoveAction) 251 249 { … … 418 416 if (m_pTableView) 419 417 { 420 m_p RightContainerLayout->addWidget(m_pTableView, 0, 0, 6, 4);418 m_pMainLayout->addWidget(m_pTableView, 1, 0, 6, 4); 421 419 m_pTableView->setSelectionMode(QAbstractItemView::ContiguousSelection); 422 420 m_pTableView->setShowGrid(false); … … 559 557 if (!m_pTableView) 560 558 return; 559 560 QModelIndex tableIndex; 561 561 if (index.isValid()) 562 562 { 563 QModelIndextableIndex = convertIndexToTableIndex(index);563 tableIndex = convertIndexToTableIndex(index); 564 564 if (tableIndex.isValid()) 565 565 m_pTableView->setRootIndex(tableIndex); 566 return; 567 } 568 QItemSelectionModel *selectionModel = m_pTreeView->selectionModel(); 569 if (selectionModel) 570 { 571 if (!selectionModel->selectedIndexes().isEmpty()) 566 } 567 else 568 { 569 QItemSelectionModel *selectionModel = m_pTreeView->selectionModel(); 570 if (selectionModel) 572 571 { 573 QModelIndex treeIndex = selectionModel->selectedIndexes().at(0); 574 QModelIndex tableIndex = convertIndexToTableIndex(treeIndex); 575 if (tableIndex.isValid()) 576 m_pTableView->setRootIndex(tableIndex); 572 if (!selectionModel->selectedIndexes().isEmpty()) 573 { 574 QModelIndex treeIndex = selectionModel->selectedIndexes().at(0); 575 tableIndex = convertIndexToTableIndex(treeIndex); 576 if (tableIndex.isValid()) 577 m_pTableView->setRootIndex(tableIndex); 578 } 579 } 580 } 581 if (tableIndex.isValid()) 582 { 583 UICustomFileSystemItem *pItem = 584 static_cast<UICustomFileSystemItem*>(m_pTableProxyModel->mapToSource(tableIndex).internalPointer()); 585 if (pItem) 586 { 587 QString strPath = pItem->data(UICustomFileSystemModelColumn_Path).toString(); 588 if (strPath == QDir::fromNativeSeparators("/")) 589 strPath += m_strVisoName; 590 updateLocationSelectorText(strPath); 577 591 } 578 592 } … … 613 627 m_pTreeProxyModel->invalidate(); 614 628 } 615 616 629 pSelectionModel->blockSignals(false); 617 630 m_pTreeView->blockSignals(false); … … 728 741 if (!rootItem() || !rootItem()->child(0)) 729 742 return; 730 const QString strName = QString(" /%1").arg(m_strVisoName);743 const QString strName = QString("%1%2").arg(QDir::toNativeSeparators("/")).arg(m_strVisoName); 731 744 732 745 rootItem()->child(0)->setData(strName, UICustomFileSystemModelColumn_Name); 746 /* If the table root index is the start item then we have to update the location selector text here: */ 747 if (m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()).internalPointer() == rootItem()->child(0)) 748 updateLocationSelectorText(strName); 733 749 m_pTreeProxyModel->invalidate(); 734 750 m_pTableProxyModel->invalidate(); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp
r77264 r77308 37 37 : QIWithRetranslateUI<QIMainDialog>(pParent) 38 38 , m_pMainLayout(0) 39 , m_p VerticalSplitter(0)39 , m_pHorizontalSplitter(0) 40 40 , m_pHostBrowser(0) 41 41 , m_pVisoBrowser(0) … … 197 197 m_pMainLayout->setSpacing(10); 198 198 #else 199 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_Layout VerticalSpacing) / 2);199 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2); 200 200 #endif 201 201 … … 224 224 } 225 225 226 m_pVerticalSplitter = new QSplitter; 227 if (!m_pVerticalSplitter) 228 return; 229 230 m_pMainLayout->addWidget(m_pVerticalSplitter); 231 m_pVerticalSplitter->setOrientation(Qt::Vertical); 232 m_pVerticalSplitter->setHandleWidth(1); 226 m_pHorizontalSplitter = new QSplitter; 227 if (!m_pHorizontalSplitter) 228 return; 229 230 m_pMainLayout->addWidget(m_pHorizontalSplitter); 231 /* Make sure m_pHorizontalSplitter takes all the extra space: */ 232 m_pMainLayout->setStretch(m_pMainLayout->indexOf(m_pHorizontalSplitter), 2); 233 m_pHorizontalSplitter->setOrientation(Qt::Horizontal); 234 m_pHorizontalSplitter->setHandleWidth(1); 233 235 234 236 m_pHostBrowser = new UIVisoHostBrowser(0 /* parent */, m_pHostBrowserMenu); 235 237 if (m_pHostBrowser) 236 238 { 237 m_p VerticalSplitter->addWidget(m_pHostBrowser);239 m_pHorizontalSplitter->addWidget(m_pHostBrowser); 238 240 connect(m_pHostBrowser, &UIVisoHostBrowser::sigAddObjectsToViso, 239 241 this, &UIVisoCreator::sltHandleAddObjectsToViso); … … 243 245 if (m_pVisoBrowser) 244 246 { 245 m_p VerticalSplitter->addWidget(m_pVisoBrowser);247 m_pHorizontalSplitter->addWidget(m_pVisoBrowser); 246 248 m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName); 247 249 } … … 250 252 if (m_pConfigurationPanel) 251 253 { 252 m_p VerticalSplitter->addWidget(m_pConfigurationPanel);254 m_pMainLayout->addWidget(m_pConfigurationPanel); 253 255 m_panelActionMap.insert(m_pConfigurationPanel, m_pActionConfiguration); 254 256 m_pConfigurationPanel->hide(); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h
r76959 r77308 114 114 115 115 QVBoxLayout *m_pMainLayout; 116 QSplitter *m_p VerticalSplitter;116 QSplitter *m_pHorizontalSplitter; 117 117 UIVisoHostBrowser *m_pHostBrowser; 118 118 UIVisoContentBrowser *m_pVisoBrowser; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp
r76959 r77308 18 18 #include <QAction> 19 19 #include <QAbstractItemModel> 20 #include <QDialog> 20 21 #include <QDir> 21 22 #include <QFileSystemModel> … … 23 24 #include <QHeaderView> 24 25 #include <QLabel> 26 #include <QLineEdit> 25 27 #include <QListView> 26 28 #include <QMenu> 27 29 #include <QMimeData> 28 30 #include <QTableView> 31 #include <QTextEdit> 29 32 #include <QTreeView> 30 33 … … 34 37 #include "UIToolBar.h" 35 38 #include "UIVisoHostBrowser.h" 39 36 40 37 41 … … 133 137 void UIVisoHostBrowser::retranslateUi() 134 138 { 135 if (m_pTitleLabel)136 m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "Host file system"));137 139 if (m_pAddAction) 138 140 { … … 169 171 if (m_pTableView) 170 172 { 171 m_p RightContainerLayout->addWidget(m_pTableView, 0, 0, 6, 4);173 m_pMainLayout->addWidget(m_pTableView, 1, 0, 8, 4); 172 174 m_pTableView->setSelectionMode(QAbstractItemView::ContiguousSelection); 173 175 m_pTableView->setShowGrid(false); … … 320 322 if (!strCurrentTreePath.isEmpty()) 321 323 m_pTableView->setRootIndex(m_pTableModel->index(strCurrentTreePath)); 324 updateLocationSelectorText(strCurrentTreePath); 322 325 } 323 326 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h
r76959 r77308 31 31 /* Forward declarations: */ 32 32 class QItemSelection; 33 class UIFileTreeContainer; 33 34 class UIVisoHostBrowserModel; 34 35 … … 72 73 QAction *m_pAddAction; 73 74 QTableView *m_pTableView; 74 75 75 }; 76 76
Note:
See TracChangeset
for help on using the changeset viewer.