From caea5872b4ca9585c9153995127b2bf111750171 Mon Sep 17 00:00:00 2001 From: Dan Donovan Date: Tue, 6 Feb 2007 03:25:14 +0000 Subject: [PATCH] Added copy+paste to style manager, ctrl+c/v only (so far, anyway) Originally committed to SVN as r925. --- aegisub/changelog.txt | 4 +- aegisub/dialog_style_manager.cpp | 94 ++++++++++++++++++++++++++++++++ aegisub/dialog_style_manager.h | 4 ++ 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/aegisub/changelog.txt b/aegisub/changelog.txt index 2d5220fab..0f6af2b01 100644 --- a/aegisub/changelog.txt +++ b/aegisub/changelog.txt @@ -101,7 +101,7 @@ Please visit http://aegisub.net to download latest version - Made the video display detachable. (AMZ) - Undo and redo now have descriptions. (Dansolo) - The three different "Recombine Lines" were merged into one that autodetects needed changes, and also supports two new cases. (AMZ) - +- Added shortcut keys (escape to close and delete to delete a style, plus ctrl+c/v for copy/paste) to style manager. (Dansolo) = 1.10 beta - 2006.08.07 =========================== @@ -201,7 +201,7 @@ Please visit http://aegisub.net to download latest version - Implemented sorting of subtitles by start time. (AMZ) - Recovered subtitle files are now saved in their own subfolder (customizeable in config.dat). (AMZ) - Fixed crash with changing font properties via the subtitle edit box when there was a \fs override tag earlier in the line. (AMZ) -- Added shortcut keys (escape to close and delete to delete a style) to style manager. (Dansolo) + = 1.09 beta - 2006.01.16 =========================== diff --git a/aegisub/dialog_style_manager.cpp b/aegisub/dialog_style_manager.cpp index 3e7d13ce9..bd7a1c12a 100644 --- a/aegisub/dialog_style_manager.cpp +++ b/aegisub/dialog_style_manager.cpp @@ -619,6 +619,74 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &event) { } +////////////////////// +// Copy to clipboard +void DialogStyleManager::CopyToClipboard (wxListBox *list, std::vector v) { + wxString data = _T(""); + AssStyle *s; + wxArrayInt selections; + list->GetSelections(selections); + + for(int unsigned i=0;iUpdateData(); + data += s->GetEntryData(); + } + + if (wxTheClipboard->Open()) { + wxTheClipboard->SetData(new wxTextDataObject(data)); + wxTheClipboard->Close(); + } +} +//////////////////////// +// Paste from clipboard +void DialogStyleManager::PasteToCurrent() { + wxString data = _T(""); + + if (wxTheClipboard->Open()) { + if (wxTheClipboard->IsSupported(wxDF_TEXT)) { + wxTextDataObject rawdata; + wxTheClipboard->GetData(rawdata); + data = rawdata.GetText(); + } + wxTheClipboard->Close(); + } + + wxStringTokenizer st(data,_T('\n')); + while (st.HasMoreTokens()) { + AssStyle *s = new AssStyle(st.GetNextToken().Trim(true)); + if (s->Valid) { + AssFile::top->InsertStyle(s); + LoadCurrentStyles(AssFile::top); + } + grid->ass->FlagAsModified(_("style paste")); + grid->CommitChanges(); + } +} +void DialogStyleManager::PasteToStorage() { + wxString data = _T(""); + + if (wxTheClipboard->Open()) { + if (wxTheClipboard->IsSupported(wxDF_TEXT)) { + wxTextDataObject rawdata; + wxTheClipboard->GetData(rawdata); + data = rawdata.GetText(); + } + wxTheClipboard->Close(); + } + + wxStringTokenizer st(data,_T('\n')); + while (st.HasMoreTokens()) { + AssStyle *s = new AssStyle(st.GetNextToken().Trim(true)); + if (s->Valid) { + Store.style.push_back(s); + Store.Save(CatalogList->GetString(CatalogList->GetSelection())); + } + LoadStorageStyles(); + StorageList->SetStringSelection(s->name); + } +} /////////////// // Storage new void DialogStyleManager::OnStorageNew (wxCommandEvent &event) { @@ -1017,6 +1085,32 @@ void DialogStyleManager::OnKeyDown(wxKeyEvent &event) { OnCurrentDelete(evt); } break; + + case 'C' : + case 'c' : + if (event.ControlDown()) { + if (wxWindow::FindFocus()==CurrentList) { + CopyToClipboard(CurrentList,styleMap); + } + else if (wxWindow::FindFocus()==StorageList) { + CopyToClipboard(StorageList,styleStorageMap); + } + } + break; + + case 'V' : + case 'v' : + if (event.ControlDown()) { + if (wxWindow::FindFocus()==CurrentList) { + PasteToCurrent(); + } + else if (wxWindow::FindFocus()==StorageList) { + PasteToStorage(); + } + } + + break; + } } ////////////////// diff --git a/aegisub/dialog_style_manager.h b/aegisub/dialog_style_manager.h index b2ca794ee..8063db04f 100644 --- a/aegisub/dialog_style_manager.h +++ b/aegisub/dialog_style_manager.h @@ -130,6 +130,10 @@ public: void OnCurrentDelete (wxCommandEvent &event); void OnCurrentImport (wxCommandEvent &event); void OnKeyDown (wxKeyEvent &event); + void CopyToClipboard (wxListBox *list, std::vector v); + void PasteToCurrent(); + void PasteToStorage(); + DECLARE_EVENT_TABLE() };