VirtualBox

Changeset 102418 in vbox


Ignore:
Timestamp:
Dec 1, 2023 11:47:43 AM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10561. Hide some of the actions from the host file browser when using in VISO dialog.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r102404 r102418  
    514514}
    515515
    516 void UIFileManagerGuestTable::readDirectory(const QString& strPath,
     516bool UIFileManagerGuestTable::readDirectory(const QString& strPath,
    517517                                     UICustomFileSystemItem *parent, bool isStartDir /*= false*/)
    518518{
    519519    if (!parent)
    520         return;
     520        return false;
    521521
    522522    CGuestDirectory directory;
     
    528528    {
    529529        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    530         return;
     530        return false;
    531531    }
    532532
     
    569569                    item->setData(fsInfo.GetUserName(), UICustomFileSystemModelData_Owner);
    570570                    item->setData(permissionString(fsInfo), UICustomFileSystemModelData_Permissions);
     571                    printf(" %s === %s\n", qPrintable(fsInfo.GetName()), qPrintable(fsInfo.GetFileAttributes()));
    571572                    item->setIsOpened(false);
    572573                    item->setIsHidden(isFileObjectHidden(fsInfo));
     
    596597        checkDotDot(fileObjects, parent, isStartDir);
    597598    }
    598 
     599    else
     600    {
     601        directory.Close();
     602        return false;
     603    }
    599604    directory.Close();
     605    return true;
    600606}
    601607
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r102393 r102418  
    8181
    8282    void            retranslateUi() override final;
    83     virtual void    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
     83    virtual bool    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    8484    virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
    8585    virtual void    goToHomeDirectory() override final;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r102393 r102418  
    135135UIFileManagerHostTable::UIFileManagerHostTable(UIActionPool *pActionPool, QWidget *pParent /* = 0 */)
    136136    :UIFileManagerTable(pActionPool, pParent)
     137    , m_pModifierActionSeparator(0)
    137138{
    138139    setModelFileSystem(isWindowsFileSystem());
     
    144145}
    145146
    146 /* static */ void UIFileManagerHostTable::scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
     147void UIFileManagerHostTable::setModifierActionsVisible(bool fShown)
     148{
     149    if (m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Delete))
     150        m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Delete)->setVisible(fShown);
     151    if (m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Rename))
     152        m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Rename)->setVisible(fShown);
     153    if (m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_CreateNewDirectory))
     154        m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_CreateNewDirectory)->setVisible(fShown);
     155    if (m_pModifierActionSeparator)
     156        m_pModifierActionSeparator->setVisible(fShown);
     157}
     158
     159/* static */ bool UIFileManagerHostTable::scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
    147160                                                        QMap<QString, UICustomFileSystemItem*> &fileObjects)
    148161{
     
    153166    /*directory.setFilter(QDir::NoDotAndDotDot);*/
    154167    parent->setIsOpened(true);
    155     if (!directory.exists())
    156         return;
     168    if (!directory.exists() || !directory.isReadable())
     169        return false;
    157170    QFileInfoList entries = directory.entryInfoList(QDir::Hidden|QDir::AllEntries|QDir::NoDotAndDotDot);
     171    if (entries.isEmpty())
     172        return false;
    158173    for (int i = 0; i < entries.size(); ++i)
    159174    {
     
    180195        item->setIsOpened(false);
    181196    }
     197    return true;
    182198}
    183199
     
    199215        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_GoHome));
    200216        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Refresh));
    201         m_pToolBar->addSeparator();
     217
     218        m_pModifierActionSeparator = m_pToolBar->addSeparator();
    202219        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Delete));
    203220        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Rename));
    204221        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_CreateNewDirectory));
    205         // m_pToolBar->addSeparator();
     222
    206223        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Copy));
    207224        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_FileManager_S_Host_Cut));
     
    267284}
    268285
    269 void UIFileManagerHostTable::readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir /*= false*/)
     286bool UIFileManagerHostTable::readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir /*= false*/)
    270287{
    271288    if (!parent)
    272         return;
     289        return false;
    273290
    274291    QMap<QString, UICustomFileSystemItem*> fileObjects;
    275     scanDirectory(strPath, parent, fileObjects);
     292    if (!scanDirectory(strPath, parent, fileObjects))
     293        return false;
    276294    checkDotDot(fileObjects, parent, isStartDir);
     295    return true;
    277296}
    278297
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.h

    r102393 r102418  
    5151
    5252    UIFileManagerHostTable(UIActionPool *pActionPool, QWidget *pParent = 0);
     53    /** Hide delete, rename, new folder actions. */
     54    void setModifierActionsVisible(bool fShown);
     55
    5356    static KFsObjType  fileType(const QFileInfo &fsInfo);
    5457    static KFsObjType  fileType(const QString &strPath);
     
    5861    /** Scans the directory with the path @strPath and inserts items to the
    5962     *  tree under the @p parent. */
    60     static void scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
     63    static bool scanDirectory(const QString& strPath, UICustomFileSystemItem *parent,
    6164                              QMap<QString, UICustomFileSystemItem*> &fileObjects);
    6265    void            retranslateUi() override final;
    63     virtual void    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
     66    virtual bool    readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) override final;
    6467    virtual void    deleteByItem(UICustomFileSystemItem *item) override final;
    6568    virtual void    goToHomeDirectory() override final;
     
    8588    static QString permissionString(QFileDevice::Permissions permissions);
    8689    void    prepareActionConnections();
     90
     91    QAction *m_pModifierActionSeparator;
    8792};
    8893
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r102393 r102418  
    687687    {
    688688        if (!item->isOpened())
    689             readDirectory(item->path(),item);
    690         changeLocation(index);
     689        {
     690            if (readDirectory(item->path(),item))
     691                changeLocation(index);
     692        }
     693        else
     694            changeLocation(index);
    691695    }
    692696}
     
    702706        /* Make sure parent is already opened: */
    703707        if (!parent->isOpened())
    704             readDirectory(parent->path(), parent, parent == getStartDirectoryItem());
     708            if (!readDirectory(parent->path(), parent, parent == getStartDirectoryItem()))
     709                return;
    705710        /* search the current path item among the parent's children: */
    706711        UICustomFileSystemItem *item = parent->child(pathTrail.at(i));
     
    713718        return;
    714719    if (!parent->isOpened())
    715         readDirectory(parent->path(), parent, parent == getStartDirectoryItem());
     720    {
     721        if (!readDirectory(parent->path(), parent, parent == getStartDirectoryItem()))
     722            return;
     723    }
    716724    goIntoDirectory(parent);
    717725}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r102393 r102418  
    211211    void checkDotDot(QMap<QString,UICustomFileSystemItem*> &map, UICustomFileSystemItem *parent, bool isStartDir);
    212212
    213     virtual void     readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0;
     213    virtual bool     readDirectory(const QString& strPath, UICustomFileSystemItem *parent, bool isStartDir = false) = 0;
    214214    virtual void     deleteByItem(UICustomFileSystemItem *item) = 0;
    215215    virtual void     goToHomeDirectory() = 0;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r102404 r102418  
    491491    AssertPtrReturnVoid(m_pHostFileBrowser);
    492492    pContainerLayout->addWidget(m_pHostFileBrowser, 0, 0, 1, 4);
     493    m_pHostFileBrowser->setModifierActionsVisible(false);
    493494
    494495    prepareVerticalToolBar();
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