From 08150381c795fe881948ed7b5902722bbfc24c76 Mon Sep 17 00:00:00 2001 From: Noldor Date: Sun, 25 Apr 2010 21:47:51 +0000 Subject: More improvements in theme module git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4295 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/theme/libkvitheme.cpp | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/modules/theme/libkvitheme.cpp') diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp index 4d63bcc68..1b240f8b6 100644 --- a/src/modules/theme/libkvitheme.cpp +++ b/src/modules/theme/libkvitheme.cpp @@ -128,6 +128,50 @@ static bool theme_kvs_cmd_apply(KviKvsModuleCommandCall * c) c->warning(__tr2qs_ctx("The theme package %Q does not exists","theme"),&szThemePackFile); return true; } +/* + @doc: theme.info + @type: + function + @title: + theme.info + @short: + Return info about a theme. + @syntax: + $theme.info() + @description: + Returns as hash the info about a theme. + Hash keys are: name, version, author, description. +*/ +static bool theme_kvs_fnc_info(KviKvsModuleFunctionCall * c) +{ + QString szThemePackFile; + + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("package_name",KVS_PT_STRING,0,szThemePackFile) + KVSM_PARAMETERS_END(c) + QString szDir; + g_pApp->getLocalKvircDirectory(szDir,KviApp::Themes); + szDir += KVI_PATH_SEPARATOR_CHAR; + szDir += szThemePackFile; + KviThemeInfo * themeInfo = new KviThemeInfo(); + if(themeInfo->loadFromDirectory(szDir)) + { + KviKvsHash *pHash=new KviKvsHash(); + KviKvsVariant *name=new KviKvsVariant(themeInfo->name()); + pHash->set("name",name); + KviKvsVariant *version=new KviKvsVariant(themeInfo->version()); + pHash->set("version",version); + KviKvsVariant *author=new KviKvsVariant(themeInfo->author()); + pHash->set("author",author); + KviKvsVariant *description=new KviKvsVariant(themeInfo->description()); + pHash->set("description",description); + c->returnValue()->setHash(pHash); + return true; + } + c->warning(__tr2qs_ctx("The theme package %Q does not exists","theme"),&szThemePackFile); + return true; +} + /* @doc: theme.list @type: @@ -238,6 +282,8 @@ static bool theme_module_init(KviModule *m) KVSM_REGISTER_SIMPLE_COMMAND(m,"screenshot",theme_kvs_cmd_screenshot); KVSM_REGISTER_FUNCTION(m,"list",theme_kvs_fnc_list); + KVSM_REGISTER_FUNCTION(m,"info",theme_kvs_fnc_info); + QString szBuf; m->getDefaultConfigFileName(szBuf); KviConfig cfg(szBuf,KviConfig::Read); -- cgit v1.3.1-10-gc9f91