Added IO list to NewFileDialog

This commit is contained in:
xarkes 2018-07-07 11:27:13 +02:00
parent b222aaa094
commit ecb5fc75cf
3 changed files with 43 additions and 12 deletions

View File

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

View File

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

View File

@ -151,7 +151,7 @@
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="1" column="1">
<item row="1" column="3">
<widget class="QPushButton" name="selectFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -164,7 +164,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="2">
<widget class="QLineEdit" name="newFileEdit">
<property name="frame">
<bool>false</bool>
@ -174,7 +174,7 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="0" column="2">
<widget class="QLabel" name="newFileLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -183,7 +183,24 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Select new file&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;b&gt;Select new file&lt;b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="ioPlugin"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="ioLabel">
<property name="text">
<string>&lt;b&gt;IO&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>://</string>
</property>
</widget>
</item>