VirtualBox

Changeset 75202 in vbox for trunk


Ignore:
Timestamp:
Oct 31, 2018 9:30:01 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6699. Move file table view context menu actions to UIActionPool

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

Legend:

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

    r75196 r75202  
    17031703    virtual void retranslateUi() /* override */
    17041704    {
    1705         setName(QApplication::translate("UIActionPool", "GoHome"));
     1705        setName(QApplication::translate("UIActionPool", "Go Home"));
    17061706        setShortcutScope(QApplication::translate("UIActionPool", "Guest Control File Manager"));
    17071707        setStatusTip(QApplication::translate("UIActionPool", "Go to home folder"));
     
    18471847    virtual void retranslateUi() /* override */
    18481848    {
    1849         setName(QApplication::translate("UIActionPool", "CreateNewDirectory"));
     1849        setName(QApplication::translate("UIActionPool", "Create New Directory"));
    18501850        setShortcutScope(QApplication::translate("UIActionPool", "Guest Control File Manager"));
    18511851        setStatusTip(QApplication::translate("UIActionPool", "Create New Directory"));
     
    19881988    virtual void retranslateUi() /* override */
    19891989    {
    1990         setName(QApplication::translate("UIActionPool", "SelectAll"));
     1990        setName(QApplication::translate("UIActionPool", "Select All"));
    19911991        setShortcutScope(QApplication::translate("UIActionPool", "Guest Control File Manager"));
    19921992        setStatusTip(QApplication::translate("UIActionPool", "Select all files objects"));
     
    20242024    virtual void retranslateUi() /* override */
    20252025    {
    2026         setName(QApplication::translate("UIActionPool", "InvertSelection"));
     2026        setName(QApplication::translate("UIActionPool", "Invert Selection"));
    20272027        setShortcutScope(QApplication::translate("UIActionPool", "Guest Control File Manager"));
    20282028        setStatusTip(QApplication::translate("UIActionPool", "Invert the current selection"));
     
    20602060    virtual void retranslateUi() /* override */
    20612061    {
    2062         setName(QApplication::translate("UIActionPool", "ShowProperties"));
     2062        setName(QApplication::translate("UIActionPool", "Show Properties"));
    20632063        setShortcutScope(QApplication::translate("UIActionPool", "Guest Control File Manager"));
    20642064        setStatusTip(QApplication::translate("UIActionPool", "Show the properties of currently selected file object(s)"));
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileManager.h

    r75196 r75202  
    128128    QTextEdit                  *m_pLogOutput;
    129129    UIToolBar                  *m_pToolBar;
    130     // QAction                    *m_pCopyGuestToHost;
    131     // QAction                    *m_pCopyHostToGuest;
    132130    QWidget                    *m_pFileTableContainerWidget;
    133131    QHBoxLayout                *m_pFileTableContainerLayout;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.cpp

    r75184 r75202  
    7171signals:
    7272
    73     void sigGoUp();
    74     void sigGoHome();
    75     void sigRefresh();
    76     void sigRename();
    77     void sigCreateNewDirectory();
    78     void sigDelete();
    79     void sigCut();
    80     void sigCopy();
    81     void sigPaste();
    82     void sigShowProperties();
    8373    void sigSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
    8474
     
    9181
    9282    virtual void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected) /*override */;
    93     void contextMenuEvent(QContextMenuEvent *pEvent);
    9483
    9584private:
     
    312301void UIGuestControlFileView::configure()
    313302{
     303    setContextMenuPolicy(Qt::CustomContextMenu);
    314304    setShowGrid(false);
    315305    setSelectionBehavior(QAbstractItemView::SelectRows);
     
    322312}
    323313
    324 void UIGuestControlFileView::contextMenuEvent(QContextMenuEvent *pEvent)
    325 {
    326     bool selectionAvaible = hasSelection();
    327 
    328     QMenu *menu = new QMenu(this);
    329     if (!menu)
    330         return;
    331 
    332     QAction *pActionGoUp = menu->addAction(QApplication::translate("UIGuestControlFileManager","Go up"));
    333     if (pActionGoUp)
    334     {
    335         pActionGoUp->setIcon(UIIconPool::iconSet(QString(":/arrow_up_10px_x2.png")));
    336         connect(pActionGoUp, &QAction::triggered, this, &UIGuestControlFileView::sigGoUp);
    337     }
    338     QAction *pActionGoHome = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Go home"));
    339     if (pActionGoHome)
    340     {
    341         pActionGoHome->setIcon(UIIconPool::iconSet(QString(":/nw_24px.png")));
    342         connect(pActionGoHome, &QAction::triggered, this, &UIGuestControlFileView::sigGoHome);
    343     }
    344 
    345     QAction *pActionRefresh = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Refresh"));
    346     if (pActionRefresh)
    347     {
    348         pActionRefresh->setIcon(UIIconPool::iconSet(QString(":/refresh_24px.png")));
    349         connect(pActionRefresh, &QAction::triggered, this, &UIGuestControlFileView::sigRefresh);
    350     }
    351 
    352     menu->addSeparator();
    353     QAction *pActionDelete = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Delete"));
    354     if (pActionDelete)
    355     {
    356         pActionDelete->setIcon(UIIconPool::iconSet(QString(":/vm_delete_32px.png")));
    357         pActionDelete->setEnabled(selectionAvaible);
    358         connect(pActionDelete, &QAction::triggered, this, &UIGuestControlFileView::sigDelete);
    359     }
    360 
    361     QAction *pActionRename = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Rename"));
    362     if (pActionRename)
    363     {
    364         pActionRename->setIcon(UIIconPool::iconSet(QString(":/name_16px_x2.png")));
    365         pActionRename->setEnabled(selectionAvaible);
    366         pActionRename->setEnabled(selectionAvaible);
    367         connect(pActionRename, &QAction::triggered, this, &UIGuestControlFileView::sigRename);
    368     }
    369 
    370     QAction *pActionCreateNewDirectory = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Create New Directory"));
    371     if (pActionCreateNewDirectory)
    372     {
    373         pActionCreateNewDirectory->setIcon(UIIconPool::iconSet(QString(":/sf_add_16px.png")));
    374         connect(pActionCreateNewDirectory, &QAction::triggered, this, &UIGuestControlFileView::sigCreateNewDirectory);
    375     }
    376 
    377     QAction *pActionCopy = 0;
    378     QAction *pActionCut = 0;
    379     QAction *pActionPaste = 0;
    380 
    381     bool isGuestFileTable = qobject_cast<UIGuestFileTable*>(parent());
    382 
    383     if (isGuestFileTable)
    384     {
    385         pActionCopy = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Copy"));
    386         if (pActionCopy)
    387         {
    388             pActionCopy->setIcon(UIIconPool::iconSet(QString(":/fd_copy_32px.png")));
    389             pActionCopy->setEnabled(selectionAvaible);
    390             connect(pActionCopy, &QAction::triggered, this, &UIGuestControlFileView::sigCopy);
    391         }
    392 
    393         pActionCut = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Cut"));
    394         if (pActionCut)
    395         {
    396             pActionCut->setIcon(UIIconPool::iconSet(QString(":/fd_move_32px.png")));
    397             pActionCut->setEnabled(selectionAvaible);
    398             connect(pActionCut, &QAction::triggered, this, &UIGuestControlFileView::sigCut);
    399         }
    400 
    401         pActionPaste = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Paste"));
    402         if (pActionPaste)
    403         {
    404             pActionPaste->setIcon(UIIconPool::iconSet(QString(":/shared_clipboard_16px.png")));
    405             connect(pActionPaste, &QAction::triggered, this, &UIGuestControlFileView::sigPaste);
    406         }
    407     }
    408 
    409     menu->addSeparator();
    410     QAction *pActionShowProperties = menu->addAction(QApplication::translate("UIGuestControlFileManager", "Properties"));
    411     if (pActionShowProperties)
    412     {
    413         pActionShowProperties->setIcon(UIIconPool::iconSet(QString(":/session_info_32px.png")));
    414         pActionShowProperties->setEnabled(selectionAvaible);
    415         connect(pActionShowProperties, &QAction::triggered, this, &UIGuestControlFileView::sigShowProperties);
    416     }
    417 
    418     menu->exec(pEvent->globalPos());
    419 
    420     if (pActionGoUp)
    421         disconnect(pActionGoUp, &QAction::triggered, this, &UIGuestControlFileView::sigGoUp);
    422     if (pActionGoHome)
    423         disconnect(pActionGoHome, &QAction::triggered, this, &UIGuestControlFileView::sigGoHome);
    424     if (pActionRefresh)
    425         disconnect(pActionRefresh, &QAction::triggered, this, &UIGuestControlFileView::sigRefresh);
    426     if (pActionDelete)
    427         disconnect(pActionDelete, &QAction::triggered, this, &UIGuestControlFileView::sigDelete);
    428     if (pActionRename)
    429         disconnect(pActionRename, &QAction::triggered, this, &UIGuestControlFileView::sigRename);
    430     if (pActionCreateNewDirectory)
    431         disconnect(pActionCreateNewDirectory, &QAction::triggered, this, &UIGuestControlFileView::sigCreateNewDirectory);
    432     if (isGuestFileTable)
    433     {
    434         if (pActionCopy)
    435             disconnect(pActionCopy, &QAction::triggered, this, &UIGuestControlFileView::sigCopy);
    436         if (pActionCut)
    437             disconnect(pActionCut, &QAction::triggered, this, &UIGuestControlFileView::sigCut);
    438         if (pActionPaste)
    439             disconnect(pActionPaste, &QAction::triggered, this, &UIGuestControlFileView::sigPaste);
    440     }
    441     if (pActionShowProperties)
    442         disconnect(pActionShowProperties, &QAction::triggered, this, &UIGuestControlFileView::sigShowProperties);
    443 
    444     delete menu;
    445 }
    446 
    447314bool UIGuestControlFileView::hasSelection() const
    448315{
     
    458325    QTableView::selectionChanged(selected, deselected);
    459326}
    460 
    461327
    462328/*********************************************************************************************************************************
     
    559425{
    560426}
    561 
    562427
    563428/*********************************************************************************************************************************
     
    835700        connect(m_pView, &UIGuestControlFileView::clicked,
    836701                this, &UIGuestControlFileTable::sltItemClicked);
    837         connect(m_pView, &UIGuestControlFileView::sigGoUp,
    838                 this, &UIGuestControlFileTable::sltGoUp);
    839         connect(m_pView, &UIGuestControlFileView::sigGoHome,
    840                 this, &UIGuestControlFileTable::sltGoHome);
    841         connect(m_pView, &UIGuestControlFileView::sigRefresh,
    842                 this, &UIGuestControlFileTable::sltRefresh);
    843         connect(m_pView, &UIGuestControlFileView::sigDelete,
    844                 this, &UIGuestControlFileTable::sltDelete);
    845         connect(m_pView, &UIGuestControlFileView::sigRename,
    846                 this, &UIGuestControlFileTable::sltRename);
    847         connect(m_pView, &UIGuestControlFileView::sigCreateNewDirectory,
    848                 this, &UIGuestControlFileTable::sltCreateNewDirectory);
    849         connect(m_pView, &UIGuestControlFileView::sigCopy,
    850                 this, &UIGuestControlFileTable::sltCopy);
    851         connect(m_pView, &UIGuestControlFileView::sigCut,
    852                 this, &UIGuestControlFileTable::sltCut);
    853         connect(m_pView, &UIGuestControlFileView::sigPaste,
    854                 this, &UIGuestControlFileTable::sltPaste);
    855         connect(m_pView, &UIGuestControlFileView::sigShowProperties,
    856                 this, &UIGuestControlFileTable::sltShowProperties);
    857702        connect(m_pView, &UIGuestControlFileView::sigSelectionChanged,
    858703                this, &UIGuestControlFileTable::sltSelectionChanged);
     704        connect(m_pView, &UIGuestControlFileView::customContextMenuRequested,
     705                this, &UIGuestControlFileTable::sltCreateFileViewContextMenu);
    859706
    860707    }
     
    12361083{
    12371084    performSelectionSearch(strText);
     1085}
     1086
     1087void UIGuestControlFileTable::sltCreateFileViewContextMenu(const QPoint &point)
     1088{
     1089    QWidget *pSender = qobject_cast<QWidget*>(sender());
     1090    if (!pSender)
     1091        return;
     1092    createFileViewContextMenu(pSender, point);
    12381093}
    12391094
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlFileTable.h

    r75184 r75202  
    283283    virtual void     determineDriveLetters() = 0;
    284284    virtual void     prepareToolbar() = 0;
     285    virtual void     createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) = 0;
    285286    QString          fileTypeString(FileObjectType type);
    286287    /* @p item index is item location in model not in 'proxy' model */
     
    323324    void sltPaste();
    324325    void sltShowProperties();
     326    void sltSelectAll();
     327    void sltInvertSelection();
     328
     329private slots:
     330
     331    void sltCreateFileViewContextMenu(const QPoint &point);
    325332    void sltSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
    326333    void sltLocationComboCurrentChange(const QString &strLocation);
    327     void sltSelectAll();
    328     void sltInvertSelection();
    329334    void sltSearchTextChanged(const QString &strText);
    330335
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.cpp

    r75193 r75202  
    561561    }
    562562    setSelectionDependentActionsEnabled(false);
     563}
     564
     565void UIGuestFileTable::createFileViewContextMenu(const QWidget *pWidget, const QPoint &/*point*/)
     566{
     567    if (!pWidget)
     568        return;
     569
     570    // QMenu menu;
     571    // menu.exec(mapToGlobal(position));
    563572}
    564573
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestFileTable.h

    r75184 r75202  
    5454    virtual void    determineDriveLetters() /* override */;
    5555    virtual void    prepareToolbar() /* override */;
     56    virtual void    createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */;
    5657
    5758private:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.cpp

    r75184 r75202  
    152152        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Rename));
    153153        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_CreateNewDirectory));
    154         m_pToolBar->addSeparator();
    155         m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Copy));
    156         m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Cut));
    157         m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Paste));
     154        /* Hide cut, copy, and paste for now. We will implement those
     155           when we have an API for host file operations: */
     156        // m_pToolBar->addSeparator();
     157        // m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Copy));
     158        // m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Cut));
     159        // m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Paste));
    158160        m_pToolBar->addSeparator();
    159161        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_SelectAll));
     
    164166        m_selectionDependentActions.insert(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Delete));
    165167        m_selectionDependentActions.insert(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Rename));
    166         m_selectionDependentActions.insert(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Copy));
    167         m_selectionDependentActions.insert(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Cut));
    168168        m_selectionDependentActions.insert(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_ShowProperties));
    169169    }
    170170
     171    setSelectionDependentActionsEnabled(false);
     172}
     173
     174void UIHostFileTable::createFileViewContextMenu(const QWidget *pWidget, const QPoint &point)
     175{
     176    if (!pWidget)
     177        return;
     178
     179    QMenu menu;
     180    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_GoUp));
     181
     182    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_GoHome));
     183    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Refresh));
     184    menu.addSeparator();
     185    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Delete));
     186    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Rename));
     187    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_CreateNewDirectory));
    171188    /* Hide cut, copy, and paste for now. We will implement those
    172189       when we have an API for host file operations: */
    173     // if (m_pCopy)
    174     //     m_pCopy->setVisible(false);
    175     // if (m_pCut)
    176     //     m_pCut->setVisible(false);
    177     // if (m_pPaste)
    178     //     m_pPaste->setVisible(false);
    179     setSelectionDependentActionsEnabled(false);
     190    // menu.addSeparator();
     191    // menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Copy));
     192    // menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Cut));
     193    // menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_Paste));
     194    menu.addSeparator();
     195    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_SelectAll));
     196    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_InvertSelection));
     197    menu.addSeparator();
     198    menu.addAction(m_pActionPool->action(UIActionIndex_M_GuestControlFileManager_S_Host_ShowProperties));
     199
     200
     201
     202    menu.exec(pWidget->mapToGlobal(point));
    180203}
    181204
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIHostFileTable.h

    r75184 r75202  
    4848    virtual void    determineDriveLetters() /* override */;
    4949    virtual void    prepareToolbar() /* override */;
     50    virtual void    createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) /* override */;
    5051
    5152private:
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