1 /**
2 \file Simple proxy for vsProxy
3 \brief external job control
4 \author mean fixounet@free.fr (c) 2015
5 */
6
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 #include <QFile>
16 #include <QFileDialog>
17
18 #include "vsProxy_qt4.h"
19 #include "ADM_cpp.h"
20 #include "ADM_default.h"
21 #include "ADM_threads.h"
22 #ifndef __APPLE__
23 #include "ADM_memsupport.h"
24 #endif
25 #include "ADM_crashdump.h"
26 #include "prefs.h"
27 #include "ADM_last.h"
28 #include "../ADM_vsProxy.h"
29 #ifdef _WIN32
30 #include "ADM_win32.h"
31 #endif
32 /**
33 \fn main
34 */
main(int argc,char * argv[])35 int main(int argc, char *argv[])
36 {
37 #ifndef __APPLE__
38 ADM_InitMemcpy();
39 #endif
40 ADM_initBaseDir(argc,argv);
41 initPrefs();
42 if(!prefs->load())
43 ADM_warning("Cannot load preferences.\n");
44 #ifdef _WIN32
45 win32_netInit();
46 #endif
47 QApplication app(argc, argv);
48 vsWindow vs;
49 vs.show();
50 app.exec();
51 // We don't save prefs to avoid overwriting Avidemux configuration
52 // with an older copy at the cost of not retaining the location of
53 // the last loaded .vpy file across sessions.
54 destroyPrefs();
55 return 0;
56 }
57 /**
58 *
59 */
vsWindow()60 vsWindow::vsWindow()
61 {
62 ui.setupUi(this);
63 ui.lineFile->setEnabled(false);
64 ui.pushButtonRun->setEnabled(false);
65 connect( ui.pushButtonRun,SIGNAL(clicked(bool)),this,SLOT(runOrStop()));
66 connect( ui.pushFileSel,SIGNAL(clicked(bool)),this,SLOT(selectFile()));
67
68 }
69 /**
70 *
71 */
~vsWindow()72 vsWindow::~vsWindow()
73 {
74
75 }
76 /**
77 *
78 */
selectFile()79 void vsWindow::selectFile()
80 {
81 std::string dir;
82 admCoreUtils::getLastReadFolder(dir);
83 QString last = QString::fromStdString(dir);
84 QString fileName = QFileDialog::getOpenFileName(this,
85 tr("Open VapourSynth File"), last, tr("VS Script Files (*.vpy)"));
86 printf("File selected : %s\n",fileName.toUtf8().constData());
87 if(!fileName.size())
88 return;
89 QFile qfile(fileName);
90 if(!qfile.exists())
91 {
92 ui.lineFile->setText(QString(""));
93 ui.pushButtonRun->setEnabled(false);
94 }else
95 {
96 ui.lineFile->setText(fileName);
97 ui.labelStatus->setText(QString("..."));
98 ui.pushButtonRun->setEnabled(true);
99 admCoreUtils::setLastReadFolder(std::string(fileName.toUtf8().constData()));
100 }
101 }
102 /**
103 *
104 */
runOrStop()105 void vsWindow::runOrStop()
106 {
107 ui.pushFileSel->setEnabled(false);
108 ui.pushButtonRun->setEnabled(false);
109 ui.spinboxPort->setEnabled(false);
110 ui.labelStatus->setText(QString("Running...."));
111 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
112
113 std::string fileName=std::string(ui.lineFile->text().toUtf8().constData());
114 vapourSynthProxy vs;
115 vs.run(ui.spinboxPort->value(),fileName.c_str());
116
117 ui.labelStatus->setText(QString("Exited (error ?)"));
118 ui.spinboxPort->setEnabled(true);
119 ui.pushButtonRun->setEnabled(true);
120 ui.pushFileSel->setEnabled(true);
121 }
122
123 //EOF
124