mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
merge
This commit is contained in:
commit
d18a96901b
@ -81,7 +81,8 @@ HEADERS += $$PWD/../common/comic.h \
|
||||
$$PWD/../common/folder.h \
|
||||
$$PWD/../common/library_item.h \
|
||||
$$PWD/yacreader_local_client.h \
|
||||
$$PWD/../common/http_worker.h
|
||||
$$PWD/../common/http_worker.h \
|
||||
$$PWD/../common/exit_check.h \
|
||||
|
||||
SOURCES += $$PWD/../common/comic.cpp \
|
||||
$$PWD/configuration.cpp \
|
||||
@ -113,8 +114,9 @@ SOURCES += $$PWD/../common/comic.cpp \
|
||||
$$PWD/../common/folder.cpp \
|
||||
$$PWD/../common/library_item.cpp \
|
||||
$$PWD/yacreader_local_client.cpp \
|
||||
$$PWD/../common/http_worker.cpp \
|
||||
$$PWD/../common/yacreader_global.cpp \
|
||||
$$PWD/../common/http_worker.cpp \
|
||||
$$PWD/../common/yacreader_global.cpp \
|
||||
$$PWD/../common/exit_check.cpp \
|
||||
|
||||
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
||||
include($$PWD/../compressed_archive/wrapper.pri)
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
Configuration::Configuration()
|
||||
{
|
||||
//read configuration
|
||||
@ -77,7 +79,7 @@ void Configuration::load(const QString & path)
|
||||
alwaysOnTop = false;
|
||||
|
||||
//load from file
|
||||
QFile f(QCoreApplication::applicationDirPath()+path);
|
||||
QFile f(YACReader::getSettingsPath()+path);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream txtS(&f);
|
||||
QString content = txtS.readAll();
|
||||
@ -158,61 +160,3 @@ void Configuration::load(const QString & path)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void Configuration::save()
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/YACReader.conf");
|
||||
if(!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Saving config file...."),tr("There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder."));
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream txtS(&f);
|
||||
|
||||
txtS << PATH << "\n";
|
||||
txtS << defaultPath << "\n";
|
||||
|
||||
txtS << MAG_GLASS_SIZE << "\n";
|
||||
txtS << magnifyingGlassSize.width() <<","<< magnifyingGlassSize.height() << "\n";
|
||||
|
||||
txtS << ZOOM_LEVEL << "\n";
|
||||
txtS << zoomLevel << "\n";
|
||||
|
||||
txtS << SLIDE_SIZE << "\n";
|
||||
txtS << gotoSlideSize.height() << "\n";
|
||||
|
||||
txtS << FIT << "\n";
|
||||
txtS << (int)adjustToWidth << "\n";
|
||||
|
||||
txtS << FLOW_TYPE << "\n";
|
||||
txtS << (int)flowType << "\n";
|
||||
|
||||
txtS << FULLSCREEN << "\n";
|
||||
txtS << (int)fullScreen << "\n";
|
||||
|
||||
txtS << FIT_TO_WIDTH_RATIO << "\n";
|
||||
txtS << fitToWidthRatio << "\n";
|
||||
|
||||
txtS << Y_WINDOW_POS << "\n";
|
||||
txtS << windowPos.x() << "," << windowPos.y() << "\n";
|
||||
|
||||
txtS << Y_WINDOW_SIZE << "\n";
|
||||
txtS << windowSize.width() << "," << windowSize.height() << "\n";
|
||||
|
||||
txtS << MAXIMIZED << "\n";
|
||||
txtS << (int)maximized << "\n";
|
||||
|
||||
txtS << DOUBLE_PAGE << "\n";
|
||||
txtS << (int)doublePage << "\n";
|
||||
|
||||
txtS << ADJUST_TO_FULL_SIZE << "\n";
|
||||
txtS << (int) adjustToFullSize << "\n";
|
||||
|
||||
txtS << BACKGROUND_COLOR << "\n";
|
||||
txtS << backgroundColor.red() << "," << backgroundColor.green() << "," << backgroundColor.blue() << "\n";
|
||||
|
||||
txtS << ALWAYS_ON_TOP << "\n";
|
||||
txtS << (int)alwaysOnTop << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -89,9 +89,6 @@ using namespace YACReader;
|
||||
void setLastVersionCheck(const QDate & date){ settings->setValue(LAST_VERSION_CHECK,date);}
|
||||
int getNumDaysBetweenVersionChecks() {return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS,1).toInt();}
|
||||
void setNumDaysBetweenVersionChecks(int days) {return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS,days);}
|
||||
|
||||
void save();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <QTranslator>
|
||||
#include "main_window_viewer.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include "exit_check.h"
|
||||
|
||||
|
||||
#if defined(WIN32) && defined(_DEBUG)
|
||||
@ -43,7 +43,9 @@ int main(int argc, char * argv[])
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
Configuration::getConfiguration().save();
|
||||
//Configuration::getConfiguration().save();
|
||||
|
||||
YACReader::exitCheck(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
|
||||
int index = list.indexOf(currentComic);
|
||||
if(index == -1) //comic not found
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
|
||||
/*QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
|
||||
if(!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder."));
|
||||
@ -1025,7 +1025,7 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
|
||||
txtS << s << '\n';
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
previousComicPath = nextComicPath = "";
|
||||
|
@ -96,7 +96,8 @@ HEADERS += comic_flow.h \
|
||||
yacreader_main_toolbar.h \
|
||||
comics_remover.h \
|
||||
../common/http_worker.h \
|
||||
yacreader_libraries.h
|
||||
yacreader_libraries.h \
|
||||
../common/exit_check.cpp \
|
||||
|
||||
SOURCES += comic_flow.cpp \
|
||||
create_library_dialog.cpp \
|
||||
@ -138,7 +139,8 @@ SOURCES += comic_flow.cpp \
|
||||
comics_remover.cpp \
|
||||
../common/http_worker.cpp \
|
||||
../common/yacreader_global.cpp \
|
||||
yacreader_libraries.cpp
|
||||
yacreader_libraries.cpp \
|
||||
../common/exit_check.cpp \
|
||||
|
||||
|
||||
include(./server/server.pri)
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include <QDebug>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlRecord>
|
||||
#include <QApplication>
|
||||
#include <QLibrary>
|
||||
|
||||
#include "data_base_management.h"
|
||||
#include "qnaturalsorting.h"
|
||||
#include "db_helper.h"
|
||||
@ -12,6 +15,8 @@
|
||||
#include "compressed_archive.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -61,6 +66,16 @@ void LibraryCreator::run()
|
||||
{
|
||||
stopRunning = false;
|
||||
|
||||
//check for 7z lib
|
||||
QLibrary *sevenzLib = new QLibrary("./utils/7z");
|
||||
if(!sevenzLib->load())
|
||||
{
|
||||
QLOG_ERROR() << "Loading 7z.dll : " + sevenzLib->errorString() << endl;
|
||||
QApplication::exit(YACReader::SevenZNotFound);
|
||||
exit();
|
||||
}
|
||||
sevenzLib->deleteLater();
|
||||
|
||||
if(_mode == CREATOR)
|
||||
{
|
||||
QLOG_INFO() << "Starting to create new library ( " << _source << "," << _target << ")";
|
||||
@ -465,6 +480,9 @@ void LibraryCreator::update(QDir dirS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ThumbnailCreator::crash = false;
|
||||
|
||||
ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target, int coverPage)
|
||||
:_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage)
|
||||
{
|
||||
@ -520,7 +538,16 @@ void ThumbnailCreator::create()
|
||||
else
|
||||
{
|
||||
|
||||
if(crash)
|
||||
return;
|
||||
|
||||
CompressedArchive archive(_fileSource);
|
||||
if(!archive.toolsLoaded())
|
||||
{
|
||||
QLOG_WARN() << "Extracting cover: 7z lib not loaded";
|
||||
crash = true;
|
||||
return;
|
||||
}
|
||||
if(!archive.isValid())
|
||||
QLOG_WARN() << "Extracting cover: file format not supported " << _fileSource;
|
||||
//se filtran para obtener sólo los formatos soportados
|
||||
|
@ -72,6 +72,7 @@
|
||||
int _numPages;
|
||||
QPixmap _cover;
|
||||
int _coverPage;
|
||||
static bool crash;
|
||||
|
||||
public slots:
|
||||
void create();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QSettings>
|
||||
#include <QLibrary>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "startup.h"
|
||||
@ -16,6 +17,7 @@
|
||||
#include "comic_db.h"
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
#include "exit_check.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
#include "QsLogDest.h"
|
||||
@ -186,12 +188,14 @@ int main( int argc, char ** argv )
|
||||
|
||||
int ret = app.exec();
|
||||
|
||||
QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret;
|
||||
|
||||
YACReader::exitCheck(ret);
|
||||
|
||||
//server shutdown
|
||||
s->stop();
|
||||
delete s;
|
||||
|
||||
QLOG_INFO() << "YACReaderLibrary closed";
|
||||
|
||||
QsLogging::Logger::destroyInstance();
|
||||
|
||||
return ret;
|
||||
|
@ -94,8 +94,8 @@ QMap<QString, QPair<int, QString> > YACReaderLibraries::getLibraries()
|
||||
void YACReaderLibraries::addLibrary(const QString &name, const QString &path)
|
||||
{
|
||||
int newID=0;
|
||||
foreach(QString name, libraries.keys())
|
||||
newID = qMax(0,libraries.value(name).first);
|
||||
foreach(QString lName, libraries.keys())
|
||||
newID = qMax(newID,libraries.value(lName).first);
|
||||
newID++;
|
||||
libraries.insert(name,QPair<int,QString>(newID,path));
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QList>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
Bookmarks::Bookmarks()
|
||||
:lastPageIndex(0)
|
||||
{
|
||||
@ -123,7 +125,7 @@ void Bookmarks::save()
|
||||
//-----------------------------------------------------------------------------
|
||||
void BookmarksList::load()
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
|
||||
QFile f(YACReader::getSettingsPath()+"/bookmarks.yacr");
|
||||
if(f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QDataStream dataS(&f);
|
||||
@ -134,7 +136,7 @@ void BookmarksList::load()
|
||||
|
||||
void BookmarksList::save()
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
|
||||
QFile f(YACReader::getSettingsPath()+"/bookmarks.yacr");
|
||||
f.open(QIODevice::WriteOnly);
|
||||
QDataStream dataS(&f);
|
||||
if(list.count()>numMaxBookmarks)
|
||||
@ -169,4 +171,4 @@ BookmarksList::Bookmark BookmarksList::get(const QString & comicID)
|
||||
{
|
||||
//if(list.contains(comicID)
|
||||
return list.value(comicID);
|
||||
}
|
||||
}
|
||||
|
@ -413,6 +413,8 @@ QList<QVector<quint32> > FileComic::getSections(int & sectionIndex)
|
||||
void FileComic::process()
|
||||
{
|
||||
CompressedArchive archive(_path);
|
||||
if(!archive.toolsLoaded())
|
||||
return;
|
||||
//se filtran para obtener sólo los formatos soportados
|
||||
_order = archive.getFileNames();
|
||||
_fileNames = filter(_order);
|
||||
|
21
common/exit_check.cpp
Normal file
21
common/exit_check.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "exit_check.h"
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace YACReader;
|
||||
|
||||
void YACReader::exitCheck(int ret)
|
||||
{
|
||||
switch(ret)
|
||||
{
|
||||
case YACReader::SevenZNotFound:
|
||||
QMessageBox::critical(0,QObject::tr("7z lib not found"),QObject::tr("unable to load 7z lib from ./utils"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
9
common/exit_check.h
Normal file
9
common/exit_check.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef EXIT_CHECK_H
|
||||
#define EXIT_CHECK_H
|
||||
|
||||
namespace YACReader
|
||||
{
|
||||
void exitCheck(int ret);
|
||||
}
|
||||
|
||||
#endif
|
@ -88,6 +88,11 @@ namespace YACReader
|
||||
Opened = 2
|
||||
};
|
||||
|
||||
enum YACReaderErrors
|
||||
{
|
||||
SevenZNotFound = 700
|
||||
};
|
||||
|
||||
QString getSettingsPath();
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,13 @@
|
||||
|
||||
#include <QLibrary>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "open_callbacks.h"
|
||||
#include "extract_callbacks.h"
|
||||
|
||||
#include "yacreader_global.h"
|
||||
|
||||
//DEFINE_GUID(CLSID_CFormat7z,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
|
||||
//DEFINE_GUID(IArchiveKK,0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x00, 0x00);
|
||||
|
||||
@ -56,12 +58,14 @@ struct SevenZipInterface {
|
||||
//SevenZipInterface * szInterface;
|
||||
|
||||
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
||||
QObject(parent),sevenzLib(0),valid(false)
|
||||
QObject(parent),sevenzLib(0),valid(false),tools(false)
|
||||
{
|
||||
szInterface = new SevenZipInterface;
|
||||
//load functions
|
||||
loadFunctions();
|
||||
if(!loadFunctions())
|
||||
return;
|
||||
|
||||
tools = true;
|
||||
//load file
|
||||
if(szInterface->createObjectFunc != 0)
|
||||
{
|
||||
@ -106,7 +110,7 @@ CompressedArchive::~CompressedArchive()
|
||||
delete sevenzLib;
|
||||
}
|
||||
|
||||
void CompressedArchive::loadFunctions()
|
||||
bool CompressedArchive::loadFunctions()
|
||||
{
|
||||
//LOAD library
|
||||
//TODO check if this works in OSX (7z.so instead of 7z.dylib)
|
||||
@ -115,7 +119,11 @@ void CompressedArchive::loadFunctions()
|
||||
if(sevenzLib == 0)
|
||||
sevenzLib = new QLibrary("./utils/7z");
|
||||
if(!sevenzLib->load())
|
||||
{
|
||||
qDebug() << "Loading 7z.dll : " + sevenzLib->errorString() << endl;
|
||||
QApplication::exit(YACReader::SevenZNotFound); //TODO app still crashing
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Loading functions" << endl;
|
||||
@ -135,6 +143,8 @@ void CompressedArchive::loadFunctions()
|
||||
if((szInterface->setLargePageModeFunc = (SetLargePageModeFunc)sevenzLib->resolve("SetLargePageMode")) == 0)
|
||||
qDebug() << "fail loading function : SetLargePageMode" << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QString> CompressedArchive::getFileNames()
|
||||
@ -170,6 +180,11 @@ bool CompressedArchive::isValid()
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool CompressedArchive::toolsLoaded()
|
||||
{
|
||||
return tools;
|
||||
}
|
||||
|
||||
int CompressedArchive::getNumFiles()
|
||||
{
|
||||
quint32 numItems = 0;
|
||||
|
@ -41,10 +41,12 @@ public slots:
|
||||
QByteArray getRawDataAtIndex(int index);
|
||||
QList<QString> getFileNames();
|
||||
bool isValid();
|
||||
bool toolsLoaded();
|
||||
private:
|
||||
SevenZipInterface * szInterface;
|
||||
QLibrary * sevenzLib;
|
||||
void loadFunctions();
|
||||
bool loadFunctions();
|
||||
bool tools;
|
||||
bool valid;
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user