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;
QJsonArray plugins = cmdj("oLj").object()["IO_Plugins"].toArray();
QJsonArray plugins = cmdj("oLj").object()["io_plugins"].toArray();
for (const QJsonValue &pluginValue : plugins) {
QJsonObject pluginObject = pluginValue.toObject();
RIOPluginDescription plugin;
plugin.name = pluginObject["Name"].toString();
plugin.description = pluginObject["Description"].toString();
plugin.license = pluginObject["License"].toString();
plugin.permissions = pluginObject["Permissions"].toString();
plugin.name = pluginObject["name"].toString();
plugin.description = pluginObject["description"].toString();
plugin.license = pluginObject["license"].toString();
plugin.permissions = pluginObject["permissions"].toString();
for (const auto &uri : pluginObject["uris"].toArray()) {
plugin.uris << uri.toString();
}
ret << plugin;
}

View File

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

View File

@ -328,7 +328,7 @@ bool NewFileDialog::fillProjectsList()
void NewFileDialog::fillIOPluginsList()
{
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);
int index = 1;
@ -338,10 +338,15 @@ void NewFileDialog::fillIOPluginsList()
if (plugin.permissions.contains('d')) {
continue;
}
ui->ioPlugin->addItem(plugin.name);
for (const auto &uri : qAsConst(plugin.uris)) {
if (uri == "file://") {
continue;
}
ui->ioPlugin->addItem(uri);
ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole);
index++;
}
}
}
void NewFileDialog::loadFile(const QString &filename)
@ -368,7 +373,7 @@ void NewFileDialog::loadFile(const QString &filename)
// Close dialog and open MainWindow/InitialOptionsDialog
QString ioFile = "";
if (ui->ioPlugin->currentIndex()) {
ioFile = ui->ioPlugin->currentText() + "://";
ioFile = ui->ioPlugin->currentText();
}
ioFile += nativeFn;
InitialOptions options;

View File

@ -157,30 +157,7 @@
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="1" column="3">
<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">
<item row="0" column="1">
<widget class="QLabel" name="newFileLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -193,6 +170,29 @@
</property>
</widget>
</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">
<widget class="QComboBox" name="ioPlugin"/>
</item>
@ -203,13 +203,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>://</string>
</property>
</widget>
</item>
</layout>
</item>
<item>