mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
fix things not being localized and settings not loading
This commit is contained in:
parent
f0a1690c92
commit
01b6b6de16
@ -165,7 +165,7 @@ namespace
|
||||
std::wstring path = std::wstring(process).erase(process.rfind(L'\\'));
|
||||
|
||||
PROCESS_INFORMATION info = {};
|
||||
auto useLocale = openSettings().value(CONFIG_JP_LOCALE, PROMPT).toInt();
|
||||
auto useLocale = Settings().value(CONFIG_JP_LOCALE, PROMPT).toInt();
|
||||
if (!x64 && (useLocale == ALWAYS || (useLocale == PROMPT && QMessageBox::question(This, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes)))
|
||||
{
|
||||
if (HMODULE localeEmulator = LoadLibraryW(L"LoaderDll"))
|
||||
@ -439,10 +439,10 @@ namespace
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void Settings()
|
||||
void OpenSettings()
|
||||
{
|
||||
QDialog dialog(This, Qt::WindowCloseButtonHint);
|
||||
QSettings settings(CONFIG_FILE, QSettings::IniFormat, &dialog);
|
||||
Settings settings(&dialog);
|
||||
QFormLayout layout(&dialog);
|
||||
QPushButton saveButton(SAVE_SETTINGS, &dialog);
|
||||
for (auto [value, label] : Array<bool&, const char*>{
|
||||
@ -501,7 +501,7 @@ namespace
|
||||
font.fromString(fontString);
|
||||
font.setStyleStrategy(QFont::NoFontMerging);
|
||||
ui.textOutput->setFont(font);
|
||||
QSettings(CONFIG_FILE, QSettings::IniFormat).setValue(FONT, font.toString());
|
||||
Settings().setValue(FONT, font.toString());
|
||||
}
|
||||
|
||||
void ProcessConnected(DWORD processId)
|
||||
@ -605,7 +605,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{ REMOVE_HOOKS, RemoveHooks },
|
||||
{ SAVE_HOOKS, SaveHooks },
|
||||
{ SEARCH_FOR_HOOKS, FindHooks },
|
||||
{ SETTINGS, Settings },
|
||||
{ SETTINGS, OpenSettings },
|
||||
{ EXTENSIONS, Extensions }
|
||||
})
|
||||
{
|
||||
@ -623,7 +623,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
connect(ui.textOutput, &QPlainTextEdit::selectionChanged, this, CopyUnlessMouseDown);
|
||||
connect(ui.textOutput, &QPlainTextEdit::customContextMenuRequested, this, OutputContextMenu);
|
||||
|
||||
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
||||
Settings settings;
|
||||
if (settings.contains(WINDOW) && QApplication::screenAt(settings.value(WINDOW).toRect().center())) setGeometry(settings.value(WINDOW).toRect());
|
||||
SetOutputFont(settings.value(FONT, ui.textOutput->font().toString()).toString());
|
||||
TextThread::filterRepetition = settings.value(FILTER_REPETITION, TextThread::filterRepetition).toBool();
|
||||
@ -672,7 +672,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
openSettings().setValue(WINDOW, geometry());
|
||||
Settings().setValue(WINDOW, geometry());
|
||||
CleanupExtensions();
|
||||
SetErrorMode(SEM_NOGPFAULTERRORBOX);
|
||||
ExitProcess(0);
|
||||
|
@ -46,6 +46,7 @@ struct PrettyWindow : QDialog
|
||||
{
|
||||
PrettyWindow(const char* name)
|
||||
{
|
||||
localize();
|
||||
ui.setupUi(this);
|
||||
ui.display->setGraphicsEffect(&outliner);
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
@ -76,7 +77,7 @@ struct PrettyWindow : QDialog
|
||||
|
||||
protected:
|
||||
QMenu menu{ ui.display };
|
||||
QSettings settings{ openSettings(this) };
|
||||
Settings settings{ this };
|
||||
|
||||
private:
|
||||
void RequestFont()
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
Window()
|
||||
: QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
||||
{
|
||||
localize();
|
||||
connect(&loadButton, &QPushButton::clicked, this, &Window::LoadScript);
|
||||
|
||||
if (scriptEditor.toPlainText().isEmpty()) scriptEditor.setPlainText(LUA_INTRO);
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
Window()
|
||||
: QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
||||
{
|
||||
localize();
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.input, &QLineEdit::textEdited, this, &Window::setRegex);
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
Window()
|
||||
: QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
||||
{
|
||||
localize();
|
||||
connect(&linkButton, &QPushButton::clicked, this, &Window::Link);
|
||||
|
||||
layout.addWidget(&linkList);
|
||||
|
@ -29,7 +29,7 @@ const char* LANGUAGE = u8"Language";
|
||||
const std::string TRANSLATION_CACHE_FILE = FormatString("%s Cache.txt", TRANSLATION_PROVIDER);
|
||||
|
||||
QFormLayout* display;
|
||||
QSettings settings = openSettings();
|
||||
Settings settings;
|
||||
Synchronized<std::wstring> translateTo = L"en", apiKey;
|
||||
|
||||
Synchronized<std::map<std::wstring, std::wstring>> translationCache;
|
||||
@ -50,6 +50,7 @@ public:
|
||||
Window() :
|
||||
QDialog(nullptr, Qt::WindowMinMaxButtonsHint)
|
||||
{
|
||||
localize();
|
||||
display = new QFormLayout(this);
|
||||
|
||||
settings.beginGroup(TRANSLATION_PROVIDER);
|
||||
|
@ -148,6 +148,8 @@ inline void TEXTRACTOR_MESSAGE(const wchar_t* format, const Args&... args) { Mes
|
||||
template <typename... Args>
|
||||
inline void TEXTRACTOR_DEBUG(const wchar_t* format, const Args&... args) { std::thread([=] { TEXTRACTOR_MESSAGE(format, args...); }).detach(); }
|
||||
|
||||
void localize();
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define TEST(...) static auto _ = CreateThread(nullptr, 0, [](auto) { __VA_ARGS__; return 0UL; }, NULL, 0, nullptr);
|
||||
#else
|
||||
|
@ -23,8 +23,8 @@ static thread_local bool ok;
|
||||
|
||||
constexpr auto CONFIG_FILE = u8"Textractor.ini";
|
||||
constexpr auto WINDOW = u8"Window";
|
||||
inline QSettings openSettings(QObject* parent = nullptr) { return { CONFIG_FILE, QSettings::IniFormat, parent }; }
|
||||
|
||||
struct Settings : QSettings { Settings(QObject* parent = nullptr) : QSettings(CONFIG_FILE, QSettings::IniFormat, parent) {} };
|
||||
struct QTextFile : QFile { QTextFile(QString name, QIODevice::OpenMode mode) : QFile(name) { open(mode | QIODevice::Text); } };
|
||||
inline std::wstring S(const QString& s) { return { s.toStdWString() }; }
|
||||
inline QString S(const std::string& s) { return QString::fromStdString(s); }
|
||||
|
6
text.cpp
6
text.cpp
@ -215,7 +215,7 @@ const char* THREAD_LINK_FROM = u8"Thread number to link from";
|
||||
const char* THREAD_LINK_TO = u8"Thread number to link to";
|
||||
const char* HEXADECIMAL = u8"Hexadecimal";
|
||||
|
||||
static auto _ = []
|
||||
void localize()
|
||||
{
|
||||
#ifdef TURKISH
|
||||
NATIVE_LANGUAGE = "Turkish";
|
||||
@ -1334,6 +1334,6 @@ Ce fichier doit être encodé en Unicode (UTF-16 Little Endian).)";
|
||||
THREAD_LINK_TO = u8"Nombre du thread du lien a";
|
||||
HEXADECIMAL = u8"Hexadecimal";
|
||||
#endif // FRENCH
|
||||
};
|
||||
|
||||
return 0;
|
||||
}();
|
||||
static auto _ = (localize(), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user