/
NeoChapay
/
telegraf
Обзор
Документация
Войти
/
NeoChapay
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/telegraf.cpp
124 строки
5 KB
mbarashkov
Версия 0.72.0
11 янв 2025, 15:23
11 янв 2025, 15:23
ef79c93
Код
Авторство
О чём код?
#ifdef QT_QML_DEBUG #include <QtQuick> #endif #include <auroraapp.h> #include <QScopedPointer> #include <QQuickView> #include <QtQml> #include <QQmlContext> #include <QQmlEngine> #include <QGuiApplication> #include <QLoggingCategory> #include <QSysInfo> #include <QSettings> #include <QDir> #include <QDirIterator> #include <QFile> #include <QFileInfo> #include "appsettings.h" #include "debuglog.h" #include "debuglogjs.h" #include "tdlibfile.h" #include "tdlibwrapper.h" #include "chatpermissionfiltermodel.h" #include "chatlistmodel.h" #include "chatlistsortedmodel.h" #include "chatmodel.h" #include "namedaction.h" #include "notificationmanager.h" #include "mceinterface.h" #include "dbusadaptor.h" #include "processlauncher.h" #include "stickermanager.h" #include "textfiltermodel.h" #include "boolfiltermodel.h" #include "tgsplugin.h" #include "telegrafutils.h" #include "knownusersmodel.h" #include "contactsmodel.h" #include "filevalidator.h" // The default filter can be overridden by QT_LOGGING_RULES envinronment variable, e.g. // QT_LOGGING_RULES="telegraf.*=true" telegraf #if defined VERBOSE_LOGGING # define DEFAULT_LOG_FILTER "telegraf.*=true" #else # define DEFAULT_LOG_FILTER "telegraf.*=false" #endif Q_IMPORT_PLUGIN(TgsIOPlugin) int main(int argc, char *argv[]) { QLoggingCategory::setFilterRules(DEFAULT_LOG_FILTER); QScopedPointer<QGuiApplication> app(Aurora::Application::application(argc, argv)); QScopedPointer<QQuickView> view(Aurora::Application::createView()); app->setApplicationVersion("0.72.0"); QQmlContext *context = view.data()->rootContext(); const char *uri = "ru.telegrafaurora.telegraf"; qmlRegisterType<TDLibFile>(uri, 1, 0, "TDLibFile"); qmlRegisterType<NamedAction>(uri, 1, 0, "NamedAction"); qmlRegisterType<TextFilterModel>(uri, 1, 0, "TextFilterModel"); qmlRegisterType<BoolFilterModel>(uri, 1, 0, "BoolFilterModel"); qmlRegisterType<ChatListSortedModel>(uri, 1, 0, "ChatListSortedModel"); qmlRegisterType<ChatPermissionFilterModel>(uri, 1, 0, "ChatPermissionFilterModel"); qmlRegisterType<FileValidator>(uri, 1, 0, "FileValidator"); qmlRegisterSingletonType<DebugLogJS>(uri, 1, 0, "DebugLog", DebugLogJS::createSingleton); AppSettings *appSettings = new AppSettings(view.data()); context->setContextProperty("appSettings", appSettings); qmlRegisterUncreatableType<AppSettings>(uri, 1, 0, "AppSettings", QString()); MceInterface *mceInterface = new MceInterface(view.data()); TDLibWrapper *tdLibWrapper = new TDLibWrapper(appSettings, mceInterface, view.data()); context->setContextProperty("tdLibWrapper", tdLibWrapper); qmlRegisterUncreatableType<TDLibWrapper>(uri, 1, 0, "TelegramAPI", QString()); TelegrafUtils *telegrafUtils = new TelegrafUtils(view.data()); context->setContextProperty("telegrafUtils", telegrafUtils); qmlRegisterUncreatableType<TelegrafUtils>(uri, 1, 0, "TelegrafUtilities", QString()); DBusAdaptor *dBusAdaptor = tdLibWrapper->getDBusAdaptor(); context->setContextProperty("dBusAdaptor", dBusAdaptor); ChatListModel chatListModel(tdLibWrapper, appSettings); context->setContextProperty("chatListModel", &chatListModel); ChatModel chatModel(tdLibWrapper); context->setContextProperty("chatModel", &chatModel); NotificationManager notificationManager(tdLibWrapper, appSettings, mceInterface, &chatModel); context->setContextProperty("notificationManager", ¬ificationManager); ProcessLauncher processLauncher; context->setContextProperty("processLauncher", &processLauncher); StickerManager stickerManager(tdLibWrapper); context->setContextProperty("stickerManager", &stickerManager); KnownUsersModel knownUsersModel(tdLibWrapper, view.data()); context->setContextProperty("knownUsersModel", &knownUsersModel); QSortFilterProxyModel knownUsersProxyModel(view.data()); knownUsersProxyModel.setSourceModel(&knownUsersModel); knownUsersProxyModel.setFilterRole(KnownUsersModel::RoleFilter); knownUsersProxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive); context->setContextProperty("knownUsersProxyModel", &knownUsersProxyModel); ContactsModel contactsModel(tdLibWrapper, view.data()); context->setContextProperty("contactsModel", &contactsModel); QSortFilterProxyModel contactsProxyModel(view.data()); contactsProxyModel.setSourceModel(&contactsModel); contactsProxyModel.setFilterRole(ContactsModel::RoleFilter); contactsProxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive); context->setContextProperty("contactsProxyModel", &contactsProxyModel); view->setSource(Aurora::Application::pathTo("qml/telegraf.qml")); view->show(); return app->exec(); }