/[svn]/qsampler/trunk/src/main.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC revision 1667 by schoenebeck, Mon Feb 4 23:24:19 2008 UTC
# Line 2  Line 2 
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, 2008 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
# Line 19  Line 20 
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);          Q_INIT_RESOURCE(qsampler);
41    
42      // Load translation support.          QApplication app(argc, argv);
     QTranslator translator(0);  
     QString sLocale = QTextCodec::codecForLocale()->name();  
     if (sLocale != "C") { //TODO: not sure if "C" locale name exists in Qt4  
         QString sLocName = "qsampler_" + sLocale;  
         if (!translator.load(sLocName, ".")) {  
             QString sLocPath = CONFIG_PREFIX "/share/locale";  
             if (!translator.load(sLocName, sLocPath))  
                 fprintf(stderr, "Warning: no locale found: %s/%s.qm\n", sLocPath.toLatin1().data(), sLocName.toLatin1().data());  
         }  
         app.installTranslator(&translator);  
     }  
   
     // Construct default settings; override with command line arguments.  
     qsamplerOptions options;  
     if (!options.parse_args(app.argc(), app.argv())) {  
         app.quit();  
         return 1;  
     }  
   
     // Construct, setup and show the main form.  
     QSampler::MainForm w;  
         app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));  
     w.setup(&options);  
     w.show();  
43    
44      // Register the quit signal/slot.          // Load translation support.
45      // app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));          QTranslator translator(0);
46            QLocale loc;
47            if (loc.language() != QLocale::C) {
48                    QString sLocName = "qsampler_" + loc.name();
49                    if (!translator.load(sLocName, ".")) {
50                            QString sLocPath = CONFIG_PREFIX "/share/locale";
51                            if (!translator.load(sLocName, sLocPath))
52                                    fprintf(stderr, "Warning: no locale found: %s/%s.qm\n",
53                                            sLocPath.toUtf8().constData(),
54                                            sLocName.toUtf8().constData());
55                    }
56                    app.installTranslator(&translator);
57            }
58    
59            #if defined(__APPLE__)  //  Toshi Nagata 20080105
60            {
61                    //  Set the plugin path to @exetutable_path/../plugins
62                    QDir dir(QApplication::applicationDirPath());
63                    dir.cdUp();  // "Contents" directory
64                    QApplication::setLibraryPaths(QStringList(dir.absolutePath() + "/plugins"));
65    
66                    //  Set the PATH environment variable to include @executable_path/../../..
67                    dir.cdUp();
68                    dir.cdUp();
69                    QString path(getenv("PATH"));
70                    path = dir.absolutePath() + ":" + path;
71                    setenv("PATH", path.toUtf8().constData(), 1);
72            }
73            #endif
74    
75            // Construct default settings; override with command line arguments.
76            QSampler::Options options;
77            if (!options.parse_args(app.argc(), app.argv())) {
78                    app.quit();
79                    return 1;
80            }
81    
82            // Construct, setup and show the main form.
83            QSampler::MainForm w;
84            w.setup(&options);
85            w.show();
86    
87      return app.exec();          // Register the quit signal/slot.
88            // app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
89    
90            return app.exec();
91  }  }
92    
93    
94  // end of main.cpp  // end of main.cpp

Legend:
Removed from v.1461  
changed lines
  Added in v.1667

  ViewVC Help
Powered by ViewVC