mirror of
https://github.com/YACReader/yacreader
synced 2025-07-17 20:44:32 -04:00
YACReaderLibrary opens now its own viewer windows
This commit is contained in:
@ -5,108 +5,9 @@ TEMPLATE = app
|
||||
TARGET =
|
||||
DEPENDPATH += . \
|
||||
release
|
||||
INCLUDEPATH += .
|
||||
INCLUDEPATH += ../common \
|
||||
../custom_widgets
|
||||
|
||||
win32 {
|
||||
INCLUDEPATH += ../dependencies/poppler/include
|
||||
LIBS += -L../dependencies/poppler/lib -lpoppler-qt4
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
||||
CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
||||
unix:!macx{
|
||||
INCLUDEPATH += /usr/include/poppler/qt4
|
||||
LIBS += -L/usr/lib -lpoppler-qt4
|
||||
LIBS += -lGLU
|
||||
}
|
||||
|
||||
macx{
|
||||
#INCLUDEPATH += "/Volumes/Mac OS X Lion/usr/X11/include"
|
||||
INCLUDEPATH += /usr/local/include/poppler/qt4
|
||||
LIBS += -L/usr/local/lib -lpoppler-qt4
|
||||
}
|
||||
|
||||
QT += network phonon opengl
|
||||
CONFIG += release
|
||||
CONFIG -= flat
|
||||
|
||||
# Input
|
||||
HEADERS += comic.h \
|
||||
configuration.h \
|
||||
goto_dialog.h \
|
||||
magnifying_glass.h \
|
||||
main_window_viewer.h \
|
||||
viewer.h \
|
||||
goto_flow.h \
|
||||
options_dialog.h \
|
||||
bookmarks.h \
|
||||
bookmarks_dialog.h \
|
||||
render.h \
|
||||
shortcuts_dialog.h \
|
||||
translator.h \
|
||||
goto_flow_gl.h \
|
||||
goto_flow_widget.h \
|
||||
page_label_widget.h \
|
||||
goto_flow_toolbar.h \
|
||||
goto_flow_decorationbar.h \
|
||||
width_slider.h \
|
||||
notifications_label_widget.h \
|
||||
../common/pictureflow.h \
|
||||
../common/custom_widgets.h \
|
||||
../common/check_new_version.h \
|
||||
../common/qnaturalsorting.h \
|
||||
../common/yacreader_flow_gl.h \
|
||||
../common/yacreader_global.h \
|
||||
../common/onstart_flow_selection_dialog.h \
|
||||
../common/comic_db.h \
|
||||
../common/folder.h \
|
||||
../common/library_item.h \
|
||||
yacreader_local_client.h
|
||||
|
||||
SOURCES += comic.cpp \
|
||||
configuration.cpp \
|
||||
goto_dialog.cpp \
|
||||
magnifying_glass.cpp \
|
||||
main.cpp \
|
||||
main_window_viewer.cpp \
|
||||
viewer.cpp \
|
||||
goto_flow.cpp \
|
||||
options_dialog.cpp \
|
||||
bookmarks.cpp \
|
||||
bookmarks_dialog.cpp \
|
||||
render.cpp \
|
||||
shortcuts_dialog.cpp \
|
||||
translator.cpp \
|
||||
goto_flow_gl.cpp \
|
||||
goto_flow_widget.cpp \
|
||||
page_label_widget.cpp \
|
||||
goto_flow_toolbar.cpp \
|
||||
goto_flow_decorationbar.cpp \
|
||||
width_slider.cpp \
|
||||
notifications_label_widget.cpp \
|
||||
../common/pictureflow.cpp \
|
||||
../common/custom_widgets.cpp \
|
||||
../common/check_new_version.cpp \
|
||||
../common/qnaturalsorting.cpp \
|
||||
../common/yacreader_flow_gl.cpp \
|
||||
../common/onstart_flow_selection_dialog.cpp \
|
||||
../common/comic_db.cpp \
|
||||
../common/folder.cpp \
|
||||
../common/library_item.cpp \
|
||||
yacreader_local_client.cpp
|
||||
|
||||
include(../custom_widgets/custom_widgets.pri)
|
||||
include(../compressed_archive/wrapper.pri)
|
||||
|
||||
RESOURCES += images.qrc \
|
||||
files.qrc
|
||||
|
||||
win32:RESOURCES += images_win.qrc
|
||||
unix:!macx:RESOURCES += images_win.qrc
|
||||
macx:RESOURCES += images_osx.qrc
|
||||
SOURCES += main.cpp
|
||||
include(YACReader.pri)
|
||||
|
||||
RC_FILE = icon.rc
|
||||
|
||||
|
@ -558,6 +558,34 @@ void MainWindowViewer::open()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowViewer::open(QString path, ComicDB & comic, QList<ComicDB> & siblings)
|
||||
{
|
||||
currentComicDB = comic;
|
||||
siblingComics = siblings;
|
||||
|
||||
QFileInfo fi(path);
|
||||
currentDirectory = fi.absoluteDir().path();
|
||||
|
||||
if(comic.info.title != 0 && !comic.info.title->isEmpty())
|
||||
setWindowTitle("YACReader - " + *comic.info.title);
|
||||
else
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
viewer->open(path);
|
||||
enableActions();
|
||||
int index = siblings.indexOf(comic);
|
||||
|
||||
if(index>0)
|
||||
openPreviousComicAction->setDisabled(false);
|
||||
else
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
|
||||
if(index+1<siblings.count())
|
||||
openNextComicAction->setDisabled(false);
|
||||
else
|
||||
openNextComicAction->setDisabled(true);
|
||||
}
|
||||
|
||||
void MainWindowViewer::openComicFromPath(QString pathFile)
|
||||
{
|
||||
currentDirectory = pathFile;
|
||||
@ -795,10 +823,19 @@ void MainWindowViewer::closeEvent ( QCloseEvent * event )
|
||||
conf.setSize(size());
|
||||
}
|
||||
conf.setMaximized(isMaximized());
|
||||
|
||||
emit (closed());
|
||||
}
|
||||
|
||||
void MainWindowViewer::openPreviousComic()
|
||||
{
|
||||
if(!siblingComics.isEmpty())
|
||||
{
|
||||
int currentIndex = siblingComics.indexOf(currentComicDB);
|
||||
ComicDB previoiusComic = siblingComics.at(currentIndex-1);
|
||||
open(currentDirectory+previoiusComic.path,previoiusComic,siblingComics);
|
||||
return;
|
||||
}
|
||||
if(!previousComicPath.isEmpty())
|
||||
{
|
||||
viewer->open(previousComicPath);
|
||||
@ -811,6 +848,13 @@ void MainWindowViewer::openPreviousComic()
|
||||
|
||||
void MainWindowViewer::openNextComic()
|
||||
{
|
||||
if(!siblingComics.isEmpty())
|
||||
{
|
||||
int currentIndex = siblingComics.indexOf(currentComicDB);
|
||||
ComicDB nextComic = siblingComics.at(currentIndex+1);
|
||||
open(currentDirectory+nextComic.path,nextComic,siblingComics);
|
||||
return;
|
||||
}
|
||||
if(!nextComicPath.isEmpty())
|
||||
{
|
||||
viewer->open(nextComicPath);
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QSettings>
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
class Comic;
|
||||
class Viewer;
|
||||
class OptionsDialog;
|
||||
@ -23,6 +25,7 @@ class YACReaderSliderAction;
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
void open(QString path, ComicDB & comic, QList<ComicDB> & siblings);
|
||||
void openFolder();
|
||||
void saveImage();
|
||||
void toggleToolBars();
|
||||
@ -115,7 +118,11 @@ class YACReaderSliderAction;
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
|
||||
QSettings * settings;
|
||||
|
||||
|
||||
ComicDB currentComicDB;
|
||||
QList<ComicDB> siblingComics;
|
||||
signals:
|
||||
void closed();
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
public:
|
||||
|
@ -127,6 +127,8 @@ win32:RESOURCES += images_win.qrc
|
||||
unix:!macx:RESOURCES += images_win.qrc
|
||||
macx:RESOURCES += images_osx.qrc
|
||||
|
||||
include(../YACReader/YACReader.pri)
|
||||
|
||||
RC_FILE = icon.rc
|
||||
|
||||
macx {
|
||||
|
@ -394,6 +394,25 @@ QVector<bool> TableModel::setAllComicsRead(bool read)
|
||||
return readList;
|
||||
}
|
||||
|
||||
QList<ComicDB> TableModel::getAllComics()
|
||||
{
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
db.transaction();
|
||||
|
||||
QList<ComicDB> comics;
|
||||
int numComics = _data.count();
|
||||
for(int i=0;i<numComics;i++)
|
||||
{
|
||||
comics.append(DBHelper::loadComic(_data.value(i)->data(ID).toULongLong(),db));
|
||||
}
|
||||
|
||||
db.commit();
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
|
||||
return comics;
|
||||
}
|
||||
|
||||
QList<ComicDB> TableModel::getComics(QList<QModelIndex> list)
|
||||
{
|
||||
QList<ComicDB> comics;
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
QVector<bool> getReadList();
|
||||
QVector<bool> setAllComicsRead(bool read);
|
||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
|
||||
QList<ComicDB> getAllComics();
|
||||
QModelIndex getIndexFromId(quint64 id);
|
||||
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
||||
//setComicInfoForAllComics(); --> inserta la informaci<63>n com<6F>n a todos los c<>mics de una sola vez.
|
||||
|
@ -55,7 +55,7 @@
|
||||
#include "comics_remover.h"
|
||||
#include "yacreader_library_list_widget.h"
|
||||
#include "yacreader_treeview.h"
|
||||
|
||||
#include "main_window_viewer.h"
|
||||
//#include "yacreader_social_dialog.h"
|
||||
//
|
||||
|
||||
@ -1006,19 +1006,25 @@ void LibraryWindow::openComic()
|
||||
{
|
||||
ComicDB comic = dmCV->getComic(comicView->currentIndex());
|
||||
QString path = currentPath() + comic.path;
|
||||
MainWindowViewer * viewer = new MainWindowViewer();
|
||||
QList<ComicDB> siblings = dmCV->getAllComics();
|
||||
viewer->open(path,comic,siblings);
|
||||
viewer->show();
|
||||
|
||||
connect(viewer,SIGNAL(closed()),viewer,SLOT(deleteLater()));
|
||||
/*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 /*<< comicId << libraryId << page*/);//,QStringList() << path);
|
||||
//Comic is readed
|
||||
#else
|
||||
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\"").arg(path)/*.arg(comicId).arg(libraryId).arg(page)*/,QStringList());
|
||||
#endif
|
||||
//#ifdef Q_OS_MAC
|
||||
//
|
||||
// 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)/*.arg(comicId).arg(libraryId).arg(page)*/,QStringList());
|
||||
//#endif
|
||||
//Comic is readed
|
||||
setCurrentComicReaded();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "yacreader_global.h"
|
||||
#include "startup.h"
|
||||
#include "yacreader_local_server.h"
|
||||
|
||||
#define PICTUREFLOW_QT4 1
|
||||
|
||||
//interfaz al servidor
|
||||
@ -21,6 +22,10 @@ int main( int argc, char ** argv )
|
||||
QString sufix = QLocale::system().name();
|
||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
||||
app.installTranslator(&translator);
|
||||
|
||||
QTranslator viewerTranslator;
|
||||
viewerTranslator.load(QCoreApplication::applicationDirPath()+"/languages/yacreader_"+sufix);
|
||||
app.installTranslator(&viewerTranslator);
|
||||
app.setApplicationName("YACReaderLibrary");
|
||||
|
||||
#ifdef SERVER_RELEASE
|
||||
|
@ -120,6 +120,8 @@ public:
|
||||
|
||||
ComicInfo info;
|
||||
|
||||
bool operator==(const ComicDB & other){return id == other.id;};
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &, const ComicDB &);
|
||||
friend QDataStream &operator>>(QDataStream &, ComicDB &);
|
||||
};
|
||||
|
Reference in New Issue
Block a user