mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 00:58:32 -04:00
Extracted default templateengine setting to Startup, so base code is no longer modified.
This commit is contained in:
parent
95cb741880
commit
d2b7487149
@ -6,7 +6,7 @@
|
|||||||
TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
|
TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
|
||||||
:TemplateLoader(settings,parent)
|
:TemplateLoader(settings,parent)
|
||||||
{
|
{
|
||||||
cache.setMaxCost(settings->value("cacheSize","160000").toInt());//este tamaño antes era 1000000
|
cache.setMaxCost(settings->value("cacheSize","1000000").toInt());
|
||||||
cacheTimeout=settings->value("cacheTime","60000").toInt();
|
cacheTimeout=settings->value("cacheTime","60000").toInt();
|
||||||
qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost());
|
qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost());
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,11 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent)
|
TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
templatePath=settings->value("path","./server/templates").toString();
|
templatePath=settings->value("path",".").toString();
|
||||||
// Convert relative path to absolute, based on the directory of the config file.
|
// Convert relative path to absolute, based on the directory of the config file.
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
if (QDir::isRelativePath(templatePath) && settings->format()!=QSettings::NativeFormat)
|
if (QDir::isRelativePath(templatePath) && settings->format()!=QSettings::NativeFormat)
|
||||||
@ -22,13 +21,8 @@ TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent)
|
|||||||
if (QDir::isRelativePath(templatePath))
|
if (QDir::isRelativePath(templatePath))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
QFileInfo configFile(settings->fileName());
|
||||||
QFileInfo configFile(QString(DATADIR)+"/yacreader");
|
templatePath=QFileInfo(configFile.absolutePath(),templatePath).absoluteFilePath();
|
||||||
templatePath=QFileInfo(QString(DATADIR)+"/yacreader",templatePath).absoluteFilePath();
|
|
||||||
#else
|
|
||||||
QFileInfo configFile(QCoreApplication::applicationDirPath());
|
|
||||||
templatePath=QFileInfo(QCoreApplication::applicationDirPath(),templatePath).absoluteFilePath();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
fileNameSuffix=settings->value("suffix",".tpl").toString();
|
fileNameSuffix=settings->value("suffix",".tpl").toString();
|
||||||
QString encoding=settings->value("encoding").toString();
|
QString encoding=settings->value("encoding").toString();
|
||||||
|
@ -54,6 +54,22 @@ void Startup::start() {
|
|||||||
// Configure template loader and cache
|
// Configure template loader and cache
|
||||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||||
templateSettings->beginGroup("templates");
|
templateSettings->beginGroup("templates");
|
||||||
|
|
||||||
|
if(templateSettings->value("cacheSize").isNull())
|
||||||
|
templateSettings->setValue("cacheSize","160000");
|
||||||
|
|
||||||
|
QString baseTemplatePath = QString("./server/templates");
|
||||||
|
QString templatePath;
|
||||||
|
|
||||||
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
|
templatePath=QFileInfo(QString(DATADIR)+"/yacreader",baseTemplatePath).absoluteFilePath();
|
||||||
|
#else
|
||||||
|
templatePath=QFileInfo(QCoreApplication::applicationDirPath(),baseTemplatePath).absoluteFilePath();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(templateSettings->value("path").isNull())
|
||||||
|
templateSettings->setValue("path",templatePath);
|
||||||
|
|
||||||
Static::templateLoader=new TemplateCache(templateSettings,app);
|
Static::templateLoader=new TemplateCache(templateSettings,app);
|
||||||
|
|
||||||
// Configure session store
|
// Configure session store
|
||||||
|
Loading…
x
Reference in New Issue
Block a user