forked from mia/Aegisub
Extract some duplicated wxFileSelector code to a helper function
This commit is contained in:
parent
bc7229782c
commit
ca9be4caef
9 changed files with 71 additions and 94 deletions
|
@ -47,10 +47,9 @@
|
||||||
#include "../include/aegisub/context.h"
|
#include "../include/aegisub/context.h"
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
#include "../selection_controller.h"
|
#include "../selection_controller.h"
|
||||||
|
#include "../utils.h"
|
||||||
#include "../video_context.h"
|
#include "../video_context.h"
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -87,16 +86,14 @@ struct audio_open : public Command {
|
||||||
STR_HELP("Opens an audio file")
|
STR_HELP("Opens an audio file")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
try {
|
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Audio")->GetString());
|
|
||||||
wxString str = _("Audio Formats") + " (*.aac,*.ac3,*.ape,*.dts,*.flac,*.m4a,*.mka,*.mp3,*.mp4,*.ogg,*.w64,*.wav,*.wma)|*.aac;*.ac3;*.ape;*.dts;*.flac;*.m4a;*.mka;*.mp3;*.mp4;*.ogg;*.w64;*.wav;*.wma|"
|
wxString str = _("Audio Formats") + " (*.aac,*.ac3,*.ape,*.dts,*.flac,*.m4a,*.mka,*.mp3,*.mp4,*.ogg,*.w64,*.wav,*.wma)|*.aac;*.ac3;*.ape;*.dts;*.flac;*.m4a;*.mka;*.mp3;*.mp4;*.ogg;*.w64;*.wav;*.wma|"
|
||||||
+ _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts|"
|
+ _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts|"
|
||||||
+ _("All Files") + " (*.*)|*.*";
|
+ _("All Files") + " (*.*)|*.*";
|
||||||
agi::fs::path filename = wxFileSelector(_("Open Audio File"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
auto filename = OpenFileSelector(_("Open Audio File"), "Path/Last/Audio", "", "", str, c->parent);
|
||||||
if (!filename.empty()) {
|
if (filename.empty()) return;
|
||||||
|
|
||||||
|
try {
|
||||||
c->audioController->OpenAudio(filename);
|
c->audioController->OpenAudio(filename);
|
||||||
OPT_SET("Path/Last/Audio")->SetString(filename.parent_path().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (agi::UserCancelException const&) { }
|
catch (agi::UserCancelException const&) { }
|
||||||
catch (agi::Exception const& e) {
|
catch (agi::Exception const& e) {
|
||||||
|
@ -224,7 +221,7 @@ struct audio_save_clip : public Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
c->audioController->SaveClip(
|
c->audioController->SaveClip(
|
||||||
from_wx(wxFileSelector(_("Save audio clip"), "", "", "wav", "", wxFD_SAVE|wxFD_OVERWRITE_PROMPT, c->parent)),
|
SaveFileSelector(_("Save audio clip"), "", "", "wav", "", c->parent),
|
||||||
TimeRange(start, end));
|
TimeRange(start, end));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,11 +40,9 @@
|
||||||
|
|
||||||
#include "../include/aegisub/context.h"
|
#include "../include/aegisub/context.h"
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
|
#include "../utils.h"
|
||||||
#include "../video_context.h"
|
#include "../video_context.h"
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <wx/filedlg.h>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using cmd::Command;
|
using cmd::Command;
|
||||||
/// @defgroup cmd-keyframed Keyframe commands.
|
/// @defgroup cmd-keyframed Keyframe commands.
|
||||||
|
@ -67,7 +65,6 @@ struct keyframe_close : public Command {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Opens a keyframe list file.
|
/// Opens a keyframe list file.
|
||||||
struct keyframe_open : public Command {
|
struct keyframe_open : public Command {
|
||||||
CMD_NAME("keyframe/open")
|
CMD_NAME("keyframe/open")
|
||||||
|
@ -76,16 +73,13 @@ struct keyframe_open : public Command {
|
||||||
STR_HELP("Opens a keyframe list file")
|
STR_HELP("Opens a keyframe list file")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
agi::fs::path filename = wxFileSelector(
|
auto filename = OpenFileSelector(
|
||||||
_("Open keyframes file"),
|
_("Open keyframes file"),
|
||||||
to_wx(OPT_GET("Path/Last/Keyframes")->GetString()),
|
"Path/Last/Keyframes", "" ,".txt",
|
||||||
""
|
|
||||||
,".txt",
|
|
||||||
_("All Supported Formats") + " (*.txt, *.pass, *.stats, *.log)|*.txt;*.pass;*.stats;*.log|" + _("All Files") + " (*.*)|*.*",
|
_("All Supported Formats") + " (*.txt, *.pass, *.stats, *.log)|*.txt;*.pass;*.stats;*.log|" + _("All Files") + " (*.*)|*.*",
|
||||||
wxFD_FILE_MUST_EXIST | wxFD_OPEN);
|
c->parent);
|
||||||
|
|
||||||
if (filename.empty()) return;
|
if (!filename.empty())
|
||||||
OPT_SET("Path/Last/Keyframes")->SetString(filename.parent_path().string());
|
|
||||||
c->videoController->LoadKeyframes(filename);
|
c->videoController->LoadKeyframes(filename);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -103,10 +97,8 @@ struct keyframe_save : public Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
std::string path = OPT_GET("Path/Last/Keyframes")->GetString();
|
auto filename = SaveFileSelector(_("Save keyframes file"), "Path/Last/Keyframes", "", "*.key.txt", "Text files (*.txt)|*.txt", c->parent);
|
||||||
agi::fs::path filename = wxFileSelector(_("Save keyframes file"),to_wx(path),"","*.key.txt","Text files (*.txt)|*.txt",wxFD_OVERWRITE_PROMPT | wxFD_SAVE);
|
if (!filename.empty())
|
||||||
if (filename.empty()) return;
|
|
||||||
OPT_SET("Path/Last/Keyframes")->SetString(filename.parent_path().string());
|
|
||||||
c->videoController->SaveKeyframes(filename);
|
c->videoController->SaveKeyframes(filename);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
#include "../video_context.h"
|
#include "../video_context.h"
|
||||||
|
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/choicdlg.h>
|
#include <wx/choicdlg.h>
|
||||||
|
|
||||||
|
@ -261,13 +260,7 @@ struct subtitle_open : public Command {
|
||||||
STR_HELP("Opens a subtitles file")
|
STR_HELP("Opens a subtitles file")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
std::string filename = from_wx(wxFileSelector(
|
auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent);
|
||||||
_("Open subtitles file"),
|
|
||||||
to_wx(OPT_GET("Path/Last/Subtitles")->GetString()),
|
|
||||||
"","",
|
|
||||||
to_wx(SubtitleFormat::GetWildcards(0)),
|
|
||||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST));
|
|
||||||
|
|
||||||
if (!filename.empty())
|
if (!filename.empty())
|
||||||
wxGetApp().frame->LoadSubtitles(filename);
|
wxGetApp().frame->LoadSubtitles(filename);
|
||||||
}
|
}
|
||||||
|
@ -294,14 +287,13 @@ struct subtitle_open_charset : public Command {
|
||||||
STR_HELP("Opens a subtitles file with a specific charset")
|
STR_HELP("Opens a subtitles file with a specific charset")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Subtitles")->GetString());
|
auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent);
|
||||||
wxString filename = wxFileSelector(_("Open subtitles file"),path,"","",to_wx(SubtitleFormat::GetWildcards(0)),wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
|
||||||
if (filename.empty()) return;
|
if (filename.empty()) return;
|
||||||
|
|
||||||
wxString charset = wxGetSingleChoice(_("Choose charset code:"), _("Charset"), agi::charset::GetEncodingsList<wxArrayString>(), c->parent, -1, -1, true, 250, 200);
|
wxString charset = wxGetSingleChoice(_("Choose charset code:"), _("Charset"), agi::charset::GetEncodingsList<wxArrayString>(), c->parent, -1, -1, true, 250, 200);
|
||||||
if (charset.empty()) return;
|
if (charset.empty()) return;
|
||||||
|
|
||||||
wxGetApp().frame->LoadSubtitles(from_wx(filename), from_wx(charset));
|
wxGetApp().frame->LoadSubtitles(filename, from_wx(charset));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -339,11 +331,9 @@ struct subtitle_properties : public Command {
|
||||||
static void save_subtitles(agi::Context *c, agi::fs::path filename) {
|
static void save_subtitles(agi::Context *c, agi::fs::path filename) {
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
c->videoController->Stop();
|
c->videoController->Stop();
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Subtitles")->GetString());
|
filename = SaveFileSelector(_("Save subtitles file"), "Path/Last/Subtitles",
|
||||||
filename = wxFileSelector(_("Save subtitles file"), path,
|
c->ass->filename.stem().string() + ".ass", "ass",
|
||||||
c->ass->filename.stem().wstring() + L".ass", "ass",
|
"Advanced Substation Alpha (*.ass)|*.ass", c->parent);
|
||||||
"Advanced Substation Alpha (*.ass)|*.ass",
|
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, c->parent);
|
|
||||||
if (filename.empty()) return;
|
if (filename.empty()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,9 @@
|
||||||
|
|
||||||
#include "../include/aegisub/context.h"
|
#include "../include/aegisub/context.h"
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
|
#include "../utils.h"
|
||||||
#include "../video_context.h"
|
#include "../video_context.h"
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
|
||||||
#include <wx/filedlg.h>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using cmd::Command;
|
using cmd::Command;
|
||||||
/// @defgroup cmd-timecode Timecode commands.
|
/// @defgroup cmd-timecode Timecode commands.
|
||||||
|
@ -76,13 +74,10 @@ struct timecode_open : public Command {
|
||||||
STR_HELP("Opens a VFR timecodes v1 or v2 file")
|
STR_HELP("Opens a VFR timecodes v1 or v2 file")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Timecodes")->GetString());
|
auto str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*";
|
||||||
wxString str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*";
|
auto filename = OpenFileSelector(_("Open Timecodes File"), "Path/Last/Timecodes", "", "", str, c->parent);
|
||||||
agi::fs::path filename = wxFileSelector(_("Open Timecodes File"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
if (!filename.empty())
|
||||||
if (!filename.empty()) {
|
|
||||||
c->videoController->LoadTimecodes(filename);
|
c->videoController->LoadTimecodes(filename);
|
||||||
OPT_SET("Path/Last/Timecodes")->SetString(filename.parent_path().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,13 +94,10 @@ struct timecode_save : public Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Timecodes")->GetString());
|
auto str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*";
|
||||||
wxString str = _("All Supported Formats") + " (*.txt)|*.txt|" + _("All Files") + " (*.*)|*.*";
|
auto filename = SaveFileSelector(_("Save Timecodes File"), "Path/Last/Timecodes", "", "", str, c->parent);
|
||||||
agi::fs::path filename = wxFileSelector(_("Save Timecodes File"),path,"","",str,wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
if (!filename.empty())
|
||||||
if (!filename.empty()) {
|
|
||||||
c->videoController->SaveTimecodes(filename);
|
c->videoController->SaveTimecodes(filename);
|
||||||
OPT_SET("Path/Last/Timecodes")->SetString(filename.parent_path().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
|
|
||||||
|
@ -559,10 +558,9 @@ struct video_jump_start : public validator_video_loaded {
|
||||||
STR_HELP("Jumps the video to the start frame of current subtitle")
|
STR_HELP("Jumps the video to the start frame of current subtitle")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
if (AssDialogue *active_line = c->selectionController->GetActiveLine()) {
|
if (AssDialogue *active_line = c->selectionController->GetActiveLine())
|
||||||
c->videoController->JumpToTime(active_line->Start);
|
c->videoController->JumpToTime(active_line->Start);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Opens a video file.
|
/// Opens a video file.
|
||||||
|
@ -573,14 +571,11 @@ struct video_open : public Command {
|
||||||
STR_HELP("Opens a video file")
|
STR_HELP("Opens a video file")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Video")->GetString());
|
auto str = _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts,*.y4m,*.yuv)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts;*.y4m;*.yuv|"
|
||||||
wxString str = _("Video Formats") + " (*.asf,*.avi,*.avs,*.d2v,*.m2ts,*.m4v,*.mkv,*.mov,*.mp4,*.mpeg,*.mpg,*.ogm,*.webm,*.wmv,*.ts,*.y4m,*.yuv)|*.asf;*.avi;*.avs;*.d2v;*.m2ts;*.m4v;*.mkv;*.mov;*.mp4;*.mpeg;*.mpg;*.ogm;*.webm;*.wmv;*.ts;*.y4m;*.yuv|"
|
|
||||||
+ _("All Files") + " (*.*)|*.*";
|
+ _("All Files") + " (*.*)|*.*";
|
||||||
agi::fs::path filename = wxFileSelector(_("Open video file"),path,"","",str,wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
auto filename = OpenFileSelector(_("Open video file"), "Path/Last/Video", "", "", str, c->parent);
|
||||||
if (!filename.empty()) {
|
if (!filename.empty())
|
||||||
c->videoController->SetVideo(filename);
|
c->videoController->SetVideo(filename);
|
||||||
OPT_SET("Path/Last/Video")->SetString(filename.parent_path().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
#include "dialog_attachments.h"
|
#include "dialog_attachments.h"
|
||||||
|
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/dirdlg.h>
|
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
|
#include <wx/dirdlg.h>
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
|
||||||
|
@ -145,21 +145,19 @@ void DialogAttachments::OnExtract(wxCommandEvent &) {
|
||||||
int i = listView->GetFirstSelected();
|
int i = listView->GetFirstSelected();
|
||||||
if (i == -1) return;
|
if (i == -1) return;
|
||||||
|
|
||||||
std::string path;
|
agi::fs::path path;
|
||||||
bool fullPath = false;
|
bool fullPath = false;
|
||||||
|
|
||||||
// Multiple or single?
|
// Multiple or single?
|
||||||
if (listView->GetNextSelected(i) != -1)
|
if (listView->GetNextSelected(i) != -1)
|
||||||
path = from_wx(wxDirSelector(_("Select the path to save the files to:"), to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()))) + "/";
|
path = wxDirSelector(_("Select the path to save the files to:"), to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()));
|
||||||
else {
|
else {
|
||||||
path = from_wx(wxFileSelector(
|
path = SaveFileSelector(
|
||||||
_("Select the path to save the file to:"),
|
_("Select the path to save the file to:"),
|
||||||
to_wx(OPT_GET("Path/Fonts Collector Destination")->GetString()),
|
"Path/Fonts Collector Destination",
|
||||||
to_wx(((AssAttachment*)wxUIntToPtr(listView->GetItemData(i)))->GetFileName()),
|
((AssAttachment*)wxUIntToPtr(listView->GetItemData(i)))->GetFileName(),
|
||||||
".ttf",
|
".ttf", "Font Files (*.ttf)|*.ttf",
|
||||||
"Font Files (*.ttf)|*.ttf",
|
this);
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
|
|
||||||
this));
|
|
||||||
fullPath = true;
|
fullPath = true;
|
||||||
}
|
}
|
||||||
if (path.empty()) return;
|
if (path.empty()) return;
|
||||||
|
@ -167,7 +165,7 @@ void DialogAttachments::OnExtract(wxCommandEvent &) {
|
||||||
// Loop through items in list
|
// Loop through items in list
|
||||||
while (i != -1) {
|
while (i != -1) {
|
||||||
AssAttachment *attach = (AssAttachment*)wxUIntToPtr(listView->GetItemData(i));
|
AssAttachment *attach = (AssAttachment*)wxUIntToPtr(listView->GetItemData(i));
|
||||||
attach->Extract(fullPath ? path : path + attach->GetFileName());
|
attach->Extract(fullPath ? path : path/attach->GetFileName());
|
||||||
i = listView->GetNextSelected(i);
|
i = listView->GetNextSelected(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "help_button.h"
|
#include "help_button.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "subtitle_format.h"
|
#include "subtitle_format.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <libaegisub/charset_conv.h>
|
#include <libaegisub/charset_conv.h>
|
||||||
|
|
||||||
|
@ -52,7 +53,6 @@
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/checklst.h>
|
#include <wx/checklst.h>
|
||||||
#include <wx/choice.h>
|
#include <wx/choice.h>
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
|
@ -162,7 +162,7 @@ DialogExport::~DialogExport() {
|
||||||
void DialogExport::OnProcess(wxCommandEvent &) {
|
void DialogExport::OnProcess(wxCommandEvent &) {
|
||||||
if (!TransferDataFromWindow()) return;
|
if (!TransferDataFromWindow()) return;
|
||||||
|
|
||||||
auto filename = wxFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
|
auto filename = SaveFileSelector(_("Export subtitles file"), "", "", "", to_wx(SubtitleFormat::GetWildcards(1)), this);
|
||||||
if (filename.empty()) return;
|
if (filename.empty()) return;
|
||||||
|
|
||||||
for (size_t i = 0; i < filter_list->GetCount(); ++i) {
|
for (size_t i = 0; i < filter_list->GetCount(); ++i) {
|
||||||
|
@ -173,7 +173,7 @@ void DialogExport::OnProcess(wxCommandEvent &) {
|
||||||
try {
|
try {
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
c->ass->SetScriptInfo("Export Encoding", from_wx(charset_list->GetStringSelection()));
|
c->ass->SetScriptInfo("Export Encoding", from_wx(charset_list->GetStringSelection()));
|
||||||
exporter->Export(from_wx(filename), from_wx(charset_list->GetStringSelection()), this);
|
exporter->Export(filename, from_wx(charset_list->GetStringSelection()), this);
|
||||||
}
|
}
|
||||||
catch (agi::UserCancelException const&) {
|
catch (agi::UserCancelException const&) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <wx/bmpbuttn.h>
|
#include <wx/bmpbuttn.h>
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
@ -561,16 +560,12 @@ void DialogStyleManager::OnCurrentDelete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogStyleManager::OnCurrentImport() {
|
void DialogStyleManager::OnCurrentImport() {
|
||||||
// Get file name
|
auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "", "", SubtitleFormat::GetWildcards(0), this);
|
||||||
wxString path = to_wx(OPT_GET("Path/Last/Subtitles")->GetString());
|
if (filename.empty()) return;
|
||||||
wxString filename = wxFileSelector(_("Open subtitles file"), path, "", "", to_wx(SubtitleFormat::GetWildcards(0)), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
|
||||||
if (!filename) return;
|
|
||||||
|
|
||||||
OPT_SET("Path/Last/Subtitles")->SetString(from_wx(wxFileName(filename).GetPath()));
|
|
||||||
|
|
||||||
AssFile temp;
|
AssFile temp;
|
||||||
try {
|
try {
|
||||||
temp.Load(from_wx(filename));
|
temp.Load(filename);
|
||||||
}
|
}
|
||||||
catch (agi::Exception const& err) {
|
catch (agi::Exception const& err) {
|
||||||
wxMessageBox(to_wx(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
wxMessageBox(to_wx(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
|
||||||
|
@ -581,7 +576,7 @@ void DialogStyleManager::OnCurrentImport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get styles
|
// Get styles
|
||||||
std::vector<std::string> styles = temp.GetStyles();
|
auto styles = temp.GetStyles();
|
||||||
if (styles.empty()) {
|
if (styles.empty()) {
|
||||||
wxMessageBox(_("The selected file has no available styles."), _("Error Importing Styles"));
|
wxMessageBox(_("The selected file has no available styles."), _("Error Importing Styles"));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filedlg.h>
|
||||||
#include <wx/stdpaths.h>
|
#include <wx/stdpaths.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
@ -281,3 +281,21 @@ void AddFullScreenButton(wxWindow *) { }
|
||||||
void SetFloatOnParent(wxWindow *) { }
|
void SetFloatOnParent(wxWindow *) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
agi::fs::path FileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, int flags, wxWindow *parent) {
|
||||||
|
wxString path;
|
||||||
|
if (!option_name.empty())
|
||||||
|
path = to_wx(OPT_GET(option_name)->GetString());
|
||||||
|
agi::fs::path filename = wxFileSelector(message, path, to_wx(default_filename), to_wx(default_extension), wildcard, flags, parent).wx_str();
|
||||||
|
if (!filename.empty() && !option_name.empty())
|
||||||
|
OPT_SET(option_name)->SetString(filename.parent_path().string());
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
agi::fs::path OpenFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent) {
|
||||||
|
return FileSelector(message, option_name, default_filename, default_extension, wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
agi::fs::path SaveFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent) {
|
||||||
|
return FileSelector(message, option_name, default_filename, default_extension, wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue