Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions: some fix and clean up #23996

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions share/extensions/example1/Main.qml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import QtQuick 2.15

import Muse.Controls 1.0
import MuseApi.Extensions 1.0
import MuseApi.Controls 1.0

Rectangle {
ExtensionBlank {

id: root

Expand Down
2 changes: 1 addition & 1 deletion share/extensions/example3/configure.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.15

import Muse.Controls 1.0
import MuseApi.Controls 1.0

Rectangle {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import QtQuick

Rectangle {

color: api.theme.backgroundPrimaryColor

}
2 changes: 2 additions & 0 deletions src/framework/extensions/api/MuseApi/Extensions/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MuseApi.Extensions
ExtensionBlank 1.0 ExtensionBlank.qml
2 changes: 2 additions & 0 deletions src/framework/extensions/extensions.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<file>qml/Muse/Extensions/internal/resources/placeholder.png</file>
<file>qml/Muse/Extensions/internal/ExtensionItem.qml</file>
<file>qml/Muse/Extensions/internal/ExtensionsListView.qml</file>
<file>api/MuseApi/Extensions/ExtensionBlank.qml</file>
<file>api/MuseApi/Extensions/qmldir</file>
</qresource>
</RCC>
15 changes: 15 additions & 0 deletions src/framework/extensions/extensionsmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@

#include "devtools/devextensionslistmodel.h"

#include "muse_framework_config.h"
#ifdef MUSE_MODULE_DIAGNOSTICS
#include "diagnostics/idiagnosticspathsregister.h"
#endif

#include "log.h"

using namespace muse::extensions;
Expand Down Expand Up @@ -106,6 +111,16 @@ void ExtensionsModule::onInit(const IApplication::RunMode& mode)

m_configuration->init();
m_actionController->init();

#ifdef MUSE_MODULE_DIAGNOSTICS
auto pr = ioc()->resolve<muse::diagnostics::IDiagnosticsPathsRegister>(moduleName());
if (pr) {
pr->reg("extensions: defaultPath", m_configuration->defaultPath());
pr->reg("extensions: userPath", m_configuration->userPath());
pr->reg("plugins (legacy): defaultPath", m_configuration->pluginsDefaultPath());
pr->reg("plugins (legacy): userPath", m_configuration->pluginsUserPath());
}
#endif
}

void ExtensionsModule::onDelayedInit()
Expand Down
8 changes: 6 additions & 2 deletions src/framework/extensions/internal/extensionsconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void ExtensionsConfiguration::init()
if (!pluginsUserPath().empty()) {
io::Dir::mkpath(pluginsUserPath());
}

io::Dir::mkpath(userPath());
}

io::path_t ExtensionsConfiguration::defaultPath() const
Expand Down Expand Up @@ -104,7 +106,7 @@ Ret ExtensionsConfiguration::setManifestConfigs(const std::map<Uri, Manifest::Co
ByteArray data = JsonDocument(arr).toJson();
{
mi::WriteResourceLockGuard lock_guard(multiInstancesProvider.get(), EXTENSIONS_RESOURCE_NAME);
ret = io::File::writeFile(pluginsUserPath() + "/config.json", data);
ret = io::File::writeFile(userPath() + "/config.json", data);
}

if (!ret) {
Expand All @@ -116,7 +118,7 @@ Ret ExtensionsConfiguration::setManifestConfigs(const std::map<Uri, Manifest::Co

std::map<muse::Uri, Manifest::Config> ExtensionsConfiguration::manifestConfigs() const
{
const io::path_t configPath = pluginsUserPath() + "/config.json";
const io::path_t configPath = userPath() + "/config.json";
const io::path_t oldPluginsConfigPath = globalConfiguration()->userAppDataPath() + "/plugins/plugins.json";

//! NOTE Load current config
Expand Down Expand Up @@ -165,6 +167,8 @@ std::map<muse::Uri, Manifest::Config> ExtensionsConfiguration::manifestConfigs()

c.actions[code] = ac;
}

result.insert({ uri, c });
}

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Muse.Controls
module MuseApi.Controls
StyledTextLabel 1.0 ../../../qml/Muse/UiComponents/StyledTextLabel.qml
FlatButton 1.0 ../../../qml/Muse/UiComponents/FlatButton.qml
2 changes: 1 addition & 1 deletion src/framework/uicomponents/uicomponents.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>api/Muse/Controls/qmldir</file>
<file>api/MuseApi/Controls/qmldir</file>
<file>qml/Muse/UiComponents/Border.qml</file>
<file>qml/Muse/UiComponents/ButtonBox.qml</file>
<file>qml/Muse/UiComponents/CheckBox.qml</file>
Expand Down