VirtualBox

Ignore:
Timestamp:
Feb 14, 2019 10:39:39 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128834
Message:

FE/Qt: bugref:9080. Redesigning VISO creator by hiding the ugly tree viewer. part 1.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r77174 r77308  
    978978        src/medium/viso/UIVisoContentBrowser.cpp \
    979979        src/medium/viso/UIVisoHostBrowser.cpp \
     980        src/medium/viso/UIVisoBrowserBase.cpp \
    980981        src/settings/global/UIGlobalSettingsExtension.cpp \
    981982        src/settings/global/UIGlobalSettingsInput.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.cpp

    r76950 r77308  
    124124{
    125125    QFrame *pSeparator = new QFrame();
     126    if (!pSeparator)
     127        return;
    126128    pSeparator->setFrameShape(QFrame::VLine);
    127129    pSeparator->setFrameShadow(QFrame::Sunken);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoBrowserBase.cpp

    r76826 r77308  
    2020#include <QGridLayout>
    2121#include <QLabel>
     22#include <QLineEdit>
    2223#include <QSplitter>
    2324#include <QTableView>
     
    2627
    2728/* GUI includes: */
     29#include "QIToolButton.h"
     30#include "UIIconPool.h"
     31#include "UIToolBar.h"
    2832#include "UIVisoBrowserBase.h"
    29 #include "UIToolBar.h"
     33
     34
     35/*********************************************************************************************************************************
     36*   UILocationSelector definition.                                                                                   *
     37*********************************************************************************************************************************/
     38
     39class UILocationSelector : public QIWithRetranslateUI<QWidget>
     40{
     41    Q_OBJECT;
     42public:
     43
     44    UILocationSelector(QWidget *pParent = 0);
     45    int  lineEditWidth() const;
     46    void updateLineEditText(const QString &strText);
     47
     48signals:
     49
     50    void sigExpandCollapseTreeView();
     51
     52protected:
     53
     54    virtual void retranslateUi() /* override */;
     55    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     56    virtual bool eventFilter(QObject *pObj, QEvent *pEvent) /* override */;
     57
     58private:
     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
     73UILocationSelector::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
     84int UILocationSelector::lineEditWidth() const
     85{
     86    if (!m_pLineEdit)
     87        return 0;
     88    return m_pLineEdit->width();
     89}
     90
     91void UILocationSelector::updateLineEditText(const QString &strText)
     92{
     93    if (!m_pLineEdit)
     94        return;
     95    m_pLineEdit->setText(strText);
     96}
     97
     98void UILocationSelector::paintEvent(QPaintEvent *pEvent)
     99{
     100    QIWithRetranslateUI<QWidget>::paintEvent(pEvent);
     101}
     102
     103void UILocationSelector::retranslateUi()
     104{
     105}
     106
     107bool 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}
     116void 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*********************************************************************************************************************************/
    30147
    31148UIVisoBrowserBase::UIVisoBrowserBase(QWidget *pParent /* = 0 */, QMenu *pMenu /*= 0*/)
    32149    : QIWithRetranslateUI<QWidget>(pParent)
    33150    , m_pTreeView(0)
    34     , m_pTitleLabel(0)
    35     , m_pRightContainerWidget(0)
    36     , m_pRightContainerLayout(0)
    37151    , m_pVerticalToolBar(0)
    38152    , m_pMenu(pMenu)
    39153    , m_pMainLayout(0)
    40     , m_pHorizontalSplitter(0)
     154    , m_pLocationSelector(0)
    41155{
    42156}
     
    51165    setLayout(m_pMainLayout);
    52166
    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);
    87178    if (m_pTreeView)
    88179    {
    89         pLeftContainerLayout->addWidget(m_pTreeView);
     180        m_pTreeView->hide();
    90181        m_pTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
    91         m_pTreeView->setAlternatingRowColors(true);
     182        //m_pTreeView->setAlternatingRowColors(true);
    92183        m_pTreeView->header()->hide();
    93184        m_pTreeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
    94     }
    95 
     185        m_pTreeView->setFrameStyle(QFrame::Panel | QFrame::Plain);
     186    }
    96187
    97188    m_pVerticalToolBar = new UIToolBar;
     
    99190    {
    100191        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    }
    110194}
    111195
     
    119203                this, &UIVisoBrowserBase::sltHandleTreeItemClicked);
    120204    }
     205    if (m_pLocationSelector)
     206        connect(m_pLocationSelector, &UILocationSelector::sigExpandCollapseTreeView,
     207                this, &UIVisoBrowserBase::sltExpandCollapseTreeView);
     208}
     209
     210void UIVisoBrowserBase::updateLocationSelectorText(const QString &strText)
     211{
     212    if (!m_pLocationSelector)
     213        return;
     214    m_pLocationSelector->updateLineEditText(strText);
     215}
     216
     217void UIVisoBrowserBase::resizeEvent(QResizeEvent *pEvent)
     218{
     219    QIWithRetranslateUI<QWidget>::resizeEvent(pEvent);
     220    if (m_pTreeView)
     221        updateTreeViewGeometry(m_pTreeView->isVisible());
    121222}
    122223
     
    142243        return;
    143244    m_pTreeView->setExpanded(modelIndex, true);
    144 }
    145 
    146 
    147 //#include "UIVisoBrowserBase.moc"
     245    m_pTreeView->hide();
     246}
     247
     248void UIVisoBrowserBase::sltExpandCollapseTreeView()
     249{
     250    if (!m_pTreeView)
     251        return;
     252    updateTreeViewGeometry(!m_pTreeView->isVisible());
     253}
     254
     255void 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  
    3838class QTableView;
    3939class QTreeView;
     40class UILocationSelector;
    4041class UIToolBar;
    4142
     
    5960    void prepareObjects();
    6061    void prepareConnections();
     62    void updateLocationSelectorText(const QString &strText);
    6163
    6264    virtual void tableViewItemDoubleClick(const QModelIndex &index) = 0;
     
    6567    virtual void setTreeCurrentIndex(QModelIndex index = QModelIndex()) = 0;
    6668
     69    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
    6770
    6871    QTreeView          *m_pTreeView;
    69     QLabel             *m_pTitleLabel;
    70     QWidget            *m_pRightContainerWidget;
    71     QGridLayout        *m_pRightContainerLayout;
    7272    UIToolBar          *m_pVerticalToolBar;
    7373    QMenu              *m_pMenu;
     74    QGridLayout       *m_pMainLayout;
     75
    7476private:
    75     QGridLayout    *m_pMainLayout;
    76     QSplitter      *m_pHorizontalSplitter;
    7777
    7878private slots:
     
    8080    void sltHandleTreeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    8181    void sltHandleTreeItemClicked(const QModelIndex &modelIndex);
     82    void sltExpandCollapseTreeView();
    8283
    8384private:
    8485
     86    void updateTreeViewGeometry(bool fShow);
     87    UILocationSelector    *m_pLocationSelector;
    8588};
    8689
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.cpp

    r76947 r77308  
    8989    addVerticalSeparator();
    9090
    91 
    9291    /* Cutom Viso options stuff: */
    9392    m_pCustomOptionsLabel = new QILabel(QApplication::translate("UIVisoCreator", "Custom VISO options:"));
     
    123122    {
    124123        /* Process key press only: */
    125     case QEvent::KeyPress:
     124        case QEvent::KeyPress:
    126125        {
    127126            /* Cast to corresponding key press event: */
     
    133132            break;
    134133        }
    135     default:
     134        default:
    136135        break;
    137136    }
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r76826 r77308  
    246246void UIVisoContentBrowser::retranslateUi()
    247247{
    248     if (m_pTitleLabel)
    249         m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "VISO content"));
    250248    if (m_pRemoveAction)
    251249    {
     
    418416    if (m_pTableView)
    419417    {
    420         m_pRightContainerLayout->addWidget(m_pTableView, 0, 0, 6, 4);
     418        m_pMainLayout->addWidget(m_pTableView, 1, 0, 6, 4);
    421419        m_pTableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
    422420        m_pTableView->setShowGrid(false);
     
    559557    if (!m_pTableView)
    560558        return;
     559
     560    QModelIndex tableIndex;
    561561    if (index.isValid())
    562562    {
    563         QModelIndex tableIndex = convertIndexToTableIndex(index);
     563        tableIndex = convertIndexToTableIndex(index);
    564564        if (tableIndex.isValid())
    565565            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)
    572571        {
    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);
    577591        }
    578592    }
     
    613627        m_pTreeProxyModel->invalidate();
    614628    }
    615 
    616629    pSelectionModel->blockSignals(false);
    617630    m_pTreeView->blockSignals(false);
     
    728741    if (!rootItem() || !rootItem()->child(0))
    729742        return;
    730     const QString strName = QString("/%1").arg(m_strVisoName);
     743    const QString strName = QString("%1%2").arg(QDir::toNativeSeparators("/")).arg(m_strVisoName);
    731744
    732745    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);
    733749    m_pTreeProxyModel->invalidate();
    734750    m_pTableProxyModel->invalidate();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r77264 r77308  
    3737    : QIWithRetranslateUI<QIMainDialog>(pParent)
    3838    , m_pMainLayout(0)
    39     , m_pVerticalSplitter(0)
     39    , m_pHorizontalSplitter(0)
    4040    , m_pHostBrowser(0)
    4141    , m_pVisoBrowser(0)
     
    197197    m_pMainLayout->setSpacing(10);
    198198#else
    199     m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);
     199    m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
    200200#endif
    201201
     
    224224    }
    225225
    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);
    233235
    234236    m_pHostBrowser = new UIVisoHostBrowser(0 /* parent */, m_pHostBrowserMenu);
    235237    if (m_pHostBrowser)
    236238    {
    237         m_pVerticalSplitter->addWidget(m_pHostBrowser);
     239        m_pHorizontalSplitter->addWidget(m_pHostBrowser);
    238240        connect(m_pHostBrowser, &UIVisoHostBrowser::sigAddObjectsToViso,
    239241                this, &UIVisoCreator::sltHandleAddObjectsToViso);
     
    243245    if (m_pVisoBrowser)
    244246    {
    245         m_pVerticalSplitter->addWidget(m_pVisoBrowser);
     247        m_pHorizontalSplitter->addWidget(m_pVisoBrowser);
    246248        m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName);
    247249    }
     
    250252    if (m_pConfigurationPanel)
    251253    {
    252         m_pVerticalSplitter->addWidget(m_pConfigurationPanel);
     254        m_pMainLayout->addWidget(m_pConfigurationPanel);
    253255        m_panelActionMap.insert(m_pConfigurationPanel, m_pActionConfiguration);
    254256        m_pConfigurationPanel->hide();
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r76959 r77308  
    114114
    115115    QVBoxLayout          *m_pMainLayout;
    116     QSplitter            *m_pVerticalSplitter;
     116    QSplitter            *m_pHorizontalSplitter;
    117117    UIVisoHostBrowser    *m_pHostBrowser;
    118118    UIVisoContentBrowser *m_pVisoBrowser;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp

    r76959 r77308  
    1818#include <QAction>
    1919#include <QAbstractItemModel>
     20#include <QDialog>
    2021#include <QDir>
    2122#include <QFileSystemModel>
     
    2324#include <QHeaderView>
    2425#include <QLabel>
     26#include <QLineEdit>
    2527#include <QListView>
    2628#include <QMenu>
    2729#include <QMimeData>
    2830#include <QTableView>
     31#include <QTextEdit>
    2932#include <QTreeView>
    3033
     
    3437#include "UIToolBar.h"
    3538#include "UIVisoHostBrowser.h"
     39
    3640
    3741
     
    133137void UIVisoHostBrowser::retranslateUi()
    134138{
    135     if (m_pTitleLabel)
    136         m_pTitleLabel->setText(QApplication::translate("UIVisoCreator", "Host file system"));
    137139    if (m_pAddAction)
    138140    {
     
    169171    if (m_pTableView)
    170172    {
    171         m_pRightContainerLayout->addWidget(m_pTableView, 0, 0, 6, 4);
     173        m_pMainLayout->addWidget(m_pTableView, 1, 0, 8, 4);
    172174        m_pTableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
    173175        m_pTableView->setShowGrid(false);
     
    320322    if (!strCurrentTreePath.isEmpty())
    321323        m_pTableView->setRootIndex(m_pTableModel->index(strCurrentTreePath));
     324    updateLocationSelectorText(strCurrentTreePath);
    322325}
    323326
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h

    r76959 r77308  
    3131/* Forward declarations: */
    3232class QItemSelection;
     33class UIFileTreeContainer;
    3334class UIVisoHostBrowserModel;
    3435
     
    7273    QAction                *m_pAddAction;
    7374    QTableView             *m_pTableView;
    74 
    7575};
    7676
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette