mirror-chatterino2/src/singletons/commandmanager.hpp
fourtf 8418e36e49 Fixed a bug where scrolling layouts wrong
It used the wrong with to layout the messages.
2018-01-05 10:41:21 +01:00

50 lines
983 B
C++

#pragma once
#include <QMap>
#include <QString>
#include <memory>
#include <mutex>
namespace chatterino {
class Channel;
namespace singletons {
//
// this class managed the custom /commands
//
class CommandManager
{
CommandManager() = default;
public:
static CommandManager &getInstance();
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
void loadCommands();
void saveCommands();
void setCommands(const QStringList &commands);
QStringList getCommands();
private:
struct Command {
QString name;
QString text;
Command() = default;
Command(QString text);
};
QMap<QString, Command> commands;
std::mutex mutex;
QStringList commandsStringList;
QString filePath;
QString execCustomCommand(const QStringList &words, const Command &command);
};
} // namespace singletons
} // namespace chatterino