From a58ecc08d7a6efe547da7d531a55e1a34dac488f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 16 Feb 2021 15:23:56 +0200 Subject: [PATCH] provide installCustomLayoutTemplate in manager --- app/templates/templatesmanager.cpp | 39 +++++++++++++++++++++++++----- app/templates/templatesmanager.h | 6 +++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/templates/templatesmanager.cpp b/app/templates/templatesmanager.cpp index 19084d74e..dfd39ee34 100644 --- a/app/templates/templatesmanager.cpp +++ b/app/templates/templatesmanager.cpp @@ -229,22 +229,49 @@ QString Manager::proposedTemplateAbsolutePath(QString templateFilename) return QString(Latte::configPath() + "/latte/templates/" + tempfilename); } +bool Manager::hasCustomLayoutTemplate(const QString &templateName) const +{ + for (int i=0; i 0) { + if (hasLayoutTemplate(name) && pos_ > 0) { name = name.left(pos_); } @@ -252,7 +279,7 @@ QString Manager::uniqueLayoutTemplateName(QString name) const QString namePart = name; - while (layoutTemplateExists(name)) { + while (hasLayoutTemplate(name)) { name = namePart + " - " + QString::number(i); i++; } @@ -264,7 +291,7 @@ QString Manager::uniqueViewTemplateName(QString name) const { int pos_ = name.lastIndexOf(QRegExp(QString(" - [0-9]+"))); - if (viewTemplateExists(name) && pos_ > 0) { + if (hasViewTemplate(name) && pos_ > 0) { name = name.left(pos_); } @@ -272,7 +299,7 @@ QString Manager::uniqueViewTemplateName(QString name) const QString namePart = name; - while (viewTemplateExists(name)) { + while (hasViewTemplate(name)) { name = namePart + " - " + QString::number(i); i++; } diff --git a/app/templates/templatesmanager.h b/app/templates/templatesmanager.h index cf88c4e70..0c53e6d41 100644 --- a/app/templates/templatesmanager.h +++ b/app/templates/templatesmanager.h @@ -56,8 +56,9 @@ public: Latte::Corona *corona(); void init(); - bool layoutTemplateExists(const QString &templateName) const; - bool viewTemplateExists(const QString &templateName) const; + bool hasCustomLayoutTemplate(const QString &templateName) const; + bool hasLayoutTemplate(const QString &templateName) const; + bool hasViewTemplate(const QString &templateName) const; bool exportTemplate(const QString &originFile, const QString &destinationFile, const Data::AppletsTable &approvedApplets); bool exportTemplate(const Latte::View *view, const QString &destinationFile, const Data::AppletsTable &approvedApplets); @@ -73,6 +74,7 @@ public: QString proposedTemplateAbsolutePath(QString templateFilename); void importSystemLayouts(); + void installCustomTemplate(const QString &templateFilePath); signals: void newLayoutAdded(const QString &path);