Support for multiple custom actions

FossilOrigin-Name: 172938d454db50a53cd0e0435991a7fccea59ae7
This commit is contained in:
kostas
2015-07-09 18:55:33 +00:00
parent 2429d6ca9e
commit 78276623a4
10 changed files with 422 additions and 145 deletions

View File

@ -4,14 +4,13 @@
#include <QMap>
#include <QVariant>
#include <QTranslator>
#include <QVector>
#define FUEL_SETTING_FOSSIL_PATH "FossilPath"
#define FUEL_SETTING_COMMIT_MSG "CommitMsgHistory"
#define FUEL_SETTING_FILE_DBLCLICK "FileDblClickAction"
#define FUEL_SETTING_LANGUAGE "Language"
#define FUEL_SETTING_WEB_BROWSER "WebBrowser"
#define FUEL_SETTING_FILEACTION_NAME "FileActionName"
#define FUEL_SETTING_FILEACTION_COMMAND "FileActionCommand"
#define FOSSIL_SETTING_GDIFF_CMD "gdiff-command"
#define FOSSIL_SETTING_GMERGE_CMD "gmerge-command"
@ -29,6 +28,50 @@ enum FileDblClickAction
FILE_DLBCLICK_ACTION_MAX
};
enum CustomActionContext
{
ACTION_CONTEXT_FILES = 1 << 0,
ACTION_CONTEXT_FOLDERS = 1 << 1,
ACTION_CONTEXT_FILES_AND_FOLDERS = ACTION_CONTEXT_FILES|ACTION_CONTEXT_FOLDERS
};
enum
{
MAX_CUSTOM_ACTIONS = 5
};
struct CustomAction
{
QString Id;
QString Description;
QString Command;
CustomActionContext Context;
CustomAction()
{
Clear();
}
bool IsValid() const
{
return !(Description.isEmpty() || Command.isEmpty());
}
bool IsActive(CustomActionContext context) const
{
return (Context & context) != 0;
}
void Clear()
{
Description.clear();
Command.clear();
Context = ACTION_CONTEXT_FILES;
}
};
struct Settings
{
struct Setting
@ -45,6 +88,7 @@ struct Settings
SettingType Type;
};
typedef QMap<QString, Setting> mappings_t;
typedef QVector<CustomAction> custom_actions_t;
Settings(bool portableMode = false);
@ -65,10 +109,14 @@ struct Settings
bool SupportsLang(const QString &langId) const;
bool InstallLang(const QString &langId);
custom_actions_t &GetCustomActions() { return customActions; }
private:
mappings_t Mappings;
class QSettings *store;
QTranslator translator;
mappings_t Mappings;
class QSettings *store;
QTranslator translator;
custom_actions_t customActions;
};