Attachment list dialog implemented, only lists so far.
Originally committed to SVN as r443.
This commit is contained in:
parent
59364bb272
commit
5103f8a4f0
15 changed files with 260 additions and 6 deletions
|
@ -240,12 +240,13 @@ wxString AssFile::GetString() {
|
|||
// I strongly advice you against touching this function unless you know what you're doing;
|
||||
// even moving things out of order might break ASS parsing - AMZ.
|
||||
//
|
||||
int AssFile::AddLine (wxString data,wxString group,int lasttime,bool &IsSSA) {
|
||||
int AssFile::AddLine (wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outGroup) {
|
||||
// Group
|
||||
AssEntry *entry = NULL;
|
||||
wxString origGroup = group;
|
||||
static wxString keepGroup;
|
||||
if (!keepGroup.IsEmpty()) group = keepGroup;
|
||||
if (outGroup) *outGroup = group;
|
||||
|
||||
// Attachment
|
||||
if (group == _T("[Fonts]") || group == _T("[Graphics]")) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
wxString GetScriptInfo(const wxString key); // Returns the value in a [Script Info] key.
|
||||
void SetScriptInfo(const wxString key,const wxString value); // Sets the value of a [Script Info] key. Adds it if it doesn't exist.
|
||||
void AddComment(const wxString comment); // Adds a ";" comment under [Script Info].
|
||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA);
|
||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outGroup=NULL);
|
||||
|
||||
static void StackPop(); // Pop subs from stack and sets 'top' to it
|
||||
static void StackRedo(); // Redoes action on stack
|
||||
|
|
BIN
core/bitmaps/attach.bmp
Normal file
BIN
core/bitmaps/attach.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -86,6 +86,7 @@ Please visit http://aegisub.net to download latest version
|
|||
- Re-arranged the controls in the subtitle editing area. (AMZ)
|
||||
- Right-clicking on the header of the subtitles grid will now bring up a popup menu that allows you to disable columns. (AMZ)
|
||||
- Saving back to SRT directly (that is, via "save", not "export" or "save as") is now allowed, as long as no data will be lost. (AMZ)
|
||||
- Aegisub now supports file attachments, which are stored decoded (to save memory) and are not part of the undo stack (for the same reason). Previously, they were simply left ignored in the file as unknown lines. (AMZ)
|
||||
|
||||
|
||||
= 1.09 beta - 2006.01.16 ===========================
|
||||
|
|
125
core/dialog_attachments.cpp
Normal file
125
core/dialog_attachments.cpp
Normal file
|
@ -0,0 +1,125 @@
|
|||
// Copyright (c) 2006, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <wx/listctrl.h>
|
||||
#include "dialog_attachments.h"
|
||||
#include "ass_file.h"
|
||||
#include "ass_attachment.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
///////////////
|
||||
// Constructor
|
||||
DialogAttachments::DialogAttachments(wxWindow *parent)
|
||||
: wxDialog(parent,-1,_("Attachment List"),wxDefaultPosition,wxDefaultSize)
|
||||
{
|
||||
// List view
|
||||
listView = new wxListView(this,-1,wxDefaultPosition,wxSize(400,200));
|
||||
listView->InsertColumn(0, _("Attachment name"), wxLIST_FORMAT_LEFT, 200);
|
||||
listView->InsertColumn(1, _("Size"), wxLIST_FORMAT_LEFT, 90);
|
||||
listView->InsertColumn(2, _("Group"), wxLIST_FORMAT_LEFT, 90);
|
||||
|
||||
// Fill list
|
||||
AssAttachment *attach;
|
||||
for (std::list<AssEntry*>::iterator cur = AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) {
|
||||
attach = AssEntry::GetAsAttachment(*cur);
|
||||
if (attach) {
|
||||
// Add item
|
||||
int row = listView->GetItemCount();
|
||||
listView->InsertItem(row,attach->filename);
|
||||
listView->SetItem(row,1,PrettySize(attach->GetData().size()));
|
||||
listView->SetItem(row,2,attach->group);
|
||||
listView->SetItemData(row,(long)attach);
|
||||
}
|
||||
}
|
||||
|
||||
// Buttons sizer
|
||||
wxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
buttonSizer->Add(new wxButton(this,BUTTON_ATTACH_FONT,_("&Attach Font")),3,0,0);
|
||||
buttonSizer->Add(new wxButton(this,BUTTON_EXTRACT,_("E&xtract")),2,0,0);
|
||||
buttonSizer->Add(new wxButton(this,BUTTON_DELETE,_("&Delete")),2,0,0);
|
||||
buttonSizer->Add(new wxButton(this,BUTTON_CLOSE,_("&Close")),2,wxLEFT,5);
|
||||
|
||||
// Main sizer
|
||||
wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
mainSizer->Add(listView,1,wxTOP | wxLEFT | wxRIGHT | wxEXPAND,5);
|
||||
mainSizer->Add(buttonSizer,0,wxALL | wxEXPAND,5);
|
||||
mainSizer->SetSizeHints(this);
|
||||
SetSizer(mainSizer);
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// Destructor
|
||||
DialogAttachments::~DialogAttachments() {
|
||||
}
|
||||
|
||||
|
||||
///////////////
|
||||
// Event table
|
||||
BEGIN_EVENT_TABLE(DialogAttachments,wxDialog)
|
||||
EVT_BUTTON(BUTTON_ATTACH_FONT,DialogAttachments::OnAttachFont)
|
||||
EVT_BUTTON(BUTTON_EXTRACT,DialogAttachments::OnExtract)
|
||||
EVT_BUTTON(BUTTON_DELETE,DialogAttachments::OnDelete)
|
||||
EVT_BUTTON(BUTTON_CLOSE,DialogAttachments::OnClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
///////////////
|
||||
// Attach font
|
||||
void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
|
||||
}
|
||||
|
||||
|
||||
///////////
|
||||
// Extract
|
||||
void DialogAttachments::OnExtract(wxCommandEvent &event) {
|
||||
}
|
||||
|
||||
|
||||
//////////
|
||||
// Delete
|
||||
void DialogAttachments::OnDelete(wxCommandEvent &event) {
|
||||
}
|
||||
|
||||
|
||||
/////////
|
||||
// Close
|
||||
void DialogAttachments::OnClose(wxCommandEvent &event) {
|
||||
EndModal(0);
|
||||
}
|
76
core/dialog_attachments.h
Normal file
76
core/dialog_attachments.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) 2006, Rodrigo Braz Monteiro
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// AEGISUB
|
||||
//
|
||||
// Website: http://aegisub.cellosoft.com
|
||||
// Contact: mailto:zeratul@cellosoft.com
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
class wxListView;
|
||||
|
||||
|
||||
//////////////////////
|
||||
// Attachments window
|
||||
class DialogAttachments : public wxDialog {
|
||||
private:
|
||||
wxListView *listView;
|
||||
|
||||
void OnAttachFont(wxCommandEvent &event);
|
||||
void OnExtract(wxCommandEvent &event);
|
||||
void OnDelete(wxCommandEvent &event);
|
||||
void OnClose(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
DialogAttachments(wxWindow *parent);
|
||||
~DialogAttachments();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
///////
|
||||
// IDs
|
||||
enum {
|
||||
BUTTON_ATTACH_FONT = 1300,
|
||||
BUTTON_EXTRACT,
|
||||
BUTTON_DELETE,
|
||||
BUTTON_CLOSE
|
||||
};
|
|
@ -173,6 +173,7 @@ void FrameMain::InitToolbar () {
|
|||
// Property stuff
|
||||
Toolbar->AddTool(Menu_Tools_Properties,_("Properties"),wxBITMAP(properties_toolbutton),_("Open Properties"));
|
||||
Toolbar->AddTool(Menu_Tools_Styles_Manager,_("Styles Manager"),wxBITMAP(style_toolbutton),_("Open Styles Manager"));
|
||||
Toolbar->AddTool(Menu_Tools_Attachments,_("Attachments"),wxBITMAP(attach_button),_("Open Attachment List"));
|
||||
Toolbar->AddSeparator();
|
||||
|
||||
// Automation
|
||||
|
@ -299,6 +300,7 @@ void FrameMain::InitMenu() {
|
|||
toolMenu = new wxMenu();
|
||||
AppendBitmapMenuItem (toolMenu,Menu_Tools_Properties, _("&Properties..."), _("Open script properties window"),wxBITMAP(properties_toolbutton));
|
||||
AppendBitmapMenuItem (toolMenu,Menu_Tools_Styles_Manager, _("&Styles Manager..."), _("Open styles manager"), wxBITMAP(style_toolbutton));
|
||||
AppendBitmapMenuItem (toolMenu,Menu_Tools_Attachments, _("&Attachments..."), _("Open the attachment list"), wxBITMAP(attach_button));
|
||||
toolMenu->AppendSeparator();
|
||||
AppendBitmapMenuItem (toolMenu,Menu_Tools_Automation, _("&Automation..."),_("Open automation manager"), wxBITMAP(automation_toolbutton));
|
||||
toolMenu->AppendSeparator();
|
||||
|
|
|
@ -182,6 +182,7 @@ private:
|
|||
void OnShift (wxCommandEvent &event);
|
||||
void OnOpenProperties (wxCommandEvent &event);
|
||||
void OnOpenStylesManager (wxCommandEvent &event);
|
||||
void OnOpenAttachments (wxCommandEvent &event);
|
||||
void OnOpenTranslation (wxCommandEvent &event);
|
||||
void OnOpenSpellCheck (wxCommandEvent &event);
|
||||
void OnOpenFontsCollector (wxCommandEvent &event);
|
||||
|
@ -312,6 +313,7 @@ enum {
|
|||
|
||||
Menu_Tools_Properties,
|
||||
Menu_Tools_Styles_Manager,
|
||||
Menu_Tools_Attachments,
|
||||
Menu_Tools_Translation,
|
||||
Menu_Tools_SpellCheck,
|
||||
Menu_Tools_Fonts_Collector,
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "subs_edit_box.h"
|
||||
#include "options.h"
|
||||
#include "dialog_properties.h"
|
||||
#include "dialog_attachments.h"
|
||||
#include "main.h"
|
||||
#include "fonts_collector.h"
|
||||
#include "about.h"
|
||||
|
@ -166,6 +167,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
|
|||
|
||||
EVT_MENU(Menu_Tools_Properties, FrameMain::OnOpenProperties)
|
||||
EVT_MENU(Menu_Tools_Styles_Manager, FrameMain::OnOpenStylesManager)
|
||||
EVT_MENU(Menu_Tools_Attachments, FrameMain::OnOpenAttachments)
|
||||
EVT_MENU(Menu_Tools_Translation, FrameMain::OnOpenTranslation)
|
||||
EVT_MENU(Menu_Tools_SpellCheck, FrameMain::OnOpenSpellCheck)
|
||||
EVT_MENU(Menu_Tools_Fonts_Collector, FrameMain::OnOpenFontsCollector)
|
||||
|
@ -700,6 +702,15 @@ void FrameMain::OnOpenStylesManager(wxCommandEvent& WXUNUSED(event)) {
|
|||
}
|
||||
|
||||
|
||||
////////////////////
|
||||
// Open attachments
|
||||
void FrameMain::OnOpenAttachments(wxCommandEvent& WXUNUSED(event)) {
|
||||
videoBox->videoDisplay->Stop();
|
||||
DialogAttachments attachments(this);
|
||||
attachments.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// Open translation assistant
|
||||
void FrameMain::OnOpenTranslation(wxCommandEvent& WXUNUSED(event)) {
|
||||
|
|
|
@ -51,6 +51,7 @@ zoom_in_button BITMAP "bitmaps/zoom_in.bmp"
|
|||
zoom_out_button BITMAP "bitmaps/zoom_out.bmp"
|
||||
font_collector_button BITMAP "bitmaps/fontcollect.bmp"
|
||||
hotkeys_button BITMAP "bitmaps/hotkeys.bmp"
|
||||
attach_button BITMAP "bitmaps/attach.bmp"
|
||||
substart_to_video BITMAP "bitmaps/substart_to_video.bmp"
|
||||
subend_to_video BITMAP "bitmaps/subend_to_video.bmp"
|
||||
video_to_substart BITMAP "bitmaps/video_to_substart.bmp"
|
||||
|
|
|
@ -111,8 +111,8 @@ void SubtitleFormat::LoadDefault() {
|
|||
|
||||
////////////
|
||||
// Add line
|
||||
int SubtitleFormat::AddLine(wxString data,wxString group,int lasttime,bool &IsSSA) {
|
||||
return assFile->AddLine(data,group,lasttime,IsSSA);
|
||||
int SubtitleFormat::AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup) {
|
||||
return assFile->AddLine(data,group,lasttime,IsSSA,outgroup);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ protected:
|
|||
void Clear();
|
||||
void LoadDefault();
|
||||
AssFile *GetAssFile() { return assFile; }
|
||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA);
|
||||
int AddLine(wxString data,wxString group,int lasttime,bool &IsSSA,wxString *outgroup=NULL);
|
||||
|
||||
public:
|
||||
SubtitleFormat();
|
||||
|
|
|
@ -78,7 +78,7 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) {
|
|||
|
||||
// Add line
|
||||
try {
|
||||
lasttime = AddLine(wxbuffer,curgroup,lasttime,IsSSA);
|
||||
lasttime = AddLine(wxbuffer,curgroup,lasttime,IsSSA,&curgroup);
|
||||
}
|
||||
catch (const wchar_t *err) {
|
||||
Clear();
|
||||
|
|
|
@ -144,3 +144,37 @@ wxString FloatToString(double value) {
|
|||
wxString IntegerToString(int value) {
|
||||
return wxString::Format(_T("%i"),value);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Pretty reading of size
|
||||
// There shall be no kiB, MiB stuff here
|
||||
wxString PrettySize(int bytes) {
|
||||
// Suffixes
|
||||
wxArrayString suffix;
|
||||
suffix.Add(_T(""));
|
||||
suffix.Add(_T(" kB"));
|
||||
suffix.Add(_T(" MB"));
|
||||
suffix.Add(_T(" GB"));
|
||||
suffix.Add(_T(" TB"));
|
||||
suffix.Add(_T(" PB"));
|
||||
|
||||
// Set size
|
||||
int i = 0;
|
||||
double size = bytes;
|
||||
while (size > 1024) {
|
||||
size = size / 1024.0;
|
||||
i++;
|
||||
if (i == 6) {
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set number of decimal places
|
||||
wxString final;
|
||||
if (size < 10) final = wxString::Format(_T("%.2f"),size);
|
||||
else if (size < 100) final = wxString::Format(_T("%.1f"),size);
|
||||
else final = wxString::Format(_T("%.0f"),size);
|
||||
return final + suffix[i];
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ wxString DecodeRelativePath(wxString path,wxString reference);
|
|||
wxString PrettyFloat(wxString src);
|
||||
wxString FloatToString(double value);
|
||||
wxString IntegerToString(int value);
|
||||
wxString PrettySize(int bytes);
|
||||
|
||||
|
||||
//////////
|
||||
|
|
Loading…
Reference in a new issue