/
mainwindow.cpp
50 lines (42 loc) · 1.03 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "mainwindow.h"
#include "graphwidget.h"
#include "zipplcontroler.h"
#include <QtGui>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
mGraphWidget = new GraphWidget;
setCentralWidget( mGraphWidget );
mController = new ZipplControler( mGraphWidget );
}
void MainWindow::openFile( int argc, char *argv[] )
{
QString file;
qDebug() << "ARGC: " << argc;
qDebug() << "ARGV: " << argv;
bool res = false;
if( argc > 1 ) {
file = argv[1];
} else {
file = autoFile();
qDebug() << "Auto-File found: " << file;
}
res = mController->loadFile( file );
if( ! res ) {
file = QFileDialog::getOpenFileName( this, tr("Pick a Zippl file to Open"),
QDir::homePath(), tr("Zippl Files (*xml)"));
res = mController->loadFile( file );
}
if( ! res ) exit(0);
}
QString MainWindow::autoFile() const
{
QFileInfo info( "zippl.xml" );
if( info.exists() ) {
return info.absoluteFilePath();
}
return QString();
}
MainWindow::~MainWindow()
{
}