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) 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 : #include "systeminfo.h"
23 :
24 : #include <QSysInfo>
25 :
26 : using namespace muse;
27 :
28 : static const std::string CPU_ARCHITECTURE_KEY = "cpuArchitecture";
29 : static const std::string PRODUCT_TYPE_KEY = "productType";
30 : static const std::string PRODUCT_VERSION_KEY = "productVersion";
31 :
32 46 : void SystemInfo::init()
33 : {
34 46 : CpuArchitecture cpuArchitecture = CpuArchitecture::Unknown;
35 46 : QString arch = QSysInfo::buildCpuArchitecture();
36 :
37 46 : if (arch == "x86_64") {
38 46 : cpuArchitecture = CpuArchitecture::x86_64;
39 0 : } else if (arch == "arm") {
40 0 : cpuArchitecture = CpuArchitecture::Arm;
41 0 : } else if (arch == "arm64") {
42 0 : cpuArchitecture = CpuArchitecture::Arm64;
43 : }
44 :
45 46 : m_params[CPU_ARCHITECTURE_KEY] = Val(int(cpuArchitecture));
46 :
47 46 : ProductType productType = ProductType::Unknown;
48 : #if defined(Q_OS_WIN)
49 : productType = ProductType::Windows;
50 : #elif defined(Q_OS_MACOS)
51 : productType = ProductType::MacOS;
52 : #elif defined(Q_OS_LINUX)
53 46 : productType = ProductType::Linux;
54 : #endif
55 :
56 46 : m_params[PRODUCT_TYPE_KEY] = Val(int(productType));
57 :
58 46 : Version version = Version(QSysInfo::productVersion());
59 46 : m_params[PRODUCT_VERSION_KEY] = Val(version.toStdString());
60 46 : }
61 :
62 0 : SystemInfo::CpuArchitecture SystemInfo::cpuArchitecture() const
63 : {
64 0 : return static_cast<CpuArchitecture>(m_params.at(CPU_ARCHITECTURE_KEY).toInt());
65 : }
66 :
67 0 : SystemInfo::ProductType SystemInfo::productType() const
68 : {
69 0 : return static_cast<ProductType>(m_params.at(PRODUCT_TYPE_KEY).toInt());
70 : }
71 :
72 0 : Version SystemInfo::productVersion() const
73 : {
74 0 : return Version(m_params.at(PRODUCT_VERSION_KEY).toString());
75 : }
|