diff --git a/src/appshell/qml/DevTools/Gallery/GeneralComponentsGallery.qml b/src/appshell/qml/DevTools/Gallery/GeneralComponentsGallery.qml index d2b011c6adb9c..50e7b42bf5a6f 100644 --- a/src/appshell/qml/DevTools/Gallery/GeneralComponentsGallery.qml +++ b/src/appshell/qml/DevTools/Gallery/GeneralComponentsGallery.qml @@ -372,6 +372,7 @@ Rectangle { width: 200 color: "black" + allowAlpha: true onNewColorSelected: function(newColor) { color = newColor diff --git a/src/appshell/qml/DevTools/Preferences/SettingsPage.qml b/src/appshell/qml/DevTools/Preferences/SettingsPage.qml index 1a548b582f7ae..1297730057d19 100644 --- a/src/appshell/qml/DevTools/Preferences/SettingsPage.qml +++ b/src/appshell/qml/DevTools/Preferences/SettingsPage.qml @@ -185,6 +185,7 @@ ColumnLayout { anchors.fill: parent color: val + allowAlpha: true onNewColorSelected: function(newColor) { changed(newColor) diff --git a/src/framework/autobot/internal/autobotinteractive.cpp b/src/framework/autobot/internal/autobotinteractive.cpp index df7c35019f522..e5c047f326997 100644 --- a/src/framework/autobot/internal/autobotinteractive.cpp +++ b/src/framework/autobot/internal/autobotinteractive.cpp @@ -138,9 +138,9 @@ io::paths_t AutobotInteractive::selectMultipleDirectories(const std::string& tit return m_real->selectMultipleDirectories(title, dir, initialDirectories); } -async::Promise AutobotInteractive::selectColor(const Color& color, const std::string& title) +async::Promise AutobotInteractive::selectColor(const Color& color, const std::string& title, bool allowAlpha) { - return m_real->selectColor(color, title); + return m_real->selectColor(color, title, allowAlpha); } bool AutobotInteractive::isSelectColorOpened() const diff --git a/src/framework/autobot/internal/autobotinteractive.h b/src/framework/autobot/internal/autobotinteractive.h index e990dc3f643c9..eb1c2d92f0203 100644 --- a/src/framework/autobot/internal/autobotinteractive.h +++ b/src/framework/autobot/internal/autobotinteractive.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_AUTOBOT_AUTOBOTINTERACTIVE_H -#define MUSE_AUTOBOT_AUTOBOTINTERACTIVE_H + +#pragma once #include @@ -36,37 +36,37 @@ class AutobotInteractive : public IInteractive std::shared_ptr realInteractive() const; Result questionSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; async::Promise question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; ButtonData buttonData(Button b) const override; // info Result infoSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; async::Promise info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // warning Result warningSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; async::Promise warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // error Result errorSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; async::Promise error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // progress void showProgress(const std::string& title, Progress progress) override; @@ -84,7 +84,7 @@ class AutobotInteractive : public IInteractive io::paths_t selectMultipleDirectories(const std::string& title, const io::path_t& dir, const io::paths_t& initialDirectories) override; // color - async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = "") override; + async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = {}, bool allowAlpha = false) override; bool isSelectColorOpened() const override; // custom @@ -125,5 +125,3 @@ class AutobotInteractive : public IInteractive using AutobotInteractivePtr = std::shared_ptr; } - -#endif // MUSE_AUTOBOT_AUTOBOTINTERACTIVE_H diff --git a/src/framework/global/iinteractive.h b/src/framework/global/iinteractive.h index 5920a87f7e985..b1e319fb5b72b 100644 --- a/src/framework/global/iinteractive.h +++ b/src/framework/global/iinteractive.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_GLOBAL_IINTERACTIVE_H -#define MUSE_GLOBAL_IINTERACTIVE_H + +#pragma once #include "modularity/imoduleinterface.h" #include "io/path.h" @@ -166,10 +166,10 @@ class IInteractive : MODULE_EXPORT_INTERFACE // question virtual async::Promise question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; async::Promise question(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - Button defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = "") + Button defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = {}) { return question(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } @@ -177,10 +177,10 @@ class IInteractive : MODULE_EXPORT_INTERFACE // info virtual async::Promise info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; async::Promise info(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - Button defBtn, const Options& options = {}, const std::string& dialogTitle = "") + Button defBtn, const Options& options = {}, const std::string& dialogTitle = {}) { return info(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } @@ -188,11 +188,11 @@ class IInteractive : MODULE_EXPORT_INTERFACE // warning virtual async::Promise warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = { WithIcon }, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; async::Promise warning(const std::string& contentTitle, const std::string& text, const Buttons& buttons, Button defBtn = Button::NoButton, const Options& options = { WithIcon }, - const std::string& dialogTitle = "") + const std::string& dialogTitle = {}) { return warning(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } @@ -200,11 +200,11 @@ class IInteractive : MODULE_EXPORT_INTERFACE // error virtual async::Promise error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = { WithIcon }, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; async::Promise error(const std::string& contentTitle, const std::string& text, const Buttons& buttons, Button defBtn = Button::NoButton, const Options& options = { WithIcon }, - const std::string& dialogTitle = "") + const std::string& dialogTitle = {}) { return error(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } @@ -226,7 +226,8 @@ class IInteractive : MODULE_EXPORT_INTERFACE const io::paths_t& selectedDirectories) = 0; // color - virtual async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = "") = 0; + virtual async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = {}, + bool allowAlpha = false) = 0; virtual bool isSelectColorOpened() const = 0; // custom @@ -262,39 +263,39 @@ class IInteractive : MODULE_EXPORT_INTERFACE //! NOTE Please don't use this //! ================================= virtual Result questionSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, - int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = "") = 0; + int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = {}) = 0; Result questionSync(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - const Button& defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = "") + const Button& defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = {}) { return questionSync(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } virtual Result infoSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, - int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = "") = 0; + int defBtn = int(Button::NoButton), const Options& options = {}, const std::string& dialogTitle = {}) = 0; Result infoSync(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - const Button& defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = "") + const Button& defBtn = Button::NoButton, const Options& options = {}, const std::string& dialogTitle = {}) { return infoSync(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } virtual Result warningSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = { WithIcon }, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; Result warningSync(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - const Button& defBtn = Button::NoButton, const Options& options = { WithIcon }, const std::string& dialogTitle = "") + const Button& defBtn = Button::NoButton, const Options& options = { WithIcon }, const std::string& dialogTitle = {}) { return warningSync(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } virtual Result errorSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = { WithIcon }, - const std::string& dialogTitle = "") = 0; + const std::string& dialogTitle = {}) = 0; Result errorSync(const std::string& contentTitle, const std::string& text, const Buttons& buttons, - const Button& defBtn = Button::NoButton, const Options& options = { WithIcon }, const std::string& dialogTitle = "") + const Button& defBtn = Button::NoButton, const Options& options = { WithIcon }, const std::string& dialogTitle = {}) { return errorSync(contentTitle, Text(text), buttonDataList(buttons), (int)defBtn, options, dialogTitle); } @@ -306,5 +307,3 @@ class IInteractive : MODULE_EXPORT_INTERFACE }; DECLARE_OPERATORS_FOR_FLAGS(IInteractive::Options) } - -#endif // MUSE_GLOBAL_IINTERACTIVE_H diff --git a/src/framework/global/internal/interactive.cpp b/src/framework/global/internal/interactive.cpp index 01c7b72fd0ad1..1f86224f7fe15 100644 --- a/src/framework/global/internal/interactive.cpp +++ b/src/framework/global/internal/interactive.cpp @@ -411,9 +411,9 @@ io::paths_t Interactive::selectMultipleDirectories(const std::string& title, con return io::pathsFromString(result.val.toString()); } -async::Promise Interactive::selectColor(const Color& color, const std::string& title) +async::Promise Interactive::selectColor(const Color& color, const std::string& title, bool allowAlpha) { - return provider()->selectColor(color, title); + return provider()->selectColor(color, title, allowAlpha); } bool Interactive::isSelectColorOpened() const diff --git a/src/framework/global/internal/interactive.h b/src/framework/global/internal/interactive.h index ff52745dad3e3..9f1bf25c13a38 100644 --- a/src/framework/global/internal/interactive.h +++ b/src/framework/global/internal/interactive.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_GLOBAL_INTERACTIVE_H -#define MUSE_GLOBAL_INTERACTIVE_H + +#pragma once #include "async/asyncable.h" @@ -91,7 +91,7 @@ class Interactive : public IInteractive, public Injectable, public async::Asynca io::paths_t selectMultipleDirectories(const std::string& title, const io::path_t& dir, const io::paths_t& selectedDirectories) override; // color - async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = "") override; + async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = {}, bool allowAlpha = false) override; bool isSelectColorOpened() const override; // custom @@ -134,5 +134,3 @@ class Interactive : public IInteractive, public Injectable, public async::Asynca const ButtonDatas& buttons, int defBtn, const Options& options, const std::string& dialogTitle); }; } - -#endif // MUSE_GLOBAL_UIINTERACTIVE_H diff --git a/src/framework/global/internal/platform/web/webinteractive.cpp b/src/framework/global/internal/platform/web/webinteractive.cpp index 9fa83bc7e5bd5..f21cf452c32d1 100644 --- a/src/framework/global/internal/platform/web/webinteractive.cpp +++ b/src/framework/global/internal/platform/web/webinteractive.cpp @@ -254,9 +254,9 @@ io::paths_t WebInteractive::selectMultipleDirectories(const std::string& title, #endif } -muse::async::Promise WebInteractive::selectColor(const muse::Color& color, const std::string& title) +muse::async::Promise WebInteractive::selectColor(const muse::Color& color, const std::string& title, bool allowAlpha) { - return m_origin->selectColor(color, title); + return m_origin->selectColor(color, title, allowAlpha); } bool WebInteractive::isSelectColorOpened() const diff --git a/src/framework/global/internal/platform/web/webinteractive.h b/src/framework/global/internal/platform/web/webinteractive.h index c96e4ce9206b0..855dc2643ca36 100644 --- a/src/framework/global/internal/platform/web/webinteractive.h +++ b/src/framework/global/internal/platform/web/webinteractive.h @@ -33,35 +33,35 @@ class WebInteractive : public muse::IInteractive // question Result questionSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; muse::async::Promise question(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // info Result infoSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; muse::async::Promise info(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // warning Result warningSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = {}, const std::string& dialogTitle = "") override; + const Options& options = {}, const std::string& dialogTitle = {}) override; muse::async::Promise warning(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = {}, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // error Result errorSync(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons, int defBtn = int(Button::NoButton), - const Options& options = { WithIcon }, const std::string& dialogTitle = "") override; + const Options& options = { WithIcon }, const std::string& dialogTitle = {}) override; muse::async::Promise error(const std::string& contentTitle, const Text& text, const ButtonDatas& buttons = {}, int defBtn = int(Button::NoButton), const Options& options = { WithIcon }, - const std::string& dialogTitle = "") override; + const std::string& dialogTitle = {}) override; // progress void showProgress(const std::string& title, muse::Progress progress) override; @@ -81,7 +81,8 @@ class WebInteractive : public muse::IInteractive const muse::io::paths_t& selectedDirectories) override; // color - muse::async::Promise selectColor(const muse::Color& color = muse::Color::WHITE, const std::string& title = "") override; + muse::async::Promise selectColor(const muse::Color& color = muse::Color::WHITE, const std::string& title = {}, + bool allowAlpha = false) override; bool isSelectColorOpened() const override; // custom diff --git a/src/framework/global/tests/mocks/interactivemock.h b/src/framework/global/tests/mocks/interactivemock.h index ed11b7882d638..357d30ec49626 100644 --- a/src/framework/global/tests/mocks/interactivemock.h +++ b/src/framework/global/tests/mocks/interactivemock.h @@ -65,7 +65,7 @@ class InteractiveMock : public IInteractive MOCK_METHOD(io::path_t, selectDirectory, (const std::string&, const io::path_t&), (override)); MOCK_METHOD(io::paths_t, selectMultipleDirectories, (const std::string&, const io::path_t&, const io::paths_t&), (override)); - MOCK_METHOD(async::Promise, selectColor, (const Color&, const std::string&), (override)); + MOCK_METHOD(async::Promise, selectColor, (const Color&, const std::string&, bool), (override)); MOCK_METHOD(bool, isSelectColorOpened, (), (const, override)); MOCK_METHOD(RetVal, openSync, (const UriQuery&), (override)); diff --git a/src/framework/ui/iinteractiveprovider.h b/src/framework/ui/iinteractiveprovider.h index 6597a857d462d..0102358cd1e63 100644 --- a/src/framework/ui/iinteractiveprovider.h +++ b/src/framework/ui/iinteractiveprovider.h @@ -19,8 +19,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef MUSE_UI_IINTERACTIVEPROVIDER_H -#define MUSE_UI_IINTERACTIVEPROVIDER_H + +#pragma once #include "global/modularity/imoduleinterface.h" @@ -40,7 +40,8 @@ class IInteractiveProvider : MODULE_EXPORT_INTERFACE virtual ~IInteractiveProvider() = default; // color - virtual async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = "") = 0; + virtual async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = {}, + bool allowAlpha = false) = 0; virtual bool isSelectColorOpened() const = 0; virtual RetVal openSync(const UriQuery& uri) = 0; @@ -65,5 +66,3 @@ class IInteractiveProvider : MODULE_EXPORT_INTERFACE virtual bool topWindowIsWidget() const = 0; }; } - -#endif // MUSE_UI_IINTERACTIVEPROVIDER_H diff --git a/src/framework/ui/view/interactiveprovider.cpp b/src/framework/ui/view/interactiveprovider.cpp index 78a07fd9ba6d7..cf9711ba6eb68 100644 --- a/src/framework/ui/view/interactiveprovider.cpp +++ b/src/framework/ui/view/interactiveprovider.cpp @@ -99,7 +99,7 @@ static void setCustomColors(const std::vector& customColors) } } -async::Promise InteractiveProvider::selectColor(const Color& color, const std::string& title) +async::Promise InteractiveProvider::selectColor(const Color& color, const std::string& title, bool allowAlpha) { if (m_isSelectColorOpened) { LOGW() << "already opened"; @@ -113,7 +113,7 @@ async::Promise InteractiveProvider::selectColor(const Color& color, const setCustomColors(config()->colorDialogCustomColors()); - return async::make_promise([this, color, title](auto resolve, auto reject) { + return async::make_promise([this, color, title, allowAlpha](auto resolve, auto reject) { //! FIX https://github.com/musescore/MuseScore/issues/23208 shortcutsRegister()->setActive(false); @@ -122,7 +122,15 @@ async::Promise InteractiveProvider::selectColor(const Color& color, const dlg->setWindowTitle(QString::fromStdString(title)); } - dlg->setCurrentColor(color.toQColor()); + QColor currentColor = color.toQColor(); + + // If the color is fully transparent, set alpha to opaque, to avoid "Hm, nothing happened" user confusion + if (currentColor.alpha() == 0) { + currentColor.setAlpha(255); + } + + dlg->setCurrentColor(currentColor); + dlg->setOption(QColorDialog::ShowAlphaChannel, allowAlpha); QObject::connect(dlg, &QColorDialog::finished, [this, dlg, resolve, reject](int result) { dlg->deleteLater(); diff --git a/src/framework/ui/view/interactiveprovider.h b/src/framework/ui/view/interactiveprovider.h index 17296f1bceba5..4c2fede7d5e21 100644 --- a/src/framework/ui/view/interactiveprovider.h +++ b/src/framework/ui/view/interactiveprovider.h @@ -65,7 +65,7 @@ class InteractiveProvider : public QObject, public IInteractiveProvider, public public: explicit InteractiveProvider(const modularity::ContextPtr& iocCtx); - async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = "") override; + async::Promise selectColor(const Color& color = Color::WHITE, const std::string& title = {}, bool allowAlpha = false) override; bool isSelectColorOpened() const override; RetVal openSync(const UriQuery& uri) override; diff --git a/src/framework/uicomponents/qml/Muse/UiComponents/ColorPicker.qml b/src/framework/uicomponents/qml/Muse/UiComponents/ColorPicker.qml index 07b2587c04a86..bd94fe9e9dfeb 100644 --- a/src/framework/uicomponents/qml/Muse/UiComponents/ColorPicker.qml +++ b/src/framework/uicomponents/qml/Muse/UiComponents/ColorPicker.qml @@ -29,6 +29,7 @@ import "Utils.js" as Utils Rectangle { id: root + property bool allowAlpha: false property bool isIndeterminate: false property alias navigation: navCtrl @@ -60,7 +61,7 @@ Rectangle { id: prv function selectColor() { - colorPickerModel.selectColor(root.color) + colorPickerModel.selectColor(root.color, root.allowAlpha) } } diff --git a/src/framework/uicomponents/qml/Muse/UiComponents/internal/ValueListItem.qml b/src/framework/uicomponents/qml/Muse/UiComponents/internal/ValueListItem.qml index 177cceb6d6be8..2484ee4a351f5 100644 --- a/src/framework/uicomponents/qml/Muse/UiComponents/internal/ValueListItem.qml +++ b/src/framework/uicomponents/qml/Muse/UiComponents/internal/ValueListItem.qml @@ -442,6 +442,7 @@ ListItemBlank { navigation.column: 1 color: val + allowAlpha: true onNewColorSelected: function(newColor) { colorControl.changed(newColor) diff --git a/src/framework/uicomponents/view/colorpickermodel.cpp b/src/framework/uicomponents/view/colorpickermodel.cpp index 9b9b9c167635d..9ea56c88355b8 100644 --- a/src/framework/uicomponents/view/colorpickermodel.cpp +++ b/src/framework/uicomponents/view/colorpickermodel.cpp @@ -31,12 +31,13 @@ ColorPickerModel::ColorPickerModel(QObject* parent) { } -void ColorPickerModel::selectColor(const QColor& currentColor) +void ColorPickerModel::selectColor(const QColor& currentColor, bool allowAlpha) { - auto promise = interactive()->selectColor(Color::fromQColor(currentColor)); - promise.onResolve(this, [this](const Color& c) { + interactive()->selectColor(Color::fromQColor(currentColor), {}, allowAlpha) + .onResolve(this, [this](const Color& c) { emit colorSelected(c.toQColor()); - }).onReject(this, [this](int code, const std::string& msg) { + }) + .onReject(this, [this](int code, const std::string& msg) { LOGD() << "select color rejected, err code: " << code << ", msg: " << msg; emit selectRejected(); }); diff --git a/src/framework/uicomponents/view/colorpickermodel.h b/src/framework/uicomponents/view/colorpickermodel.h index e5d8a4524b3ba..8433f0ccfb0fd 100644 --- a/src/framework/uicomponents/view/colorpickermodel.h +++ b/src/framework/uicomponents/view/colorpickermodel.h @@ -20,8 +20,7 @@ * along with this program. If not, see . */ -#ifndef MUSE_UICOMPONENTS_COLORPICKER_H -#define MUSE_UICOMPONENTS_COLORPICKER_H +#pragma once #include @@ -40,12 +39,10 @@ class ColorPickerModel : public QObject, public muse::Injectable, public async:: public: explicit ColorPickerModel(QObject* parent = nullptr); - Q_INVOKABLE void selectColor(const QColor& currentColor); + Q_INVOKABLE void selectColor(const QColor& currentColor, bool allowAlpha = false); signals: void colorSelected(QColor color); void selectRejected(); }; } - -#endif // MUSE_UICOMPONENTS_COLORPICKER_H diff --git a/src/inspector/view/qml/MuseScore/Inspector/common/ColorSection.qml b/src/inspector/view/qml/MuseScore/Inspector/common/ColorSection.qml index 1ce91e0e7fdfc..ff748fe42c7d1 100644 --- a/src/inspector/view/qml/MuseScore/Inspector/common/ColorSection.qml +++ b/src/inspector/view/qml/MuseScore/Inspector/common/ColorSection.qml @@ -47,6 +47,7 @@ InspectorPropertyView { enabled: root.propertyItem ? root.propertyItem.isEnabled : false isIndeterminate: root.propertyItem && enabled ? root.propertyItem.isUndefined : false color: root.propertyItem && !root.propertyItem.isUndefined ? root.propertyItem.value : ui.theme.backgroundPrimaryColor + allowAlpha: true onNewColorSelected: function(newColor) { if (root.propertyItem) {