Skip to content

Commit

Permalink
Added File Menu items and fixed large image bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmello committed Aug 26, 2017
1 parent 3d25e56 commit 0a42ea9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
41 changes: 24 additions & 17 deletions src/gui-qt/PixelSortApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,18 @@ PixelSortApp::PixelSortApp(QApplication* parent):
dockwidget.setAllowedAreas(Qt::LeftDockWidgetArea);
dockwidget.setFeatures(QDockWidget::NoDockWidgetFeatures);
dockwidget.setWidget(&dockwidget_mid);


// Set up menubar actions
QAction* openAction = fileMenu.addAction("&Open");
QAction* saveAction = fileMenu.addAction("&Save");
openAction->setShortcuts(QKeySequence::Open);
saveAction->setShortcuts(QKeySequence::Save);

// Set up menubar
menuBar()->addMenu(&fileMenu);
menuBar()->addAction(fileMenu.menuAction());
menuBar()->show();

// add import and export button to vbox
vbox.addWidget(&importbutton);
vbox.addWidget(&exportbutton);
Expand All @@ -77,19 +88,23 @@ PixelSortApp::PixelSortApp(QApplication* parent):
fileimport.setAcceptMode(QFileDialog::AcceptOpen);
fileimport.setNameFilter("Images (*.png *.tiff *.tif)");
fileimport.fileSelected(imageFilePath);
// reload image view after importing
QObject::connect(&fileimport, SIGNAL(fileSelected(QString)), this, SLOT(reloadImage(QString)));

// file export dialog settings
fileexport.setFileMode(QFileDialog::AnyFile);
fileexport.setAcceptMode(QFileDialog::AcceptSave);

// Connect actual import button events
QObject::connect(&importbutton, SIGNAL(clicked()), &fileimport, SLOT(exec()));
QObject::connect(&fileimport, SIGNAL(fileSelected(QString)), this, SLOT(reloadImage(QString)));

// Connect actual export button events
QObject::connect(&exportbutton, SIGNAL(clicked()), &fileexport, SLOT(exec()));
// write image after selecting export filename
QObject::connect(&fileexport, SIGNAL(fileSelected(QString)), this, SLOT(writeImage(QString)));


// Set up openAction and saveAction
QObject::connect(openAction, &QAction::triggered, &fileimport, &QFileDialog::exec);
QObject::connect(saveAction, &QAction::triggered, &fileexport, &QFileDialog::exec);

// Connect import and export button events
QObject::connect(&importbutton, &QPushButton::clicked, openAction, &QAction::trigger);
QObject::connect(&exportbutton, &QPushButton::clicked, saveAction, &QAction::trigger);

// Set up the form layout widget
vbox.addLayout(&formlayout);
formlayout.setLabelAlignment(Qt::AlignCenter);
Expand Down Expand Up @@ -194,14 +209,6 @@ PixelSortApp::PixelSortApp(QApplication* parent):
// vbox.addWidget(&quitbutton);
// QObject::connect(&quitbutton, SIGNAL(clicked()), appPtr, SLOT(quit()));

// Set up menubar
fileMenu.addAction("Item 1");
fileMenu.addAction("Item 2");
menuBar()->addMenu(&fileMenu);
menuBar()->addAction(fileMenu.menuAction());
menuBar()->show();
// menuBar()->setNativeMenuBar(false);

// Read initial image file
imageFilePath = "./pixelsort.app/Contents/resources/lake.png";
img.load(imageFilePath);
Expand Down
2 changes: 2 additions & 0 deletions src/gui-qt/PixelSortApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
#include <QGraphicsView>
#include <QPixmap>
#include <QColor>
#include <QAction>
#include <QGraphicsPixmapItem>

#include <QFileDialog>
#include <QPushButton>
#include <QKeySequence>

// PixelSort includes
#include "PixelSortOptions.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/gui-qt/PixelSortOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ void PixelSortOptions::doSort()
/* Create Xrepeat, Yrepeat parameters */
int Xstart = Xrepeat[0];
int Xpitch = Xrepeat[1];
int Xend = img->columns() < unsigned(Xrepeat[2]) ? img->columns() : Xrepeat[2];
int Xend = img->columns(); // not controllable yet
int Ystart = Yrepeat[0];
int Ypitch = Yrepeat[1];
int Yend = img->rows() < unsigned(Yrepeat[2]) ? img->rows() : Yrepeat[2];
int Yend = img->rows(); // not controllable yet

/*
* Start PixelSorting
Expand Down

0 comments on commit 0a42ea9

Please sign in to comment.