|
@@ -26,6 +26,7 @@ MainWindow::MainWindow ()
|
|
|
directoryname = NULL;
|
|
|
suffix = NULL;
|
|
|
filenames = NULL;
|
|
|
+ autoLoad = false;
|
|
|
|
|
|
setWindowTitle (tr ("DSL - Draw Strength Line"));
|
|
|
|
|
@@ -35,7 +36,7 @@ MainWindow::MainWindow ()
|
|
|
int screenHeight = screenGeometry.height () - 200;
|
|
|
|
|
|
wa = new WorkArea (screenWidth, screenHeight, this);
|
|
|
-
|
|
|
+ wa->setReadOnly(false);
|
|
|
setCentralWidget (wa);
|
|
|
|
|
|
setFixedSize (screenWidth, screenHeight);
|
|
@@ -76,13 +77,26 @@ MainWindow::openFile ()
|
|
|
}
|
|
|
|
|
|
QDir::setCurrent(*directoryname);
|
|
|
- wa->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
- wa->repaint();
|
|
|
- setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
|
|
|
+ loadImage();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+MainWindow::loadImage()
|
|
|
+{
|
|
|
+ wa->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
+ if(autoLoad)
|
|
|
+ {
|
|
|
+ QString jsonFile(QDir::currentPath ().append("/").append(QFileInfo(filenames->at(openedImage)).baseName().append(*suffix).append(".json")));
|
|
|
+ if(QFile(jsonFile).exists()){
|
|
|
+ wa->loadSL(QDir::currentPath ().append("/").append(QFileInfo(filenames->at(openedImage)).baseName().append(*suffix).append(".json")).toStdString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wa->repaint();
|
|
|
+ setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
MainWindow::save ()
|
|
|
{
|
|
@@ -127,11 +141,24 @@ MainWindow::lastImage ()
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-MainWindow::loadImage()
|
|
|
+MainWindow::automaticLoading ()
|
|
|
{
|
|
|
- wa->loadImage (filenames->at(openedImage).toStdString ());
|
|
|
+ autoLoad = !autoLoad;
|
|
|
+ automaticLoadingAct->setChecked(!autoLoad);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void
|
|
|
+MainWindow::readOnly ()
|
|
|
+{
|
|
|
+ if(wa->getReadOnly()){
|
|
|
+ wa->setReadOnly(false);
|
|
|
+ readOnlyAct->setText(tr ("W&ritable"));
|
|
|
+ }else{
|
|
|
+ wa->setReadOnly(true);
|
|
|
+ readOnlyAct->setText(tr ("&Read Only"));
|
|
|
+ }
|
|
|
wa->repaint();
|
|
|
- setFixedSize (wa->geometry().width(), wa->geometry().height()+wa->geometry().y());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -150,6 +177,15 @@ MainWindow::createActions ()
|
|
|
exitAct->setShortcuts (QKeySequence::Quit);
|
|
|
connect (exitAct, &QAction::triggered, this, &QWidget::close);
|
|
|
|
|
|
+ automaticLoadingAct = new QAction (tr ("Automatic &Loading Line json file"), this);
|
|
|
+ automaticLoadingAct->setShortcut (QKeySequence(Qt::CTRL | Qt::Key_L));
|
|
|
+ automaticLoadingAct->setCheckable(true);
|
|
|
+ connect (automaticLoadingAct, &QAction::triggered, this, &MainWindow::automaticLoading);
|
|
|
+
|
|
|
+ readOnlyAct = new QAction (tr ("&Read Only"), this);
|
|
|
+ readOnlyAct->setShortcut (QKeySequence(Qt::CTRL | Qt::Key_R));
|
|
|
+ connect (readOnlyAct, &QAction::triggered, this, &MainWindow::readOnly);
|
|
|
+
|
|
|
firstImageAct = new QAction (tr ("First"), this);
|
|
|
firstImageAct->setShortcuts (QKeySequence::MoveToPreviousLine);
|
|
|
connect (firstImageAct, &QAction::triggered, this, &MainWindow::firstImage);
|
|
@@ -178,6 +214,10 @@ MainWindow::createMenus ()
|
|
|
|
|
|
fileMenu->addAction (exitAct);
|
|
|
|
|
|
+ editMenu = menuBar()->addMenu(tr("&Edit"));
|
|
|
+ editMenu->addAction (automaticLoadingAct);
|
|
|
+ editMenu->addAction (readOnlyAct);
|
|
|
+
|
|
|
imageMenu = menuBar ()->addMenu (tr ("&Image"));
|
|
|
imageMenu->addAction (firstImageAct);
|
|
|
imageMenu->addAction (previousImageAct);
|