From ecb5fc75cf46ff2b62a529e26d373fefaad1b51e Mon Sep 17 00:00:00 2001 From: xarkes Date: Sat, 7 Jul 2018 11:27:13 +0200 Subject: [PATCH] Added IO list to NewFileDialog --- src/dialogs/NewFileDialog.cpp | 28 +++++++++++++++++++++------- src/dialogs/NewFileDialog.h | 2 +- src/dialogs/NewfileDialog.ui | 25 +++++++++++++++++++++---- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 49248eaf..97991847 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -63,12 +63,10 @@ NewFileDialog::NewFileDialog(QWidget *parent) : ui->logoSvgWidget->load(Config()->getLogoFile()); fillRecentFilesList(); + fillIOPluginsList(); - if (Config()->getNewFileLastClicked() == TAB_PROJECTS) { - ui->tabWidget->setCurrentWidget(ui->projectsTab); - } else { - ui->tabWidget->setCurrentWidget(ui->filesTab); - } + // Set last clicked tab + ui->tabWidget->setCurrentIndex(Config()->getNewFileLastClicked()); ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr); @@ -306,9 +304,24 @@ bool NewFileDialog::fillProjectsList() return !projects.isEmpty(); } +void NewFileDialog::fillIOPluginsList() +{ + ui->ioPlugin->clear(); + ui->ioPlugin->addItem(""); + ui->ioPlugin->setItemData(0, tr("Open a file with no extra treatment."), Qt::ToolTipRole); + + int index = 1; + QList ioPlugins = Core()->getRIOPluginDescriptions(); + for (RIOPluginDescription plugin : ioPlugins) { + ui->ioPlugin->addItem(plugin.name); + ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole); + index++; + } +} + void NewFileDialog::loadFile(const QString &filename) { - if (!ui->checkBox_FilelessOpen->isChecked() && !Core()->tryFile(filename, false)) { + if (ui->ioPlugin->currentIndex() == 0 && !Core()->tryFile(filename, false) && !ui->checkBox_FilelessOpen->isChecked()) { QMessageBox msgBox(this); msgBox.setText(tr("Select a new program or a previous one before continuing.")); msgBox.exec(); @@ -327,7 +340,8 @@ void NewFileDialog::loadFile(const QString &filename) // Close dialog and open MainWindow/OptionsDialog MainWindow *main = new MainWindow(); - main->openNewFile(filename); + QString ioFile = ui->ioPlugin->currentText() + "://" + filename; + main->openNewFile(ioFile); close(); } diff --git a/src/dialogs/NewFileDialog.h b/src/dialogs/NewFileDialog.h index bcb2dadf..2653863a 100644 --- a/src/dialogs/NewFileDialog.h +++ b/src/dialogs/NewFileDialog.h @@ -16,7 +16,6 @@ class NewFileDialog : public QDialog public: explicit NewFileDialog(QWidget *parent = nullptr); ~NewFileDialog(); - enum newFileTabs { TAB_FILES = 0, TAB_PROJECTS }; private slots: void on_loadFileButton_clicked(); @@ -55,6 +54,7 @@ private: * @return true if list is not empty */ bool fillProjectsList(); + void fillIOPluginsList(); void loadFile(const QString &filename); void loadProject(const QString &project); diff --git a/src/dialogs/NewfileDialog.ui b/src/dialogs/NewfileDialog.ui index 53271e96..f4d6b854 100755 --- a/src/dialogs/NewfileDialog.ui +++ b/src/dialogs/NewfileDialog.ui @@ -151,7 +151,7 @@ 5 - + @@ -164,7 +164,7 @@ - + false @@ -174,7 +174,7 @@ - + @@ -183,7 +183,24 @@ - <html><head/><body><p><span style=" font-weight:600;">Select new file</span></p></body></html> + <b>Select new file<b> + + + + + + + + + + <b>IO</b> + + + + + + + ://