separated iex imagesexport module

This commit is contained in:
Igor Korsukov 2021-02-04 13:40:59 +02:00
parent e4fb7384fa
commit d3c0b0df3a
20 changed files with 117 additions and 117 deletions

View file

@ -27,16 +27,6 @@ endif (BUILD_WORKSPACE_MODULE)
if (NOT OS_IS_WASM)
add_subdirectory(importexport)
add_subdirectory(importexport/bb)
add_subdirectory(importexport/braille)
add_subdirectory(importexport/bww)
add_subdirectory(importexport/capella)
add_subdirectory(importexport/guitarpro)
add_subdirectory(importexport/midiimport)
add_subdirectory(importexport/musedata)
add_subdirectory(importexport/musicxml)
add_subdirectory(importexport/ove)
add_subdirectory(importexport/audioexport)
add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/beatroot beatroot) # for midiimport
add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/rtf2html rtf2html) # for capella

View file

@ -69,7 +69,7 @@ void CommandLineController::apply()
if (m_parser.isSet("r")) {
std::optional<float> val = floatValue("r");
if (val) {
importexportConfiguration()->setExportPngDpiResolution(val);
imagesExportConfiguration()->setExportPngDpiResolution(val);
} else {
LOGE() << "Option: -r not recognized DPI value: " << m_parser.value("r");
}

View file

@ -25,14 +25,14 @@
#include "modularity/ioc.h"
#include "global/iapplication.h"
#include "ui/iuiconfiguration.h"
#include "importexport/iimportexportconfiguration.h"
#include "importexport/imagesexport/iimagesexportconfiguration.h"
namespace mu::appshell {
class CommandLineController
{
INJECT(appshell, framework::IApplication, application)
INJECT(appshell, ui::IUiConfiguration, uiConfiguration)
INJECT(appshell, importexport::IImportexportConfiguration, importexportConfiguration)
INJECT(appshell, iex::imagesexport::IImagesExportConfiguration, imagesExportConfiguration)
public:
CommandLineController() = default;

View file

@ -17,32 +17,15 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================
# We are separating the importexport module into separate modules,
# soon there will be nothing left of it
set(MODULE importexport)
set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/importexportmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/importexportmodule.h
${CMAKE_CURRENT_LIST_DIR}/iimportexportconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/importexportconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/importexportconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/svgwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/svgwriter.h
${CMAKE_CURRENT_LIST_DIR}/internal/svggenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/svggenerator.h
${CMAKE_CURRENT_LIST_DIR}/internal/pngwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/pngwriter.h
${CMAKE_CURRENT_LIST_DIR}/internal/pdfwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/pdfwriter.h
)
set(MODULE_LINK
libmscore
qzip
notation
)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)
add_subdirectory(bb)
add_subdirectory(braille)
add_subdirectory(bww)
add_subdirectory(capella)
add_subdirectory(guitarpro)
add_subdirectory(midiimport)
add_subdirectory(musedata)
add_subdirectory(musicxml)
add_subdirectory(ove)
add_subdirectory(audioexport)
add_subdirectory(imagesexport)

View file

@ -0,0 +1,46 @@
#=============================================================================
# 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 iex_imagesexport)
set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/imagesexportmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/imagesexportmodule.h
${CMAKE_CURRENT_LIST_DIR}/iimagesexportconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/imagesexportconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/imagesexportconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/svgwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/svgwriter.h
${CMAKE_CURRENT_LIST_DIR}/internal/svggenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/svggenerator.h
${CMAKE_CURRENT_LIST_DIR}/internal/pngwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/pngwriter.h
${CMAKE_CURRENT_LIST_DIR}/internal/pdfwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/pdfwriter.h
)
set(MODULE_LINK
libmscore
qzip
notation
)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)

View file

@ -16,23 +16,20 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_IMPORTEXPORT_IIMPORTEXPORTCONFIGURATION_H
#define MU_IMPORTEXPORT_IIMPORTEXPORTCONFIGURATION_H
#ifndef MU_IMPORTEXPORT_IIMAGESEXPORTCONFIGURATION_H
#define MU_IMPORTEXPORT_IIMAGESEXPORTCONFIGURATION_H
#include <string>
#include <optional>
#include "modularity/imoduleexport.h"
namespace mu::importexport {
class IImportexportConfiguration : MODULE_EXPORT_INTERFACE
namespace mu::iex::imagesexport {
class IImagesExportConfiguration : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(IImportexportConfiguration)
INTERFACE_ID(IImagesExportConfiguration)
public:
virtual ~IImportexportConfiguration() = default;
// GuitarPro
virtual std::string importGuitarProCharset() const = 0;
virtual ~IImagesExportConfiguration() = default;
// Pdf
virtual int exportPdfDpiResolution() const = 0;
@ -46,4 +43,4 @@ public:
};
}
#endif // MU_IMPORTEXPORT_IIMPORTEXPORTCONFIGURATION_H
#endif // MU_IMPORTEXPORT_IIMAGESEXPORTCONFIGURATION_H

View file

@ -16,40 +16,35 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "importexportmodule.h"
#include "imagesexportmodule.h"
#include "log.h"
#include "config.h"
#include "modularity/ioc.h"
#include "notation/inotationreadersregister.h"
#include "notation/inotationwritersregister.h"
#include "internal/pdfwriter.h"
#include "internal/pngwriter.h"
#include "internal/svgwriter.h"
#include "internal/importexportconfiguration.h"
#include "internal/imagesexportconfiguration.h"
using namespace mu::importexport;
using namespace mu::iex::imagesexport;
using namespace mu::notation;
static std::shared_ptr<ImportexportConfiguration> s_configuration = std::make_shared<ImportexportConfiguration>();
static std::shared_ptr<ImagesExportConfiguration> s_configuration = std::make_shared<ImagesExportConfiguration>();
std::string ImportExportModule::moduleName() const
std::string ImagesExportModule::moduleName() const
{
return "importexport";
return "iex_imagesexport";
}
void ImportExportModule::registerExports()
void ImagesExportModule::registerExports()
{
framework::ioc()->registerExport<IImportexportConfiguration>(moduleName(), s_configuration);
framework::ioc()->registerExport<IImagesExportConfiguration>(moduleName(), s_configuration);
}
void ImportExportModule::onInit(const framework::IApplication::RunMode&)
void ImagesExportModule::resolveImports()
{
s_configuration->init();
auto writers = framework::ioc()->resolve<INotationWritersRegister>(moduleName());
if (writers) {
writers->reg({ "pdf" }, std::make_shared<PdfWriter>());
@ -57,3 +52,8 @@ void ImportExportModule::onInit(const framework::IApplication::RunMode&)
writers->reg({ "png" }, std::make_shared<PngWriter>());
}
}
void ImagesExportModule::onInit(const framework::IApplication::RunMode&)
{
s_configuration->init();
}

View file

@ -16,22 +16,21 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#define MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#ifndef MU_IMPORTEXPORT_IMAGESEXPORTMODULE_H
#define MU_IMPORTEXPORT_IMAGESEXPORTMODULE_H
#include "modularity/imodulesetup.h"
namespace mu {
namespace importexport {
class ImportExportModule : public framework::IModuleSetup
namespace mu::iex::imagesexport {
class ImagesExportModule : public framework::IModuleSetup
{
public:
std::string moduleName() const override;
void registerExports() override;
void resolveImports() override;
void onInit(const framework::IApplication::RunMode& mode) override;
};
}
}
#endif // MU_IMPORTEXPORT_IMPORTEXPORTMODULE_H
#endif // MU_IMPORTEXPORT_IMAGESEXPORTMODULE_H

View file

@ -16,50 +16,37 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "importexportconfiguration.h"
#include "imagesexportconfiguration.h"
#include "settings.h"
#include "libmscore/mscore.h"
using namespace mu::framework;
using namespace mu::importexport;
using namespace mu::iex::imagesexport;
static const std::string module_name("importexport");
static const Settings::Key EXPORT_PDF_DPI_RESOLUTION_KEY("iex_imagesexport", "export/pdf/dpi");
static const Settings::Key EXPORT_PNG_DPI_RESOLUTION_KEY("iex_imagesexport", "export/png/resolution");
static const Settings::Key EXPORT_PNG_USE_TRASNPARENCY_KEY("iex_imagesexport", "export/png/useTransparency");
static const Settings::Key SHORTEST_NOTE_KEY(module_name, "io/midi/shortestNote");
static const Settings::Key IMPORT_GUITARPRO_CHARSET_KEY(module_name, "import/guitarpro/charset");
static const Settings::Key EXPORT_PDF_DPI_RESOLUTION_KEY(module_name, "export/pdf/dpi");
static const Settings::Key EXPORT_PNG_DPI_RESOLUTION_KEY(module_name, "export/png/resolution");
static const Settings::Key EXPORT_PNG_USE_TRASNPARENCY_KEY(module_name, "export/png/useTransparency");
void ImportexportConfiguration::init()
void ImagesExportConfiguration::init()
{
settings()->setDefaultValue(SHORTEST_NOTE_KEY, Val(Ms::MScore::division / 4));
settings()->setDefaultValue(IMPORT_GUITARPRO_CHARSET_KEY, Val("UTF-8"));
settings()->setDefaultValue(EXPORT_PNG_DPI_RESOLUTION_KEY, Val(Ms::DPI));
settings()->setDefaultValue(EXPORT_PNG_USE_TRASNPARENCY_KEY, Val(true));
settings()->setDefaultValue(EXPORT_PDF_DPI_RESOLUTION_KEY, Val(Ms::DPI));
}
std::string ImportexportConfiguration::importGuitarProCharset() const
{
return settings()->value(IMPORT_GUITARPRO_CHARSET_KEY).toString();
}
int ImportexportConfiguration::exportPdfDpiResolution() const
int ImagesExportConfiguration::exportPdfDpiResolution() const
{
return settings()->value(EXPORT_PDF_DPI_RESOLUTION_KEY).toInt();
}
void ImportexportConfiguration::setExportPngDpiResolution(std::optional<float> dpi)
void ImagesExportConfiguration::setExportPngDpiResolution(std::optional<float> dpi)
{
m_customExportPngDpi = dpi;
}
float ImportexportConfiguration::exportPngDpiResolution() const
float ImagesExportConfiguration::exportPngDpiResolution() const
{
if (m_customExportPngDpi) {
return m_customExportPngDpi.value();
@ -68,7 +55,7 @@ float ImportexportConfiguration::exportPngDpiResolution() const
return settings()->value(EXPORT_PNG_DPI_RESOLUTION_KEY).toFloat();
}
bool ImportexportConfiguration::exportPngWithTransparentBackground() const
bool ImagesExportConfiguration::exportPngWithTransparentBackground() const
{
return settings()->value(EXPORT_PNG_USE_TRASNPARENCY_KEY).toBool();
}

View file

@ -16,19 +16,17 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_IMPORTEXPORT_IMPORTEXPORTCONFIGURATION_H
#define MU_IMPORTEXPORT_IMPORTEXPORTCONFIGURATION_H
#ifndef MU_IMPORTEXPORT_IMAGESEXPORTCONFIGURATION_H
#define MU_IMPORTEXPORT_IMAGESEXPORTCONFIGURATION_H
#include "../iimportexportconfiguration.h"
#include "../iimagesexportconfiguration.h"
namespace mu::importexport {
class ImportexportConfiguration : public IImportexportConfiguration
namespace mu::iex::imagesexport {
class ImagesExportConfiguration : public IImagesExportConfiguration
{
public:
void init();
std::string importGuitarProCharset() const override;
int exportPdfDpiResolution() const override;
void setExportPngDpiResolution(std::optional<float> dpi) override;
@ -42,4 +40,4 @@ private:
};
}
#endif // MU_IMPORTEXPORT_IMPORTEXPORTCONFIGURATION_H
#endif // MU_IMPORTEXPORT_IMAGESEXPORTCONFIGURATION_H

View file

@ -26,7 +26,7 @@
#include <QPdfWriter>
#include <QPainter>
using namespace mu::importexport;
using namespace mu::iex::imagesexport;
using namespace mu::system;
using namespace Ms;

View file

@ -22,13 +22,13 @@
#include "notation/abstractnotationwriter.h"
#include "../iimportexportconfiguration.h"
#include "../iimagesexportconfiguration.h"
#include "modularity/ioc.h"
namespace mu::importexport {
namespace mu::iex::imagesexport {
class PdfWriter : public notation::AbstractNotationWriter
{
INJECT(importexport, IImportexportConfiguration, configuration)
INJECT(iex_imagesexport, IImagesExportConfiguration, configuration)
public:
Ret write(const notation::INotationPtr notation, system::IODevice& destinationDevice, const Options& options = Options()) override;

View file

@ -29,7 +29,7 @@
#include <QImage>
#include <QPainter>
using namespace mu::importexport;
using namespace mu::iex::imagesexport;
using namespace mu::system;
mu::Ret PngWriter::write(const notation::INotationPtr notation, IODevice& destinationDevice, const Options& options)

View file

@ -22,13 +22,13 @@
#include "notation/abstractnotationwriter.h"
#include "../iimportexportconfiguration.h"
#include "../iimagesexportconfiguration.h"
#include "modularity/ioc.h"
namespace mu::importexport {
namespace mu::iex::imagesexport {
class PngWriter : public notation::AbstractNotationWriter
{
INJECT(importexport, IImportexportConfiguration, configuration)
INJECT(iex_imagesexport, IImagesExportConfiguration, configuration)
public:
Ret write(const notation::INotationPtr notation, system::IODevice& destinationDevice, const Options& options = Options()) override;

View file

@ -32,7 +32,7 @@
#include <QPainter>
using namespace mu::importexport;
using namespace mu::iex::imagesexport;
using namespace mu::system;
mu::Ret SvgWriter::write(const notation::INotationPtr notation, IODevice& destinationDevice, const Options& options)

View file

@ -22,7 +22,7 @@
#include "notation/abstractnotationwriter.h"
namespace mu::importexport {
namespace mu::iex::imagesexport {
class SvgWriter : public notation::AbstractNotationWriter
{
public:

View file

@ -164,7 +164,6 @@ if (NOT CC_IS_EMSCRIPTEN)
list(APPEND LINK_LIB cloud)
list(APPEND LINK_LIB extensions)
list(APPEND LINK_LIB languages)
list(APPEND LINK_LIB importexport)
list(APPEND LINK_LIB iex_musicxml)
list(APPEND LINK_LIB iex_bb)
list(APPEND LINK_LIB iex_braille)
@ -175,6 +174,7 @@ if (NOT CC_IS_EMSCRIPTEN)
list(APPEND LINK_LIB iex_musedata)
list(APPEND LINK_LIB iex_ove)
list(APPEND LINK_LIB iex_audioexport)
list(APPEND LINK_LIB iex_imagesexport)
list(APPEND LINK_LIB plugins)
endif()

View file

@ -63,7 +63,6 @@
#endif
#include "notation/notationmodule.h"
#include "importexport/importexportmodule.h"
#include "importexport/musicxml/musicxmlmodule.h"
#include "importexport/bb/bbmodule.h"
#include "importexport/bww/bwwmodule.h"
@ -72,6 +71,7 @@
#include "importexport/midiimport/midiimportmodule.h"
#include "importexport/ove/ovemodule.h"
#include "importexport/audioexport/audioexportmodule.h"
#include "importexport/imagesexport/imagesexportmodule.h"
#include "commonscene/commonscenemodule.h"
#ifdef BUILD_PALETTE_MODULE
@ -110,7 +110,7 @@
#else
#include "stubs/plugins/pluginsstubmodule.h"
#endif
#include "importexport/importexportmodule.h"
#ifdef BUILD_CLOUD_MODULE
#include "cloud/cloudmodule.h"
#else
@ -219,7 +219,6 @@ int main(int argc, char** argv)
app.addModule(new mu::converter::ConverterModule());
#ifndef Q_OS_WASM
app.addModule(new mu::importexport::ImportExportModule());
app.addModule(new mu::iex::bb::BBModule());
app.addModule(new mu::iex::bww::BwwModule());
app.addModule(new mu::iex::musicxml::MusicXmlModule());
@ -228,6 +227,7 @@ int main(int argc, char** argv)
app.addModule(new mu::iex::midiimport::MidiImportModule());
app.addModule(new mu::iex::ove::OveModule());
app.addModule(new mu::iex::audioexport::AudioExportModule());
app.addModule(new mu::iex::imagesexport::ImagesExportModule());
#ifdef BUILD_WORKSPACE_MODULE
app.addModule(new mu::workspace::WorkspaceModule());