Re-Initialize MinetestMapperExecutable after Settings changed
parent
df2f883282
commit
00f9704b86
|
@ -57,13 +57,23 @@ ConfigDialog::~ConfigDialog()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigSettings ConfigDialog::getSettings() const
|
||||||
|
{
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigDialog::setSettings(const ConfigSettings &value)
|
||||||
|
{
|
||||||
|
settings = value;
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigDialog::on_browseMapper_clicked()
|
void ConfigDialog::on_browseMapper_clicked()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString fileType = tr("Executable (*.exe)");
|
QString fileType = tr("Executable (*.exe)");
|
||||||
#else
|
#else
|
||||||
QString fileType;
|
QString fileType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool selectionSeemsOK;
|
bool selectionSeemsOK;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
@ -180,18 +190,11 @@ void ConfigDialog::on_path_Minetestmapper_currentIndexChanged(int index)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ConfigDialog::on_CancelButton_clicked()
|
void ConfigDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
application->closeConfigDialog();
|
QDialogButtonBox::StandardButton b = ui->buttonBox->standardButton(button);
|
||||||
}
|
if(b== QDialogButtonBox::RestoreDefaults)
|
||||||
|
{
|
||||||
void ConfigDialog::on_ApplyButton_clicked()
|
ui->path_Minetestmapper->setCurrentIndex(0);
|
||||||
{
|
}
|
||||||
application->updateConfigSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigDialog::on_OKButton_clicked()
|
|
||||||
{
|
|
||||||
on_ApplyButton_clicked();
|
|
||||||
on_CancelButton_clicked();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,9 @@ public:
|
||||||
explicit ConfigDialog(const ConfigSettings &settings, MainWindow *app, QWidget *parent = 0);
|
explicit ConfigDialog(const ConfigSettings &settings, MainWindow *app, QWidget *parent = 0);
|
||||||
~ConfigDialog();
|
~ConfigDialog();
|
||||||
|
|
||||||
|
ConfigSettings getSettings() const;
|
||||||
|
void setSettings(const ConfigSettings &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConfigDialog *ui;
|
Ui::ConfigDialog *ui;
|
||||||
QStringList executableList;
|
QStringList executableList;
|
||||||
|
@ -50,10 +53,7 @@ private slots:
|
||||||
void on_browseMapper_clicked();
|
void on_browseMapper_clicked();
|
||||||
|
|
||||||
void on_path_Minetestmapper_currentIndexChanged(int index);
|
void on_path_Minetestmapper_currentIndexChanged(int index);
|
||||||
|
void on_buttonBox_clicked(QAbstractButton *button);
|
||||||
void on_CancelButton_clicked();
|
|
||||||
void on_ApplyButton_clicked();
|
|
||||||
void on_OKButton_clicked();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGDIALOG_H
|
#endif // CONFIGDIALOG_H
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>483</width>
|
<width>483</width>
|
||||||
<height>73</height>
|
<height>86</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -31,44 +31,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="CancelButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="ApplyButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Apply</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="OKButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>OK</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="path_Minetestmapper">
|
<widget class="QComboBox" name="path_Minetestmapper">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -90,12 +52,59 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mapper Location: </string>
|
<string>Mapper Location: </string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>path_Minetestmapper</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>path_Minetestmapper</tabstop>
|
||||||
|
<tabstop>browseMapper</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="minetestmappergui.qrc"/>
|
<include location="minetestmappergui.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>ConfigDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>298</x>
|
||||||
|
<y>60</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>270</x>
|
||||||
|
<y>81</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>ConfigDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>386</x>
|
||||||
|
<y>68</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>422</x>
|
||||||
|
<y>78</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -37,8 +37,7 @@ InitStatics::InitStatics(void)
|
||||||
|
|
||||||
MainWindow::MainWindow(bool portable, QWidget *parent) :
|
MainWindow::MainWindow(bool portable, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow)
|
||||||
configDialog(NULL)
|
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (!migrateSettingsProfiles())
|
if (!migrateSettingsProfiles())
|
||||||
|
@ -284,10 +283,6 @@ void MainWindow::changeEvent(QEvent* event)
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
if (configDialog) {
|
|
||||||
delete configDialog;
|
|
||||||
configDialog = NULL;
|
|
||||||
}
|
|
||||||
minetestMapper->cancel();
|
minetestMapper->cancel();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
@ -1127,33 +1122,19 @@ void MainWindow::on_tileorigin_clicked()
|
||||||
|
|
||||||
void MainWindow::on_actionPreferences_triggered()
|
void MainWindow::on_actionPreferences_triggered()
|
||||||
{
|
{
|
||||||
if (!configDialog) {
|
ConfigDialog *d = new ConfigDialog(currentSettings, this, this);
|
||||||
configDialog = new ConfigDialog(currentSettings, this, this);
|
int ret = d->exec();
|
||||||
configDialog->show();
|
if(ret == ConfigDialog::Accepted)
|
||||||
} else {
|
{
|
||||||
configDialog->show();
|
|
||||||
configDialog->activateWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::closeConfigDialog(void)
|
|
||||||
{
|
|
||||||
if (configDialog) {
|
|
||||||
delete configDialog;
|
|
||||||
configDialog = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::updateConfigSettings(const ConfigSettings &newSettings)
|
|
||||||
{
|
|
||||||
if (newSettings.mapperPath != currentSettings.mapperPath) {
|
|
||||||
// Update all 'auto' paths (colors files, ...) ???
|
// Update all 'auto' paths (colors files, ...) ???
|
||||||
// (currently there are none, but in the future,
|
// (currently there are none, but in the future,
|
||||||
// colors files could be searched for relative to the minetestmapper path.
|
// colors files could be searched for relative to the minetestmapper path.
|
||||||
// If the mapper path changes, the paths of the possible colors files
|
// If the mapper path changes, the paths of the possible colors files
|
||||||
// may change as well
|
// may change as well
|
||||||
|
currentSettings = d->getSettings();
|
||||||
|
minetestMapper->setExecutableFile(currentSettings.mapperPath);
|
||||||
|
minetestMapper->init();
|
||||||
}
|
}
|
||||||
currentSettings = newSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::startColorsTxtAssistant(void)
|
void MainWindow::startColorsTxtAssistant(void)
|
||||||
|
|
|
@ -41,10 +41,6 @@ public:
|
||||||
explicit MainWindow(bool portable, QWidget *parent = 0);
|
explicit MainWindow(bool portable, QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
// Interaction with config dialog
|
|
||||||
void closeConfigDialog(void);
|
|
||||||
void updateConfigSettings(const ConfigSettings &newSettings);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void startColorsTxtAssistant();
|
void startColorsTxtAssistant();
|
||||||
protected:
|
protected:
|
||||||
|
@ -131,7 +127,6 @@ private:
|
||||||
QWinTaskbarProgress *taskbarProgress;
|
QWinTaskbarProgress *taskbarProgress;
|
||||||
#endif
|
#endif
|
||||||
ConfigSettings currentSettings;
|
ConfigSettings currentSettings;
|
||||||
ConfigDialog *configDialog;
|
|
||||||
|
|
||||||
void finishUiInitialisation(void);
|
void finishUiInitialisation(void);
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,21 @@
|
||||||
MinetestMapperExe::MinetestMapperExe(const QString &program, QObject *parent) : QObject(parent)
|
MinetestMapperExe::MinetestMapperExe(const QString &program, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
minetestMapperExecutableFile = program;
|
setExecutableFile(program);
|
||||||
process->setProgram(program);
|
|
||||||
connect(process, SIGNAL(errorOccurred(QProcess::ProcessError)),
|
connect(process, SIGNAL(errorOccurred(QProcess::ProcessError)),
|
||||||
this, SLOT(errorOccured(QProcess::ProcessError)));
|
this, SLOT(errorOccured(QProcess::ProcessError)));
|
||||||
|
connect(process, SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||||
|
this, SLOT(finished(int,QProcess::ExitStatus)));
|
||||||
|
connect(process, SIGNAL(readyReadStandardOutput()),
|
||||||
|
this, SLOT(readStandardOutput()));
|
||||||
|
connect(process, SIGNAL(readyReadStandardError()),
|
||||||
|
this, SLOT(readStandardError()));
|
||||||
|
}
|
||||||
|
void MinetestMapperExe::setExecutableFile(const QString &program)
|
||||||
|
{
|
||||||
|
state = Uninitialized;
|
||||||
|
minetestMapperExecutableFile = program;
|
||||||
|
process->setProgram(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MinetestMapperExe::getSupportedBackends() const
|
QStringList MinetestMapperExe::getSupportedBackends() const
|
||||||
|
@ -53,8 +63,7 @@ bool MinetestMapperExe::init(){
|
||||||
{
|
{
|
||||||
emit busyStateChanged(true);
|
emit busyStateChanged(true);
|
||||||
emit progressRangeChanged(0, 0);
|
emit progressRangeChanged(0, 0);
|
||||||
connect(process, SIGNAL(finished(int,QProcess::ExitStatus)),
|
|
||||||
this, SLOT(finished(int,QProcess::ExitStatus)));
|
|
||||||
state = InitVersion;
|
state = InitVersion;
|
||||||
emit stateChanged("Init Version...");
|
emit stateChanged("Init Version...");
|
||||||
process->setArguments(QStringList("--version"));
|
process->setArguments(QStringList("--version"));
|
||||||
|
@ -159,48 +168,47 @@ bool MinetestMapperExe::initHelp()
|
||||||
void MinetestMapperExe::readStandardOutput(void)
|
void MinetestMapperExe::readStandardOutput(void)
|
||||||
{
|
{
|
||||||
static const QRegularExpression re("([0-9]{1,3})(\\%)");
|
static const QRegularExpression re("([0-9]{1,3})(\\%)");
|
||||||
QByteArray outData = process->readAllStandardOutput();
|
if(state == MappingStart || state == MappingProgress || state == MappingEnd) {
|
||||||
QString out = QString(outData).trimmed();
|
QByteArray outData = process->readAllStandardOutput();
|
||||||
if(!out.isEmpty()) {
|
QString out = QString(outData).trimmed();
|
||||||
QRegularExpressionMatch match = re.match(out);
|
if(!out.isEmpty()) {
|
||||||
if(match.hasMatch()){
|
QRegularExpressionMatch match = re.match(out);
|
||||||
if(state == MappingStart)
|
if(match.hasMatch()){
|
||||||
{
|
if(state == MappingStart)
|
||||||
state = MappingProgress;
|
{
|
||||||
emit progressRangeChanged(0, 100);
|
state = MappingProgress;
|
||||||
|
emit progressRangeChanged(0, 100);
|
||||||
|
}
|
||||||
|
int percent = match.captured(1).toInt(); // percent == number
|
||||||
|
emit progressChanged(percent);
|
||||||
}
|
}
|
||||||
int percent = match.captured(1).toInt(); // percent == number
|
else {
|
||||||
emit progressChanged(percent);
|
if(state == MappingProgress)
|
||||||
}
|
{
|
||||||
else {
|
|
||||||
if(state == MappingProgress)
|
|
||||||
{
|
|
||||||
|
|
||||||
state = MappingEnd;
|
state = MappingEnd;
|
||||||
emit progressRangeChanged(0, 0);
|
emit progressRangeChanged(0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
emit stateChanged(out);
|
||||||
|
emit mappingStandardOutput(out);
|
||||||
}
|
}
|
||||||
emit stateChanged(out);
|
|
||||||
emit mappingStandardOutput(out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinetestMapperExe::readStandardError()
|
void MinetestMapperExe::readStandardError()
|
||||||
{
|
{
|
||||||
const QByteArray outData = process->readAllStandardError();
|
if(state == MappingStart || state == MappingProgress || state == MappingEnd) {
|
||||||
if(outData.length() >1) {
|
const QByteArray outData = process->readAllStandardError();
|
||||||
const QString out = QString(outData).trimmed();
|
if(outData.length() >1) {
|
||||||
emit mappingStandardError(out);
|
const QString out = QString(outData).trimmed();
|
||||||
}
|
emit mappingStandardError(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinetestMapperExe::finishInitialization()
|
void MinetestMapperExe::finishInitialization()
|
||||||
{
|
{
|
||||||
connect(process, SIGNAL(readyReadStandardOutput()),
|
|
||||||
this, SLOT(readStandardOutput()));
|
|
||||||
connect(process, SIGNAL(readyReadStandardError()),
|
|
||||||
this, SLOT(readStandardError()));
|
|
||||||
|
|
||||||
emit initialisationFinished(true);
|
emit initialisationFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
Tree getTree(void) const;
|
Tree getTree(void) const;
|
||||||
QString getTreeString(void) const;
|
QString getTreeString(void) const;
|
||||||
|
|
||||||
|
void setExecutableFile(const QString &program);
|
||||||
signals:
|
signals:
|
||||||
void stateChanged(const QString &str);
|
void stateChanged(const QString &str);
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue