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