21#include <wx/listctrl.h>
28#include "../widgets/Grid.h"
30#define EXTIMPORT_MIME_SUPPORT 0
63:
PrefsPanel(parent, winid,
XO("Extended Import")), RuleTable(NULL),
64 PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
65 mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1)
84 return XO(
"Preferences for ExtImport");
89 return "Extended_Import_Preferences";
112 S.TieCheckBox(
XXO(
"A&ttempt to use filter in OpenFile dialog first"),
113 {
wxT(
"/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
115 S.StartStatic(
XO(
"Rules to choose import filters"), 1);
117 S.SetSizerProportion(1);
118 S.StartHorizontalLay (wxEXPAND, 1);
120 bool fillRuleTable =
false;
126#if EXTIMPORT_MIME_SUPPORT
127 RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
129 RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
133 RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
134 RuleTable->SetColLabelValue (0,
_(
"File extensions"));
135#if EXTIMPORT_MIME_SUPPORT
136 RuleTable->SetColLabelValue (1,
_(
"Mime-types"));
139 RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
150 dragtarget1->SetPrefs (
this);
153 fillRuleTable =
true;
155 S.Position(wxEXPAND | wxALL)
159 { {
XO(
"Importer order"), wxLIST_FORMAT_LEFT,
160 wxLIST_AUTOSIZE_USEHEADER } },
161 wxLC_REPORT | wxLC_SINGLE_SEL
172 dragtarget2->SetPrefs (
this);
177 for (
const auto &item : items)
187 S.EndHorizontalLay();
188 S.StartHorizontalLay (wxSHRINK, 0);
192 XXO(
"Move rule &down"));
194 XXO(
"Move f&ilter up"));
196 XXO(
"Move &filter down"));
198 S.EndHorizontalLay();
199 S.StartHorizontalLay (wxSHRINK, 0);
204 S.EndHorizontalLay();
211 SetMinSize(GetSize());
238 for (
int i = 0; i < 1; i++)
269 if (d == -1 || d2 == -1)
301 if (code != WXK_UP && code != WXK_DOWN)
305 long itemIndex2 = -1;
306 itemIndex =
PluginList->GetNextItem(itemIndex,
307 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
317 if (code == WXK_UP && itemIndex == 0)
319 else if (code == WXK_DOWN && itemIndex ==
PluginList->GetItemCount() - 1)
324 itemIndex2 = itemIndex - 1;
326 else if (code == WXK_DOWN)
328 itemIndex2 = itemIndex + 1;
333 PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
334 PluginList->SetItemState (itemIndex2, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
335 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
363 auto &t1 = items[row1];
364 auto &t2 = items[row2];
367 for (
int i = 0; i <
RuleTable->GetNumberCols(); i++)
377 wxDropSource dragSource(
this);
383 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
399 int mods =
event.GetModifiers();
400 if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
401 event.GetKeyCode() == WXK_DOWN))
413 int selrow =
RuleTable->GetGridCursorRow ();
415 if (keycode == WXK_UP)
423 else if (keycode == WXK_DOWN)
425 if (selrow ==
RuleTable->GetNumberRows() - 1)
440 toprow =
event.GetRow();
454 toprow =
event.GetTopRow();
469 if (toprow < 0 || toprow >= (
int)items.size())
480 for (
int i = 0; i < fcount; i++)
491 item->
filter_objects[i]->GetPluginFormatDescription().Translation());
501 PluginList->InsertItem (fcount,
_(
"Unused filters:"));
507 info.SetStateMask (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
508 info.SetState (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
509 info.SetMask (wxLIST_MASK_STATE);
511 PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
517 int row =
event.GetRow();
518 int col =
event.GetCol();
523 wxString val =
RuleTable->GetCellValue (row, col);
524 int fixSpaces = wxNO;
525 bool askedAboutSpaces =
false;
527 wxString delims(
wxT(
":"));
539 for (
size_t i = 0; i < vals.size(); i++)
542 wxString trimmed = vals[i];
543 trimmed.Trim().Trim(
false);
544 if (trimmed != vals[i])
546 if (!askedAboutSpaces)
550"There are space characters (spaces, newlines, tabs or linefeeds) in one of \
551the items. They are likely to break the pattern matching. Unless you know \
552what you are doing, it is recommended to trim spaces. Do you want \
553Audacity to trim spaces for you?"),
554 XO(
"Spaces detected"),
556 askedAboutSpaces =
true;
558 if (fixSpaces != wxYES)
577 if (fixSpaces == wxYES)
579 wxString vals_as_string;
580 for (
size_t i = 0; i < vals.size(); i++)
583 vals_as_string.Append (
wxT(
":"));
584 vals_as_string.Append (vals[i]);
586 RuleTable->SetCellValue (row, col, vals_as_string);
594 wxString extensions, mime_types;
598 for (
unsigned int i = 1; i < item->
extensions.size(); i++)
600 extensions.Append (
wxT(
":"));
607 for (
unsigned int i = 1; i < item->
mime_types.size(); i++)
609 mime_types.Append (
wxT(
":"));
615 RuleTable->SetCellValue (index, 0, extensions);
616#if EXTIMPORT_MIME_SUPPORT
617 RuleTable->SetCellValue (index, 1, mime_types);
626 auto item = uitem.get();
627 items.push_back(std::move(uitem));
642 XO(
"Do you really want to delete selected rule?"),
643 XO(
"Rule deletion confirmation"),
677 wxListEvent fakeevent(wxEVT_COMMAND_LIST_KEY_DOWN,
EIPPluginList);
678 fakeevent.SetEventObject(
this);
679 fakeevent.m_code = keycode;
681 GetEventHandler()->ProcessEvent (fakeevent);
698 int row =
event.GetRow();
702 wxDropSource dragSource(
this);
706 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
722 : wxDropTarget(dataObject)
742#if defined(__WXMSW__)
751 long count = list->GetItemCount();
753 for (
long i = 0; i < count; i++)
755 if (list->GetItemRect (i, r))
757 if (r.Contains (x, y))
773 if (RuleTable->YToRow(
774 RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y) == wxNOT_FOUND)
779#if defined(__WXMSW__)
783 long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
799 wxDragResult WXUNUSED(def))
808 row = RuleTable->YToRow(RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y);
809 if (row == wxNOT_FOUND)
813 int cRow = RuleTable->GetGridCursorRow ();
817 RuleTable->SetGridCursor (row, 0);
818 RuleTable->SelectRow (row);
823#if defined(__WXMSW__)
827 long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
833 selected = PluginList->GetNextItem(selected,
834 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
838 if (item != selected)
841 PluginList->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
842 PluginList->SetItemState (item, wxLIST_STATE_SELECTED,
843 wxLIST_STATE_SELECTED);
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
long wxCustomFindItem(wxListCtrl *list, int x, int y)
#define EXT_IMPORT_PREFS_PLUGIN_SYMBOL
XXO("&Cut/Copy/Paste Toolbar")
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
std::vector< ImportPlugin * > filter_objects
ExtImportPrefsDropTarget(wxDataObject *dataObject=nullptr)
void SetPrefs(ExtImportPrefs *prefs)
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
~ExtImportPrefsDropTarget()
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
bool OnDrop(wxCoord x, wxCoord y)
A PrefsPanel used to select extended import filter options.
wxTextDataObject * dragtext2
void OnAddRule(wxCommandEvent &event)
wxTextDataObject * dragtext1
wxButton * MoveFilterDown
void OnRuleTableCellClick(wxGridEvent &event)
void OnFilterMoveDown(wxCommandEvent &event)
bool DoOnPluginKeyDown(int code)
void DoOnRuleTableKeyDown(int keycode)
TranslatableString GetDescription() const override
wxListCtrl * GetPluginList()
wxWindow * GetDragFocus()
void OnDelRule(wxCommandEvent &event)
void SwapPluginRows(int row1, int row2)
void OnRuleMoveUp(wxCommandEvent &event)
void OnRuleTableSelect(wxGridEvent &event)
void Populate()
Creates the dialog and its contents.
void PopulateOrExchange(ShuttleGui &S) override
void OnRuleTableKeyDown(wxKeyEvent &event)
void OnShow(wxShowEvent &event)
void OnPluginKeyDown(wxListEvent &event)
bool mStopRecursiveSelection
void OnPluginBeginDrag(wxListEvent &event)
void FakeOnPluginKeyDown(int keycode)
void OnRuleTableEdit(wxGridEvent &event)
void DoOnRuleTableSelect(int toprow)
void AddItemToTable(int index, const ExtImportItem *item)
void OnRuleTableSelectRange(wxGridRangeSelectEvent &event)
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
void SwapRows(int row1, int row2)
void OnFilterMoveUp(wxCommandEvent &event)
ComponentInterfaceSymbol GetSymbol() const override
void OnRuleMoveDown(wxCommandEvent &event)
static FormatterContext EmptyContext()
Supplies an accessible grid based on wxGrid.
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
ExtImportItems & GetImportItems()
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
PrefsPanel::Registration sAttachment
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)