Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split off the current image in iv into a separate window (#2058) #4017

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading