-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
93 lines (80 loc) · 3.51 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
/****************************************
*
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
* Copyright (C) 2020 Victor Tran
*
* 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
* *************************************/
#include "mainwindow.h"
#include <QDir>
#include <tapplication.h>
#include <notificationengine.h>
#include <entertaining.h>
#include <tsettings.h>
#include <musicengine.h>
#include <discordintegration.h>
int main(int argc, char* argv[]) {
tApplication a(argc, argv);
a.registerCrashTrap();
if (QDir("/usr/share/entertaining-chess").exists()) {
a.setShareDir("/usr/share/entertaining-chess");
} else if (QDir(QDir::cleanPath(QApplication::applicationDirPath() + "/../share/entertaining-chess/")).exists()) {
a.setShareDir(QDir::cleanPath(QApplication::applicationDirPath() + "/../share/entertaining-chess/"));
}
a.installTranslators();
a.setOrganizationName("theSuite");
a.setOrganizationDomain("");
a.setApplicationIcon(QIcon::fromTheme("entertaining-chess", QIcon(":/assets/entertaining-chess.svg")));
a.setApplicationVersion("0.1");
a.setGenericName(QApplication::translate("main", "Chess"));
a.setApplicationLicense(tApplication::Gpl3OrLater);
a.setCopyrightHolder("Victor Tran, Mart Koster");
a.setCopyrightYear("2021");
a.setDesktopFileName("com.vicr123.entertaining.chess");
#ifdef T_BLUEPRINT_BUILD
a.setApplicationName("Entertaining Chess Blueprint");
#else
a.setApplicationName("Entertaining Chess");
#endif
#if defined(Q_OS_WIN)
QIcon::setThemeName("contemporary-icons");
QIcon::setThemeSearchPaths({a.applicationDirPath() + "\\icons"});
tSettings::registerDefaults(a.applicationDirPath() + "/defaults.conf");
#elif defined(Q_OS_MAC)
QIcon::setThemeName("contemporary-icons");
QIcon::setThemeSearchPaths({a.macOSBundlePath() + "/Contents/Resources/icons"});
tSettings::registerDefaults(a.macOSBundlePath() + "/Contents/Resources/defaults.conf");
a.setQuitOnLastWindowClosed(false);
#else
tSettings::registerDefaults(a.applicationDirPath() + "/defaults.conf");
tSettings::registerDefaults("/etc/entertaining-games/entertaining-chess/defaults.conf");
#endif
Entertaining::initialize();
DiscordIntegration::makeInstance("795591987495436298", "");
tSettings settings;
QObject::connect(&settings, &tSettings::settingChanged, [ = ](QString key, QVariant value) {
if (key == "audio/backgroundVol") {
MusicEngine::setUserBackgroundVolume(value.toInt() / 100.0);
} else if (key == "audio/effects") {
MusicEngine::setMuteEffects(!value.toBool());
}
});
MusicEngine::setUserBackgroundVolume(settings.value("audio/backgroundVol").toInt() / 100.0);
MusicEngine::setMuteEffects(!settings.value("audio/effects").toBool());
MainWindow w;
w.show();
NotificationEngine::setApplicationNotificationWindow(&w);
return a.exec();
}