|
@@ -26,7 +26,7 @@ MainWindow::MainWindow ()
|
|
|
directoryname = NULL;
|
|
|
suffix = NULL;
|
|
|
filenames = NULL;
|
|
|
- autoLoad = false;
|
|
|
+ autoLoad = true;
|
|
|
|
|
|
setWindowTitle (tr ("DSL - Draw Strength Line"));
|
|
|
|
|
@@ -45,40 +45,42 @@ MainWindow::MainWindow ()
|
|
|
void
|
|
|
MainWindow::openFile ()
|
|
|
{
|
|
|
- QString filename = QFileDialog::getOpenFileName (this,
|
|
|
- QObject::tr ("Open image file"),
|
|
|
- QDir::currentPath (),
|
|
|
- QObject::tr("Images files (*.jpg *.png);;All files (*.*)"));
|
|
|
+ if(this->checkModificationinProgress() == QMessageBox::Yes){
|
|
|
+ QString filename = QFileDialog::getOpenFileName (this,
|
|
|
+ QObject::tr ("Open image file"),
|
|
|
+ QDir::currentPath (),
|
|
|
+ QObject::tr("Images files (*.jpg *.png);;All files (*.*)"));
|
|
|
|
|
|
- if(!filename.isEmpty()) {
|
|
|
+ if(!filename.isEmpty()) {
|
|
|
|
|
|
- directoryname = new QString(QString(filename).remove(QUrl(filename).fileName()));
|
|
|
+ directoryname = new QString(QString(filename).remove(QUrl(filename).fileName()));
|
|
|
|
|
|
- bool ok;
|
|
|
- suffix = new QString(QInputDialog::getText(this, tr("Suffix for your json files"),
|
|
|
- tr("Suffix to use :"), QLineEdit::Normal,
|
|
|
- "_"+QDir::home().dirName(), &ok));
|
|
|
-
|
|
|
- if(ok)
|
|
|
- {
|
|
|
- delete filenames;
|
|
|
- filenames = new QStringList();
|
|
|
+ bool ok;
|
|
|
+ suffix = new QString(QInputDialog::getText(this, tr("Suffix for your json files"),
|
|
|
+ tr("Suffix to use :"), QLineEdit::Normal,
|
|
|
+ "_"+QDir::home().dirName(), &ok));
|
|
|
+
|
|
|
+ if(ok)
|
|
|
+ {
|
|
|
+ delete filenames;
|
|
|
+ filenames = new QStringList();
|
|
|
|
|
|
- QDirIterator it(*directoryname, {"*.jpg", "*.png"}, QDir::Files);
|
|
|
- while (it.hasNext()) {
|
|
|
- filenames->append( it.next() );
|
|
|
- }
|
|
|
- filenames->sort();
|
|
|
-
|
|
|
- for(int i = 0; i <filenames->size() ; i++)
|
|
|
- {
|
|
|
- if(filename == (filenames->at(i)))
|
|
|
- openedImage = i;
|
|
|
+ QDirIterator it(*directoryname, {"*.jpg", "*.png"}, QDir::Files);
|
|
|
+ while (it.hasNext()) {
|
|
|
+ filenames->append( it.next() );
|
|
|
}
|
|
|
-
|
|
|
- QDir::setCurrent(*directoryname);
|
|
|
- loadImage();
|
|
|
- }
|
|
|
+ filenames->sort();
|
|
|
+
|
|
|
+ for(int i = 0; i <filenames->size() ; i++)
|
|
|
+ {
|
|
|
+ if(filename == (filenames->at(i)))
|
|
|
+ openedImage = i;
|
|
|
+ }
|
|
|
+
|
|
|
+ QDir::setCurrent(*directoryname);
|
|
|
+ loadImage();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -94,6 +96,7 @@ MainWindow::loadImage()
|
|
|
}
|
|
|
}
|
|
|
wa->repaint();
|
|
|
+ wa->setModificationInProgress(false);
|
|
|
setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
|
|
|
}
|
|
|
|
|
@@ -104,40 +107,56 @@ MainWindow::save ()
|
|
|
wa->saveStrengthLine (toSave.toStdString ());
|
|
|
}
|
|
|
|
|
|
+QMessageBox::StandardButton
|
|
|
+MainWindow::checkModificationinProgress()
|
|
|
+{
|
|
|
+ if(wa->getModificationInProgress())
|
|
|
+ return QMessageBox::question(this, "Modification in progress", "Do you really want to change the image ? Modifications in progress will be lost.");
|
|
|
+ return QMessageBox::Yes;
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
MainWindow::firstImage ()
|
|
|
{
|
|
|
- if(filenames->size() > 1){
|
|
|
- openedImage = 0;
|
|
|
- loadImage();
|
|
|
- }
|
|
|
+ if(this->checkModificationinProgress() == QMessageBox::Yes)
|
|
|
+ if(filenames != NULL)
|
|
|
+ if(filenames->size() > 1){
|
|
|
+ openedImage = 0;
|
|
|
+ loadImage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void
|
|
|
MainWindow::previousImage ()
|
|
|
{
|
|
|
- if(filenames->size() > 1){
|
|
|
- openedImage = (openedImage-1+filenames->size())%(filenames->size());
|
|
|
- loadImage();
|
|
|
- }
|
|
|
+ if(this->checkModificationinProgress() == QMessageBox::Yes)
|
|
|
+ if(filenames != NULL)
|
|
|
+ if(filenames->size() > 1){
|
|
|
+ openedImage = (openedImage-1+filenames->size())%(filenames->size());
|
|
|
+ loadImage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void
|
|
|
MainWindow::nextImage ()
|
|
|
{
|
|
|
- if(filenames->size() > 1){
|
|
|
- openedImage = (openedImage+1)%(filenames->size());
|
|
|
- loadImage();
|
|
|
- }
|
|
|
+ if(this->checkModificationinProgress() == QMessageBox::Yes)
|
|
|
+ if(filenames != NULL)
|
|
|
+ if(filenames->size() > 1){
|
|
|
+ openedImage = (openedImage+1)%(filenames->size());
|
|
|
+ loadImage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void
|
|
|
MainWindow::lastImage ()
|
|
|
{
|
|
|
- if(filenames->size() > 1){
|
|
|
- openedImage = filenames->size()-1;
|
|
|
- loadImage();
|
|
|
- }
|
|
|
+ if(this->checkModificationinProgress() == QMessageBox::Yes)
|
|
|
+ if(filenames != NULL)
|
|
|
+ if(filenames->size() > 1){
|
|
|
+ openedImage = filenames->size()-1;
|
|
|
+ loadImage();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -180,6 +199,7 @@ MainWindow::createActions ()
|
|
|
automaticLoadingAct = new QAction (tr ("Automatic &Loading Line json file"), this);
|
|
|
automaticLoadingAct->setShortcut (QKeySequence(Qt::CTRL | Qt::Key_L));
|
|
|
automaticLoadingAct->setCheckable(true);
|
|
|
+ automaticLoadingAct->setChecked(true);
|
|
|
connect (automaticLoadingAct, &QAction::triggered, this, &MainWindow::automaticLoading);
|
|
|
|
|
|
readOnlyAct = new QAction (tr ("&Read Only"), this);
|