mirror-chatterino2/src/controllers/commands/CommandController.hpp

47 lines
979 B
C++
Raw Normal View History

#pragma once
2018-07-07 11:41:01 +02:00
#include "common/Singleton.hpp"
#include <QMap>
#include <memory>
2018-06-05 18:51:14 +02:00
#include <mutex>
#include "common/SignalVector.hpp"
2018-06-26 17:20:03 +02:00
#include "controllers/commands/Command.hpp"
namespace chatterino {
2018-08-02 14:23:27 +02:00
class Settings;
class Paths;
class Channel;
class CommandModel;
2018-08-02 14:23:27 +02:00
class CommandController final : public Singleton
{
public:
CommandController();
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
QStringList getDefaultTwitchCommandList();
2018-08-02 14:23:27 +02:00
virtual void initialize(Settings &settings, Paths &paths) override;
2018-07-07 11:41:01 +02:00
virtual void save() override;
CommandModel *createModel(QObject *parent);
2018-06-26 17:06:17 +02:00
UnsortedSignalVector<Command> items;
private:
2018-08-02 14:23:27 +02:00
void load(Paths &paths);
2018-07-07 11:41:01 +02:00
QMap<QString, Command> commandsMap_;
std::mutex mutex_;
QString filePath_;
QString execCustomCommand(const QStringList &words, const Command &command);
};
} // namespace chatterino