~ubuntu-branches/ubuntu/karmic/qsampler/karmic

« back to all changes in this revision

Viewing changes to src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2008-08-28 08:43:21 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080828084321-guq8v04yg31co9gm
Tags: 0.2.1-1
* New upstream release
* Uploaded to Debian (Closes: #280576)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// main.cpp
2
2
//
3
3
/****************************************************************************
4
 
   Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.
 
4
   Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
 
5
   Copyright (C) 2007, Christian Schoenebeck
5
6
 
6
7
   This program is free software; you can redistribute it and/or
7
8
   modify it under the terms of the GNU General Public License
13
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
15
   GNU General Public License for more details.
15
16
 
16
 
   You should have received a copy of the GNU General Public License
17
 
   along with this program; if not, write to the Free Software
18
 
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
   You should have received a copy of the GNU General Public License along
 
18
   with this program; if not, write to the Free Software Foundation, Inc.,
 
19
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
 
20
21
*****************************************************************************/
21
22
 
22
 
#include <qapplication.h>
23
 
#include <qtextcodec.h>
24
 
 
25
23
#include "qsamplerAbout.h"
26
24
#include "qsamplerOptions.h"
27
25
#include "qsamplerMainForm.h"
28
26
 
29
 
#include "config.h"
 
27
#include <QApplication>
 
28
#include <QTranslator>
 
29
#include <QLocale>
 
30
 
30
31
 
31
32
//-------------------------------------------------------------------------
32
33
// main - The main program trunk.
34
35
 
35
36
int main ( int argc, char **argv )
36
37
{
37
 
    QApplication app(argc, argv);
38
 
 
39
 
    // Load translation support.
40
 
    QTranslator translator(0);
41
 
    QString sLocale = QTextCodec::locale();
42
 
    if (sLocale != "C") {
43
 
        QString sLocName = "qsampler_" + sLocale;
44
 
        if (!translator.load(sLocName, ".")) {
45
 
            QString sLocPath = CONFIG_PREFIX "/share/locale";
46
 
            if (!translator.load(sLocName, sLocPath))
47
 
                fprintf(stderr, "Warning: no locale found: %s/%s.qm\n", sLocPath.latin1(), sLocName.latin1());
48
 
        }
49
 
        app.installTranslator(&translator);
50
 
    }
51
 
 
52
 
    // Construct default settings; override with command line arguments.
53
 
    qsamplerOptions options;
54
 
    if (!options.parse_args(app.argc(), app.argv())) {
55
 
        app.quit();
56
 
        return 1;
57
 
    }
58
 
    
59
 
    // Construct, setup and show the main form.
60
 
    qsamplerMainForm w;
61
 
    w.setup(&options);
62
 
    w.show();
63
 
 
64
 
    // Register the quit signal/slot.
65
 
    app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
66
 
 
67
 
    return app.exec();
 
38
        QApplication app(argc, argv);
 
39
 
 
40
        // Load translation support.
 
41
        QTranslator translator(0);
 
42
        QLocale loc;
 
43
        if (loc.language() != QLocale::C) {
 
44
                QString sLocName = "qsampler_" + loc.name();
 
45
                if (!translator.load(sLocName, ".")) {
 
46
                        QString sLocPath = CONFIG_PREFIX "/share/locale";
 
47
                        if (!translator.load(sLocName, sLocPath))
 
48
                                fprintf(stderr, "Warning: no locale found: %s/%s.qm\n",
 
49
                                        sLocPath.toUtf8().constData(),
 
50
                                        sLocName.toUtf8().constData());
 
51
                }
 
52
                app.installTranslator(&translator);
 
53
        }
 
54
 
 
55
        // Construct default settings; override with command line arguments.
 
56
        QSampler::Options options;
 
57
        if (!options.parse_args(app.argc(), app.argv())) {
 
58
                app.quit();
 
59
                return 1;
 
60
        }
 
61
 
 
62
        // Construct, setup and show the main form.
 
63
        QSampler::MainForm w;
 
64
        w.setup(&options);
 
65
        w.show();
 
66
 
 
67
        // Register the quit signal/slot.
 
68
        // app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
 
69
 
 
70
        return app.exec();
68
71
}
69
72
 
 
73
 
70
74
// end of main.cpp
71