convert default_dir to be a shared_ptr and then pass it around
all of our windows that need to save things. Pretty much now
whenever someone saves something we'll remember that last directory
and use it as our default dir.
I hope this works on windows, if it breaks, there
might be a few fs::natives that are needed.
-ImageSaveDialog::ImageSaveDialog(QGLWidget *newglwidget, QWidget *parent)
- : QDialog(parent)
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
+
+ImageSaveDialog::ImageSaveDialog(boost::shared_ptr<QDir> default_dir_,
+ QGLWidget *newglwidget,
+ QWidget *parent)
+ : QDialog(parent),
+ default_dir(default_dir_)
{
setWindowTitle(tr("Mussa Save Image"));
{
setWindowTitle(tr("Mussa Save Image"));
+QDir ImageSaveDialog::defaultDir() const
+{
+ return *default_dir;
+}
+
void ImageSaveDialog::accept()
{
bool endDialog = true;
void ImageSaveDialog::accept()
{
bool endDialog = true;
QString filePath;
filePath = QFileDialog::getSaveFileName(this,
"Choose a filename to save image",
QString filePath;
filePath = QFileDialog::getSaveFileName(this,
"Choose a filename to save image",
+ default_dir->absolutePath(),
"Images (*.png *.jpg)");
if (filePath.isNull()) {
"Images (*.png *.jpg)");
if (filePath.isNull()) {
filePath.append(".png");
pixmap.save(filePath, "PNG");
}
filePath.append(".png");
pixmap.save(filePath, "PNG");
}
+ fs::path path(filePath.toStdString(), fs::native);
+ default_dir->setPath(path.branch_path().native_directory_string().c_str());
#ifndef _IMAGESAVEDIALOG_H_
#define _IMAGESAVEDIALOG_H_
#ifndef _IMAGESAVEDIALOG_H_
#define _IMAGESAVEDIALOG_H_
+
+#include <boost/shared_ptr.hpp>
class ImageScaler;
class QLabel;
class ImageScaler;
class QLabel;
- ImageSaveDialog(QGLWidget *qlwidget = 0, QWidget *parent = 0);
-
+ ImageSaveDialog(boost::shared_ptr<QDir> default_dir_, QGLWidget *qlwidget = 0, QWidget *parent = 0);
+ QDir defaultDir() const;
+
public slots:
void accept();
void reject();
public slots:
void accept();
void reject();
void savePixmap(bool &endDialog);
QSize getOpenGlPixmapSize();
QPixmap renderOpenGlPixmap();
void savePixmap(bool &endDialog);
QSize getOpenGlPixmapSize();
QPixmap renderOpenGlPixmap();
+
+ boost::shared_ptr<QDir> default_dir;
ImageScaler *imageScaler;
QPushButton *saveButton;
QPushButton *cancelButton;
ImageScaler *imageScaler;
QPushButton *saveButton;
QPushButton *cancelButton;
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
-MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
+MussaAlignedWindow::MussaAlignedWindow(MussaRef m,
+ boost::shared_ptr<QDir> default_dir_,
const set<int>& sel_paths,
SubanalysisWindowRef window,
QWidget *parent)
: QMainWindow(parent),
analysis(m),
const set<int>& sel_paths,
SubanalysisWindowRef window,
QWidget *parent)
: QMainWindow(parent),
analysis(m),
+ default_dir(default_dir_),
subanalysis_window(window),
subanalysis_window(window),
pick_align_menu(tr("Choose Alignment")),
view_align_menu(tr("View Alignment")),
threshold_widget(0),
pick_align_menu(tr("Choose Alignment")),
view_align_menu(tr("View Alignment")),
threshold_widget(0),
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <QMainWindow>
#include <QMenu>
#include <QToolBar>
#include <QMainWindow>
#include <QMenu>
#include <QToolBar>
* sequence portions from both the mussa window and the sequence view window
* \param parent is the typical Qt pointer to a parent widget
*/
* sequence portions from both the mussa window and the sequence view window
* \param parent is the typical Qt pointer to a parent widget
*/
- MussaAlignedWindow(MussaRef analysis, const std::set<int>& paths,
+ MussaAlignedWindow(MussaRef analysis,
+ boost::shared_ptr<QDir> default_dir,
+ const std::set<int>& paths,
SubanalysisWindowRef window, QWidget *parent=0);
public slots:
SubanalysisWindowRef window, QWidget *parent=0);
public slots:
void setupAlignmentMenus();
void computeMatchLines();
void setupAlignmentMenus();
void computeMatchLines();
+ MussaRef analysis;
+ boost::shared_ptr<QDir> default_dir;
//std::vector<Sequence> sequences;
//const std::set<int>& selected_paths;
std::vector<ConservedPath> selected_paths;
//std::vector<Sequence> sequences;
//const std::set<int>& selected_paths;
std::vector<ConservedPath> selected_paths;
MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
QMainWindow(parent),
analysis(analysis_),
MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
QMainWindow(parent),
analysis(analysis_),
- default_dir(QDir::home().absolutePath()),
+ default_dir(new QDir(QDir::home().absolutePath())),
motif_editor(0),
setup_analysis_dialog(new MussaSetupDialog(this)),
subanalysis_window(new SubanalysisWindow(analysis)),
motif_editor(0),
setup_analysis_dialog(new MussaSetupDialog(this)),
subanalysis_window(new SubanalysisWindow(analysis)),
- browser(new SequenceBrowserWidget(this)),
+ browser(new SequenceBrowserWidget(default_dir, this)),
mussaViewTB(new QToolBar("Path Views")),
zoom(new ZoomWidget),
threshold(new ThresholdWidget),
mussaViewTB(new QToolBar("Path Views")),
zoom(new ZoomWidget),
threshold(new ThresholdWidget),
std::auto_ptr<QFileDialog> dialog(new QFileDialog(this));
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setFileMode(QFileDialog::AnyFile);
std::auto_ptr<QFileDialog> dialog(new QFileDialog(this));
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setFileMode(QFileDialog::AnyFile);
- dialog->setDirectory(default_dir);
+ dialog->setDirectory(*default_dir);
QStringList fileNames;
if (not dialog->exec()) {
QStringList fileNames;
if (not dialog->exec()) {
}
analysis->save(save_path);
fs::path normalized_path = (save_path / "..").normalize();
}
analysis->save(save_path);
fs::path normalized_path = (save_path / "..").normalize();
- default_dir = normalized_path.native_directory_string().c_str();
+ default_dir->setPath(normalized_path.native_directory_string().c_str());
}
bool MussaWindow::isClearingAnalysisSafe()
}
bool MussaWindow::isClearingAnalysisSafe()
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getOpenFileName(this,
caption,
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getOpenFileName(this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter);
// user hit cancel?
if (path.isNull())
filter);
// user hit cancel?
if (path.isNull())
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->load_motifs(converted_path);
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->load_motifs(converted_path);
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
emit changedMotifs();
} catch (runtime_error e) {
QString msg("Unable to load ");
emit changedMotifs();
} catch (runtime_error e) {
QString msg("Unable to load ");
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getSaveFileName(this,
caption,
QString filter("Motif list(*.txt *.mtl)");
QString path = QFileDialog::getSaveFileName(this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter);
// user hit cancel?
if (path.isNull())
filter);
// user hit cancel?
if (path.isNull())
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->save_motifs(converted_path);
try {
fs::path converted_path(path.toStdString(), fs::native);
analysis->save_motifs(converted_path);
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} catch (runtime_error e) {
QString msg("Unable to save ");
msg += path;
} catch (runtime_error e) {
QString msg("Unable to save ");
msg += path;
QString mupa_path = QFileDialog::getOpenFileName(
this,
caption,
QString mupa_path = QFileDialog::getOpenFileName(
this,
caption,
- default_dir.absolutePath(),
+ default_dir->absolutePath(),
filter
);
// user hit cancel?
filter
);
// user hit cancel?
setAnalysis(m);
updateTitle();
// grab the path ignoring the mupa file portion
setAnalysis(m);
updateTitle();
// grab the path ignoring the mupa file portion
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} catch (mussa_load_error e) {
QString msg("Unable to load ");
msg += mupa_path;
} catch (mussa_load_error e) {
QString msg("Unable to load ");
msg += mupa_path;
QString muway_dir = QFileDialog::getExistingDirectory(
this,
caption,
QString muway_dir = QFileDialog::getExistingDirectory(
this,
caption,
- default_dir.absolutePath()
+ default_dir->absolutePath()
);
// user hit cancel?
if (muway_dir.isNull())
);
// user hit cancel?
if (muway_dir.isNull())
// our current window is empty so load and replace.
setAnalysis(m);
updateTitle();
// our current window is empty so load and replace.
setAnalysis(m);
updateTitle();
- default_dir = converted_path.branch_path().native_directory_string().c_str();
+ default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
} else {
MussaWindow *win = new MussaWindow(m);
updateTitle();
} else {
MussaWindow *win = new MussaWindow(m);
updateTitle();
- win->default_dir = converted_path.branch_path().native_directory_string().c_str();
+ win->default_dir->setPath(converted_path.branch_path().native_directory_string().c_str());
win->show();
}
} catch (mussa_load_error e) {
win->show();
}
} catch (mussa_load_error e) {
"first"));
} else {
MussaAlignedWindowRef ma_win(
"first"));
} else {
MussaAlignedWindowRef ma_win(
- new MussaAlignedWindow(analysis, selected_paths, subanalysis_window)
+ new MussaAlignedWindow(analysis, default_dir, selected_paths, subanalysis_window)
);
aligned_windows.push_back(ma_win);
);
aligned_windows.push_back(ma_win);
//! shared_ptr to our analysis
MussaRef analysis;
//! the default directory we should loand and save from
//! shared_ptr to our analysis
MussaRef analysis;
//! the default directory we should loand and save from
+ boost::shared_ptr<QDir> default_dir;
std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
MotifEditor *motif_editor;
MussaSetupDialog *setup_analysis_dialog;
std::list<boost::shared_ptr<MussaAlignedWindow> > aligned_windows;
MotifEditor *motif_editor;
MussaSetupDialog *setup_analysis_dialog;
#include <math.h>
using namespace std;
#include <math.h>
using namespace std;
-SequenceBrowserWidget::SequenceBrowserWidget(QWidget *parent)
+SequenceBrowserWidget::SequenceBrowserWidget(
+ boost::shared_ptr<QDir> default_dir_,
+ QWidget *parent
+)
- scrollable_browser(parent)
+ default_dir(default_dir_),
+ scrollable_browser(this)
{
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(&left_sidebar, 0);
{
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(&left_sidebar, 0);
QSize size;
size = scrollable_browser.browser().size();
//Image Save Dialog
QSize size;
size = scrollable_browser.browser().size();
//Image Save Dialog
- ImageSaveDialog imageSaveDialog(&scrollable_browser.browser(), this);
+ ImageSaveDialog imageSaveDialog(default_dir, &scrollable_browser.browser(), this);
imageSaveDialog.setSize(size.width(), size.height());
imageSaveDialog.exec();
}
imageSaveDialog.setSize(size.width(), size.height());
imageSaveDialog.exec();
}
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <QWidget>
#include "alg/sequence.hpp"
#include <QWidget>
#include "alg/sequence.hpp"
- SequenceBrowserWidget(QWidget *parent=0);
+ SequenceBrowserWidget(boost::shared_ptr<QDir>, QWidget *parent=0);
//! return the popup menu for the glcanvas (reference stored internally)
QMenu *getPopupMenu();
//! return the popup menu for the glcanvas (reference stored internally)
QMenu *getPopupMenu();
+ boost::shared_ptr<QDir> default_dir;
ScrollableSequenceBrowser scrollable_browser;
SequenceBrowserSidebar left_sidebar;
SequenceBrowserSidebar right_sidebar;
ScrollableSequenceBrowser scrollable_browser;
SequenceBrowserSidebar left_sidebar;
SequenceBrowserSidebar right_sidebar;