VirtualBox

Changeset 94797 in vbox for trunk


Ignore:
Timestamp:
May 3, 2022 6:21:34 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10081. Implementing slot for the clear action.

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

Legend:

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

    r94757 r94797  
    13141314}
    13151315
     1316bool UIMessageCenter::confirmDVDListClear(const QStringList &DVDPathList, QWidget *pParent /* = 0 */)
     1317{
     1318    if (DVDPathList.isEmpty())
     1319        return false;
     1320
     1321    QString strDetails("<!--EOM-->");
     1322    QString strDetailMessage(tr("The list of inaccessible DVDs is as follows:"));
     1323
     1324    if (!strDetailMessage.isEmpty())
     1325        strDetails.prepend(QString("<p>%1.</p>").arg(UITranslator::emphasize(strDetailMessage)));
     1326
     1327    strDetails += QString("<table bgcolor=%1 border=0 cellspacing=5 cellpadding=0 width=100%>")
     1328                         .arg(QApplication::palette().color(QPalette::Active, QPalette::Window).name(QColor::HexRgb));
     1329    foreach (const QString &strDVD, DVDPathList)
     1330        strDetails += QString("<tr><td>%1</td></tr>").arg(strDVD);
     1331    strDetails += QString("</table>");
     1332
     1333    if (!strDetails.isEmpty())
     1334        strDetails = "<qt>" + strDetails + "</qt>";
     1335
     1336    return message(pParent,
     1337                   MessageType_Question,
     1338                   tr("<p>This will clear the optical disk list by releasing inaccessible DVDs"
     1339                      " from the virtual machines they are attached to"
     1340                      " and remove them from the list of registered media.<p>"
     1341                      "Are you sure?"),
     1342                   strDetails,
     1343                   0 /* auto-confirm id */,
     1344                   AlertButton_Ok,
     1345                   AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
     1346                   0 /* third button */,
     1347                   tr("Clear") /* ok button text */,
     1348                   QString() /* cancel button text */,
     1349                   QString() /* 3rd button text */,
     1350                   QString() /* help keyword */);
     1351}
     1352
    13161353bool UIMessageCenter::confirmCloudNetworkRemoval(const QString &strName, QWidget *pParent /* = 0*/) const
    13171354{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r94757 r94797  
    353353        bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const;
    354354        int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const;
     355        bool confirmDVDListClear(const QStringList &DVDPathList, QWidget *pParent = 0);
    355356    /** @} */
    356357
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp

    r93115 r94797  
    9191}
    9292
    93 bool UIMediumItem::release(bool fInduced /* = false */)
     93bool UIMediumItem::release(bool fShowMessageBox, bool fInduced)
    9494{
    9595    /* Refresh medium and item: */
     
    102102
    103103    /* Confirm release: */
    104     if (!msgCenter().confirmMediumRelease(medium(), fInduced, treeWidget()))
    105         return false;
     104    if (fShowMessageBox)
     105        if (!msgCenter().confirmMediumRelease(medium(), fInduced, treeWidget()))
     106            return false;
    106107
    107108    /* Release: */
     
    193194
    194195    /* Detach the medium from all the VMs it's attached to: */
    195     if (!release(true))
     196    if (!release(true, true))
    196197        return false;
    197198
     
    402403}
    403404
    404 bool UIMediumItemHD::remove()
     405bool UIMediumItemHD::remove(bool fShowMessageBox)
    405406{
    406407    /* Confirm medium removal: */
    407     if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
    408         return false;
     408    if (fShowMessageBox)
     409        if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
     410            return false;
    409411
    410412    /* Propose to remove medium storage: */
     
    507509}
    508510
    509 bool UIMediumItemCD::remove()
     511bool UIMediumItemCD::remove(bool fShowMessageBox)
    510512{
    511513    /* Confirm medium removal: */
    512     if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
    513         return false;
     514    if (fShowMessageBox)
     515        if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
     516            return false;
    514517
    515518    /* Close optical-disk: */
     
    568571}
    569572
    570 bool UIMediumItemFD::remove()
     573bool UIMediumItemFD::remove(bool fShowMessageBox)
    571574{
    572575    /* Confirm medium removal: */
    573     if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
    574         return false;
     576    if (fShowMessageBox)
     577        if (!msgCenter().confirmMediumRemoval(medium(), treeWidget()))
     578            return false;
    575579
    576580    /* Close floppy-disk: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.h

    r93990 r94797  
    5050    virtual bool move();
    5151    /** Removes UIMedium wrapped by <i>this</i> item. */
    52     virtual bool remove() = 0;
     52    virtual bool remove(bool fShowMessageBox) = 0;
    5353    /** Releases UIMedium wrapped by <i>this</i> item.
    5454      * @param  fInduced  Brings whether this action is caused by other user's action,
    5555      *                   not a direct order to release particularly selected medium. */
    56     virtual bool release(bool fInduced = false);
     56    virtual bool release(bool fShowMessageBox, bool fInduced);
    5757
    5858    /** Refreshes item fully. */
     
    181181
    182182    /** Removes UIMedium wrapped by <i>this</i> item. */
    183     virtual bool remove() RT_OVERRIDE;
     183    virtual bool remove(bool fShowMessageBox) RT_OVERRIDE;
    184184    /** Releases UIMedium wrapped by <i>this</i> item from virtual @a comMachine. */
    185185    virtual bool releaseFrom(CMachine comMachine) RT_OVERRIDE;
     
    208208
    209209    /** Removes UIMedium wrapped by <i>this</i> item. */
    210     virtual bool remove() RT_OVERRIDE;
     210    virtual bool remove(bool fShowMessageBox) RT_OVERRIDE;
    211211    /** Releases UIMedium wrapped by <i>this</i> item from virtual @a comMachine. */
    212212    virtual bool releaseFrom(CMachine comMachine) RT_OVERRIDE;
     
    230230
    231231    /** Removes UIMedium wrapped by <i>this</i> item. */
    232     virtual bool remove() RT_OVERRIDE;
     232    virtual bool remove(bool fShowMessageBox) RT_OVERRIDE;
    233233    /** Releases UIMedium wrapped by <i>this</i> item from virtual @a comMachine. */
    234234    virtual bool releaseFrom(CMachine comMachine) RT_OVERRIDE;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r94294 r94797  
    507507
    508508    /* Remove current medium-item: */
    509     pMediumItem->remove();
     509    pMediumItem->remove(true /* show message box */);
    510510}
    511511
     
    518518
    519519    /* Remove current medium-item: */
    520     bool fResult = pMediumItem->release();
     520    bool fResult = pMediumItem->release(true /* show message box */, false /* induced */);
    521521
    522522    /* Refetch currently chosen medium-item: */
     
    527527void UIMediumManagerWidget::sltClear()
    528528{
     529    /* Currently we clear only DVD medium type items: */
     530    if (currentMediumType() != UIMediumDeviceType_DVD)
     531        return;
     532    QITreeWidget* pTreeWidget = currentTreeWidget();
     533    AssertReturnVoid(pTreeWidget);
     534    /* Iterate over the tree items assuming medium items are immediate children of the root and they dont have children
     535    *  themselves which currently holds for DVD medium type: */
     536    QList<UIMediumItem*> mediumsToRemove;
     537    QStringList nameList;
     538    for (int i = 0; i < pTreeWidget->childCount(); ++i)
     539    {
     540        UIMediumItem *pMediumItem = qobject_cast<UIMediumItem*>(pTreeWidget->childItem(i));
     541        if (!pMediumItem)
     542            continue;
     543        if (pMediumItem->state() == KMediumState_Inaccessible)
     544        {
     545            mediumsToRemove << pMediumItem;
     546            nameList << pMediumItem->name();
     547        }
     548    }
     549    if (!msgCenter().confirmDVDListClear(nameList, this))
     550        return;
     551
     552    foreach (UIMediumItem *pMediumItem, mediumsToRemove)
     553    {
     554        pMediumItem->release(false /* no messag box */, false /* induced */);
     555        pMediumItem->remove(false /* show no message box */);
     556    }
    529557}
    530558
     
    601629    if (m_pDetailsWidget)
    602630        m_pDetailsWidget->setCurrentType(currentMediumType());
     631
     632    /* Clear action is enabled only for DVD medium type: */
     633    if (m_pActionPool && m_pActionPool->action(UIActionIndexMN_M_Medium_S_Clear))
     634        m_pActionPool->action(UIActionIndexMN_M_Medium_S_Clear)->setEnabled(currentMediumType() == UIMediumDeviceType_DVD);
     635
    603636    /* Re-fetch currently chosen medium-item: */
    604637    refetchCurrentChosenMediumItem();
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