Add minimal command line parser to YACReader and YACReaderLibrary.

Introduce new command line options --comicId and --libraryId for
communication between Reader and Library.
Support for standard command line options --help and --version.
This commit is contained in:
Felix Kauselmann
2014-08-08 20:42:14 +02:00
parent b2e3e77495
commit 1f4f524397
7 changed files with 126 additions and 11 deletions

View File

@ -169,7 +169,7 @@ void MainWindowViewer::setupUI()
setWindowTitle("YACReader");
openFromArgv();
//openFromArgv();
checkNewVersion();
@ -232,12 +232,16 @@ void MainWindowViewer::openFromArgv()
open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
}
else
{isClient = false; QMessageBox::information(this,"Connection Error", "Unable to connect to YACReaderLibrary");/*error*/}
{
isClient = false;
QMessageBox::information(this,"Connection Error", "Unable to connect to YACReaderLibrary");
//error
}
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
}
}
void MainWindowViewer::createActions()
{
openAction = new QAction(tr("&Open"),this);
@ -649,6 +653,39 @@ void MainWindowViewer::open(QString path, ComicDB & comic, QList<ComicDB> & sibl
openNextComicAction->setDisabled(true);
}
void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId)
{
//QString pathFile = QCoreApplication::arguments().at(1);
currentDirectory = path;
//quint64 comicId = QCoreApplication::arguments().at(2).split("=").at(1).toULongLong();
//libraryId = QCoreApplication::arguments().at(3).split("=").at(1).toULongLong();
this->libraryId=libraryId;
// this->path=path;
enableActions();
currentComicDB.id = comicId;
YACReaderLocalClient client;
int tries = 1;
bool success = false;
while(!(success = client.requestComicInfo(libraryId,currentComicDB,siblingComics)) && tries != 0)
tries--;
if(success)
{
isClient = true;
open(path+currentComicDB.path,currentComicDB,siblingComics);
}
else
{
isClient = false;
QMessageBox::information(this,"Connection Error", "Unable to connect to YACReaderLibrary");
//error
}
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
}
void MainWindowViewer::openComicFromPath(QString pathFile)
{
QFileInfo fi(pathFile);