forked from quicky2000/tartini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
100 lines (77 loc) · 2.94 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/***************************************************************************
main.cpp - description
-------------------
begin : May 2002
copyright : (C) 2002-2005 by Philip McLeod
email : pmcleod@cs.otago.ac.nz
copyright : (C) 2016 by Julien Thevenon
email : julien_thevenon at yahoo.fr
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Please read LICENSE.txt for details.
***************************************************************************/
#include "main.h"
#include "application.h"
#ifdef MACX
#include <CoreFoundation/CoreFoundation.h>
QString macxPathString;
#endif // MACX
#include "gdata.h"
#include "myassert.h"
int main( int p_argc
, char ** p_argv
)
{
#ifdef WINDOWS
freopen("stdout.txt", "w", stdout);
freopen("stderr.txt", "w", stderr);
#endif // WINDOWS
#ifdef MACX
CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
macxPathString = QString(pathPtr);
if(!macxPathString.endsWith("/"))
{
macxPathString.append('/');
}
CFRelease(pluginRef);
CFRelease(macPath);
#endif // MACX
application l_app(p_argc, p_argv);
QString l_locale = QLocale::system().name();
QTranslator l_translator;
l_translator.load(QString("tartini_") + l_locale);
l_app.installTranslator(&l_translator);
Q_INIT_RESOURCE(pitch);
std::cerr << "QT_VERSION_STR=\"" << QT_VERSION_STR << "\"" << std::endl;
std::cerr << "QT_VERSION=" << std::hex << QT_VERSION << std::dec << std::endl;
std::cerr << "QWT_VERSION_STR=\"" << QWT_VERSION_STR << "\"" << std::endl;
std::cerr << "QWT_VERSION=" << std::hex << QWT_VERSION << std::dec << std::endl;
//Create one instance only of the global data
GData::createUniqueInstance();
g_main_window = new MainWindow();
//call init after we know the windows size
GData::getUniqueInstance().getView().init();
g_main_window->showMaximized();
g_main_window->show();
l_app.connect(&l_app, SIGNAL(lastWindowClosed()), &l_app, SLOT(quit()));
if(!g_main_window->loadViewGeometry())
{
g_main_window->aboutTartini(); //open the tartini dialog on first time open
}
//open any files on the command line
if(p_argc >= 2)
{
for(int l_index = 1; l_index < p_argc; l_index++)
{
g_main_window->openFile(p_argv[l_index]);
}
}
int l_ret_value = l_app.exec();
GData::deleteUniqueInstance();
return l_ret_value;
}
//EOF