Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soarqin committed Jul 15, 2018
1 parent bb15b39 commit d7c933c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif ()
add_executable(FinalHE WIN32 ${SRC_FILES} ${UI_FILES} ${RES_FILES} ${FINALHE_RCC_SRC} ${TRANSLATION_FILES} ${TRANSLATION_QM})
target_link_libraries(FinalHE Qt5::Widgets Qt5::Network vitamtp vitapkg psvimg miniz scrypto)
if (WIN32)
target_link_libraries(FinalHE shlwapi)
target_link_libraries(FinalHE shlwapi psapi)
endif ()

add_custom_command(TARGET FinalHE POST_BUILD
Expand Down
22 changes: 16 additions & 6 deletions src/finalhe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ FinalHE::FinalHE(QWidget *parent): QMainWindow(parent) {
ui.progressBar->setMaximum(100);
QDir dir(qApp->applicationDirPath());
QDir baseDir(dir);
if (!baseDir.cd("data")) {
if (!baseDir.mkdir("data") || !baseDir.cd("data")) {
QMessageBox::critical(this, tr("ERROR"), tr("You don't have write permission to this folder! Exit now."));
QCoreApplication::quit();
return;
}
if (!baseDir.mkpath("data") || !(baseDir.cd("data"), baseDir.exists())) {
QMessageBox::critical(this, tr("ERROR"), tr("You don't have write permission to this folder! Exit now."));
QCoreApplication::quit();
return;
}
vita = new VitaConn(baseDir.path(), this);
pkg = new Package(baseDir.path(), this);
int useSysLang = 0;
if (dir.cd("language")) {
QStringList ll = dir.entryList({"*.qm"}, QDir::Filter::Files, QDir::SortFlag::IgnoreCase);
ui.comboLang->addItem(trans.isEmpty() ? "English" : trans.translate("base", "English"));
for (auto &p: ll) {
QString compPath = dir.filePath(p);
QTranslator transl;
if (transl.load(compPath)) {
int index = ui.comboLang->count();
ui.comboLang->addItem(transl.translate("base", "LANGUAGE"), compPath);
if (QFileInfo(p).baseName() == QLocale::system().name()) {
useSysLang = index;
}
}
}
}
Expand All @@ -54,6 +57,11 @@ FinalHE::FinalHE(QWidget *parent): QMainWindow(parent) {

vita->process();
pkg->tips();

if (useSysLang) {
ui.comboLang->setCurrentIndex(useSysLang);
langChange();
}
}

FinalHE::~FinalHE() {
Expand All @@ -65,6 +73,8 @@ void FinalHE::langChange() {
QVariant var = ui.comboLang->currentData();
QString compPath = var.toString();
loadLanguage(compPath);
pkg->tips();
vita->updateStatus();
}

void FinalHE::onStart() {
Expand Down
9 changes: 6 additions & 3 deletions src/package.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Package::~Package() {
}

void Package::tips() {
emit setStatusText(tr("Launch Content Manager on PS Vita and connect to computer."));
if (accountId.isEmpty())
emit setStatusText(tr("Launch Content Manager on PS Vita and connect to computer."));
}

void Package::get(const QString &url, QString &result) {
Expand Down Expand Up @@ -81,6 +82,8 @@ void Package::download(const QString &url, const QString &localFilename, const c
}
}
}, &n);
} else {
startDownload(url, filename);
}
}

Expand Down Expand Up @@ -350,7 +353,7 @@ void Package::downloadFinished(QFile *f) {
}, [this](void *arg) {
if (*(int*)arg)
startUnpackHencore(HENCORE_FILE);
});
}, &n);
} else if (fi.fileName() == BSPKG_FILE) {
Worker::start(this, [this, filepath](void *arg) {
if (verify(filepath, BSPKG_SHA256))
Expand All @@ -360,6 +363,6 @@ void Package::downloadFinished(QFile *f) {
}, [this](void *arg) {
if (*(int*)arg)
startUnpackDemo(BSPKG_FILE);
});
}, &n);
}
}
40 changes: 20 additions & 20 deletions src/translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<translation>无法强制关闭Qcma,请手动关闭后再重启本工具</translation>
</message>
<message>
<location filename="../finalhe.cc" line="22"/>
<location filename="../finalhe.cc" line="21"/>
<location filename="../main.cc" line="62"/>
<source>ERROR</source>
<translation>错误</translation>
</message>
<message>
<location filename="../finalhe.cc" line="22"/>
<location filename="../finalhe.cc" line="21"/>
<source>You don&apos;t have write permission to this folder! Exit now.</source>
<translation>没有目录写入权限,关闭工具中 </translation>
</message>
Expand All @@ -51,37 +51,37 @@
<context>
<name>Package</name>
<message>
<location filename="../package.cc" line="89"/>
<location filename="../package.cc" line="92"/>
<source>Downloading %1</source>
<translation>正在下载 %1</translation>
</message>
<message>
<location filename="../package.cc" line="110"/>
<location filename="../package.cc" line="113"/>
<source>Unpacking %1</source>
<translation>正在解包 %1</translation>
</message>
<message>
<location filename="../package.cc" line="124"/>
<location filename="../package.cc" line="127"/>
<source>Failed to unpack %1</source>
<translation>无法解包 %1</translation>
</message>
<message>
<location filename="../package.cc" line="147"/>
<location filename="../package.cc" line="150"/>
<source>Decompressing %1</source>
<translation>正在解压 %1</translation>
</message>
<message>
<location filename="../package.cc" line="162"/>
<location filename="../package.cc" line="165"/>
<source>Failed to decompress %1</source>
<translation>无法解压 %1</translation>
</message>
<message>
<location filename="../package.cc" line="202"/>
<location filename="../package.cc" line="205"/>
<source>Verifying %1</source>
<translation>正在校验 %1</translation>
</message>
<message>
<location filename="../package.cc" line="238"/>
<location filename="../package.cc" line="241"/>
<source>Everything is ready, now follow below steps on your PS Vita:
1. Launch Content Manager and connect to your computer.
2. Select &quot;PC -&gt; PS Vita System&quot; -&gt; &quot;Applications&quot; -&gt; &quot;PS Vita&quot;.
Expand All @@ -94,34 +94,34 @@
4. 在PSV上运行 &quot;h-encore&quot;,大功告成!</translation>
</message>
<message>
<location filename="../package.cc" line="250"/>
<location filename="../package.cc" line="253"/>
<source>Fetching backup key from cma.henkaku.xyz</source>
<translation>正在从cma.henkaku.xyz获得备份密钥</translation>
</message>
<message>
<location filename="../package.cc" line="333"/>
<location filename="../package.cc" line="336"/>
<source>Fetched backup key.
Click button to START!</source>
<translation>已获得备份密钥
现在点击按钮开始!</translation>
</message>
<message>
<location filename="../package.cc" line="270"/>
<location filename="../package.cc" line="273"/>
<source>Trimming package</source>
<translation>正在瘦身</translation>
</message>
<message>
<location filename="../package.cc" line="35"/>
<location filename="../package.cc" line="36"/>
<source>Launch Content Manager on PS Vita and connect to computer.</source>
<translation>在PSV上运行内容管理器并连接到计算机</translation>
</message>
<message>
<location filename="../package.cc" line="303"/>
<location filename="../package.cc" line="306"/>
<source>Createing psvimg&apos;s</source>
<translation>正在创建psvimg</translation>
</message>
<message>
<location filename="../package.cc" line="330"/>
<location filename="../package.cc" line="333"/>
<source>Cannot get backup key from your AID.
Please check your network connection!</source>
<translation>无法从用户ID获取备份密钥,请检查计算机的网络连接</translation>
Expand All @@ -130,26 +130,26 @@ Please check your network connection!</source>
<context>
<name>VitaConn</name>
<message>
<location filename="../vita.cc" line="122"/>
<location filename="../vita.cc" line="160"/>
<source>Waiting for connection to PS Vita...</source>
<translation>等待连接到PSV……</translation>
</message>
<message>
<location filename="../vita.cc" line="200"/>
<location filename="../vita.cc" line="163"/>
<source>Connected to PS Vita [%1], Waiting for account ID</source>
<translation>已经连接到PSV [%1], 等待用户ID</translation>
</message>
<message>
<location filename="../vita.cc" line="418"/>
<location filename="../vita.cc" line="165"/>
<source>Connected to PS Vita [%1] (%2)</source>
<translation>已经连接到PSV [%1] (%2)</translation>
</message>
</context>
<context>
<name>base</name>
<message>
<location filename="../finalhe.cc" line="31"/>
<location filename="../finalhe.cc" line="97"/>
<location filename="../finalhe.cc" line="30"/>
<location filename="../finalhe.cc" line="107"/>
<source>English</source>
<translation>英语</translation>
</message>
Expand Down
40 changes: 20 additions & 20 deletions src/translations/zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<translation>無法強制關閉Qcma,請手動關閉後再重新執行本工具</translation>
</message>
<message>
<location filename="../finalhe.cc" line="22"/>
<location filename="../finalhe.cc" line="21"/>
<location filename="../main.cc" line="62"/>
<source>ERROR</source>
<translation>錯誤</translation>
</message>
<message>
<location filename="../finalhe.cc" line="22"/>
<location filename="../finalhe.cc" line="21"/>
<source>You don&apos;t have write permission to this folder! Exit now.</source>
<translation>沒有檔案寫入權限,關閉工具中 </translation>
</message>
Expand All @@ -51,37 +51,37 @@
<context>
<name>Package</name>
<message>
<location filename="../package.cc" line="89"/>
<location filename="../package.cc" line="92"/>
<source>Downloading %1</source>
<translation>正在下載 %1</translation>
</message>
<message>
<location filename="../package.cc" line="110"/>
<location filename="../package.cc" line="113"/>
<source>Unpacking %1</source>
<translation>正在解開 %1</translation>
</message>
<message>
<location filename="../package.cc" line="124"/>
<location filename="../package.cc" line="127"/>
<source>Failed to unpack %1</source>
<translation>無法解開 %1</translation>
</message>
<message>
<location filename="../package.cc" line="147"/>
<location filename="../package.cc" line="150"/>
<source>Decompressing %1</source>
<translation>正在解開壓縮檔案 %1</translation>
</message>
<message>
<location filename="../package.cc" line="162"/>
<location filename="../package.cc" line="165"/>
<source>Failed to decompress %1</source>
<translation>無法解開壓縮檔案 %1</translation>
</message>
<message>
<location filename="../package.cc" line="202"/>
<location filename="../package.cc" line="205"/>
<source>Verifying %1</source>
<translation>正在校驗 %1</translation>
</message>
<message>
<location filename="../package.cc" line="238"/>
<location filename="../package.cc" line="241"/>
<source>Everything is ready, now follow below steps on your PS Vita:
1. Launch Content Manager and connect to your computer.
2. Select &quot;PC -&gt; PS Vita System&quot; -&gt; &quot;Applications&quot; -&gt; &quot;PS Vita&quot;.
Expand All @@ -94,34 +94,34 @@
4. 在PSV上執行 &quot;h-encore&quot;,大功告成!</translation>
</message>
<message>
<location filename="../package.cc" line="250"/>
<location filename="../package.cc" line="253"/>
<source>Fetching backup key from cma.henkaku.xyz</source>
<translation>正在從cma.henkaku.xyz獲得備份密鑰</translation>
</message>
<message>
<location filename="../package.cc" line="333"/>
<location filename="../package.cc" line="336"/>
<source>Fetched backup key.
Click button to START!</source>
<translation>已獲得備份密鑰
現在點擊按鈕開始!</translation>
</message>
<message>
<location filename="../package.cc" line="270"/>
<location filename="../package.cc" line="273"/>
<source>Trimming package</source>
<translation>正在縮減容量</translation>
</message>
<message>
<location filename="../package.cc" line="35"/>
<location filename="../package.cc" line="36"/>
<source>Launch Content Manager on PS Vita and connect to computer.</source>
<translation>在PS Vita上執行內容管理器並連接到個人電腦</translation>
</message>
<message>
<location filename="../package.cc" line="303"/>
<location filename="../package.cc" line="306"/>
<source>Createing psvimg&apos;s</source>
<translation>正在製作psvimg</translation>
</message>
<message>
<location filename="../package.cc" line="330"/>
<location filename="../package.cc" line="333"/>
<source>Cannot get backup key from your AID.
Please check your network connection!</source>
<translation>無法從用戶ID獲取備份密鑰,請檢查個人電腦的網絡連接</translation>
Expand All @@ -130,26 +130,26 @@ Please check your network connection!</source>
<context>
<name>VitaConn</name>
<message>
<location filename="../vita.cc" line="122"/>
<location filename="../vita.cc" line="160"/>
<source>Waiting for connection to PS Vita...</source>
<translation>等待連接到PSV……</translation>
</message>
<message>
<location filename="../vita.cc" line="200"/>
<location filename="../vita.cc" line="163"/>
<source>Connected to PS Vita [%1], Waiting for account ID</source>
<translation>已經連接到PSV [%1], 等待用戶ID</translation>
</message>
<message>
<location filename="../vita.cc" line="418"/>
<location filename="../vita.cc" line="165"/>
<source>Connected to PS Vita [%1] (%2)</source>
<translation>已經連接到PSV [%1] (%2)</translation>
</message>
</context>
<context>
<name>base</name>
<message>
<location filename="../finalhe.cc" line="31"/>
<location filename="../finalhe.cc" line="97"/>
<location filename="../finalhe.cc" line="30"/>
<location filename="../finalhe.cc" line="107"/>
<source>English</source>
<translation>英文</translation>
</message>
Expand Down
Loading

0 comments on commit d7c933c

Please sign in to comment.