Implemented stubs for palette module

This commit is contained in:
Eism 2021-01-22 14:16:59 +02:00 committed by Igor Korsukov
parent b75fb05a73
commit 3c5d0eaa11
31 changed files with 519 additions and 22 deletions

View file

@ -60,6 +60,7 @@ option(BUILD_CLOUD_MODULE "Build cloud module" ON)
option(BUILD_EXTENSIONS_MODULE "Build extensions module" ON) option(BUILD_EXTENSIONS_MODULE "Build extensions module" ON)
option(BUILD_LANGUAGES_MODULE "Build languages module" ON) option(BUILD_LANGUAGES_MODULE "Build languages module" ON)
option(BUILD_PLAYBACK_MODULE "Build playback module" ON) option(BUILD_PLAYBACK_MODULE "Build playback module" ON)
option(BUILD_PALETTE_MODULE "Build palette module" ON)
option(BUILD_INSTRUMENTS_MODULE "Build instruments module" ON) option(BUILD_INSTRUMENTS_MODULE "Build instruments module" ON)
option(BUILD_INSPECTOR_MODULE "Build inspector module" ON) option(BUILD_INSPECTOR_MODULE "Build inspector module" ON)

View file

@ -49,6 +49,7 @@
#cmakedefine BUILD_EXTENSIONS_MODULE #cmakedefine BUILD_EXTENSIONS_MODULE
#cmakedefine BUILD_LANGUAGES_MODULE #cmakedefine BUILD_LANGUAGES_MODULE
#cmakedefine BUILD_PLAYBACK_MODULE #cmakedefine BUILD_PLAYBACK_MODULE
#cmakedefine BUILD_PALETTE_MODULE
#cmakedefine BUILD_INSTRUMENTS_MODULE #cmakedefine BUILD_INSTRUMENTS_MODULE
#cmakedefine BUILD_INSPECTOR_MODULE #cmakedefine BUILD_INSPECTOR_MODULE

View file

@ -50,7 +50,9 @@ if (BUILD_PLAYBACK_MODULE)
endif (BUILD_PLAYBACK_MODULE) endif (BUILD_PLAYBACK_MODULE)
# Notation # Notation
add_subdirectory(palette) if (BUILD_PALETTE_MODULE)
add_subdirectory(palette)
endif (BUILD_PALETTE_MODULE)
if (BUILD_INSTRUMENTS_MODULE) if (BUILD_INSTRUMENTS_MODULE)
add_subdirectory(instruments) add_subdirectory(instruments)
endif (BUILD_INSTRUMENTS_MODULE) endif (BUILD_INSTRUMENTS_MODULE)

View file

@ -10,7 +10,7 @@ PopupViewButton {
property alias model: horizontalFramePopup.model property alias model: horizontalFramePopup.model
icon: IconCode.HORIZONTAL_FRAME icon: IconCode.HORIZONTAL_FRAME
text: qsTrc("palette", "Horizontal frames") text: qsTrc("inspector", "Horizontal frames")
visible: root.model ? !root.model.isEmpty : false visible: root.model ? !root.model.isEmpty : false

View file

@ -54,7 +54,11 @@
#include "importexport/importexportmodule.h" #include "importexport/importexportmodule.h"
#include "importexport/musicxml/musicxmlmodule.h" #include "importexport/musicxml/musicxmlmodule.h"
#include "commonscene/commonscenemodule.h" #include "commonscene/commonscenemodule.h"
#ifdef BUILD_PALETTE_MODULE
#include "palette/palettemodule.h" #include "palette/palettemodule.h"
#else
#include "stubs/palette/palettestubmodule.h"
#endif
#include "inspector/inspectormodule.h" #include "inspector/inspectormodule.h"
#ifdef BUILD_PLAYBACK_MODULE #ifdef BUILD_PLAYBACK_MODULE
#include "playback/playbackmodule.h" #include "playback/playbackmodule.h"
@ -168,7 +172,11 @@ int main(int argc, char** argv)
#endif #endif
app.addModule(new mu::inspector::InspectorModule()); app.addModule(new mu::inspector::InspectorModule());
#ifdef BUILD_PALETTE_MODULE
app.addModule(new mu::palette::PaletteModule()); app.addModule(new mu::palette::PaletteModule());
#else
app.addModule(new mu::palette::PaletteStubModule());
#endif
app.addModule(new mu::converter::ConverterModule()); app.addModule(new mu::converter::ConverterModule());
#ifndef Q_OS_WASM #ifndef Q_OS_WASM

View file

@ -1,18 +1,18 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>qml/MuseScore/Palette/MoreElementsPopup.qml</file>
<file>qml/MuseScore/Palette/Palette.qml</file>
<file>qml/MuseScore/Palette/PaletteGrid.qml</file>
<file>qml/MuseScore/Palette/PalettesListPopup.qml</file>
<file>qml/MuseScore/Palette/PalettesWidget.qml</file> <file>qml/MuseScore/Palette/PalettesWidget.qml</file>
<file>qml/MuseScore/Palette/PalettesWidgetHeader.qml</file>
<file>qml/MuseScore/Palette/PaletteTree.qml</file>
<file>qml/MuseScore/Palette/PlaceholderManager.qml</file>
<file>qml/MuseScore/Palette/TreePaletteHeader.qml</file>
<file>qml/MuseScore/Palette/utils.js</file>
<file>qml/MuseScore/Palette/qmldir</file> <file>qml/MuseScore/Palette/qmldir</file>
<file>qml/MuseScore/Palette/CreateCustomPalettePopup.qml</file> <file>qml/MuseScore/Palette/internal/CreateCustomPalettePopup.qml</file>
<file>qml/MuseScore/Palette/PalettePropertiesDialog.qml</file> <file>qml/MuseScore/Palette/internal/MoreElementsPopup.qml</file>
<file>qml/MuseScore/Palette/internal/Palette.qml</file>
<file>qml/MuseScore/Palette/internal/PaletteGrid.qml</file>
<file>qml/MuseScore/Palette/internal/PalettesListPopup.qml</file>
<file>qml/MuseScore/Palette/internal/PalettesWidgetHeader.qml</file>
<file>qml/MuseScore/Palette/internal/PaletteTree.qml</file>
<file>qml/MuseScore/Palette/internal/PlaceholderManager.qml</file>
<file>qml/MuseScore/Palette/internal/TreePaletteHeader.qml</file>
<file>qml/MuseScore/Palette/internal/utils.js</file>
<file>qml/MuseScore/Palette/PaletteCellPropertiesDialog.qml</file> <file>qml/MuseScore/Palette/PaletteCellPropertiesDialog.qml</file>
<file>qml/MuseScore/Palette/PalettePropertiesDialog.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -26,6 +26,8 @@ import MuseScore.Palette 1.0
// TODO: make some properties 'property alias`? // TODO: make some properties 'property alias`?
// and `readonly property`? // and `readonly property`?
import "internal"
Rectangle { Rectangle {
id: palettesWidget id: palettesWidget

View file

@ -1,13 +1,4 @@
module MuseScore.Palette module MuseScore.Palette
MoreElementsPopup 1.0 MoreElementsPopup.qml
PaletteGrid 1.0 PaletteGrid.qml
Palette 1.0 Palette.qml
PalettesListPopup 1.0 PalettesListPopup.qml
PalettesWidgetHeader 1.0 PalettesWidgetHeader.qml
PalettesWidget 1.0 PalettesWidget.qml PalettesWidget 1.0 PalettesWidget.qml
PaletteTree 1.0 PaletteTree.qml
PlaceholderManager 1.0 PlaceholderManager.qml
TreePaletteHeader 1.0 TreePaletteHeader.qml
CreateCustomPalettePopup 1.0 CreateCustomPalettePopup.qml
PalettePropertiesDialog 1.0 PalettePropertiesDialog.qml PalettePropertiesDialog 1.0 PalettePropertiesDialog.qml
PaletteCellPropertiesDialog 1.0 PaletteCellPropertiesDialog.qml PaletteCellPropertiesDialog 1.0 PaletteCellPropertiesDialog.qml

View file

@ -21,6 +21,10 @@ if (NOT BUILD_PLAYBACK_MODULE)
add_subdirectory(playback) add_subdirectory(playback)
endif (NOT BUILD_PLAYBACK_MODULE) endif (NOT BUILD_PLAYBACK_MODULE)
if (NOT BUILD_PALETTE_MODULE)
add_subdirectory(palette)
endif (NOT BUILD_PALETTE_MODULE)
if (NOT BUILD_INSTRUMENTS_MODULE) if (NOT BUILD_INSTRUMENTS_MODULE)
add_subdirectory(instruments) add_subdirectory(instruments)
endif (NOT BUILD_INSTRUMENTS_MODULE) endif (NOT BUILD_INSTRUMENTS_MODULE)

View file

@ -0,0 +1,35 @@
#=============================================================================
# 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 palette)
set(MODULE_QRC ${CMAKE_CURRENT_LIST_DIR}/palette.qrc)
set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml)
set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/palettestubmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/palettestubmodule.h
${CMAKE_CURRENT_LIST_DIR}/paletteadapterstub.cpp
${CMAKE_CURRENT_LIST_DIR}/paletteadapterstub.h
${CMAKE_CURRENT_LIST_DIR}/paletteconfigurationstub.cpp
${CMAKE_CURRENT_LIST_DIR}/paletteconfigurationstub.h
)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)

View file

@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/">
<file>qml/MuseScore/Palette/PalettesWidget.qml</file>
<file>qml/MuseScore/Palette/qmldir</file>
<file>qml/MuseScore/Palette/PaletteCellPropertiesDialog.qml</file>
<file>qml/MuseScore/Palette/PalettePropertiesDialog.qml</file>
</qresource>
</RCC>

View file

@ -0,0 +1,79 @@
//=============================================================================
// 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 "paletteadapterstub.h"
#include <QAction>
using namespace mu::palette;
QAction* PaletteAdapterStub::getAction(const char*) const
{
return new QAction();
}
QString PaletteAdapterStub::actionHelp(const char*) const
{
return QString();
}
void PaletteAdapterStub::showMasterPalette(const QString&)
{
}
bool PaletteAdapterStub::isSelected() const
{
return false;
}
bool PaletteAdapterStub::applyPaletteElement(Ms::Element*, Qt::KeyboardModifiers)
{
return false;
}
Ms::PaletteWorkspace* PaletteAdapterStub::paletteWorkspace() const
{
return nullptr;
}
mu::ValCh<bool> PaletteAdapterStub::paletteEnabled() const
{
return mu::ValCh<bool>();
}
void PaletteAdapterStub::setPaletteEnabled(bool)
{
}
void PaletteAdapterStub::requestPaletteSearch()
{
}
mu::async::Notification PaletteAdapterStub::paletteSearchRequested() const
{
return mu::async::Notification();
}
void PaletteAdapterStub::notifyElementDraggedToScoreView()
{
}
mu::async::Notification PaletteAdapterStub::elementDraggedToScoreView() const
{
return mu::async::Notification();
}

View file

@ -0,0 +1,48 @@
//=============================================================================
// 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_PALETTE_PALETTEADAPTERSTUB_H
#define MU_PALETTE_PALETTEADAPTERSTUB_H
#include "palette/ipaletteadapter.h"
namespace mu::palette {
class PaletteAdapterStub : public IPaletteAdapter
{
public:
QAction* getAction(const char* id) const override;
QString actionHelp(const char* id) const override;
void showMasterPalette(const QString&) override;
// score
bool isSelected() const override;
bool applyPaletteElement(Ms::Element* element, Qt::KeyboardModifiers modifiers = {}) override;
// qml
Ms::PaletteWorkspace* paletteWorkspace() const override;
mu::ValCh<bool> paletteEnabled() const override;
void setPaletteEnabled(bool arg) override;
void requestPaletteSearch() override;
async::Notification paletteSearchRequested() const override;
void notifyElementDraggedToScoreView() override;
async::Notification elementDraggedToScoreView() const override;
};
}
#endif // MU_PALETTE_PALETTEADAPTERSTUB_H

View file

@ -0,0 +1,94 @@
//=============================================================================
// 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 "paletteconfigurationstub.h"
using namespace mu::palette;
double PaletteConfigurationStub::paletteScaling() const
{
return 0.f;
}
bool PaletteConfigurationStub::isSinglePalette() const
{
return false;
}
QColor PaletteConfigurationStub::elementsBackgroundColor() const
{
return QColor();
}
QColor PaletteConfigurationStub::elementsColor() const
{
return QColor();
}
QColor PaletteConfigurationStub::gridColor() const
{
return QColor();
}
QColor PaletteConfigurationStub::accentColor() const
{
return QColor();
}
mu::async::Notification PaletteConfigurationStub::colorsChanged() const
{
return mu::async::Notification();
}
mu::io::path PaletteConfigurationStub::keySignaturesDirPath() const
{
return mu::io::path();
}
mu::io::path PaletteConfigurationStub::timeSignaturesDirPath() const
{
return mu::io::path();
}
bool PaletteConfigurationStub::useFactorySettings() const
{
return false;
}
bool PaletteConfigurationStub::enableExperimental() const
{
return false;
}
mu::ValCh<IPaletteConfiguration::PaletteConfig> PaletteConfigurationStub::paletteConfig(const QString&) const
{
return mu::ValCh<IPaletteConfiguration::PaletteConfig>();
}
void PaletteConfigurationStub::setPaletteConfig(const QString&, const IPaletteConfiguration::PaletteConfig&)
{
}
mu::ValCh<IPaletteConfiguration::PaletteCellConfig> PaletteConfigurationStub::paletteCellConfig(const QString&) const
{
return mu::ValCh<IPaletteConfiguration::PaletteCellConfig>();
}
void PaletteConfigurationStub::setPaletteCellConfig(const QString&, const IPaletteConfiguration::PaletteCellConfig&)
{
}

View file

@ -0,0 +1,51 @@
//=============================================================================
// 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_PALETTE_PALETTECONFIGURATIONSTUB_H
#define MU_PALETTE_PALETTECONFIGURATIONSTUB_H
#include "palette/ipaletteconfiguration.h"
namespace mu::palette {
class PaletteConfigurationStub : public IPaletteConfiguration
{
public:
double paletteScaling() const override;
bool isSinglePalette() const override;
QColor elementsBackgroundColor() const override;
QColor elementsColor() const override;
QColor gridColor() const override;
QColor accentColor() const override;
async::Notification colorsChanged() const override;
io::path keySignaturesDirPath() const override;
io::path timeSignaturesDirPath() const override;
bool useFactorySettings() const override;
bool enableExperimental() const override;
ValCh<PaletteConfig> paletteConfig(const QString& paletteId) const override;
void setPaletteConfig(const QString& paletteId, const PaletteConfig& config) override;
ValCh<PaletteCellConfig> paletteCellConfig(const QString& cellId) const override;
void setPaletteCellConfig(const QString& cellId, const PaletteCellConfig& config) override;
};
}
#endif // MU_PALETTE_IPALETTECONFIGURATION_H

View file

@ -0,0 +1,68 @@
//=============================================================================
// 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 "palettestubmodule.h"
#include "modularity/ioc.h"
#include "ui/iuiengine.h"
#include "ui/iinteractiveuriregister.h"
#include "paletteadapterstub.h"
#include "paletteconfigurationstub.h"
using namespace mu::palette;
using namespace mu::framework;
using namespace mu::ui;
static void palette_init_qrc()
{
Q_INIT_RESOURCE(palette);
}
std::string PaletteStubModule::moduleName() const
{
return "palette_stub";
}
void PaletteStubModule::registerExports()
{
ioc()->registerExport<IPaletteAdapter>(moduleName(), new PaletteAdapterStub());
ioc()->registerExport<IPaletteConfiguration>(moduleName(), new PaletteConfigurationStub());
}
void PaletteStubModule::resolveImports()
{
auto ir = ioc()->resolve<IInteractiveUriRegister>(moduleName());
if (ir) {
ir->registerUri(Uri("musescore://palette/properties"),
ContainerMeta(ContainerType::QmlDialog, "MuseScore/Palette/PalettePropertiesDialog.qml"));
ir->registerUri(Uri("musescore://palette/cellproperties"),
ContainerMeta(ContainerType::QmlDialog, "MuseScore/Palette/PaletteCellPropertiesDialog.qml"));
}
}
void PaletteStubModule::registerResources()
{
palette_init_qrc();
}
void PaletteStubModule::registerUiTypes()
{
ioc()->resolve<ui::IUiEngine>(moduleName())->addSourceImportPath(palette_QML_IMPORT);
}

View file

@ -0,0 +1,38 @@
//=============================================================================
// 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_PALETTE_PALETTESTUBMODULE_H
#define MU_PALETTE_PALETTESTUBMODULE_H
#include "modularity/imodulesetup.h"
namespace mu::palette {
class PaletteStubModule : public framework::IModuleSetup
{
public:
std::string moduleName() const override;
void registerExports() override;
void resolveImports() override;
void registerResources() override;
void registerUiTypes() override;
};
}
#endif // MU_PALETTE_PALETTESTUBMODULE_H

View file

@ -0,0 +1,24 @@
import QtQuick 2.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0
QmlDialog {
width: 280
height: 370
title: qsTrc("palette", "Palette Cell Properties")
property var properties
Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor
StyledTextLabel {
anchors.centerIn: parent
text: "Palette Cell Properties Dialog Stub"
}
}
}

View file

@ -0,0 +1,24 @@
import QtQuick 2.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0
QmlDialog {
width: 280
height: 370
title: qsTrc("palette", "Palette Properties")
property var properties
Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor
StyledTextLabel {
anchors.centerIn: parent
text: "Palette Properties Dialog Stub"
}
}
}

View file

@ -0,0 +1,15 @@
import QtQuick 2.15
import MuseScore.UiComponents 1.0
Rectangle {
readonly property QtObject paletteWorkspace: null
readonly property bool hasFocus: false
color: ui.theme.backgroundPrimaryColor
StyledTextLabel {
anchors.centerIn: parent
text: "Palette Panel Stub"
}
}

View file

@ -0,0 +1,4 @@
module MuseScore.Palette
PalettesWidget 1.0 PalettesWidget.qml
PalettePropertiesDialog 1.0 PalettePropertiesDialog.qml
PaletteCellPropertiesDialog 1.0 PaletteCellPropertiesDialog.qml