mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add CHATTERINO_HAVE_PLUGINS define
This commit is contained in:
parent
a61bc4d6d1
commit
c7f47df827
16 changed files with 110 additions and 72 deletions
|
@ -24,6 +24,12 @@ option(CHATTERINO_GENERATE_COVERAGE "Generate coverage files" OFF)
|
|||
option(BUILD_TRANSLATIONS "" OFF)
|
||||
option(BUILD_SHARED_LIBS "" OFF)
|
||||
option(CHATTERINO_LTO "Enable LTO for all targets" OFF)
|
||||
option(CHATTERINO_PLUGINS "Enable EXPERIMENTAL plugin support in Chatterino" OFF)
|
||||
|
||||
if(CHATTERINO_PLUGINS)
|
||||
add_definitions(-DCHATTERINO_HAVE_PLUGINS)
|
||||
message(STATUS "Building Chatterino with lua plugin support enabled.")
|
||||
endif()
|
||||
|
||||
if(CHATTERINO_LTO)
|
||||
include(CheckIPOSupported)
|
||||
|
@ -148,9 +154,10 @@ else()
|
|||
add_subdirectory("${CMAKE_SOURCE_DIR}/lib/settings" EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
|
||||
if (CHATTERINO_PLUGINS)
|
||||
set(LUA_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/lib/lua/src")
|
||||
add_subdirectory(lib/lua)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "controllers/ignores/IgnoreController.hpp"
|
||||
#include "controllers/notifications/NotificationController.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
# include "controllers/plugins/PluginController.hpp"
|
||||
#endif
|
||||
#include "controllers/sound/SoundController.hpp"
|
||||
#include "controllers/userdata/UserDataController.hpp"
|
||||
#include "debug/AssertInGuiThread.hpp"
|
||||
|
@ -85,7 +87,9 @@ Application::Application(Settings &_settings, Paths &_paths)
|
|||
, seventvBadges(&this->emplace<SeventvBadges>())
|
||||
, userData(&this->emplace<UserDataController>())
|
||||
, sound(&this->emplace<SoundController>())
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
, plugins(&this->emplace<PluginController>())
|
||||
#endif
|
||||
, logging(&this->emplace<Logging>())
|
||||
{
|
||||
this->instance = this;
|
||||
|
|
|
@ -20,7 +20,9 @@ class HotkeyController;
|
|||
class IUserDataController;
|
||||
class UserDataController;
|
||||
class SoundController;
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
class PluginController;
|
||||
#endif
|
||||
|
||||
class Theme;
|
||||
class WindowManager;
|
||||
|
@ -96,7 +98,9 @@ public:
|
|||
UserDataController *const userData{};
|
||||
SoundController *const sound{};
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
PluginController *const plugins{};
|
||||
#endif
|
||||
|
||||
/*[[deprecated]]*/ Logging *const logging{};
|
||||
|
||||
|
|
|
@ -625,8 +625,10 @@ target_link_libraries(${LIBRARY_PROJECT}
|
|||
RapidJSON::RapidJSON
|
||||
LRUCache
|
||||
MagicEnum
|
||||
lua
|
||||
)
|
||||
if (CHATTERINO_PLUGINS)
|
||||
target_link_libraries(${LIBRARY_PROJECT} PUBLIC lua)
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_QTKEYCHAIN)
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
|
|
|
@ -230,11 +230,12 @@ void CompletionModel::refresh(const QString &prefix, bool isFirstWord)
|
|||
{
|
||||
addString(emote.first.string, TaggedString::Type::BTTVGlobalEmote);
|
||||
}
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
for (const auto &command : getApp()->commands->pluginCommands())
|
||||
{
|
||||
addString(command, TaggedString::PluginCommand);
|
||||
}
|
||||
#endif
|
||||
// Custom Chatterino commands
|
||||
for (const auto &command : getApp()->commands->items)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,9 @@ class CompletionModel : public QAbstractListModel
|
|||
CustomCommand,
|
||||
ChatterinoCommand,
|
||||
TwitchCommand,
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
PluginCommand,
|
||||
#endif
|
||||
};
|
||||
|
||||
TaggedString(QString _string, Type type);
|
||||
|
|
|
@ -3220,7 +3220,7 @@ QString CommandController::execCommand(const QString &textNoEmoji,
|
|||
|
||||
return text;
|
||||
}
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
bool CommandController::registerPluginCommand(const QString &commandName)
|
||||
{
|
||||
if (this->commands_.contains(commandName))
|
||||
|
@ -3244,6 +3244,7 @@ bool CommandController::unregisterPluginCommand(const QString &commandName)
|
|||
this->pluginCommands_.removeAll(commandName);
|
||||
return this->commands_.erase(commandName) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CommandController::registerCommand(const QString &commandName,
|
||||
CommandFunctionVariants commandFunction)
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
const QStringList &words, const Command &command, bool dryRun,
|
||||
ChannelPtr channel, const Message *message = nullptr,
|
||||
std::unordered_map<QString, QString> context = {});
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
bool registerPluginCommand(const QString &commandName);
|
||||
bool unregisterPluginCommand(const QString &commandName);
|
||||
|
||||
|
@ -50,6 +50,7 @@ public:
|
|||
{
|
||||
return this->pluginCommands_;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
void load(Paths &paths);
|
||||
|
@ -81,7 +82,9 @@ private:
|
|||
commandsSetting_;
|
||||
|
||||
QStringList defaultChatterinoCommandAutoCompletions_;
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
QStringList pluginCommands_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "LuaUtilities.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
# include "common/Channel.hpp"
|
||||
# include "controllers/commands/CommandContext.hpp"
|
||||
|
@ -109,3 +110,4 @@ bool peek(lua_State *L, QString *out, StackIdx idx)
|
|||
return true;
|
||||
}
|
||||
} // namespace chatterino::lua
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
# include "lua.h"
|
||||
|
||||
# include <qlist.h>
|
||||
|
@ -73,3 +74,4 @@ bool pop(lua_State *L, T *out, StackIdx idx = -1)
|
|||
}
|
||||
|
||||
} // namespace chatterino::lua
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "Plugin.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
namespace chatterino {
|
||||
bool Plugin::registerCommand(const QString &name, const QString &functionName)
|
||||
|
@ -27,3 +28,4 @@ std::set<QString> Plugin::listRegisteredCommands()
|
|||
return out;
|
||||
}
|
||||
} // namespace chatterino
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#include "PluginController.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
# include "Application.hpp"
|
||||
# include "common/QLogging.hpp"
|
||||
# include "controllers/commands/CommandContext.hpp"
|
||||
# include "controllers/plugins/LuaUtilities.hpp"
|
||||
# include "lauxlib.h"
|
||||
# include "lua.h"
|
||||
# include "lualib.h"
|
||||
# include "messages/MessageBuilder.hpp"
|
||||
# include "providers/twitch/TwitchIrcServer.hpp"
|
||||
# include "singletons/Paths.hpp"
|
||||
|
@ -18,12 +22,6 @@
|
|||
# include <memory>
|
||||
# include <utility>
|
||||
|
||||
//extern "C" {
|
||||
#include "lauxlib.h"
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
//}
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
void PluginController::initialize(Settings &settings, Paths &paths)
|
||||
|
@ -362,3 +360,4 @@ bool PluginController::isEnabled(const QString &codename)
|
|||
}
|
||||
|
||||
}; // namespace chatterino
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
# include "common/Singleton.hpp"
|
||||
# include "controllers/plugins/Plugin.hpp"
|
||||
# include "singletons/Paths.hpp"
|
||||
|
@ -68,3 +70,4 @@ private:
|
|||
};
|
||||
|
||||
}; // namespace chatterino
|
||||
#endif
|
||||
|
|
|
@ -216,7 +216,9 @@ void SettingsDialog::addTabs()
|
|||
this->addTab([]{return new ModerationPage;}, "Moderation", ":/settings/moderation.svg", SettingsTabId::Moderation);
|
||||
this->addTab([]{return new NotificationPage;}, "Live Notifications", ":/settings/notification2.svg");
|
||||
this->addTab([]{return new ExternalToolsPage;}, "External tools", ":/settings/externaltools.svg");
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
this->addTab([]{return new PluginsPage;}, "Plugins", ":/settings/externaltools.svg");
|
||||
#endif
|
||||
this->ui_.tabContainer->addStretch(1);
|
||||
this->addTab([]{return new AboutPage;}, "About", ":/settings/about.svg", SettingsTabId(), Qt::AlignBottom);
|
||||
// clang-format on
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "PluginsPage.hpp"
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
|
||||
# include "Application.hpp"
|
||||
# include "controllers/plugins/PluginController.hpp"
|
||||
|
@ -163,3 +164,4 @@ void PluginsPage::rebuildContent()
|
|||
}
|
||||
|
||||
} // namespace chatterino
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
# include "util/LayoutCreator.hpp"
|
||||
# include "widgets/settingspages/SettingsPage.hpp"
|
||||
|
||||
|
@ -23,3 +24,4 @@ private:
|
|||
QFrame *dataFrame_;
|
||||
};
|
||||
} // namespace chatterino
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue