mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-04 07:47:59 +03:00
Working on the Settings tab: start the importer/wizard
This commit is contained in:
parent
cfe66abbc5
commit
21c406316f
12 changed files with 342 additions and 109 deletions
|
@ -41,14 +41,20 @@ QStringList Config::LauncherSettings::subKeys(const QString &key)
|
|||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
QStringList keys = settings.uniqueKeys();
|
||||
|
||||
qDebug() << keys;
|
||||
|
||||
QRegExp keyRe("(.+)/");
|
||||
|
||||
QStringList result;
|
||||
|
||||
foreach (const QString ¤tKey, keys) {
|
||||
if (keyRe.indexIn(currentKey) != -1) {
|
||||
|
||||
if (keyRe.indexIn(currentKey) != -1)
|
||||
{
|
||||
QString prefixedKey = keyRe.cap(1);
|
||||
if(prefixedKey.startsWith(key)) {
|
||||
|
||||
if(prefixedKey.startsWith(key))
|
||||
{
|
||||
QString subKey = prefixedKey.remove(key);
|
||||
if (!subKey.isEmpty())
|
||||
result.append(subKey);
|
||||
|
|
|
@ -1,23 +1,63 @@
|
|||
#include "processinvoker.hpp"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
Process::ProcessInvoker::ProcessInvoker()
|
||||
Process::ProcessInvoker::ProcessInvoker(QWidget *parent)
|
||||
{
|
||||
mProcess = new QProcess(this);
|
||||
|
||||
mName = QString();
|
||||
mArguments = QStringList();
|
||||
}
|
||||
|
||||
Process::ProcessInvoker::~ProcessInvoker()
|
||||
{
|
||||
}
|
||||
|
||||
//void Process::ProcessInvoker::setProcessName(const QString &name)
|
||||
//{
|
||||
// mName = name;
|
||||
//}
|
||||
|
||||
//void Process::ProcessInvoker::setProcessArguments(const QStringList &arguments)
|
||||
//{
|
||||
// mArguments = arguments;
|
||||
//}
|
||||
|
||||
QProcess* Process::ProcessInvoker::getProcess()
|
||||
{
|
||||
return mProcess;
|
||||
}
|
||||
|
||||
//QString Process::ProcessInvoker::getProcessName()
|
||||
//{
|
||||
// return mName;
|
||||
//}
|
||||
|
||||
//QStringList Process::ProcessInvoker::getProcessArguments()
|
||||
//{
|
||||
// return mArguments;
|
||||
//}
|
||||
|
||||
bool Process::ProcessInvoker::startProcess(const QString &name, const QStringList &arguments, bool detached)
|
||||
{
|
||||
// mProcess = new QProcess(this);
|
||||
|
||||
connect(mProcess, SIGNAL(error(QProcess::ProcessError)),
|
||||
this, SLOT(processError(QProcess::ProcessError)));
|
||||
|
||||
connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||
this, SLOT(processFinished(int,QProcess::ExitStatus)));
|
||||
|
||||
mName = name;
|
||||
mArguments = arguments;
|
||||
|
||||
QString path(name);
|
||||
#ifdef Q_OS_WIN
|
||||
path.append(QLatin1String(".exe"));
|
||||
|
@ -28,7 +68,6 @@ bool Process::ProcessInvoker::startProcess(const QString &name, const QStringLis
|
|||
path.prepend(QLatin1String("./"));
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
QFileInfo info(path);
|
||||
|
||||
if (!info.exists()) {
|
||||
|
@ -57,7 +96,7 @@ bool Process::ProcessInvoker::startProcess(const QString &name, const QStringLis
|
|||
|
||||
// Start the executable
|
||||
if (detached) {
|
||||
if (!process.startDetached(path, arguments)) {
|
||||
if (!mProcess->startDetached(path, arguments)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
|
@ -65,45 +104,79 @@ bool Process::ProcessInvoker::startProcess(const QString &name, const QStringLis
|
|||
msgBox.setText(tr("<html><head/><body><p><b>Could not start %1</b></p> \
|
||||
<p>An error occurred while starting %1.</p> \
|
||||
<p>Press \"Show Details...\" for more information.</p></body></html>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(process.errorString());
|
||||
msgBox.setDetailedText(mProcess->errorString());
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
process.start(path, arguments);
|
||||
if (!process.waitForFinished()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<html><head/><body><p><b>Could not start %1</b></p> \
|
||||
<p>An error occurred while starting %1.</p> \
|
||||
<p>Press \"Show Details...\" for more information.</p></body></html>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(process.errorString());
|
||||
msgBox.exec();
|
||||
mProcess->start(path, arguments);
|
||||
|
||||
return false;
|
||||
}
|
||||
// if (!mProcess->waitForFinished()) {
|
||||
// QMessageBox msgBox;
|
||||
// msgBox.setWindowTitle(tr("Error starting executable"));
|
||||
// msgBox.setIcon(QMessageBox::Critical);
|
||||
// msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
// msgBox.setText(tr("<html><head/><body><p><b>Could not start %1</b></p> \
|
||||
// <p>An error occurred while starting %1.</p> \
|
||||
// <p>Press \"Show Details...\" for more information.</p></body></html>").arg(info.fileName()));
|
||||
// msgBox.setDetailedText(mProcess->errorString());
|
||||
// msgBox.exec();
|
||||
|
||||
if (process.exitCode() != 0 || process.exitStatus() == QProcess::CrashExit) {
|
||||
QString error(process.readAllStandardError());
|
||||
error.append(tr("\nArguments:\n"));
|
||||
error.append(arguments.join(" "));
|
||||
// return false;
|
||||
// }
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error running executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<html><head/><body><p><b>Executable %1 returned an error</b></p> \
|
||||
<p>An error occurred while running %1.</p> \
|
||||
<p>Press \"Show Details...\" for more information.</p></body></html>").arg(info.fileName()));
|
||||
msgBox.setDetailedText(error);
|
||||
msgBox.exec();
|
||||
// if (mProcess->exitCode() != 0 || mProcess->exitStatus() == QProcess::CrashExit) {
|
||||
// QString error(mProcess->readAllStandardError());
|
||||
// error.append(tr("\nArguments:\n"));
|
||||
// error.append(arguments.join(" "));
|
||||
|
||||
return false;
|
||||
}
|
||||
// QMessageBox msgBox;
|
||||
// msgBox.setWindowTitle(tr("Error running executable"));
|
||||
// msgBox.setIcon(QMessageBox::Critical);
|
||||
// msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
// msgBox.setText(tr("<html><head/><body><p><b>Executable %1 returned an error</b></p> \
|
||||
// <p>An error occurred while running %1.</p> \
|
||||
// <p>Press \"Show Details...\" for more information.</p></body></html>").arg(info.fileName()));
|
||||
// msgBox.setDetailedText(error);
|
||||
// msgBox.exec();
|
||||
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void Process::ProcessInvoker::processError(QProcess::ProcessError error)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error running executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<html><head/><body><p><b>Executable %1 returned an error</b></p> \
|
||||
<p>An error occurred while running %1.</p> \
|
||||
<p>Press \"Show Details...\" for more information.</p></body></html>").arg(mName));
|
||||
msgBox.setDetailedText(mProcess->errorString());
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
|
||||
void Process::ProcessInvoker::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
if (exitCode != 0 || exitStatus == QProcess::CrashExit) {
|
||||
QString error(mProcess->readAllStandardError());
|
||||
error.append(tr("\nArguments:\n"));
|
||||
error.append(mArguments.join(" "));
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error running executable"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<html><head/><body><p><b>Executable %1 returned an error</b></p> \
|
||||
<p>An error occurred while running %1.</p> \
|
||||
<p>Press \"Show Details...\" for more information.</p></body></html>").arg(mName));
|
||||
msgBox.setDetailedText(error);
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QProcess>
|
||||
|
||||
namespace Process
|
||||
{
|
||||
|
@ -10,13 +11,32 @@ namespace Process
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
ProcessInvoker();
|
||||
~ProcessInvoker();
|
||||
|
||||
public:
|
||||
|
||||
inline static bool startProcess(const QString &name, bool detached = false) { return startProcess(name, QStringList(), detached); }
|
||||
bool static startProcess(const QString &name, const QStringList &arguments, bool detached = false);
|
||||
ProcessInvoker(QWidget *parent = 0);
|
||||
~ProcessInvoker();
|
||||
|
||||
// void setProcessName(const QString &name);
|
||||
// void setProcessArguments(const QStringList &arguments);
|
||||
|
||||
QProcess* getProcess();
|
||||
// QString getProcessName();
|
||||
// QStringList getProcessArguments();
|
||||
|
||||
// inline bool startProcess(bool detached = false) { return startProcess(mName, mArguments, detached); }
|
||||
inline bool startProcess(const QString &name, bool detached = false) { return startProcess(name, QStringList(), detached); }
|
||||
bool startProcess(const QString &name, const QStringList &arguments, bool detached = false);
|
||||
|
||||
private:
|
||||
QProcess *mProcess;
|
||||
|
||||
QString mName;
|
||||
QStringList mArguments;
|
||||
|
||||
private slots:
|
||||
void processError(QProcess::ProcessError error);
|
||||
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue