1
0
mirror of https://github.com/odrling/Aegisub synced 2025-04-11 22:56:02 +02:00

General fixes to fonts collector, and made font attachment work. Collecting to archives still doesn't work, and there are a few destination-box related issues.

Originally committed to SVN as r1271.
This commit is contained in:
Rodrigo Braz Monteiro 2007-06-20 06:29:20 +00:00
parent fa293466d6
commit 6319bcca7b
2 changed files with 44 additions and 18 deletions

View File

@ -94,6 +94,7 @@ DialogFontsCollector::DialogFontsCollector(wxWindow *parent)
choices.Add(_T("Copy fonts to zipped archive")); choices.Add(_T("Copy fonts to zipped archive"));
choices.Add(_T("Attach fonts to current subtitles")); choices.Add(_T("Attach fonts to current subtitles"));
CollectAction = new wxRadioBox(this,RADIO_BOX,_T("Action"),wxDefaultPosition,wxDefaultSize,choices,1); CollectAction = new wxRadioBox(this,RADIO_BOX,_T("Action"),wxDefaultPosition,wxDefaultSize,choices,1);
CollectAction->SetSelection(Options.AsInt(_T("Fonts Collector Action")));
// Log box // Log box
LogBox = new wxStyledTextCtrl(this,-1,wxDefaultPosition,wxSize(300,210),0,_T("")); LogBox = new wxStyledTextCtrl(this,-1,wxDefaultPosition,wxSize(300,210),0,_T(""));
@ -184,8 +185,9 @@ void DialogFontsCollector::OnStart(wxCommandEvent &event) {
dest = _T("?script"); dest = _T("?script");
} }
Options.SetText(_T("Fonts Collector Destination"),dest); Options.SetText(_T("Fonts Collector Destination"),dest);
Options.Save();
} }
Options.SetInt(_T("Fonts Collector Action"),action);
Options.Save();
// Set buttons // Set buttons
StartButton->Enable(false); StartButton->Enable(false);
@ -237,17 +239,22 @@ void DialogFontsCollector::OnRadio(wxCommandEvent &event) {
/////////////////// ///////////////////
// Update controls // Update controls
void DialogFontsCollector::Update(int value) { void DialogFontsCollector::Update(int value) {
// Enable buttons
CloseButton->Enable(true);
StartButton->Enable(true);
CollectAction->Enable(true);
// Get value if -1 // Get value if -1
if (value == -1) { if (value == -1) {
value = CollectAction->GetSelection(); value = CollectAction->GetSelection();
} }
// Check // Check or attach
if (value == 0) { if (value == 0 || value == 3) {
DestBox->Enable(false); DestBox->Enable(false);
BrowseButton->Enable(false); BrowseButton->Enable(false);
DestLabel->SetLabel(_T("N/A\n"));
DestLabel->Enable(false); DestLabel->Enable(false);
DestLabel->SetLabel(_T("N/A\n"));
} }
// Collect to folder // Collect to folder
@ -278,14 +285,6 @@ void DialogFontsCollector::Update(int value) {
DestLabel->Enable(true); DestLabel->Enable(true);
DestLabel->SetLabel(_("Enter the name of the destination zip file to collect the fonts to.\nIf a folder is entered, a default name will be used.")); DestLabel->SetLabel(_("Enter the name of the destination zip file to collect the fonts to.\nIf a folder is entered, a default name will be used."));
} }
// Attach
else if (value == 3) {
DestBox->Enable(false);
BrowseButton->Enable(false);
DestLabel->Enable(false);
DestLabel->SetLabel(_T("N/A\n"));
}
} }
@ -313,7 +312,9 @@ FontsCollectorThread::FontsCollectorThread(AssFile *_subs,wxString _destination,
wxThread::ExitCode FontsCollectorThread::Entry() { wxThread::ExitCode FontsCollectorThread::Entry() {
// Collect // Collect
Collect(); Collect();
collector->CloseButton->Enable(true);
// After done, restore status
collector->Update();
// Return // Return
if (IsDetached()) Delete(); if (IsDetached()) Delete();
@ -324,6 +325,13 @@ wxThread::ExitCode FontsCollectorThread::Entry() {
/////////// ///////////
// Collect // Collect
void FontsCollectorThread::Collect() { void FontsCollectorThread::Collect() {
// Clear log box
wxMutexGuiEnter();
collector->LogBox->SetReadOnly(false);
collector->LogBox->ClearAll();
collector->LogBox->SetReadOnly(true);
wxMutexGuiLeave();
// Set destination folder // Set destination folder
int oper = collector->CollectAction->GetSelection(); int oper = collector->CollectAction->GetSelection();
destFolder = collector->DestBox->GetValue(); destFolder = collector->DestBox->GetValue();
@ -368,14 +376,27 @@ void FontsCollectorThread::Collect() {
case 3: AppendText(_("Attaching fonts to file...\n")); break; case 3: AppendText(_("Attaching fonts to file...\n")); break;
} }
bool ok = true; bool ok = true;
bool someOk = false;
for (size_t i=0;i<fonts.Count();i++) { for (size_t i=0;i<fonts.Count();i++) {
if (!ProcessFont(fonts[i])) ok = false; bool result = ProcessFont(fonts[i]);
if (result) someOk = true;
if (!result) ok = false;
} }
// Final result // Final result
if (ok) { if (ok) {
if (oper == 0) AppendText(_("Done. All fonts found."),1); if (oper == 0) AppendText(_("Done. All fonts found."),1);
else AppendText(_("Done. All fonts copied."),1); else {
AppendText(_("Done. All fonts copied."),1);
// Modify file if it was attaching
if (oper == 3 && someOk) {
wxMutexGuiEnter();
subs->FlagAsModified(_("font attachment"));
collector->main->SubsBox->CommitChanges();
wxMutexGuiLeave();
}
}
} }
else { else {
if (oper == 0) AppendText(_("Done. Some fonts could not be found."),2); if (oper == 0) AppendText(_("Done. Some fonts could not be found."),2);
@ -457,7 +478,13 @@ bool FontsCollectorThread::ArchiveFont(wxString filename) {
/////////////// ///////////////
// Attach font // Attach font
bool FontsCollectorThread::AttachFont(wxString filename) { bool FontsCollectorThread::AttachFont(wxString filename) {
return false; try {
subs->InsertAttachment(filename);
}
catch (...) {
return false;
}
return true;
} }

View File

@ -314,8 +314,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults) {
SetBool(_T("Paste Over #9"),true); SetBool(_T("Paste Over #9"),true);
SetText(_T("Fonts Collector Destination"),_T("?script")); SetText(_T("Fonts Collector Destination"),_T("?script"));
SetBool(_T("Fonts Collector Attachment"),0); SetInt(_T("Fonts Collector Action"),0);
SetBool(_T("Fonts Collector Archive"),1);
SetInt(_T("Audio Display Height"),100); SetInt(_T("Audio Display Height"),100);
SetBool(_T("Audio Spectrum"),false); SetBool(_T("Audio Spectrum"),false);