2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
|
#include <QApplication> |
|
|
#include <QTextCodec> |
|
|
#include <QTranslator> |
|
|
|
|
23 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
24 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
25 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
26 |
|
|
27 |
|
#include <QApplication> |
28 |
|
#include <QTranslator> |
29 |
|
#include <QLocale> |
30 |
|
#if defined(__APPLE__) // Toshi Nagata 20080105 |
31 |
|
#include <QDir> |
32 |
|
#endif |
33 |
|
|
34 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
35 |
// main - The main program trunk. |
// main - The main program trunk. |
36 |
// |
// |
37 |
|
|
38 |
int main ( int argc, char **argv ) |
int main ( int argc, char **argv ) |
39 |
{ |
{ |
40 |
QApplication app(argc, argv); |
QApplication app(argc, argv); |
41 |
|
|
42 |
// Load translation support. |
// Load translation support. |
43 |
QTranslator translator(0); |
QTranslator translator(0); |
44 |
QString sLocale = QTextCodec::codecForLocale()->name(); |
QLocale loc; |
45 |
if (sLocale != "C") { //TODO: not sure if "C" locale name exists in Qt4 |
if (loc.language() != QLocale::C) { |
46 |
QString sLocName = "qsampler_" + sLocale; |
QString sLocName = "qsampler_" + loc.name(); |
47 |
if (!translator.load(sLocName, ".")) { |
if (!translator.load(sLocName, ".")) { |
48 |
QString sLocPath = CONFIG_PREFIX "/share/locale"; |
QString sLocPath = CONFIG_PREFIX "/share/locale"; |
49 |
if (!translator.load(sLocName, sLocPath)) |
if (!translator.load(sLocName, sLocPath)) |
50 |
fprintf(stderr, "Warning: no locale found: %s/%s.qm\n", sLocPath.toLatin1().data(), sLocName.toLatin1().data()); |
fprintf(stderr, "Warning: no locale found: %s/%s.qm\n", |
51 |
} |
sLocPath.toUtf8().constData(), |
52 |
app.installTranslator(&translator); |
sLocName.toUtf8().constData()); |
53 |
} |
} |
54 |
|
app.installTranslator(&translator); |
55 |
// Construct default settings; override with command line arguments. |
} |
56 |
qsamplerOptions options; |
|
57 |
if (!options.parse_args(app.argc(), app.argv())) { |
#if defined(__APPLE__) // Toshi Nagata 20080105 |
58 |
app.quit(); |
{ |
59 |
return 1; |
// Set the plugin path to @exetutable_path/../plugins |
60 |
} |
QDir dir(QApplication::applicationDirPath()); |
61 |
|
dir.cdUp(); // "Contents" directory |
62 |
// Construct, setup and show the main form. |
QApplication::setLibraryPaths(QStringList(dir.absolutePath() + "/plugins")); |
63 |
QSampler::MainForm w; |
|
64 |
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); |
// Set the PATH environment variable to include @executable_path/../../.. |
65 |
w.setup(&options); |
dir.cdUp(); |
66 |
w.show(); |
dir.cdUp(); |
67 |
|
QString path(getenv("PATH")); |
68 |
|
path = dir.absolutePath() + ":" + path; |
69 |
|
setenv("PATH", path.toUtf8().constData(), 1); |
70 |
|
} |
71 |
|
#endif |
72 |
|
|
73 |
|
// Construct default settings; override with command line arguments. |
74 |
|
QSampler::Options options; |
75 |
|
if (!options.parse_args(app.argc(), app.argv())) { |
76 |
|
app.quit(); |
77 |
|
return 1; |
78 |
|
} |
79 |
|
|
80 |
|
// Construct, setup and show the main form. |
81 |
|
QSampler::MainForm w; |
82 |
|
w.setup(&options); |
83 |
|
w.show(); |
84 |
|
|
85 |
// Register the quit signal/slot. |
// Register the quit signal/slot. |
86 |
// app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); |
// app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); |
87 |
|
|
88 |
return app.exec(); |
return app.exec(); |
89 |
} |
} |
90 |
|
|
91 |
|
|
92 |
// end of main.cpp |
// end of main.cpp |