mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
7.0 fields added
save current page on viewer close
This commit is contained in:
parent
97db3f582a
commit
57d7a8abdc
@ -54,7 +54,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
MainWindowViewer::MainWindowViewer()
|
MainWindowViewer::MainWindowViewer()
|
||||||
:QMainWindow(),fullscreen(false),toolbars(true),alwaysOnTop(false),currentDirectory("."),currentDirectoryImgDest(".")
|
:QMainWindow(),fullscreen(false),toolbars(true),alwaysOnTop(false),currentDirectory("."),currentDirectoryImgDest("."),isClient(false)
|
||||||
{
|
{
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
setupUI();
|
setupUI();
|
||||||
@ -154,6 +154,7 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
if(QCoreApplication::argc() == 2) //only path...
|
if(QCoreApplication::argc() == 2) //only path...
|
||||||
{
|
{
|
||||||
|
isClient = false;
|
||||||
//TODO: new method open(QString)
|
//TODO: new method open(QString)
|
||||||
QString pathFile = QCoreApplication::arguments().at(1);
|
QString pathFile = QCoreApplication::arguments().at(1);
|
||||||
QFileInfo fi(pathFile);
|
QFileInfo fi(pathFile);
|
||||||
@ -166,6 +167,7 @@ void MainWindowViewer::setupUI()
|
|||||||
}
|
}
|
||||||
else if(QCoreApplication::argc() == 5)
|
else if(QCoreApplication::argc() == 5)
|
||||||
{
|
{
|
||||||
|
isClient = true;
|
||||||
QString pathFile = QCoreApplication::arguments().at(1);
|
QString pathFile = QCoreApplication::arguments().at(1);
|
||||||
currentDirectory = pathFile;
|
currentDirectory = pathFile;
|
||||||
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
|
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
|
||||||
@ -596,7 +598,7 @@ void MainWindowViewer::open(QString path, ComicDB & comic, QList<ComicDB> & sibl
|
|||||||
else
|
else
|
||||||
setWindowTitle("YACReader - " + fi.fileName());
|
setWindowTitle("YACReader - " + fi.fileName());
|
||||||
|
|
||||||
viewer->open(path,comic.info.currentPage);
|
viewer->open(path,comic.info.currentPage-1);
|
||||||
enableActions();
|
enableActions();
|
||||||
int index = siblings.indexOf(comic);
|
int index = siblings.indexOf(comic);
|
||||||
|
|
||||||
@ -840,6 +842,15 @@ void MainWindowViewer::newVersion()
|
|||||||
|
|
||||||
void MainWindowViewer::closeEvent ( QCloseEvent * event )
|
void MainWindowViewer::closeEvent ( QCloseEvent * event )
|
||||||
{
|
{
|
||||||
|
YACReaderLocalClient client;
|
||||||
|
if(isClient)
|
||||||
|
{
|
||||||
|
currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1;
|
||||||
|
currentComicDB.info.hasBeenOpened = true;
|
||||||
|
//viewer->getBookmarks();
|
||||||
|
client.sendComicInfo(0,currentComicDB);
|
||||||
|
}
|
||||||
|
|
||||||
viewer->save();
|
viewer->save();
|
||||||
Configuration & conf = Configuration::getConfiguration();
|
Configuration & conf = Configuration::getConfiguration();
|
||||||
if(!fullscreen && !isMaximized())
|
if(!fullscreen && !isMaximized())
|
||||||
@ -980,6 +991,7 @@ void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
if (event->mimeData()->hasFormat("text/uri-list"))
|
if (event->mimeData()->hasFormat("text/uri-list"))
|
||||||
{
|
{
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
isClient = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,7 @@ class YACReaderSliderAction;
|
|||||||
|
|
||||||
ComicDB currentComicDB;
|
ComicDB currentComicDB;
|
||||||
QList<ComicDB> siblingComics;
|
QList<ComicDB> siblingComics;
|
||||||
|
bool isClient;
|
||||||
signals:
|
signals:
|
||||||
void closed();
|
void closed();
|
||||||
protected:
|
protected:
|
||||||
|
@ -805,3 +805,8 @@ unsigned int Viewer::getIndex()
|
|||||||
{
|
{
|
||||||
return render->getIndex()+1;
|
return render->getIndex()+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Viewer::getCurrentPageNumber()
|
||||||
|
{
|
||||||
|
return render->getIndex();
|
||||||
|
}
|
@ -81,6 +81,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
|||||||
void updateImageOptions();
|
void updateImageOptions();
|
||||||
void showIsCoverMessage();
|
void showIsCoverMessage();
|
||||||
void showIsLastMessage();
|
void showIsLastMessage();
|
||||||
|
int getCurrentPageNumber();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool information;
|
bool information;
|
||||||
|
@ -73,7 +73,7 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
|
|||||||
QDataStream out(&block, QIODevice::WriteOnly);
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
out.setVersion(QDataStream::Qt_4_8);
|
out.setVersion(QDataStream::Qt_4_8);
|
||||||
out << (quint16)0;
|
out << (quint16)0;
|
||||||
out << (quint8)YACReaderIPCMessages::RequestComicInfo;
|
out << (quint8)YACReaderIPCMessages::SendComicInfo;
|
||||||
out << libraryId;
|
out << libraryId;
|
||||||
out << comic;
|
out << comic;
|
||||||
out.device()->seek(0);
|
out.device()->seek(0);
|
||||||
|
@ -37,7 +37,8 @@ static QString fields = "title ,"
|
|||||||
"characters,"
|
"characters,"
|
||||||
"notes,"
|
"notes,"
|
||||||
|
|
||||||
"hash";
|
"hash"
|
||||||
|
;
|
||||||
|
|
||||||
DataBaseManagement::DataBaseManagement()
|
DataBaseManagement::DataBaseManagement()
|
||||||
:QObject(),dataBasesList()
|
:QObject(),dataBasesList()
|
||||||
@ -167,7 +168,19 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
|||||||
|
|
||||||
"hash TEXT UNIQUE NOT NULL,"
|
"hash TEXT UNIQUE NOT NULL,"
|
||||||
"edited BOOLEAN DEFAULT 0,"
|
"edited BOOLEAN DEFAULT 0,"
|
||||||
"read BOOLEAN DEFAULT 0)");
|
"read BOOLEAN DEFAULT 0,"
|
||||||
|
//now 7.0 fields
|
||||||
|
|
||||||
|
"hasBeenOpened BOOLEAN DEFAULT 0,"
|
||||||
|
|
||||||
|
"currentPage INTEGER DEFAULT 1, "
|
||||||
|
"bookmark1 INTEGER DEFAULT -1, "
|
||||||
|
"bookmark2 INTEGER DEFAULT -1, "
|
||||||
|
"bookmark3 INTEGER DEFAULT -1, "
|
||||||
|
"brightness INTEGER DEFAULT -1, "
|
||||||
|
"contrast INTEGER DEFAULT -1, "
|
||||||
|
"gamma INTEGER DEFAULT -1 "
|
||||||
|
")");
|
||||||
success = success && queryComicInfo.exec();
|
success = success && queryComicInfo.exec();
|
||||||
//queryComicInfo.finish();
|
//queryComicInfo.finish();
|
||||||
|
|
||||||
@ -550,6 +563,27 @@ bool DataBaseManagement::updateToCurrentVersion(const QString & fullPath)
|
|||||||
|
|
||||||
if(updateVersion.numRowsAffected() > 0)
|
if(updateVersion.numRowsAffected() > 0)
|
||||||
returnValue = true;
|
returnValue = true;
|
||||||
|
if(returnValue) //TODO: execute only if previous version was < 7.0
|
||||||
|
{
|
||||||
|
//new 7.0 fields
|
||||||
|
QSqlQuery alterTableComicInfo(db);
|
||||||
|
alterTableComicInfo.prepare("ALTER TABLE comic_info ADD ("
|
||||||
|
"hasBeenOpened BOOLEAN DEFAULT 0,"
|
||||||
|
|
||||||
|
"currentPage INTEGER DEFAULT 1, "
|
||||||
|
"bookmark1 INTEGER DEFAULT -1, "
|
||||||
|
"bookmark2 INTEGER DEFAULT -1, "
|
||||||
|
"bookmark3 INTEGER DEFAULT -1, "
|
||||||
|
"brightness INTEGER DEFAULT -1, "
|
||||||
|
"contrast INTEGER DEFAULT -1, "
|
||||||
|
"gamma INTEGER DEFAULT -1 "
|
||||||
|
")");
|
||||||
|
alterTableComicInfo.exec();
|
||||||
|
|
||||||
|
returnValue = (alterTableComicInfo.numRowsAffected() > 0);
|
||||||
|
}
|
||||||
|
//TODO update hasBeenOpened value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -187,6 +187,17 @@ void DBHelper::update(ComicDB * comic, QSqlDatabase & db)
|
|||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBHelper::update(const QString & libraryName, ComicInfo & comicInfo)
|
||||||
|
{
|
||||||
|
QString libraryPath = DBHelper::getLibraries().value(libraryName);
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||||
|
|
||||||
|
DBHelper::update(&comicInfo,db);
|
||||||
|
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(libraryPath);
|
||||||
|
}
|
||||||
|
|
||||||
void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
QSqlQuery updateComicInfo(db);
|
QSqlQuery updateComicInfo(db);
|
||||||
@ -225,8 +236,18 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
|||||||
"notes = :notes,"
|
"notes = :notes,"
|
||||||
|
|
||||||
"read = :read,"
|
"read = :read,"
|
||||||
"edited = :edited"
|
"edited = :edited,"
|
||||||
|
//new 7.0 fields
|
||||||
|
"hasBeenOpened = :hasBeenOpened,"
|
||||||
|
|
||||||
|
"currentPage = :currentPage,"
|
||||||
|
"bookmark1 = :bookmark1,"
|
||||||
|
"bookmark2 = :bookmark2,"
|
||||||
|
"bookmark3 = :bookmark3,"
|
||||||
|
"brightness = :brightness,"
|
||||||
|
"contrast = :contrast, "
|
||||||
|
"gamma = :gamma"
|
||||||
|
//--
|
||||||
" WHERE id = :id ");
|
" WHERE id = :id ");
|
||||||
bindField(":title",comicInfo->title,updateComicInfo);
|
bindField(":title",comicInfo->title,updateComicInfo);
|
||||||
|
|
||||||
@ -264,6 +285,16 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
|||||||
updateComicInfo.bindValue(":read", comicInfo->read?1:0);
|
updateComicInfo.bindValue(":read", comicInfo->read?1:0);
|
||||||
updateComicInfo.bindValue(":id", comicInfo->id);
|
updateComicInfo.bindValue(":id", comicInfo->id);
|
||||||
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
||||||
|
|
||||||
|
updateComicInfo.bindValue(":hasBeenOpened", comicInfo->hasBeenOpened?1:0);
|
||||||
|
updateComicInfo.bindValue(":currentPage", comicInfo->currentPage);
|
||||||
|
updateComicInfo.bindValue(":bookmark1", comicInfo->bookmark1);
|
||||||
|
updateComicInfo.bindValue(":bookmark2", comicInfo->bookmark2);
|
||||||
|
updateComicInfo.bindValue(":bookmark3", comicInfo->bookmark3);
|
||||||
|
updateComicInfo.bindValue(":brightness", comicInfo->brightness);
|
||||||
|
updateComicInfo.bindValue(":contrast", comicInfo->contrast);
|
||||||
|
updateComicInfo.bindValue(":gamma", comicInfo->gamma);
|
||||||
|
|
||||||
updateComicInfo.exec();
|
updateComicInfo.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,6 +579,17 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase & db)
|
|||||||
comicInfo.read = record.value("read").toBool();
|
comicInfo.read = record.value("read").toBool();
|
||||||
comicInfo.edited = record.value("edited").toBool();
|
comicInfo.edited = record.value("edited").toBool();
|
||||||
|
|
||||||
|
//new 7.0 fields
|
||||||
|
comicInfo.hasBeenOpened = record.value("hasBeenOpened").toBool();
|
||||||
|
comicInfo.currentPage = record.value("currentPage").toInt();
|
||||||
|
comicInfo.bookmark1 = record.value("bookmark1").toInt();
|
||||||
|
comicInfo.bookmark2 = record.value("bookmark2").toInt();
|
||||||
|
comicInfo.bookmark3 = record.value("bookmark3").toInt();
|
||||||
|
comicInfo.brightness = record.value("brightness").toInt();
|
||||||
|
comicInfo.contrast = record.value("contrast").toInt();
|
||||||
|
comicInfo.gamma = record.value("gamma").toInt();
|
||||||
|
//--
|
||||||
|
|
||||||
setField("title",comicInfo.title,record);
|
setField("title",comicInfo.title,record);
|
||||||
setField("numPages",comicInfo.numPages,record);
|
setField("numPages",comicInfo.numPages,record);
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
static qulonglong insert(Folder * folder, QSqlDatabase & db);
|
static qulonglong insert(Folder * folder, QSqlDatabase & db);
|
||||||
static qulonglong insert(ComicDB * comic, QSqlDatabase & db);
|
static qulonglong insert(ComicDB * comic, QSqlDatabase & db);
|
||||||
//updates
|
//updates
|
||||||
|
static void update(const QString & libraryName, ComicInfo & comicInfo);
|
||||||
static void update(ComicDB * comics, QSqlDatabase & db);
|
static void update(ComicDB * comics, QSqlDatabase & db);
|
||||||
static void update(ComicInfo * comicInfo, QSqlDatabase & db);
|
static void update(ComicInfo * comicInfo, QSqlDatabase & db);
|
||||||
static void updateRead(ComicInfo * comicInfo, QSqlDatabase & db);
|
static void updateRead(ComicInfo * comicInfo, QSqlDatabase & db);
|
||||||
|
@ -51,24 +51,39 @@ void YACReaderLocalServer::sendResponse()
|
|||||||
dataStream >> libraryId;
|
dataStream >> libraryId;
|
||||||
dataStream >> comic;
|
dataStream >> comic;
|
||||||
|
|
||||||
QList<ComicDB> siblings;
|
switch (msgType)
|
||||||
getComicInfo(libraryId,comic,siblings);
|
|
||||||
|
|
||||||
QByteArray block;
|
|
||||||
QDataStream out(&block, QIODevice::WriteOnly);
|
|
||||||
out.setVersion(QDataStream::Qt_4_8);
|
|
||||||
out << (quint16)0;
|
|
||||||
out << comic;
|
|
||||||
out << siblings;
|
|
||||||
out.device()->seek(0);
|
|
||||||
out << (quint16)(block.size() - sizeof(quint16));
|
|
||||||
|
|
||||||
int written = 0;
|
|
||||||
while(written != block.size())
|
|
||||||
{
|
{
|
||||||
written += clientConnection->write(block);
|
case YACReaderIPCMessages::RequestComicInfo:
|
||||||
clientConnection->flush();
|
{
|
||||||
|
QList<ComicDB> siblings;
|
||||||
|
getComicInfo(libraryId,comic,siblings);
|
||||||
|
|
||||||
|
QByteArray block;
|
||||||
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
out.setVersion(QDataStream::Qt_4_8);
|
||||||
|
out << (quint16)0;
|
||||||
|
out << comic;
|
||||||
|
out << siblings;
|
||||||
|
out.device()->seek(0);
|
||||||
|
out << (quint16)(block.size() - sizeof(quint16));
|
||||||
|
|
||||||
|
int written = 0;
|
||||||
|
while(written != block.size())
|
||||||
|
{
|
||||||
|
written += clientConnection->write(block);
|
||||||
|
clientConnection->flush();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case YACReaderIPCMessages::SendComicInfo:
|
||||||
|
{
|
||||||
|
updateComic(libraryId,comic);
|
||||||
|
//clientConnection->disconnectFromServer();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//clientConnection->waitForBytesWritten();*/
|
//clientConnection->waitForBytesWritten();*/
|
||||||
//clientConnection->disconnectFromServer();
|
//clientConnection->disconnectFromServer();
|
||||||
}
|
}
|
||||||
@ -79,6 +94,11 @@ void YACReaderLocalServer::getComicInfo(quint64 libraryId, ComicDB & comic, QLis
|
|||||||
siblings = DBHelper::getSiblings(DBHelper::getLibrariesNames().at(libraryId), comic.parentId);
|
siblings = DBHelper::getSiblings(DBHelper::getLibrariesNames().at(libraryId), comic.parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalServer::updateComic(quint64 libraryId, ComicDB & comic)
|
||||||
|
{
|
||||||
|
DBHelper::update(DBHelper::getLibrariesNames().at(libraryId), comic.info);
|
||||||
|
}
|
||||||
|
|
||||||
bool YACReaderLocalServer::isRunning()
|
bool YACReaderLocalServer::isRunning()
|
||||||
{
|
{
|
||||||
QLocalSocket socket;
|
QLocalSocket socket;
|
||||||
|
@ -19,6 +19,7 @@ public slots:
|
|||||||
void sendResponse();
|
void sendResponse();
|
||||||
static bool isRunning();
|
static bool isRunning();
|
||||||
void getComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & sibling);
|
void getComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & sibling);
|
||||||
|
void updateComic(quint64 libraryId, ComicDB & comic);
|
||||||
private:
|
private:
|
||||||
QLocalServer * localServer;
|
QLocalServer * localServer;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ ComicInfo::ComicInfo()
|
|||||||
:existOnDb(false),
|
:existOnDb(false),
|
||||||
rating(-1),
|
rating(-1),
|
||||||
hasBeenOpened(false),
|
hasBeenOpened(false),
|
||||||
currentPage(0),
|
currentPage(1),
|
||||||
bookmark1(-1),
|
bookmark1(-1),
|
||||||
bookmark2(-1),
|
bookmark2(-1),
|
||||||
bookmark3(-1),
|
bookmark3(-1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user