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
- 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();
}
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) {
if (skinRefsIterator == skinRefs.end()) {
return NULL;

View File

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

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.0.1\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"
"Last-Translator: Louis Braun <louis.braun@gmx.de>\n"
"Language-Team: \n"
@ -54,9 +54,21 @@ msgstr "Installiere Skin"
msgid "Update from Git"
msgstr "Aus Git aktualisieren"
msgid "Delete Skin"
msgstr "Skin löschen"
msgid "No Git Repsoitory available"
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"
msgstr ""
@ -143,4 +155,3 @@ msgstr "Unterstützte Plugins"
msgid "Skin Designer"
msgstr "Skin Designer"

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-skindesigner 0.2.0\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"
"Last-Translator: Rolf Ahrenberg\n"
"Language-Team: Finnish\n"
@ -54,9 +54,21 @@ msgstr ""
msgid "Update from Git"
msgstr ""
msgid "Delete Skin"
msgstr ""
msgid "No Git Repsoitory available"
msgstr ""
msgid "Skin is running and can't be deleted"
msgstr ""
msgid "Really delete skin"
msgstr ""
msgid "Skin deleted"
msgstr ""
msgid "Plugin Setup"
msgstr "Yleiset"

48
setup.c
View File

@ -1,3 +1,4 @@
#include <vdr/interface.h>
#include "libcore/curlfuncs.h"
#include "setup.h"
@ -115,7 +116,6 @@ eOSState cInstallManager::ProcessInstallationStatus(void) {
return osContinue;
}
// --- cSkinDesignerSetup -----------------------------------------------------------
cSkinDesignerSetup::cSkinDesignerSetup() {
numLogosPerSizeInitial = config.numLogosPerSizeInitial;
@ -161,7 +161,7 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
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);
cOsdItem *current = Get(Current());
cSkinMenuItem *skinMenuItem = dynamic_cast<cSkinMenuItem*>(current);
@ -188,8 +188,11 @@ eOSState cSkinDesignerSetup::ProcessKey(eKeys Key) {
SetHelp(tr("Install Skin"), NULL, NULL, NULL);
} else if (type == itSkinSetup || type == itNoSkinSetup) {
cSkinRepo *repo = config.GetSkinRepo(currentSkin);
if (repo && repo->Type() == rtGit) {
SetHelp(tr("Update from Git"), NULL, NULL, NULL);
if (repo) {
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;
}
@ -366,7 +383,7 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
break;
} else {
return osBack;
}
}
}
case kRed: {
bool gitAvailable = StartUpdate(skin);
@ -375,6 +392,20 @@ eOSState cSkindesignerSkinSetup::ProcessKey(eKeys Key) {
} else {
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:
break;
@ -390,8 +421,11 @@ void cSkindesignerSkinSetup::Set(void) {
}
cSkinRepo *repo = config.GetSkinRepo(skin);
if (repo && repo->Type() == rtGit) {
SetHelp(tr("Update from Git"), NULL, NULL, NULL);
if (repo) {
if (repo->Type() == rtGit)
SetHelp(tr("Update from Git"), NULL, tr("Delete Skin"), NULL);
else
SetHelp(NULL, NULL, tr("Delete Skin"), NULL);
}
menu->InitParameterIterator();