Files
chatterino2/src/singletons/commandmanager.hpp
Rasmus Karlsson ae26b835b6 Perform initial refactoring work
Things that were once singletons are no longer singletons, but are
instead stored in the "Application" singleton

Some singletons still remain, and some renaming/renamespacing is left
2018-04-27 22:11:19 +02:00

51 lines
971 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;
friend class Application;
public:
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