mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
merged changes from 7.1.0 branch
This commit is contained in:
commit
8266767a26
@ -81,6 +81,39 @@ int main(int argc, char * argv[])
|
|||||||
app.setApplicationName("YACReader");
|
app.setApplicationName("YACReader");
|
||||||
app.setOrganizationName("YACReader");
|
app.setOrganizationName("YACReader");
|
||||||
|
|
||||||
|
//simple command line parser
|
||||||
|
//will be replaced by QCommandLineParser in the future
|
||||||
|
QStringList optlist;
|
||||||
|
QStringList arglist;
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
//extract options and arguments
|
||||||
|
optlist = QCoreApplication::arguments().filter(QRegExp ("^-{1,2}")); //options starting with "-"
|
||||||
|
arglist = QCoreApplication::arguments().filter(QRegExp ("^(?!-{1,2})")); //positional arguments
|
||||||
|
//deal with standard options
|
||||||
|
if (!optlist.isEmpty())
|
||||||
|
{
|
||||||
|
QTextStream parser(stdout);
|
||||||
|
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: YACReader [File|Directory|Option]" << endl << endl;
|
||||||
|
parser << "Options:" << endl;
|
||||||
|
parser << " -h, --help\t\tDisplay this text and exit." << endl;
|
||||||
|
parser << " -v, --version\t\tDisplay version information and exit." << endl << endl;
|
||||||
|
parser << "Arguments:" << endl;
|
||||||
|
parser << " file\t\t\tOpen comic file." <<endl;
|
||||||
|
parser << " directory\t\tOpen comic directory." << endl << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString destLog = YACReader::getSettingsPath()+"/yacreader.log";
|
QString destLog = YACReader::getSettingsPath()+"/yacreader.log";
|
||||||
QDir().mkpath(YACReader::getSettingsPath());
|
QDir().mkpath(YACReader::getSettingsPath());
|
||||||
|
|
||||||
@ -101,8 +134,24 @@ int main(int argc, char * argv[])
|
|||||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
||||||
#endif
|
#endif
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
|
|
||||||
MainWindowViewer * mwv = new MainWindowViewer();
|
MainWindowViewer * mwv = new MainWindowViewer();
|
||||||
|
//parser code for comic loading needs to be processed after MainWindowViewer creation
|
||||||
|
//if we have a valid request, open it - if not, load normally
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
if (!optlist.filter("--comicId=").isEmpty() && !optlist.filter("--libraryId=").isEmpty())
|
||||||
|
{
|
||||||
|
if (arglist.count()>1)
|
||||||
|
{
|
||||||
|
mwv->open(arglist.at(1), optlist.filter("--comicId=").at(0).split("=").at(1).toULongLong(), optlist.filter("--libraryId=").at(0).split("=").at(1).toULongLong());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((arglist.count()>1))
|
||||||
|
{
|
||||||
|
//open first positional argument, silently ignore all following positional arguments
|
||||||
|
mwv->openComicFromPath(arglist.at(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
app.setWindow(mwv);
|
app.setWindow(mwv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,8 +175,6 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
setWindowTitle("YACReader");
|
setWindowTitle("YACReader");
|
||||||
|
|
||||||
openFromArgv();
|
|
||||||
|
|
||||||
checkNewVersion();
|
checkNewVersion();
|
||||||
|
|
||||||
viewer->setFocusPolicy(Qt::StrongFocus);
|
viewer->setFocusPolicy(Qt::StrongFocus);
|
||||||
@ -200,50 +198,6 @@ void MainWindowViewer::setupUI()
|
|||||||
hideToolBars();
|
hideToolBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::openFromArgv()
|
|
||||||
{
|
|
||||||
if(QCoreApplication::arguments().count() == 2) //only path...
|
|
||||||
{
|
|
||||||
isClient = false;
|
|
||||||
//TODO: new method open(QString)
|
|
||||||
QString pathFile = QCoreApplication::arguments().at(1);
|
|
||||||
QFileInfo fi(pathFile);
|
|
||||||
currentDirectory = fi.absoluteDir().path();
|
|
||||||
getSiblingComics(fi.absolutePath(),fi.fileName());
|
|
||||||
|
|
||||||
setWindowTitle("YACReader - " + fi.fileName());
|
|
||||||
enableActions();
|
|
||||||
viewer->open(pathFile);
|
|
||||||
}
|
|
||||||
else if(QCoreApplication::arguments().count() == 4)
|
|
||||||
{
|
|
||||||
|
|
||||||
QString pathFile = QCoreApplication::arguments().at(1);
|
|
||||||
currentDirectory = pathFile;
|
|
||||||
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
|
|
||||||
libraryId = QCoreApplication::arguments().at(3).toULongLong();
|
|
||||||
|
|
||||||
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(pathFile+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::createActions()
|
void MainWindowViewer::createActions()
|
||||||
{
|
{
|
||||||
openAction = new QAction(tr("&Open"),this);
|
openAction = new QAction(tr("&Open"),this);
|
||||||
@ -691,6 +645,39 @@ void MainWindowViewer::open(QString path, ComicDB & comic, QList<ComicDB> & sibl
|
|||||||
openNextComicAction->setDisabled(true);
|
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)
|
void MainWindowViewer::openComicFromPath(QString pathFile)
|
||||||
{
|
{
|
||||||
QFileInfo fi(pathFile);
|
QFileInfo fi(pathFile);
|
||||||
|
@ -27,6 +27,7 @@ class EditShortcutsDialog;
|
|||||||
public slots:
|
public slots:
|
||||||
void open();
|
void open();
|
||||||
void open(QString path, ComicDB & comic, QList<ComicDB> & siblings);
|
void open(QString path, ComicDB & comic, QList<ComicDB> & siblings);
|
||||||
|
void open(QString path, qint64 comicId, qint64 libraryId);
|
||||||
void openFolder();
|
void openFolder();
|
||||||
void saveImage();
|
void saveImage();
|
||||||
void toggleToolBars();
|
void toggleToolBars();
|
||||||
@ -114,7 +115,6 @@ class EditShortcutsDialog;
|
|||||||
QString nextComicPath;
|
QString nextComicPath;
|
||||||
//! Método que inicializa el interfaz.
|
//! Método que inicializa el interfaz.
|
||||||
void setupUI();
|
void setupUI();
|
||||||
void openFromArgv();
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
void getSiblingComics(QString path,QString currentComic);
|
void getSiblingComics(QString path,QString currentComic);
|
||||||
@ -131,6 +131,7 @@ class EditShortcutsDialog;
|
|||||||
ComicDB currentComicDB;
|
ComicDB currentComicDB;
|
||||||
QList<ComicDB> siblingComics;
|
QList<ComicDB> siblingComics;
|
||||||
bool isClient;
|
bool isClient;
|
||||||
|
QString startComicPath;
|
||||||
quint64 libraryId;
|
quint64 libraryId;
|
||||||
signals:
|
signals:
|
||||||
void closed();
|
void closed();
|
||||||
|
@ -609,8 +609,11 @@ void Render::update()
|
|||||||
void Render::load(const QString & path, int atPage)
|
void Render::load(const QString & path, int atPage)
|
||||||
{
|
{
|
||||||
createComic(path);
|
createComic(path);
|
||||||
|
if (comic !=0)
|
||||||
|
{
|
||||||
loadComic(path,atPage);
|
loadComic(path,atPage);
|
||||||
startLoad();
|
startLoad();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -636,8 +639,11 @@ void Render::load(const QString & path, const ComicDB & comicDB)
|
|||||||
filters[i]->setLevel(comicDB.info.gamma);
|
filters[i]->setLevel(comicDB.info.gamma);
|
||||||
}
|
}
|
||||||
createComic(path);
|
createComic(path);
|
||||||
|
if (comic!=0)
|
||||||
|
{
|
||||||
loadComic(path,comicDB);
|
loadComic(path,comicDB);
|
||||||
startLoad();
|
startLoad();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render::createComic(const QString & path)
|
void Render::createComic(const QString & path)
|
||||||
|
@ -1285,8 +1285,8 @@ void LibraryWindow::openComic()
|
|||||||
//Invoke YACReader comicPath comicId libraryId NO-->currentPage bookmark1 bookmark2 bookmark3 brightness contrast gamma
|
//Invoke YACReader comicPath comicId libraryId NO-->currentPage bookmark1 bookmark2 bookmark3 brightness contrast gamma
|
||||||
bool yacreaderFound = false;
|
bool yacreaderFound = false;
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QString comicIdS = QString("%1").arg(comicId);
|
QString comicIdS = QString("--comicId=") + QString("%1").arg(comicId);
|
||||||
QString libraryIdS = QString("%1").arg(libraryId);
|
QString libraryIdS = QString("--libraryId=") + QString("%1").arg(libraryId);
|
||||||
QString yacreaderPath = QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app");
|
QString yacreaderPath = QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app");
|
||||||
if(yacreaderFound = QFileInfo(yacreaderPath).exists())
|
if(yacreaderFound = QFileInfo(yacreaderPath).exists())
|
||||||
QProcess::startDetached("open", QStringList() << "-n" << yacreaderPath << "--args" << path << comicIdS << libraryIdS ); /*<< page << bookmark1 << bookmark2 << bookmark3 << brightness << contrast << gamma*///,QStringList() << path);
|
QProcess::startDetached("open", QStringList() << "-n" << yacreaderPath << "--args" << path << comicIdS << libraryIdS ); /*<< page << bookmark1 << bookmark2 << bookmark3 << brightness << contrast << gamma*///,QStringList() << path);
|
||||||
@ -1294,11 +1294,11 @@ void LibraryWindow::openComic()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN /* \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\" \"%10\" */
|
#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
|
#endif
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
QStringList parameters = QStringList() << path << QString::number(comicId) << QString::number(libraryId);
|
QStringList parameters = QStringList() << path << (QString("--comicId=") + QString::number(comicId)) << (QString("--libraryId=") + QString::number(libraryId));
|
||||||
yacreaderFound = QProcess::startDetached(QString("YACReader"),parameters);
|
yacreaderFound = QProcess::startDetached(QString("YACReader"),parameters);
|
||||||
#endif
|
#endif
|
||||||
if(!yacreaderFound)
|
if(!yacreaderFound)
|
||||||
@ -1746,7 +1746,7 @@ void LibraryWindow::openContainingFolderComic()
|
|||||||
{
|
{
|
||||||
QModelIndex modelIndex = comicsView->currentIndex();
|
QModelIndex modelIndex = comicsView->currentIndex();
|
||||||
QFileInfo file = QDir::cleanPath(currentPath() + dmCV->getComicPath(modelIndex));
|
QFileInfo file = QDir::cleanPath(currentPath() + dmCV->getComicPath(modelIndex));
|
||||||
#ifdef Q_OS_LINUX
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
QString path = file.absolutePath();
|
QString path = file.absolutePath();
|
||||||
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode));
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
@ -141,6 +142,31 @@ int main( int argc, char ** argv )
|
|||||||
app.setApplicationName("YACReaderLibrary");
|
app.setApplicationName("YACReaderLibrary");
|
||||||
app.setOrganizationName("YACReader");
|
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";
|
QString destLog = YACReader::getSettingsPath()+"/yacreaderlibrary.log";
|
||||||
QDir().mkpath(YACReader::getSettingsPath());
|
QDir().mkpath(YACReader::getSettingsPath());
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ QList<QString> addresses()
|
|||||||
getifaddrs(&ifAddrStruct);
|
getifaddrs(&ifAddrStruct);
|
||||||
|
|
||||||
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
||||||
|
if (ifa ->ifa_addr) {
|
||||||
if (ifa ->ifa_addr->sa_family==AF_INET) { // check it is IP4
|
if (ifa ->ifa_addr->sa_family==AF_INET) { // check it is IP4
|
||||||
// is a valid IP4 Address
|
// is a valid IP4 Address
|
||||||
tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
|
tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
|
||||||
@ -47,6 +48,7 @@ QList<QString> addresses()
|
|||||||
//printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
//printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
|
if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
|
||||||
return localAddreses;
|
return localAddreses;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ bool HttpVersionChecker::checkNewVersion(QString sourceContent)
|
|||||||
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32.*");
|
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32.*");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}X11.*");
|
QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}X11.*");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user