From ff0f15605bc6b0e47e82a665ec3ed4c383b8fedf Mon Sep 17 00:00:00 2001 From: karliss Date: Fri, 17 May 2019 10:09:10 +0300 Subject: [PATCH] Fix io plugin listing. (#1544) --- src/core/Cutter.cpp | 13 +++++---- src/core/CutterDescriptions.h | 1 + src/dialogs/NewFileDialog.cpp | 15 ++++++---- src/dialogs/NewfileDialog.ui | 55 +++++++++++++++-------------------- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 1db71c52..20d3e98b 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -1467,16 +1467,19 @@ QList CutterCore::getRIOPluginDescriptions() { QList 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; } diff --git a/src/core/CutterDescriptions.h b/src/core/CutterDescriptions.h index cc8f4034..b1c86897 100644 --- a/src/core/CutterDescriptions.h +++ b/src/core/CutterDescriptions.h @@ -165,6 +165,7 @@ struct RIOPluginDescription { QString description; QString license; QString permissions; + QList uris; }; struct RCorePluginDescription { diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 75aaa22c..f1f73530 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -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,9 +338,14 @@ void NewFileDialog::fillIOPluginsList() if (plugin.permissions.contains('d')) { continue; } - ui->ioPlugin->addItem(plugin.name); - ui->ioPlugin->setItemData(index, plugin.description, Qt::ToolTipRole); - index++; + for (const auto &uri : qAsConst(plugin.uris)) { + if (uri == "file://") { + 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 QString ioFile = ""; if (ui->ioPlugin->currentIndex()) { - ioFile = ui->ioPlugin->currentText() + "://"; + ioFile = ui->ioPlugin->currentText(); } ioFile += nativeFn; InitialOptions options; diff --git a/src/dialogs/NewfileDialog.ui b/src/dialogs/NewfileDialog.ui index 09d7073d..6c37f05b 100755 --- a/src/dialogs/NewfileDialog.ui +++ b/src/dialogs/NewfileDialog.ui @@ -157,30 +157,7 @@ 5 - - - - - 0 - 0 - - - - Select - - - - - - - false - - - true - - - - + @@ -193,6 +170,29 @@ + + + + + 0 + 0 + + + + Select + + + + + + + false + + + true + + + @@ -203,13 +203,6 @@ - - - - :// - - -