[go: up one dir, main page]

File: main.cpp

package info (click to toggle)
qabc 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 544 kB
  • sloc: cpp: 2,314; xml: 48; makefile: 3
file content (62 lines) | stat: -rw-r--r-- 2,127 bytes parent folder | download | duplicates (2)
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
// This source code is part of QAbc, a minimal ABC music notation editor.
// QAbc is Copyright © 2021 Benoît Rouits <brouits@free.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 3 of the License, or
// (at your option) any later version.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "config.h"
#include "AbcApplication.h"
#include "AbcMainWindow.h"
#include <QCommandLineParser>
#include <QLibraryInfo>
#include <QLocale>
#include <QTranslator>

int main(int argc, char** argv)
{
	Q_INIT_RESOURCE(resources);

	AbcApplication abcapplication(argc, argv);

	QString locale = QLocale::system().name();
    QTranslator qtTranslator;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
    if (qtTranslator.load(QLocale::system(), u"qtbase"_qs, u"_"_qs,
                          QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
#else
    if (qtTranslator.load("qt_" + locale,
                          QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
#endif
        abcapplication.installTranslator(&qtTranslator);

    QTranslator qabcTranslator;
    if (qabcTranslator.load(TARGET "_" + locale, "locale"))
        abcapplication.installTranslator(&qabcTranslator);
    else if (qabcTranslator.load(TARGET "_" + locale, DATADIR "/" TARGET "/locale"))
        abcapplication.installTranslator(&qabcTranslator);

    QCommandLineParser parser;
	parser.setApplicationDescription("ABC music notation minimal GUI.");
	parser.addHelpOption();
	parser.addVersionOption();
	parser.addPositionalArgument("score", QCoreApplication::translate("main", "ABC score file to work on."));

	parser.process(abcapplication);

	AbcMainWindow w;
	abcapplication.setMainWindow(&w);

	QString iconpath = QString(DATADIR "/pixmaps/" TARGET ".png");
	if (QFileInfo::exists(iconpath))
		abcapplication.setWindowIcon(QIcon(iconpath));

	const QStringList args = parser.positionalArguments();
	if (args.length() > 0)
		abcapplication.openFileNames(args);

	return abcapplication.exec();
}