forked from StephaneCouturier/Katalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·118 lines (95 loc) · 4.83 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*LICENCE
This file is part of Katalog
Copyright (C) 2020, the Katalog Development team
Author: Stephane Couturier (Symbioxy)
Katalog 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.
Katalog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Katalog; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*FILE DESCRIPTION
* /////////////////////////////////////////////////////////////////////////////
// Application: Katalog
// File Name: main.cpp
// Purpose: Main file for the application at start
// Description: Generates the app, initialize language, theme, fallback icons, translation, and the main window
// Author: Stephane Couturier
// Version: 1.00
/////////////////////////////////////////////////////////////////////////////
*/
#include <QApplication>
#include <QCommandLineParser>
#include <QTranslator>
#ifdef Q_OS_LINUX
#include <KAboutData>
#include <KLocalizedString>
#endif
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//Get language choice and apply translation
//Get user home path
QStringList standardsPaths = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
QString homePath = standardsPaths[0];
//Define Setting file path and name
QString settingsFilePath = homePath + "/.config/katalog_settings.ini";
QSettings settings(settingsFilePath, QSettings:: IniFormat);
QString userLanguage = settings.value("Settings/Language").toString();
//Define a language for the first run (no value in the settings file)
if ( userLanguage == "" ){
//Get the language of the user's system
userLanguage = QLocale::system().name();
//If this language is not supported yet, default to Engish US.
QStringList availableUserLanguages;
availableUserLanguages << "en_US" << "fr_FR" << "cz_CZ";
if ( availableUserLanguages.contains(userLanguage) == false )
userLanguage = "en_US";
}
QTranslator* translator=new QTranslator(0);
if (translator->load("Katalog_" + userLanguage, ":translations")) {
app.installTranslator(translator);
}
#ifdef Q_OS_LINUX
KLocalizedString::setApplicationDomain("Katalog");
KAboutData aboutData(
QStringLiteral("Katalog"), // The program name used internally. (componentName)
i18n("Katalog"), // A displayable program name string. (displayName)
QStringLiteral("1.00"), // The program version string. (version)
// Short description of what the app does. (shortDescription)
i18n("Katalog is an application to catalog, search, and manage files from any drive, permanent or removable."),
KAboutLicense::GPL,// The license this code is released under
i18n("(c) 2021 Stephane JM Couturier"),// Copyright Statement (copyrightStatement = QString())
// Optional text shown in the About box.
// Can contain any information desired. (otherText)
i18n(""),
// The program homepage string. (homePageAddress = QString())
QStringLiteral("https://github.com/StephaneCouturier/Katalog/wiki"),
// The bug report address
// (bugsEmailAddress = QLatin1String("[email protected]")
QStringLiteral("https://github.com/StephaneCouturier/Katalog/issues/new"));
aboutData.addAuthor(i18n("Stéphane Couturier"), i18n("Creator"), QStringLiteral("[email protected]"),
QStringLiteral("https://github.com/StephaneCouturier/"), QStringLiteral("OSC Username"));
KAboutData::setApplicationData(aboutData);
QCommandLineParser parser;
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
#else
QApplication::setStyle("fusion");
#endif
//Set theme (on linux it would use the Desktop one, on windows this will fallbak to the pathset jsut after)
QIcon::setThemeName( "breeze" );
//Set icon fallback in case theme is not available
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":fallback-icons");
MainWindow* window = new MainWindow();
window->show();
return app.exec();
}