VirtualBox

Ignore:
Timestamp:
Jul 7, 2017 5:40:58 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116819
Message:

FE/Qt: bugref:8400: Virtual Media Manager: Implementing possibility to change medium name/location.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc

    r67815 r67863  
    5050        <file alias="progress_media_create_90px.png">images/progress_media_create_90px.png</file>
    5151        <file alias="progress_media_delete_90px.png">images/progress_media_delete_90px.png</file>
     52        <file alias="progress_media_move_90px.png">images/progress_media_move_90px.png</file>
    5253        <file alias="progress_network_interface_90px.png">images/progress_network_interface_90px.png</file>
    5354        <file alias="progress_poweroff_90px.png">images/progress_poweroff_90px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2_hidpi.qrc

    r67815 r67863  
    5959        <file alias="progress_media_create_90px_hidpi.png">images/hidpi/progress_media_create_90px_hidpi.png</file>
    6060        <file alias="progress_media_delete_90px_hidpi.png">images/hidpi/progress_media_delete_90px_hidpi.png</file>
     61        <file alias="progress_media_move_90px_hidpi.png">images/hidpi/progress_media_move_90px_hidpi.png</file>
    6162        <file alias="progress_network_interface_90px_hidpi.png">images/hidpi/progress_network_interface_90px_hidpi.png</file>
    6263        <file alias="progress_poweroff_90px_hidpi.png">images/hidpi/progress_poweroff_90px_hidpi.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r67471 r67863  
    13251325             .arg(strLocation),
    13261326          formatErrorInfo(progress));
     1327}
     1328
     1329void UIMessageCenter::cannotMoveHardDiskStorage(const CMedium &comMedium, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent /* = 0 */) const
     1330{
     1331    error(pParent, MessageType_Error,
     1332          tr("Failed to move the storage unit of the hard disk <b>%1</b> to <b>%2</b>.")
     1333             .arg(strLocationOld, strLocationNew),
     1334          formatErrorInfo(comMedium));
     1335}
     1336
     1337void UIMessageCenter::cannotMoveHardDiskStorage(const CProgress &comProgress, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent /* = 0 */) const
     1338{
     1339    error(pParent, MessageType_Error,
     1340          tr("Failed to move the storage unit of the hard disk <b>%1</b> to <b>%2</b>.")
     1341             .arg(strLocationOld, strLocationNew),
     1342          formatErrorInfo(comProgress));
    13271343}
    13281344
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r67471 r67863  
    250250    void cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const;
    251251    void cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const;
     252    void cannotMoveHardDiskStorage(const CMedium &comMedium, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent = 0) const;
     253    void cannotMoveHardDiskStorage(const CProgress &comProgress, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent = 0) const;
    252254    void cannotDetachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0) const;
    253255    bool cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp

    r67810 r67863  
    3232# include "QITabWidget.h"
    3333# include "UIConverter.h"
     34# include "UIFilePathSelector.h"
    3435# include "UIIconPool.h"
    3536# include "UIMediumDetailsWidget.h"
     
    4445    , m_newData(UIDataMedium())
    4546    , m_pTabWidget(0)
    46     , m_pLabelType(0)
    47     , m_pComboBoxType(0)
    48     , m_pErrorPaneType(0)
     47    , m_pLabelType(0), m_pComboBoxType(0), m_pErrorPaneType(0)
     48    , m_pLabelLocation(0), m_pSelectorLocation(0), m_pErrorPaneLocation(0)
    4949    , m_pButtonBox(0)
    5050    , m_pLayoutDetails(0)
     
    8181    /* Translate 'Options' tab content. */
    8282
    83     /* Translate type label: */
    84     m_pLabelType->setText(tr("&Type"));
    85 
    86     /* Translate type field: */
     83    /* Translate labels: */
     84    m_pLabelType->setText(tr("&Type:"));
     85    m_pLabelLocation->setText(tr("&Location:"));
     86
     87    /* Translate fields: */
    8788    m_pComboBoxType->setToolTip(tr("Holds the type of this medium."));
    8889    for (int i = 0; i < m_pComboBoxType->count(); ++i)
    8990        m_pComboBoxType->setItemText(i, gpConverter->toString(m_pComboBoxType->itemData(i).value<KMediumType>()));
     91    m_pSelectorLocation->setToolTip(tr("Holds the location of this medium."));
    9092
    9193    /* Translate button-box: */
     
    114116    m_newData.m_options.m_enmType = m_pComboBoxType->itemData(iIndex).value<KMediumType>();
    115117    revalidate(m_pErrorPaneType);
     118    updateButtonStates();
     119}
     120
     121void UIMediumDetailsWidget::sltLocationPathChanged(const QString &strPath)
     122{
     123    m_newData.m_options.m_strLocation = strPath;
     124    revalidate(m_pErrorPaneLocation);
    116125    updateButtonStates();
    117126}
     
    238247            }
    239248
     249            /* Create location label: */
     250            m_pLabelLocation = new QLabel;
     251            AssertPtrReturnVoid(m_pLabelLocation);
     252            {
     253                /* Configure label: */
     254                m_pLabelLocation->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     255                /* Add into layout: */
     256                pLayoutOptions->addWidget(m_pLabelLocation, 1, 0);
     257            }
     258            /* Create location layout: */
     259            QHBoxLayout *pLayoutLocation = new QHBoxLayout;
     260            AssertPtrReturnVoid(pLayoutLocation);
     261            {
     262                /* Configure layout: */
     263                pLayoutLocation->setContentsMargins(0, 0, 0, 0);
     264                /* Create location editor: */
     265                m_pSelectorLocation = new UIFilePathSelector;
     266                AssertPtrReturnVoid(m_pSelectorLocation);
     267                {
     268                    /* Configure editor: */
     269                    m_pLabelLocation->setBuddy(m_pSelectorLocation);
     270                    m_pSelectorLocation->setResetEnabled(false);
     271                    m_pSelectorLocation->setMode(UIFilePathSelector::Mode_File_Save);
     272                    m_pSelectorLocation->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     273                    connect(m_pSelectorLocation, &UIFilePathSelector::pathChanged,
     274                            this, &UIMediumDetailsWidget::sltLocationPathChanged);
     275
     276                    /* Add into layout: */
     277                    pLayoutLocation->addWidget(m_pSelectorLocation);
     278                }
     279                /* Create location error pane: */
     280                m_pErrorPaneLocation = new QLabel;
     281                AssertPtrReturnVoid(m_pErrorPaneLocation);
     282                {
     283                    /* Configure label: */
     284                    m_pErrorPaneLocation->setAlignment(Qt::AlignCenter);
     285                    m_pErrorPaneLocation->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
     286                                                    .pixmap(QSize(iIconMetric, iIconMetric)));
     287                    /* Add into layout: */
     288                    pLayoutLocation->addWidget(m_pErrorPaneLocation);
     289                }
     290                /* Add into layout: */
     291                pLayoutOptions->addLayout(pLayoutLocation, 1, 1);
     292            }
     293
    240294            /* Create stretch: */
    241295            QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
     
    243297            {
    244298                /* Add into layout: */
    245                 pLayoutOptions->addItem(pSpacer2, 1, 0, 1, 2);
     299                pLayoutOptions->addItem(pSpacer2, 2, 0, 1, 2);
    246300            }
    247301
     
    380434            m_pComboBoxType->setCurrentIndex(i);
    381435    sltTypeIndexChanged(m_pComboBoxType->currentIndex());
     436
     437    /* Load location: */
     438    m_pSelectorLocation->setPath(m_newData.m_options.m_strLocation);
     439    sltLocationPathChanged(m_pSelectorLocation->path());
    382440}
    383441
     
    408466        m_pErrorPaneType->setVisible(fError);
    409467    }
     468    if (!pWidget || pWidget == m_pErrorPaneLocation)
     469    {
     470        /* Always valid for now: */
     471        const bool fError = false;
     472        m_pErrorPaneLocation->setVisible(fError);
     473    }
    410474
    411475    /* Retranslate validation: */
     
    417481    /* Translate 'Interface' tab content: */
    418482//    if (!pWidget || pWidget == m_pErrorPaneType)
    419 //        m_pErrorPaneType->setToolTip(tr("Cannot directly change from type <b>%1</b> to type <b>%2</b>.")
    420 //                                     .arg(m_oldData.m_enmType).arg(m_newData.m_enmType));
     483//        m_pErrorPaneType->setToolTip(tr("Cannot change from type <b>%1</b> to <b>%2</b>.")
     484//                                     .arg(m_oldData.m_options.m_enmType).arg(m_newData.m_options.m_enmType));
     485//    if (!pWidget || pWidget == m_pErrorPaneLocation)
     486//        m_pErrorPaneLocation->setToolTip(tr("Cannot change medium location from <b>%1</b> to <b>%2</b>.")
     487//                                         .arg(m_oldData.m_options.m_strLocation).arg(m_newData.m_options.m_strLocation));
    421488}
    422489
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h

    r67810 r67863  
    3838class QILabel;
    3939class QITabWidget;
     40class UIFilePathSelector;
    4041
    4142
     
    4647    UIDataMediumOptions()
    4748        : m_enmType(KMediumType_Normal)
     49        , m_strLocation(QString())
    4850    {}
    4951
     
    5355        return true
    5456               && (m_enmType == other.m_enmType)
     57               && (m_strLocation == other.m_strLocation)
    5558               ;
    5659    }
     
    6366    /** Holds the type. */
    6467    KMediumType m_enmType;
     68    /** Holds the location. */
     69    QString m_strLocation;
    6570};
    6671
     
    183188        /** Handles type change. */
    184189        void sltTypeIndexChanged(int iIndex);
     190        /** Handles location change. */
     191        void sltLocationPathChanged(const QString &strPath);
    185192
    186193        /** Handles button-box button click. */
     
    254261        /** Holds the type combo-box. */
    255262        QComboBox *m_pComboBoxType;
    256         /** Holds the automatic interface configuration error pane. */
     263        /** Holds the type error pane. */
    257264        QLabel    *m_pErrorPaneType;
     265
     266        /** Holds the location label. */
     267        QLabel    *m_pLabelLocation;
     268        /** Holds the location selector. */
     269        UIFilePathSelector *m_pSelectorLocation;
     270        /** Holds the location error pane. */
     271        QLabel    *m_pErrorPaneLocation;
    258272
    259273        /** Holds the button-box instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r67854 r67863  
    385385    /* Gather medium options data: */
    386386    m_options.m_enmType = m_guiMedium.mediumType();
     387    m_options.m_strLocation = m_guiMedium.location();
    387388    /* Gather medium details data: */
    388389    m_details.m_aFields.clear();
     
    921922
    922923    /* Try to assign new medium type: */
    923     if (newData.m_options.m_enmType != oldData.m_options.m_enmType)
     924    if (   comMedium.isOk()
     925        && newData.m_options.m_enmType != oldData.m_options.m_enmType)
     926    {
    924927        comMedium.SetType(newData.m_options.m_enmType);
    925928
    926     /* Show error message if necessary: */
    927     if (!comMedium.isOk())
    928         msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enmType, newData.m_options.m_enmType, this);
     929        /* Show error message if necessary: */
     930        if (!comMedium.isOk())
     931            msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enmType, newData.m_options.m_enmType, this);
     932    }
     933
     934    /* Try to assign new medium location: */
     935    if (   comMedium.isOk()
     936        && newData.m_options.m_strLocation != oldData.m_options.m_strLocation)
     937    {
     938        /* Prepare move storage progress: */
     939        CProgress comProgress = comMedium.SetLocation(newData.m_options.m_strLocation);
     940
     941        /* Show error message if necessary: */
     942        if (!comMedium.isOk())
     943            msgCenter().cannotMoveHardDiskStorage(comMedium,
     944                                                  oldData.m_options.m_strLocation,
     945                                                  newData.m_options.m_strLocation,
     946                                                  this);
     947        else
     948        {
     949            /* Show move storage progress: */
     950            msgCenter().showModalProgressDialog(comProgress, UIMediumManager::tr("Moving medium..."),
     951                                                ":/progress_media_move_90px.png", this);
     952
     953            /* Show error message if necessary: */
     954            if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     955                msgCenter().cannotMoveHardDiskStorage(comProgress,
     956                                                      oldData.m_options.m_strLocation,
     957                                                      newData.m_options.m_strLocation,
     958                                                      this);
     959        }
     960    }
    929961
    930962    /* Recache current item: */
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