Allow opening of multiple files on application launch on OS X. Fixes #1229

master
Marius Kintel 2015-02-27 10:19:21 -05:00
parent b9e1b6603e
commit b4d00a3da2
3 changed files with 13 additions and 10 deletions

View File

@ -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();
}
}

View File

@ -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 &current, 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;
};

View File

@ -707,7 +707,10 @@ int gui(vector<string> &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;