Save/Open Session - Prompt user before Open/Save Dialog
This commit is contained in:
parent
8f08fc92c9
commit
93dbe8e118
@ -150,15 +150,6 @@ void MainWindow::on_actionOpenSession_triggered()
|
|||||||
QString errorStr;
|
QString errorStr;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
fileTypes.append("All files (*)");
|
|
||||||
if (fileTypes.size())
|
|
||||||
fileType = fileTypes.at(0);
|
|
||||||
|
|
||||||
fileName = QFileDialog::getOpenFileName(this, tr("Open Session"),
|
|
||||||
dirName, fileTypes.join(";;"), &fileType);
|
|
||||||
if (fileName.isEmpty())
|
|
||||||
goto _exit;
|
|
||||||
|
|
||||||
if (portsWindow->portGroupCount()) {
|
if (portsWindow->portGroupCount()) {
|
||||||
if (QMessageBox::question(this,
|
if (QMessageBox::question(this,
|
||||||
tr("Open Session"),
|
tr("Open Session"),
|
||||||
@ -168,6 +159,15 @@ void MainWindow::on_actionOpenSession_triggered()
|
|||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileTypes.append("All files (*)");
|
||||||
|
if (fileTypes.size())
|
||||||
|
fileType = fileTypes.at(0);
|
||||||
|
|
||||||
|
fileName = QFileDialog::getOpenFileName(this, tr("Open Session"),
|
||||||
|
dirName, fileTypes.join(";;"), &fileType);
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
goto _exit;
|
||||||
|
|
||||||
ret = openSession(fileName, errorStr);
|
ret = openSession(fileName, errorStr);
|
||||||
if (!ret || !errorStr.isEmpty()) {
|
if (!ret || !errorStr.isEmpty()) {
|
||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
@ -198,6 +198,17 @@ void MainWindow::on_actionSaveSession_triggered()
|
|||||||
QString errorStr;
|
QString errorStr;
|
||||||
QFileDialog::Options options;
|
QFileDialog::Options options;
|
||||||
|
|
||||||
|
if (portsWindow->reservedPortCount()) {
|
||||||
|
QString myself = appSettings->value(kUserKey, kUserDefaultValue)
|
||||||
|
.toString();
|
||||||
|
if (QMessageBox::question(this,
|
||||||
|
tr("Save Session"),
|
||||||
|
QString("Some ports are reserved!\n\nOnly ports reserved by %1 will be saved. Proceed?").arg(myself),
|
||||||
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
QMessageBox::No) == QMessageBox::No)
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
// On Mac OS with Native Dialog, getSaveFileName() ignores fileType.
|
// On Mac OS with Native Dialog, getSaveFileName() ignores fileType.
|
||||||
// Although currently there's only one supported file type, we may
|
// Although currently there's only one supported file type, we may
|
||||||
// have more in the future
|
// have more in the future
|
||||||
@ -213,17 +224,6 @@ void MainWindow::on_actionSaveSession_triggered()
|
|||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
||||||
if (portsWindow->reservedPortCount()) {
|
|
||||||
QString myself = appSettings->value(kUserKey, kUserDefaultValue)
|
|
||||||
.toString();
|
|
||||||
if (QMessageBox::question(this,
|
|
||||||
tr("Save Session"),
|
|
||||||
QString("Some ports are reserved!\n\nOnly ports reserved by %1 will be saved. Proceed?").arg(myself),
|
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
|
||||||
QMessageBox::No) == QMessageBox::No)
|
|
||||||
goto _exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!saveSession(fileName, fileType, errorStr))
|
if (!saveSession(fileName, fileType, errorStr))
|
||||||
QMessageBox::critical(this, qApp->applicationName(), errorStr);
|
QMessageBox::critical(this, qApp->applicationName(), errorStr);
|
||||||
else if (!errorStr.isEmpty())
|
else if (!errorStr.isEmpty())
|
||||||
|
Loading…
Reference in New Issue
Block a user