/* Load data to cache from corresponding external object(s),
 * this task COULD be performed in other than GUI thread: */
void UIMachineSettingsDisplay::loadToCacheFrom(QVariant &data)
{
    /* Fetch data to machine: */
    UISettingsPageMachine::fetchData(data);

    /* Clear cache initially: */
    m_cache.clear();

    /* Prepare display data: */
    UIDataSettingsMachineDisplay displayData;

    /* Cache Screen data: */
    displayData.m_iCurrentVRAM = m_machine.GetVRAMSize();
    displayData.m_cGuestScreenCount = m_machine.GetMonitorCount();
    displayData.m_dScaleFactor = gEDataManager->scaleFactor(m_machine.GetId());
#ifdef Q_WS_MAC
    displayData.m_fUseUnscaledHiDPIOutput = gEDataManager->useUnscaledHiDPIOutput(m_machine.GetId());
#endif /* Q_WS_MAC */
    displayData.m_f3dAccelerationEnabled = m_machine.GetAccelerate3DEnabled();
#ifdef VBOX_WITH_VIDEOHWACCEL
    displayData.m_f2dAccelerationEnabled = m_machine.GetAccelerate2DVideoEnabled();
#endif /* VBOX_WITH_VIDEOHWACCEL */

    /* Check if Remote Display server is valid: */
    CVRDEServer remoteDisplayServer = m_machine.GetVRDEServer();
    displayData.m_fRemoteDisplayServerSupported = !remoteDisplayServer.isNull();
    if (!remoteDisplayServer.isNull())
    {
        /* Cache Remote Display data: */
        displayData.m_fRemoteDisplayServerEnabled = remoteDisplayServer.GetEnabled();
        displayData.m_strRemoteDisplayPort = remoteDisplayServer.GetVRDEProperty("TCP/Ports");
        displayData.m_remoteDisplayAuthType = remoteDisplayServer.GetAuthType();
        displayData.m_uRemoteDisplayTimeout = remoteDisplayServer.GetAuthTimeout();
        displayData.m_fRemoteDisplayMultiConnAllowed = remoteDisplayServer.GetAllowMultiConnection();
    }

    /* Cache Video Capture data: */
    displayData.m_fVideoCaptureEnabled = m_machine.GetVideoCaptureEnabled();
    displayData.m_strVideoCaptureFolder = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath();
    displayData.m_strVideoCaptureFilePath = m_machine.GetVideoCaptureFile();
    displayData.m_iVideoCaptureFrameWidth = m_machine.GetVideoCaptureWidth();
    displayData.m_iVideoCaptureFrameHeight = m_machine.GetVideoCaptureHeight();
    displayData.m_iVideoCaptureFrameRate = m_machine.GetVideoCaptureFPS();
    displayData.m_iVideoCaptureBitRate = m_machine.GetVideoCaptureRate();
    displayData.m_screens = m_machine.GetVideoCaptureScreens();

    /* Initialize other variables: */
    m_iInitialVRAM = RT_MIN(displayData.m_iCurrentVRAM, m_iMaxVRAM);

    /* Cache display data: */
    m_cache.cacheInitialData(displayData);

    /* Upload machine to data: */
    UISettingsPageMachine::uploadData(data);
}
void UIGInformationUpdateTaskDisplay::run()
{
    /* Acquire corresponding machine: */
    CMachine machine = property("machine").value<CMachine>();
    if (machine.isNull())
        return;

    /* Prepare table: */
    UITextTable table;

    /* Gather information: */
    if (machine.GetAccessible())
    {
        /* Video memory: */
        table << UITextTableLine(QApplication::translate("UIGInformation", "Video Memory", "details (display)"),
                                 QApplication::translate("UIGInformation", "%1 MB", "details").arg(machine.GetVRAMSize()));

        /* Screen count: */
        int cGuestScreens = machine.GetMonitorCount();
        if (cGuestScreens > 1)
            table << UITextTableLine(QApplication::translate("UIGInformation", "Screens", "details (display)"),
                                     QString::number(cGuestScreens));

        /* Get scale-factor value: */
        const QString strScaleFactor = machine.GetExtraData(UIExtraDataDefs::GUI_ScaleFactor);
        {
            /* Try to convert loaded data to double: */
            bool fOk = false;
            double dValue = strScaleFactor.toDouble(&fOk);
            /* Invent the default value: */
            if (!fOk || !dValue)
                dValue = 1.0;
            /* Append information: */
            if (dValue != 1.0)
                table << UITextTableLine(QApplication::translate("UIGInformation", "Scale-factor", "details (display)"),
                                         QString::number(dValue, 'f', 2));
        }

#ifdef Q_WS_MAC
        /* Get 'Unscaled HiDPI Video Output' mode value: */
        const QString strUnscaledHiDPIMode = machine.GetExtraData(UIExtraDataDefs::GUI_HiDPI_UnscaledOutput);
        {
            /* Try to convert loaded data to bool: */
            const bool fEnabled  = strUnscaledHiDPIMode.compare("true", Qt::CaseInsensitive) == 0 ||
                                   strUnscaledHiDPIMode.compare("yes", Qt::CaseInsensitive) == 0 ||
                                   strUnscaledHiDPIMode.compare("on", Qt::CaseInsensitive) == 0 ||
                                   strUnscaledHiDPIMode == "1";
            /* Append information: */
            if (fEnabled)
                table << UITextTableLine(QApplication::translate("UIGInformation", "Unscaled HiDPI Video Output", "details (display)"),
                                         QApplication::translate("UIGInformation", "Enabled", "details (display/Unscaled HiDPI Video Output)"));
        }
#endif /* Q_WS_MAC */

        QStringList acceleration;
#ifdef VBOX_WITH_VIDEOHWACCEL
        /* 2D acceleration: */
        if (machine.GetAccelerate2DVideoEnabled())
            acceleration << QApplication::translate("UIGInformation", "2D Video", "details (display)");
#endif /* VBOX_WITH_VIDEOHWACCEL */
        /* 3D acceleration: */
        if (machine.GetAccelerate3DEnabled())
            acceleration << QApplication::translate("UIGInformation", "3D", "details (display)");
        if (!acceleration.isEmpty())
            table << UITextTableLine(QApplication::translate("UIGInformation", "Acceleration", "details (display)"),
                                     acceleration.join(", "));

        /* VRDE info: */
        CVRDEServer srv = machine.GetVRDEServer();
        if (!srv.isNull())
        {
            if (srv.GetEnabled())
                table << UITextTableLine(QApplication::translate("UIGInformation", "Remote Desktop Server Port", "details (display/vrde)"),
                                         srv.GetVRDEProperty("TCP/Ports"));
            else
                table << UITextTableLine(QApplication::translate("UIGInformation", "Remote Desktop Server", "details (display/vrde)"),
                                         QApplication::translate("UIGInformation", "Disabled", "details (display/vrde/VRDE server)"));
        }

        /* Video Capture info: */
        if (machine.GetVideoCaptureEnabled())
        {
            table << UITextTableLine(QApplication::translate("UIGInformation", "Video Capture File", "details (display/video capture)"),
                                     machine.GetVideoCaptureFile());
            table << UITextTableLine(QApplication::translate("UIGInformation", "Video Capture Attributes", "details (display/video capture)"),
                                     QApplication::translate("UIGInformation", "Frame Size: %1x%2, Frame Rate: %3fps, Bit Rate: %4kbps")
                                     .arg(machine.GetVideoCaptureWidth()).arg(machine.GetVideoCaptureHeight())
                                     .arg(machine.GetVideoCaptureFPS()).arg(machine.GetVideoCaptureRate()));
        }
        else
        {
            table << UITextTableLine(QApplication::translate("UIGInformation", "Video Capture", "details (display/video capture)"),
                                     QApplication::translate("UIGInformation", "Disabled", "details (display/video capture)"));
        }
    }
    else
        table << UITextTableLine(QApplication::translate("UIGInformation", "Information Inaccessible", "details"), QString());

    /* Save the table as property: */
    setProperty("table", QVariant::fromValue(table));
}