Skip to content

Commit

Permalink
Implemented stubs for userscores module
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism authored and igorkorsukov committed Jan 22, 2021
1 parent d981e7c commit b0ce85b
Show file tree
Hide file tree
Showing 29 changed files with 390 additions and 41 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(TELEMETRY_TRACK_ID "" CACHE STRING "Telemetry track id")
set(CRASH_REPORT_URL "" CACHE STRING "URL where to send crash reports")

option(BUILD_NETWORK_MODULE "Build network module" ON)
option(BUILD_USERSCORES_MODULE "Build userscores module" ON)
option(BUILD_EXTENSIONS_MODULE "Build extensions module" ON)
option(BUILD_LANGUAGES_MODULE "Build languages module" ON)

Expand Down
1 change: 1 addition & 0 deletions build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define TELEMETRY_TRACK_ID "${TELEMETRY_TRACK_ID}"

#cmakedefine BUILD_NETWORK_MODULE
#cmakedefine BUILD_USERSCORES_MODULE
#cmakedefine BUILD_EXTENSIONS_MODULE
#cmakedefine BUILD_LANGUAGES_MODULE

Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ add_subdirectory(appshell)
add_subdirectory(audiofile)
add_subdirectory(context)
add_subdirectory(notation)
add_subdirectory(userscores)

if (BUILD_USERSCORES_MODULE)
add_subdirectory(userscores)
endif (BUILD_USERSCORES_MODULE)

add_subdirectory(converter)
add_subdirectory(workspace)

Expand Down
9 changes: 9 additions & 0 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
#include "appshell/appshellmodule.h"
#include "cloud/cloudmodule.h"
#include "context/contextmodule.h"
#ifdef BUILD_USERSCORES_MODULE
#include "userscores/userscoresmodule.h"
#else
#include "stubs/userscores/userscoresstubmodule.h"
#endif
#include "plugins/pluginsmodule.h"
#include "notation/notationmodule.h"
#include "importexport/importexportmodule.h"
Expand Down Expand Up @@ -128,7 +132,12 @@ int main(int argc, char** argv)

app.addModule(new mu::audio::AudioModule());
app.addModule(new mu::midi::MidiModule());

#ifdef BUILD_USERSCORES_MODULE
app.addModule(new mu::userscores::UserScoresModule());
#else
app.addModule(new mu::userscores::UserScoresStubModule());
#endif

app.addModule(new mu::notation::NotationModule());
app.addModule(new mu::commonscene::CommonSceneModule());
Expand Down
6 changes: 5 additions & 1 deletion src/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

add_subdirectory(framework)

if (NOT BUILD_USERSCORES_MODULE)
add_subdirectory(userscores)
endif (NOT BUILD_USERSCORES_MODULE)

if (NOT BUILD_EXTENSIONS_MODULE)
add_subdirectory(extensions)
add_subdirectory(extensions)
endif (NOT BUILD_EXTENSIONS_MODULE)

if (NOT BUILD_LANGUAGES_MODULE)
Expand Down
36 changes: 36 additions & 0 deletions src/stubs/userscores/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2020 MuseScore BVBA and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================

set(MODULE userscores)

set(MODULE_QRC userscores.qrc)

set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml)

set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/userscoresstubmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/userscoresstubmodule.h
${CMAKE_CURRENT_LIST_DIR}/filescorecontrollerstub.cpp
${CMAKE_CURRENT_LIST_DIR}/filescorecontrollerstub.h
${CMAKE_CURRENT_LIST_DIR}/userscoresconfigurationstub.cpp
${CMAKE_CURRENT_LIST_DIR}/userscoresconfigurationstub.h
)

include(${PROJECT_SOURCE_DIR}/build/module.cmake)

41 changes: 41 additions & 0 deletions src/stubs/userscores/filescorecontrollerstub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "filescorecontrollerstub.h"

using namespace mu::userscores;

void FileScoreControllerStub::openScore(const mu::actions::ActionData&)
{
}

void FileScoreControllerStub::importScore()
{
}

void FileScoreControllerStub::newScore()
{
}

void FileScoreControllerStub::saveScore()
{
}

void FileScoreControllerStub::saveScoreAs()
{
}
37 changes: 37 additions & 0 deletions src/stubs/userscores/filescorecontrollerstub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_USERSCORES_FILESCORECONTROLLERSTUB_H
#define MU_USERSCORES_FILESCORECONTROLLERSTUB_H

#include "userscores/ifilescorecontroller.h"

namespace mu::userscores {
class FileScoreControllerStub : public IFileScoreController
{
public:
void openScore(const actions::ActionData& args = actions::ActionData()) override;
void importScore() override;
void newScore() override;

void saveScore() override;
void saveScoreAs() override;
};
}

#endif // MU_USERSCORES_FILESCORECONTROLLERSTUB_H
23 changes: 23 additions & 0 deletions src/stubs/userscores/qml/MuseScore/UserScores/NewScoreDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import QtQuick 2.15

import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0

QmlDialog {
id: root

height: 600
width: 1024

title: "New Score"

Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor

StyledTextLabel {
anchors.centerIn: parent
text: "New Score Dialog Stub"
}
}
}
12 changes: 12 additions & 0 deletions src/stubs/userscores/qml/MuseScore/UserScores/ScoresPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QtQuick 2.15

import MuseScore.UiComponents 1.0

Rectangle {
color: ui.theme.backgroundPrimaryColor

StyledTextLabel {
anchors.centerIn: parent
text: "Score Page Stub"
}
}
3 changes: 3 additions & 0 deletions src/stubs/userscores/qml/MuseScore/UserScores/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module MuseScore.UserScores
ScoresPage 1.0 ScoresPage.qml
NewScoreDialog 1.0 NewScoreDialog.qml
7 changes: 7 additions & 0 deletions src/stubs/userscores/userscores.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>qml/MuseScore/UserScores/qmldir</file>
<file>qml/MuseScore/UserScores/NewScoreDialog.qml</file>
<file>qml/MuseScore/UserScores/ScoresPage.qml</file>
</qresource>
</RCC>
56 changes: 56 additions & 0 deletions src/stubs/userscores/userscoresconfigurationstub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "userscoresconfigurationstub.h"

using namespace mu::userscores;
using namespace mu;

ValCh<QStringList> UserScoresConfigurationStub::recentScoreList() const
{
return ValCh<QStringList>();
}

void UserScoresConfigurationStub::setRecentScoreList(const QStringList&)
{
}

io::paths UserScoresConfigurationStub::templatesDirPaths() const
{
return {};
}

io::path UserScoresConfigurationStub::scoresPath() const
{
return io::path();
}

io::path UserScoresConfigurationStub::defaultSavingFilePath(const std::string&) const
{
return io::path();
}

QColor UserScoresConfigurationStub::templatePreviewBackgroundColor() const
{
return QColor();
}

async::Channel<QColor> UserScoresConfigurationStub::templatePreviewBackgroundColorChanged() const
{
return async::Channel<QColor>();
}
40 changes: 40 additions & 0 deletions src/stubs/userscores/userscoresconfigurationstub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_USERSCORES_USERSCORESCONFIGURATIONSTUB_H
#define MU_USERSCORES_USERSCORESCONFIGURATIONSTUB_H

#include "userscores/iuserscoresconfiguration.h"

namespace mu::userscores {
class UserScoresConfigurationStub : public IUserScoresConfiguration
{
public:
ValCh<QStringList> recentScoreList() const override;
void setRecentScoreList(const QStringList& recentScoreList) override;

io::paths templatesDirPaths() const override;
io::path scoresPath() const override;
io::path defaultSavingFilePath(const std::string& fileName) const override;

QColor templatePreviewBackgroundColor() const override;
async::Channel<QColor> templatePreviewBackgroundColorChanged() const override;
};
}

#endif // MU_USERSCORES_USERSCORESCONFIGURATIONSTUB_H
65 changes: 65 additions & 0 deletions src/stubs/userscores/userscoresstubmodule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "userscoresstubmodule.h"

#include "modularity/ioc.h"
#include "ui/iuiengine.h"

#include "filescorecontrollerstub.h"
#include "userscoresconfigurationstub.h"
#include "ui/iinteractiveuriregister.h"

using namespace mu::userscores;
using namespace mu::framework;
using namespace mu::ui;

static void userscores_init_qrc()
{
Q_INIT_RESOURCE(userscores);
}

std::string UserScoresStubModule::moduleName() const
{
return "userscores_stub";
}

void UserScoresStubModule::registerExports()
{
ioc()->registerExport<IFileScoreController>(moduleName(), new FileScoreControllerStub());
ioc()->registerExport<IUserScoresConfiguration>(moduleName(), new UserScoresConfigurationStub());
}

void UserScoresStubModule::resolveImports()
{
auto ir = ioc()->resolve<IInteractiveUriRegister>(moduleName());
if (ir) {
ir->registerUri(Uri("musescore://userscores/newscore"),
ContainerMeta(ContainerType::QmlDialog, "MuseScore/UserScores/NewScoreDialog.qml"));
}
}

void UserScoresStubModule::registerResources()
{
userscores_init_qrc();
}

void UserScoresStubModule::registerUiTypes()
{
ioc()->resolve<ui::IUiEngine>(moduleName())->addSourceImportPath(userscores_QML_IMPORT);
}
Loading

0 comments on commit b0ce85b

Please sign in to comment.