LCOV - code coverage report
Current view: top level - muse/framework/workspace/internal - workspaceconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 32 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) 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 "workspaceconfiguration.h"
      23              : 
      24              : #include "settings.h"
      25              : 
      26              : #include "global/configreader.h"
      27              : 
      28              : using namespace muse;
      29              : using namespace muse::workspace;
      30              : 
      31              : static const muse::Settings::Key CURRENT_WORKSPACE("workspace", "workspace");
      32              : 
      33            0 : void WorkspaceConfiguration::init()
      34              : {
      35            0 :     fileSystem()->makePath(userWorkspacesPath());
      36              : 
      37            0 :     m_config = ConfigReader::read(":/configs/workspaces.cfg");
      38              : 
      39            0 :     settings()->setDefaultValue(CURRENT_WORKSPACE, Val(defaultWorkspaceName()));
      40            0 :     settings()->valueChanged(CURRENT_WORKSPACE).onReceive(this, [this](const Val& name) {
      41            0 :         m_currentWorkspaceNameChanged.send(name.toString());
      42            0 :     });
      43            0 : }
      44              : 
      45            0 : io::paths_t WorkspaceConfiguration::workspacePaths() const
      46              : {
      47            0 :     io::paths_t paths;
      48            0 :     paths.push_back(userWorkspacesPath());
      49              : 
      50            0 :     return paths;
      51            0 : }
      52              : 
      53            0 : io::paths_t WorkspaceConfiguration::builtinWorkspacesFilePaths() const
      54              : {
      55            0 :     io::paths_t result;
      56              : 
      57            0 :     ValList builtinWorkspacesFiles = m_config.value("builtin_workspace_files").toList();
      58            0 :     io::path_t appDir = globalConfiguration()->appDataPath();
      59              : 
      60            0 :     for (const Val& builtinWorkspaceFileVal : builtinWorkspacesFiles) {
      61            0 :         result.emplace_back(appDir + "/workspaces/" + builtinWorkspaceFileVal.toString());
      62              :     }
      63              : 
      64            0 :     return result;
      65            0 : }
      66              : 
      67            0 : io::path_t WorkspaceConfiguration::userWorkspacesPath() const
      68              : {
      69            0 :     return globalConfiguration()->userAppDataPath() + "/workspaces";
      70              : }
      71              : 
      72            0 : std::string WorkspaceConfiguration::defaultWorkspaceName() const
      73              : {
      74            0 :     return m_config.value("default_workspace_name").toString();
      75              : }
      76              : 
      77            0 : std::string WorkspaceConfiguration::currentWorkspaceName() const
      78              : {
      79            0 :     return settings()->value(CURRENT_WORKSPACE).toString();
      80              : }
      81              : 
      82            0 : void WorkspaceConfiguration::setCurrentWorkspaceName(const std::string& workspaceName)
      83              : {
      84              :     //! NOTE Workspace selection does not need to be synchronized between instances
      85            0 :     settings()->setLocalValue(CURRENT_WORKSPACE, Val(workspaceName));
      86            0 : }
      87              : 
      88            0 : async::Channel<std::string> WorkspaceConfiguration::currentWorkspaceNameChanged() const
      89              : {
      90            0 :     return m_currentWorkspaceNameChanged;
      91              : }
        

Generated by: LCOV version 2.0-1