Audacity 3.2.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
audacity::cloud::audiocom::sync::ProjectsListDialog Class Referencefinal

#include <ProjectsListDialog.h>

Inheritance diagram for audacity::cloud::audiocom::sync::ProjectsListDialog:
[legend]
Collaboration diagram for audacity::cloud::audiocom::sync::ProjectsListDialog:
[legend]

Classes

class  ProjectsTableData
 

Public Member Functions

 ProjectsListDialog (wxWindow *parent, AudacityProject *project)
 
 ~ProjectsListDialog () override
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void SetupHandlers ()
 
void OnBeforeRefresh ()
 
void OnRefreshCompleted (bool success)
 
void FormatPageLabel ()
 
void OnOpen ()
 
void OnOpenAudioCom ()
 
void OnGridSelect (wxGridRangeSelectEvent &event)
 
void OnSelectCell (wxGridEvent &event)
 
void OnSearchTextChanged ()
 
void OnSearchTextSubmitted ()
 

Private Attributes

AudacityProjectmProject { nullptr }
 
wxTextCtrl * mSearchCtrl { nullptr }
 
wxGrid * mProjectsTable { nullptr }
 
ProjectsTableDatamProjectsTableData { nullptr }
 
wxStaticText * mPageLabel { nullptr }
 
wxButton * mPrevPageButton { nullptr }
 
wxButton * mNextPageButton { nullptr }
 
wxButton * mOpenButton { nullptr }
 
wxButton * mOpenAudioCom { nullptr }
 
wxString mLastSearchValue
 
std::unique_ptr< wxTimer > mSearchTimer
 
bool mInRangeSelection { false }
 

Detailed Description

Definition at line 33 of file ProjectsListDialog.h.

Constructor & Destructor Documentation

◆ ProjectsListDialog()

audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsListDialog ( wxWindow *  parent,
AudacityProject project 
)

Definition at line 549 of file ProjectsListDialog.cpp.

551 : wxDialogWrapper { parent, wxID_ANY, OpenFromCloudTitle }
552 , mProject { project }
553{
554 auto header =
555 safenew wxStaticText { this, wxID_ANY,
556 XO("Cloud saved projects").Translation() };
557 auto searchHeader =
558 safenew wxStaticText { this, wxID_ANY, XO("Search:").Translation() };
559
560 mSearchCtrl = safenew wxTextCtrl { this, wxID_ANY,
561 wxEmptyString, wxDefaultPosition,
562 wxDefaultSize, wxTE_PROCESS_ENTER };
563
564 mProjectsTable = safenew wxGrid { this, wxID_ANY };
565
566 mProjectsTableData = safenew ProjectsTableData { *this, 7 };
567
568 mProjectsTable->SetDefaultRowSize(32);
569
570 mProjectsTable->SetGridLineColour(
571 mProjectsTable->GetDefaultCellBackgroundColour());
572 mProjectsTable->SetCellHighlightPenWidth(0);
573
574 mProjectsTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
575 mProjectsTable->SetTable(mProjectsTableData, true);
576 mProjectsTable->SetRowLabelSize(0);
577
578 mProjectsTable->EnableEditing(false);
579 mProjectsTable->SetSelectionMode(wxGrid::wxGridSelectRows);
580 mProjectsTable->SetTabBehaviour(wxGrid::Tab_Leave);
581
582 mProjectsTable->SetMinSize({ -1, 32 * 8 + 9 });
583
584 for (auto i = 0; i < mProjectsTableData->GetNumberCols(); ++i)
586
587#if wxUSE_ACCESSIBILITY
588 mAccessible =
589 safenew ProjectListAccessible { *mProjectsTable, *mProjectsTableData };
590 mProjectsTable->GetGridWindow()->SetAccessible(mAccessible);
591#endif
592
593 mPageLabel = safenew wxStaticText { this, wxID_ANY, {} };
595 safenew wxButton { this, wxID_ANY, XO("Prev").Translation() };
597 safenew wxButton { this, wxID_ANY, XO("Next").Translation() };
598 mOpenButton = safenew wxButton { this, wxID_ANY, XO("Open").Translation() };
599 mOpenAudioCom = safenew wxButton { this, wxID_ANY,
600 XO("View in audio.com").Translation() };
601
602 auto topSizer = safenew wxBoxSizer { wxVERTICAL };
603
604 auto headerSizer = safenew wxBoxSizer { wxHORIZONTAL };
605 headerSizer->Add(header, wxSizerFlags().CenterVertical().Left());
606 headerSizer->AddStretchSpacer();
607 headerSizer->Add(
608 searchHeader, wxSizerFlags().CenterVertical().Border(wxRIGHT, 4));
609 headerSizer->Add(mSearchCtrl, wxSizerFlags().CenterVertical());
610
611 topSizer->Add(headerSizer, wxSizerFlags().Expand().Border(wxALL, 16));
612 topSizer->Add(
613 mProjectsTable, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 16));
614
615 auto pageSizer = safenew wxBoxSizer { wxHORIZONTAL };
616 pageSizer->Add(mPageLabel, wxSizerFlags().CenterVertical());
617 pageSizer->AddStretchSpacer();
618 pageSizer->Add(mPrevPageButton, wxSizerFlags().CenterVertical());
619 pageSizer->Add(mNextPageButton, wxSizerFlags().CenterVertical());
620 topSizer->AddSpacer(8);
621 topSizer->Add(
622 pageSizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 16));
623
624 auto buttonsSizer = safenew wxBoxSizer { wxHORIZONTAL };
625 buttonsSizer->Add(mOpenAudioCom, wxSizerFlags().CenterVertical());
626 buttonsSizer->AddStretchSpacer();
627 buttonsSizer->Add(mOpenButton, wxSizerFlags().CenterVertical());
628
629 topSizer->Add(buttonsSizer, wxSizerFlags().Expand().Border(wxALL, 16));
630
631 mOpenButton->Disable();
632 mOpenAudioCom->Disable();
633
634 mSearchTimer = std::make_unique<wxTimer>(this);
635
636 SetSizer(topSizer);
637 Fit();
638 Center();
639
641 BasicUI::CallAfter([this]
643}
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
const auto project
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:214

References BasicUI::CallAfter(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetColWidth(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetNumberCols(), mLastSearchValue, mNextPageButton, mOpenAudioCom, mOpenButton, mPageLabel, mPrevPageButton, mProjectsTable, mProjectsTableData, mSearchCtrl, mSearchTimer, audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::Refresh(), safenew, SetupHandlers(), and XO().

Here is the call graph for this function:

◆ ~ProjectsListDialog()

audacity::cloud::audiocom::sync::ProjectsListDialog::~ProjectsListDialog ( )
overridedefault

Member Function Documentation

◆ FormatPageLabel()

void audacity::cloud::audiocom::sync::ProjectsListDialog::FormatPageLabel ( )
private

Definition at line 771 of file ProjectsListDialog.cpp.

772{
774 {
775 mPageLabel->SetLabel({});
776 return;
777 }
778
779 mPageLabel->SetLabel(XO("Page %d of %d")
780 .Format(
783 .Translation());
784}
Abstract base class used in importing a file.

References audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetCurrentPage(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetPagesCount(), mPageLabel, mProjectsTableData, and XO().

Referenced by OnRefreshCompleted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnBeforeRefresh()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnBeforeRefresh ( )
private

Definition at line 748 of file ProjectsListDialog.cpp.

749{
750 mProjectsTable->Enable(false);
751 mPrevPageButton->Enable(false);
752 mNextPageButton->Enable(false);
753}

References mNextPageButton, mPrevPageButton, and mProjectsTable.

Referenced by audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::Refresh().

Here is the caller graph for this function:

◆ OnGridSelect()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnGridSelect ( wxGridRangeSelectEvent &  event)
private

Definition at line 841 of file ProjectsListDialog.cpp.

842{
843 event.Skip();
844
845 if (!event.Selecting())
846 {
847 mOpenButton->Disable();
848 mOpenAudioCom->Disable();
849 return;
850 }
851
852 mOpenButton->Enable();
853 mOpenAudioCom->Enable();
854
855 const auto topRow = event.GetTopRow();
856 const auto bottomRow = event.GetBottomRow();
857 const auto currentRow = mProjectsTable->GetGridCursorRow();
858
859 if (topRow != bottomRow)
860 {
862 return;
863
864 mInRangeSelection = true;
865 auto switcher = finally([this] { mInRangeSelection = false; });
866
867 mProjectsTable->SelectRow(currentRow == topRow ? bottomRow : topRow);
868 }
869}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnOpen()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnOpen ( )
private

Definition at line 786 of file ProjectsListDialog.cpp.

787{
788 if (mProjectsTable->GetSelectedRows().empty())
789 return;
790
791 const auto projectInfo = mProjectsTableData->GetSelectedProjectInfo();
792
793 if (projectInfo == nullptr)
794 return;
795
796 if (projectInfo->HeadSnapshot.Synced == 0)
797 {
798 const auto state = CloudSyncService::GetProjectState(projectInfo->Id);
799
801 {
802 const bool hasValidSnapshot =
803 !projectInfo->LastSyncedSnapshotId.empty();
804
805 const auto result =
806 UnsyncedProjectDialog { mProject, hasValidSnapshot }.ShowDialog();
807
809 {
812
813 return;
814 }
815
817 return;
818 }
819 }
820
821 EndModal(wxID_OK);
822
824 [project = mProject, selectedProjectId = projectInfo->Id]
825 { OpenProjectFromCloud(project, selectedProjectId, {}, false); });
826}
static ProjectState GetProjectState(const std::string &projectId)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Definition: BasicUI.cpp:246
wxString ToWXString(const std::string &str)

References BasicUI::CallAfter(), audacity::cloud::audiocom::sync::AudioComDialogBase::CancelButtonIdentifier(), audacity::cloud::audiocom::CloudSyncService::GetProjectState(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetSelectedProjectInfo(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetSelectedProjectUrl(), mProject, mProjectsTable, mProjectsTableData, BasicUI::OpenInDefaultBrowser(), audacity::cloud::audiocom::CloudSyncService::PendingSync, project, audacity::ToWXString(), and audacity::cloud::audiocom::sync::UnsyncedProjectDialog::VisitAudioComButtonIdentifier().

Referenced by SetupHandlers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnOpenAudioCom()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnOpenAudioCom ( )
private

Definition at line 828 of file ProjectsListDialog.cpp.

829{
830 if (mProjectsTable->GetSelectedRows().empty())
831 return;
832
833 const auto selectedProjectUrl = mProjectsTableData->GetSelectedProjectUrl();
834
835 if (selectedProjectUrl.empty())
836 return;
837
838 BasicUI::OpenInDefaultBrowser(ToWXString(selectedProjectUrl));
839}

References BasicUI::OpenInDefaultBrowser(), and audacity::ToWXString().

Referenced by SetupHandlers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRefreshCompleted()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnRefreshCompleted ( bool  success)
private

Definition at line 755 of file ProjectsListDialog.cpp.

756{
757 mProjectsTable->Enable(success);
758
759 mPrevPageButton->Enable(success && mProjectsTableData->HasPrevPage());
760 mNextPageButton->Enable(success && mProjectsTableData->HasNextPage());
761
763
764 mProjectsTable->ForceRefresh();
765
766#if wxUSE_ACCESSIBILITY
767 mAccessible->TableDataUpdated();
768#endif
769}

References FormatPageLabel(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::HasNextPage(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::HasPrevPage(), mNextPageButton, mPrevPageButton, mProjectsTable, and mProjectsTableData.

Referenced by audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::Refresh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSearchTextChanged()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnSearchTextChanged ( )
private

Definition at line 881 of file ProjectsListDialog.cpp.

882{
883 mSearchTimer->StartOnce(500);
884}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnSearchTextSubmitted()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnSearchTextSubmitted ( )
private

Definition at line 886 of file ProjectsListDialog.cpp.

887{
888 if (mSearchTimer->IsRunning())
889 mSearchTimer->Stop();
890
891 const auto searchTerm = mSearchCtrl->GetValue();
892
893 if (searchTerm == mLastSearchValue)
894 return;
895
896 mLastSearchValue = searchTerm;
897
899}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnSelectCell()

void audacity::cloud::audiocom::sync::ProjectsListDialog::OnSelectCell ( wxGridEvent &  event)
private

Definition at line 871 of file ProjectsListDialog.cpp.

872{
873 event.Skip();
874 mProjectsTable->SelectRow(event.GetRow());
875
876#if wxUSE_ACCESSIBILITY
877 mAccessible->SetSelectedRow(event.GetRow());
878#endif
879}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ SetupHandlers()

void audacity::cloud::audiocom::sync::ProjectsListDialog::SetupHandlers ( )
private

Definition at line 647 of file ProjectsListDialog.cpp.

648{
649 mPrevPageButton->Bind(
650 wxEVT_BUTTON, [this](auto&) { mProjectsTableData->PrevPage(); });
651
652 mNextPageButton->Bind(
653 wxEVT_BUTTON, [this](auto&) { mProjectsTableData->NextPage(); });
654
655 mOpenButton->Bind(wxEVT_BUTTON, [this](auto&) { OnOpen(); });
656
657 mOpenAudioCom->Bind(wxEVT_BUTTON, [this](auto&) { OnOpenAudioCom(); });
658
659 mProjectsTable->Bind(
660 wxEVT_GRID_CELL_LEFT_DCLICK, [this](auto&) { OnOpen(); });
661
662 Bind(
663 wxEVT_CHAR_HOOK,
664 [this](auto& evt)
665 {
666 if (!IsEscapeKey(evt))
667 {
668 evt.Skip();
669 return;
670 }
671
672 EndModal(wxID_CANCEL);
673 });
674
675 mProjectsTable->Bind(
676 wxEVT_GRID_RANGE_SELECT, [this](auto& evt) { OnGridSelect(evt); });
677
678 mProjectsTable->Bind(
679 wxEVT_GRID_SELECT_CELL, [this](auto& evt) { OnSelectCell(evt); });
680
681 mProjectsTable->Bind(
682 wxEVT_KEY_UP,
683 [this](auto& evt)
684 {
685 const auto keyCode = evt.GetKeyCode();
686 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
687 {
688 evt.Skip();
689 return;
690 }
691
692 OnOpen();
693 });
694
695 mProjectsTable->Bind(
696 wxEVT_KEY_DOWN,
697 [this](auto& evt)
698 {
699 const auto keyCode = evt.GetKeyCode();
700 // prevent being able to up arrow past the first row (issue #6251)
701 if (keyCode == WXK_UP && mProjectsTable->GetGridCursorRow() == 0) {
702 return;
703 }
704 // prevent being able to down arrow past the last row (issue #6251)
705 if (keyCode == WXK_DOWN &&
706 mProjectsTable->GetGridCursorRow() ==
707 mProjectsTable->GetNumberRows() - 1) {
708 return;
709 }
710 if (keyCode != WXK_RETURN && keyCode != WXK_NUMPAD_ENTER)
711 {
712 evt.Skip();
713 return;
714 }
715 });
716
717 mProjectsTable->Bind(
718 wxEVT_GRID_TABBING,
719 [this](auto& evt)
720 {
721 // needed for correct tabbing - see issue #6190
722 NavigateIn(evt.ShiftDown() ? wxNavigationKeyEvent::IsBackward :
723 wxNavigationKeyEvent::IsForward);
724 });
725
726 mProjectsTable->Bind(
727 wxEVT_SET_FOCUS,
728 [this](auto& evt)
729 {
730 // needed so that for screen readers a row rather than the whole
731 // table is the initial focus - see issue #6190
732#if wxUSE_ACCESSIBILITY
733 int row = mProjectsTable->GetGridCursorRow();
734 if (row != -1)
735 mAccessible->SetSelectedRow(row);
736#endif
737 evt.Skip();
738 });
739
740 mSearchCtrl->Bind(wxEVT_TEXT, [this](auto&) { OnSearchTextChanged(); });
741
742 mSearchCtrl->Bind(
743 wxEVT_TEXT_ENTER, [this](auto&) { OnSearchTextSubmitted(); });
744
745 Bind(wxEVT_TIMER, [this](auto&) { OnSearchTextSubmitted(); });
746}

References mNextPageButton, mOpenAudioCom, mOpenButton, mPrevPageButton, mProjectsTable, mProjectsTableData, mSearchCtrl, audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::NextPage(), OnGridSelect(), OnOpen(), OnOpenAudioCom(), OnSearchTextChanged(), OnSearchTextSubmitted(), OnSelectCell(), and audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::PrevPage().

Referenced by ProjectsListDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mInRangeSelection

bool audacity::cloud::audiocom::sync::ProjectsListDialog::mInRangeSelection { false }
private

Definition at line 82 of file ProjectsListDialog.h.

◆ mLastSearchValue

wxString audacity::cloud::audiocom::sync::ProjectsListDialog::mLastSearchValue
private

◆ mNextPageButton

wxButton* audacity::cloud::audiocom::sync::ProjectsListDialog::mNextPageButton { nullptr }
private

◆ mOpenAudioCom

wxButton* audacity::cloud::audiocom::sync::ProjectsListDialog::mOpenAudioCom { nullptr }
private

Definition at line 72 of file ProjectsListDialog.h.

Referenced by ProjectsListDialog(), and SetupHandlers().

◆ mOpenButton

wxButton* audacity::cloud::audiocom::sync::ProjectsListDialog::mOpenButton { nullptr }
private

Definition at line 71 of file ProjectsListDialog.h.

Referenced by ProjectsListDialog(), and SetupHandlers().

◆ mPageLabel

wxStaticText* audacity::cloud::audiocom::sync::ProjectsListDialog::mPageLabel { nullptr }
private

Definition at line 67 of file ProjectsListDialog.h.

Referenced by FormatPageLabel(), and ProjectsListDialog().

◆ mPrevPageButton

wxButton* audacity::cloud::audiocom::sync::ProjectsListDialog::mPrevPageButton { nullptr }
private

◆ mProject

AudacityProject* audacity::cloud::audiocom::sync::ProjectsListDialog::mProject { nullptr }
private

◆ mProjectsTable

wxGrid* audacity::cloud::audiocom::sync::ProjectsListDialog::mProjectsTable { nullptr }
private

◆ mProjectsTableData

ProjectsTableData* audacity::cloud::audiocom::sync::ProjectsListDialog::mProjectsTableData { nullptr }
private

◆ mSearchCtrl

wxTextCtrl* audacity::cloud::audiocom::sync::ProjectsListDialog::mSearchCtrl { nullptr }
private

Definition at line 62 of file ProjectsListDialog.h.

Referenced by ProjectsListDialog(), and SetupHandlers().

◆ mSearchTimer

std::unique_ptr<wxTimer> audacity::cloud::audiocom::sync::ProjectsListDialog::mSearchTimer
private

Definition at line 76 of file ProjectsListDialog.h.

Referenced by ProjectsListDialog().


The documentation for this class was generated from the following files: