feat: refactor

This commit is contained in:
ZavaruKitsu 2023-09-21 23:02:53 +03:00
parent 3a1f8459e2
commit d2f4a1b32c
8 changed files with 65 additions and 13 deletions

View file

@ -101,6 +101,8 @@ PRIVATE
ayu/ayu_settings.h
ayu/ayu_lang.cpp
ayu/ayu_lang.h
ayu/ayu_infra.cpp
ayu/ayu_infra.h
ayu/ayu_constants.h
ayu/utils/ayu_mapper.cpp
ayu/utils/ayu_mapper.h

View file

@ -0,0 +1,39 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#include "ayu_infra.h"
#include "ayu_lang.h"
#include "ayu/ayu_lottie.h"
#include "ayu/ui/ayu_lottie.h"
#include "lang/lang_instance.h"
namespace AyuInfra
{
void initLang()
{
QString langPackBaseId = Lang::GetInstance().baseId();
QString langPackId = Lang::GetInstance().id();
if (langPackId.isEmpty()) {
LOG(("Lang ID not found! Re-use old language pack..."));
return;
}
CustomLangPack::initInstance();
CustomLangPack::currentInstance()->fetchCustomLangPack(langPackId, langPackBaseId);
}
void initLottie() {
AyuUi::setLottieImpl(std::make_shared<AyuUi::AyuLottieImpl>());
}
void init()
{
initLang();
initLottie();
}
}

View file

@ -0,0 +1,14 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#pragma once
namespace AyuInfra
{
void init();
}

View file

@ -4,7 +4,6 @@
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#include "ayu_lang.h"
#include "qjsondocument.h"

View file

@ -10,7 +10,7 @@
namespace AyuUi
{
std::unique_ptr<Lottie::Icon> getLottie(const QString &text)
std::unique_ptr<Lottie::Icon> AyuLottieImpl::getLottie(const QString &text)
{
// todo: some kind of mapping
// Lottie::MakeIcon({.json = QString(), .sizeOverride = {24, 24}});

View file

@ -7,10 +7,13 @@
#pragma once
#include "lottie/lottie_icon.h"
#include "ayu/ayu_lottie.h"
namespace AyuUi
{
std::unique_ptr<Lottie::Icon> getLottie(const QString &text);
class AyuLottieImpl : public AyuLottie {
std::unique_ptr<Lottie::Icon> getLottie(const QString &text) override;
};
}

View file

@ -32,8 +32,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QDirIterator>
// AyuGram includes
#include "ayu/ayu_infra.h"
#include "ayu/ayu_settings.h"
#include "ayu/ayu_lang.h"
#ifndef Q_OS_WIN
#include <unistd.h>
@ -425,6 +426,8 @@ void start() {
}
readLangPack();
AyuInfra::init();
}
void writeSettings() {
@ -1133,14 +1136,6 @@ void readLangPack() {
if (langpack.stream.status() == QDataStream::Ok) {
Lang::GetInstance().fillFromSerialized(data, langpack.version);
}
QString langPackBaseId = Lang::GetInstance().baseId();
QString langPackId = Lang::GetInstance().id();
if (langPackId.isEmpty()) {
LOG(("Lang ID not found! Re-use old language pack..."));
return;
}
CustomLangPack::initInstance();
CustomLangPack::currentInstance()->fetchCustomLangPack(langPackId, langPackBaseId);
}
void writeLangPack() {

@ -1 +1 @@
Subproject commit e69faa9d6bac69fb44e440ca2cffd86f7ed6b26a
Subproject commit ca3c91fb0be7db2d61defe5c6b0670e0faa93d03