VirtualBox

Ignore:
Timestamp:
Jun 30, 2017 8:36:52 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116565
Message:

FE/Qt: bugref:8400: Virtual Media Manager: A bit of action related rework.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r67704 r67718  
    754754    , m_pContextMenu(0)
    755755    , m_pMenu(0)
    756     , m_pActionCopy(0), m_pActionModify(0)
    757     , m_pActionRemove(0), m_pActionRelease(0)
     756    , m_pActionCopy(0), m_pActionRemove(0)
     757    , m_pActionRelease(0), m_pActionModify(0)
    758758    , m_pActionRefresh(0)
    759759    , m_pProgressBar(0)
     
    776776        m_pActionCopy->setStatusTip(UIMediumManager::tr("Copy an existing disk image file"));
    777777    }
     778    if (m_pActionRemove)
     779    {
     780        m_pActionRemove->setText(UIMediumManager::tr("R&emove"));
     781        m_pActionRemove->setToolTip(m_pActionRemove->text().remove('&') + QString(" (%1)").arg(m_pActionRemove->shortcut().toString()));
     782        m_pActionRemove->setStatusTip(UIMediumManager::tr("Remove the selected disk image file"));
     783    }
     784    if (m_pActionRelease)
     785    {
     786        m_pActionRelease->setText(UIMediumManager::tr("Re&lease"));
     787        m_pActionRelease->setToolTip(m_pActionRelease->text().remove('&') + QString(" (%1)").arg(m_pActionRelease->shortcut().toString()));
     788        m_pActionRelease->setStatusTip(UIMediumManager::tr("Release the selected disk image file by detaching it from the machines"));
     789    }
    778790    if (m_pActionModify)
    779791    {
     
    781793        m_pActionModify->setToolTip(m_pActionModify->text().remove('&') + QString(" (%1)").arg(m_pActionModify->shortcut().toString()));
    782794        m_pActionModify->setStatusTip(UIMediumManager::tr("Modify the attributes of the selected disk image file"));
    783     }
    784     if (m_pActionRemove)
    785     {
    786         m_pActionRemove->setText(UIMediumManager::tr("R&emove"));
    787         m_pActionRemove->setToolTip(m_pActionRemove->text().remove('&') + QString(" (%1)").arg(m_pActionRemove->shortcut().toString()));
    788         m_pActionRemove->setStatusTip(UIMediumManager::tr("Remove the selected disk image file"));
    789     }
    790     if (m_pActionRelease)
    791     {
    792         m_pActionRelease->setText(UIMediumManager::tr("Re&lease"));
    793         m_pActionRelease->setToolTip(m_pActionRelease->text().remove('&') + QString(" (%1)").arg(m_pActionRelease->shortcut().toString()));
    794         m_pActionRelease->setStatusTip(UIMediumManager::tr("Release the selected disk image file by detaching it from the machines"));
    795795    }
    796796    if (m_pActionRefresh)
     
    10261026}
    10271027
    1028 void UIMediumManagerWidget::sltModifyMedium()
     1028void UIMediumManagerWidget::sltRemoveMedium()
    10291029{
    10301030    /* Get current medium-item: */
     
    10331033    AssertReturnVoid(!pMediumItem->id().isNull());
    10341034
    1035     /* Modify current medium-item: */
    1036     bool fResult = pMediumItem->modify();
    1037 
    1038     /* Update HD information-panes: */
    1039     if (fResult)
    1040         updateInformationFieldsHD();
    1041 }
    1042 
    1043 void UIMediumManagerWidget::sltRemoveMedium()
     1035    /* Remove current medium-item: */
     1036    pMediumItem->remove();
     1037}
     1038
     1039void UIMediumManagerWidget::sltReleaseMedium()
    10441040{
    10451041    /* Get current medium-item: */
     
    10491045
    10501046    /* Remove current medium-item: */
    1051     pMediumItem->remove();
    1052 }
    1053 
    1054 void UIMediumManagerWidget::sltReleaseMedium()
     1047    bool fResult = pMediumItem->release();
     1048
     1049    /* Refetch currently chosen medium-item: */
     1050    if (fResult)
     1051        refetchCurrentChosenMediumItem();
     1052}
     1053
     1054void UIMediumManagerWidget::sltModifyMedium()
    10551055{
    10561056    /* Get current medium-item: */
     
    10591059    AssertReturnVoid(!pMediumItem->id().isNull());
    10601060
    1061     /* Remove current medium-item: */
    1062     bool fResult = pMediumItem->release();
    1063 
    1064     /* Refetch currently chosen medium-item: */
     1061    /* Modify current medium-item: */
     1062    bool fResult = pMediumItem->modify();
     1063
     1064    /* Update HD information-panes: */
    10651065    if (fResult)
    1066         refetchCurrentChosenMediumItem();
     1066        updateInformationFieldsHD();
    10671067}
    10681068
     
    12201220    }
    12211221
     1222    /* Create 'Remove' action: */
     1223    m_pActionRemove  = new QAction(this);
     1224    AssertPtrReturnVoid(m_pActionRemove);
     1225    {
     1226        /* Configure remove-action: */
     1227        m_pActionRemove->setShortcut(QKeySequence(QKeySequence::Delete));
     1228        connect(m_pActionRemove, SIGNAL(triggered()), this, SLOT(sltRemoveMedium()));
     1229    }
     1230
     1231    /* Create 'Release' action: */
     1232    m_pActionRelease = new QAction(this);
     1233    AssertPtrReturnVoid(m_pActionRelease);
     1234    {
     1235        /* Configure release-action: */
     1236        m_pActionRelease->setShortcut(QKeySequence("Ctrl+L"));
     1237        connect(m_pActionRelease, SIGNAL(triggered()), this, SLOT(sltReleaseMedium()));
     1238    }
     1239
    12221240    /* Create 'Modify' action: */
    12231241    m_pActionModify = new QAction(this);
     
    12271245        m_pActionModify->setShortcut(QKeySequence("Ctrl+Space"));
    12281246        connect(m_pActionModify, SIGNAL(triggered()), this, SLOT(sltModifyMedium()));
    1229     }
    1230 
    1231     /* Create 'Remove' action: */
    1232     m_pActionRemove  = new QAction(this);
    1233     AssertPtrReturnVoid(m_pActionRemove);
    1234     {
    1235         /* Configure remove-action: */
    1236         m_pActionRemove->setShortcut(QKeySequence(QKeySequence::Delete));
    1237         connect(m_pActionRemove, SIGNAL(triggered()), this, SLOT(sltRemoveMedium()));
    1238     }
    1239 
    1240     /* Create 'Release' action: */
    1241     m_pActionRelease = new QAction(this);
    1242     AssertPtrReturnVoid(m_pActionRelease);
    1243     {
    1244         /* Configure release-action: */
    1245         m_pActionRelease->setShortcut(QKeySequence("Ctrl+L"));
    1246         connect(m_pActionRelease, SIGNAL(triggered()), this, SLOT(sltReleaseMedium()));
    12471247    }
    12481248
     
    12711271    AssertPtrReturnVoid(m_pMenu);
    12721272    {
    1273         /* Configure 'Actions' menu: */
    1274         m_pMenu->addAction(m_pActionCopy);
    1275         m_pMenu->addAction(m_pActionModify);
    1276         m_pMenu->addAction(m_pActionRemove);
    1277         m_pMenu->addAction(m_pActionRelease);
    1278         m_pMenu->addAction(m_pActionRefresh);
     1273        /* Configure 'Medium' menu: */
     1274        if (m_pActionCopy)
     1275            m_pMenu->addAction(m_pActionCopy);
     1276        if (m_pActionRemove)
     1277            m_pMenu->addAction(m_pActionRemove);
     1278        if (   (m_pActionCopy || m_pActionRemove)
     1279            && (m_pActionRelease || m_pActionModify))
     1280            m_pMenu->addSeparator();
     1281        if (m_pActionRelease)
     1282            m_pMenu->addAction(m_pActionRelease);
     1283        if (m_pActionModify)
     1284            m_pMenu->addAction(m_pActionModify);
     1285        if (   (m_pActionRelease || m_pActionModify)
     1286            && (m_pActionRefresh))
     1287            m_pMenu->addSeparator();
     1288        if (m_pActionRefresh)
     1289            m_pMenu->addAction(m_pActionRefresh);
    12791290    }
    12801291}
     
    12871298    {
    12881299        /* Configure contex-menu: */
    1289         m_pContextMenu->addAction(m_pActionCopy);
    1290         m_pContextMenu->addAction(m_pActionModify);
    1291         m_pContextMenu->addAction(m_pActionRemove);
    1292         m_pContextMenu->addAction(m_pActionRelease);
     1300        if (m_pActionCopy)
     1301            m_pContextMenu->addAction(m_pActionCopy);
     1302        if (m_pActionRemove)
     1303            m_pContextMenu->addAction(m_pActionRemove);
     1304        if (   (m_pActionCopy || m_pActionRemove)
     1305            && (m_pActionRelease || m_pActionModify))
     1306            m_pContextMenu->addSeparator();
     1307        if (m_pActionRelease)
     1308            m_pContextMenu->addAction(m_pActionRelease);
     1309        if (m_pActionModify)
     1310            m_pContextMenu->addAction(m_pActionModify);
    12931311    }
    12941312}
     
    13281346        if (m_pActionCopy)
    13291347            m_pToolBar->addAction(m_pActionCopy);
     1348        if (m_pActionRemove)
     1349            m_pToolBar->addAction(m_pActionRemove);
     1350        if (   (m_pActionCopy || m_pActionRemove)
     1351            && (m_pActionModify || m_pActionRelease))
     1352            m_pToolBar->addSeparator();
     1353        if (m_pActionRelease)
     1354            m_pToolBar->addAction(m_pActionRelease);
    13301355        if (m_pActionModify)
    13311356            m_pToolBar->addAction(m_pActionModify);
    1332         if (m_pActionRemove)
    1333             m_pToolBar->addAction(m_pActionRemove);
    1334         if (m_pActionRelease)
    1335             m_pToolBar->addAction(m_pActionRelease);
     1357        if (   (m_pActionModify || m_pActionRelease)
     1358            && (m_pActionRefresh))
     1359            m_pToolBar->addSeparator();
    13361360        if (m_pActionRefresh)
    13371361            m_pToolBar->addAction(m_pActionRefresh);
     1362
    13381363#ifdef VBOX_WS_MAC
    13391364        /* Check whether we are embedded into a stack: */
     
    13651390        m_pTabWidget->setTabIcon(tabIndex(UIMediumType_Floppy), m_iconFD);
    13661391        connect(m_pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged()));
     1392
    13671393        /* Add tab-widget into central layout: */
    13681394        layout()->addWidget(m_pTabWidget);
     1395
    13691396        /* Update other widgets according chosen tab: */
    13701397        sltHandleCurrentTabChanged();
     
    15971624        m_pActionCopy->setEnabled(fActionEnabledCopy);
    15981625    }
     1626    if (m_pActionRemove)
     1627    {
     1628        bool fActionEnabledRemove = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Remove);
     1629        m_pActionRemove->setEnabled(fActionEnabledRemove);
     1630    }
     1631    if (m_pActionRelease)
     1632    {
     1633        bool fActionEnabledRelease = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Release);
     1634        m_pActionRelease->setEnabled(fActionEnabledRelease);
     1635    }
    15991636    if (m_pActionModify)
    16001637    {
     
    16021639                                    fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Modify);
    16031640        m_pActionModify->setEnabled(fActionEnabledModify);
    1604     }
    1605     if (m_pActionRemove)
    1606     {
    1607         bool fActionEnabledRemove = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Remove);
    1608         m_pActionRemove->setEnabled(fActionEnabledRemove);
    1609     }
    1610     if (m_pActionRelease)
    1611     {
    1612         bool fActionEnabledRelease = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Release);
    1613         m_pActionRelease->setEnabled(fActionEnabledRelease);
    16141641    }
    16151642}
     
    16331660                                                       QString(":/%1_copy_disabled_22px.png").arg(strPrefix),
    16341661                                                       QString(":/%1_copy_disabled_16px.png").arg(strPrefix)));
    1635     if (m_pActionModify)
    1636         m_pActionModify->setIcon(UIIconPool::iconSetFull(QString(":/%1_modify_22px.png").arg(strPrefix),
    1637                                                          QString(":/%1_modify_16px.png").arg(strPrefix),
    1638                                                          QString(":/%1_modify_disabled_22px.png").arg(strPrefix),
    1639                                                          QString(":/%1_modify_disabled_16px.png").arg(strPrefix)));
    16401662    if (m_pActionRemove)
    16411663        m_pActionRemove->setIcon(UIIconPool::iconSetFull(QString(":/%1_remove_22px.png").arg(strPrefix),
     
    16481670                                                          QString(":/%1_release_disabled_22px.png").arg(strPrefix),
    16491671                                                          QString(":/%1_release_disabled_16px.png").arg(strPrefix)));
     1672    if (m_pActionModify)
     1673        m_pActionModify->setIcon(UIIconPool::iconSetFull(QString(":/%1_modify_22px.png").arg(strPrefix),
     1674                                                         QString(":/%1_modify_16px.png").arg(strPrefix),
     1675                                                         QString(":/%1_modify_disabled_22px.png").arg(strPrefix),
     1676                                                         QString(":/%1_modify_disabled_16px.png").arg(strPrefix)));
    16501677    if (m_pActionRefresh && m_pActionRefresh->icon().isNull())
    16511678        m_pActionRefresh->setIcon(UIIconPool::iconSetFull(":/refresh_22px.png", ":/refresh_16px.png",
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r67704 r67718  
    107107        /** Handles command to copy medium. */
    108108        void sltCopyMedium();
    109         /** Handles command to modify medium. */
    110         void sltModifyMedium();
    111109        /** Handles command to remove medium. */
    112110        void sltRemoveMedium();
    113111        /** Handles command to release medium. */
    114112        void sltReleaseMedium();
     113        /** Handles command to modify medium. */
     114        void sltModifyMedium();
    115115        /** Handles command to refresh medium. */
    116116        void sltRefreshAll();
     
    309309        /** Holds the Copy action instance. */
    310310        QAction   *m_pActionCopy;
    311         /** Holds the Modify action instance. */
    312         QAction   *m_pActionModify;
    313311        /** Holds the Remove action instance. */
    314312        QAction   *m_pActionRemove;
    315313        /** Holds the Release action instance. */
    316314        QAction   *m_pActionRelease;
     315        /** Holds the Modify action instance. */
     316        QAction   *m_pActionModify;
    317317        /** Holds the Refresh action instance. */
    318318        QAction   *m_pActionRefresh;
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