VirtualBox

Ignore:
Timestamp:
Apr 16, 2019 3:52:58 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Showing correct path separators in file manager

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPathOperations.cpp

    r76606 r78146  
    130130/* static */ QStringList UIPathOperations::pathTrail(const QString &path)
    131131{
    132     QStringList pathList = path.split(UIPathOperations::delimiter, QString::SkipEmptyParts);
    133     if (!pathList.isEmpty() && doesPathStartWithDriveLetter(pathList[0]))
    134     {
    135         pathList[0] = addTrailingDelimiters(pathList[0]);
    136     }
    137     return pathList;
     132    return path.split(UIPathOperations::delimiter, QString::SkipEmptyParts);
    138133}
    139134
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r78057 r78146  
    158158        return;
    159159    m_comGuestSession = session;
     160    /* To determine the path separator we need to have a valid guest session: */
     161    determinePathSeparator();
    160162    initializeFileTree();
    161163}
     
    604606            m_driveLetterList.push_back(path);
    605607    }
     608}
     609
     610void UIFileManagerGuestTable::determinePathSeparator()
     611{
     612    if (m_comGuestSession.isNull())
     613        return;
     614    KPathStyle pathStyle = m_comGuestSession.GetPathStyle();
     615    if (pathStyle == KPathStyle_DOS)
     616        setPathSeparator(UIPathOperations::dosDelimiter);
    606617}
    607618
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r77528 r78146  
    6666    virtual void    showProperties() /* override */;
    6767    virtual void    determineDriveLetters() /* override */;
     68    virtual void    determinePathSeparator() /* override */;
    6869    virtual void    prepareToolbar() /* override */;
    6970    virtual void    createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r77932 r78146  
    127127    prepareToolbar();
    128128    prepareActionConnections();
     129    determinePathSeparator();
    129130    retranslateUi();
    130131}
     
    448449        if (UIPathOperations::doesPathStartWithDriveLetter(drive[i].filePath()))
    449450            m_driveLetterList.push_back(drive[i].filePath());
    450 
    451     }
     451    }
     452}
     453
     454void UIFileManagerHostTable::determinePathSeparator()
     455{
     456    setPathSeparator(QDir::separator());
    452457}
    453458
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h

    r77528 r78146  
    5656    virtual void    showProperties() /* override */;
    5757    virtual void    determineDriveLetters() /* override */;
     58    virtual void    determinePathSeparator() /* override */;
    5859    virtual void    prepareToolbar() /* override */;
    5960    virtual void    createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r78058 r78146  
    8484    UIFileManagerBreadCrumbs(QWidget *pParent = 0);
    8585    void setPath(const QString &strPath);
     86    void setPathSeparator(const QChar &separator);
    8687
    8788protected:
     
    9293
    9394    QString m_strPath;
     95    QChar   m_pathSeparator;
    9496};
    9597
     
    113115    void setPath(const QString &strLocation);
    114116    void reset();
     117    void setPathSeparator(const QChar &separator);
    115118
    116119private slots:
     
    119122    /* Makes sure that we switch to breadcrumbs widget as soon as the combo box popup is hidden. */
    120123    void sltHandleHidePopup();
     124    void sltHandlePathChange(const QString &strPath);
    121125
    122126private:
     
    128132    UIFileManagerHistoryComboBox *m_pHistoryComboBox;
    129133    QToolButton                  *m_pSwitchButton;
     134    QChar                         m_pathSeparator;
    130135};
    131136
     
    250255    , m_pHistoryComboBox(0)
    251256    , m_pSwitchButton(0)
     257    , m_pathSeparator('/')
    252258{
    253259    prepare();
     
    261267    if (m_pHistoryComboBox)
    262268    {
    263         int itemIndex = m_pHistoryComboBox->findText(strLocation,
     269        QString strNativeLocation(strLocation);
     270        strNativeLocation.replace('/', m_pathSeparator);
     271        int itemIndex = m_pHistoryComboBox->findText(strNativeLocation,
    264272                                                      Qt::MatchExactly | Qt::MatchCaseSensitive);
    265273        if (itemIndex == -1)
    266274        {
    267             m_pHistoryComboBox->insertItem(m_pHistoryComboBox->count(), strLocation);
     275            m_pHistoryComboBox->insertItem(m_pHistoryComboBox->count(), strNativeLocation);
    268276            itemIndex = m_pHistoryComboBox->count() - 1;
    269277        }
     
    277285    {
    278286        disconnect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
    279                    this, &UIFileManagerNavigationWidget::sigPathChanged);
     287                   this, &UIFileManagerNavigationWidget::sltHandlePathChange);
    280288        m_pHistoryComboBox->clear();
    281289        connect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
    282                 this, &UIFileManagerNavigationWidget::sigPathChanged);
     290                this, &UIFileManagerNavigationWidget::sltHandlePathChange);
    283291    }
    284292
    285293    if (m_pBreadCrumbs)
    286294        m_pBreadCrumbs->setPath(QString());
     295}
     296
     297void UIFileManagerNavigationWidget::setPathSeparator(const QChar &separator)
     298{
     299    m_pathSeparator = separator;
     300    if (m_pBreadCrumbs)
     301        m_pBreadCrumbs->setPathSeparator(m_pathSeparator);
    287302}
    288303
     
    305320            m_pBreadCrumbs->setIndent(0.5 * qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin));
    306321            connect(m_pBreadCrumbs, &UIFileManagerBreadCrumbs::linkActivated,
    307                     this, &UIFileManagerNavigationWidget::sigPathChanged);
     322                    this, &UIFileManagerNavigationWidget::sltHandlePathChange);
    308323            connect(m_pHistoryComboBox, &UIFileManagerHistoryComboBox::sigHidePopup,
    309324                    this, &UIFileManagerNavigationWidget::sltHandleHidePopup);
    310325            connect(m_pHistoryComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
    311                     this, &UIFileManagerNavigationWidget::sigPathChanged);
     326                    this, &UIFileManagerNavigationWidget::sltHandlePathChange);
    312327
    313328            m_pContainer->addWidget(m_pBreadCrumbs);
     
    340355}
    341356
     357void UIFileManagerNavigationWidget::sltHandlePathChange(const QString &strPath)
     358{
     359    QString strNonNativePath(strPath);
     360    strNonNativePath.replace(m_pathSeparator, '/');
     361    emit sigPathChanged(strNonNativePath);
     362}
     363
    342364void UIFileManagerNavigationWidget::sltHandleSwitch()
    343365{
     
    361383UIFileManagerBreadCrumbs::UIFileManagerBreadCrumbs(QWidget *pParent /* = 0 */)
    362384    :QLabel(pParent)
     385    , m_pathSeparator('/')
    363386{
    364387    float fFontMult = 1.2f;
     
    407430    for (int i = folderList.size() - 1; i >= 0; --i)
    408431    {
    409         QString strFolder = UIPathOperations::removeTrailingDelimiters(folderList.at(i));
     432        QString strFolder = UIPathOperations::removeTrailingDelimiters(folderList.at(i)).replace('/', m_pathSeparator);
    410433        QString strWord = QString("<a href=\"%1\" style=\"color:black;text-decoration:none;\">%2</a>").arg(strPathUpto[i]).arg(strFolder);
    411 
    412434        if (i < folderList.size() - 1)
    413435        {
     
    422444    }
    423445    setText(strLabelText);
     446}
     447
     448void UIFileManagerBreadCrumbs::setPathSeparator(const QChar &separator)
     449{
     450    m_pathSeparator = separator;
    424451}
    425452
     
    669696    , m_pView(0)
    670697    , m_pProxyModel(0)
     698    , m_pNavigationWidget(0)
    671699    , m_pMainLayout(0)
    672700    , m_pWarningLabel(0)
    673     , m_pNavigationWidget(0)
     701    , m_pathSeparator('/')
    674702{
    675703    prepareObjects();
     
    849877        for (int i = 0; i < m_driveLetterList.size(); ++i)
    850878        {
    851             UICustomFileSystemItem* driveItem = new UICustomFileSystemItem(m_driveLetterList[i], startItem, KFsObjType_Directory);
     879            UICustomFileSystemItem* driveItem = new UICustomFileSystemItem(UIPathOperations::removeTrailingDelimiters(m_driveLetterList[i]),
     880                                                                           startItem, KFsObjType_Directory);
    852881            driveItem->setPath(m_driveLetterList[i]);
    853882            driveItem->setIsOpened(false);
     
    14021431}
    14031432
     1433void UIFileManagerTable::setPathSeparator(const QChar &separator)
     1434{
     1435    m_pathSeparator = separator;
     1436    if (m_pNavigationWidget)
     1437        m_pNavigationWidget->setPathSeparator(m_pathSeparator);
     1438}
     1439
    14041440bool UIFileManagerTable::event(QEvent *pEvent)
    14051441{
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r78058 r78146  
    209209     *  drive letters */
    210210    virtual void     determineDriveLetters() = 0;
     211    virtual void     determinePathSeparator() = 0;
    211212    virtual void     prepareToolbar() = 0;
    212213    virtual void     createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) = 0;
     
    234235    void             setSelectionDependentActionsEnabled(bool fIsEnabled);
    235236    UICustomFileSystemItem*   rootItem();
     237    void             setPathSeparator(const QChar &separator);
    236238
    237239    QILabel                 *m_pLocationLabel;
     
    239241    UIActionPool            *m_pActionPool;
    240242    UIToolBar               *m_pToolBar;
     243
    241244    /** Stores the drive letters the file system has (for windows system). For non-windows
    242245     *  systems this is empty and for windows system it should at least contain C:/ */
     
    287290    void            markUnmarkSearchLineEdit(bool fMark);
    288291
    289     UICustomFileSystemModel      *m_pModel;
    290     UIGuestControlFileView       *m_pView;
    291     UICustomFileSystemProxyModel *m_pProxyModel;
     292    UICustomFileSystemModel       *m_pModel;
     293    UIGuestControlFileView        *m_pView;
     294    UICustomFileSystemProxyModel  *m_pProxyModel;
     295    /** Contains m_pBreadCrumbsWidget and m_pLocationComboBox. */
     296    UIFileManagerNavigationWidget *m_pNavigationWidget;
    292297
    293298    QGridLayout     *m_pMainLayout;
     
    296301    QColor           m_searchLineMarkColor;
    297302    QILabel         *m_pWarningLabel;
    298 
    299     /** Contains m_pBreadCrumbsWidget and m_pLocationComboBox. */
    300     UIFileManagerNavigationWidget           *m_pNavigationWidget;
    301     //UIFileManagerBreadCrumbs *m_pBreadCrumbsWidget;
     303    QChar            m_pathSeparator;
    302304
    303305    friend class     UICustomFileSystemModel;
Note: See TracChangeset for help on using the changeset viewer.

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