LCOV - code coverage report
Current view: top level - muse/framework/languages/internal - languagesservice.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 2 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2025 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #pragma once
      24              : 
      25              : #include "ilanguagesservice.h"
      26              : #include "async/asyncable.h"
      27              : 
      28              : #include "modularity/ioc.h"
      29              : #include "ilanguagesconfiguration.h"
      30              : #include "framework/network/inetworkmanagercreator.h"
      31              : #include "io/ifilesystem.h"
      32              : #include "multiwindows/imultiwindowsprovider.h"
      33              : 
      34              : #include "progress.h"
      35              : 
      36              : class QJsonObject;
      37              : class QTranslator;
      38              : 
      39              : namespace muse::languages {
      40              : class LanguagesService : public ILanguagesService, public Contextable, public async::Asyncable
      41              : {
      42              :     GlobalInject<ILanguagesConfiguration> configuration;
      43              :     GlobalInject<network::INetworkManagerCreator> networkManagerCreator;
      44              :     GlobalInject<io::IFileSystem> fileSystem;
      45              :     GlobalInject<mi::IMultiWindowsProvider> multiwindowsProvider;
      46              : 
      47              : public:
      48            0 :     LanguagesService(const modularity::ContextPtr& iocCtx)
      49            0 :         : Contextable(iocCtx) {}
      50              : 
      51              :     void init();
      52              : 
      53              :     const LanguagesHash& languages() const override;
      54              :     Language language(const QString& languageCode) const override;
      55              :     const Language& currentLanguage() const override;
      56              :     async::Notification currentLanguageChanged() const override;
      57              : 
      58              :     bool hasPlaceholderLanguage() const override;
      59              :     const Language& placeholderLanguage() const override;
      60              : 
      61              :     Progress update(const QString& languageCode) override;
      62              : 
      63              :     bool restartRequiredToApplyLanguage() const override;
      64              :     async::Channel<bool> restartRequiredToApplyLanguageChanged() const override;
      65              : 
      66              : private:
      67              :     void loadLanguages();
      68              : 
      69              :     void setCurrentLanguage(const QString& languageCode);
      70              :     QString effectiveLanguageCode(QString languageCode) const;
      71              : 
      72              :     Ret loadLanguage(Language& lang);
      73              :     Ret doLoadLanguage(Language& lang);
      74              : 
      75              :     void downloadServerLanguagesInfo(const QString& languageCode, std::function<void(const RetVal<QJsonObject>&)> finished);
      76              :     QStringList languagesToUpdate(const QString& mainLanguageCode, const QJsonObject& serverLanguagesInfo) const;
      77              :     void doUpdateLanguages(const QStringList& languageCodes, Progress overallProgress, std::function<void(const Ret&)> overallFinished);
      78              :     void  doUpdateLanguage(const QString& languageCode, std::function<void(int64_t current, int64_t total,
      79              :                                                                            const std::string&)> progressCallback,
      80              :                            std::function<void(const Ret&)> finished);
      81              : 
      82              :     Ret unpackAndWriteLanguage(const QByteArray& zipData);
      83              : 
      84              :     RetVal<QString> fileHash(const io::path_t& path) const;
      85              : 
      86              : private:
      87              :     LanguagesHash m_languagesHash;
      88              :     Language m_currentLanguage;
      89              :     async::Notification m_currentLanguageChanged;
      90              :     Language m_placeholderLanguage;
      91              : 
      92              :     std::vector<QTranslator*> m_translators;
      93              : 
      94              :     bool m_inited = false;
      95              :     bool m_languageUpdateInProgress = false;
      96              :     bool m_restartRequiredToApplyLanguage = false;
      97              :     async::Channel<bool> m_restartRequiredToApplyLanguageChanged;
      98              : 
      99              :     network::INetworkManagerPtr m_networkManager;
     100              : };
     101              : }
        

Generated by: LCOV version 2.0-1