Skip to content

Commit

Permalink
feat(iv): split off the current image in iv into a separate window (#…
Browse files Browse the repository at this point in the history
…4017)

This change adds a menu item "Move to new window" under the menu "File" which
creates a new window and initialises it with the currently displayed
image.

I have tested the UI changes on Mac and linux, I don't have a Windows
machine currently.
No other functionality should be affected by this change.

This was one item from issue #2058 

---------

Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
  • Loading branch information
antond-weta authored Oct 19, 2023
1 parent 7315db8 commit e51dd5c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 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 @@ -193,6 +195,10 @@ ImageViewer::createActions()
connect(saveSelectionAsAct, SIGNAL(triggered()), this,
SLOT(saveSelectionAs()));

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

printAct = new QAction(tr("&Print..."), this);
printAct->setShortcut(tr("Ctrl+P"));
printAct->setEnabled(false);
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,20 @@ ImageViewer::saveSelectionAs()
this);
}

void
ImageViewer::moveToNewWindow()
{
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 moveToNewWindow(); ///< 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 e51dd5c

Please sign in to comment.