added some cli arg support #280
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
@@ -7,14 +8,58 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
QString appName = "Olive (January 2019 | Alpha";
|
||||||
|
#ifdef GITHASH
|
||||||
|
appName += " | ";
|
||||||
|
appName += GITHASH;
|
||||||
|
#endif
|
||||||
|
appName += ")";
|
||||||
|
|
||||||
|
bool launch_fullscreen = false;
|
||||||
|
QString load_proj;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
for (int i=1;i<argc;i++) {
|
||||||
|
if (argv[i][0] == '-') {
|
||||||
|
if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
|
||||||
|
#ifndef GITHASH
|
||||||
|
printf("[WARNING] No Git commit information found\n");
|
||||||
|
#endif
|
||||||
|
printf("%s\n", appName.toUtf8().constData());
|
||||||
|
return 0;
|
||||||
|
} else if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
||||||
|
printf("Usage: %s [options] [filename]\n\n[filename] is the file to open on startup.\n\nOptions:\n\t-v, --version\tShow version information\n\t-h, --help\tShow this help\n\t-f, --fullscreen\tStart in full screen mode\n\n", argv[0]);
|
||||||
|
return 0;
|
||||||
|
} else if (!strcmp(argv[1], "--fullscreen") || !strcmp(argv[1], "-f")) {
|
||||||
|
launch_fullscreen = true;
|
||||||
|
} else {
|
||||||
|
printf("[ERROR] Unknown argument '%s'\n", argv[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else if (load_proj.isEmpty()) {
|
||||||
|
load_proj = argv[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// init ffmpeg subsystem
|
// init ffmpeg subsystem
|
||||||
av_register_all();
|
av_register_all();
|
||||||
avfilter_register_all();
|
avfilter_register_all();
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
if (argc > 1) w.launch_with_project(argv[1]);
|
w.appName = appName;
|
||||||
w.showMaximized();
|
w.updateTitle("");
|
||||||
|
|
||||||
|
if (!load_proj.isEmpty()) {
|
||||||
|
w.launch_with_project(load_proj);
|
||||||
|
}
|
||||||
|
if (launch_fullscreen) {
|
||||||
|
w.showFullScreen();
|
||||||
|
} else {
|
||||||
|
w.showMaximized();
|
||||||
|
}
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-11
@@ -56,7 +56,6 @@ MainWindow* mainWindow;
|
|||||||
|
|
||||||
QTimer autorecovery_timer;
|
QTimer autorecovery_timer;
|
||||||
QString config_fn;
|
QString config_fn;
|
||||||
QString appName;
|
|
||||||
bool demoNoticeShown = false;
|
bool demoNoticeShown = false;
|
||||||
|
|
||||||
void MainWindow::setup_layout(bool reset) {
|
void MainWindow::setup_layout(bool reset) {
|
||||||
@@ -95,13 +94,6 @@ void MainWindow::setup_layout(bool reset) {
|
|||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent)
|
QMainWindow(parent)
|
||||||
{
|
{
|
||||||
appName = "Olive (January 2019 | Alpha";
|
|
||||||
#ifdef GITHASH
|
|
||||||
appName += " | ";
|
|
||||||
appName += GITHASH;
|
|
||||||
#endif
|
|
||||||
appName += ")";
|
|
||||||
|
|
||||||
enable_launch_with_project = false;
|
enable_launch_with_project = false;
|
||||||
|
|
||||||
setup_debug();
|
setup_debug();
|
||||||
@@ -137,8 +129,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
||||||
|
|
||||||
updateTitle("");
|
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
|
|
||||||
layout()->invalidate();
|
layout()->invalidate();
|
||||||
@@ -239,9 +229,10 @@ MainWindow::~MainWindow() {
|
|||||||
close_debug();
|
close_debug();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::launch_with_project(const char* s) {
|
void MainWindow::launch_with_project(const QString& s) {
|
||||||
project_url = s;
|
project_url = s;
|
||||||
enable_launch_with_project = true;
|
enable_launch_with_project = true;
|
||||||
|
demoNoticeShown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::make_new_menu(QMenu *parent) {
|
void MainWindow::make_new_menu(QMenu *parent) {
|
||||||
|
|||||||
+3
-1
@@ -15,11 +15,13 @@ public:
|
|||||||
void updateTitle(const QString &url);
|
void updateTitle(const QString &url);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void launch_with_project(const char *s);
|
void launch_with_project(const QString& s);
|
||||||
|
|
||||||
void make_new_menu(QMenu* parent);
|
void make_new_menu(QMenu* parent);
|
||||||
void make_inout_menu(QMenu* parent);
|
void make_inout_menu(QMenu* parent);
|
||||||
|
|
||||||
|
QString appName;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
|||||||
Reference in New Issue
Block a user