]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/main.cpp
ad23101308f26360e730b358fb6c2d968c0aa86f
[PrivacyBrowserPC.git] / src / main.cpp
1 /*
2  * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
5  *
6  * Privacy Browser PC is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Privacy Browser PC is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 // Application headers.
21 #include "helpers/DomainsDatabaseHelper.h"
22 #include "windows/BrowserWindow.h"
23
24 // KDE Frameworks headers.
25 #include <KAboutData>
26 #include <KCrash>
27 #include <KLocalizedString>
28 #include <KDBusService>
29
30 // Qt headers.
31 #include <QApplication>
32 #include <QCommandLineParser>
33 #include <QFile>
34
35 int main(int argc, char *argv[])
36 {
37     // Create the application.
38     QApplication application(argc, argv);
39
40     // Set the localization application domain.
41     KLocalizedString::setApplicationDomain("privacybrowser");
42
43     // Initialize KCrash.
44     KCrash::initialize();
45
46     // Instantiate about data, setting the component name, the display name, and the version.
47     KAboutData aboutData(QStringLiteral("privacybrowser"), i18n("Privacy Browser"), QStringLiteral("0.1"));
48
49     // Add the author name, job description, email address, and website.
50     aboutData.addAuthor(i18n("Soren Stoutner"),i18n("Principal developer"), QStringLiteral("soren@stoutner.com"), QStringLiteral("https://www.stoutner.com/"));
51
52     // Populate additional about data info.
53     aboutData.setBugAddress("https://redmine.stoutner.com/projects/privacy-browser-pc/issues");
54     aboutData.setCopyrightStatement(i18n("Copyright © 2016-2017,2021-2022 Soren Stoutner <soren@stoutner.com>"));
55     aboutData.setDesktopFileName(QStringLiteral("com.stoutner.privacybrowser"));
56     aboutData.setHomepage(QStringLiteral("https://www.stoutner.com/privacy-browser-pc/"));
57     aboutData.setLicenseTextFile(":/licenses/GPLv3+.txt");
58     aboutData.setOrganizationDomain("stoutner.com");
59     aboutData.setShortDescription(i18n("A web browser that respects your privacy."));
60
61     // Set the application data.
62     KAboutData::setApplicationData(aboutData);
63
64     // Set the window icon.
65     application.setWindowIcon(QIcon::fromTheme(QStringLiteral("privacy-browser"), QIcon(":/icons/sc-apps-privacy-browser.svg")));
66
67     // Create a command line parser.
68     QCommandLineParser commandLineParser;
69
70     // Process the command line through about data (this adds --license and --author).
71     aboutData.setupCommandLine(&commandLineParser);
72
73     // Process the application command line options (this adds --version, --help, and --help-all).
74     commandLineParser.process(application);
75
76     // Make it so.
77     aboutData.processCommandLine(&commandLineParser);
78
79     // Register with D-Bus, allowing multiple instances and allowing the program to run if for some reason the registration fails.
80     KDBusService appDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure);
81
82     // Add the domains database.
83     DomainsDatabaseHelper::addDatabase();
84
85     // Create the main window.
86     BrowserWindow *browserWindowPointer = new BrowserWindow();
87
88     // Show the main window.
89     browserWindowPointer->show();
90
91     // Return the application.
92     return application.exec();
93 }