mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 14:34:42 -04:00
load(path,atPage) added in viewer,render and comic classes
updated CHANGELOG
This commit is contained in:
@ -1004,15 +1004,20 @@ void LibraryWindow::openComic()
|
||||
{
|
||||
if(!importedCovers)
|
||||
{
|
||||
QString path = currentPath() + dmCV->getComicPath(comicView->currentIndex());
|
||||
ComicDB comic = dmCV->getComic(comicView->currentIndex());
|
||||
QString path = currentPath() + comic.path;
|
||||
/*quint64 comicId = comic.id;
|
||||
//TODO generate IDS for libraries...
|
||||
quint64 libraryId = selectedLibrary->currentIndex();
|
||||
int page = *(comic.info.numPages) / 2;*/
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
|
||||
QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path);//,QStringList() << path);
|
||||
QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path /*<< comicId << libraryId << page*/);//,QStringList() << path);
|
||||
//Comic is readed
|
||||
#else
|
||||
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\"").arg(path),QStringList());
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\"").arg(path)/*.arg(comicId).arg(libraryId).arg(page)*/,QStringList());
|
||||
#endif
|
||||
//Comic is readed
|
||||
setCurrentComicReaded();
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <QLocalSocket>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "db_helper.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
||||
QObject(parent)
|
||||
@ -49,24 +52,52 @@ void YACReaderLocalServer::sendResponse()
|
||||
clientConnection->flush();
|
||||
clientConnection->disconnectFromServer();*/
|
||||
|
||||
QByteArray block;
|
||||
QDataStream out(&block, QIODevice::WriteOnly);
|
||||
out.setVersion(QDataStream::Qt_4_0);
|
||||
out << (quint16)0;
|
||||
out << QString("ok");
|
||||
out.device()->seek(0);
|
||||
out << (quint16)(block.size() - sizeof(quint16));
|
||||
|
||||
QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
||||
connect(clientConnection, SIGNAL(disconnected()),
|
||||
clientConnection, SLOT(deleteLater()));
|
||||
|
||||
clientConnection->write(block);
|
||||
clientConnection->flush();
|
||||
quint64 libraryId;
|
||||
ComicDB comic;
|
||||
clientConnection->waitForReadyRead();
|
||||
QByteArray data;
|
||||
QDataStream inputStream(data);
|
||||
inputStream.setVersion(QDataStream::Qt_4_0);
|
||||
int totalSize = 0;
|
||||
while((data.size()-sizeof(quint16)) != totalSize )
|
||||
{
|
||||
data.append(clientConnection->read(1000000000));
|
||||
if(data.size()>=sizeof(quint16) && totalSize == 0)
|
||||
inputStream >> totalSize;
|
||||
}
|
||||
inputStream >> libraryId;
|
||||
inputStream >> comic;
|
||||
|
||||
getComicInfo(libraryId,comic);
|
||||
|
||||
QByteArray block;
|
||||
QDataStream out(&block, QIODevice::WriteOnly);
|
||||
out.setVersion(QDataStream::Qt_4_0);
|
||||
out << (quint16)0;
|
||||
out << comic;
|
||||
out.device()->seek(0);
|
||||
out << (quint16)(block.size() - sizeof(quint16));
|
||||
|
||||
int written = 0;
|
||||
while(written != block.size())
|
||||
{
|
||||
written += clientConnection->write(block);
|
||||
clientConnection->flush();
|
||||
}
|
||||
//clientConnection->waitForBytesWritten();
|
||||
clientConnection->disconnectFromServer();
|
||||
|
||||
}
|
||||
|
||||
void YACReaderLocalServer::getComicInfo(quint64 libraryId, ComicDB & comic)
|
||||
{
|
||||
comic = DBHelper::getComicInfo(DBHelper::getLibrariesNames().at(libraryId), comic.id);
|
||||
}
|
||||
|
||||
bool YACReaderLocalServer::isRunning()
|
||||
{
|
||||
QLocalSocket socket;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
|
||||
class QLocalServer;
|
||||
class ComicDB;
|
||||
|
||||
class YACReaderLocalServer : public QObject
|
||||
{
|
||||
@ -17,7 +18,7 @@ public slots:
|
||||
bool isListening();
|
||||
void sendResponse();
|
||||
static bool isRunning();
|
||||
|
||||
void getComicInfo(quint64 libraryId, ComicDB & comic);
|
||||
private:
|
||||
QLocalServer * localServer;
|
||||
|
||||
|
Reference in New Issue
Block a user