Fix io plugin listing. (#1544)

This commit is contained in:
karliss 2019-05-17 10:09:10 +03:00 committed by GitHub
parent a38d6707cd
commit ff0f15605b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 41 deletions

View File

@ -1467,16 +1467,19 @@ QList<RIOPluginDescription> CutterCore::getRIOPluginDescriptions()
{ {
QList<RIOPluginDescription> ret; QList<RIOPluginDescription> ret;
QJsonArray plugins = cmdj("oLj").object()["IO_Plugins"].toArray(); QJsonArray plugins = cmdj("oLj").object()["io_plugins"].toArray();
for (const QJsonValue &pluginValue : plugins) { for (const QJsonValue &pluginValue : plugins) {
QJsonObject pluginObject = pluginValue.toObject(); QJsonObject pluginObject = pluginValue.toObject();
RIOPluginDescription plugin; RIOPluginDescription plugin;
plugin.name = pluginObject["Name"].toString(); plugin.name = pluginObject["name"].toString();
plugin.description = pluginObject["Description"].toString(); plugin.description = pluginObject["description"].toString();
plugin.license = pluginObject["License"].toString(); plugin.license = pluginObject["license"].toString();
plugin.permissions = pluginObject["Permissions"].toString(); plugin.permissions = pluginObject["permissions"].toString();
for (const auto &uri : pluginObject["uris"].toArray()) {
plugin.uris << uri.toString();
}
ret << plugin; ret << plugin;
} }

View File

@ -165,6 +165,7 @@ struct RIOPluginDescription {
QString description; QString description;
QString license; QString license;
QString permissions; QString permissions;
QList<QString> uris;
}; };
struct RCorePluginDescription { struct RCorePluginDescription {

View File

@ -328,7 +328,7 @@ bool NewFileDialog::fillProjectsList()
void NewFileDialog::fillIOPluginsList() void NewFileDialog::fillIOPluginsList()
{ {
ui->ioPlugin->clear(); ui->ioPlugin->clear();
ui->ioPlugin->addItem("file"); ui->ioPlugin->addItem("file://");
ui->ioPlugin->setItemData(0, tr("Open a file with no extra treatment."), Qt::ToolTipRole); ui->ioPlugin->setItemData(0, tr("Open a file with no extra treatment."), Qt::ToolTipRole);
int index = 1; int index = 1;
@ -338,9 +338,14 @@ void NewFileDialog::fillIOPluginsList()
if (plugin.permissions.contains('d')) { if (plugin.permissions.contains('d')) {
continue; continue;
} }
ui->ioPlugin->addItem(plugin.name); for (const auto &uri : qAsConst(plugin.uris)) {
ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole); if (uri == "file://") {
index++; continue;
}
ui->ioPlugin->addItem(uri);
ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole);
index++;
}
} }
} }
@ -368,7 +373,7 @@ void NewFileDialog::loadFile(const QString &filename)
// Close dialog and open MainWindow/InitialOptionsDialog // Close dialog and open MainWindow/InitialOptionsDialog
QString ioFile = ""; QString ioFile = "";
if (ui->ioPlugin->currentIndex()) { if (ui->ioPlugin->currentIndex()) {
ioFile = ui->ioPlugin->currentText() + "://"; ioFile = ui->ioPlugin->currentText();
} }
ioFile += nativeFn; ioFile += nativeFn;
InitialOptions options; InitialOptions options;

View File

@ -157,30 +157,7 @@
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>5</number> <number>5</number>
</property> </property>
<item row="1" column="3"> <item row="0" column="1">
<widget class="QPushButton" name="selectFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="newFileEdit">
<property name="frame">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<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">
@ -193,6 +170,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2">
<widget class="QPushButton" name="selectFileButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="newFileEdit">
<property name="frame">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QComboBox" name="ioPlugin"/> <widget class="QComboBox" name="ioPlugin"/>
</item> </item>
@ -203,13 +203,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>://</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>