@@ -34,6 +34,8 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
3434 swap_action = new QAction (tr (" &Swap check box Watershed" ), this );
3535 undo_action = new QAction (tr (" &Undo" ), this );
3636 redo_action = new QAction (tr (" &Redo" ), this );
37+ next_file_action = new QAction (tr (" &Select next file" ), this );
38+ previous_file_action = new QAction (tr (" &Select previous file" ), this );
3739 undo_action->setShortcuts (QKeySequence::Undo);
3840 redo_action->setShortcuts (QKeySequence::Redo);
3941 save_action->setShortcut (Qt::CTRL + Qt::Key_S);
@@ -42,6 +44,8 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
4244 paste_mask_action->setShortcut (Qt::CTRL + Qt::Key_V);
4345 clear_mask_action->setShortcut (Qt::CTRL + Qt::Key_R);
4446 close_tab_action->setShortcut (Qt::CTRL + Qt::Key_W);
47+ next_file_action->setShortcut (Qt::CTRL + Qt::SHIFT + Qt::Key_Down);
48+ previous_file_action->setShortcut (Qt::CTRL + Qt::SHIFT + Qt::Key_Up);
4549 undo_action->setEnabled (false );
4650 redo_action->setEnabled (false );
4751
@@ -53,6 +57,8 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
5357 menuEdit->addAction (paste_mask_action);
5458 menuEdit->addAction (clear_mask_action);
5559 menuEdit->addAction (swap_action);
60+ menuEdit->addAction (next_file_action);
61+ menuEdit->addAction (previous_file_action);
5662
5763 tabWidget->clear ();
5864
@@ -64,6 +70,8 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
6470 connect (copy_mask_action , SIGNAL (triggered ()) , this , SLOT (copyMask ()));
6571 connect (paste_mask_action , SIGNAL (triggered ()) , this , SLOT (pasteMask ()));
6672 connect (clear_mask_action , SIGNAL (triggered ()) , this , SLOT (clearMask ()));
73+ connect (next_file_action , SIGNAL (triggered ()) , this , SLOT (nextFile ()));
74+ connect (previous_file_action , SIGNAL (triggered ()) , this , SLOT (previousFile ()));
6775 connect (tabWidget , SIGNAL (tabCloseRequested (int )) , this , SLOT (closeTab (int ) ));
6876 connect (tabWidget , SIGNAL (currentChanged (int )) , this , SLOT (updateConnect (int )));
6977 connect (tree_widget_img , SIGNAL (itemClicked (QTreeWidgetItem *,int )), this , SLOT (treeWidgetClicked ()));
@@ -365,6 +373,23 @@ void MainWindow::on_actionOpenDir_triggered() {
365373 // setWindowTitle("PixelAnnotation - " + openedDir);
366374}
367375
376+ void MainWindow::nextFile () {
377+ QTreeWidgetItem *currentItem = tree_widget_img->currentItem ();
378+ if (!currentItem) return ;
379+ QTreeWidgetItem *nextItem = tree_widget_img->itemBelow (currentItem);
380+ if (!nextItem) return ;
381+ tree_widget_img->setCurrentItem (nextItem);
382+ treeWidgetClicked ();
383+ }
384+
385+ void MainWindow::previousFile () {
386+ QTreeWidgetItem *currentItem = tree_widget_img->currentItem ();
387+ if (!currentItem) return ;
388+ QTreeWidgetItem *previousItem = tree_widget_img->itemAbove (currentItem);
389+ if (!previousItem) return ;
390+ tree_widget_img->setCurrentItem (previousItem);
391+ treeWidgetClicked ();
392+ }
368393
369394void MainWindow::saveConfigFile () {
370395 QString file = QFileDialog::getSaveFileName (this , tr (" Save Config File" ), QString (), tr (" JSon file (*.json)" ));
0 commit comments