VirtualBox

Changeset 90376 in vbox for trunk


Ignore:
Timestamp:
Jul 28, 2021 5:11:28 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Notification signature for virtual machine move progress (in UIVirtualBoxManager) which should now go to center instead of modal dialogs.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r90157 r90376  
    5252#include "UIModalWindowManager.h"
    5353#include "UINetworkManager.h"
     54#include "UINotificationCenter.h"
    5455#include "UIQObjectStuff.h"
    5556#include "UISettingsDialogSpecific.h"
     
    11501151    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
    11511152
    1152     /* Open a session thru which we will modify the machine: */
    1153     CSession comSession = uiCommon().openSession(pItem->id(), KLockType_Write);
    1154     if (comSession.isNull())
    1155         return;
    1156 
    1157     /* Get session machine: */
    1158     CMachine comMachine = comSession.GetMachine();
    1159     AssertMsgReturnVoid(comSession.isOk() && comMachine.isNotNull(), ("Unable to acquire machine!\n"));
    1160 
    11611153    /* Open a file dialog for the user to select a destination folder. Start with the default machine folder: */
    1162     CVirtualBox comVBox = uiCommon().virtualBox();
    1163     QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder();
    1164     QString strTitle = tr("Select a destination folder to move the selected virtual machine");
    1165     QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle);
     1154    const QString strBaseFolder = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     1155    const QString strTitle = tr("Select a destination folder to move the selected virtual machine");
     1156    const QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle);
    11661157    if (!strDestinationFolder.isEmpty())
    11671158    {
    1168         /* Prepare machine move progress: */
    1169         CProgress comProgress = comMachine.MoveTo(strDestinationFolder, "basic");
    1170         if (comMachine.isOk() && comProgress.isNotNull())
    1171         {
    1172             /* Show machine move progress: */
    1173             msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_dnd_hg_90px.png");
    1174             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    1175                 msgCenter().cannotMoveMachine(comProgress, comMachine.GetName());
    1176         }
    1177         else
    1178             msgCenter().cannotMoveMachine(comMachine);
    1179     }
    1180     comSession.UnlockMachine();
     1159        /* Move machine: */
     1160        UINotificationProgressMachineMove *pNotification = new UINotificationProgressMachineMove(pItem->id(),
     1161                                                                                                 strDestinationFolder,
     1162                                                                                                 "basic");
     1163        notificationCenter().append(pNotification);
     1164    }
    11811165}
    11821166
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90375 r90376  
    1616 */
    1717
     18/* Qt includes: */
     19#include <QDir>
     20#include <QFileInfo>
     21
    1822/* GUI includes: */
     23#include "UICommon.h"
    1924#include "UINotificationObjects.h"
    2025
     
    182187    if (m_comTarget.isNotNull() && !m_comTarget.GetId().isNull())
    183188        emit sigMachineCopied(m_comTarget);
     189}
     190
     191
     192/*********************************************************************************************************************************
     193*   Class UINotificationProgressMachineMove implementation.                                                                      *
     194*********************************************************************************************************************************/
     195
     196UINotificationProgressMachineMove::UINotificationProgressMachineMove(const QUuid &uId,
     197                                                                     const QString &strDestination,
     198                                                                     const QString &strType)
     199    : m_uId(uId)
     200    , m_strDestination(QDir::toNativeSeparators(strDestination))
     201    , m_strType(strType)
     202{
     203    connect(this, &UINotificationProgress::sigProgressFinished,
     204            this, &UINotificationProgressMachineMove::sltHandleProgressFinished);
     205}
     206
     207QString UINotificationProgressMachineMove::name() const
     208{
     209    return UINotificationProgress::tr("Moving machine ...");
     210}
     211
     212QString UINotificationProgressMachineMove::details() const
     213{
     214    return UINotificationProgress::tr("<b>From:</b> %1<br><b>To:</b> %2")
     215                                     .arg(m_strSource, m_strDestination);
     216}
     217
     218CProgress UINotificationProgressMachineMove::createProgress(COMResult &comResult)
     219{
     220    /* Open a session thru which we will modify the machine: */
     221    m_comSession = uiCommon().openSession(m_uId, KLockType_Write);
     222
     223    /* Get session machine: */
     224    CMachine comMachine = m_comSession.GetMachine();
     225    if (!m_comSession.isOk())
     226    {
     227        comResult = m_comSession;
     228        return CProgress();
     229    }
     230
     231    /* Acquire VM source: */
     232    const QString strSettingFilePath = comMachine.GetSettingsFilePath();
     233    if (!comMachine.isOk())
     234    {
     235        comResult = comMachine;
     236        return CProgress();
     237    }
     238    QDir parentDir = QFileInfo(strSettingFilePath).absoluteDir();
     239    parentDir.cdUp();
     240    m_strSource = QDir::toNativeSeparators(parentDir.absolutePath());
     241
     242    /* Initialize progress-wrapper: */
     243    CProgress comProgress = comMachine.MoveTo(m_strDestination, m_strType);
     244    /* Store COM result: */
     245    comResult = comMachine;
     246    /* Return progress-wrapper: */
     247    return comProgress;
     248}
     249
     250void UINotificationProgressMachineMove::sltHandleProgressFinished()
     251{
     252    /* Unlock session finally: */
     253    m_comSession.UnlockMachine();
    184254}
    185255
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90375 r90376  
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QUuid>
     26
    2427/* GUI includes: */
    2528#include "UINotificationObject.h"
     
    3437#include "CMachine.h"
    3538#include "CMedium.h"
     39#include "CSession.h"
    3640#include "CVirtualSystemDescription.h"
    3741
     
    204208    /** Holds the target machine options. */
    205209    QVector<KCloneOptions>  m_options;
     210};
     211
     212/** UINotificationProgress extension for machine move functionality. */
     213class SHARED_LIBRARY_STUFF UINotificationProgressMachineMove : public UINotificationProgress
     214{
     215    Q_OBJECT;
     216
     217public:
     218
     219    /** Constructs medium move notification-progress.
     220      * @param  uId             Brings the machine id.
     221      * @param  strDestination  Brings the move destination.
     222      * @param  strType         Brings the moving type. */
     223    UINotificationProgressMachineMove(const QUuid &uId,
     224                                      const QString &strDestination,
     225                                      const QString &strType);
     226
     227protected:
     228
     229    /** Returns object name. */
     230    virtual QString name() const /* override final */;
     231    /** Returns object details. */
     232    virtual QString details() const /* override final */;
     233    /** Creates and returns started progress-wrapper. */
     234    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     235
     236private slots:
     237
     238    /** Handles signal about progress being finished. */
     239    void sltHandleProgressFinished();
     240
     241private:
     242
     243    /** Holds the machine id. */
     244    QUuid     m_uId;
     245    /** Holds the session being opened. */
     246    CSession  m_comSession;
     247    /** Holds the machine source. */
     248    QString   m_strSource;
     249    /** Holds the machine destination. */
     250    QString   m_strDestination;
     251    /** Holds the moving type. */
     252    QString   m_strType;
    206253};
    207254
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