r21817 by craig - Related to #14667: Move template finding code to scpaths
scribus-commit
scribus-commit at lists.scribus.net
Sat Mar 11 19:53:36 UTC 2017
Author: craig
Date: Sat Mar 11 19:53:36 2017
New Revision: 21817
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21817
Log:
Related to #14667: Move template finding code to scpaths
Modified:
trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
trunk/Scribus/scribus/scpaths.cpp
trunk/Scribus/scribus/scpaths.h
Modified: trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21817&path=/trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp Sat Mar 11 19:53:36 2017
@@ -33,7 +33,7 @@
categories.append(cat);
}
return true;
- };
+ }
};
SATDialog::SATDialog(QWidget* parent, QString tmplName, int pageW, int pageH) : QDialog(parent)
@@ -109,6 +109,8 @@
void SATDialog::addCategories(const QString& dir)
{
+ if(dir.isEmpty())
+ return;
// Read categories from the dir itself
QString tmplFile = findTemplateXml(dir);
if (QFile::exists(tmplFile))
@@ -175,11 +177,9 @@
cats.insert(QString("Signs") , QObject::tr("Signs"));
cats.insert(QString("Text Documents"), QObject::tr("Text Documents"));
- addCategories(ScPaths::applicationDataDir() + "/templates");
+ addCategories(ScPaths::instance().applicationDataDir() + "/templates");
addCategories(ScPaths::instance().templateDir());
- QString userTemplateDir(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
- if (!userTemplateDir.isEmpty())
- addCategories(userTemplateDir);
+ addCategories(ScPaths::instance().userTemplateDir(true));
QStringList list = cats.values();
list.removeDuplicates();
Modified: trunk/Scribus/scribus/scpaths.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21817&path=/trunk/Scribus/scribus/scpaths.cpp
==============================================================================
--- trunk/Scribus/scribus/scpaths.cpp (original)
+++ trunk/Scribus/scribus/scpaths.cpp Sat Mar 11 19:53:36 2017
@@ -11,6 +11,7 @@
#include <QProcess>
#include <QStandardPaths>
+#include "prefsmanager.h"
#include "scconfig.h"
#include "scribusapp.h"
@@ -606,6 +607,16 @@
return useFilesDirectory.absolutePath()+"/";
}
+QString ScPaths::userTemplateDir(bool createIfNotExists)
+{
+ if (PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates.isEmpty())
+ return QString();
+ QDir useFilesDirectory(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
+ if(createIfNotExists && !useFilesDirectory.exists())
+ useFilesDirectory.mkpath(useFilesDirectory.absolutePath());
+ return useFilesDirectory.absolutePath()+"/";
+}
+
QString ScPaths::userDocumentDir(void)
{
QString userDocs = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
Modified: trunk/Scribus/scribus/scpaths.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21817&path=/trunk/Scribus/scribus/scpaths.h
==============================================================================
--- trunk/Scribus/scribus/scpaths.h (original)
+++ trunk/Scribus/scribus/scpaths.h Sat Mar 11 19:53:36 2017
@@ -83,6 +83,8 @@
static QString userHelpFilesDir(bool createIfNotExists);
/** @brief Return path to application data dir for downloaded palettes */
static QString userPaletteFilesDir(bool createIfNotExists);
+ /** @brief Return path to user template dir */
+ static QString userTemplateDir(bool createIfNotExists);
/** @brief Return path to image cache dir*/
static QString imageCacheDir(void);
/** @brief Return path to plugin data dir*/
More information about the scribus-commit
mailing list