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 540 of file ProjectsListDialog.cpp.

542 : wxDialogWrapper { parent, wxID_ANY, OpenFromCloudTitle }
543 , mProject { project }
544{
545 auto header =
546 safenew wxStaticText { this, wxID_ANY,
547 XO("Cloud saved projects").Translation() };
548 auto searchHeader =
549 safenew wxStaticText { this, wxID_ANY, XO("Search:").Translation() };
550
551 mSearchCtrl = safenew wxTextCtrl { this, wxID_ANY,
552 wxEmptyString, wxDefaultPosition,
553 wxDefaultSize, wxTE_PROCESS_ENTER };
554
555 mProjectsTable = safenew wxGrid { this, wxID_ANY };
556
557 mProjectsTableData = safenew ProjectsTableData { *this, 7 };
558
559 mProjectsTable->SetDefaultRowSize(32);
560
561 mProjectsTable->SetGridLineColour(
562 mProjectsTable->GetDefaultCellBackgroundColour());
563 mProjectsTable->SetCellHighlightPenWidth(0);
564
565 mProjectsTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
566 mProjectsTable->SetTable(mProjectsTableData, true);
567 mProjectsTable->SetRowLabelSize(0);
568
569 mProjectsTable->EnableEditing(false);
570 mProjectsTable->SetSelectionMode(wxGrid::wxGridSelectRows);
571 mProjectsTable->SetTabBehaviour(wxGrid::Tab_Leave);
572
573 mProjectsTable->SetMinSize({ -1, 32 * 8 + 9 });
574
575 for (auto i = 0; i < mProjectsTableData->GetNumberCols(); ++i)
577
578#if wxUSE_ACCESSIBILITY
579 mAccessible =
580 safenew ProjectListAccessible { *mProjectsTable, *mProjectsTableData };
581 mProjectsTable->GetGridWindow()->SetAccessible(mAccessible);
582#endif
583
584 mPageLabel = safenew wxStaticText { this, wxID_ANY, {} };
586 safenew wxButton { this, wxID_ANY, XO("Prev").Translation() };
588 safenew wxButton { this, wxID_ANY, XO("Next").Translation() };
589 mOpenButton = safenew wxButton { this, wxID_ANY, XO("Open").Translation() };
590 mOpenAudioCom = safenew wxButton { this, wxID_ANY,
591 XO("View in audio.com").Translation() };
592
593 auto topSizer = safenew wxBoxSizer { wxVERTICAL };
594
595 auto headerSizer = safenew wxBoxSizer { wxHORIZONTAL };
596 headerSizer->Add(header, wxSizerFlags().CenterVertical().Left());
597 headerSizer->AddStretchSpacer();
598 headerSizer->Add(
599 searchHeader, wxSizerFlags().CenterVertical().Border(wxRIGHT, 4));
600 headerSizer->Add(mSearchCtrl, wxSizerFlags().CenterVertical());
601
602 topSizer->Add(headerSizer, wxSizerFlags().Expand().Border(wxALL, 16));
603 topSizer->Add(
604 mProjectsTable, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 16));
605
606 auto pageSizer = safenew wxBoxSizer { wxHORIZONTAL };
607 pageSizer->Add(mPageLabel, wxSizerFlags().CenterVertical());
608 pageSizer->AddStretchSpacer();
609 pageSizer->Add(mPrevPageButton, wxSizerFlags().CenterVertical());
610 pageSizer->Add(mNextPageButton, wxSizerFlags().CenterVertical());
611 topSizer->AddSpacer(8);
612 topSizer->Add(
613 pageSizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 16));
614
615 auto buttonsSizer = safenew wxBoxSizer { wxHORIZONTAL };
616 buttonsSizer->Add(mOpenAudioCom, wxSizerFlags().CenterVertical());
617 buttonsSizer->AddStretchSpacer();
618 buttonsSizer->Add(mOpenButton, wxSizerFlags().CenterVertical());
619
620 topSizer->Add(buttonsSizer, wxSizerFlags().Expand().Border(wxALL, 16));
621
622 mOpenButton->Disable();
623 mOpenAudioCom->Disable();
624
625 mSearchTimer = std::make_unique<wxTimer>(this);
626
627 SetSizer(topSizer);
628 Fit();
629 Center();
630
632 BasicUI::CallAfter([this]
634}
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 762 of file ProjectsListDialog.cpp.

763{
765 {
766 mPageLabel->SetLabel({});
767 return;
768 }
769
770 mPageLabel->SetLabel(XO("Page %d of %d")
771 .Format(
774 .Translation());
775}
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 739 of file ProjectsListDialog.cpp.

740{
741 mProjectsTable->Enable(false);
742 mPrevPageButton->Enable(false);
743 mNextPageButton->Enable(false);
744}

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 832 of file ProjectsListDialog.cpp.

833{
834 event.Skip();
835
836 if (!event.Selecting())
837 {
838 mOpenButton->Disable();
839 mOpenAudioCom->Disable();
840 return;
841 }
842
843 mOpenButton->Enable();
844 mOpenAudioCom->Enable();
845
846 const auto topRow = event.GetTopRow();
847 const auto bottomRow = event.GetBottomRow();
848 const auto currentRow = mProjectsTable->GetGridCursorRow();
849
850 if (topRow != bottomRow)
851 {
853 return;
854
855 mInRangeSelection = true;
856 auto switcher = finally([this] { mInRangeSelection = false; });
857
858 mProjectsTable->SelectRow(currentRow == topRow ? bottomRow : topRow);
859 }
860}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnOpen()

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

Definition at line 777 of file ProjectsListDialog.cpp.

778{
779 if (mProjectsTable->GetSelectedRows().empty())
780 return;
781
782 const auto projectInfo = mProjectsTableData->GetSelectedProjectInfo();
783
784 if (projectInfo == nullptr)
785 return;
786
787 if (projectInfo->HeadSnapshot.Synced == 0)
788 {
789 const auto state = CloudSyncService::GetProjectState(projectInfo->Id);
790
792 {
793 const bool hasValidSnapshot =
794 !projectInfo->LastSyncedSnapshotId.empty();
795
796 const auto result =
797 UnsyncedProjectDialog { mProject, hasValidSnapshot }.ShowDialog();
798
800 {
803
804 return;
805 }
806
808 return;
809 }
810 }
811
812 EndModal(wxID_OK);
813
815 [project = mProject, selectedProjectId = projectInfo->Id]
816 { OpenProjectFromCloud(project, selectedProjectId, {}, false); });
817}
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 819 of file ProjectsListDialog.cpp.

820{
821 if (mProjectsTable->GetSelectedRows().empty())
822 return;
823
824 const auto selectedProjectUrl = mProjectsTableData->GetSelectedProjectUrl();
825
826 if (selectedProjectUrl.empty())
827 return;
828
829 BasicUI::OpenInDefaultBrowser(ToWXString(selectedProjectUrl));
830}

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 746 of file ProjectsListDialog.cpp.

747{
748 mProjectsTable->Enable(success);
749
750 mPrevPageButton->Enable(success && mProjectsTableData->HasPrevPage());
751 mNextPageButton->Enable(success && mProjectsTableData->HasNextPage());
752
754
755 mProjectsTable->ForceRefresh();
756
757#if wxUSE_ACCESSIBILITY
758 mAccessible->TableDataUpdated();
759#endif
760}

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 872 of file ProjectsListDialog.cpp.

873{
874 mSearchTimer->StartOnce(500);
875}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnSearchTextSubmitted()

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

Definition at line 877 of file ProjectsListDialog.cpp.

878{
879 if (mSearchTimer->IsRunning())
880 mSearchTimer->Stop();
881
882 const auto searchTerm = mSearchCtrl->GetValue();
883
884 if (searchTerm == mLastSearchValue)
885 return;
886
887 mLastSearchValue = searchTerm;
888
890}

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 862 of file ProjectsListDialog.cpp.

863{
864 event.Skip();
865 mProjectsTable->SelectRow(event.GetRow());
866
867#if wxUSE_ACCESSIBILITY
868 mAccessible->SetSelectedRow(event.GetRow());
869#endif
870}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ SetupHandlers()

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

Definition at line 638 of file ProjectsListDialog.cpp.

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

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: