-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
103 lines (82 loc) · 3 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
#include <QtGui/QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QFontDatabase>
#include <QSettings>
#include <QtWidgets/QApplication>
#include "applicationmanager.h"
#include "usermanager.h"
#include "youtubeapimanager.h"
#include "playlistsmanager.h"
#include "videoitem.h"
#include "playlist.h"
#include "sslsafenetworkfactory.h"
#include "closeeventfilter.h"
#include "mouseeventfilter.h"
#include <componentslibrary.h>
#include <QmlVlc.h>
#include <QmlVlcConfig.h>
#include <QmlVlcPlayerProxy.h>
QString logFileName;
void myMessageHandler(QtMsgType, const QMessageLogContext&, const QString &message)
{
// QFile outFile(logFileName);
// outFile.open(QIODevice::WriteOnly | QIODevice::Append);
// QTextStream ts(&outFile);
// QDateTime date;
// QString dateStr = date.currentDateTime().toString("[dd/MM/yy | hh:mm:ss]");
// ts << dateStr << " - " << message << endl;
}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
//logFileName = "log.txt";
// qInstallMessageHandler(myMessageHandler);
#ifdef Q_OS_WIN
//qputenv("VLC_PLUGIN_PATH", QString(QCoreApplication::applicationDirPath() + "/vlc_plugins/"));
//qDebug() << qgetenv("VLC_PLUGIN_PATH");
#else
setenv("VLC_PLUGIN_PATH", QString(QCoreApplication::applicationDirPath() + "/vlc_plugins").toLatin1(), 1);
qDebug() << getenv("VLC_PLUGIN_PATH");
#endif
#ifdef Q_OS_LINUX
QApplication::setWindowIcon(QIcon(":/images/logoSymbol"));
#endif
QFontDatabase::addApplicationFont(":/fonts/openSans");
QFontDatabase::addApplicationFont(":/fonts/openSansBold");
QFontDatabase::addApplicationFont(":/fonts/harabara");
ApplicationManager::singleton()->loadConfiguration();
ApplicationManager::declareQML();
UserManager::declareQML();
YoutubeAPIManager::declareQML();
PlaylistsManager::declareQML();
VideoItem::declareQML();
Playlist::declareQML();
Components::initResources();
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
RegisterQmlVlc();
QmlVlcConfig& config = QmlVlcConfig::instance();
config.setNetworkCacheTime(5000);
config.enableAdjustFilter(true);
config.enableMarqueeFilter(true);
config.enableLogoFilter(true);
config.enableDebug(false);
qRegisterMetaType<QmlVlcPlayerProxy::State>("QmlVlcPlayerProxy::State");
QQmlApplicationEngine engine;
engine.setNetworkAccessManagerFactory(new SSLSafeNetworkFactory);
engine.load(QUrl("qrc:/qml/main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
CloseEventFilter closeFilter;
MouseEventFilter mouseFilter;
window->installEventFilter(&closeFilter);
window->installEventFilter(&mouseFilter);
#ifdef Q_OS_WIN
window->setFlags(window->flags() | Qt::FramelessWindowHint);
#else
ApplicationManager::singleton()->setWindowControlButtonsEnabled(false);
#endif
ApplicationManager::singleton()->setWindow(window);
return app.exec();
}