Allow user try open file twice from menu.

--HG--
branch : develop
This commit is contained in:
dismine 2014-11-28 19:55:27 +02:00
parent e25dfbada9
commit eff6143f97
3 changed files with 31 additions and 31 deletions

View File

@ -98,25 +98,16 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
debugdate += QString(":WARNING:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
.arg(context.function).arg(context.category).arg(msg);
messageBox.setIcon(QMessageBox::Warning);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
break;
case QtCriticalMsg:
debugdate += QString(":CRITICAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
.arg(context.function).arg(context.category).arg(msg);
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
break;
case QtFatalMsg:
debugdate += QString(":FATAL:%1(%2)] %3: %4: %5").arg(context.file).arg(context.line)
.arg(context.function).arg(context.category).arg(msg);
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
break;
default:
break;
@ -124,6 +115,15 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
(*qApp->LogFile()) << debugdate << endl;
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
{
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setWindowModality(Qt::ApplicationModal);
messageBox.setModal(true);
messageBox.exec();
}
if (QtFatalMsg == type)
{
abort();

View File

@ -764,7 +764,11 @@ void MainWindow::OpenRecentFile()
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
OpenPattern(action->data().toString());
const QString filePath = action->data().toString();
if (filePath.isEmpty() == false)
{
LoadPattern(filePath);
}
}
}
@ -1406,7 +1410,7 @@ void MainWindow::Open()
}
qCDebug(vMainWindow)<<"Run QFileDialog::getOpenFileName: dir ="<<dir<<".";
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter);
OpenPattern(filePath);
LoadPattern(filePath);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2157,6 +2161,7 @@ void MainWindow::CreateMenus()
AddDocks();
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::AddDocks()
{
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction());
@ -2176,12 +2181,14 @@ void MainWindow::PropertyBrowser()
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::OpenNewValentina(const QString &fileName) const
bool MainWindow::OpenNewValentina(const QString &fileName) const
{
if (this->isWindowModified() || curFile.isEmpty() == false)
{
VApplication::NewValentina(fileName);
return true;
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
@ -2293,7 +2300,17 @@ void MainWindow::LoadPattern(const QString &fileName)
qCDebug(vMainWindow)<<"Loading new file"<<fileName<<".";
//We have unsaved changes or load more then one file per time
OpenNewValentina(fileName);
if (OpenNewValentina(fileName))
{
return;
}
if (fileName.isEmpty())
{
qCDebug(vMainWindow) << "Got empty file.";
Clear();
return;
}
qCDebug(vMainWindow)<<"Loking file";
lock = new QLockFile(fileName+".lock");
@ -2527,22 +2544,6 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Measureme
return path;
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::OpenPattern(const QString &filePath)
{
if (filePath.isEmpty() == false && filePath != curFile)
{
if (curFile.isEmpty() && this->isWindowModified() == false)
{
LoadPattern(filePath);
}
else
{
VApplication::NewValentina(filePath);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ChangePP(int index, bool zoomBestFit)
{

View File

@ -242,7 +242,6 @@ private:
void InitAutoSave();
QString PatternPieceName(const QString &text);
QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType);
void OpenPattern(const QString &filePath);
QComboBox *SetGradationList(const QString &label, const QStringList &list);
void ChangePP(int index, bool zoomBestFit = true);
/**
@ -257,7 +256,7 @@ private:
void AddDocks();
void PropertyBrowser();
void OpenNewValentina(const QString &fileName = QString())const;
bool OpenNewValentina(const QString &fileName = QString())const;
void FileClosedCorrect();
QStringList GetUnlokedRestoreFileList()const;
};