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

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

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

760{
762 {
763 mPageLabel->SetLabel({});
764 return;
765 }
766
767 mPageLabel->SetLabel(XO("Page %d of %d")
768 .Format(
771 .Translation());
772}
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 736 of file ProjectsListDialog.cpp.

737{
738 mProjectsTable->Enable(false);
739 mPrevPageButton->Enable(false);
740 mNextPageButton->Enable(false);
741}

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

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

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnOpen()

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

Definition at line 774 of file ProjectsListDialog.cpp.

775{
776 if (mProjectsTable->GetSelectedRows().empty())
777 return;
778
779 const auto projectInfo = mProjectsTableData->GetSelectedProjectInfo();
780
781 if (projectInfo == nullptr)
782 return;
783
784 if (projectInfo->HeadSnapshot.Synced == 0)
785 {
786 const auto state = CloudSyncService::GetProjectState(projectInfo->Id);
787
789 {
790 const bool hasValidSnapshot =
791 !projectInfo->LastSyncedSnapshotId.empty();
792
793 const auto result =
794 UnsyncedProjectDialog { mProject, hasValidSnapshot }.ShowDialog();
795
797 {
800
801 return;
802 }
803
805 return;
806 }
807 }
808
809 EndModal(wxID_OK);
810
812 [project = mProject, selectedProjectId = projectInfo->Id]
813 { OpenProjectFromCloud(project, selectedProjectId, {}, false); });
814}
static ProjectState GetProjectState(const std::string &projectId)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Definition: BasicUI.cpp:245
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 816 of file ProjectsListDialog.cpp.

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

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

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

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

870{
871 mSearchTimer->StartOnce(500);
872}

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ OnSearchTextSubmitted()

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

Definition at line 874 of file ProjectsListDialog.cpp.

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

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

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

Referenced by SetupHandlers().

Here is the caller graph for this function:

◆ SetupHandlers()

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

Definition at line 635 of file ProjectsListDialog.cpp.

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

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: