From b4d00a3da230c6132934ea785786623c3314753f Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Fri, 27 Feb 2015 10:19:21 -0500 Subject: [PATCH] Allow opening of multiple files on application launch on OS X. Fixes #1229 --- src/launchingscreen.cc | 12 ++++++------ src/launchingscreen.h | 6 +++--- src/openscad.cc | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/launchingscreen.cc b/src/launchingscreen.cc index 461ba701..82b02f3b 100644 --- a/src/launchingscreen.cc +++ b/src/launchingscreen.cc @@ -55,7 +55,7 @@ LaunchingScreen::LaunchingScreen(QWidget *parent) : QDialog(parent) } connect(this->pushButtonNew, SIGNAL(clicked()), this, SLOT(accept())); - connect(this->pushButtonOpen, SIGNAL(clicked()), this, SLOT(openFile())); + connect(this->pushButtonOpen, SIGNAL(clicked()), this, SLOT(openUserFile())); connect(this->pushButtonHelp, SIGNAL(clicked()), this, SLOT(openUserManualURL())); connect(this->recentList->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(enableRecentButton(const QModelIndex &, const QModelIndex &))); @@ -73,9 +73,9 @@ LaunchingScreen::~LaunchingScreen() LaunchingScreen::inst = NULL; } -QString LaunchingScreen::selectedFile() +QStringList LaunchingScreen::selectedFiles() { - return this->selection; + return this->files; } void LaunchingScreen::enableRecentButton(const QModelIndex &, const QModelIndex &) @@ -118,15 +118,15 @@ void LaunchingScreen::checkOpen(const QVariant &data) return; } - this->selection = path; + this->files.append(path); accept(); } -void LaunchingScreen::openFile() +void LaunchingScreen::openUserFile() { QFileInfo fileInfo = UIUtils::openFile(this); if (fileInfo.exists()) { - this->selection = fileInfo.canonicalFilePath(); + this->files.append(fileInfo.canonicalFilePath()); accept(); } } diff --git a/src/launchingscreen.h b/src/launchingscreen.h index d28aae34..51d720cd 100644 --- a/src/launchingscreen.h +++ b/src/launchingscreen.h @@ -15,7 +15,7 @@ public: static LaunchingScreen *getDialog(); explicit LaunchingScreen(QWidget *parent = 0); virtual ~LaunchingScreen(); - QString selectedFile(); + QStringList selectedFiles(); public slots: void openFile(const QString &filename); @@ -24,7 +24,7 @@ private slots: void checkboxState(bool state); void enableRecentButton(const QModelIndex ¤t, const QModelIndex &previous); void enableExampleButton(QTreeWidgetItem *current, QTreeWidgetItem *previous); - void openFile(); + void openUserFile(); void openRecent(); void openExample(); void openUserManualURL(); @@ -32,6 +32,6 @@ private slots: private: void checkOpen(const QVariant &data); - QString selection; + QStringList files; static LaunchingScreen *inst; }; diff --git a/src/openscad.cc b/src/openscad.cc index 0953ffdb..46518900 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -707,7 +707,10 @@ int gui(vector &inputFiles, const fs::path &original_path, int argc, cha int dialogResult = launcher->exec(); if (dialogResult == QDialog::Accepted) { inputFiles.clear(); - inputFiles.push_back(launcher->selectedFile().toStdString()); + QStringList files = launcher->selectedFiles(); + BOOST_FOREACH(const QString &f, files) { + inputFiles.push_back(f.toStdString()); + } delete launcher; } else { return 0;