mirror of https://github.com/AxioDL/metaforce.git
Various GUI logic fixes and improvements
This commit is contained in:
parent
4f888becdf
commit
8c9ad43a60
|
@ -145,6 +145,9 @@ void DownloadManager::binaryError(QNetworkReply::NetworkError error)
|
|||
|
||||
if (m_progBar)
|
||||
m_progBar->setEnabled(false);
|
||||
|
||||
if (m_failedHandler)
|
||||
m_failedHandler(m_outPath);
|
||||
}
|
||||
|
||||
void DownloadManager::binaryValidateCert()
|
||||
|
|
|
@ -19,6 +19,7 @@ class DownloadManager : public QObject
|
|||
QLabel* m_errorLabel = nullptr;
|
||||
std::function<void(const QStringList& index)> m_indexCompletionHandler;
|
||||
std::function<void(const QString& file)> m_completionHandler;
|
||||
std::function<void(const QString& file)> m_failedHandler;
|
||||
|
||||
void resetError()
|
||||
{
|
||||
|
@ -43,12 +44,14 @@ public:
|
|||
: QObject(parent), m_netManager(this) {}
|
||||
void connectWidgets(QProgressBar* progBar, QLabel* errorLabel,
|
||||
std::function<void(const QStringList& index)>&& indexCompletionHandler,
|
||||
std::function<void(const QString& file)>&& completionHandler)
|
||||
std::function<void(const QString& file)>&& completionHandler,
|
||||
std::function<void(const QString& file)>&& failedHandler)
|
||||
{
|
||||
m_progBar = progBar;
|
||||
m_errorLabel = errorLabel;
|
||||
m_indexCompletionHandler = std::move(indexCompletionHandler);
|
||||
m_completionHandler = std::move(completionHandler);
|
||||
m_failedHandler = std::move(failedHandler);
|
||||
}
|
||||
void fetchIndex();
|
||||
void fetchBinary(const QString& str, const QString& outPath);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef GUI_ERRORLABEL_HPP
|
||||
#define GUI_ERRORLABEL_HPP
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class ErrorLabel : public QLabel
|
||||
{
|
||||
public:
|
||||
ErrorLabel(QWidget* parent = Q_NULLPTR) : QLabel(parent) {}
|
||||
void setText(const QString& str, bool success = false)
|
||||
{
|
||||
QPalette pal = QLabel::palette();
|
||||
if (success)
|
||||
pal.setColor(QPalette::WindowText, QColor(0,255,0));
|
||||
else
|
||||
pal.setColor(QPalette::WindowText, QColor(255,47,0));
|
||||
QLabel::setPalette(pal);
|
||||
QLabel::setText(str);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GUI_ERRORLABEL_HPP
|
|
@ -5,6 +5,7 @@
|
|||
#include <QScrollBar>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QTextCursor>
|
||||
#include "FileDirDialog.hpp"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
|
@ -16,7 +17,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
m_ui->splitter->setSizes({0,-1});
|
||||
m_ui->splitter->setSizes({0,100});
|
||||
|
||||
m_ui->aboutIcon->setPixmap(QApplication::windowIcon().pixmap(256, 256));
|
||||
|
||||
|
@ -24,6 +25,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
mFont.setPointSize(m_ui->currentBinaryLabel->font().pointSize());
|
||||
m_ui->currentBinaryLabel->setFont(mFont);
|
||||
m_ui->recommendedBinaryLabel->setFont(mFont);
|
||||
mFont.setPointSize(10);
|
||||
m_ui->processOutput->setFont(mFont);
|
||||
|
||||
m_updateURDEButton = new QPushButton(QStringLiteral("Update URDE"), m_ui->centralwidget);
|
||||
m_ui->gridLayout->addWidget(m_updateURDEButton, 2, 3, 1, 1);
|
||||
|
@ -37,7 +40,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
m_dlManager.connectWidgets(m_ui->downloadProgressBar, m_ui->downloadErrorLabel,
|
||||
std::bind(&MainWindow::onIndexDownloaded, this, std::placeholders::_1),
|
||||
std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1));
|
||||
std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1),
|
||||
std::bind(&MainWindow::onBinaryFailed, this, std::placeholders::_1));
|
||||
|
||||
initSlots();
|
||||
|
||||
|
@ -565,7 +569,96 @@ void MainWindow::parseEscapeSequence(int attribute, QListIterator<QString>& i, Q
|
|||
|
||||
void MainWindow::onExtract()
|
||||
{
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
QString imgPath = QFileDialog::getOpenFileName(this, QStringLiteral("Extract Image"), {},
|
||||
QStringLiteral("Images (*.iso *.wbfs *.gcm)"));
|
||||
m_ansiString.clear();
|
||||
m_ui->processOutput->clear();
|
||||
m_heclProc.close();
|
||||
m_heclProc.terminate();
|
||||
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
||||
m_heclProc.setWorkingDirectory(m_path);
|
||||
m_heclProc.start(m_heclPath, {"extract", "-y", imgPath, m_path});
|
||||
|
||||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
|
||||
disableOperations();
|
||||
m_ui->extractBtn->setText(QStringLiteral("Cancel"));
|
||||
m_ui->extractBtn->setEnabled(true);
|
||||
disconnect(m_ui->extractBtn, SIGNAL(clicked()), nullptr, nullptr);
|
||||
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(doHECLTerminate()));
|
||||
|
||||
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
|
||||
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onExtractFinished(int)));
|
||||
}
|
||||
|
||||
void MainWindow::onExtractFinished(int returnCode)
|
||||
{
|
||||
disconnect(m_ui->extractBtn, SIGNAL(clicked()), nullptr, nullptr);
|
||||
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(onExtract()));
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
|
||||
void MainWindow::onPackage()
|
||||
{
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
m_ansiString.clear();
|
||||
m_ui->processOutput->clear();
|
||||
m_heclProc.close();
|
||||
m_heclProc.terminate();
|
||||
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
||||
m_heclProc.setWorkingDirectory(m_path);
|
||||
m_heclProc.start(m_heclPath, {"package", "-y"});
|
||||
|
||||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
|
||||
disableOperations();
|
||||
m_ui->packageBtn->setText(QStringLiteral("Cancel"));
|
||||
m_ui->packageBtn->setEnabled(true);
|
||||
disconnect(m_ui->packageBtn, SIGNAL(clicked()), nullptr, nullptr);
|
||||
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(doHECLTerminate()));
|
||||
|
||||
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
|
||||
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onPackageFinished(int)));
|
||||
}
|
||||
|
||||
void MainWindow::onPackageFinished(int returnCode)
|
||||
{
|
||||
disconnect(m_ui->packageBtn, SIGNAL(clicked()), nullptr, nullptr);
|
||||
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(onPackage()));
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
|
||||
void MainWindow::onLaunch()
|
||||
{
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
m_ansiString.clear();
|
||||
m_ui->processOutput->clear();
|
||||
m_heclProc.close();
|
||||
m_heclProc.terminate();
|
||||
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
||||
m_heclProc.setWorkingDirectory(m_path);
|
||||
m_heclProc.start(m_urdePath, {"--no-shader-warmup", m_path + "/out"});
|
||||
|
||||
m_ui->heclTabs->setCurrentIndex(0);
|
||||
|
||||
disableOperations();
|
||||
|
||||
disconnect(&m_heclProc, SIGNAL(finished(int)), nullptr, nullptr);
|
||||
connect(&m_heclProc, SIGNAL(finished(int)), this, SLOT(onLaunchFinished(int)));
|
||||
}
|
||||
|
||||
void MainWindow::onLaunchFinished(int returnCode)
|
||||
{
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
|
||||
void MainWindow::doHECLTerminate()
|
||||
{
|
||||
m_heclProc.terminate();
|
||||
}
|
||||
|
||||
void MainWindow::onReturnPressed()
|
||||
|
@ -601,8 +694,8 @@ void MainWindow::onDownloadPressed()
|
|||
{
|
||||
m_updateURDEButton->hide();
|
||||
QString filename = m_ui->binaryComboBox->currentData().value<URDEVersion>().fileString(true);
|
||||
printf("Downloading %s\n", filename.toUtf8().data());
|
||||
m_ui->launchBtn->setEnabled(false);
|
||||
disableOperations();
|
||||
m_ui->downloadButton->setEnabled(false);
|
||||
m_dlManager.fetchBinary(filename, m_path + '/' + filename);
|
||||
}
|
||||
|
||||
|
@ -616,48 +709,122 @@ void MainWindow::onBinaryDownloaded(const QString& file)
|
|||
{
|
||||
QFileInfo path(file);
|
||||
#ifndef _WIN32
|
||||
QProcess untar;
|
||||
untar.setWorkingDirectory(path.dir().absolutePath());
|
||||
untar.start("tar", {"-xvf", path.fileName()});
|
||||
untar.waitForFinished();
|
||||
#if __APPLE__
|
||||
QFile::rename(path.dir().absoluteFilePath(path.baseName()) + ".app", "urde.app");
|
||||
QProcess unzip;
|
||||
unzip.setWorkingDirectory(path.dir().absolutePath());
|
||||
unzip.start("unzip", {"-o", path.fileName()});
|
||||
unzip.waitForFinished();
|
||||
int err = unzip.exitCode();
|
||||
#else
|
||||
QFile::rename(path.dir().absoluteFilePath(path.baseName()), "urde");
|
||||
SHFILEOPSTRUCT fileOp = {};
|
||||
fileOp.wFunc = FO_COPY;
|
||||
fileOp.pFrom = (path.fileName().toStdWString() + L"\\*.*\0\0").c_str();
|
||||
fileOp.pTo = (path.dir().absolutePath().toStdWString() + L"\0\0").c_str();
|
||||
fileOp.fFlags |= FOF_NOCONFIRMATION;
|
||||
int err = SHFileOperationW(&fileOp);
|
||||
if (fileOp.fAnyOperationsAborted)
|
||||
err = 1;
|
||||
#endif
|
||||
QFile::remove(file);
|
||||
#else
|
||||
QFile::rename(file, "urde.exe");
|
||||
#endif
|
||||
if (err)
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Error extracting ") + path.fileName());
|
||||
else
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("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);
|
||||
}
|
||||
|
||||
void MainWindow::onBinaryFailed(const QString& file)
|
||||
{
|
||||
m_ui->downloadButton->setEnabled(true);
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
|
||||
void MainWindow::checkDownloadedBinary()
|
||||
void MainWindow::disableOperations()
|
||||
{
|
||||
m_updateURDEButton->hide();
|
||||
m_ui->extractBtn->setEnabled(false);
|
||||
m_ui->packageBtn->setEnabled(false);
|
||||
m_ui->launchBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
#if __APPLE__
|
||||
QString urdePath = m_path + "/urde.app/Contents/MacOS/urde";
|
||||
#elif _WIN32
|
||||
QString urdePath = m_path + "urde.exe";
|
||||
#else
|
||||
QString urdePath = m_path + "urde";
|
||||
#endif
|
||||
void MainWindow::enableOperations()
|
||||
{
|
||||
disableOperations();
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
|
||||
m_ui->extractBtn->setText(QStringLiteral("Extract"));
|
||||
m_ui->packageBtn->setText(QStringLiteral("Package"));
|
||||
m_ui->launchBtn->setText(QStringLiteral("Launch"));
|
||||
|
||||
m_ui->extractBtn->setEnabled(true);
|
||||
if (QFile::exists(m_path + "/MP1/!original_ids.yaml"))
|
||||
{
|
||||
m_ui->packageBtn->setEnabled(true);
|
||||
if (QFile::exists(m_path + "/out/MP1/!original_ids.upak"))
|
||||
m_ui->launchBtn->setEnabled(true);
|
||||
}
|
||||
|
||||
if (m_ui->launchBtn->isEnabled())
|
||||
insertContinueNote("Package complete - Press 'Launch' to start URDE.");
|
||||
else if (m_ui->packageBtn->isEnabled())
|
||||
insertContinueNote("Extract complete - Press 'Package' to continue.");
|
||||
else if (m_ui->extractBtn->isEnabled())
|
||||
insertContinueNote("Press 'Extract' to begin.");
|
||||
}
|
||||
|
||||
static bool GetDLPackage(const QString& path, QString& dlPackage)
|
||||
{
|
||||
QProcess proc;
|
||||
proc.start(urdePath, {"--dlpackage"}, QIODevice::ReadOnly);
|
||||
proc.start(path, {"--dlpackage"}, QIODevice::ReadOnly);
|
||||
if (proc.waitForStarted())
|
||||
{
|
||||
proc.waitForFinished();
|
||||
QString dlPackage = QString::fromUtf8(proc.readLine()).trimmed();
|
||||
if (proc.exitCode() == 100)
|
||||
{
|
||||
if (dlPackage.isEmpty())
|
||||
{
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("unknown"));
|
||||
dlPackage = QString::fromUtf8(proc.readLine()).trimmed();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::checkDownloadedBinary()
|
||||
{
|
||||
URDEVersion v(dlPackage);
|
||||
disableOperations();
|
||||
m_updateURDEButton->hide();
|
||||
|
||||
m_urdePath = QString();
|
||||
m_heclPath = QString();
|
||||
|
||||
if (m_path.isEmpty())
|
||||
return false;
|
||||
|
||||
#if __APPLE__
|
||||
QString urdePath = m_path + "/URDE.app/Contents/MacOS/urde";
|
||||
QString heclPath = m_path + "/URDE.app/Contents/MacOS/hecl";
|
||||
QString visigenPath = m_path + "/URDE.app/Contents/MacOS/visigen";
|
||||
#elif _WIN32
|
||||
QString urdePath = m_path + "/urde.exe";
|
||||
QString heclPath = m_path + "/hecl.exe";
|
||||
QString visigenPath = m_path + "/visigen.exe";
|
||||
#else
|
||||
QString urdePath = m_path + "/urde";
|
||||
QString heclPath = m_path + "/hecl";
|
||||
QString visigenPath = m_path + "/visigen";
|
||||
#endif
|
||||
urdePath = QFileInfo(urdePath).absoluteFilePath();
|
||||
heclPath = QFileInfo(heclPath).absoluteFilePath();
|
||||
|
||||
QString urdeDlPackage, heclDlPackage, visigenDlPackage;
|
||||
if (GetDLPackage(urdePath, urdeDlPackage) &&
|
||||
GetDLPackage(heclPath, heclDlPackage) &&
|
||||
GetDLPackage(visigenPath, visigenDlPackage))
|
||||
{
|
||||
if (!urdeDlPackage.isEmpty() &&
|
||||
urdeDlPackage == heclDlPackage &&
|
||||
urdeDlPackage == visigenDlPackage)
|
||||
{
|
||||
URDEVersion v(urdeDlPackage);
|
||||
m_ui->currentBinaryLabel->setText(v.fileString(false));
|
||||
if (m_recommendedVersion.isValid() && v.isValid() &&
|
||||
m_recommendedVersion.getVersion() > v.getVersion())
|
||||
|
@ -665,30 +832,36 @@ void MainWindow::checkDownloadedBinary()
|
|||
m_updateURDEButton->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("unknown"));
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("unknown... re-download recommended"));
|
||||
}
|
||||
|
||||
enableOperations();
|
||||
m_urdePath = urdePath;
|
||||
m_heclPath = heclPath;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
|
||||
m_ui->heclTabs->setCurrentIndex(1);
|
||||
m_ui->downloadErrorLabel->setText(QStringLiteral("Press 'Download' to fetch latest URDE binary."), true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::setPath(const QString& path)
|
||||
{
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
m_path = path;
|
||||
m_settings.setValue(QStringLiteral("working_dir"), m_path);
|
||||
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
m_ui->pathEdit->setText(m_path);
|
||||
m_ui->extractBtn->setEnabled(true);
|
||||
m_ui->packageBtn->setEnabled(true);
|
||||
m_ui->downloadButton->setToolTip(QString());
|
||||
m_ui->downloadButton->setEnabled(m_ui->binaryComboBox->isEnabled());
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -696,6 +869,8 @@ void MainWindow::setPath(const QString& path)
|
|||
m_ui->downloadButton->setEnabled(false);
|
||||
m_ui->currentBinaryLabel->setText(QStringLiteral("none"));
|
||||
}
|
||||
|
||||
checkDownloadedBinary();
|
||||
}
|
||||
|
||||
void MainWindow::initSlots()
|
||||
|
@ -705,22 +880,13 @@ void MainWindow::initSlots()
|
|||
#endif
|
||||
connect(&m_heclProc, &QProcess::readyRead, [=](){
|
||||
m_ansiString = m_heclProc.readAll();
|
||||
m_ui->processOutput->clear();
|
||||
setTextTermFormatting(m_ui->processOutput, m_ansiString);
|
||||
setTextTermFormatting(m_ansiString);
|
||||
m_ui->processOutput->ensureCursorVisible();
|
||||
});
|
||||
|
||||
connect(m_ui->extractBtn, &QPushButton::clicked, [=](){
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
QString path = QFileInfo(m_path).absolutePath();
|
||||
m_ansiString.clear();
|
||||
m_heclProc.close();
|
||||
m_heclProc.terminate();
|
||||
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
||||
m_heclProc.setWorkingDirectory(path);
|
||||
m_heclProc.start("../hecl/driver/hecl.exe", {"extract", m_path, "-y"});
|
||||
});
|
||||
connect(m_ui->extractBtn, SIGNAL(clicked()), this, SLOT(onExtract()));
|
||||
connect(m_ui->packageBtn, SIGNAL(clicked()), this, SLOT(onPackage()));
|
||||
connect(m_ui->launchBtn, SIGNAL(clicked()), this, SLOT(onLaunch()));
|
||||
|
||||
connect(m_ui->browseBtn, &QPushButton::clicked, [=]() {
|
||||
FileDirDialog dialog(this);
|
||||
|
@ -736,33 +902,53 @@ void MainWindow::initSlots()
|
|||
setPath(dialog.selectedFiles().at(0));
|
||||
});
|
||||
|
||||
connect(m_ui->packageBtn, &QPushButton::clicked, [=](){
|
||||
if (m_path.isEmpty())
|
||||
return;
|
||||
QString projectDir = m_path;
|
||||
if (projectDir.endsWith(".iso", Qt::CaseInsensitive))
|
||||
projectDir.remove(m_path.length() - 4, 4);
|
||||
|
||||
m_ansiString.clear();
|
||||
m_heclProc.close();
|
||||
m_heclProc.terminate();
|
||||
m_heclProc.setWorkingDirectory(projectDir);
|
||||
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
||||
m_heclProc.start("../hecl/driver/hecl.exe", {"package", "-y"});
|
||||
});
|
||||
|
||||
connect(m_ui->downloadButton, SIGNAL(clicked()), this, SLOT(onDownloadPressed()));
|
||||
}
|
||||
|
||||
void MainWindow::setTextTermFormatting(QTextEdit* textEdit, const QString& text)
|
||||
static void ReturnInsert(QTextCursor& cur, const QString& text)
|
||||
{
|
||||
QTextDocument * document = textEdit->document();
|
||||
QStringList list = text.split('\r');
|
||||
if (!list.front().isEmpty())
|
||||
cur.insertText(list.front());
|
||||
if (list.size() > 1)
|
||||
{
|
||||
for (auto it = list.begin() + 1; it != list.end(); ++it)
|
||||
{
|
||||
cur.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||
if (!it->isEmpty())
|
||||
cur.insertText(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ReturnInsert(QTextCursor& cur, const QString& text, const QTextCharFormat& format)
|
||||
{
|
||||
QStringList list = text.split('\r');
|
||||
if (!list.front().isEmpty())
|
||||
cur.insertText(list.front(), format);
|
||||
if (list.size() > 1)
|
||||
{
|
||||
for (auto it = list.begin() + 1; it != list.end(); ++it)
|
||||
{
|
||||
cur.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||
if (!it->isEmpty())
|
||||
cur.insertText(*it, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setTextTermFormatting(const QString& text)
|
||||
{
|
||||
m_inContinueNote = false;
|
||||
|
||||
QTextDocument* document = m_ui->processOutput->document();
|
||||
QRegExp const escapeSequenceExpression(R"(\x1B\[([\d;]+)m)");
|
||||
QTextCursor cursor(document);
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
QTextCharFormat defaultTextCharFormat = cursor.charFormat();
|
||||
cursor.beginEditBlock();
|
||||
int offset = escapeSequenceExpression.indexIn(text);
|
||||
cursor.insertText(text.mid(0, offset));
|
||||
ReturnInsert(cursor, text.mid(0, offset));
|
||||
QTextCharFormat textCharFormat = defaultTextCharFormat;
|
||||
while (!(offset < 0)) {
|
||||
int previousOffset = offset + escapeSequenceExpression.matchedLength();
|
||||
|
@ -776,13 +962,31 @@ void MainWindow::setTextTermFormatting(QTextEdit* textEdit, const QString& text)
|
|||
}
|
||||
offset = escapeSequenceExpression.indexIn(text, previousOffset);
|
||||
if (offset < 0) {
|
||||
cursor.insertText(text.mid(previousOffset), textCharFormat);
|
||||
ReturnInsert(cursor, text.mid(previousOffset), textCharFormat);
|
||||
} else {
|
||||
cursor.insertText(text.mid(previousOffset, offset - previousOffset), textCharFormat);
|
||||
ReturnInsert(cursor, text.mid(previousOffset, offset - previousOffset), textCharFormat);
|
||||
}
|
||||
}
|
||||
cursor.setCharFormat(defaultTextCharFormat);
|
||||
cursor.endEditBlock();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
textEdit->setTextCursor(cursor);
|
||||
m_ui->processOutput->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void MainWindow::insertContinueNote(const QString& text)
|
||||
{
|
||||
if (m_inContinueNote)
|
||||
return;
|
||||
m_inContinueNote = true;
|
||||
|
||||
QTextDocument* document = m_ui->processOutput->document();
|
||||
QTextCursor cursor(document);
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
QTextCharFormat textCharFormat = cursor.charFormat();
|
||||
textCharFormat.setForeground(QColor(0,255,0));
|
||||
cursor.beginEditBlock();
|
||||
cursor.insertText(text + '\n', textCharFormat);
|
||||
cursor.endEditBlock();
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
m_ui->processOutput->setTextCursor(cursor);
|
||||
}
|
||||
|
|
|
@ -20,28 +20,41 @@ class MainWindow : public QMainWindow
|
|||
Ui::MainWindow* m_ui;
|
||||
QString m_ansiString;
|
||||
QString m_path;
|
||||
QString m_urdePath;
|
||||
QString m_heclPath;
|
||||
QProcess m_heclProc;
|
||||
DownloadManager m_dlManager;
|
||||
QSettings m_settings;
|
||||
URDEVersion m_recommendedVersion;
|
||||
QPushButton* m_updateURDEButton;
|
||||
bool m_inContinueNote = false;
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void setTextTermFormatting(QTextEdit* textEdit, QString const & text);
|
||||
void setTextTermFormatting(const QString& text);
|
||||
void insertContinueNote(const QString& text);
|
||||
void parseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharFormat& textCharFormat,
|
||||
const QTextCharFormat& defaultTextCharFormat);
|
||||
private slots:
|
||||
void onExtract();
|
||||
void onExtractFinished(int exitCode);
|
||||
void onPackage();
|
||||
void onPackageFinished(int exitCode);
|
||||
void onLaunch();
|
||||
void onLaunchFinished(int exitCode);
|
||||
void doHECLTerminate();
|
||||
void onReturnPressed();
|
||||
void onDownloadPressed();
|
||||
void onUpdateURDEPressed();
|
||||
private:
|
||||
void checkDownloadedBinary();
|
||||
bool checkDownloadedBinary();
|
||||
void setPath(const QString& path);
|
||||
void initSlots();
|
||||
void onIndexDownloaded(const QStringList& index);
|
||||
void onBinaryDownloaded(const QString& file);
|
||||
void onBinaryFailed(const QString& file);
|
||||
void disableOperations();
|
||||
void enableOperations();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_HPP
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
<item row="1" column="0" colspan="5">
|
||||
<widget class="QTabWidget" name="heclTabs">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="dataTab">
|
||||
<attribute name="title">
|
||||
|
@ -225,22 +225,9 @@
|
|||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Terminal</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Terminal'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
|
@ -350,6 +337,49 @@ p, li { white-space: pre-wrap; }
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>53</red>
|
||||
<green>53</green>
|
||||
<blue>72</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>53</red>
|
||||
<green>53</green>
|
||||
<blue>72</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="52">
|
||||
<red>53</red>
|
||||
<green>53</green>
|
||||
<blue>72</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download</string>
|
||||
</property>
|
||||
|
@ -446,7 +476,7 @@ p, li { white-space: pre-wrap; }
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="downloadErrorLabel">
|
||||
<widget class="ErrorLabel" name="downloadErrorLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
|
@ -616,6 +646,11 @@ p, li { white-space: pre-wrap; }
|
|||
<extends>QTableView</extends>
|
||||
<header>SysReqTableView.hpp</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ErrorLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>ErrorLabel.hpp</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
|
@ -91,7 +91,7 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
|
|||
case 1:
|
||||
return m_cpuSpeed >= 1500;
|
||||
case 2:
|
||||
return m_memorySize >= 0x100000000;
|
||||
return m_memorySize >= 0xC0000000;
|
||||
case 3:
|
||||
#ifdef __APPLE__
|
||||
return m_macosMajor > 10 || m_macosMinor >= 9;
|
||||
|
@ -118,7 +118,7 @@ QVariant SysReqTableModel::data(const QModelIndex& index, int role) const
|
|||
case 1:
|
||||
return QStringLiteral("1.5 GHz");
|
||||
case 2:
|
||||
return QStringLiteral("4 GB");
|
||||
return QStringLiteral("3 GB");
|
||||
case 3:
|
||||
#ifdef __APPLE__
|
||||
return QStringLiteral("macOS 10.9");
|
||||
|
|
Loading…
Reference in New Issue