mirror of
https://github.com/YACReader/yacreader
synced 2026-04-09 06:12:43 -04:00
moved settings files from local dir to standar paths
added YACReaderLibraries class, libraries are now identified by id
This commit is contained in:
@ -98,7 +98,8 @@ SOURCES += $$PWD/../common/comic.cpp \
|
|||||||
$$PWD/../common/folder.cpp \
|
$$PWD/../common/folder.cpp \
|
||||||
$$PWD/../common/library_item.cpp \
|
$$PWD/../common/library_item.cpp \
|
||||||
$$PWD/yacreader_local_client.cpp \
|
$$PWD/yacreader_local_client.cpp \
|
||||||
$$PWD/../common/http_worker.cpp
|
$$PWD/../common/http_worker.cpp \
|
||||||
|
$$PWD/../common/yacreader_global.cpp \
|
||||||
|
|
||||||
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
||||||
include($$PWD/../compressed_archive/wrapper.pri)
|
include($$PWD/../compressed_archive/wrapper.pri)
|
||||||
|
|||||||
@ -30,11 +30,13 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
app.setApplicationName("YACReader");
|
||||||
|
app.setOrganizationName("YACReader");
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QString sufix = QLocale::system().name();
|
QString sufix = QLocale::system().name();
|
||||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
app.setApplicationName("YACReader");
|
|
||||||
|
|
||||||
MainWindowViewer * mwv = new MainWindowViewer();
|
MainWindowViewer * mwv = new MainWindowViewer();
|
||||||
mwv->show();
|
mwv->show();
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
#include "yacreader_local_client.h"
|
#include "yacreader_local_client.h"
|
||||||
|
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -105,7 +107,7 @@ MainWindowViewer::~MainWindowViewer()
|
|||||||
}
|
}
|
||||||
void MainWindowViewer::loadConfiguration()
|
void MainWindowViewer::loadConfiguration()
|
||||||
{
|
{
|
||||||
settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
settings = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
|
|
||||||
Configuration & config = Configuration::getConfiguration();
|
Configuration & config = Configuration::getConfiguration();
|
||||||
config.load(settings);
|
config.load(settings);
|
||||||
|
|||||||
@ -242,7 +242,7 @@ void OptionsDialog::fitToWidthRatio(int value)
|
|||||||
|
|
||||||
void OptionsDialog::brightnessChanged(int value)
|
void OptionsDialog::brightnessChanged(int value)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
settings.setValue(BRIGHTNESS,value);
|
settings.setValue(BRIGHTNESS,value);
|
||||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||||
//emit(changedImageOptions());
|
//emit(changedImageOptions());
|
||||||
@ -250,7 +250,7 @@ void OptionsDialog::brightnessChanged(int value)
|
|||||||
|
|
||||||
void OptionsDialog::contrastChanged(int value)
|
void OptionsDialog::contrastChanged(int value)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
settings.setValue(CONTRAST,value);
|
settings.setValue(CONTRAST,value);
|
||||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||||
///emit(changedImageOptions());
|
///emit(changedImageOptions());
|
||||||
@ -258,7 +258,7 @@ void OptionsDialog::contrastChanged(int value)
|
|||||||
|
|
||||||
void OptionsDialog::gammaChanged(int value)
|
void OptionsDialog::gammaChanged(int value)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
settings.setValue(GAMMA,value);
|
settings.setValue(GAMMA,value);
|
||||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||||
//emit(changedImageOptions());
|
//emit(changedImageOptions());
|
||||||
@ -269,7 +269,7 @@ void OptionsDialog::resetImageConfig()
|
|||||||
brightnessS->setValue(0);
|
brightnessS->setValue(0);
|
||||||
contrastS->setValue(100);
|
contrastS->setValue(100);
|
||||||
gammaS->setValue(100);
|
gammaS->setValue(100);
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
settings.setValue(BRIGHTNESS,0);
|
settings.setValue(BRIGHTNESS,0);
|
||||||
settings.setValue(CONTRAST,100);
|
settings.setValue(CONTRAST,100);
|
||||||
settings.setValue(GAMMA,100);
|
settings.setValue(GAMMA,100);
|
||||||
@ -280,7 +280,7 @@ void OptionsDialog::resetImageConfig()
|
|||||||
void OptionsDialog::show()
|
void OptionsDialog::show()
|
||||||
{
|
{
|
||||||
//TODO solucionar el tema de las settings, esto s<>lo deber<65>a aparecer en una <20>nica l<>nea de c<>digo
|
//TODO solucionar el tema de las settings, esto s<>lo deber<65>a aparecer en una <20>nica l<>nea de c<>digo
|
||||||
QSettings *s = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings *s = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
fitToWidthRatioS->disconnect();
|
fitToWidthRatioS->disconnect();
|
||||||
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||||
connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
|
connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
|
||||||
|
|||||||
@ -242,7 +242,7 @@ QImage BrightnessFilter::setFilter(const QImage & image)
|
|||||||
return result;*/
|
return result;*/
|
||||||
if(level ==-1)
|
if(level ==-1)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
|
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -320,7 +320,7 @@ QImage ContrastFilter::setFilter(const QImage & image)
|
|||||||
return result;*/
|
return result;*/
|
||||||
if(level ==-1)
|
if(level ==-1)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
return changeContrast(image,settings.value(CONTRAST,100).toInt());
|
return changeContrast(image,settings.value(CONTRAST,100).toInt());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -341,7 +341,7 @@ QImage GammaFilter::setFilter(const QImage & image)
|
|||||||
{
|
{
|
||||||
if(level ==-1)
|
if(level ==-1)
|
||||||
{
|
{
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
return changeGamma(image,settings.value(GAMMA,100).toInt());
|
return changeGamma(image,settings.value(GAMMA,100).toInt());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -61,7 +61,7 @@ shouldOpenPrevious(false)
|
|||||||
|
|
||||||
goToDialog = new GoToDialog(this);
|
goToDialog = new GoToDialog(this);
|
||||||
|
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
|
|
||||||
//CONFIG GOTO_FLOW--------------------------------------------------------
|
//CONFIG GOTO_FLOW--------------------------------------------------------
|
||||||
if(QGLFormat::hasOpenGL() && !settings->contains(USE_OPEN_GL))
|
if(QGLFormat::hasOpenGL() && !settings->contains(USE_OPEN_GL))
|
||||||
@ -894,7 +894,7 @@ void Viewer::updateComic(ComicDB & comic)
|
|||||||
comic.info.bookmark3 = boomarksList[2];
|
comic.info.bookmark3 = boomarksList[2];
|
||||||
//set filters
|
//set filters
|
||||||
//TODO: avoid use settings for this...
|
//TODO: avoid use settings for this...
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||||
int brightness = settings.value(BRIGHTNESS,0).toInt();
|
int brightness = settings.value(BRIGHTNESS,0).toInt();
|
||||||
int contrast = settings.value(CONTRAST,100).toInt();
|
int contrast = settings.value(CONTRAST,100).toInt();
|
||||||
int gamma = settings.value(GAMMA,100).toInt();
|
int gamma = settings.value(GAMMA,100).toInt();
|
||||||
|
|||||||
@ -78,7 +78,8 @@ HEADERS += comic_flow.h \
|
|||||||
yacreader_local_server.h \
|
yacreader_local_server.h \
|
||||||
yacreader_main_toolbar.h \
|
yacreader_main_toolbar.h \
|
||||||
comics_remover.h \
|
comics_remover.h \
|
||||||
../common/http_worker.h
|
../common/http_worker.h \
|
||||||
|
yacreader_libraries.h
|
||||||
|
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
create_library_dialog.cpp \
|
create_library_dialog.cpp \
|
||||||
@ -118,7 +119,9 @@ SOURCES += comic_flow.cpp \
|
|||||||
yacreader_local_server.cpp \
|
yacreader_local_server.cpp \
|
||||||
yacreader_main_toolbar.cpp \
|
yacreader_main_toolbar.cpp \
|
||||||
comics_remover.cpp \
|
comics_remover.cpp \
|
||||||
../common/http_worker.cpp
|
../common/http_worker.cpp \
|
||||||
|
../common/yacreader_global.cpp \
|
||||||
|
yacreader_libraries.cpp
|
||||||
|
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
|
|||||||
@ -75,7 +75,7 @@ void CreateLibraryDialog::setupUI()
|
|||||||
setWindowTitle(tr("Create new library"));
|
setWindowTitle(tr("Create new library"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateLibraryDialog::show(const QMap<QString,QString> & libs)
|
void CreateLibraryDialog::show(const YACReaderLibraries & libs)
|
||||||
{
|
{
|
||||||
libraries = libs;
|
libraries = libs;
|
||||||
QDialog::show();
|
QDialog::show();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#ifndef __CREATE_LIBRARY_DIALOG_H
|
#ifndef __CREATE_LIBRARY_DIALOG_H
|
||||||
#define __CREATE_LIBRARY_DIALOG_H
|
#define __CREATE_LIBRARY_DIALOG_H
|
||||||
|
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@ -23,7 +25,7 @@
|
|||||||
QPushButton * find;
|
QPushButton * find;
|
||||||
QPushButton * accept;
|
QPushButton * accept;
|
||||||
QPushButton * cancel;
|
QPushButton * cancel;
|
||||||
QMap<QString,QString> libraries;
|
YACReaderLibraries libraries;
|
||||||
void setupUI();
|
void setupUI();
|
||||||
public slots:
|
public slots:
|
||||||
void create();
|
void create();
|
||||||
@ -32,7 +34,7 @@
|
|||||||
void setDataAndStart(QString name, QString paht);
|
void setDataAndStart(QString name, QString paht);
|
||||||
void nameSetted(const QString & text);
|
void nameSetted(const QString & text);
|
||||||
void pathSetted(const QString & text);
|
void pathSetted(const QString & text);
|
||||||
void show(const QMap<QString,QString> & libraries);
|
void show(const YACReaderLibraries &libraries);
|
||||||
signals:
|
signals:
|
||||||
void createLibrary(QString source, QString target, QString name);
|
void createLibrary(QString source, QString target, QString name);
|
||||||
void cancelCreate();
|
void cancelCreate();
|
||||||
|
|||||||
@ -16,54 +16,21 @@
|
|||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
#include "data_base_management.h"
|
#include "data_base_management.h"
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "qnaturalsorting.h"
|
#include "qnaturalsorting.h"
|
||||||
|
|
||||||
//server
|
//server
|
||||||
|
|
||||||
//TODO optimizar, evitar que se tenga que leer en cada petición el archivo
|
YACReaderLibraries DBHelper::getLibraries()
|
||||||
//conservar un QDateTime stático que compruebe si libraries.yacr ha sido modificado
|
|
||||||
//libraries debe ser una variable estática
|
|
||||||
static QDateTime lastModified;
|
|
||||||
static QMap<QString,QString> libraries;
|
|
||||||
|
|
||||||
QMap<QString,QString> DBHelper::getLibraries()
|
|
||||||
{
|
{
|
||||||
QFileInfo fi(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
YACReaderLibraries libraries;
|
||||||
if(fi.lastModified() == lastModified)
|
libraries.load();
|
||||||
return libraries;
|
|
||||||
|
|
||||||
lastModified = fi.lastModified();
|
|
||||||
libraries.clear();
|
|
||||||
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
QTextStream txtS(&f);
|
|
||||||
QString content = txtS.readAll();
|
|
||||||
QStringList lines = content.split('\n');
|
|
||||||
QString line,name;
|
|
||||||
int i=0;
|
|
||||||
foreach(line,lines)
|
|
||||||
{
|
|
||||||
if((i%2)==0)
|
|
||||||
{
|
|
||||||
name = line;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//sólo se agregan las bibliotecas realmente disponibles
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(line.trimmed()+"/.yacreaderlibrary");
|
|
||||||
if(db.isValid())
|
|
||||||
libraries.insert(name.trimmed(),line.trimmed());
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
f.close();
|
|
||||||
return libraries;
|
return libraries;
|
||||||
}
|
}
|
||||||
QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId)
|
QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
QList<LibraryItem *> list = DBHelper::getFoldersFromParent(folderId,db,false);
|
QList<LibraryItem *> list = DBHelper::getFoldersFromParent(folderId,db,false);
|
||||||
@ -74,7 +41,7 @@ QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libra
|
|||||||
}
|
}
|
||||||
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId)
|
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
QList<LibraryItem *> list = DBHelper::getComicsFromParent(folderId,db,false);
|
QList<LibraryItem *> list = DBHelper::getComicsFromParent(folderId,db,false);
|
||||||
@ -85,7 +52,7 @@ QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & librar
|
|||||||
}
|
}
|
||||||
qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qulonglong id)
|
qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qulonglong id)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
Folder f = DBHelper::loadFolder(id,db);
|
Folder f = DBHelper::loadFolder(id,db);
|
||||||
@ -96,7 +63,7 @@ qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qul
|
|||||||
}
|
}
|
||||||
ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
|
ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
ComicDB comic = DBHelper::loadComic(id,db);
|
ComicDB comic = DBHelper::loadComic(id,db);
|
||||||
@ -108,7 +75,7 @@ ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
|
|||||||
|
|
||||||
QList<ComicDB> DBHelper::getSiblings(const QString & libraryName, qulonglong parentId)
|
QList<ComicDB> DBHelper::getSiblings(const QString & libraryName, qulonglong parentId)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
QList<ComicDB> comics = DBHelper::getSortedComicsFromParent(parentId,db);
|
QList<ComicDB> comics = DBHelper::getSortedComicsFromParent(parentId,db);
|
||||||
@ -119,7 +86,7 @@ QList<ComicDB> DBHelper::getSiblings(const QString & libraryName, qulonglong par
|
|||||||
|
|
||||||
QString DBHelper::getFolderName(const QString & libraryName, qulonglong id)
|
QString DBHelper::getFolderName(const QString & libraryName, qulonglong id)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
QString name="";
|
QString name="";
|
||||||
@ -143,19 +110,13 @@ QString DBHelper::getFolderName(const QString & libraryName, qulonglong id)
|
|||||||
}
|
}
|
||||||
QList<QString> DBHelper::getLibrariesNames()
|
QList<QString> DBHelper::getLibrariesNames()
|
||||||
{
|
{
|
||||||
QStringList names = getLibraries().keys();
|
QStringList names = getLibraries().getNames();
|
||||||
qSort(names.begin(),names.end(),naturalSortLessThanCI);
|
qSort(names.begin(),names.end(),naturalSortLessThanCI);
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
QString DBHelper::getLibraryName(int id)
|
QString DBHelper::getLibraryName(int id)
|
||||||
{
|
{
|
||||||
QStringList names = getLibrariesNames();
|
return getLibraries().getName(id);
|
||||||
if(names.isEmpty())
|
|
||||||
return "";
|
|
||||||
if(id>=0 && id<names.count())
|
|
||||||
return names.at(id);
|
|
||||||
else
|
|
||||||
return names.at(0);
|
|
||||||
}
|
}
|
||||||
//objects management
|
//objects management
|
||||||
//deletes
|
//deletes
|
||||||
@ -191,7 +152,7 @@ void DBHelper::update(ComicDB * comic, QSqlDatabase & db)
|
|||||||
|
|
||||||
void DBHelper::update(const QString & libraryName, ComicInfo & comicInfo)
|
void DBHelper::update(const QString & libraryName, ComicInfo & comicInfo)
|
||||||
{
|
{
|
||||||
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
DBHelper::update(&comicInfo,db);
|
DBHelper::update(&comicInfo,db);
|
||||||
|
|||||||
@ -12,12 +12,13 @@ class QSqlDatabase;
|
|||||||
class ComicInfo;
|
class ComicInfo;
|
||||||
class QSqlRecord;
|
class QSqlRecord;
|
||||||
class QSqlQuery;
|
class QSqlQuery;
|
||||||
|
class YACReaderLibraries;
|
||||||
|
|
||||||
class DBHelper
|
class DBHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//server
|
//server
|
||||||
static QMap<QString,QString> getLibraries();
|
static YACReaderLibraries getLibraries();
|
||||||
static QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
static QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||||
static QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
static QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||||
static qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
static qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
||||||
|
|||||||
@ -86,7 +86,7 @@ void ImportLibraryDialog::setupUI()
|
|||||||
setModal(true);
|
setModal(true);
|
||||||
setWindowTitle(tr("Extract a catalog"));
|
setWindowTitle(tr("Extract a catalog"));
|
||||||
}
|
}
|
||||||
void ImportLibraryDialog::show(const QMap<QString,QString> & libs)
|
void ImportLibraryDialog::show(const YACReaderLibraries &libs)
|
||||||
{
|
{
|
||||||
libraries = libs;
|
libraries = libs;
|
||||||
QDialog::show();
|
QDialog::show();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef IMPORT_LIBRARY_DIALOG_H
|
#ifndef IMPORT_LIBRARY_DIALOG_H
|
||||||
#define IMPORT_LIBRARY_DIALOG_H
|
#define IMPORT_LIBRARY_DIALOG_H
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@ -29,14 +29,14 @@
|
|||||||
void setupUI();
|
void setupUI();
|
||||||
int progressCount;
|
int progressCount;
|
||||||
void closeEvent ( QCloseEvent * e );
|
void closeEvent ( QCloseEvent * e );
|
||||||
QMap<QString,QString> libraries;
|
YACReaderLibraries libraries;
|
||||||
public slots:
|
public slots:
|
||||||
void add();
|
void add();
|
||||||
void findPath();
|
void findPath();
|
||||||
void findDestination();
|
void findDestination();
|
||||||
void close();
|
void close();
|
||||||
void nameEntered();
|
void nameEntered();
|
||||||
void show(const QMap<QString,QString> & libs);
|
void show(const YACReaderLibraries & libs);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void unpackCLC(QString clc,QString targetFolder, QString name);
|
void unpackCLC(QString clc,QString targetFolder, QString name);
|
||||||
|
|||||||
@ -68,13 +68,14 @@ LibraryWindow::LibraryWindow()
|
|||||||
setupUI();
|
setupUI();
|
||||||
loadLibraries();
|
loadLibraries();
|
||||||
|
|
||||||
if(libraries.size()==0)
|
if(libraries.isEmpty())
|
||||||
{
|
{
|
||||||
showNoLibrariesWidget();
|
showNoLibrariesWidget();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
showRootWidget();
|
showRootWidget();
|
||||||
|
selectedLibrary->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ void LibraryWindow::setupUI()
|
|||||||
libraryCreator = new LibraryCreator();
|
libraryCreator = new LibraryCreator();
|
||||||
packageManager = new PackageManager();
|
packageManager = new PackageManager();
|
||||||
|
|
||||||
settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("libraryConfig");
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
@ -754,7 +755,7 @@ void LibraryWindow::createConnections()
|
|||||||
|
|
||||||
void LibraryWindow::loadLibrary(const QString & name)
|
void LibraryWindow::loadLibrary(const QString & name)
|
||||||
{
|
{
|
||||||
if(libraries.size()>0) //si hay bibliotecas...
|
if(!libraries.isEmpty()) //si hay bibliotecas...
|
||||||
{
|
{
|
||||||
currentFolderNavigation=0;
|
currentFolderNavigation=0;
|
||||||
backAction->setDisabled(true);
|
backAction->setDisabled(true);
|
||||||
@ -763,7 +764,7 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
history.append(QModelIndex());
|
history.append(QModelIndex());
|
||||||
|
|
||||||
showRootWidget();
|
showRootWidget();
|
||||||
QString path=libraries.value(name)+"/.yacreaderlibrary";
|
QString path=libraries.getPath(name)+"/.yacreaderlibrary";
|
||||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||||
QString dbVersion;
|
QString dbVersion;
|
||||||
if(d.exists(path) && d.exists(path+"/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "") //si existe en disco la biblioteca seleccionada, y es v<>lida..
|
if(d.exists(path) && d.exists(path+"/library.ydb") && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "") //si existe en disco la biblioteca seleccionada, y es v<>lida..
|
||||||
@ -804,7 +805,7 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
else
|
else
|
||||||
disableFoldersActions(true);
|
disableFoldersActions(true);
|
||||||
|
|
||||||
d.setCurrent(libraries.value(name));
|
d.setCurrent(libraries.getPath(name));
|
||||||
d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
if(d.count()<=1) //librer<65>a de s<>lo lectura
|
if(d.count()<=1) //librer<65>a de s<>lo lectura
|
||||||
{
|
{
|
||||||
@ -878,7 +879,7 @@ void LibraryWindow::loadLibrary(const QString & name)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
QString path = libraries.value(selectedLibrary->currentText());
|
QString path = libraries.getPath(selectedLibrary->currentText());
|
||||||
if(QMessageBox::question(this,tr("Old library"),tr("Library '%1' has been created with an older version of YACReaderLibrary. It must be created again. Do you want to create the library now?").arg(currentLibrary),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
if(QMessageBox::question(this,tr("Old library"),tr("Library '%1' has been created with an older version of YACReaderLibrary. It must be created again. Do you want to create the library now?").arg(currentLibrary),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
QDir d(path+"/.yacreaderlibrary");
|
QDir d(path+"/.yacreaderlibrary");
|
||||||
@ -1107,10 +1108,10 @@ void LibraryWindow::openLastCreated()
|
|||||||
selectedLibrary->disconnect();
|
selectedLibrary->disconnect();
|
||||||
|
|
||||||
selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded));
|
selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded));
|
||||||
libraries.insert(_lastAdded,_sourceLastAdded);
|
libraries.addLibrary(_lastAdded,_sourceLastAdded);
|
||||||
selectedLibrary->addItem(_lastAdded,_sourceLastAdded);
|
selectedLibrary->addItem(_lastAdded,_sourceLastAdded);
|
||||||
selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded));
|
selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded));
|
||||||
saveLibraries();
|
libraries.save();
|
||||||
|
|
||||||
connect(selectedLibrary,SIGNAL(currentIndexChanged(QString)),this,SLOT(loadLibrary(QString)));
|
connect(selectedLibrary,SIGNAL(currentIndexChanged(QString)),this,SLOT(loadLibrary(QString)));
|
||||||
|
|
||||||
@ -1147,40 +1148,17 @@ void LibraryWindow::openLibrary(QString path, QString name)
|
|||||||
|
|
||||||
void LibraryWindow::loadLibraries()
|
void LibraryWindow::loadLibraries()
|
||||||
{
|
{
|
||||||
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
libraries.load();
|
||||||
f.open(QIODevice::ReadOnly);
|
foreach(QString name,libraries.getNames())
|
||||||
QTextStream txtS(&f);
|
selectedLibrary->addItem(name,libraries.getPath(name));
|
||||||
QString content = txtS.readAll();
|
|
||||||
QStringList lines = content.split('\n');
|
|
||||||
QString line,name;
|
|
||||||
int i=0;
|
|
||||||
bool librariesAvailable = false;
|
|
||||||
foreach(line,lines)
|
|
||||||
{
|
|
||||||
if((i%2)==0)
|
|
||||||
{
|
|
||||||
name = line;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
librariesAvailable = true;
|
|
||||||
libraries.insert(name.trimmed(),line.trimmed());
|
|
||||||
selectedLibrary->addItem(name.trimmed(),line.trimmed());
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!librariesAvailable)
|
|
||||||
{
|
|
||||||
disableAllActions();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
selectedLibrary->setCurrentIndex(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LibraryWindow::saveLibraries()
|
void LibraryWindow::saveLibraries()
|
||||||
{
|
{
|
||||||
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
|
||||||
|
libraries.save();
|
||||||
|
/*QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
||||||
if(!f.open(QIODevice::WriteOnly))
|
if(!f.open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(NULL,tr("Saving libraries file...."),tr("There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder."));
|
QMessageBox::critical(NULL,tr("Saving libraries file...."),tr("There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder."));
|
||||||
@ -1193,7 +1171,7 @@ void LibraryWindow::saveLibraries()
|
|||||||
txtS << i.key() << "\n";
|
txtS << i.key() << "\n";
|
||||||
txtS << i.value() << "\n";
|
txtS << i.value() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::updateLibrary()
|
void LibraryWindow::updateLibrary()
|
||||||
@ -1202,7 +1180,7 @@ void LibraryWindow::updateLibrary()
|
|||||||
showImportingWidget();
|
showImportingWidget();
|
||||||
|
|
||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
QString path = libraries.value(currentLibrary);
|
QString path = libraries.getPath(currentLibrary);
|
||||||
_lastAdded = currentLibrary;
|
_lastAdded = currentLibrary;
|
||||||
libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary");
|
libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary");
|
||||||
libraryCreator->start();
|
libraryCreator->start();
|
||||||
@ -1210,7 +1188,7 @@ void LibraryWindow::updateLibrary()
|
|||||||
|
|
||||||
void LibraryWindow::deleteCurrentLibrary()
|
void LibraryWindow::deleteCurrentLibrary()
|
||||||
{
|
{
|
||||||
QString path = libraries.value(selectedLibrary->currentText());
|
QString path = libraries.getPath(selectedLibrary->currentText());
|
||||||
libraries.remove(selectedLibrary->currentText());
|
libraries.remove(selectedLibrary->currentText());
|
||||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
//selectedLibrary->setCurrentIndex(0);
|
//selectedLibrary->setCurrentIndex(0);
|
||||||
@ -1219,13 +1197,13 @@ void LibraryWindow::deleteCurrentLibrary()
|
|||||||
QDir d(path);
|
QDir d(path);
|
||||||
delTree(d);
|
delTree(d);
|
||||||
d.rmdir(path);
|
d.rmdir(path);
|
||||||
if(libraries.size()==0)//no more libraries avaliable.
|
if(libraries.isEmpty())//no more libraries avaliable.
|
||||||
{
|
{
|
||||||
comicView->setModel(NULL);
|
comicView->setModel(NULL);
|
||||||
foldersView->setModel(NULL);
|
foldersView->setModel(NULL);
|
||||||
comicFlow->clear();
|
comicFlow->clear();
|
||||||
}
|
}
|
||||||
saveLibraries();
|
libraries.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::removeLibrary()
|
void LibraryWindow::removeLibrary()
|
||||||
@ -1239,20 +1217,20 @@ void LibraryWindow::removeLibrary()
|
|||||||
libraries.remove(currentLibrary);
|
libraries.remove(currentLibrary);
|
||||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
//selectedLibrary->setCurrentIndex(0);
|
//selectedLibrary->setCurrentIndex(0);
|
||||||
if(libraries.size()==0)//no more libraries avaliable.
|
if(libraries.isEmpty())//no more libraries avaliable.
|
||||||
{
|
{
|
||||||
comicView->setModel(NULL);
|
comicView->setModel(NULL);
|
||||||
foldersView->setModel(NULL);
|
foldersView->setModel(NULL);
|
||||||
comicFlow->clear();
|
comicFlow->clear();
|
||||||
}
|
}
|
||||||
saveLibraries();
|
libraries.save();
|
||||||
}
|
}
|
||||||
else if(ret == QMessageBox::YesToAll)
|
else if(ret == QMessageBox::YesToAll)
|
||||||
{
|
{
|
||||||
deleteCurrentLibrary();
|
deleteCurrentLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(libraries.size()==0)
|
if(libraries.isEmpty())
|
||||||
{
|
{
|
||||||
disableAllActions();
|
disableAllActions();
|
||||||
showNoLibrariesWidget();
|
showNoLibrariesWidget();
|
||||||
@ -1264,19 +1242,18 @@ void LibraryWindow::renameLibrary()
|
|||||||
renameLibraryDialog->show();
|
renameLibraryDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::rename(QString newName)
|
void LibraryWindow::rename(QString newName) //TODO replace
|
||||||
{
|
{
|
||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
if(newName != currentLibrary)
|
if(newName != currentLibrary)
|
||||||
{
|
{
|
||||||
if(!libraries.contains(newName))
|
if(!libraries.contains(newName))
|
||||||
{
|
{
|
||||||
QString path = libraries.value(currentLibrary);
|
libraries.rename(currentLibrary,newName);
|
||||||
libraries.remove(currentLibrary);
|
|
||||||
//selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
//selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
libraries.insert(newName,path);
|
//libraries.addLibrary(newName,path);
|
||||||
selectedLibrary->renameCurrentLibrary(newName);
|
selectedLibrary->renameCurrentLibrary(newName);
|
||||||
saveLibraries();
|
libraries.save();
|
||||||
renameLibraryDialog->close();
|
renameLibraryDialog->close();
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
if(!foldersView->currentIndex().isValid())
|
if(!foldersView->currentIndex().isValid())
|
||||||
@ -1306,9 +1283,9 @@ void LibraryWindow::stopLibraryCreator()
|
|||||||
|
|
||||||
void LibraryWindow::setRootIndex()
|
void LibraryWindow::setRootIndex()
|
||||||
{
|
{
|
||||||
if(libraries.size()>0)
|
if(!libraries.isEmpty())
|
||||||
{
|
{
|
||||||
QString path=libraries.value(selectedLibrary->currentText())+"/.yacreaderlibrary";
|
QString path=libraries.getPath(selectedLibrary->currentText())+"/.yacreaderlibrary";
|
||||||
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
QDir d; //TODO change this by static methods (utils class?? with delTree for example)
|
||||||
if(d.exists(path))
|
if(d.exists(path))
|
||||||
{
|
{
|
||||||
@ -1498,7 +1475,7 @@ void LibraryWindow::openContainingFolder()
|
|||||||
void LibraryWindow::exportLibrary(QString destPath)
|
void LibraryWindow::exportLibrary(QString destPath)
|
||||||
{
|
{
|
||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
QString path = libraries.value(currentLibrary)+"/.yacreaderlibrary";
|
QString path = libraries.getPath(currentLibrary)+"/.yacreaderlibrary";
|
||||||
packageManager->createPackage(path,destPath+"/"+currentLibrary);
|
packageManager->createPackage(path,destPath+"/"+currentLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1517,7 +1494,7 @@ void LibraryWindow::reloadOptions()
|
|||||||
|
|
||||||
QString LibraryWindow::currentPath()
|
QString LibraryWindow::currentPath()
|
||||||
{
|
{
|
||||||
return libraries.value(selectedLibrary->currentText());
|
return libraries.getPath(selectedLibrary->currentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::hideComicFlow(bool hide)
|
void LibraryWindow::hideComicFlow(bool hide)
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
|
#include <yacreader_libraries.h>
|
||||||
|
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QDirModel;
|
class QDirModel;
|
||||||
@ -97,7 +98,7 @@ private:
|
|||||||
TreeModel * dm;
|
TreeModel * dm;
|
||||||
TableModel * dmCV;
|
TableModel * dmCV;
|
||||||
//QStringList paths;
|
//QStringList paths;
|
||||||
QMap<QString,QString> libraries;
|
YACReaderLibraries libraries;
|
||||||
QLabel * fullScreenToolTip;
|
QLabel * fullScreenToolTip;
|
||||||
|
|
||||||
QStackedWidget * mainWidget;
|
QStackedWidget * mainWidget;
|
||||||
|
|||||||
@ -10,17 +10,12 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#else
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
#include "yacreader_local_server.h"
|
#include "yacreader_local_server.h"
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
#include "QsLogDest.h"
|
#include "QsLogDest.h"
|
||||||
@ -110,7 +105,7 @@ void logSystemAndConfig()
|
|||||||
else
|
else
|
||||||
QLOG_INFO() << "qrencode : not found";
|
QLOG_INFO() << "qrencode : not found";
|
||||||
|
|
||||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
settings.beginGroup("libraryConfig");
|
settings.beginGroup("libraryConfig");
|
||||||
if(settings.value(SERVER_ON).toBool())
|
if(settings.value(SERVER_ON).toBool())
|
||||||
QLOG_INFO() << "server : enabled";
|
QLOG_INFO() << "server : enabled";
|
||||||
@ -122,7 +117,7 @@ void logSystemAndConfig()
|
|||||||
else
|
else
|
||||||
QLOG_INFO() << "OpenGL : disabled";
|
QLOG_INFO() << "OpenGL : disabled";
|
||||||
|
|
||||||
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries();
|
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
|
||||||
QLOG_INFO() << "--------------------------------------------";
|
QLOG_INFO() << "--------------------------------------------";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,16 +128,8 @@ int main( int argc, char ** argv )
|
|||||||
app.setApplicationName("YACReaderLibrary");
|
app.setApplicationName("YACReaderLibrary");
|
||||||
app.setOrganizationName("YACReader");
|
app.setOrganizationName("YACReader");
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
||||||
QString destLog = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/yacreaderlibrary.log";
|
QDir().mkpath(YACReader::getSettingsPath());
|
||||||
QString destErr = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/yacreaderlibrary.err";
|
|
||||||
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
|
||||||
|
|
||||||
#else
|
|
||||||
QString destLog = QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/yacreaderlibrary.log";
|
|
||||||
QString destErr = QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/yacreaderlibrary.err";
|
|
||||||
QDir().mkpath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Logger& logger = Logger::instance();
|
Logger& logger = Logger::instance();
|
||||||
logger.setLoggingLevel(QsLogging::TraceLevel);
|
logger.setLoggingLevel(QsLogging::TraceLevel);
|
||||||
@ -166,7 +153,7 @@ int main( int argc, char ** argv )
|
|||||||
qRegisterMetaType<ComicDB>("ComicDB");
|
qRegisterMetaType<ComicDB>("ComicDB");
|
||||||
|
|
||||||
#ifdef SERVER_RELEASE
|
#ifdef SERVER_RELEASE
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("libraryConfig");
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
s = new Startup();
|
s = new Startup();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "comiccontroller.h"
|
#include "comiccontroller.h"
|
||||||
|
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "../static.h"
|
#include "../static.h"
|
||||||
@ -38,14 +39,14 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
//que crear una clase que se encargue de estas cosas
|
//que crear una clase que se encargue de estas cosas
|
||||||
//<2F>Se est<73> accediendo a la UI desde un hilo?
|
//<2F>Se est<73> accediendo a la UI desde un hilo?
|
||||||
|
|
||||||
QMap<QString,QString> libraries = DBHelper::getLibraries();
|
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||||
|
|
||||||
|
|
||||||
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
||||||
|
|
||||||
session.setDownloadedComic(comic.info.hash);
|
session.setDownloadedComic(comic.info.hash);
|
||||||
|
|
||||||
Comic * comicFile = FactoryComic::newComic(libraries.value(libraryName)+comic.path);
|
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryName)+comic.path);
|
||||||
|
|
||||||
if(comicFile != NULL)
|
if(comicFile != NULL)
|
||||||
{
|
{
|
||||||
@ -58,7 +59,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
comicFile->load(libraries.value(libraryName)+comic.path);
|
comicFile->load(libraries.getPath(libraryName)+comic.path);
|
||||||
|
|
||||||
if(thread != NULL)
|
if(thread != NULL)
|
||||||
thread->start();
|
thread->start();
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "covercontroller.h"
|
#include "covercontroller.h"
|
||||||
#include "db_helper.h" //get libraries
|
#include "db_helper.h" //get libraries
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "../static.h"
|
#include "../static.h"
|
||||||
@ -15,7 +16,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
response.setHeader("Connection","close");
|
response.setHeader("Connection","close");
|
||||||
//response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
//response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||||
|
|
||||||
QMap<QString,QString> libraries = DBHelper::getLibraries();
|
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||||
|
|
||||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||||
QStringList pathElements = path.split('/');
|
QStringList pathElements = path.split('/');
|
||||||
@ -40,7 +41,7 @@ void CoverController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
// file.close();
|
// file.close();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
QImage img(libraries.value(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
QImage img(libraries.getPath(libraryName)+"/.yacreaderlibrary/covers/"+fileName);
|
||||||
if (!img.isNull()) {
|
if (!img.isNull()) {
|
||||||
|
|
||||||
int width = 80;
|
int width = 80;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "librariescontroller.h"
|
#include "librariescontroller.h"
|
||||||
#include "db_helper.h" //get libraries
|
#include "db_helper.h" //get libraries
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "../static.h"
|
#include "../static.h"
|
||||||
@ -39,13 +40,17 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
|||||||
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
||||||
t.enableWarnings();
|
t.enableWarnings();
|
||||||
|
|
||||||
|
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||||
QList<QString> names = DBHelper::getLibrariesNames();
|
QList<QString> names = DBHelper::getLibrariesNames();
|
||||||
|
|
||||||
t.loop("library",names.length());
|
t.loop("library",names.length());
|
||||||
int i=0;
|
|
||||||
while (i<names.length()) {
|
int currentId = 0;
|
||||||
t.setVariable(QString("library%1.name").arg(i),QString::number(i));
|
int i = 0;
|
||||||
t.setVariable(QString("library%1.label").arg(i),names.at(i));
|
foreach (QString name,names) {
|
||||||
|
currentId = libraries.getId(name);
|
||||||
|
t.setVariable(QString("library%1.name").arg(i),QString::number(currentId));
|
||||||
|
t.setVariable(QString("library%1.label").arg(i),name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "controllers/errorcontroller.h"
|
#include "controllers/errorcontroller.h"
|
||||||
|
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
|
#include "yacreader_libraries.h"
|
||||||
|
|
||||||
RequestMapper::RequestMapper(QObject* parent)
|
RequestMapper::RequestMapper(QObject* parent)
|
||||||
:HttpRequestHandler(parent) {}
|
:HttpRequestHandler(parent) {}
|
||||||
@ -53,7 +54,7 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
|||||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||||
if(!session.isNull() && session.contains("ySession"))
|
if(!session.isNull() && session.contains("ySession"))
|
||||||
{
|
{
|
||||||
if(library.indexIn(path)!=-1 && DBHelper::getLibraries().count() > library.cap(1).toInt() )
|
if(library.indexIn(path)!=-1 && DBHelper::getLibraries().contains(library.cap(1).toInt()) )
|
||||||
{
|
{
|
||||||
//listar el contenido del folder
|
//listar el contenido del folder
|
||||||
if(folder.exactMatch(path))
|
if(folder.exactMatch(path))
|
||||||
|
|||||||
@ -166,7 +166,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent)
|
|||||||
|
|
||||||
this->setFixedSize(image.size());
|
this->setFixedSize(image.size());
|
||||||
|
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("libraryConfig");
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
if(settings->value(SERVER_ON,true).toBool())
|
if(settings->value(SERVER_ON,true).toBool())
|
||||||
@ -184,7 +184,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent)
|
|||||||
|
|
||||||
void ServerConfigDialog::enableServer(int status)
|
void ServerConfigDialog::enableServer(int status)
|
||||||
{
|
{
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("libraryConfig");
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
if(status == Qt::Checked)
|
if(status == Qt::Checked)
|
||||||
@ -313,7 +313,7 @@ void ServerConfigDialog::regenerateQR(const QString & ip)
|
|||||||
void ServerConfigDialog::updatePort()
|
void ServerConfigDialog::updatePort()
|
||||||
{
|
{
|
||||||
|
|
||||||
QSettings * settings = new QSettings(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creaci<63>n del fichero de config con el servidor
|
||||||
settings->beginGroup("listener");
|
settings->beginGroup("listener");
|
||||||
settings->setValue("port",port->text().toInt());
|
settings->setValue("port",port->text().toInt());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|||||||
147
YACReaderLibrary/yacreader_libraries.cpp
Normal file
147
YACReaderLibrary/yacreader_libraries.cpp
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#include "yacreader_libraries.h"
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
YACReaderLibraries::YACReaderLibraries()
|
||||||
|
:QObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
YACReaderLibraries::YACReaderLibraries(const YACReaderLibraries &source)
|
||||||
|
:QObject(),libraries(source.libraries)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> YACReaderLibraries::getNames()
|
||||||
|
{
|
||||||
|
return libraries.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YACReaderLibraries::getPath(const QString &name)
|
||||||
|
{
|
||||||
|
return libraries.value(name).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YACReaderLibraries::getPath(int id)
|
||||||
|
{
|
||||||
|
foreach(QString name, libraries.keys())
|
||||||
|
if(libraries.value(name).first == id)
|
||||||
|
return libraries.value(name).second;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString YACReaderLibraries::getName(int id)
|
||||||
|
{
|
||||||
|
foreach(QString name, libraries.keys())
|
||||||
|
if(libraries.value(name).first == id)
|
||||||
|
return name;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLibraries::isEmpty()
|
||||||
|
{
|
||||||
|
return libraries.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLibraries::contains(const QString &name)
|
||||||
|
{
|
||||||
|
return libraries.contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLibraries::contains(int id)
|
||||||
|
{
|
||||||
|
foreach(QString name, libraries.keys())
|
||||||
|
if(libraries.value(name).first == id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLibraries::remove(const QString &name)
|
||||||
|
{
|
||||||
|
libraries.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLibraries::rename(const QString &oldName, const QString &newName)
|
||||||
|
{
|
||||||
|
if(libraries.contains(oldName))
|
||||||
|
{
|
||||||
|
QPair<int,QString> value = libraries.value(oldName);
|
||||||
|
libraries.remove(oldName);
|
||||||
|
libraries.insert(newName,value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int YACReaderLibraries::getId(const QString &name)
|
||||||
|
{
|
||||||
|
return libraries.value(name).first;
|
||||||
|
}
|
||||||
|
|
||||||
|
YACReaderLibraries &YACReaderLibraries::operator=(const YACReaderLibraries &source)
|
||||||
|
{
|
||||||
|
libraries = source.libraries;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QPair<int, QString> > YACReaderLibraries::getLibraries()
|
||||||
|
{
|
||||||
|
return libraries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void YACReaderLibraries::addLibrary(const QString &name, const QString &path)
|
||||||
|
{
|
||||||
|
int newID=0;
|
||||||
|
foreach(QString name, libraries.keys())
|
||||||
|
newID = qMax(0,libraries.value(name).first);
|
||||||
|
newID++;
|
||||||
|
libraries.insert(name,QPair<int,QString>(newID,path));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLibraries::load()
|
||||||
|
{
|
||||||
|
QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
|
||||||
|
if(settings.value(LIBRARIES).isValid())
|
||||||
|
{
|
||||||
|
QByteArray data = settings.value(LIBRARIES).toByteArray();
|
||||||
|
QDataStream in(&data, QIODevice::ReadOnly);
|
||||||
|
in >> libraries;
|
||||||
|
}
|
||||||
|
else //only for compatibility with old versions (<7.0)
|
||||||
|
{
|
||||||
|
QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr");
|
||||||
|
f.open(QIODevice::ReadOnly);
|
||||||
|
QTextStream txtS(&f);
|
||||||
|
QString content = txtS.readAll();
|
||||||
|
QStringList lines = content.split('\n');
|
||||||
|
QString line,name;
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
foreach(line,lines)
|
||||||
|
{
|
||||||
|
if((i%2)==0)
|
||||||
|
name = line;
|
||||||
|
else
|
||||||
|
addLibrary(name.trimmed(),line.trimmed());
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
f.close();
|
||||||
|
if(save())
|
||||||
|
f.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YACReaderLibraries::save()
|
||||||
|
{
|
||||||
|
QSettings settings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
|
||||||
|
QByteArray data;
|
||||||
|
QDataStream out(&data, QIODevice::WriteOnly);
|
||||||
|
out << libraries;
|
||||||
|
settings.setValue(LIBRARIES, data);
|
||||||
|
|
||||||
|
return settings.isWritable();
|
||||||
|
}
|
||||||
34
YACReaderLibrary/yacreader_libraries.h
Normal file
34
YACReaderLibrary/yacreader_libraries.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef YACREADER_LIBRARIES_H
|
||||||
|
#define YACREADER_LIBRARIES_H
|
||||||
|
|
||||||
|
#include <QtCore>
|
||||||
|
|
||||||
|
class YACReaderLibraries : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
YACReaderLibraries();
|
||||||
|
YACReaderLibraries(const YACReaderLibraries & source);
|
||||||
|
QList<QString> getNames();
|
||||||
|
QString getPath(const QString & name);
|
||||||
|
QString getPath(int id);
|
||||||
|
QString getName(int id);
|
||||||
|
bool isEmpty();
|
||||||
|
bool contains(const QString & name);
|
||||||
|
bool contains(int id);
|
||||||
|
void remove(const QString & name);
|
||||||
|
void rename(const QString & oldName, const QString & newName);
|
||||||
|
int getId(const QString & name);
|
||||||
|
YACReaderLibraries & operator=(const YACReaderLibraries & source);
|
||||||
|
QMap <QString , QPair<int,QString> > getLibraries();
|
||||||
|
public slots:
|
||||||
|
void addLibrary(const QString & name, const QString & path);
|
||||||
|
void load();
|
||||||
|
bool save();
|
||||||
|
private:
|
||||||
|
//name <id,path>
|
||||||
|
QMap <QString , QPair<int,QString> > libraries;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // YACREADER_LIBRARIES_H
|
||||||
13
common/yacreader_global.cpp
Normal file
13
common/yacreader_global.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
using namespace YACReader;
|
||||||
|
|
||||||
|
QString YACReader::getSettingsPath()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||||
|
#else
|
||||||
|
return QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,6 +1,13 @@
|
|||||||
#ifndef __YACREADER_GLOBAL_H
|
#ifndef __YACREADER_GLOBAL_H
|
||||||
#define __YACREADER_GLOBAL_H
|
#define __YACREADER_GLOBAL_H
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#else
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define VERSION "6.5.3"
|
#define VERSION "6.5.3"
|
||||||
|
|
||||||
#define PATH "PATH"
|
#define PATH "PATH"
|
||||||
@ -53,6 +60,8 @@
|
|||||||
|
|
||||||
#define YACREADERLIBRARY_GUID "ea343ff3-2005-4865-b212-7fa7c43999b8"
|
#define YACREADERLIBRARY_GUID "ea343ff3-2005-4865-b212-7fa7c43999b8"
|
||||||
|
|
||||||
|
#define LIBRARIES "LIBRARIES"
|
||||||
|
|
||||||
namespace YACReader
|
namespace YACReader
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -79,6 +88,8 @@ namespace YACReader
|
|||||||
Opened = 2
|
Opened = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString getSettingsPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user