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