forked from qt-creator/qt-creator
Lua: Code cosmetics
The initialization/setup/... methods are typically called 'setupX...' nowadays. Change-Id: Iecdca160a54f60fbeb3dbffcc6d7aca20bc68682 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "../luaengine.h"
|
||||
#include "../luaqttypes.h"
|
||||
#include "../luatr.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
@@ -23,6 +22,8 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Lua::Internal {
|
||||
|
||||
static QString opToString(QNetworkAccessManager::Operation op)
|
||||
@@ -46,12 +47,12 @@ static QString opToString(QNetworkAccessManager::Operation op)
|
||||
}
|
||||
}
|
||||
|
||||
void addFetchModule()
|
||||
void setupFetchModule()
|
||||
{
|
||||
class Module : Utils::AspectContainer
|
||||
class Module : AspectContainer
|
||||
{
|
||||
Utils::StringListAspect pluginsAllowedToFetch{this};
|
||||
Utils::StringListAspect pluginsNotAllowedToFetch{this};
|
||||
StringListAspect pluginsAllowedToFetch{this};
|
||||
StringListAspect pluginsNotAllowedToFetch{this};
|
||||
|
||||
class LuaOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
@@ -64,7 +65,7 @@ void addFetchModule()
|
||||
setDisplayCategory("Lua");
|
||||
setCategoryIconPath(":/lua/images/settingscategory_lua.png");
|
||||
setSettingsProvider(
|
||||
[module] { return static_cast<Utils::AspectContainer *>(module); });
|
||||
[module] { return static_cast<AspectContainer *>(module); });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,8 +204,8 @@ void addFetchModule()
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::InfoBarEntry entry{
|
||||
Utils::Id("Fetch").withSuffix(pluginName),
|
||||
InfoBarEntry entry{
|
||||
Id("Fetch").withSuffix(pluginName),
|
||||
Tr::tr("Allow the extension \"%1\" to fetch data from the internet?")
|
||||
.arg(pluginName)};
|
||||
entry.setDetailsWidgetCreator([pluginName, url] {
|
||||
@@ -216,21 +217,21 @@ void addFetchModule()
|
||||
QLabel *list = new QLabel();
|
||||
list->setTextFormat(Qt::TextFormat::MarkdownText);
|
||||
list->setText(markdown);
|
||||
list->setMargin(Utils::StyleHelper::SpacingTokens::ExPaddingGapS);
|
||||
list->setMargin(StyleHelper::SpacingTokens::ExPaddingGapS);
|
||||
return list;
|
||||
});
|
||||
entry.addCustomButton(Tr::tr("Always Allow"), [mod, pluginName, fetch]() {
|
||||
mod->setAllowedToFetch(pluginName, Module::IsAllowed::Yes);
|
||||
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||
Core::ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName));
|
||||
fetch();
|
||||
});
|
||||
entry.addCustomButton(Tr::tr("Allow Once"), [pluginName, fetch]() {
|
||||
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||
Core::ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName));
|
||||
fetch();
|
||||
});
|
||||
|
||||
entry.setCancelButtonInfo(Tr::tr("Deny"), [mod, notAllowed, pluginName]() {
|
||||
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||
Core::ICore::infoBar()->removeInfo(Id("Fetch").withSuffix(pluginName));
|
||||
mod->setAllowedToFetch(pluginName, Module::IsAllowed::No);
|
||||
notAllowed();
|
||||
});
|
||||
@@ -260,9 +261,9 @@ void addFetchModule()
|
||||
|
||||
QNetworkReply *reply = nullptr;
|
||||
if (method == "get")
|
||||
reply = Utils::NetworkAccessManager::instance()->get(request);
|
||||
reply = NetworkAccessManager::instance()->get(request);
|
||||
else if (method == "post")
|
||||
reply = Utils::NetworkAccessManager::instance()->post(request, data.toUtf8());
|
||||
reply = NetworkAccessManager::instance()->post(request, data.toUtf8());
|
||||
else
|
||||
throw std::runtime_error("Unknown method: " + method.toStdString());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user