mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #5 from lioncash/translate
General: Make UI strings translation-aware
This commit is contained in:
commit
98b821a20a
|
@ -84,7 +84,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
m_ui->processOutput->setFont(mFont);
|
||||
m_cursor = QTextCursor(m_ui->processOutput->document());
|
||||
|
||||
m_updateURDEButton = new QPushButton(QStringLiteral("Update URDE"), m_ui->centralwidget);
|
||||
m_updateURDEButton = new QPushButton(tr("Update URDE"), m_ui->centralwidget);
|
||||
m_ui->gridLayout->addWidget(m_updateURDEButton, 2, 3, 1, 1);
|
||||
m_updateURDEButton->hide();
|
||||
QPalette pal = m_updateURDEButton->palette();
|
||||
|
@ -115,12 +115,15 @@ MainWindow::~MainWindow() {
|
|||
}
|
||||
|
||||
void MainWindow::onExtract() {
|
||||
if (m_path.isEmpty())
|
||||
if (m_path.isEmpty()) {
|
||||
return;
|
||||
QString imgPath = QFileDialog::getOpenFileName(this, QStringLiteral("Extract Image"), m_path,
|
||||
QStringLiteral("Images (*.iso *.wbfs *.gcm)"));
|
||||
if (imgPath.isEmpty())
|
||||
}
|
||||
|
||||
const QString imgPath =
|
||||
QFileDialog::getOpenFileName(this, tr("Extract Image"), m_path, tr("Images (*.iso *.wbfs *.gcm)"));
|
||||
if (imgPath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->processOutput->clear();
|
||||
KillProcessTree(m_heclProc);
|
||||
|
@ -140,7 +143,7 @@ void MainWindow::onExtract() {
|
|||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
|
||||
disableOperations();
|
||||
m_ui->extractBtn->setText(QStringLiteral("Cancel"));
|
||||
m_ui->extractBtn->setText(tr("Cancel"));
|
||||
m_ui->extractBtn->setEnabled(true);
|
||||
disconnect(m_ui->extractBtn, &QPushButton::clicked, nullptr, nullptr);
|
||||
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
|
||||
|
@ -174,7 +177,7 @@ void MainWindow::onPackage() {
|
|||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
|
||||
disableOperations();
|
||||
m_ui->packageBtn->setText(QStringLiteral("Cancel"));
|
||||
m_ui->packageBtn->setText(tr("Cancel"));
|
||||
m_ui->packageBtn->setEnabled(true);
|
||||
disconnect(m_ui->packageBtn, &QPushButton::clicked, nullptr, nullptr);
|
||||
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
|
||||
|
@ -266,21 +269,23 @@ void MainWindow::onUpdateURDEPressed() {
|
|||
}
|
||||
|
||||
void MainWindow::onBinaryDownloaded(QuaZip& file) {
|
||||
bool err = !ExtractZip::extractDir(file, m_path);
|
||||
const bool err = !ExtractZip::extractDir(file, m_path);
|
||||
|
||||
if (err)
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Error extracting zip"));
|
||||
else
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Download successful"), true);
|
||||
if (err) {
|
||||
m_ui->downloadErrorLabel->setText(tr("Error extracting zip"));
|
||||
} else {
|
||||
m_ui->downloadErrorLabel->setText(tr("Download successful"), true);
|
||||
}
|
||||
|
||||
m_ui->downloadButton->setEnabled(true);
|
||||
checkDownloadedBinary();
|
||||
|
||||
if (!err && m_ui->extractBtn->isEnabled())
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Download successful - Press 'Extract' to continue."), true);
|
||||
if (!err && !m_ui->sysReqTable->isBlenderVersionOk())
|
||||
m_ui->downloadErrorLabel->setText(
|
||||
QStringLiteral("Blender 2.78+ must be installed. Please download via Steam or blender.org."));
|
||||
if (!err && m_ui->extractBtn->isEnabled()) {
|
||||
m_ui->downloadErrorLabel->setText(tr("Download successful - Press 'Extract' to continue."), true);
|
||||
}
|
||||
if (!err && !m_ui->sysReqTable->isBlenderVersionOk()) {
|
||||
m_ui->downloadErrorLabel->setText(tr("Blender 2.80+ must be installed. Please download via Steam or blender.org."));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onBinaryFailed() {
|
||||
|
@ -310,9 +315,9 @@ void MainWindow::enableOperations() {
|
|||
if (m_heclPath.isEmpty())
|
||||
return;
|
||||
|
||||
m_ui->extractBtn->setText(QStringLiteral("Extract"));
|
||||
m_ui->packageBtn->setText(QStringLiteral("Package"));
|
||||
m_ui->launchBtn->setText(QStringLiteral("Launch"));
|
||||
m_ui->extractBtn->setText(tr("Extract"));
|
||||
m_ui->packageBtn->setText(tr("Package"));
|
||||
m_ui->launchBtn->setText(tr("Launch"));
|
||||
|
||||
m_ui->extractBtn->setEnabled(true);
|
||||
if (QFile::exists(m_path + QStringLiteral("/MP1/!original_ids.yaml"))) {
|
||||
|
@ -321,14 +326,15 @@ void MainWindow::enableOperations() {
|
|||
m_ui->launchBtn->setEnabled(true);
|
||||
}
|
||||
|
||||
if (!m_ui->sysReqTable->isBlenderVersionOk())
|
||||
insertContinueNote(tr("Blender 2.78+ must be installed. Please download via Steam or blender.org."));
|
||||
else if (m_ui->launchBtn->isEnabled())
|
||||
if (!m_ui->sysReqTable->isBlenderVersionOk()) {
|
||||
insertContinueNote(tr("Blender 2.80+ must be installed. Please download via Steam or blender.org."));
|
||||
} else if (m_ui->launchBtn->isEnabled()) {
|
||||
insertContinueNote(tr("Package complete - Press 'Launch' to start URDE."));
|
||||
else if (m_ui->packageBtn->isEnabled())
|
||||
} else if (m_ui->packageBtn->isEnabled()) {
|
||||
insertContinueNote(tr("Extract complete - Press 'Package' to continue."));
|
||||
else if (m_ui->extractBtn->isEnabled())
|
||||
} else if (m_ui->extractBtn->isEnabled()) {
|
||||
insertContinueNote(tr("Press 'Extract' to begin."));
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::isPackageComplete() const {
|
||||
|
@ -376,7 +382,7 @@ bool MainWindow::checkDownloadedBinary() {
|
|||
|
||||
if (m_path.isEmpty()) {
|
||||
m_ui->heclTabs->setCurrentIndex(1);
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Set working directory to continue."), true);
|
||||
m_ui->downloadErrorLabel->setText(tr("Set working directory to continue."), true);
|
||||
enableOperations();
|
||||
return false;
|
||||
}
|
||||
|
@ -408,7 +414,7 @@ bool MainWindow::checkDownloadedBinary() {
|
|||
m_updateURDEButton->show();
|
||||
}
|
||||
} else {
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("unknown -- re-download recommended"));
|
||||
m_ui->currentBinaryLabel->setText(tr("unknown -- re-download recommended"));
|
||||
}
|
||||
|
||||
m_urdePath = urdePath;
|
||||
|
@ -417,9 +423,9 @@ bool MainWindow::checkDownloadedBinary() {
|
|||
enableOperations();
|
||||
return true;
|
||||
} else {
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
|
||||
m_ui->currentBinaryLabel->setText(tr("none"));
|
||||
m_ui->heclTabs->setCurrentIndex(1);
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Press 'Download' to fetch latest URDE binary."), true);
|
||||
m_ui->downloadErrorLabel->setText(tr("Press 'Download' to fetch latest URDE binary."), true);
|
||||
enableOperations();
|
||||
}
|
||||
|
||||
|
@ -427,21 +433,25 @@ bool MainWindow::checkDownloadedBinary() {
|
|||
}
|
||||
|
||||
void MainWindow::setPath(const QString& path) {
|
||||
QFileInfo finfo(path);
|
||||
const QFileInfo finfo(path);
|
||||
|
||||
QString usePath;
|
||||
if (!path.isEmpty())
|
||||
if (!path.isEmpty()) {
|
||||
usePath = finfo.absoluteFilePath();
|
||||
}
|
||||
|
||||
if (!usePath.isEmpty() && !finfo.exists()) {
|
||||
if (QMessageBox::question(this, QStringLiteral("Make Directory"),
|
||||
QStringLiteral("%1 does not exist. Create it now?").arg(usePath)) == QMessageBox::Yes)
|
||||
if (QMessageBox::question(this, tr("Make Directory"), tr("%1 does not exist. Create it now?").arg(usePath)) ==
|
||||
QMessageBox::Yes) {
|
||||
QDir().mkpath(usePath);
|
||||
else
|
||||
} else {
|
||||
usePath = QString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!usePath.isEmpty() && !finfo.isDir()) {
|
||||
QMessageBox::warning(this, QStringLiteral("Directory Error"), QStringLiteral("%1 is not a directory").arg(usePath),
|
||||
QMessageBox::Ok, QMessageBox::NoButton);
|
||||
QMessageBox::warning(this, tr("Directory Error"), tr("%1 is not a directory").arg(usePath), QMessageBox::Ok,
|
||||
QMessageBox::NoButton);
|
||||
usePath = QString();
|
||||
}
|
||||
|
||||
|
@ -453,9 +463,9 @@ void MainWindow::setPath(const QString& path) {
|
|||
m_ui->downloadButton->setToolTip(QString());
|
||||
m_ui->downloadButton->setEnabled(m_ui->binaryComboBox->isEnabled());
|
||||
} else {
|
||||
m_ui->downloadButton->setToolTip(QStringLiteral("Working directory must be set"));
|
||||
m_ui->downloadButton->setToolTip(tr("Working directory must be set"));
|
||||
m_ui->downloadButton->setEnabled(false);
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
|
||||
m_ui->currentBinaryLabel->setText(tr("none"));
|
||||
}
|
||||
|
||||
m_ui->sysReqTable->updateFreeDiskSpace(m_path);
|
||||
|
|
|
@ -23,21 +23,21 @@
|
|||
#elif _WIN32
|
||||
static QString GetWindowsVersionString() {
|
||||
if (IsWindows10OrGreater())
|
||||
return QStringLiteral("Windows 10");
|
||||
return QObject::tr("Windows 10");
|
||||
else if (IsWindows8Point1OrGreater())
|
||||
return QStringLiteral("Windows 8.1");
|
||||
return QObject::tr("Windows 8.1");
|
||||
else if (IsWindows8OrGreater())
|
||||
return QStringLiteral("Windows 8");
|
||||
return QObject::tr("Windows 8");
|
||||
else if (IsWindows7SP1OrGreater())
|
||||
return QStringLiteral("Windows 7 SP1");
|
||||
return QObject::tr("Windows 7 SP1");
|
||||
else if (IsWindows7OrGreater())
|
||||
return QStringLiteral("Windows 7");
|
||||
return QObject::tr("Windows 7");
|
||||
else if (IsWindowsVistaOrGreater())
|
||||
return QStringLiteral("Windows Vista");
|
||||
return QObject::tr("Windows Vista");
|
||||
else if (IsWindowsXPOrGreater())
|
||||
return QStringLiteral("Windows XP");
|
||||
return QObject::tr("Windows XP");
|
||||
else
|
||||
return QStringLiteral("Windows Old And Won't Work");
|
||||
return QObject::tr("Windows Old And Won't Work");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -47,7 +47,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent
|
|||
if (file.open(QFile::ReadOnly)) {
|
||||
const QString str(QString::fromUtf8(file.readAll()));
|
||||
m_cpuSpeed = str.toInt() / 1000;
|
||||
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.0);
|
||||
m_cpuSpeedStr = tr("%1 GHz").arg(m_cpuSpeed / 1000.0);
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
QProcess spProc;
|
||||
|
@ -77,7 +77,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent
|
|||
n = n.nextSiblingElement(QStringLiteral("string"));
|
||||
const double speed = n.text().split(QLatin1Char{' '}).front().toDouble();
|
||||
m_cpuSpeed = uint64_t(speed * 1000.0);
|
||||
m_cpuSpeedStr.sprintf("%g GHz", speed);
|
||||
m_cpuSpeedStr = tr("%1 GHz").arg(speed);
|
||||
}
|
||||
}
|
||||
#elif _WIN32
|
||||
|
@ -88,7 +88,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent
|
|||
DWORD size = sizeof(MHz);
|
||||
if (RegQueryValueEx(hkey, _SYS_STR("~MHz"), nullptr, nullptr, (LPBYTE)&MHz, &size) == ERROR_SUCCESS) {
|
||||
m_cpuSpeed = uint64_t(MHz);
|
||||
m_cpuSpeedStr.sprintf("%1.1f GHz", MHz / 1000.f);
|
||||
m_cpuSpeedStr = tr("%1 GHz").arg(MHz / 1000.f, 1, 'f', 1);
|
||||
}
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
|
@ -100,7 +100,7 @@ SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent
|
|||
zeus::getCpuInfo(0x16, regs);
|
||||
m_cpuSpeed = uint64_t(regs[0]);
|
||||
}
|
||||
m_cpuSpeedStr.sprintf("%g GHz", m_cpuSpeed / 1000.f);
|
||||
m_cpuSpeedStr = tr("%1 GHz").arg(m_cpuSpeed / 1000.f);
|
||||
#endif
|
||||
#if _WIN32
|
||||
ULONGLONG memSize;
|
||||
|
@ -109,35 +109,35 @@ SysReqTableModel::SysReqTableModel(QObject* parent) : QAbstractTableModel(parent
|
|||
#else
|
||||
m_memorySize = uint64_t(sysconf(_SC_PHYS_PAGES)) * sysconf(_SC_PAGESIZE);
|
||||
#endif
|
||||
m_memorySizeStr.sprintf("%g GiB", m_memorySize / 1024.f / 1024.f / 1024.f);
|
||||
m_memorySizeStr = tr("%1 GiB").arg(m_memorySize / 1024.f / 1024.f / 1024.f);
|
||||
#ifdef __APPLE__
|
||||
GetMacOSSystemVersion(m_macosMajor, m_macosMinor, m_macosPatch);
|
||||
if (m_macosPatch == 0)
|
||||
m_osVersion.sprintf("macOS %d.%d", m_macosMajor, m_macosMinor);
|
||||
else
|
||||
m_osVersion.sprintf("macOS %d.%d.%d", m_macosMajor, m_macosMinor, m_macosPatch);
|
||||
if (m_macosPatch == 0) {
|
||||
m_osVersion = tr("macOS %1.%2").arg(m_macosMajor, m_macosMinor);
|
||||
} else {
|
||||
m_osVersion = tr("macOS %1.%2.%3").arg(m_macosMajor, m_macosMinor, m_macosPatch);
|
||||
}
|
||||
#elif _WIN32
|
||||
m_win7SP1OrGreater = IsWindows7SP1OrGreater();
|
||||
m_osVersion = GetWindowsVersionString();
|
||||
#elif __linux__
|
||||
m_osVersion = QStringLiteral("Linux");
|
||||
m_osVersion = tr("Linux");
|
||||
#endif
|
||||
hecl::blender::FindBlender(m_blendMajor, m_blendMinor);
|
||||
if (m_blendMajor) {
|
||||
m_blendVersionStr =
|
||||
QStringLiteral("Blender ") + QString::number(m_blendMajor) + QLatin1Char{'.'} + QString::number(m_blendMinor);
|
||||
m_blendVersionStr = tr("Blender %1.%2").arg(QString::number(m_blendMajor), QString::number(m_blendMinor));
|
||||
} else {
|
||||
m_blendVersionStr = QStringLiteral("Not Found");
|
||||
m_blendVersionStr = tr("Not Found");
|
||||
}
|
||||
}
|
||||
|
||||
void SysReqTableModel::updateFreeDiskSpace(const QString& path) {
|
||||
if (path.isEmpty()) {
|
||||
m_freeDiskSpace = 0;
|
||||
m_freeDiskSpaceStr = QStringLiteral("<Set Working Directory>");
|
||||
m_freeDiskSpaceStr = tr("<Set Working Directory>");
|
||||
} else {
|
||||
m_freeDiskSpace = QStorageInfo(path).bytesFree();
|
||||
m_freeDiskSpaceStr.sprintf("%1.1f GB", m_freeDiskSpace / 1000.f / 1000.f / 1000.f);
|
||||
m_freeDiskSpaceStr = tr("%1 GB").arg(m_freeDiskSpace / 1000.f / 1000.f / 1000.f, 1, 'f', 1);
|
||||
}
|
||||
emit dataChanged(index(3, 0), index(3, 0));
|
||||
}
|
||||
|
@ -178,28 +178,28 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const {
|
|||
switch (index.row()) {
|
||||
case 0:
|
||||
#if ZEUS_ARCH_X86 || ZEUS_ARCH_X86_64
|
||||
return QStringLiteral("x86_64");
|
||||
return tr("x86_64");
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
case 1:
|
||||
return QStringLiteral("1.5 GHz");
|
||||
return tr("1.5 GHz");
|
||||
case 2:
|
||||
return QStringLiteral("3 GiB");
|
||||
return tr("3 GiB");
|
||||
case 3:
|
||||
return QStringLiteral("5 GB (MP1)");
|
||||
return tr("5 GB (MP1)");
|
||||
case 4:
|
||||
#ifdef __APPLE__
|
||||
return QStringLiteral("macOS 10.9");
|
||||
return tr("macOS 10.9");
|
||||
#elif defined(_WIN32)
|
||||
return QStringLiteral("Windows 7 SP1");
|
||||
return tr("Windows 7 SP1");
|
||||
#elif defined(__linux__)
|
||||
return QStringLiteral("Linux");
|
||||
return tr("Linux");
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
case 5:
|
||||
return QStringLiteral("Blender 2.78");
|
||||
return tr("Blender 2.80");
|
||||
}
|
||||
} else if (index.column() == 1) {
|
||||
/* Your System */
|
||||
|
@ -235,27 +235,27 @@ QVariant SysReqTableModel::headerData(int section, Qt::Orientation orientation,
|
|||
switch (section) {
|
||||
case 0:
|
||||
default:
|
||||
return QStringLiteral("Recommended");
|
||||
return tr("Recommended");
|
||||
case 1:
|
||||
return QStringLiteral("Your System");
|
||||
return tr("Your System");
|
||||
}
|
||||
} else {
|
||||
switch (section) {
|
||||
case 0:
|
||||
default:
|
||||
return QStringLiteral("Architecture");
|
||||
return tr("Architecture");
|
||||
case 1:
|
||||
return QStringLiteral("CPU Speed");
|
||||
return tr("CPU Speed");
|
||||
case 2:
|
||||
return QStringLiteral("Memory");
|
||||
return tr("Memory");
|
||||
case 3:
|
||||
return QStringLiteral("Disk Space");
|
||||
return tr("Disk Space");
|
||||
case 4:
|
||||
return QStringLiteral("OS");
|
||||
return tr("OS");
|
||||
case 5:
|
||||
return QStringLiteral("Blender");
|
||||
return tr("Blender");
|
||||
case 6:
|
||||
return QStringLiteral("Vector ISA");
|
||||
return tr("Vector ISA");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class SysReqTableModel : public QAbstractTableModel {
|
|||
uint64_t m_memorySize = 0;
|
||||
QString m_memorySizeStr;
|
||||
qint64 m_freeDiskSpace = 0;
|
||||
QString m_freeDiskSpaceStr = QStringLiteral("<Set Working Directory>");
|
||||
QString m_freeDiskSpaceStr = tr("<Set Working Directory>");
|
||||
#if __APPLE__
|
||||
int m_macosMajor = 0;
|
||||
int m_macosMinor = 0;
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
bool isBlenderVersionOk() const { return m_blendMajor > 2 || (m_blendMajor == 2 && m_blendMinor >= 78); }
|
||||
bool isBlenderVersionOk() const { return m_blendMajor > 2 || (m_blendMajor == 2 && m_blendMinor >= 80); }
|
||||
void updateFreeDiskSpace(const QString& path);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue