implemented possibility to delete skins

This commit is contained in:
louis 2015-06-04 16:29:25 +02:00
parent ecf8c75323
commit 872320b921
6 changed files with 128 additions and 10 deletions

View File

@ -357,4 +357,5 @@ Version 0.5.1
- changed skin installation that VDR main loop is not blocked - changed skin installation that VDR main loop is not blocked
- use shallow clone when cloning git - use shallow clone when cloning git
- implemented possibility to delete skins

View File

@ -177,6 +177,64 @@ void cDesignerConfig::AddNewSkinRef(string skin) {
(hit->second)->TranslateSetup(); (hit->second)->TranslateSetup();
} }
bool cDesignerConfig::SkinActive(string skin) {
cSkin *activeSkin = Skins.Current();
if (activeSkin && !skin.compare(activeSkin->Name()))
return true;
return false;
}
void cDesignerConfig::DeleteSkin(string skin) {
dsyslog("skindesigner: deleting skin %s", skin.c_str());
cSkin *deleteSkin = NULL;
bool found = false;
for (deleteSkin = Skins.First(); deleteSkin; deleteSkin = Skins.Next(deleteSkin)) {
if (!skin.compare(deleteSkin->Name())) {
found = true;
break;
}
}
if (!found || !deleteSkin) {
esyslog("skindesigner: skin %s to delete not found", skin.c_str());
return;
}
vector<cSkinDesigner*>::iterator delIt;
for (delIt = skinRefs.begin(); delIt != skinRefs.end(); delIt++) {
if (*delIt == deleteSkin)
break;
}
if (delIt != skinRefs.end())
skinRefs.erase(delIt);
vector<string>::iterator delIt2;
for (delIt2 = installerSkins.begin(); delIt2 != installerSkins.end(); delIt2++) {
if (!skin.compare(*delIt2))
break;
}
if (delIt2 != installerSkins.end())
installerSkins.erase(delIt2);
vector<string>::iterator delIt3;
for (delIt3 = skins.begin(); delIt3 != skins.end(); delIt3++) {
if (!skin.compare(*delIt3))
break;
}
if (delIt3 != skins.end())
skins.erase(delIt3);
Skins.Del(deleteSkin);
stringstream deletePath;
deletePath << *installerSkinPath << skin;
string delPath = deletePath.str();
if (FolderExists(delPath)) {
dsyslog("skindesigner: deleting skin %s", delPath.c_str());
cString command = cString::sprintf("rm -rf %s", delPath.c_str());
system(*command);
}
}
cSkinDesigner* cDesignerConfig::GetNextSkinRef(void) { cSkinDesigner* cDesignerConfig::GetNextSkinRef(void) {
if (skinRefsIterator == skinRefs.end()) { if (skinRefsIterator == skinRefs.end()) {
return NULL; return NULL;

View File

@ -65,6 +65,8 @@ public:
cString GetSkinPath(string skin); cString GetSkinPath(string skin);
void AddSkin(cSkinDesigner *skin) { skinRefs.push_back(skin); }; void AddSkin(cSkinDesigner *skin) { skinRefs.push_back(skin); };
void AddNewSkinRef(string skin); void AddNewSkinRef(string skin);
bool SkinActive(string skin);
void DeleteSkin(string skin);
void InitSkinRefsIterator(void) { skinRefsIterator = skinRefs.begin(); }; void InitSkinRefsIterator(void) { skinRefsIterator = skinRefs.begin(); };
cSkinDesigner *GetNextSkinRef(void); cSkinDesigner *GetNextSkinRef(void);
void ClearSkinSetups(void); void ClearSkinSetups(void);

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-skindesigner 0.0.1\n" "Project-Id-Version: vdr-skindesigner 0.0.1\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-06-04 10:40+0200\n" "POT-Creation-Date: 2015-06-04 16:05+0200\n"
"PO-Revision-Date: 2014-09-27 11:02+0200\n" "PO-Revision-Date: 2014-09-27 11:02+0200\n"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n" "Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n" "Language-Team: \n"
@ -54,9 +54,21 @@ msgstr "Installiere Skin"
msgid "Update from Git" msgid "Update from Git"
msgstr "Aus Git aktualisieren" msgstr "Aus Git aktualisieren"
msgid "Delete Skin"
msgstr "Skin löschen"
msgid "No Git Repsoitory available" msgid "No Git Repsoitory available"
msgstr "Kein Git Repository verfügbar" msgstr "Kein Git Repository verfügbar"
msgid "Skin is running and can't be deleted"
msgstr "Skin ist aktiv und kann nicht gelöscht werden"
msgid "Really delete skin"
msgstr "Skin wirklich löschen"
msgid "Skin deleted"
msgstr "Skin gelöscht"
msgid "Plugin Setup" msgid "Plugin Setup"
msgstr "" msgstr ""
@ -143,4 +155,3 @@ msgstr "Unterstützte Plugins"
msgid "Skin Designer" msgid "Skin Designer"
msgstr "Skin Designer" msgstr "Skin Designer"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: vdr-skindesigner 0.2.0\n" "Project-Id-Version: vdr-skindesigner 0.2.0\n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2015-06-04 10:40+0200\n" "POT-Creation-Date: 2015-06-04 16:05+0200\n"
"PO-Revision-Date: 2015-01-25 01:25+0200\n" "PO-Revision-Date: 2015-01-25 01:25+0200\n"
"Last-Translator: Rolf Ahrenberg\n" "Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish\n" "Language-Team: Finnish\n"
@ -54,9 +54,21 @@ msgstr ""
msgid "Update from Git" msgid "Update from Git"
msgstr "" msgstr ""
msgid "Delete Skin"
msgstr ""
msgid "No Git Repsoitory available" msgid "No Git Repsoitory available"
msgstr "" msgstr ""
msgid "Skin is running and can't be deleted"
msgstr ""
msgid "Really delete skin"
msgstr ""
msgid "Skin deleted"
msgstr ""
msgid "Plugin Setup" msgid "Plugin Setup"
msgstr "Yleiset" msgstr "Yleiset"

48
setup.c
View File

@ -1,3 +1,4 @@
#include <vdr/interface.h>
#include "libcore/curlfuncs.h" #include "libcore/curlfuncs.h"
#include "setup.h" #include "setup.h"
@ -115,7 +116,6 @@ eOSState cInstallManager::ProcessInstallationStatus(void) {
return osContinue; return osContinue;
} }
// --- cSkinDesignerSetup ----------------------------------------------------------- // --- cSkinDesignerSetup -----------------------------------------------------------
cSkinDesignerSetup::cSkinDesignerSetup() { cSkinDesignerSetup::cSkinDesignerSetup() {
numLogosPerSizeInitial = config.numLogosPerSizeInitial; numLogosPerSizeInitial = config.numLogosPerSizeInitial;
@ -161,7 +161,7 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
Store(); Store();
} }
if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed)) { if (!hadSubMenu && (Key == kOk || Key == kUp || Key == kDown || Key == kLeft || Key == kRight || Key == kRed || Key == kYellow)) {
SetHelp(NULL, NULL, NULL, NULL); SetHelp(NULL, NULL, NULL, NULL);
cOsdItem *current = Get(Current()); cOsdItem *current = Get(Current());
cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current); cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current);
@ -188,8 +188,11 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL); SetHelp(tr("Install Skin"), NULL, NULL, NULL);
} else if (type == itSkinSetup || type == itNoSkinSetup) { } else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *repo = config.GetSkinRepo(currentSkin); cSkinRepo *repo = config.GetSkinRepo(currentSkin);
if (repo && repo->Type() == rtGit) { if (repo) {
SetHelp(tr("Update from Git"), NULL, NULL, NULL); if (repo->Type() == rtGit)
SetHelp(tr("Update from Git"), NULL, tr("Delete Skin"), NULL);
else
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
} }
} }
} }
@ -207,6 +210,20 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
} }
} }
} }
// KEY YELLOW
if (Key == kYellow) {
if (type == itSkinSetup || type == itNoSkinSetup) {
if (config.SkinActive(currentSkin)) {
Skins.Message(mtError, tr("Skin is running and can't be deleted"));
} else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) {
config.DeleteSkin(currentSkin);
Skins.Message(mtStatus, tr("Skin deleted"));
cCondWait::SleepMs(1000);
return osEnd;
}
state = osContinue;
}
}
} }
return state; return state;
} }
@ -366,7 +383,7 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
break; break;
} else { } else {
return osBack; return osBack;
} }
} }
case kRed: { case kRed: {
bool gitAvailable = StartUpdate(skin); bool gitAvailable = StartUpdate(skin);
@ -375,6 +392,20 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
} else { } else {
Skins.Message(mtStatus, tr("No Git Repsoitory available")); Skins.Message(mtStatus, tr("No Git Repsoitory available"));
} }
break;
}
// KEY YELLOW
case kYellow: {
if (config.SkinActive(skin)) {
Skins.Message(mtError, tr("Skin is running and can't be deleted"));
} else if (Interface->Confirm(*cString::sprintf("%s?", tr("Really delete skin")))) {
config.DeleteSkin(skin);
Skins.Message(mtStatus, tr("Skin deleted"));
cCondWait::SleepMs(1000);
return osEnd;
}
state = osContinue;
break;
} }
default: default:
break; break;
@ -390,8 +421,11 @@ void cSkindesignerSkinSetup::Set(void) {
} }
cSkinRepo *repo = config.GetSkinRepo(skin); cSkinRepo *repo = config.GetSkinRepo(skin);
if (repo && repo->Type() == rtGit) { if (repo) {
SetHelp(tr("Update from Git"), NULL, NULL, NULL); if (repo->Type() == rtGit)
SetHelp(tr("Update from Git"), NULL, tr("Delete Skin"), NULL);
else
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
} }
menu->InitParameterIterator(); menu->InitParameterIterator();