Ejemplo n.º 1
0
    void load() {
        QSettings settings(file, QSettings::IniFormat);
        timeout = settings.value("timeout", 30.0).toReal();
        abort_timeout = settings.value("abort_timeout", true).toBool();
        force_fps = settings.value("force_fps", 0.0).toReal();
        settings.beginGroup("decoder");
        settings.beginGroup("video");
        QString decs_default("FFmpeg");
        //decs_default.append(" CUDA ").append(" DXVA ").append(" VAAPI ").append(" VDA ");
#if 0
        QString all_names_string = settings.value("all", QString()).toString();
        if (!all_names_string.isEmpty()) {
            all_names = all_names_string.split(" ", QString::SkipEmptyParts);
        }
#endif
        video_decoders = settings.value("priority", decs_default).toString().split(" ", QString::SkipEmptyParts);
        settings.endGroup(); //video
        settings.endGroup(); //decoder

        settings.beginGroup("capture");
        capture_dir = settings.value("dir", QString()).toString();
        if (capture_dir.isEmpty()) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
            capture_dir = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
#else
            capture_dir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
#endif
        }
        capture_fmt = settings.value("format", "png").toByteArray();
        capture_quality = settings.value("quality", 100).toInt();
        settings.endGroup();
        settings.beginGroup("subtitle");
        subtitle_autoload = settings.value("autoLoad", true).toBool();
        subtitle_enabled = settings.value("enabled", true).toBool();
        subtitle_engines = settings.value("engines", QStringList() << "FFmpeg" << "LibASS").toStringList();
        subtitle_delay = settings.value("delay", 0.0).toInt();
        QFont f;
        f.setPointSize(20);
        f.setBold(true);
        subtitle_font = settings.value("font", f).value<QFont>();
        subtitle_color = settings.value("color", QColor("white")).value<QColor>();
        subtitle_outline_color = settings.value("outline_color", QColor("blue")).value<QColor>();
        subtitle_outline = settings.value("outline", true).toBool();
        subtilte_bottom_margin = settings.value("bottom margin", 8).toInt();
        settings.endGroup();
        settings.beginGroup("preview");
        preview_enabled = settings.value("enabled", true).toBool();
        preview_w = settings.value("width", 160).toInt();
        preview_h = settings.value("height", 90).toInt();
        settings.endGroup();
        settings.beginGroup("avformat");
        avformat_on = settings.value("enable", false).toBool();
        direct = settings.value("avioflags", 0).toString() == "direct";
        probe_size = settings.value("probesize", 5000000).toUInt();
        analyze_duration = settings.value("analyzeduration", 5000000).toInt();
        avformat_extra = settings.value("extra", "").toString();
        settings.endGroup();
        settings.beginGroup("avfilterVideo");
        avfilterVideo_on = settings.value("enable", true).toBool();
        avfilterVideo = settings.value("options", "").toString();
        settings.endGroup();
        settings.beginGroup("avfilterAudio");
        avfilterAudio_on = settings.value("enable", true).toBool();
        avfilterAudio = settings.value("options", "").toString();
        settings.endGroup();
        settings.beginGroup("opengl");
        const QString glname = settings.value("type", "OpenGLES").toString();
        opengl = (Config::OpenGLType)Config::staticMetaObject.enumerator(Config::staticMetaObject.indexOfEnumerator("OpenGLType")).keysToValue(glname.toLatin1().constData());
        // d3d11 bad performance (gltexsubimage2d)
        angle_dx = settings.value("angle_platform", "d3d9").toString();
        settings.endGroup();

        settings.beginGroup("buffer");
        buffer_value = settings.value("value", -1).toInt();
        settings.endGroup();
    }
Ejemplo n.º 2
0
    void load() {
        // for old config data migration
        QString dir_old = qApp->applicationDirPath() + QString::fromLatin1("/data");
        if (!QDir(dir_old).exists()) {
            dir_old = QDir::homePath() + QString::fromLatin1("/.QtAV");
        }
        if (QDir(dir_old).exists()) {
            if (!QFile(file).exists()) {
                QString old = dir_old + QString::fromLatin1("/") + qApp->applicationName() + QString::fromLatin1(".ini");
                if (QFile(old).exists()) {
                    QFile::copy(old, file);
                    QFile::remove(old);
                }
                old = dir_old + QString::fromLatin1("/playlist.qds");
                if (QFile(old).exists()) {
                    if (!QFile::copy(old, appDataDir() + QString::fromLatin1("/playlist.qds")))
                        qWarning("error to move old playlist data");
                    QFile::remove(old);
                }
                old = dir_old + QString::fromLatin1("/history.qds");
                if (QFile(old).exists()) {
                    if (!QFile::copy(old, appDataDir() + QString::fromLatin1("/history.qds")))
                        qWarning("error to move old history data");
                    QFile::remove(old);
                }
            }
        }

        QSettings settings(file, QSettings::IniFormat);
        log = settings.value(QString::fromLatin1("log"), QString()).toString();
        last_file = settings.value(QString::fromLatin1("last_file"), QString()).toString();
        timeout = settings.value(QString::fromLatin1("timeout"), 30.0).toReal();
        abort_timeout = settings.value(QString::fromLatin1("abort_timeout"), true).toBool();
        force_fps = settings.value(QString::fromLatin1("force_fps"), 0.0).toReal();
        settings.beginGroup(QString::fromLatin1("decoder"));
        settings.beginGroup(QString::fromLatin1("video"));
        QString decs_default(QString::fromLatin1("FFmpeg"));
        //decs_default.append(QString::fromLatin1(" CUDA ")).append(QString::fromLatin1(" DXVA ")).append(QString::fromLatin1(" VAAPI ")).append(QString::fromLatin1(" VDA "));
#if 0
        QString all_names_string = settings.value("all", QString()).toString();
        if (!all_names_string.isEmpty()) {
            all_names = all_names_string.split(" ", QString::SkipEmptyParts);
        }
#endif
        video_decoders = settings.value(QString::fromLatin1("priority"), decs_default).toString().split(QString::fromLatin1(" "), QString::SkipEmptyParts);
        settings.endGroup(); //video
        settings.endGroup(); //decoder

        settings.beginGroup(QString::fromLatin1("capture"));
        capture_dir = settings.value(QString::fromLatin1("dir"), QString()).toString();
        if (capture_dir.isEmpty()) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
            capture_dir = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
#else
            capture_dir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
#endif
        }
        capture_fmt = settings.value(QString::fromLatin1("format"), QString::fromLatin1("png")).toString();
        capture_quality = settings.value(QString::fromLatin1("quality"), 100).toInt();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("subtitle"));
        subtitle_autoload = settings.value(QString::fromLatin1("autoLoad"), true).toBool();
        subtitle_enabled = settings.value(QString::fromLatin1("enabled"), true).toBool();
        subtitle_engines = settings.value(QString::fromLatin1("engines"), QStringList() << QString::fromLatin1("FFmpeg") << QString::fromLatin1("LibASS")).toStringList();
        subtitle_delay = settings.value(QString::fromLatin1("delay"), 0.0).toInt();
        QFont f;
        f.setPointSize(20);
        f.setBold(true);
        subtitle_font = settings.value(QString::fromLatin1("font"), f).value<QFont>();
        subtitle_color = settings.value(QString::fromLatin1("color"), QColor("white")).value<QColor>();
        subtitle_outline_color = settings.value(QString::fromLatin1("outline_color"), QColor("blue")).value<QColor>();
        subtitle_outline = settings.value(QString::fromLatin1("outline"), true).toBool();
        subtilte_bottom_margin = settings.value(QString::fromLatin1("bottom margin"), 8).toInt();
        settings.beginGroup(QString::fromLatin1("ass"));
        ass_font_file = settings.value(QString::fromLatin1("font_file"), QString()).toString();
        ass_force_font_file = settings.value(QString::fromLatin1("force_font_file"), false).toBool();
        ass_fonts_dir = settings.value(QString::fromLatin1("fonts_dir"), QString()).toString();
        settings.endGroup();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("preview"));
        preview_enabled = settings.value(QString::fromLatin1("enabled"), true).toBool();
        preview_w = settings.value(QString::fromLatin1("width"), 160).toInt();
        preview_h = settings.value(QString::fromLatin1("height"), 90).toInt();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("avformat"));
        avformat_on = settings.value(QString::fromLatin1("enable"), false).toBool();
        direct = settings.value(QString::fromLatin1("avioflags"), 0).toString() == QLatin1String("direct");
        probe_size = settings.value(QString::fromLatin1("probesize"), 5000000).toUInt();
        analyze_duration = settings.value(QString::fromLatin1("analyzeduration"), 5000000).toInt();
        avformat_extra = settings.value(QString::fromLatin1("extra"), QString()).toString();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("avfilterVideo"));
        avfilterVideo_on = settings.value(QString::fromLatin1("enable"), true).toBool();
        avfilterVideo = settings.value(QString::fromLatin1("options"), QString()).toString();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("avfilterAudio"));
        avfilterAudio_on = settings.value(QString::fromLatin1("enable"), true).toBool();
        avfilterAudio = settings.value(QString::fromLatin1("options"), QString()).toString();
        settings.endGroup();
        settings.beginGroup(QString::fromLatin1("opengl"));
        egl = settings.value(QString::fromLatin1("egl"), false).toBool();
        const QString glname = settings.value(QString::fromLatin1("type"), QString::fromLatin1("OpenGLES")).toString();
        opengl = (Config::OpenGLType)Config::staticMetaObject.enumerator(Config::staticMetaObject.indexOfEnumerator("OpenGLType")).keysToValue(glname.toLatin1().constData());
        // d3d11 bad performance (gltexsubimage2d)
        angle_dx = settings.value(QString::fromLatin1("angle_platform"), QString::fromLatin1("d3d9")).toString();
        settings.endGroup();

        settings.beginGroup(QString::fromLatin1("buffer"));
        buffer_value = settings.value(QString::fromLatin1("value"), -1).toInt();
        settings.endGroup();
    }