VirtualBox

Ignore:
Timestamp:
Aug 17, 2018 12:43:50 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: Media Manager: Fix few small action related aspects.

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

Legend:

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

    r73718 r73734  
    18351835    {
    18361836        setName(QApplication::translate("UIActionPool", "&Add..."));
    1837         setStatusTip(QApplication::translate("UIActionPool", "Add a Disk Image File"));
     1837        setStatusTip(QApplication::translate("UIActionPool", "Add a disk image file"));
    18381838        setToolTip(tr("Add a Disk Image File (%1)").arg(shortcut().toString()));
    18391839    }
     
    22392239    /* 'Remove' action: */
    22402240    fSeparator = addAction(pMenu, action(UIActionIndexST_M_Medium_S_Remove)) || fSeparator;
     2241    /* 'Release' action: */
     2242    fSeparator = addAction(pMenu, action(UIActionIndexST_M_Medium_S_Release)) || fSeparator;
    22412243
    22422244    /* Separator? */
     
    22472249    }
    22482250
    2249     /* 'Release' action: */
    2250     fSeparator = addAction(pMenu, action(UIActionIndexST_M_Medium_S_Release)) || fSeparator;
    22512251    /* 'Properties' action: */
    22522252    fSeparator = addAction(pMenu, action(UIActionIndexST_M_Medium_T_Details)) || fSeparator;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r73723 r73734  
    166166    , m_pDetailsWidget(0)
    167167    , m_pToolBar(0)
    168     , m_pContextMenu(0)
    169168    , m_pProgressBar(0)
    170169{
     
    189188void UIMediumManagerWidget::retranslateUi()
    190189{
    191     /* Translate toolbar: */
     190    /* Adjust toolbar: */
    192191#ifdef VBOX_WS_MAC
    193192    // WORKAROUND:
     
    617616}
    618617
    619 void UIMediumManagerWidget::sltHandleContextMenuCall(const QPoint &position)
     618void UIMediumManagerWidget::sltHandleContextMenuRequest(const QPoint &position)
    620619{
    621620    /* Get current tree-widget: */
     
    623622    AssertPtrReturnVoid(pTreeWidget);
    624623
    625     /* Make sure underlaying item was found: */
     624    /* If underlaying item was found => make sure that item is current one: */
    626625    QTreeWidgetItem *pItem = pTreeWidget->itemAt(position);
    627     if (!pItem)
    628         return;
    629 
    630     /* Make sure that item is current one: */
    631     setCurrentItem(pTreeWidget, pItem);
    632 
    633     /* Show item context menu: */
    634     if (m_pContextMenu)
    635         m_pContextMenu->exec(pTreeWidget->viewport()->mapToGlobal(position));
     626    if (pItem)
     627        setCurrentItem(pTreeWidget, pItem);
     628
     629    /* Compose temporary context-menu: */
     630    QMenu menu;
     631    if (pTreeWidget->itemAt(position))
     632    {
     633        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Copy));
     634        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Move));
     635        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Remove));
     636        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Release));
     637        menu.addSeparator();
     638        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_T_Details));
     639    }
     640    else
     641    {
     642        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Add));
     643        menu.addSeparator();
     644        menu.addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Refresh));
     645    }
     646    /* And show it: */
     647    menu.exec(pTreeWidget->viewport()->mapToGlobal(position));
    636648}
    637649
     
    734746    /* Update action icons: */
    735747    updateActionIcons();
    736 
    737     /* Prepare context-menu: */
    738     prepareContextMenu();
    739 }
    740 
    741 void UIMediumManagerWidget::prepareContextMenu()
    742 {
    743     /* Create context-menu: */
    744     m_pContextMenu = new QMenu(this);
    745     AssertPtrReturnVoid(m_pContextMenu);
    746     {
    747         /* Configure contex-menu: */
    748         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Add));
    749         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Copy));
    750         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Move));
    751         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Remove));
    752         m_pContextMenu->addSeparator();
    753         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Release));
    754         m_pContextMenu->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_T_Details));
    755     }
    756748}
    757749
     
    795787        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Move));
    796788        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Remove));
     789        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Release));
    797790        m_pToolBar->addSeparator();
    798         m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_S_Release));
    799791        m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Medium_T_Details));
    800792        m_pToolBar->addSeparator();
     
    890882                m_pActionPool->action(UIActionIndexST_M_Medium_T_Details), &QAction::setChecked);
    891883        connect(pTreeWidget, &QITreeWidget::customContextMenuRequested,
    892                 this, &UIMediumManagerWidget::sltHandleContextMenuCall);
     884                this, &UIMediumManagerWidget::sltHandleContextMenuRequest);
    893885        connect(pTreeWidget, &QITreeWidget::resized,
    894886                this, &UIMediumManagerWidget::sltPerformTablesAdjustment, Qt::QueuedConnection);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r73721 r73734  
    188188        void sltHandleCurrentItemChanged();
    189189        /** Handles item context-menu-call case. */
    190         void sltHandleContextMenuCall(const QPoint &position);
     190        void sltHandleContextMenuRequest(const QPoint &position);
    191191    /** @} */
    192192
     
    209209        /** Prepares actions. */
    210210        void prepareActions();
    211         /** Prepares context-menu. */
    212         void prepareContextMenu();
    213211        /** Prepares widgets. */
    214212        void prepareWidgets();
     
    348346        /** Holds the toolbar widget instance. */
    349347        UIToolBar *m_pToolBar;
    350         /** Holds the context-menu object instance. */
    351         QMenu     *m_pContextMenu;
    352348    /** @} */
    353349
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