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()); ui->logoSvgWidget->load(Config()->getLogoFile());
fillRecentFilesList(); fillRecentFilesList();
fillIOPluginsList();
if (Config()->getNewFileLastClicked() == TAB_PROJECTS) { // Set last clicked tab
ui->tabWidget->setCurrentWidget(ui->projectsTab); ui->tabWidget->setCurrentIndex(Config()->getNewFileLastClicked());
} else {
ui->tabWidget->setCurrentWidget(ui->filesTab);
}
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr); ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
@ -306,9 +304,24 @@ bool NewFileDialog::fillProjectsList()
return !projects.isEmpty(); 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) 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); QMessageBox msgBox(this);
msgBox.setText(tr("Select a new program or a previous one before continuing.")); msgBox.setText(tr("Select a new program or a previous one before continuing."));
msgBox.exec(); msgBox.exec();
@ -327,7 +340,8 @@ void NewFileDialog::loadFile(const QString &filename)
// Close dialog and open MainWindow/OptionsDialog // Close dialog and open MainWindow/OptionsDialog
MainWindow *main = new MainWindow(); MainWindow *main = new MainWindow();
main->openNewFile(filename); QString ioFile = ui->ioPlugin->currentText() + "://" + filename;
main->openNewFile(ioFile);
close(); close();
} }

View File

@ -16,7 +16,6 @@ class NewFileDialog : public QDialog
public: public:
explicit NewFileDialog(QWidget *parent = nullptr); explicit NewFileDialog(QWidget *parent = nullptr);
~NewFileDialog(); ~NewFileDialog();
enum newFileTabs { TAB_FILES = 0, TAB_PROJECTS };
private slots: private slots:
void on_loadFileButton_clicked(); void on_loadFileButton_clicked();
@ -55,6 +54,7 @@ private:
* @return true if list is not empty * @return true if list is not empty
*/ */
bool fillProjectsList(); bool fillProjectsList();
void fillIOPluginsList();
void loadFile(const QString &filename); void loadFile(const QString &filename);
void loadProject(const QString &project); void loadProject(const QString &project);

View File

@ -151,7 +151,7 @@
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>5</number> <number>5</number>
</property> </property>
<item row="1" column="1"> <item row="1" column="3">
<widget class="QPushButton" name="selectFileButton"> <widget class="QPushButton" name="selectFileButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -164,7 +164,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="2">
<widget class="QLineEdit" name="newFileEdit"> <widget class="QLineEdit" name="newFileEdit">
<property name="frame"> <property name="frame">
<bool>false</bool> <bool>false</bool>
@ -174,7 +174,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="2">
<widget class="QLabel" name="newFileLabel"> <widget class="QLabel" name="newFileLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -183,7 +183,24 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>