예제 #1
0
VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine)
    : QIWithRetranslateUI<QIDialog>(pParent)
{
    /* Apply UI decorations */
    Ui::VBoxTakeSnapshotDlg::setupUi(this);

    /* Alt key filter */
    QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this);
    altKeyFilter->watchOn(mLeName);

    /* Setup connections */
    connect (mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &)));

    /* Check if machine have immutable attachments */
    int immutableMediums = 0;

    if (machine.GetState() == KMachineState_Paused)
    {
        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
        {
            CMedium medium = attachment.GetMedium();
            if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable)
                ++ immutableMediums;
        }
    }
예제 #2
0
VBoxTakeSnapshotDlg::VBoxTakeSnapshotDlg(QWidget *pParent, const CMachine &machine)
    : QIWithRetranslateUI<QIDialog>(pParent)
{
#ifdef Q_WS_MAC
    /* No sheets in another mode than normal for now. Firstly it looks ugly and
     * secondly in some cases it is broken. */
    if (   vboxGlobal().isSheetWindowsAllowed(pParent)
        || qobject_cast<VBoxSnapshotsWgt*>(pParent))
        setWindowFlags(Qt::Sheet);
#endif /* Q_WS_MAC */

    /* Apply UI decorations */
    Ui::VBoxTakeSnapshotDlg::setupUi(this);

    /* Alt key filter */
    QIAltKeyFilter *altKeyFilter = new QIAltKeyFilter(this);
    altKeyFilter->watchOn(mLeName);

    /* Setup connections */
    connect (mButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    connect (mLeName, SIGNAL(textChanged(const QString &)), this, SLOT(nameChanged(const QString &)));

    /* Check if machine have immutable attachments */
    int immutableMediums = 0;

    if (machine.GetState() == KMachineState_Paused)
    {
        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
        {
            CMedium medium = attachment.GetMedium();
            if (!medium.isNull() && !medium.GetParent().isNull() && medium.GetBase().GetType() == KMediumType_Immutable)
                ++ immutableMediums;
        }
    }
예제 #3
0
void UIMedium::refresh()
{
    /* Reset ID parameters: */
    m_strId = nullID();
    m_strRootId = nullID();
    m_strParentId = nullID();

    /* Reset cache parameters: */
    //m_strKey = nullID();

    /* Reset name/location/size parameters: */
    m_strName = VBoxGlobal::tr("Empty", "medium");
    m_strLocation = m_strSize = m_strLogicalSize = QString("--");

    /* Reset hard drive related parameters: */
    m_strHardDiskType = QString();
    m_strHardDiskFormat = QString();
    m_strStorageDetails = QString();
    m_strEncryptionPasswordID = QString();

    /* Reset data parameters: */
    m_strUsage = QString();
    m_strToolTip = QString();
    m_machineIds.clear();
    m_curStateMachineIds.clear();

    /* Reset m_noDiffs: */
    m_noDiffs.isSet = false;

    /* Reset flags: */
    m_fHidden = false;
    m_fUsedByHiddenMachinesOnly = false;
    m_fReadOnly = false;
    m_fUsedInSnapshots = false;
    m_fHostDrive = false;
    m_fEncrypted = false;

    /* For non NULL medium: */
    if (!m_medium.isNull())
    {
        /* Refresh medium ID: */
        m_strId = normalizedID(m_medium.GetId());
        /* Refresh root medium ID: */
        m_strRootId = m_strId;

        /* Init medium key if necessary: */
        if (m_strKey.isNull())
            m_strKey = m_strId;

        /* Check whether this is host-drive medium: */
        m_fHostDrive = m_medium.GetHostDrive();

        /* Refresh medium name: */
        if (!m_fHostDrive)
            m_strName = m_medium.GetName();
        else if (m_medium.GetDescription().isEmpty())
            m_strName = VBoxGlobal::tr("Host Drive '%1'", "medium").arg(QDir::toNativeSeparators(m_medium.GetLocation()));
        else
            m_strName = VBoxGlobal::tr("Host Drive %1 (%2)", "medium").arg(m_medium.GetDescription(), m_medium.GetName());
        /* Refresh medium location: */
        if (!m_fHostDrive)
            m_strLocation = QDir::toNativeSeparators(m_medium.GetLocation());

        /* Refresh medium size and logical size: */
        if (!m_fHostDrive)
        {
            /* Only for created and accessible mediums: */
            if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated)
            {
                m_strSize = vboxGlobal().formatSize(m_medium.GetSize());
                if (m_type == UIMediumType_HardDisk)
                    m_strLogicalSize = vboxGlobal().formatSize(m_medium.GetLogicalSize());
                else
                    m_strLogicalSize = m_strSize;
            }
        }

        /* For hard drive medium: */
        if (m_type == UIMediumType_HardDisk)
        {
            /* Refresh hard drive disk type: */
            m_strHardDiskType = vboxGlobal().mediumTypeString(m_medium);
            /* Refresh hard drive format: */
            m_strHardDiskFormat = m_medium.GetFormat();

            /* Refresh hard drive storage details: */
            qlonglong iMediumVariant = 0;
            foreach (const KMediumVariant &enmVariant, m_medium.GetVariant())
                iMediumVariant |= enmVariant;
            m_strStorageDetails = gpConverter->toString((KMediumVariant)iMediumVariant);

            /* Check whether this is read-only hard drive: */
            m_fReadOnly = m_medium.GetReadOnly();

            /* Refresh parent hard drive ID: */
            CMedium parentMedium = m_medium.GetParent();
            if (!parentMedium.isNull())
                m_strParentId = normalizedID(parentMedium.GetId());

            /* Only for created and accessible mediums: */
            if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated)
            {
                /* Refresh root hard drive ID: */
                while (!parentMedium.isNull())
                {
                    m_strRootId = normalizedID(parentMedium.GetId());
                    parentMedium = parentMedium.GetParent();
                }

                /* Refresh encryption attributes: */
                if (m_strRootId != m_strId)
                {
                    m_strEncryptionPasswordID = root().encryptionPasswordID();
                    m_fEncrypted = root().isEncrypted();
                }
                else
                {
                    QString strCipher;
                    CMedium medium(m_medium);
                    const QString strEncryptionPasswordID = medium.GetEncryptionSettings(strCipher);
                    if (medium.isOk())
                    {
                        m_strEncryptionPasswordID = strEncryptionPasswordID;
                        m_fEncrypted = true;
                    }
                }
            }
        }