Skip to content

Commit 136de9c

Browse files
committed
update 250522
1 parent ec888e1 commit 136de9c

File tree

72 files changed

+920
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+920
-544
lines changed

framework/audio/internal/soundfontrepository.cpp

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,50 +100,63 @@ Notification SoundFontRepository::soundFontsChanged() const
100100
return m_soundFontsChanged;
101101
}
102102

103-
Ret SoundFontRepository::addSoundFont(const SoundFontPath& path)
103+
void SoundFontRepository::addSoundFont(const SoundFontPath& path)
104104
{
105105
std::string title = muse::qtrc("audio", "Do you want to add the SoundFont: %1?")
106106
.arg(io::filename(path).toQString()).toStdString();
107107

108-
IInteractive::Button btn = interactive()->question(title, "", {
108+
interactive()->question(title, "", {
109109
IInteractive::Button::No,
110110
IInteractive::Button::Yes
111-
}).standardButton();
112-
113-
if (btn == IInteractive::Button::No) {
114-
return muse::make_ret(Ret::Code::Cancel);
115-
}
116-
117-
RetVal<SoundFontPath> newPath = resolveInstallationPath(path);
118-
if (!newPath.ret) {
119-
return newPath.ret;
120-
}
121-
122-
if (fileSystem()->exists(newPath.val)) {
123-
title = muse::trc("audio", "File already exists. Do you want to overwrite it?");
124-
125-
std::string body = muse::qtrc("audio", "File path: %1")
126-
.arg(newPath.val.toQString()).toStdString();
111+
})
112+
.onResolve(this, [this, path](const IInteractive::Result& res) {
113+
if (res.isButton(IInteractive::Button::No)) {
114+
LOGI() << "soundfont addition cancelled";
115+
return;
116+
}
127117

128-
btn = interactive()->question(title, body, {
129-
IInteractive::Button::No,
130-
IInteractive::Button::Yes
131-
}, IInteractive::Button::Yes, IInteractive::WithIcon).standardButton();
118+
RetVal<SoundFontPath> newPath = resolveInstallationPath(path);
119+
if (!newPath.ret) {
120+
LOGE() << "failed resolve path, err: " << newPath.ret.toString();
121+
return;
122+
}
132123

133-
if (btn == IInteractive::Button::No) {
134-
return muse::make_ret(Ret::Code::Cancel);
124+
if (fileSystem()->exists(newPath.val)) {
125+
std::string title = muse::trc("audio", "File already exists. Do you want to overwrite it?");
126+
127+
std::string body = muse::qtrc("audio", "File path: %1")
128+
.arg(newPath.val.toQString()).toStdString();
129+
130+
interactive()->question(title, body, {
131+
IInteractive::Button::No,
132+
IInteractive::Button::Yes
133+
}, IInteractive::Button::Yes, IInteractive::WithIcon)
134+
.onResolve(this, [this, path, newPath](const IInteractive::Result& res) {
135+
if (res.isButton(IInteractive::Button::No)) {
136+
LOGI() << "soundfont replacement cancelled";
137+
return;
138+
}
139+
140+
Ret ret = doAddSoundFont(path, newPath.val);
141+
if (ret) {
142+
interactive()->info(muse::trc("audio", "SoundFont installed"),
143+
muse::trc("audio", "You can assign soundfonts to instruments using the mixer panel."),
144+
{}, 0, IInteractive::Option::WithIcon);
145+
} else {
146+
LOGE() << "failed add soundfont, err: " << ret.toString();
147+
}
148+
});
135149
}
136-
}
150+
});
151+
}
137152

138-
Ret ret = fileSystem()->copy(path, newPath.val, true /* replace */);
153+
Ret SoundFontRepository::doAddSoundFont(const synth::SoundFontPath& src, const SoundFontPath& dst)
154+
{
155+
Ret ret = fileSystem()->copy(src, dst, true /* replace */);
139156

140157
if (ret) {
141-
loadSoundFont(newPath.val);
158+
loadSoundFont(dst);
142159
m_soundFontsChanged.notify();
143-
144-
interactive()->info(muse::trc("audio", "SoundFont installed"),
145-
muse::trc("audio", "You can assign soundfonts to instruments using the mixer panel."),
146-
{}, 0, IInteractive::Option::WithIcon);
147160
}
148161

149162
return ret;

framework/audio/internal/soundfontrepository.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ class SoundFontRepository : public ISoundFontRepository, public Injectable, publ
4747
const synth::SoundFontsMap& soundFonts() const override;
4848
async::Notification soundFontsChanged() const override;
4949

50-
Ret addSoundFont(const synth::SoundFontPath& path) override;
50+
void addSoundFont(const synth::SoundFontPath& path) override;
5151

5252
private:
53+
54+
Ret doAddSoundFont(const synth::SoundFontPath& src, const synth::SoundFontPath& dst);
55+
5356
void loadSoundFonts();
5457
void loadSoundFont(const synth::SoundFontPath& path, const synth::SoundFontsMap& oldSoundFonts = {});
5558

framework/audio/isoundfontrepository.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include "modularity/imoduleinterface.h"
2626

27-
#include "global/types/ret.h"
2827
#include "global/async/notification.h"
2928

3029
#include "soundfonttypes.h"
@@ -41,7 +40,7 @@ class ISoundFontRepository : MODULE_EXPORT_INTERFACE
4140
virtual const synth::SoundFontsMap& soundFonts() const = 0;
4241
virtual async::Notification soundFontsChanged() const = 0;
4342

44-
virtual Ret addSoundFont(const synth::SoundFontPath& path) = 0;
43+
virtual void addSoundFont(const synth::SoundFontPath& path) = 0;
4544
};
4645
}
4746

framework/audio/thirdparty/fluidsynth/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ target_no_warning(${MODULE} -WMSVC-no-assignment-within-conditional-expression)
4242
target_no_warning(${MODULE} -WMSVC-no-hides-previous)
4343
target_no_warning(${MODULE} -WMSVC-no-undefined-assuming-extern)
4444
target_no_warning(${MODULE} -WMSVC-named-type-definition-in-parentheses)
45+
target_no_warning(${MODULE} -WMSVC-no-different-enum-types)

framework/audio/thirdparty/lame/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ target_no_warning(${MODULE} -WMSVC-no-assignment-within-conditional-expression)
8181
target_no_warning(${MODULE} -WMSVC-no-hides-previous)
8282
target_no_warning(${MODULE} -WMSVC-no-undefined-assuming-extern)
8383
target_no_warning(${MODULE} -WMSVC-named-type-definition-in-parentheses)
84+
target_no_warning(${MODULE} -WMSVC-no-benign-redefinition)

framework/autobot/autobotmodule.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,21 @@
4646
using namespace muse::autobot;
4747
using namespace muse::api;
4848

49+
static void autobot_init_qrc()
50+
{
51+
Q_INIT_RESOURCE(autobot);
52+
}
53+
4954
std::string AutobotModule::moduleName() const
5055
{
5156
return "autobot";
5257
}
5358

59+
void AutobotModule::registerResources()
60+
{
61+
autobot_init_qrc();
62+
}
63+
5464
void AutobotModule::registerExports()
5565
{
5666
m_configuration = std::make_shared<AutobotConfiguration>(iocContext());

framework/autobot/autobotmodule.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AutobotModule : public modularity::IModuleSetup
3535
public:
3636

3737
std::string moduleName() const override;
38+
void registerResources() override;
3839
void registerExports() override;
3940
void resolveImports() override;
4041
void registerUiTypes() override;

framework/autobot/internal/api/autobotapi.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void AutobotApi::runTestCase(const QJSValue& testCase)
5454
bool AutobotApi::pause(bool immediately)
5555
{
5656
if (immediately) {
57-
IInteractive::Result res = interactive()->question("Pause", "Continue?",
58-
{ IInteractive::Button::Continue, IInteractive::Button::Abort });
57+
IInteractive::Result res = interactive()->questionSync("Pause", "Continue?",
58+
{ IInteractive::Button::Continue, IInteractive::Button::Abort });
5959

6060
if (res.standardButton() == IInteractive::Button::Abort) {
6161
abort();
@@ -72,7 +72,7 @@ bool AutobotApi::pause(bool immediately)
7272
bool AutobotApi::confirm(const QString& msg)
7373
{
7474
int pauseBtn = int(IInteractive::Button::CustomButton) + 1;
75-
IInteractive::Result res = interactive()->question("Confirm", msg.toStdString(), {
75+
IInteractive::Result res = interactive()->questionSync("Confirm", msg.toStdString(), {
7676
interactive()->buttonData(IInteractive::Button::Continue),
7777
IInteractive::ButtonData(pauseBtn, "Pause"),
7878
interactive()->buttonData(IInteractive::Button::Abort)

framework/autobot/internal/autobotinteractive.cpp

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ std::shared_ptr<IInteractive> AutobotInteractive::realInteractive() const
3636
return m_real;
3737
}
3838

39-
IInteractive::Result AutobotInteractive::question(const std::string& contentTitle, const std::string& text, const Buttons& buttons,
40-
const Button& def, const Options& options,
41-
const std::string& dialogTitle) const
39+
IInteractive::Result AutobotInteractive::questionSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
40+
int defBtn, const Options& options, const std::string& dialogTitle)
4241
{
43-
return m_real->question(contentTitle, text, buttons, def, options, dialogTitle);
42+
return m_real->questionSync(contentTitle, text, buttons, defBtn, options, dialogTitle);
4443
}
4544

46-
IInteractive::Result AutobotInteractive::question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
47-
int defBtn, const Options& options, const std::string& dialogTitle) const
45+
async::Promise<IInteractive::Result> AutobotInteractive::question(const std::string& contentTitle, const Text& text,
46+
const ButtonDatas& buttons, int defBtn,
47+
const Options& options, const std::string& dialogTitle)
4848
{
4949
return m_real->question(contentTitle, text, buttons, defBtn, options, dialogTitle);
5050
}
@@ -54,56 +54,47 @@ IInteractive::ButtonData AutobotInteractive::buttonData(Button b) const
5454
return m_real->buttonData(b);
5555
}
5656

57-
IInteractive::Result AutobotInteractive::info(const std::string& contentTitle, const std::string& text, const Buttons& buttons,
58-
int defBtn, const Options& options, const std::string& dialogTitle) const
57+
IInteractive::Result AutobotInteractive::infoSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn,
58+
const Options& options, const std::string& dialogTitle)
5959
{
60-
return m_real->info(contentTitle, text, buttons, defBtn, options, dialogTitle);
60+
return m_real->infoSync(contentTitle, text, buttons, defBtn, options, dialogTitle);
6161
}
6262

63-
IInteractive::Result AutobotInteractive::info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn,
64-
const Options& options, const std::string& dialogTitle) const
63+
async::Promise<IInteractive::Result> AutobotInteractive::info(const std::string& contentTitle, const Text& text,
64+
const ButtonDatas& buttons, int defBtn,
65+
const Options& options, const std::string& dialogTitle)
6566
{
6667
return m_real->info(contentTitle, text, buttons, defBtn, options, dialogTitle);
6768
}
6869

69-
IInteractive::Result AutobotInteractive::warning(const std::string& contentTitle, const std::string& text, const Buttons& buttons,
70-
const Button& def, const Options& options, const std::string& dialogTitle) const
70+
IInteractive::Result AutobotInteractive::warningSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
71+
int defBtn,
72+
const Options& options, const std::string& dialogTitle)
7173
{
72-
return m_real->warning(contentTitle, text, buttons, def, options, dialogTitle);
74+
return m_real->warningSync(contentTitle, text, buttons, defBtn, options, dialogTitle);
7375
}
7476

75-
IInteractive::Result AutobotInteractive::warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
76-
int defBtn, const Options& options, const std::string& dialogTitle) const
77+
async::Promise<IInteractive::Result> AutobotInteractive::warning(const std::string& contentTitle, const Text& text,
78+
const ButtonDatas& buttons, int defBtn,
79+
const Options& options, const std::string& dialogTitle)
7780
{
7881
return m_real->warning(contentTitle, text, buttons, defBtn, options, dialogTitle);
7982
}
8083

81-
IInteractive::Result AutobotInteractive::warning(const std::string& contentTitle, const Text& text, const std::string& detailedText,
82-
const ButtonDatas& buttons, int defBtn,
83-
const Options& options, const std::string& dialogTitle) const
84+
IInteractive::Result AutobotInteractive::errorSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
85+
int defBtn,
86+
const Options& options, const std::string& dialogTitle)
8487
{
85-
return m_real->warning(contentTitle, text, detailedText, buttons, defBtn, options, dialogTitle);
88+
return m_real->errorSync(contentTitle, text, buttons, defBtn, options, dialogTitle);
8689
}
8790

88-
IInteractive::Result AutobotInteractive::error(const std::string& contentTitle, const std::string& text, const Buttons& buttons,
89-
const Button& def, const Options& options, const std::string& dialogTitle) const
90-
{
91-
return m_real->error(contentTitle, text, buttons, def, options, dialogTitle);
92-
}
93-
94-
IInteractive::Result AutobotInteractive::error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
95-
int defBtn, const Options& options, const std::string& dialogTitle) const
91+
async::Promise<IInteractive::Result> AutobotInteractive::error(const std::string& contentTitle, const Text& text,
92+
const ButtonDatas& buttons, int defBtn,
93+
const Options& options, const std::string& dialogTitle)
9694
{
9795
return m_real->error(contentTitle, text, buttons, defBtn, options, dialogTitle);
9896
}
9997

100-
IInteractive::Result AutobotInteractive::error(const std::string& contentTitle, const Text& text, const std::string& detailedText,
101-
const ButtonDatas& buttons, int defBtn, const Options& options,
102-
const std::string& dialogTitle) const
103-
{
104-
return m_real->error(contentTitle, text, detailedText, buttons, defBtn, options, dialogTitle);
105-
}
106-
10798
Ret AutobotInteractive::showProgress(const std::string& title, Progress* progress) const
10899
{
109100
return m_real->showProgress(title, progress);
@@ -165,6 +156,11 @@ RetVal<Val> AutobotInteractive::open(const UriQuery& uri) const
165156
return m_real->open(uri);
166157
}
167158

159+
async::Promise<Val> AutobotInteractive::openAsync(const UriQuery& uri)
160+
{
161+
return m_real->openAsync(uri);
162+
}
163+
168164
RetVal<bool> AutobotInteractive::isOpened(const std::string& uri) const
169165
{
170166
return m_real->isOpened(uri);

framework/autobot/internal/autobotinteractive.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,38 @@ class AutobotInteractive : public IInteractive
3535
void setRealInteractive(std::shared_ptr<IInteractive> real);
3636
std::shared_ptr<IInteractive> realInteractive() const;
3737

38-
Result question(const std::string& contentTitle, const std::string& text, const Buttons& buttons, const Button& def = Button::NoButton,
39-
const Options& options = {}, const std::string& dialogTitle = "") const override;
38+
Result questionSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
39+
const Options& options = {}, const std::string& dialogTitle = "") override;
4040

41-
Result question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
42-
const Options& options = {}, const std::string& dialogTitle = "") const override;
41+
async::Promise<Result> question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons,
42+
int defBtn = int(Button::NoButton), const Options& options = {},
43+
const std::string& dialogTitle = "") override;
4344

4445
ButtonData buttonData(Button b) const override;
4546

4647
// info
47-
Result info(const std::string& contentTitle, const std::string& text, const Buttons& buttons = {}, int defBtn = int(Button::NoButton),
48-
const Options& options = {}, const std::string& dialogTitle = "") const override;
48+
Result infoSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
49+
const Options& options = {}, const std::string& dialogTitle = "") override;
4950

50-
Result info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
51-
const Options& options = {}, const std::string& dialogTitle = "") const override;
51+
async::Promise<Result> info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {},
52+
int defBtn = int(Button::NoButton), const Options& options = {},
53+
const std::string& dialogTitle = "") override;
5254

5355
// warning
54-
Result warning(const std::string& contentTitle, const std::string& text, const Buttons& buttons = {},
55-
const Button& def = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = "") const override;
56+
Result warningSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
57+
const Options& options = {}, const std::string& dialogTitle = "") override;
5658

57-
Result warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton),
58-
const Options& options = {}, const std::string& dialogTitle = "") const override;
59-
60-
Result warning(const std::string& contentTitle, const Text& text, const std::string& detailedText, const ButtonDatas& buttons = {},
61-
int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = "") const override;
59+
async::Promise<Result> warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {},
60+
int defBtn = int(Button::NoButton), const Options& options = {},
61+
const std::string& dialogTitle = "") override;
6262

6363
// error
64-
Result error(const std::string& contentTitle, const std::string& text, const Buttons& buttons = {},
65-
const Button& def = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = "") const override;
66-
67-
Result error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton),
68-
const Options& options = {}, const std::string& dialogTitle = "") const override;
64+
Result errorSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton),
65+
const Options& options = {}, const std::string& dialogTitle = "") override;
6966

70-
Result error(const std::string& contentTitle, const Text& text, const std::string& detailedText, const ButtonDatas& buttons = {},
71-
int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = "") const override;
67+
async::Promise<Result> error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {},
68+
int defBtn = int(Button::NoButton), const Options& options = {},
69+
const std::string& dialogTitle = "") override;
7270

7371
// progress
7472
Ret showProgress(const std::string& title, Progress* progress) const override;
@@ -90,6 +88,7 @@ class AutobotInteractive : public IInteractive
9088
RetVal<Val> open(const std::string& uri) const override;
9189
RetVal<Val> open(const Uri& uri) const override;
9290
RetVal<Val> open(const UriQuery& uri) const override;
91+
async::Promise<Val> openAsync(const UriQuery& uri) override;
9392
RetVal<bool> isOpened(const std::string& uri) const override;
9493
RetVal<bool> isOpened(const Uri& uri) const override;
9594
RetVal<bool> isOpened(const UriQuery& uri) const override;

0 commit comments

Comments
 (0)