Skip to content
Open
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
31 changes: 31 additions & 0 deletions src/project/internal/recentfilescontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "global/concurrency/concurrent.h"
#endif

#include "log.h"

using namespace mu::project;
using namespace muse;
using namespace muse::async;
Expand Down Expand Up @@ -99,6 +101,8 @@ void RecentFilesController::prependRecentFile(const RecentFile& newFile)

void RecentFilesController::moveRecentFile(const muse::io::path_t& before, const RecentFile& after)
{
TRACEFUNC;

bool moved = false;
RecentFilesList newList = m_recentFilesList;

Expand All @@ -115,6 +119,33 @@ void RecentFilesController::moveRecentFile(const muse::io::path_t& before, const
}
}

void RecentFilesController::removeRecentFile(const muse::io::path_t& path)
{
if (path.empty()) {
return;
}

TRACEFUNC;

RecentFilesList newList;
newList.reserve(m_recentFilesList.size());

bool removed = false;

for (const RecentFile& file : m_recentFilesList) {
if (file.path == path) {
removed = true;
continue;
}

newList.push_back(file);
}

if (removed) {
setRecentFilesList(newList, true);
}
}

void RecentFilesController::clearRecentFiles()
{
setRecentFilesList({}, true);
Expand Down
1 change: 1 addition & 0 deletions src/project/internal/recentfilescontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RecentFilesController : public IRecentFilesController, public muse::async:

void prependRecentFile(const RecentFile& file) override;
void moveRecentFile(const muse::io::path_t& before, const RecentFile& after) override;
void removeRecentFile(const muse::io::path_t& path) override;
void clearRecentFiles() override;

muse::async::Promise<QPixmap> thumbnail(const muse::io::path_t& file) const override;
Expand Down
1 change: 1 addition & 0 deletions src/project/irecentfilescontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class IRecentFilesController : MODULE_CONTEXT_INTERFACE

virtual void prependRecentFile(const RecentFile& file) = 0;
virtual void moveRecentFile(const muse::io::path_t& before, const RecentFile& after) = 0;
virtual void removeRecentFile(const muse::io::path_t& path) = 0;
virtual void clearRecentFiles() = 0;

virtual muse::async::Promise<QPixmap> thumbnail(const muse::io::path_t& filePath) const = 0;
Expand Down
1 change: 1 addition & 0 deletions src/project/qml/MuseScore/Project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ qt_add_qml_module(project_qml
internal/ScoresPage/CloudScoresView.qml
internal/ScoresPage/RecentScoresView.qml
internal/ScoresPage/ScoreGridItem.qml
internal/ScoresPage/ScoreItemMenuButton.qml
internal/ScoresPage/ScoreListItem.qml
internal/ScoresPage/ScoresGridView.qml
internal/ScoresPage/ScoresListView.qml
Expand Down
16 changes: 16 additions & 0 deletions src/project/qml/MuseScore/Project/ScoresPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ FocusScope {
onOpenScoreRequested: function(scorePath, displayName) {
Qt.callLater(scoresPageModel.openScore, scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
Qt.callLater(scoresPageModel.revealInFileBrowser, scorePath)
}

onViewOnlineRequested: function(scoreId) {
Qt.callLater(scoresPageModel.viewOnline, scoreId)
}
}
}

Expand Down Expand Up @@ -288,6 +296,14 @@ FocusScope {
Qt.callLater(scoresPageModel.openScore, scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
Qt.callLater(scoresPageModel.revealInFileBrowser, scorePath)
}

onViewOnlineRequested: function(scoreId) {
Qt.callLater(scoresPageModel.viewOnline, scoreId)
}

Connections {
target: refreshButton

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ ScoresView {
onOpenScoreRequested: function(scorePath, displayName) {
root.openScoreRequested(scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
root.revealInFileBrowserRequested(scorePath)
}

onViewOnlineRequested: function(scoreId) {
root.viewOnlineRequested(scoreId)
}
}
}

Expand All @@ -107,6 +115,14 @@ ScoresView {
onOpenScoreRequested: function(scorePath, displayName) {
root.openScoreRequested(scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
root.revealInFileBrowserRequested(scorePath)
}

onViewOnlineRequested: function(scoreId) {
root.viewOnlineRequested(scoreId)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ScoresView {

model: recentScoresModel
searchText: root.searchText
allowRemoveFromRecentFiles: true

isNoResultsMessageAllowed: false // provided by the model instead

Expand All @@ -65,6 +66,18 @@ ScoresView {
onOpenScoreRequested: function(scorePath, displayName) {
root.openScoreRequested(scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
root.revealInFileBrowserRequested(scorePath)
}

onViewOnlineRequested: function(scoreId) {
root.viewOnlineRequested(scoreId)
}

onRemoveFromRecentFilesRequested: function(scorePath) {
recentScoresModel.removeRecentScore(scorePath)
}
}
}

Expand All @@ -78,6 +91,7 @@ ScoresView {

model: recentScoresModel
searchText: root.searchText
allowRemoveFromRecentFiles: true

backgroundColor: root.backgroundColor
sideMargin: root.sideMargin
Expand All @@ -97,6 +111,18 @@ ScoresView {
root.openScoreRequested(scorePath, displayName)
}

onRevealInFileBrowserRequested: function(scorePath) {
root.revealInFileBrowserRequested(scorePath)
}

onViewOnlineRequested: function(scoreId) {
root.viewOnlineRequested(scoreId)
}

onRemoveFromRecentFilesRequested: function(scorePath) {
recentScoresModel.removeRecentScore(scorePath)
}

columns: [
ScoresListView.ColumnItem {
id: modifiedColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ FocusScope {
property bool isNoResultsFound: false
property bool isCloud: false
property int cloudScoreId: 0
property bool showRemoveFromRecentFiles: false

property alias navigation: navCtrl

signal clicked()
signal revealInFileBrowserRequested(string scorePath)
signal viewOnlineRequested(int scoreId)
signal removeFromRecentFilesRequested(string scorePath)

NavigationControl {
id: navCtrl
Expand All @@ -62,13 +66,23 @@ FocusScope {
}

MouseArea {
id: mouseArea
id: rootMouseArea
anchors.fill: parent

enabled: root.enabled
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton

onClicked: function(mouse) {
navCtrl.requestActiveByInteraction()

if (mouse.button === Qt.RightButton) {
if (contextMenu.menuModel.length > 0) {
contextMenu.show(Qt.point(mouse.x, mouse.y), root)
}
return
}

onClicked: {
root.clicked()
}
}
Expand Down Expand Up @@ -98,7 +112,7 @@ FocusScope {

sourceComponent: {
if (root.isCreateNew) {
return addComp
return createNewComp
}

if (root.isNoResultsFound) {
Expand Down Expand Up @@ -133,7 +147,7 @@ FocusScope {
states: [
State {
name: "NORMAL"
when: !mouseArea.containsMouse && !mouseArea.pressed
when: !rootMouseArea.containsMouse && !rootMouseArea.pressed

PropertyChanges {
target: thumbnail
Expand All @@ -143,7 +157,7 @@ FocusScope {

State {
name: "HOVERED"
when: mouseArea.containsMouse && !mouseArea.pressed
when: rootMouseArea.containsMouse && !rootMouseArea.pressed

PropertyChanges {
target: thumbnail
Expand All @@ -154,7 +168,7 @@ FocusScope {

State {
name: "PRESSED"
when: mouseArea.pressed
when: rootMouseArea.pressed

PropertyChanges {
target: thumbnail
Expand All @@ -173,6 +187,35 @@ FocusScope {
}
}

ScoreItemMenuButton {
id: contextMenu

anchors.top: parent.top
anchors.topMargin: 8
anchors.right: parent.right
anchors.rightMargin: 8
visible: menuModel.length > 0
&& (rootMouseArea.containsMouse
|| mouseArea.containsMouse
|| root.navigation.active
|| navigation.active
|| isMenuOpenedByButton)

isCreateNew: root.isCreateNew
isNoResultsFound: root.isNoResultsFound
isCloud: root.isCloud
showRemoveFromRecentFiles: root.showRemoveFromRecentFiles

navigation.panel: root.navigation.panel
navigation.row: root.navigation.row
navigation.column: root.navigation.column + 1

onOpenRequested: root.clicked()
onViewOnlineRequested: root.viewOnlineRequested(root.cloudScoreId)
onRevealInFileBrowserRequested: root.revealInFileBrowserRequested(root.path)
onRemoveFromRecentFilesRequested: root.removeFromRecentFilesRequested(root.path)
}

Loader {
active: root.isCloud

Expand Down Expand Up @@ -208,7 +251,7 @@ FocusScope {

navigation.panel: root.navigation.panel
navigation.row: root.navigation.row
navigation.column: root.navigation.column + 1
navigation.column: root.navigation.column + 2
}

CloudScoreIndicatorButton {
Expand All @@ -219,7 +262,7 @@ FocusScope {

navigation.panel: root.navigation.panel
navigation.row: root.navigation.row
navigation.column: root.navigation.column + 2
navigation.column: root.navigation.column + 3

onClicked: {
if (isProgress) {
Expand Down Expand Up @@ -264,7 +307,7 @@ FocusScope {
}

Component {
id: addComp
id: createNewComp

Rectangle {
anchors.fill: parent
Expand Down
Loading
Loading