remember the last mode in which was created the score and will use it again after reopening dialog
This commit is contained in:
parent
a9941f9c99
commit
e0330a5bd4
7 changed files with 71 additions and 7 deletions
|
@ -31,6 +31,7 @@ static const std::string module_name("userscores");
|
|||
static const Settings::Key RECENT_LIST(module_name, "userscores/recentList");
|
||||
static const Settings::Key USER_TEMPLATES_PATH(module_name, "application/paths/myTemplates");
|
||||
static const Settings::Key USER_SCORES_PATH(module_name, "application/paths/myScores");
|
||||
static const Settings::Key PREFERRED_SCORE_CREATION_MODE_KEY(module_name, "userscores/preferedScoreCreationMode");
|
||||
|
||||
const QString UserScoresConfiguration::DEFAULT_FILE_SUFFIX(".mscz");
|
||||
|
||||
|
@ -43,6 +44,9 @@ void UserScoresConfiguration::init()
|
|||
QStringList recentList = parseRecentList(val.toString());
|
||||
m_recentListChanged.send(recentList);
|
||||
});
|
||||
|
||||
Val preferredScoreCreationMode = Val(static_cast<int>(PreferredScoreCreationMode::FromInstruments));
|
||||
settings()->setDefaultValue(PREFERRED_SCORE_CREATION_MODE_KEY, preferredScoreCreationMode);
|
||||
}
|
||||
|
||||
ValCh<QStringList> UserScoresConfiguration::recentScoreList() const
|
||||
|
@ -102,3 +106,13 @@ async::Channel<QColor> UserScoresConfiguration::templatePreviewBackgroundColorCh
|
|||
{
|
||||
return notationConfiguration()->backgroundColorChanged();
|
||||
}
|
||||
|
||||
UserScoresConfiguration::PreferredScoreCreationMode UserScoresConfiguration::preferredScoreCreationMode() const
|
||||
{
|
||||
return static_cast<PreferredScoreCreationMode>(settings()->value(PREFERRED_SCORE_CREATION_MODE_KEY).toInt());
|
||||
}
|
||||
|
||||
void UserScoresConfiguration::setPreferredScoreCreationMode(PreferredScoreCreationMode mode)
|
||||
{
|
||||
settings()->setValue(PREFERRED_SCORE_CREATION_MODE_KEY, Val(static_cast<int>(mode)));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class UserScoresConfiguration : public IUserScoresConfiguration
|
|||
INJECT(userscores, notation::INotationConfiguration, notationConfiguration)
|
||||
|
||||
public:
|
||||
|
||||
static const QString DEFAULT_FILE_SUFFIX;
|
||||
|
||||
void init();
|
||||
|
@ -48,6 +47,9 @@ public:
|
|||
QColor templatePreviewBackgroundColor() const override;
|
||||
async::Channel<QColor> templatePreviewBackgroundColorChanged() const override;
|
||||
|
||||
PreferredScoreCreationMode preferredScoreCreationMode() const override;
|
||||
void setPreferredScoreCreationMode(PreferredScoreCreationMode mode) override;
|
||||
|
||||
private:
|
||||
QStringList parseRecentList(const std::string& recents) const;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "modularity/imoduleexport.h"
|
||||
#include "retval.h"
|
||||
#include "io/path.h"
|
||||
#include "userscorestypes.h"
|
||||
|
||||
namespace mu::userscores {
|
||||
class IUserScoresConfiguration : MODULE_EXPORT_INTERFACE
|
||||
|
@ -43,6 +44,14 @@ public:
|
|||
|
||||
virtual QColor templatePreviewBackgroundColor() const = 0;
|
||||
virtual async::Channel<QColor> templatePreviewBackgroundColorChanged() const = 0;
|
||||
|
||||
enum class PreferredScoreCreationMode {
|
||||
FromInstruments,
|
||||
FromTemplate
|
||||
};
|
||||
|
||||
virtual PreferredScoreCreationMode preferredScoreCreationMode() const = 0;
|
||||
virtual void setPreferredScoreCreationMode(PreferredScoreCreationMode mode) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ QmlDialog {
|
|||
|
||||
ChooseInstrumentsAndTemplatesPage {
|
||||
id: chooseInstrumentsAndTemplatePage
|
||||
|
||||
Component.onCompleted: {
|
||||
preferredScoreCreationMode = newScoreModel.preferredScoreCreationMode()
|
||||
}
|
||||
}
|
||||
|
||||
ScoreInfoPage {
|
||||
|
|
|
@ -10,6 +10,8 @@ import MuseScore.Instruments 1.0
|
|||
Item {
|
||||
id: root
|
||||
|
||||
property string preferredScoreCreationMode: ""
|
||||
|
||||
property bool hasSelection: {
|
||||
if (pagesStack.currentIndex === 0) {
|
||||
return instrumentsPage.hasSelectedInstruments
|
||||
|
@ -47,15 +49,25 @@ Item {
|
|||
sideMargin: 22
|
||||
isCurrent: bar.currentIndex === 0
|
||||
}
|
||||
|
||||
StyledTabButton {
|
||||
text: qsTrc("userscores", "Choose from template")
|
||||
sideMargin: 22
|
||||
isCurrent: bar.currentIndex === 1
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.preferredScoreCreationMode === "FromInstruments") {
|
||||
currentIndex = 0
|
||||
} else if (root.preferredScoreCreationMode === "FromTemplate") {
|
||||
currentIndex = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StackLayout {
|
||||
id: pagesStack
|
||||
|
||||
anchors.top: bar.bottom
|
||||
anchors.topMargin: 24
|
||||
anchors.left: parent.left
|
||||
|
|
|
@ -21,15 +21,26 @@
|
|||
#include "log.h"
|
||||
|
||||
using namespace mu::userscores;
|
||||
using namespace mu::actions;
|
||||
using namespace mu::notation;
|
||||
using namespace mu::instruments;
|
||||
|
||||
using PreferredScoreCreationMode = IUserScoresConfiguration::PreferredScoreCreationMode;
|
||||
|
||||
NewScoreModel::NewScoreModel(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString NewScoreModel::preferredScoreCreationMode() const
|
||||
{
|
||||
switch (configuration()->preferredScoreCreationMode()) {
|
||||
case PreferredScoreCreationMode::FromInstruments: return "FromInstruments";
|
||||
case PreferredScoreCreationMode::FromTemplate: return "FromTemplate";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool NewScoreModel::createScore(const QVariant& info)
|
||||
{
|
||||
ScoreCreateOptions options = parseOptions(info.toMap());
|
||||
|
@ -48,6 +59,9 @@ bool NewScoreModel::createScore(const QVariant& info)
|
|||
|
||||
globalContext()->setCurrentMasterNotation(notation);
|
||||
|
||||
bool isScoreCreatedFromInstruments = options.templatePath.empty();
|
||||
updatePreferredScoreCreationMode(isScoreCreatedFromInstruments);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,3 +103,12 @@ ScoreCreateOptions NewScoreModel::parseOptions(const QVariantMap& info) const
|
|||
|
||||
return options;
|
||||
}
|
||||
|
||||
void NewScoreModel::updatePreferredScoreCreationMode(bool isScoreCreatedFromInstruments)
|
||||
{
|
||||
if (isScoreCreatedFromInstruments) {
|
||||
configuration()->setPreferredScoreCreationMode(PreferredScoreCreationMode::FromInstruments);
|
||||
} else {
|
||||
configuration()->setPreferredScoreCreationMode(PreferredScoreCreationMode::FromTemplate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,30 +23,30 @@
|
|||
|
||||
#include "modularity/ioc.h"
|
||||
|
||||
#include "actions/iactionsdispatcher.h"
|
||||
#include "iglobalconfiguration.h"
|
||||
#include "iuserscoresconfiguration.h"
|
||||
|
||||
#include "notation/inotationcreator.h"
|
||||
#include "notation/notationtypes.h"
|
||||
#include "context/iglobalcontext.h"
|
||||
#include "instruments/instrumentstypes.h"
|
||||
|
||||
namespace mu::userscores {
|
||||
class NewScoreModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
INJECT(scores, actions::IActionsDispatcher, dispatcher)
|
||||
INJECT(scores, framework::IGlobalConfiguration, globalConfiguration)
|
||||
INJECT(scores, IUserScoresConfiguration, configuration)
|
||||
INJECT(scores, notation::INotationCreator, notationCreator)
|
||||
INJECT(scores, context::IGlobalContext, globalContext)
|
||||
|
||||
public:
|
||||
explicit NewScoreModel(QObject* parent = nullptr);
|
||||
|
||||
Q_INVOKABLE QString preferredScoreCreationMode() const;
|
||||
Q_INVOKABLE bool createScore(const QVariant& info);
|
||||
|
||||
private:
|
||||
notation::ScoreCreateOptions parseOptions(const QVariantMap& info) const;
|
||||
void updatePreferredScoreCreationMode(bool isScoreCreatedFromInstruments);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue