Skip to content

Commit

Permalink
Merge pull request #26384 from Eism/workspace_redesign
Browse files Browse the repository at this point in the history
Workspaces. Redesign
  • Loading branch information
Eism authored Feb 21, 2025
2 parents dbe4adf + b8414b5 commit 40d8cee
Show file tree
Hide file tree
Showing 62 changed files with 1,204 additions and 769 deletions.
6 changes: 6 additions & 0 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ install (DIRECTORY
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}
PATTERN ".*" EXCLUDE
)

install (DIRECTORY
workspaces
DESTINATION ${Mscore_SHARE_NAME}${Mscore_INSTALL_NAME}
PATTERN ".*" EXCLUDE
)
Binary file added share/workspaces/Default.mws
Binary file not shown.
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ if (MUE_BUILD_PROJECT_MODULE)
add_subdirectory(project)
endif()

if (MUSE_MODULE_WORKSPACE)
add_subdirectory(workspacescene)
endif()

# Stubs
add_subdirectory(stubs)

Expand Down
1 change: 0 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ set(LINK_LIB
context
muse::shortcuts
muse::workspace
workspacescene
muse::audio
muse::mpe
muse::midi
Expand Down
1 change: 1 addition & 0 deletions src/app/app.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<file>configs/data/shortcuts.xml</file>
<file>configs/data/shortcuts_mac.xml</file>
<file>configs/data/shortcuts_azerty.xml</file>
<file>configs/workspaces.cfg</file>
</qresource>
</RCC>
8 changes: 0 additions & 8 deletions src/app/appfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,6 @@
#include "stubs/project/projectstubmodule.h"
#endif

#ifdef MUSE_MODULE_WORKSPACE
#include "workspacescene/workspacescenemodule.h"
#else
#include "stubs/workspacescene/workspacescenestubmodule.h"
#endif

#ifdef Q_OS_WASM
#include "wasmtest/wasmtestmodule.h"
#endif
Expand Down Expand Up @@ -323,7 +317,6 @@ std::shared_ptr<muse::IApplication> AppFactory::newGuiApp(const CmdOptions& opti
app->addModule(new mu::project::ProjectModule());
app->addModule(new muse::update::UpdateModule());
app->addModule(new muse::workspace::WorkspaceModule());
app->addModule(new mu::workspacescene::WorkspaceSceneModule());

#ifdef Q_OS_WASM
app->addModule(new mu::wasmtest::WasmTestModule());
Expand Down Expand Up @@ -439,7 +432,6 @@ std::shared_ptr<muse::IApplication> AppFactory::newConsoleApp(const CmdOptions&
app->addModule(new mu::project::ProjectModule());
app->addModule(new muse::update::UpdateModule());
app->addModule(new muse::workspace::WorkspaceModule());
app->addModule(new mu::workspacescene::WorkspaceSceneModule());

#ifdef Q_OS_WASM
app->addModule(new mu::wasmtest::WasmTestModule());
Expand Down
6 changes: 6 additions & 0 deletions src/app/configs/workspaces.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default_workspace_name": "Default",
"builtin_workspace_files": [
"Default.mws"
]
}
15 changes: 14 additions & 1 deletion src/appshell/qml/NotationPage/NotationStatusBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,27 @@ Item {
Layout.preferredHeight: 28

text: model.currentWorkspaceItem.title
icon: IconCode.WORKSPACE
orientation: Qt.Horizontal

transparent: true
visible: statusBarRow.remainingSpace > width + concertPitchControl.width

navigation.panel: navPanel
navigation.order: 1

onClicked: {
Qt.callLater(model.selectWorkspace)
menuLoader.toggleOpened(model.currentWorkspaceItem.subitems)
}

StyledMenuLoader {
id: menuLoader

menuAnchorItem: ui.rootItem

onHandleMenuItem: function(itemId) {
Qt.callLater(model.handleWorkspacesMenuItem, itemId)
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/appshell/qml/platform/PlatformMenuBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ Item {
menu.title = menuInfo.title
menu.enabled = menuInfo.enabled
menu.subitems = menuInfo.subitems

menuInfo.subitemsChanged.connect(function(subitems, menuId) {
if (menu.id === menuId) {
menu.subitems = subitems
menu.load()
}
})
}

function makeMenuItem(parentMenu, itemInfo) {
Expand Down
78 changes: 27 additions & 51 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

#include "types/translatablestring.h"

#include "muse_framework_config.h"

#ifdef MUSE_MODULE_WORKSPACE
#include "workspace/view/workspacesmenumodel.h"
#endif

#include "log.h"

using namespace muse;
Expand All @@ -45,6 +51,9 @@ static QString makeId(const ActionCode& actionCode, int itemIndex)
AppMenuModel::AppMenuModel(QObject* parent)
: AbstractMenuModel(parent)
{
#ifdef MUSE_MODULE_WORKSPACE
m_workspacesMenuModel = std::make_shared<WorkspacesMenuModel>(this);
#endif
}

void AppMenuModel::load()
Expand All @@ -53,6 +62,10 @@ void AppMenuModel::load()

AbstractMenuModel::load();

#ifdef MUSE_MODULE_WORKSPACE
m_workspacesMenuModel->load();
#endif

MenuItemList items {
makeFileMenu(),
makeEditMenu(),
Expand Down Expand Up @@ -103,15 +116,12 @@ void AppMenuModel::setupConnections()
recentScoreListItem.setSubitems(recentScoresList);
});

workspacesManager()->currentWorkspaceChanged().onNotify(this, [this]() {
#ifdef MUSE_MODULE_WORKSPACE
connect(m_workspacesMenuModel.get(), &WorkspacesMenuModel::itemsChanged, this, [this](){
MenuItem& workspacesItem = findMenu("menu-workspaces");
workspacesItem.setSubitems(makeWorkspacesItems());
});

workspacesManager()->workspacesListChanged().onNotify(this, [this]() {
MenuItem& workspacesItem = findMenu("menu-workspaces");
workspacesItem.setSubitems(makeWorkspacesItems());
workspacesItem.setSubitems(m_workspacesMenuModel->items());
});
#endif

extensionsProvider()->manifestListChanged().onNotify(this, [this]() {
MenuItem& pluginsMenu = findMenu("menu-plugins");
Expand Down Expand Up @@ -264,14 +274,18 @@ MenuItem* AppMenuModel::makeViewMenu()
makeMenuItem("playback-setup"),
//makeMenuItem("toggle-scorecmp-tool"), // not implemented
makeSeparator(),
makeMenu(TranslatableString("appshell/menu/view", "&Toolbars"), makeToolbarsItems(), "menu-toolbars"),
makeMenu(TranslatableString("appshell/menu/view", "W&orkspaces"), makeWorkspacesItems(), "menu-workspaces"),
makeSeparator(),
makeMenu(TranslatableString("appshell/menu/view", "&Show"), makeShowItems(), "menu-show"),
makeSeparator(),
makeMenuItem("dock-restore-default-layout")
makeMenu(TranslatableString("appshell/menu/view", "&Toolbars"), makeToolbarsItems(), "menu-toolbars")
};

#ifdef MUSE_MODULE_WORKSPACE
viewItems << makeMenu(TranslatableString("appshell/menu/view", "W&orkspaces"), m_workspacesMenuModel->items(), "menu-workspaces"),
#endif

viewItems << makeSeparator()
<< makeMenu(TranslatableString("appshell/menu/view", "&Show"), makeShowItems(), "menu-show")
<< makeSeparator()
<< makeMenuItem("dock-restore-default-layout");

return makeMenu(TranslatableString("appshell/menu/view", "&View"), viewItems, "menu-view");
}

Expand Down Expand Up @@ -686,44 +700,6 @@ MenuItemList AppMenuModel::makeToolbarsItems()
return items;
}

MenuItemList AppMenuModel::makeWorkspacesItems()
{
MenuItemList items;

IWorkspacePtrList workspaces = workspacesManager()->workspaces();
IWorkspacePtr currentWorkspace = workspacesManager()->currentWorkspace();

std::sort(workspaces.begin(), workspaces.end(), [](const IWorkspacePtr& workspace1, const IWorkspacePtr& workspace2) {
return workspace1->name() < workspace2->name();
});

int index = 0;
for (const IWorkspacePtr& workspace : workspaces) {
MenuItem* item = new MenuItem(uiActionsRegister()->action("select-workspace"), this);
item->setId(makeId(item->action().code, index++));

UiAction action = item->action();
action.title = TranslatableString::untranslatable(String::fromStdString(workspace->title()));

item->setAction(action);
item->setArgs(ActionData::make_arg1<std::string>(workspace->name()));
item->setSelectable(true);
item->setSelected(workspace == currentWorkspace);

UiActionState state;
state.enabled = true;
state.checked = item->selected();
item->setState(state);

items << item;
}

items << makeSeparator()
<< makeMenuItem("configure-workspaces");

return items;
}

MenuItemList AppMenuModel::makeShowItems()
{
MenuItemList items {
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/view/appmenumodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ class AppMenuModel : public muse::uicomponents::AbstractMenuModel

mu::notation::INotationUndoStackPtr undoStack() const;
void updateUndoRedoItems();

std::shared_ptr<muse::uicomponents::AbstractMenuModel> m_workspacesMenuModel;
};
}
39 changes: 25 additions & 14 deletions src/appshell/view/notationstatusbarmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@

#include "types/translatablestring.h"

#include "muse_framework_config.h"

#ifdef MUSE_MODULE_WORKSPACE
#include "workspace/view/workspacesmenumodel.h"
#endif

#include "defer.h"
#include "log.h"

Expand All @@ -33,6 +39,7 @@ using namespace muse;
using namespace muse::actions;
using namespace muse::ui;
using namespace muse::uicomponents;
using namespace muse::workspace;

static const QString TITLE_KEY("title");
static const QString ICON_KEY("icon");
Expand Down Expand Up @@ -69,6 +76,9 @@ static ActionCode zoomTypeToActionCode(ZoomType type)
NotationStatusBarModel::NotationStatusBarModel(QObject* parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
#ifdef MUSE_MODULE_WORKSPACE
m_workspacesMenuModel = std::make_shared<WorkspacesMenuModel>(this);
#endif
}

QString NotationStatusBarModel::accessibilityInfo() const
Expand Down Expand Up @@ -103,6 +113,10 @@ QVariant NotationStatusBarModel::currentWorkspaceItem()

m_currentWorkspaceItem->setAction(action);

#ifdef MUSE_MODULE_WORKSPACE
m_currentWorkspaceItem->setSubitems(m_workspacesMenuModel->items());
#endif

return QVariant::fromValue(m_currentWorkspaceItem);
}

Expand Down Expand Up @@ -214,17 +228,12 @@ void NotationStatusBarModel::load()
onCurrentNotationChanged();
});

workspaceConfiguration()->currentWorkspaceNameChanged().onReceive(this, [this](const std::string&) {
#ifdef MUSE_MODULE_WORKSPACE
m_workspacesMenuModel->load();
connect(m_workspacesMenuModel.get(), &WorkspacesMenuModel::itemsChanged, this, [this](){
emit currentWorkspaceActionChanged();
});

actionsRegister()->actionStateChanged().onReceive(this, [this](const ActionCodeList& codeList) {
for (const ActionCode& code : codeList) {
if (code == SELECT_WORKSPACE_CODE) {
emit currentWorkspaceActionChanged();
}
}
});
#endif
}

void NotationStatusBarModel::onCurrentNotationChanged()
Expand Down Expand Up @@ -273,11 +282,6 @@ void NotationStatusBarModel::listenChangesInAccessibility()
});
}

void NotationStatusBarModel::selectWorkspace()
{
dispatch(SELECT_WORKSPACE_CODE);
}

void NotationStatusBarModel::toggleConcertPitch()
{
dispatch(TOGGLE_CONCERT_PITCH_CODE);
Expand Down Expand Up @@ -400,6 +404,13 @@ void NotationStatusBarModel::handleAction(const QString& actionCode)
dispatch(codeFromQString(actionCode));
}

void NotationStatusBarModel::handleWorkspacesMenuItem(const QString& itemId)
{
#ifdef MUSE_MODULE_WORKSPACE
m_workspacesMenuModel->handleMenuItem(itemId);
#endif
}

INotationPtr NotationStatusBarModel::notation() const
{
return context()->currentNotation();
Expand Down
6 changes: 5 additions & 1 deletion src/appshell/view/notationstatusbarmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

#include "async/asyncable.h"
#include "actions/actionable.h"

#include "uicomponents/view/menuitem.h"
#include "uicomponents/view/abstractmenumodel.h"

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
Expand Down Expand Up @@ -73,7 +75,6 @@ class NotationStatusBarModel : public QObject, public muse::Injectable, public m

Q_INVOKABLE void load();

Q_INVOKABLE void selectWorkspace();
Q_INVOKABLE void toggleConcertPitch();
Q_INVOKABLE void setCurrentViewMode(const QString& modeCode);

Expand All @@ -84,6 +85,7 @@ class NotationStatusBarModel : public QObject, public muse::Injectable, public m
Q_INVOKABLE void zoomOut();

Q_INVOKABLE void handleAction(const QString& actionCode);
Q_INVOKABLE void handleWorkspacesMenuItem(const QString& itemId);

public slots:
void setCurrentZoomPercentage(int zoomPercentage);
Expand Down Expand Up @@ -126,6 +128,8 @@ public slots:
muse::uicomponents::MenuItem* m_concertPitchItem = nullptr;
muse::uicomponents::MenuItemList m_availableViewModeList;
muse::uicomponents::MenuItemList m_availableZoomList;

std::shared_ptr<muse::uicomponents::AbstractMenuModel> m_workspacesMenuModel;
};
}

Expand Down
10 changes: 10 additions & 0 deletions src/framework/stubs/workspace/workspaceconfigurationstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,21 @@ io::paths_t WorkspaceConfigurationStub::workspacePaths() const
return io::paths_t();
}

io::paths_t WorkspaceConfigurationStub::builtinWorkspacesFilePaths() const
{
return io::paths_t();
}

io::path_t WorkspaceConfigurationStub::userWorkspacesPath() const
{
return io::path_t();
}

std::string WorkspaceConfigurationStub::defaultWorkspaceName() const
{
return std::string();
}

std::string WorkspaceConfigurationStub::currentWorkspaceName() const
{
return std::string();
Expand Down
Loading

0 comments on commit 40d8cee

Please sign in to comment.