android state handling improved
This commit is contained in:
parent
99e04b843e
commit
aa7af3efb7
|
@ -109,6 +109,7 @@ public slots:
|
|||
void restartApp();
|
||||
void on_actionOpenProject_triggered();
|
||||
void on_actionNewProject_triggered();
|
||||
void saveStateBeforeExit();
|
||||
private slots:
|
||||
void on_actionOpenFile_triggered();
|
||||
void on_actionNewFile_triggered();
|
||||
|
|
|
@ -721,6 +721,12 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
return;
|
||||
}
|
||||
emit disableWorker();
|
||||
saveStateBeforeExit();
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::saveStateBeforeExit()
|
||||
{
|
||||
// save project
|
||||
project->save(editorTabs->getOpenTabFiles(), editorTabs->getOpenTabLines(), editorTabs->getCurrentTabIndex(), ui->todoEdit->toPlainText());
|
||||
if (Settings::get("devpack_install_silent") == "no") {
|
||||
|
@ -736,7 +742,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
if (args.length() <= 1) {
|
||||
windowSettings.setValue("project_path", project->getPath());
|
||||
}
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::menuEditOnShow()
|
||||
|
@ -3074,7 +3079,7 @@ void MainWindow::applicationStateChanged(Qt::ApplicationState state)
|
|||
if (progressInfo->isVisible()) {
|
||||
emit progressInfo->cancelTriggered();
|
||||
}
|
||||
Settings::save();
|
||||
saveStateBeforeExit();
|
||||
suspended = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QCoreApplication>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include "helper.h"
|
||||
#include "project.h"
|
||||
#include "servers.h"
|
||||
|
@ -44,6 +45,12 @@ ParserWorker::ParserWorker(QObject *parent) : QObject(parent){
|
|||
wantStop = false;
|
||||
phpWebServerPid = 0;
|
||||
init();
|
||||
|
||||
QSettings windowSettings;
|
||||
if (windowSettings.allKeys().size() > 0 && windowSettings.contains("php_webserver_pid")) {
|
||||
int _phpWebServerPid = windowSettings.value("php_webserver_pid").toInt();
|
||||
if (_phpWebServerPid > 0) phpWebServerPid = _phpWebServerPid;
|
||||
}
|
||||
}
|
||||
|
||||
void ParserWorker::init()
|
||||
|
@ -238,7 +245,9 @@ void ParserWorker::startPHPWebServer(QString path)
|
|||
return;
|
||||
}
|
||||
if (path.size() == 0 || !Helper::folderExists(path)) return;
|
||||
if (phpWebServerPid != 0) return;
|
||||
if (phpWebServerPid != 0) {
|
||||
stopPHPWebServer();
|
||||
}
|
||||
QProcess process(this);
|
||||
process.setWorkingDirectory(path);
|
||||
process.setProgram(phpPath);
|
||||
|
@ -246,6 +255,8 @@ void ParserWorker::startPHPWebServer(QString path)
|
|||
process.setStandardOutputFile(QProcess::nullDevice());
|
||||
process.setStandardErrorFile(QProcess::nullDevice());
|
||||
if (process.startDetached(&phpWebServerPid)) {
|
||||
QSettings windowSettings;
|
||||
windowSettings.setValue("php_webserver_pid", QVariant(phpWebServerPid));
|
||||
emit execPHPWebServerFinished(true, tr("PHP web-server started.")+"\n"+tr("Document root: %1").arg(path)+"\n"+tr("URL address: %1").arg("http://" + PHP_WEBSERVER_URI));
|
||||
} else {
|
||||
emit execPHPWebServerFinished(false, tr("Could not start PHP web-server."));
|
||||
|
@ -257,6 +268,8 @@ void ParserWorker::stopPHPWebServer()
|
|||
if (phpWebServerPid == 0) return;
|
||||
if (QProcess::startDetached("kill", {QString::number(phpWebServerPid)})) {
|
||||
phpWebServerPid = 0;
|
||||
QSettings windowSettings;
|
||||
windowSettings.remove("php_webserver_pid");
|
||||
// success = false (do not want browser to be opened)
|
||||
emit execPHPWebServerFinished(false, tr("PHP web-server stopped."));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue