mirror of
https://github.com/YACReader/yacreader
synced 2025-07-24 16:05:01 -04:00
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:
@ -1136,8 +1136,8 @@ void LibraryWindow::openComic()
|
||||
//Invoke YACReader comicPath comicId libraryId NO-->currentPage bookmark1 bookmark2 bookmark3 brightness contrast gamma
|
||||
bool yacreaderFound = false;
|
||||
#ifdef Q_OS_MAC
|
||||
QString comicIdS = QString("%1").arg(comicId);
|
||||
QString libraryIdS = QString("%1").arg(libraryId);
|
||||
QString comicIdS = QString("--comicId=") + QString("%1").arg(comicId);
|
||||
QString libraryIdS = QString("--libraryId=") + QString("%1").arg(libraryId);
|
||||
QString yacreaderPath = QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app");
|
||||
if(yacreaderFound = QFileInfo(yacreaderPath).exists())
|
||||
QProcess::startDetached("open", QStringList() << "-n" << yacreaderPath << "--args" << path << comicIdS << libraryIdS ); /*<< page << bookmark1 << bookmark2 << bookmark3 << brightness << contrast << gamma*///,QStringList() << path);
|
||||
@ -1145,12 +1145,12 @@ void LibraryWindow::openComic()
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN /* \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\" \"%10\" */
|
||||
yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\" \"%2\" \"%3\"").arg(path).arg(comicId).arg(libraryId)/*.arg(page).arg(bookmark1).arg(bookmark2).arg(bookmark3).arg(brightness).arg(contrast).arg(gamma)*/,QStringList());
|
||||
yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\" \"%2\" \"%3\"").arg(path).arg(QString("--comicId=") + QString::number(comicId))).arg(QString("--libraryId=") + QString::number(libraryId))/*.arg(page).arg(bookmark1).arg(bookmark2).arg(bookmark3).arg(brightness).arg(contrast).arg(gamma)*/,QStringList());
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
QStringList parameters = QStringList() << path << QString::number(comicId) << QString::number(libraryId);
|
||||
yacreaderFound = QProcess::startDetached(QString("YACReader"),parameters);
|
||||
QStringList parameters = QStringList() << path << (QString("--comicId=") + QString::number(comicId)) << (QString("--libraryId=") + QString::number(libraryId));
|
||||
yacreaderFound = QProcess::startDetached(QString("YACReader"),parameters);
|
||||
#endif
|
||||
if(!yacreaderFound)
|
||||
QMessageBox::critical(this,tr("YACReader not found"),tr("YACReader not found, YACReader should be installed in the same folder as YACReaderLibrary."));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QSettings>
|
||||
#include <QLibrary>
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "startup.h"
|
||||
@ -141,6 +142,31 @@ int main( int argc, char ** argv )
|
||||
app.setApplicationName("YACReaderLibrary");
|
||||
app.setOrganizationName("YACReader");
|
||||
|
||||
//simple command line parser
|
||||
//will be replaced by QCommandLineParser in the future
|
||||
//TODO: --headless, --server=[on|off], support for file and directory arguments
|
||||
if (argc > 1)
|
||||
{
|
||||
QTextStream parser(stdout);
|
||||
QStringList optlist = QCoreApplication::arguments().filter(QRegExp ("^-{1,2}"));
|
||||
if (optlist.contains("--version") | optlist.contains("-v"))
|
||||
{
|
||||
parser << app.applicationName() << " " << QString(VERSION) << endl << "Copyright 2014 by Luis Angel San Martin Rodriguez" << endl;
|
||||
return 0;
|
||||
}
|
||||
if (optlist.contains("--help") | optlist.contains("-h"))
|
||||
{
|
||||
parser << endl << "Usage:" << "\tYACReaderLibrary [Option]" << endl << endl;
|
||||
parser << "Options:" << endl;
|
||||
parser << " none\t\t\tStart YACReaderLibrary" << endl;
|
||||
parser << " -h, --help\t\tDisplay help text and exit." << endl;
|
||||
parser << " -v, --version\t\tDisplay version information and exit." << endl;
|
||||
return 0;
|
||||
}
|
||||
parser << "Unsupported command line options. See YACReaderLibrary --help for further information." << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
||||
QDir().mkpath(YACReader::getSettingsPath());
|
||||
|
||||
|
@ -51,6 +51,7 @@ void YACReaderLocalServer::sendResponse()
|
||||
connect(worker,SIGNAL(comicUpdated(quint64, ComicDB)),this,SIGNAL(comicUpdated(quint64, ComicDB)));
|
||||
connect(worker,SIGNAL(finished()),worker,SLOT(deleteLater()));
|
||||
worker->start();
|
||||
QLOG_INFO() << "connection incoming" << "Worker started";
|
||||
}
|
||||
|
||||
QLOG_INFO() << "connection incoming";
|
||||
|
Reference in New Issue
Block a user