Skip to content

Commit

Permalink
feat: split off the current image in iv into a separate window (#2058)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
  • Loading branch information
antond-weta committed Oct 12, 2023
1 parent 2e1e5f9 commit 7be78fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/iv/imageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ ImageViewer::ImageViewer()
setWindowTitle(tr("Image Viewer"));
resize(m_default_width, m_default_height);
// setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Ignored);

setAttribute(Qt::WA_DeleteOnClose);
}


Expand Down Expand Up @@ -192,6 +194,10 @@ ImageViewer::createActions()
saveSelectionAsAct = new QAction(tr("Save Selection As..."), this);
connect(saveSelectionAsAct, SIGNAL(triggered()), this,
SLOT(saveSelectionAs()));

moveToNewWindowAct = new QAction(tr("Move to new window"), this);
connect(moveToNewWindowAct, SIGNAL(triggered()), this,
SLOT(splitOff()));

printAct = new QAction(tr("&Print..."), this);
printAct->setShortcut(tr("Ctrl+P"));
Expand Down Expand Up @@ -457,6 +463,7 @@ ImageViewer::createMenus()
fileMenu->addAction(saveWindowAsAct);
fileMenu->addAction(saveSelectionAsAct);
fileMenu->addSeparator();
fileMenu->addAction(moveToNewWindowAct);
fileMenu->addAction(printAct);
fileMenu->addAction(deleteCurrentImageAct);
fileMenu->addSeparator();
Expand Down Expand Up @@ -866,7 +873,21 @@ ImageViewer::saveSelectionAs()
this);
}


void
ImageViewer::splitOff()
{
if (m_images.size())
{
ImageViewer* imageViewer = new ImageViewer();

imageViewer->show();
imageViewer->rawcolor(rawcolor());
imageViewer->add_image(m_images[m_current_image]->name());
imageViewer->current_image(0);
imageViewer->raise();
imageViewer->activateWindow();
}
}

void
ImageViewer::updateTitle()
Expand Down
2 changes: 2 additions & 0 deletions src/iv/imageviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ private slots:
void saveAs(); ///< Save As... functionality
void saveWindowAs(); ///< Save As... functionality
void saveSelectionAs(); ///< Save As... functionality
void splitOff(); ///< Split current image off as a new window
void print(); ///< Print current image
void deleteCurrentImage(); ///< Deleting displayed image
void zoomIn(); ///< Zoom in to next power of 2
Expand Down Expand Up @@ -332,6 +333,7 @@ private slots:
static const unsigned int MaxRecentFiles = 10;
QAction* openRecentAct[MaxRecentFiles];
QAction *saveAsAct, *saveWindowAsAct, *saveSelectionAsAct;
QAction* moveToNewWindowAct;
QAction* printAct;
QAction* deleteCurrentImageAct;
QAction* exitAct;
Expand Down

0 comments on commit 7be78fd

Please sign in to comment.