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

View File

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

View File

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