mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
feat: refactor
This commit is contained in:
parent
3a1f8459e2
commit
d2f4a1b32c
8 changed files with 65 additions and 13 deletions
|
@ -101,6 +101,8 @@ PRIVATE
|
||||||
ayu/ayu_settings.h
|
ayu/ayu_settings.h
|
||||||
ayu/ayu_lang.cpp
|
ayu/ayu_lang.cpp
|
||||||
ayu/ayu_lang.h
|
ayu/ayu_lang.h
|
||||||
|
ayu/ayu_infra.cpp
|
||||||
|
ayu/ayu_infra.h
|
||||||
ayu/ayu_constants.h
|
ayu/ayu_constants.h
|
||||||
ayu/utils/ayu_mapper.cpp
|
ayu/utils/ayu_mapper.cpp
|
||||||
ayu/utils/ayu_mapper.h
|
ayu/utils/ayu_mapper.h
|
||||||
|
|
39
Telegram/SourceFiles/ayu/ayu_infra.cpp
Normal file
39
Telegram/SourceFiles/ayu/ayu_infra.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
Telegram/SourceFiles/ayu/ayu_infra.h
Normal file
14
Telegram/SourceFiles/ayu/ayu_infra.h
Normal 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();
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
// but be respectful and credit the original author.
|
// but be respectful and credit the original author.
|
||||||
//
|
//
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include "ayu_lang.h"
|
#include "ayu_lang.h"
|
||||||
|
|
||||||
#include "qjsondocument.h"
|
#include "qjsondocument.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace AyuUi
|
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
|
// todo: some kind of mapping
|
||||||
// Lottie::MakeIcon({.json = QString(), .sizeOverride = {24, 24}});
|
// Lottie::MakeIcon({.json = QString(), .sizeOverride = {24, 24}});
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "lottie/lottie_icon.h"
|
#include "lottie/lottie_icon.h"
|
||||||
|
#include "ayu/ayu_lottie.h"
|
||||||
|
|
||||||
namespace AyuUi
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <QtCore/QDirIterator>
|
#include <QtCore/QDirIterator>
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/ayu_infra.h"
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
#include "ayu/ayu_lang.h"
|
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -425,6 +426,8 @@ void start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
readLangPack();
|
readLangPack();
|
||||||
|
|
||||||
|
AyuInfra::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeSettings() {
|
void writeSettings() {
|
||||||
|
@ -1133,14 +1136,6 @@ void readLangPack() {
|
||||||
if (langpack.stream.status() == QDataStream::Ok) {
|
if (langpack.stream.status() == QDataStream::Ok) {
|
||||||
Lang::GetInstance().fillFromSerialized(data, langpack.version);
|
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() {
|
void writeLangPack() {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e69faa9d6bac69fb44e440ca2cffd86f7ed6b26a
|
Subproject commit ca3c91fb0be7db2d61defe5c6b0670e0faa93d03
|
Loading…
Add table
Reference in a new issue