diff --git a/Libs/SelfMade/Strings/u_Qstrings.h b/Libs/SelfMade/Strings/u_Qstrings.h
index 3296aa7..93c3c2e 100644
--- a/Libs/SelfMade/Strings/u_Qstrings.h
+++ b/Libs/SelfMade/Strings/u_Qstrings.h
@@ -11,6 +11,9 @@ namespace str {
inline QString toQ(std::string_view x)
{ return QString::fromUtf8(x.data(), x.size()); }
+ inline QString toQ(std::wstring_view x)
+ { return QString::fromWCharArray(x.data(), x.size()); }
+
inline QString toQ(std::u8string_view x)
{ return QString::fromUtf8(x.data(), x.size()); }
diff --git a/UTranslator/FmMain.cpp b/UTranslator/FmMain.cpp
index c6138bf..8eb146d 100644
--- a/UTranslator/FmMain.cpp
+++ b/UTranslator/FmMain.cpp
@@ -436,6 +436,7 @@ FmMain::FmMain(QWidget *parent)
// Signals/slots: editing
connect(ui->edId, &QLineEdit::textEdited, this, &This::tempModify);
+ connect(ui->edFilePath, &QLineEdit::textEdited, this, &This::tempModify);
connect(ui->memoOriginal, &QPlainTextEdit::textChanged, this, &This::tempModify);
connect(ui->chkIdless, &QCheckBox::clicked, this, &This::tempModify);
connect(ui->memoTranslation, &QPlainTextEdit::textChanged, this, &This::tempModify);
@@ -617,6 +618,7 @@ void FmMain::loadObject(tr::UiObject& obj)
if (auto fi = obj.ownFileInfo()) {
ui->stackOriginal->setCurrentWidget(ui->pageFile);
ui->chkIdless->setChecked(fi->isIdless);
+ ui->edFilePath->setText(str::toQ(fi->origPath.wstring()));
bool canAddFiles = project->info.canAddFiles();
ui->pageFile->setEnabled(canAddFiles);
ui->wiId->setEnabled(canAddFiles);
@@ -704,8 +706,9 @@ void FmMain::acceptObject(tr::UiObject& obj)
auto idx9 = treeModel.toIndex(obj, treeModel.columnCount() - 1);
treeModel.dataChanged(idx0, idx9);
std::string cache;
- if (project->info.canEditOriginal()) {
+ if (project->info.canAddFiles()) {
obj.setId(toU8sv(ui->edId, cache), tr::Modify::YES);
+ obj.setOrigPath(ui->edFilePath->text().toStdWString(), tr::Modify::YES);
obj.setIdless(ui->chkIdless->isChecked(), tr::Modify::YES);
obj.setOriginal(toTextSv(ui->memoOriginal, cache), tr::Modify::YES);
// Bilingual (currently unimplemented):
diff --git a/UTranslator/FmMain.ui b/UTranslator/FmMain.ui
index 168a268..b7cd297 100644
--- a/UTranslator/FmMain.ui
+++ b/UTranslator/FmMain.ui
@@ -312,7 +312,7 @@ QLabel {
-
-
+
@@ -955,7 +955,7 @@ QLabel {
btStartOpen
treeStrings
edId
- lineEdit
+ edFilePath
memoOriginal
chkIdless
btFileFormat
diff --git a/UTranslator/TrProject/TrProject.cpp b/UTranslator/TrProject/TrProject.cpp
index 64b38de..8eddb37 100644
--- a/UTranslator/TrProject/TrProject.cpp
+++ b/UTranslator/TrProject/TrProject.cpp
@@ -166,6 +166,20 @@ bool tr::UiObject::setIdless(bool x, tr::Modify wantModify)
}
+bool tr::UiObject::setOrigPath(const std::filesystem::path& x, tr::Modify wantModify)
+{
+ if (auto fi = ownFileInfo()) {
+ if (fi->origPath != x) {
+ fi->origPath = x;
+ if (wantModify != Modify::NO) {
+ doModify(Mch::ORIG);
+ }
+ }
+ }
+ return false;
+}
+
+
bool tr::UiObject::setTranslation(
std::optional x, tr::Modify wantModify)
{
@@ -993,6 +1007,10 @@ void tr::File::writeToXml(pugi::xml_node& root, WrCache& c) const
auto node = root.append_child("file");
node.append_attribute("name") = str::toC(id);
node.append_attribute("idless") = info.isIdless;
+ if (!info.origPath.empty())
+ node.append_attribute("orig-path") = str::toC(info.origPath.u8string());
+ if (!info.translPath.empty())
+ node.append_attribute("transl-path") = str::toC(info.translPath.u8string());
if (info.format) {
auto nodeFormat = node.append_child("format");
nodeFormat.append_attribute("name") = info.format->proto().techName().data(); // Tech names are const, so OK
@@ -1006,6 +1024,8 @@ void tr::File::readFromXml(const pugi::xml_node& node, const PrjInfo& pinfo)
{
id = str::toU8sv(node.attribute("name").as_string());
info.isIdless = node.attribute("idless").as_bool(false);
+ info.origPath = str::toU8sv(node.attribute("orig-path").as_string());
+ info.translPath = str::toU8sv(node.attribute("transl-path").as_string());
if (auto nodeFormat = node.child("format")) {
std::string_view sName = nodeFormat.attribute("name").as_string();
if (!sName.empty()) {
diff --git a/UTranslator/TrProject/TrProject.h b/UTranslator/TrProject/TrProject.h
index 74ad453..5d1dc31 100644
--- a/UTranslator/TrProject/TrProject.h
+++ b/UTranslator/TrProject/TrProject.h
@@ -292,6 +292,8 @@ namespace tr {
bool setTranslatorsComment(std::u8string_view x, tr::Modify wantModify);
/// @return [+] was actually changed
bool setIdless(bool x, tr::Modify wantModify);
+ /// @return [+] was actually changed
+ bool setOrigPath(const std::filesystem::path& x, tr::Modify wantModify);
/// @return some ID
std::u8string makeId(
std::u8string_view prefix,