-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
147 lines (112 loc) · 4.28 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include <QFontDatabase>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCommandLineParser>
#include <QIcon>
#if defined Q_OS_MACOS || defined Q_OS_WIN
#include <KF5/KI18n/KLocalizedString>
#else
#include <KI18n/KLocalizedString>
#endif
#if defined Q_OS_ANDROID || defined Q_OS_IOS
#include <QGuiApplication>
#else
#include <QApplication>
#endif
#include "kde/mpris2/mpris2.h"
#if defined Q_OS_LINUX && !defined Q_OS_ANDROID
#include "kde/mpris2/mediaplayer2player.h"
#endif
#ifdef Q_OS_ANDROID
#include "mauiandroid.h"
#endif
#ifdef Q_OS_MACOS
#include "mauimacos.h"
#endif
#include "vvave_version.h"
#include <MauiKit/fmstatic.h>
#include <MauiKit/mauiapp.h>
#include "vvave.h"
#include "services/local/artworkprovider.h"
#include "services/local/player.h"
#include "services/local/playlist.h"
#include "utils/bae.h"
#include "models/albums/albumsmodel.h"
#include "models/cloud/cloud.h"
#include "models/playlists/playlistsmodel.h"
#include "models/tracks/tracksmodel.h"
#include "models/folders/foldersmodel.h"
#define VVAVE_URI "org.maui.vvave"
#ifdef Q_OS_ANDROID
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
QCoreApplication::setAttribute(Qt::AA_DisableSessionManager, true);
#ifdef Q_OS_WIN32
qputenv("QT_MULTIMEDIA_PREFERRED_PLUGINS", "w");
#endif
#if defined Q_OS_ANDROID | defined Q_OS_IOS
QGuiApplication app(argc, argv);
#else
QApplication app(argc, argv);
#endif
#ifdef Q_OS_ANDROID
if (!MAUIAndroid::checkRunTimePermissions({"android.permission.WRITE_EXTERNAL_STORAGE"}))
return -1;
#endif
app.setOrganizationName(QStringLiteral("Maui"));
app.setWindowIcon(QIcon("qrc:/assets/vvave.png"));
MauiApp::instance()->setHandleAccounts(true); // for now pix can not handle cloud accounts
MauiApp::instance()->setIconName("qrc:/assets/vvave.png");
KLocalizedString::setApplicationDomain("vvave");
KAboutData about(
QStringLiteral("vvave"), i18n("Vvave"), VVAVE_VERSION_STRING, i18n("Vvave lets you organize, browse and listen to your local and online music collection."), KAboutLicense::LGPL_V3, i18n("© 2019-%1 Nitrux Development Team", QString::number(QDate::currentDate().year())));
about.addAuthor(i18n("Camilo Higuita"), i18n("Developer"), QStringLiteral("[email protected]"));
about.setHomepage("https://mauikit.org");
about.setProductName("maui/vvave");
about.setBugAddress("https://invent.kde.org/maui/vvave/-/issues");
about.setOrganizationDomain(VVAVE_URI);
about.setProgramLogo(app.windowIcon());
KAboutData::setApplicationData(about);
QCommandLineParser parser;
parser.process(app);
about.setupCommandLine(&parser);
about.processCommandLine(&parser);
const QStringList args = parser.positionalArguments();
QFontDatabase::addApplicationFont(":/assets/materialdesignicons-webfont.ttf");
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreated,
&app,
[url, args](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
if (!args.isEmpty())
vvave::instance()->openUrls(args);
},
Qt::QueuedConnection);
qmlRegisterSingletonInstance<vvave>(VVAVE_URI, 1, 0, "Vvave", vvave::instance());
qmlRegisterType<TracksModel>(VVAVE_URI, 1, 0, "Tracks");
qmlRegisterType<PlaylistsModel>(VVAVE_URI, 1, 0, "Playlists");
qmlRegisterType<AlbumsModel>(VVAVE_URI, 1, 0, "Albums");
qmlRegisterType<Cloud>(VVAVE_URI, 1, 0, "Cloud");
qmlRegisterType<FoldersModel>(VVAVE_URI, 1, 0, "Folders");
qmlRegisterType<Player>(VVAVE_URI, 1, 0, "Player");
qmlRegisterType<Playlist>(VVAVE_URI, 1, 0, "Playlist");
qmlRegisterType<Mpris2>(VVAVE_URI, 1, 0, "Mpris2");
engine.addImageProvider("artwork", new ArtworkProvider());
#if defined Q_OS_LINUX && !defined Q_OS_ANDROID
qRegisterMetaType<MediaPlayer2Player *>();
#endif
engine.load(url);
#ifdef Q_OS_MACOS
// MAUIMacOS::removeTitlebarFromWindow();
#endif
return app.exec();
}