mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
Merge branch 'misc' into feature
This commit is contained in:
commit
b9ba4ea42c
@ -544,7 +544,7 @@ struct edit_find_replace final : public Command {
|
|||||||
|
|
||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
c->videoController->Stop();
|
c->videoController->Stop();
|
||||||
DialogSearchReplace::Show(c, true);
|
ShowSearchReplaceDialog(c, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ struct subtitle_find final : public Command {
|
|||||||
|
|
||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
c->videoController->Stop();
|
c->videoController->Stop();
|
||||||
DialogSearchReplace::Show(c, false);
|
ShowSearchReplaceDialog(c, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ struct subtitle_find_next final : public Command {
|
|||||||
void operator()(agi::Context *c) override {
|
void operator()(agi::Context *c) override {
|
||||||
c->videoController->Stop();
|
c->videoController->Stop();
|
||||||
if (!c->search->FindNext())
|
if (!c->search->FindNext())
|
||||||
DialogSearchReplace::Show(c, false);
|
ShowSearchReplaceDialog(c, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
if (*diag.first == typeid(DialogType)) {
|
if (*diag.first == typeid(DialogType)) {
|
||||||
diag.second->Show();
|
diag.second->Show();
|
||||||
diag.second->SetFocus();
|
diag.second->SetFocus();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "dialog_search_replace.h"
|
#include "dialog_search_replace.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "dialog_manager.h"
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "search_replace_engine.h"
|
#include "search_replace_engine.h"
|
||||||
@ -42,11 +43,11 @@
|
|||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/valgen.h>
|
#include <wx/valgen.h>
|
||||||
|
|
||||||
DialogSearchReplace::DialogSearchReplace(agi::Context* c, bool replace)
|
template<bool has_replace>
|
||||||
: wxDialog(c->parent, -1, replace ? _("Replace") : _("Find"))
|
DialogSearchReplace<has_replace>::DialogSearchReplace(agi::Context* c)
|
||||||
|
: wxDialog(c->parent, -1, has_replace ? _("Replace") : _("Find"))
|
||||||
, c(c)
|
, c(c)
|
||||||
, settings(agi::make_unique<SearchReplaceSettings>())
|
, settings(agi::make_unique<SearchReplaceSettings>())
|
||||||
, has_replace(replace)
|
|
||||||
{
|
{
|
||||||
auto recent_find(lagi_MRU_wxAS("Find"));
|
auto recent_find(lagi_MRU_wxAS("Find"));
|
||||||
auto recent_replace(lagi_MRU_wxAS("Replace"));
|
auto recent_replace(lagi_MRU_wxAS("Replace"));
|
||||||
@ -128,10 +129,8 @@ DialogSearchReplace::DialogSearchReplace(agi::Context* c, bool replace)
|
|||||||
replace_all->Bind(wxEVT_BUTTON, std::bind(&DialogSearchReplace::FindReplace, this, &SearchReplaceEngine::ReplaceAll));
|
replace_all->Bind(wxEVT_BUTTON, std::bind(&DialogSearchReplace::FindReplace, this, &SearchReplaceEngine::ReplaceAll));
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogSearchReplace::~DialogSearchReplace() {
|
template<bool has_replace>
|
||||||
}
|
void DialogSearchReplace<has_replace>::FindReplace(bool (SearchReplaceEngine::*func)()) {
|
||||||
|
|
||||||
void DialogSearchReplace::FindReplace(bool (SearchReplaceEngine::*func)()) {
|
|
||||||
TransferDataFromWindow();
|
TransferDataFromWindow();
|
||||||
|
|
||||||
if (settings->find.empty())
|
if (settings->find.empty())
|
||||||
@ -160,7 +159,7 @@ void DialogSearchReplace::FindReplace(bool (SearchReplaceEngine::*func)()) {
|
|||||||
UpdateDropDowns();
|
UpdateDropDowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_mru(wxComboBox *cb, const char *mru_name) {
|
void update_mru(wxComboBox *cb, const char *mru_name) {
|
||||||
cb->Freeze();
|
cb->Freeze();
|
||||||
cb->Clear();
|
cb->Clear();
|
||||||
cb->Append(lagi_MRU_wxAS(mru_name));
|
cb->Append(lagi_MRU_wxAS(mru_name));
|
||||||
@ -169,27 +168,33 @@ static void update_mru(wxComboBox *cb, const char *mru_name) {
|
|||||||
cb->Thaw();
|
cb->Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogSearchReplace::UpdateDropDowns() {
|
template<bool has_replace>
|
||||||
|
void DialogSearchReplace<has_replace>::UpdateDropDowns() {
|
||||||
update_mru(find_edit, "Find");
|
update_mru(find_edit, "Find");
|
||||||
|
|
||||||
if (has_replace)
|
if (has_replace)
|
||||||
update_mru(replace_edit, "Replace");
|
update_mru(replace_edit, "Replace");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogSearchReplace::Show(agi::Context *context, bool replace) {
|
template<bool replace>
|
||||||
static DialogSearchReplace *diag = nullptr;
|
void ShowSearchReplaceDialog(agi::Context *context) {
|
||||||
|
auto other = context->dialog->Get<DialogSearchReplace<!replace>>();
|
||||||
if (diag && replace != diag->has_replace) {
|
if (other != nullptr) {
|
||||||
// Already opened, but wrong type - destroy and create the right one
|
other->Close();
|
||||||
diag->Destroy();
|
|
||||||
diag = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!diag)
|
context->dialog->Show<DialogSearchReplace<replace>>(context);
|
||||||
diag = new DialogSearchReplace(context, replace);
|
auto dialog = context->dialog->Get<DialogSearchReplace<replace>>();
|
||||||
|
|
||||||
diag->find_edit->SetFocus();
|
dialog->find_edit->SetFocus();
|
||||||
diag->find_edit->SelectAll();
|
dialog->find_edit->SelectAll();
|
||||||
diag->wxDialog::Show();
|
dialog->Raise();
|
||||||
diag->Raise();
|
}
|
||||||
|
|
||||||
|
void ShowSearchReplaceDialog(agi::Context *context, bool replace) {
|
||||||
|
if (replace) {
|
||||||
|
ShowSearchReplaceDialog<true>(context);
|
||||||
|
} else {
|
||||||
|
ShowSearchReplaceDialog<false>(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,19 +28,16 @@ class SearchReplaceEngine;
|
|||||||
struct SearchReplaceSettings;
|
struct SearchReplaceSettings;
|
||||||
class wxComboBox;
|
class wxComboBox;
|
||||||
|
|
||||||
|
template<bool has_replace>
|
||||||
class DialogSearchReplace final : public wxDialog {
|
class DialogSearchReplace final : public wxDialog {
|
||||||
agi::Context *c;
|
agi::Context *c;
|
||||||
std::unique_ptr<SearchReplaceSettings> settings;
|
std::unique_ptr<SearchReplaceSettings> settings;
|
||||||
bool has_replace;
|
|
||||||
wxComboBox *find_edit;
|
|
||||||
wxComboBox *replace_edit;
|
wxComboBox *replace_edit;
|
||||||
|
|
||||||
void UpdateDropDowns();
|
void UpdateDropDowns();
|
||||||
void FindReplace(bool (SearchReplaceEngine::*func)());
|
void FindReplace(bool (SearchReplaceEngine::*func)());
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Show(agi::Context *context, bool with_replace);
|
wxComboBox *find_edit;
|
||||||
|
DialogSearchReplace(agi::Context* c);
|
||||||
DialogSearchReplace(agi::Context* c, bool with_replace);
|
|
||||||
~DialogSearchReplace();
|
|
||||||
};
|
};
|
||||||
|
@ -68,6 +68,7 @@ void ShowKanjiTimerDialog(agi::Context *c);
|
|||||||
void ShowLogWindow(agi::Context *c);
|
void ShowLogWindow(agi::Context *c);
|
||||||
void ShowPreferences(wxWindow *parent);
|
void ShowPreferences(wxWindow *parent);
|
||||||
void ShowPropertiesDialog(agi::Context *c);
|
void ShowPropertiesDialog(agi::Context *c);
|
||||||
|
void ShowSearchReplaceDialog(agi::Context *c, bool replace);
|
||||||
void ShowSelectLinesDialog(agi::Context *c);
|
void ShowSelectLinesDialog(agi::Context *c);
|
||||||
void ShowShiftTimesDialog(agi::Context *c);
|
void ShowShiftTimesDialog(agi::Context *c);
|
||||||
void ShowSpellcheckerDialog(agi::Context *c);
|
void ShowSpellcheckerDialog(agi::Context *c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user