Skip to content

Commit

Permalink
Adds cloud related menus
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Mar 25, 2024
1 parent a8be725 commit 80d4473
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/mod-cloud-audiocom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set( TARGET mod-cloud-audiocom )

set( SOURCES
menus/AudioComMenus.cpp

ui/images/CloudImages.cpp
ui/images/CloudImages.hpp

Expand Down
109 changes: 109 additions & 0 deletions modules/mod-cloud-audiocom/menus/AudioComMenus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*!********************************************************************
Audacity: A Digital Audio Editor
AudioComMenus.cpp
Dmitry Vedenko
**********************************************************************/

#include "BasicUI.h"
#include "CloudProjectFileIOExtensions.h"
#include "CloudProjectMixdownUtils.h"
#include "CommandContext.h"
#include "MenuRegistry.h"

#include "sync/MixdownUploader.h"
#include "sync/ProjectCloudExtension.h"

#include "ProjectWindow.h"

#include "ui/dialogs/ProjectsListDialog.h"
#include "ui/dialogs/ShareAudioDialog.h"

#include "CommonCommandFlags.h"

namespace
{
using namespace audacity::cloud::audiocom;
using namespace audacity::cloud::audiocom::sync;

void OnSaveToCloud(const CommandContext& context)
{
SaveToCloud(context.project, UploadMode::Normal);
}

void OnOpenFromCloud(const CommandContext& context)
{
ProjectsListDialog dialog { ProjectWindow::Find(&context.project),
&context.project };

dialog.ShowModal();
}

void OnUpdateMixdown(const CommandContext& context)
{
UploadMixdown(
context.project,
[](auto& project, auto state)
{
if (state != MixdownState::Succeeded)
return;

auto& projectCloudExtension = ProjectCloudExtension::Get(project);

BasicUI::OpenInDefaultBrowser(
projectCloudExtension.GetCloudProjectPage());
});
}

void OnShareAudio(const CommandContext& context)
{
ShareAudioDialog dialog {
context.project,
ProjectWindow::Find(&context.project),
};

dialog.ShowModal();
}

const ReservedCommandFlag& IsCloudProjectFlag()
{
static ReservedCommandFlag flag {
[](const AudacityProject& project)
{ return ProjectCloudExtension::Get(project).IsCloudProject(); },
CommandFlagOptions { [](const TranslatableString&) {
return XO("Previews can be updated only for Cloud projects");
} }.QuickTest()
.Priority(1)
};
return flag;
}

using namespace MenuRegistry;

AttachedItem sSaveAttachment { Command(
wxT("SaveToCloud"), XXO("Save To Cloud..."),
OnSaveToCloud, AlwaysEnabledFlag),
wxT("File/Save") };

AttachedItem sMixdownAttachment { Command(
wxT("UpdateMixdown"),
XXO("Update Cloud Audio Preview"),
OnUpdateMixdown, IsCloudProjectFlag()),
wxT("File/Save") };

AttachedItem sOpenAttachment { Command(
wxT("OpenFromCloud"),
XXO("Open From Cloud..."), OnOpenFromCloud,
AlwaysEnabledFlag),
wxT("File/Basic") };

AttachedItem sShareAttachment { Command(
wxT("ShareAudio"), XXO("Share Audio..."),
OnShareAudio, WaveTracksExistFlag()),
wxT("File/Import-Export") };

} // namespace

0 comments on commit 80d4473

Please sign in to comment.