LCOV - code coverage report
Current view: top level - src/appshell/qml/MuseScore/AppShell - aboutmodel.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 76 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 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              : #include "aboutmodel.h"
      24              : 
      25              : #include <QClipboard>
      26              : #include <QGuiApplication>
      27              : #include <QUrl>
      28              : 
      29              : #include "translation.h"
      30              : 
      31              : using namespace mu::appshell;
      32              : 
      33              : //! NOTE: Should match value in projectpropertiesmodel.cpp
      34              : static const QString GITHUB_REVISION_URL("https://github.com/musescore/MuseScore/commit/");
      35              : 
      36            0 : AboutModel::AboutModel(QObject* parent)
      37            0 :     : QObject(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
      38              : {
      39            0 : }
      40              : 
      41            0 : QString AboutModel::museScoreVersion() const
      42              : {
      43            0 :     QString version = QString::fromStdString(configuration()->museScoreVersion());
      44            0 :     return application()->unstable()
      45            0 :            ? muse::qtrc("appshell/about", "Unstable prerelease for %1").arg(version)
      46            0 :            : version;
      47            0 : }
      48              : 
      49            0 : QString AboutModel::museScoreRevisionLink() const
      50              : {
      51            0 :     const QString rev = QString::fromStdString(configuration()->museScoreRevision());
      52            0 :     if (rev.isEmpty()) {
      53            0 :         return muse::qtrc("global", "Unknown");
      54              :     }
      55            0 :     const QString revUrl = GITHUB_REVISION_URL + rev;
      56            0 :     return QString("<a href=\"%1\">%2</a>").arg(revUrl, rev);
      57            0 : }
      58              : 
      59            0 : QString AboutModel::museScoreBuildDateTime() const
      60              : {
      61            0 :     auto buildDateISO = []() -> QString {
      62              :         // Attempt to convert __DATE__ into ISO 8601 format (YYYY-MM-DD)
      63            0 :         QDate date = QDate::fromString(__DATE__, "MMM dd yyyy");
      64            0 :         if (!date.isValid()) {
      65            0 :             date = QDate::fromString(__DATE__, "MMM  d yyyy");
      66              :         }
      67            0 :         return date.isValid() ? date.toString(Qt::ISODate) : __DATE__;
      68              :     };
      69              : 
      70            0 :     QString dateTime;
      71            0 :     dateTime += buildDateISO();
      72            0 :     dateTime += " ";
      73            0 :     dateTime += __TIME__;
      74              : 
      75            0 :     return dateTime;
      76            0 : }
      77              : 
      78            0 : QVariantMap AboutModel::museScoreUrl() const
      79              : {
      80            0 :     QUrl museScoreUrl(QString::fromStdString(configuration()->museScoreUrl()));
      81            0 :     return makeUrl(museScoreUrl, false);
      82            0 : }
      83              : 
      84            0 : QVariantMap AboutModel::museScoreForumUrl() const
      85              : {
      86            0 :     QUrl museScoreForumUrl(QString::fromStdString(configuration()->museScoreForumUrl()));
      87            0 :     return makeUrl(museScoreForumUrl);
      88            0 : }
      89              : 
      90            0 : QVariantMap AboutModel::museScoreContributionUrl() const
      91              : {
      92            0 :     QUrl museScoreContributionUrl(QString::fromStdString(configuration()->museScoreContributionUrl()));
      93            0 :     return makeUrl(museScoreContributionUrl);
      94            0 : }
      95              : 
      96            0 : QVariantMap AboutModel::museScorePrivacyPolicyUrl() const
      97              : {
      98            0 :     QUrl museScorePrivacyPolicyUrl(QString::fromStdString(updateConfiguration()->privacyPolicyUrl()));
      99            0 :     return makeUrl(museScorePrivacyPolicyUrl);
     100            0 : }
     101              : 
     102            0 : QVariantMap AboutModel::musicXMLLicenseUrl() const
     103              : {
     104            0 :     QUrl musicXMLLicenseUrl(QString::fromStdString(configuration()->musicXMLLicenseUrl()));
     105            0 :     return makeUrl(musicXMLLicenseUrl);
     106            0 : }
     107              : 
     108            0 : QVariantMap AboutModel::musicXMLLicenseDeedUrl() const
     109              : {
     110            0 :     QUrl musicXMLLicenseDeedUrl(QString::fromStdString(configuration()->musicXMLLicenseDeedUrl()));
     111            0 :     return makeUrl(musicXMLLicenseDeedUrl);
     112            0 : }
     113              : 
     114            0 : void AboutModel::copyRevisionToClipboard() const
     115              : {
     116            0 :     QString osName = QSysInfo::prettyProductName();
     117            0 :     if (QSysInfo::productType() == "windows" && (QSysInfo::productVersion() == "10" || QSysInfo::productVersion() == "11")) {
     118            0 :         osName += " or later";
     119              :     }
     120              : 
     121            0 :     QString forClipboard = QString("OS: %1, Arch.: %2, MuseScore Studio version (%3-bit): %4-%5")
     122            0 :                            .arg(osName, QSysInfo::currentCpuArchitecture())
     123            0 :                            .arg(QSysInfo::WordSize)
     124            0 :                            .arg(application()->version().toString(), application()->build());
     125              : 
     126            0 :     const QString rev = QString::fromStdString(configuration()->museScoreRevision());
     127            0 :     if (!rev.isEmpty()) {
     128            0 :         const QString revUrl = GITHUB_REVISION_URL + rev;
     129            0 :         forClipboard += QString(", revision: [%1](%2)").arg(rev, revUrl);
     130            0 :     }
     131              : 
     132            0 :     QGuiApplication::clipboard()->setText(forClipboard);
     133            0 : }
     134              : 
     135            0 : void AboutModel::toggleDevMode()
     136              : {
     137            0 :     globalConfiguration()->setDevModeEnabled(!globalConfiguration()->devModeEnabled());
     138            0 : }
     139              : 
     140            0 : QVariantMap AboutModel::makeUrl(const QUrl& url, bool showPath) const
     141              : {
     142            0 :     QVariantMap urlMap;
     143            0 :     urlMap["url"] = url.toString();
     144            0 :     urlMap["displayName"] = showPath ? url.host() + url.path() : url.host();
     145              : 
     146            0 :     return urlMap;
     147            0 : }
        

Generated by: LCOV version 2.0-1