Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 1, 2015
1 parent 71a6c57 commit c804872
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/QMLPlayer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int main(int argc, char *argv[])
("scale", 1.0, QLatin1String("scale of graphics context. 0: auto"))
;
options.parse(argc, argv);
Config::setName(QString::fromLatin1("QMLPlayer"));
do_common_options_before_qapp(options);

QGuiApplication app(argc, argv);
Expand Down
14 changes: 13 additions & 1 deletion examples/common/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class Config::Data
{
public:
Data() {
file = appDataDir() + QString::fromLatin1("/") + qApp->applicationName() + QString::fromLatin1(".ini");
if (!Data::name.isEmpty())
file = appDataDir() + QString::fromLatin1("/") + Data::name + QString::fromLatin1(".ini");
else
file = appDataDir() + QString::fromLatin1("/") + qApp->applicationName() + QString::fromLatin1(".ini");
if (!QDir(appDataDir()).exists()) {
if (!QDir().mkpath(appDataDir())) {
qWarning() << "Failed to create appDataDir: " << appDataDir();
Expand Down Expand Up @@ -267,14 +270,23 @@ class Config::Data
qreal timeout;
int buffer_value;
QString log;

static QString name;
};

QString Config::Data::name;

Config& Config::instance()
{
static Config cfg;
return cfg;
}

void Config::setName(const QString &name)
{
Config::Data::name = name;
}

Config::Config(QObject *parent)
: QObject(parent)
, mpData(new Data())
Expand Down
2 changes: 1 addition & 1 deletion examples/common/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class COMMON_EXPORT Config : public QObject
};

static Config& instance();

static void setName(const QString& name); // config file base name
Q_INVOKABLE bool reset();
void reload();
/*!
Expand Down
1 change: 1 addition & 0 deletions examples/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void Logger(QtMsgType type, const QMessageLogContext &, const QString& qmsg)
fileLogger()->write(QByteArray("Fatal: "));
abort();
}
fflush(0);
fileLogger()->write(msgArray);
fileLogger()->write(QByteArray("\n"));
fileLogger()->flush();
Expand Down
6 changes: 5 additions & 1 deletion examples/filters/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char *argv[])
qDebug("vo: %s", vo.toUtf8().constData());
bool opt_has_file = argc > idx + 2;
vo = vo.toLower();
if (vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi") && vo != QLatin1String("xv"))
if (vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi") && vo != QLatin1String("xv") && vo != QLatin1String("x11"))
vo = QString::fromLatin1("qpainter");
QString title = QString::fromLatin1("QtAV %1 [email protected]").arg(QtAV_Version_String_Long());
VideoRenderer *renderer = 0;
Expand All @@ -71,6 +71,10 @@ int main(int argc, char *argv[])
renderer = VideoRenderer::create(VideoRendererId_GDI);
} else if (vo == QLatin1String("xv")) {
renderer = VideoRenderer::create(VideoRendererId_XV);
textfilter = true;
} else if (vo == QLatin1String("x11")) {
renderer = VideoRenderer::create(VideoRendererId_X11);
textfilter = true;
} else {
renderer = VideoRenderer::create(VideoRendererId_Widget);
textfilter = true;
Expand Down
1 change: 1 addition & 0 deletions examples/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ VideoRendererId rendererId_from_opt_name(const QString& name) {
int main(int argc, char *argv[])
{
qDebug() << aboutQtAV_PlainText();
Config::setName(QString::fromLatin1("Player"));
QOptions options = get_common_options();
options.add(QString::fromLatin1("player options"))
("ffmpeg-log", QString(), QString::fromLatin1("ffmpeg log level. can be: quiet, panic, fatal, error, warn, info, verbose, debug. this can override env 'QTAV_FFMPEG_LOG'"))
Expand Down

0 comments on commit c804872

Please sign in to comment.