]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/main.cpp
9ff1e4d0534cda8c0c3e14a84f89366e4d17aac2
[PrivacyBrowserPC.git] / src / main.cpp
1 /*
2  * Copyright 2022-2024 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 "GlobalVariables.h"
22 #include "databases/BookmarksDatabase.h"
23 #include "databases/CookiesDatabase.h"
24 #include "databases/DomainsDatabase.h"
25 #include "helpers/FilterListHelper.h"
26 #include "windows/BrowserWindow.h"
27
28 // KDE Frameworks headers.
29 #include <KAboutData>
30 #include <KCrash>
31 #include <KDBusService>
32 #include <KLocalizedString>
33
34 // Qt headers.
35 #include <QApplication>
36 #include <QCommandLineParser>
37 #include <QFile>
38
39 // Declare the global variables.
40 FilterListHelper *globalFilterListHelperPointer;
41
42 int main(int argc, char *argv[])
43 {
44     // Create the application.
45     QApplication application(argc, argv);
46
47     // Set the localization application domain.
48     KLocalizedString::setApplicationDomain("privacybrowser");
49
50     // Initialize KCrash.
51     KCrash::initialize();
52
53     // Instantiate about data, setting the component name, the display name, and the version.
54     KAboutData aboutData(QStringLiteral("privacybrowser"), i18nc("Program Name", "Privacy Browser"), QStringLiteral("0.5"));
55
56     // Add the author name, job description, email address, and website.
57     aboutData.addAuthor(i18nc("Developer Information", "Soren Stoutner"),i18nc("Developer Information", "Principal developer"), QStringLiteral("soren@stoutner.com"),
58                         QStringLiteral("https://www.stoutner.com/"));
59
60     // Populate additional about data info.
61     aboutData.setBugAddress("https://redmine.stoutner.com/projects/privacy-browser-pc/issues");
62     aboutData.setCopyrightStatement(i18nc("Copyright", "Copyright 2016-2017,2021-2024 Soren Stoutner <soren@stoutner.com>"));
63     aboutData.setDesktopFileName(QStringLiteral("com.stoutner.privacybrowser"));
64     aboutData.setHomepage(QStringLiteral("https://www.stoutner.com/privacy-browser-pc/"));
65     //aboutData.setLicense(KAboutLicense::GPL_V3, KAboutLicense::OrLaterVersions);  <https://redmine.stoutner.com/issues/822>
66     aboutData.setLicenseTextFile(QStringLiteral(":/licenses/GPLv3+.txt"));
67     aboutData.setOrganizationDomain("stoutner.com");
68     aboutData.setShortDescription(i18nc("Tagline", "A web browser that respects your privacy."));
69
70     // Set the application data.
71     KAboutData::setApplicationData(aboutData);
72
73     // Set the window icon.
74     application.setWindowIcon(QIcon::fromTheme(QStringLiteral("privacy-browser"), QIcon(QStringLiteral(":/icons/sc-apps-privacybrowser.svg"))));
75
76     // Create a command line parser.
77     QCommandLineParser commandLineParser;
78
79     // Process the command line through about data (this adds --license and --author).
80     aboutData.setupCommandLine(&commandLineParser);
81
82     // Process the application command line options (this adds --version, --help, and --help-all).
83     commandLineParser.process(application);
84
85     // Make it so.
86     aboutData.processCommandLine(&commandLineParser);
87
88     // Register with D-Bus, allowing multiple instances and allowing the program to run if for some reason the registration fails.
89     KDBusService appDBusService(KDBusService::Multiple | KDBusService::NoExitOnFailure);
90
91     // Create the app data location directory if it doesn't currently exist.  This directory is used to store the databases in the subsequent commands.
92     // The first directory in the list should be the private, writable location, which on Linux should be `/home/user/.local/share/privacybrowser`.
93     QDir().mkdir(QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first());
94
95     // Add the databases.
96     BookmarksDatabase::addDatabase();
97     CookiesDatabase::addDatabase();
98     DomainsDatabase::addDatabase();
99
100     // Populate the filter lists.
101     globalFilterListHelperPointer = new FilterListHelper;
102
103     // Create the main window.
104     BrowserWindow *browserWindowPointer = new BrowserWindow();
105
106     // Show the main window.
107     browserWindowPointer->show();
108
109     // Return the application.
110     return application.exec();
111 }