mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Remove software and opengl flow implementations
This simplifies the code base A LOT.
This commit is contained in:
@ -24,24 +24,13 @@ SOURCES += main.cpp
|
||||
|
||||
INCLUDEPATH += ../common \
|
||||
../custom_widgets
|
||||
INCLUDEPATH += ../common/rhi
|
||||
|
||||
!CONFIG(no_opengl) {
|
||||
INCLUDEPATH += ../common/gl
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
INCLUDEPATH += ../common/rhi
|
||||
DEFINES += YACREADER_USE_RHI
|
||||
}
|
||||
}
|
||||
HEADERS += ../common/rhi/flow_types.h
|
||||
SOURCES += ../common/rhi/flow_types.cpp
|
||||
|
||||
win32 {
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -luser32
|
||||
# When using RHI (Qt 6.7+), don't link OpenGL directly - QRhiWidget handles graphics APIs
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
message("RHI mode: not linking opengl32 (using QRhiWidget)")
|
||||
} else {
|
||||
LIBS += -lopengl32
|
||||
}
|
||||
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -luser32
|
||||
msvc {
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||
QMAKE_LFLAGS_RELEASE += /LTCG
|
||||
@ -59,7 +48,7 @@ macx {
|
||||
|
||||
QT += network widgets core multimedia svg
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
QT += gui-private
|
||||
@ -76,7 +65,6 @@ HEADERS += ../common/comic.h \
|
||||
main_window_viewer.h \
|
||||
mouse_handler.h \
|
||||
viewer.h \
|
||||
goto_flow.h \
|
||||
options_dialog.h \
|
||||
../common/bookmarks.h \
|
||||
bookmarks_dialog.h \
|
||||
@ -87,7 +75,6 @@ HEADERS += ../common/comic.h \
|
||||
goto_flow_toolbar.h \
|
||||
width_slider.h \
|
||||
notifications_label_widget.h \
|
||||
../common/pictureflow.h \
|
||||
../common/custom_widgets.h \
|
||||
../common/check_new_version.h \
|
||||
../common/qnaturalsorting.h \
|
||||
@ -100,20 +87,12 @@ HEADERS += ../common/comic.h \
|
||||
../common/http_worker.h \
|
||||
../common/exit_check.h \
|
||||
../common/scroll_management.h \
|
||||
../common/opengl_checker.h \
|
||||
../common/pdf_comic.h \
|
||||
../common/global_info_provider.h \
|
||||
../common/rhi/yacreader_flow_rhi.h \
|
||||
../common/rhi/yacreader_comic_flow_rhi.h \
|
||||
../common/rhi/yacreader_page_flow_rhi.h
|
||||
|
||||
!CONFIG(no_opengl) {
|
||||
HEADERS += ../common/gl/yacreader_flow_gl.h \
|
||||
goto_flow_gl.h
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
HEADERS += ../common/rhi/yacreader_flow_rhi.h
|
||||
HEADERS += ../common/rhi/yacreader_comic_flow_rhi.h \
|
||||
../common/rhi/yacreader_page_flow_rhi.h
|
||||
}
|
||||
}
|
||||
|
||||
SOURCES += ../common/comic.cpp \
|
||||
configuration.cpp \
|
||||
@ -122,7 +101,6 @@ SOURCES += ../common/comic.cpp \
|
||||
main_window_viewer.cpp \
|
||||
mouse_handler.cpp \
|
||||
viewer.cpp \
|
||||
goto_flow.cpp \
|
||||
options_dialog.cpp \
|
||||
../common/bookmarks.cpp \
|
||||
bookmarks_dialog.cpp \
|
||||
@ -133,7 +111,6 @@ SOURCES += ../common/comic.cpp \
|
||||
goto_flow_toolbar.cpp \
|
||||
width_slider.cpp \
|
||||
notifications_label_widget.cpp \
|
||||
../common/pictureflow.cpp \
|
||||
../common/custom_widgets.cpp \
|
||||
../common/check_new_version.cpp \
|
||||
../common/qnaturalsorting.cpp \
|
||||
@ -146,23 +123,15 @@ SOURCES += ../common/comic.cpp \
|
||||
../common/yacreader_global_gui.cpp \
|
||||
../common/exit_check.cpp \
|
||||
../common/scroll_management.cpp \
|
||||
../common/opengl_checker.cpp \
|
||||
../common/global_info_provider.cpp \
|
||||
../common/rhi/yacreader_flow_rhi.cpp \
|
||||
../common/rhi/yacreader_comic_flow_rhi.cpp \
|
||||
../common/rhi/yacreader_page_flow_rhi.cpp
|
||||
|
||||
!CONFIG(no_opengl) {
|
||||
SOURCES += ../common/gl/yacreader_flow_gl.cpp \
|
||||
goto_flow_gl.cpp
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
SOURCES += ../common/rhi/yacreader_flow_rhi.cpp
|
||||
SOURCES += ../common/rhi/yacreader_comic_flow_rhi.cpp \
|
||||
../common/rhi/yacreader_page_flow_rhi.cpp
|
||||
RESOURCES += ../common/rhi/shaders/shaders.qrc
|
||||
# Make raw GLSL shader sources editable in Qt Creator
|
||||
OTHER_FILES += ../common/rhi/shaders/flow.vert \
|
||||
../common/rhi/shaders/flow.frag
|
||||
}
|
||||
}
|
||||
RESOURCES += ../common/rhi/shaders/shaders.qrc
|
||||
# Make raw GLSL shader sources editable in Qt Creator
|
||||
OTHER_FILES += ../common/rhi/shaders/flow.vert \
|
||||
../common/rhi/shaders/flow.frag
|
||||
|
||||
include(../custom_widgets/custom_widgets_yacreader.pri)
|
||||
|
||||
|
||||
@ -1,297 +0,0 @@
|
||||
#include "goto_flow.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QSize>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QMutex>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QPixmap>
|
||||
#include <QThread>
|
||||
#include <QSize>
|
||||
#include <QIntValidator>
|
||||
#include <QWaitCondition>
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
|
||||
#include "yacreader_flow.h"
|
||||
|
||||
#include "goto_flow_toolbar.h"
|
||||
|
||||
GoToFlow::GoToFlow(QWidget *parent, FlowType flowType)
|
||||
: GoToFlowWidget(parent), ready(false)
|
||||
{
|
||||
updateTimer = new QTimer;
|
||||
connect(updateTimer, &QTimer::timeout, this, &GoToFlow::updateImageData);
|
||||
|
||||
worker = new PageLoader(&mutexGoToFlow);
|
||||
|
||||
flow = new YACReaderFlow(this, flowType);
|
||||
flow->setReflectionEffect(PictureFlow::PlainReflection);
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
|
||||
flow->setSlideSize(imageSize);
|
||||
connect(flow, &PictureFlow::centerIndexChanged, this, &GoToFlowWidget::setPageNumber);
|
||||
connect(flow, &YACReaderFlow::selected, this, &GoToFlow::goToPage);
|
||||
connect(flow, &PictureFlow::centerIndexChanged, this, &GoToFlow::preload);
|
||||
connect(flow, &PictureFlow::centerIndexChangedSilent, this, &GoToFlow::preload);
|
||||
|
||||
connect(toolBar, &GoToFlowToolBar::goToPage, this, &GoToFlow::goToPage);
|
||||
connect(toolBar, &GoToFlowToolBar::setCenter, flow, &PictureFlow::showSlide);
|
||||
|
||||
mainLayout->addWidget(flow);
|
||||
toolBar->raise();
|
||||
|
||||
resize(static_cast<int>(5 * imageSize.width()), toolBar->height() + static_cast<int>(imageSize.height() * 1.7));
|
||||
|
||||
this->setCursor(QCursor(Qt::ArrowCursor));
|
||||
}
|
||||
|
||||
GoToFlow::~GoToFlow()
|
||||
{
|
||||
delete flow;
|
||||
delete updateTimer;
|
||||
worker->deleteLater();
|
||||
}
|
||||
|
||||
void GoToFlow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Up:
|
||||
QApplication::sendEvent(flow, event);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GoToFlowWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GoToFlow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
|
||||
toolBar->move(0, event->size().height() - toolBar->height());
|
||||
toolBar->setFixedWidth(width());
|
||||
}
|
||||
|
||||
void GoToFlow::centerSlide(int slide)
|
||||
{
|
||||
if (flow->centerIndex() != slide) {
|
||||
flow->setCenterIndex(slide);
|
||||
if (ready) // load images if pages are loaded.
|
||||
{
|
||||
// worker->reset(); //BUG FIXED : image didn't load if worker was working
|
||||
preload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GoToFlow::setNumSlides(unsigned int slides)
|
||||
{
|
||||
// numPagesLabel->setText(tr("Total pages : ")+QString::number(slides));
|
||||
// numPagesLabel->adjustSize();
|
||||
imagesReady.clear();
|
||||
imagesReady.fill(false, slides);
|
||||
|
||||
rawImages.clear();
|
||||
rawImages.resize(slides);
|
||||
|
||||
toolBar->setTop(slides);
|
||||
|
||||
imagesLoaded.clear();
|
||||
imagesLoaded.fill(false, slides);
|
||||
|
||||
imagesSetted.clear();
|
||||
imagesSetted.fill(false, slides);
|
||||
|
||||
numImagesLoaded = 0;
|
||||
|
||||
ready = true;
|
||||
worker->reset();
|
||||
|
||||
flow->clear();
|
||||
for (unsigned int i = 0; i < slides; i++)
|
||||
flow->addSlide(QImage());
|
||||
flow->setCenterIndex(0);
|
||||
}
|
||||
|
||||
void GoToFlow::reset()
|
||||
{
|
||||
updateTimer->stop();
|
||||
/*imagesLoaded.clear();
|
||||
numImagesLoaded = 0;
|
||||
imagesReady.clear();
|
||||
rawImages.clear();*/
|
||||
ready = false;
|
||||
}
|
||||
|
||||
void GoToFlow::setImageReady(int index, const QByteArray &image)
|
||||
{
|
||||
rawImages[index] = image;
|
||||
imagesReady[index] = true;
|
||||
preload();
|
||||
}
|
||||
|
||||
void GoToFlow::preload()
|
||||
{
|
||||
if (numImagesLoaded < imagesLoaded.size())
|
||||
updateTimer->start(30); // TODO comprobar rendimiento, antes era 70
|
||||
}
|
||||
|
||||
void GoToFlow::updateImageData()
|
||||
{
|
||||
// can't do anything, wait for the next possibility
|
||||
if (worker->busy())
|
||||
return;
|
||||
|
||||
// set image of last one
|
||||
int idx = worker->index();
|
||||
if (idx >= 0 && !worker->result().isNull()) {
|
||||
if (!imagesSetted[idx]) {
|
||||
flow->setSlide(idx, worker->result());
|
||||
imagesSetted[idx] = true;
|
||||
numImagesLoaded++;
|
||||
rawImages[idx].clear();
|
||||
; // release memory
|
||||
imagesLoaded[idx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// try to load only few images on the left and right side
|
||||
// i.e. all visible ones plus some extra
|
||||
#define COUNT 8
|
||||
int indexes[2 * COUNT + 1];
|
||||
int center = flow->centerIndex();
|
||||
indexes[0] = center;
|
||||
for (int j = 0; j < COUNT; j++) {
|
||||
indexes[j * 2 + 1] = center + j + 1;
|
||||
indexes[j * 2 + 2] = center - j - 1;
|
||||
}
|
||||
for (int c = 0; c < 2 * COUNT + 1; c++) {
|
||||
int i = indexes[c];
|
||||
if ((i >= 0) && (i < flow->slideCount()))
|
||||
if (!imagesLoaded[i] && imagesReady[i]) // slide(i).isNull())
|
||||
{
|
||||
// schedule thumbnail generation
|
||||
|
||||
worker->generate(i, flow->slideSize(), rawImages[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// no need to generate anything? stop polling...
|
||||
updateTimer->stop();
|
||||
}
|
||||
|
||||
void GoToFlow::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->angleDelta().y() < 0)
|
||||
flow->showNext();
|
||||
else
|
||||
flow->showPrevious();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void GoToFlow::setFlowType(YACReader::FlowType flowType)
|
||||
{
|
||||
flow->setFlowType(flowType);
|
||||
}
|
||||
|
||||
void GoToFlow::updateConfig(QSettings *settings)
|
||||
{
|
||||
GoToFlowWidget::updateConfig(settings);
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
flow->setFlowType(Configuration::getConfiguration().getFlowType());
|
||||
resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
|
||||
updateSize();
|
||||
}
|
||||
|
||||
void GoToFlow::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PageLoader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
PageLoader::PageLoader(QMutex *m)
|
||||
: QThread(), mutex(m), restart(false), working(false), idx(-1)
|
||||
{
|
||||
}
|
||||
|
||||
PageLoader::~PageLoader()
|
||||
{
|
||||
// TODO this destructor never runs. If it is ever called, it will hang, because
|
||||
// the implementation is broken due to the absolutely endless loop in run().
|
||||
mutex->lock();
|
||||
condition.wakeOne();
|
||||
mutex->unlock();
|
||||
wait();
|
||||
}
|
||||
|
||||
bool PageLoader::busy() const
|
||||
{
|
||||
return isRunning() ? working.load() : false;
|
||||
}
|
||||
|
||||
void PageLoader::generate(int index, QSize size, const QByteArray &rImage)
|
||||
{
|
||||
mutex->lock();
|
||||
this->idx = index;
|
||||
// this->img = QImage();
|
||||
this->size = size;
|
||||
this->rawImage = rImage;
|
||||
mutex->unlock();
|
||||
|
||||
if (!isRunning())
|
||||
start();
|
||||
else {
|
||||
mutex->lock();
|
||||
// already running, wake up whenever ready
|
||||
restart = true;
|
||||
condition.wakeOne();
|
||||
mutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void PageLoader::run()
|
||||
{
|
||||
for (;;) {
|
||||
// copy necessary data
|
||||
mutex->lock();
|
||||
this->working = true;
|
||||
// int idx = this->idx;
|
||||
|
||||
QImage image;
|
||||
image.loadFromData(this->rawImage);
|
||||
// let everyone knows it is ready
|
||||
image = image.scaled(this->size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
mutex->unlock();
|
||||
|
||||
mutex->lock();
|
||||
this->img = image;
|
||||
this->working = false;
|
||||
mutex->unlock();
|
||||
|
||||
// put to sleep
|
||||
mutex->lock();
|
||||
while (!this->restart)
|
||||
condition.wait(mutex);
|
||||
restart = false;
|
||||
mutex->unlock();
|
||||
}
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
#ifndef __GOTO_FLOW_H
|
||||
#define __GOTO_FLOW_H
|
||||
|
||||
#include "goto_flow_widget.h"
|
||||
#include "yacreader_global_gui.h"
|
||||
|
||||
#include <QThread>
|
||||
|
||||
#include <QWaitCondition>
|
||||
#include <QMutex>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QPixmap;
|
||||
class QThread;
|
||||
class QSize;
|
||||
class QIntValidator;
|
||||
class QWaitCondition;
|
||||
class QEvent;
|
||||
class QLabel;
|
||||
|
||||
class Comic;
|
||||
class PageLoader;
|
||||
class YACReaderFlow;
|
||||
class PictureFlow;
|
||||
class QKeyEvent;
|
||||
|
||||
class GoToFlow : public GoToFlowWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GoToFlow(QWidget *parent = nullptr, FlowType flowType = CoverFlowLike);
|
||||
~GoToFlow() override;
|
||||
bool ready; // comic is ready for read.
|
||||
private:
|
||||
YACReaderFlow *flow;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
// Comic * comic;
|
||||
QSize imageSize;
|
||||
|
||||
QVector<bool> imagesLoaded;
|
||||
QVector<bool> imagesSetted;
|
||||
int numImagesLoaded;
|
||||
QVector<bool> imagesReady;
|
||||
QVector<QByteArray> rawImages;
|
||||
QTimer *updateTimer;
|
||||
PageLoader *worker;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
QMutex mutexGoToFlow;
|
||||
|
||||
private slots:
|
||||
void preload();
|
||||
void updateImageData();
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void centerSlide(int slide) override;
|
||||
void reset() override;
|
||||
void setNumSlides(unsigned int slides) override;
|
||||
void setImageReady(int index, const QByteArray &image) override;
|
||||
void setFlowType(YACReader::FlowType flowType) override;
|
||||
void updateConfig(QSettings *settings) override;
|
||||
void setFlowRightToLeft(bool b) override;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PageLoader
|
||||
//-----------------------------------------------------------------------------
|
||||
class PageLoader : public QThread
|
||||
{
|
||||
public:
|
||||
PageLoader(QMutex *m);
|
||||
~PageLoader() override;
|
||||
// returns FALSE if worker is still busy and can't take the task
|
||||
bool busy() const;
|
||||
void generate(int index, QSize size, const QByteArray &rImage);
|
||||
void reset() { idx = -1; };
|
||||
int index() const { return idx; }
|
||||
QImage result() const { return img; }
|
||||
|
||||
protected:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
QMutex *mutex;
|
||||
QWaitCondition condition;
|
||||
|
||||
bool restart;
|
||||
std::atomic<bool> working;
|
||||
int idx;
|
||||
|
||||
QSize size;
|
||||
QImage img;
|
||||
QByteArray rawImage;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,164 +0,0 @@
|
||||
#include "goto_flow_gl.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QIntValidator>
|
||||
#include <QPushButton>
|
||||
#include <QPushButton>
|
||||
#include <QSize>
|
||||
#include <QApplication>
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#include "goto_flow_toolbar.h"
|
||||
|
||||
GoToFlowGL::GoToFlowGL(QWidget *parent, FlowType flowType)
|
||||
: GoToFlowWidget(parent)
|
||||
{
|
||||
Q_UNUSED(flowType)
|
||||
flow = new YACReaderPageFlowImpl(this);
|
||||
flow->setShowMarks(false);
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
|
||||
flow->setSlideSize(imageSize);
|
||||
connect(flow, &YACReaderPageFlowImpl::centerIndexChanged, this, &GoToFlowWidget::setPageNumber);
|
||||
connect(flow, &YACReaderPageFlowImpl::selected, this, &GoToFlowGL::goToPage);
|
||||
|
||||
connect(toolBar, &GoToFlowToolBar::goToPage, this, &GoToFlowGL::goToPage);
|
||||
connect(toolBar, &GoToFlowToolBar::setCenter, flow, &YACReaderPageFlowImpl::setCenterIndex);
|
||||
|
||||
mainLayout->addWidget(flow);
|
||||
toolBar->raise();
|
||||
|
||||
resize(static_cast<int>(5 * imageSize.width()), toolBar->height() + static_cast<int>(imageSize.height() * 1.7));
|
||||
|
||||
this->setCursor(QCursor(Qt::ArrowCursor));
|
||||
}
|
||||
|
||||
GoToFlowGL::~GoToFlowGL()
|
||||
{
|
||||
delete flow;
|
||||
}
|
||||
|
||||
void GoToFlowGL::reset()
|
||||
{
|
||||
flow->reset();
|
||||
}
|
||||
|
||||
void GoToFlowGL::centerSlide(int slide)
|
||||
{
|
||||
if (flow->centerIndex() != slide) {
|
||||
flow->setCenterIndex(slide);
|
||||
}
|
||||
}
|
||||
|
||||
void GoToFlowGL::setFlowType(FlowType flowType)
|
||||
{
|
||||
if (flowType == CoverFlowLike)
|
||||
flow->setPreset(presetYACReaderFlowClassicConfig);
|
||||
else if (flowType == Strip)
|
||||
flow->setPreset(presetYACReaderFlowStripeConfig);
|
||||
else if (flowType == StripOverlapped)
|
||||
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
|
||||
else
|
||||
flow->setPreset(defaultYACReaderFlowConfig);
|
||||
}
|
||||
|
||||
void GoToFlowGL::setNumSlides(unsigned int slides)
|
||||
{
|
||||
flow->populate(slides);
|
||||
toolBar->setTop(slides);
|
||||
}
|
||||
void GoToFlowGL::setImageReady(int index, const QByteArray &imageData)
|
||||
{
|
||||
flow->rawImages[index] = imageData;
|
||||
flow->imagesReady[index] = true;
|
||||
}
|
||||
|
||||
void GoToFlowGL::updateConfig(QSettings *settings)
|
||||
{
|
||||
GoToFlowWidget::updateConfig(settings);
|
||||
|
||||
Performance performance = medium;
|
||||
switch (settings->value(PERFORMANCE).toInt()) {
|
||||
case 0:
|
||||
performance = low;
|
||||
break;
|
||||
case 1:
|
||||
performance = medium;
|
||||
break;
|
||||
case 2:
|
||||
performance = high;
|
||||
break;
|
||||
case 3:
|
||||
performance = ultraHigh;
|
||||
break;
|
||||
}
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
|
||||
updateSize();
|
||||
|
||||
flow->setPerformance(performance);
|
||||
|
||||
switch (settings->value(FLOW_TYPE_GL).toInt()) {
|
||||
case FlowType::CoverFlowLike:
|
||||
flow->setPreset(presetYACReaderFlowClassicConfig);
|
||||
break;
|
||||
case FlowType::Strip:
|
||||
flow->setPreset(presetYACReaderFlowStripeConfig);
|
||||
break;
|
||||
case FlowType::StripOverlapped:
|
||||
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
|
||||
break;
|
||||
case FlowType::Modern:
|
||||
flow->setPreset(defaultYACReaderFlowConfig);
|
||||
break;
|
||||
case FlowType::Roulette:
|
||||
flow->setPreset(pressetYACReaderFlowDownConfig);
|
||||
break;
|
||||
case FlowType::Custom:
|
||||
flow->setCF_RX(settings->value(X_ROTATION).toInt());
|
||||
flow->setCF_Y(settings->value(Y_POSITION).toInt());
|
||||
flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
|
||||
flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
|
||||
flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
|
||||
flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
|
||||
flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
|
||||
flow->setRotation(settings->value(COVER_ROTATION).toInt());
|
||||
flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
|
||||
flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
|
||||
flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
|
||||
break;
|
||||
}
|
||||
if (Configuration::getConfiguration().getQuickNaviMode())
|
||||
flow->setFadeOutDist(20);
|
||||
}
|
||||
|
||||
void GoToFlowGL::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Up:
|
||||
QApplication::sendEvent(flow, event);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GoToFlowWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GoToFlowGL::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
|
||||
toolBar->move(0, event->size().height() - toolBar->height());
|
||||
toolBar->setFixedWidth(width());
|
||||
}
|
||||
|
||||
void GoToFlowGL::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
#ifndef __GOTO_FLOW_GL_H
|
||||
#define __GOTO_FLOW_GL_H
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "goto_flow_widget.h"
|
||||
|
||||
// Conditional include based on Qt version and RHI availability
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
#include "yacreader_page_flow_rhi.h"
|
||||
using YACReaderPageFlowImpl = YACReaderPageFlow3D;
|
||||
#else
|
||||
#include "yacreader_flow_gl.h"
|
||||
using YACReaderPageFlowImpl = YACReaderPageFlowGL;
|
||||
#endif
|
||||
|
||||
class QLineEdit;
|
||||
class QIntValidator;
|
||||
class QPushButton;
|
||||
class QPushButton;
|
||||
class QSize;
|
||||
class QKeyEvent;
|
||||
|
||||
class GoToFlowGL : public GoToFlowWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GoToFlowGL(QWidget *parent = nullptr, FlowType flowType = CoverFlowLike);
|
||||
~GoToFlowGL() override;
|
||||
void reset() override;
|
||||
void centerSlide(int slide) override;
|
||||
void setFlowType(FlowType flowType) override;
|
||||
void setNumSlides(unsigned int slides) override;
|
||||
void setImageReady(int index, const QByteArray &image) override;
|
||||
|
||||
void updateConfig(QSettings *settings) override;
|
||||
void setFlowRightToLeft(bool b) override;
|
||||
|
||||
private:
|
||||
YACReaderPageFlowImpl *flow;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
// Comic * comic;
|
||||
QSize imageSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,16 +1,19 @@
|
||||
#include "goto_flow_widget.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
|
||||
#include "goto_flow_toolbar.h"
|
||||
#include "configuration.h"
|
||||
|
||||
GoToFlowWidget::GoToFlowWidget(QWidget *parent)
|
||||
GoToFlowWidget::GoToFlowWidget(QWidget *parent, FlowType flowType)
|
||||
: QWidget(parent)
|
||||
{
|
||||
Q_UNUSED(flowType)
|
||||
|
||||
mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(0);
|
||||
@ -19,19 +22,151 @@ GoToFlowWidget::GoToFlowWidget(QWidget *parent)
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
// toolBar->installEventFilter(this);
|
||||
flow = new YACReaderPageFlow3D(this);
|
||||
flow->setShowMarks(false);
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
|
||||
flow->setSlideSize(imageSize);
|
||||
connect(flow, &YACReaderPageFlow3D::centerIndexChanged, this, &GoToFlowWidget::setPageNumber);
|
||||
connect(flow, &YACReaderPageFlow3D::selected, this, &GoToFlowWidget::goToPage);
|
||||
|
||||
connect(toolBar, &GoToFlowToolBar::goToPage, this, &GoToFlowWidget::goToPage);
|
||||
connect(toolBar, &GoToFlowToolBar::setCenter, flow, &YACReaderPageFlow3D::setCenterIndex);
|
||||
|
||||
mainLayout->addWidget(flow);
|
||||
toolBar->raise();
|
||||
|
||||
resize(static_cast<int>(5 * imageSize.width()), toolBar->height() + static_cast<int>(imageSize.height() * 1.7));
|
||||
|
||||
this->setCursor(QCursor(Qt::ArrowCursor));
|
||||
}
|
||||
|
||||
GoToFlowWidget::~GoToFlowWidget() { }
|
||||
GoToFlowWidget::~GoToFlowWidget()
|
||||
{
|
||||
delete flow;
|
||||
}
|
||||
|
||||
void GoToFlowWidget::reset()
|
||||
{
|
||||
flow->reset();
|
||||
}
|
||||
|
||||
void GoToFlowWidget::centerSlide(int slide)
|
||||
{
|
||||
if (flow->centerIndex() != slide) {
|
||||
flow->setCenterIndex(slide);
|
||||
}
|
||||
}
|
||||
|
||||
void GoToFlowWidget::setPageNumber(int page)
|
||||
{
|
||||
toolBar->setPage(page);
|
||||
}
|
||||
|
||||
void GoToFlowWidget::setFlowType(FlowType flowType)
|
||||
{
|
||||
if (flowType == CoverFlowLike)
|
||||
flow->setPreset(presetYACReaderFlowClassicConfig);
|
||||
else if (flowType == Strip)
|
||||
flow->setPreset(presetYACReaderFlowStripeConfig);
|
||||
else if (flowType == StripOverlapped)
|
||||
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
|
||||
else
|
||||
flow->setPreset(defaultYACReaderFlowConfig);
|
||||
}
|
||||
|
||||
void GoToFlowWidget::setNumSlides(unsigned int slides)
|
||||
{
|
||||
flow->populate(slides);
|
||||
toolBar->setTop(slides);
|
||||
}
|
||||
|
||||
void GoToFlowWidget::setImageReady(int index, const QByteArray &imageData)
|
||||
{
|
||||
flow->rawImages[index] = imageData;
|
||||
flow->imagesReady[index] = true;
|
||||
}
|
||||
|
||||
void GoToFlowWidget::updateSize()
|
||||
{
|
||||
if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr)
|
||||
resize(parentWidget()->width(), height());
|
||||
}
|
||||
|
||||
void GoToFlowWidget::updateConfig(QSettings *settings)
|
||||
{
|
||||
toolBar->updateOptions();
|
||||
|
||||
Performance performance = medium;
|
||||
switch (settings->value(PERFORMANCE).toInt()) {
|
||||
case 0:
|
||||
performance = low;
|
||||
break;
|
||||
case 1:
|
||||
performance = medium;
|
||||
break;
|
||||
case 2:
|
||||
performance = high;
|
||||
break;
|
||||
case 3:
|
||||
performance = ultraHigh;
|
||||
break;
|
||||
}
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
resize(5 * imageSize.width(), toolBar->height() + imageSize.height() * 1.7);
|
||||
updateSize();
|
||||
|
||||
flow->setPerformance(performance);
|
||||
|
||||
switch (settings->value(FLOW_TYPE_GL).toInt()) {
|
||||
case FlowType::CoverFlowLike:
|
||||
flow->setPreset(presetYACReaderFlowClassicConfig);
|
||||
break;
|
||||
case FlowType::Strip:
|
||||
flow->setPreset(presetYACReaderFlowStripeConfig);
|
||||
break;
|
||||
case FlowType::StripOverlapped:
|
||||
flow->setPreset(presetYACReaderFlowOverlappedStripeConfig);
|
||||
break;
|
||||
case FlowType::Modern:
|
||||
flow->setPreset(defaultYACReaderFlowConfig);
|
||||
break;
|
||||
case FlowType::Roulette:
|
||||
flow->setPreset(pressetYACReaderFlowDownConfig);
|
||||
break;
|
||||
case FlowType::Custom:
|
||||
flow->setCF_RX(settings->value(X_ROTATION).toInt());
|
||||
flow->setCF_Y(settings->value(Y_POSITION).toInt());
|
||||
flow->setX_Distance(settings->value(COVER_DISTANCE).toInt());
|
||||
flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt());
|
||||
flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt());
|
||||
flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt());
|
||||
flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt());
|
||||
flow->setRotation(settings->value(COVER_ROTATION).toInt());
|
||||
flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt());
|
||||
flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt());
|
||||
flow->setMaxAngle(settings->value(MAX_ANGLE).toInt());
|
||||
break;
|
||||
}
|
||||
if (Configuration::getConfiguration().getQuickNaviMode())
|
||||
flow->setFadeOutDist(20);
|
||||
}
|
||||
|
||||
void GoToFlowWidget::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
||||
void GoToFlowWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Up:
|
||||
QApplication::sendEvent(flow, event);
|
||||
return;
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
toolBar->goTo();
|
||||
@ -48,31 +183,10 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void GoToFlowWidget::updateConfig(QSettings *settings)
|
||||
void GoToFlowWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
toolBar->updateOptions();
|
||||
}
|
||||
QWidget::resizeEvent(event);
|
||||
|
||||
void GoToFlowWidget::updateSize()
|
||||
{
|
||||
// called by parent in resizeEvent
|
||||
// no need to update width when QuickNaviMode disabled
|
||||
// height is set in updateConfig
|
||||
if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr)
|
||||
resize(parentWidget()->width(), height());
|
||||
toolBar->move(0, event->size().height() - toolBar->height());
|
||||
toolBar->setFixedWidth(width());
|
||||
}
|
||||
|
||||
/*bool GoToFlowWidget::eventFilter(QObject * target, QEvent * event)
|
||||
{
|
||||
if(event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent * e = static_cast<QKeyEvent *>(event);
|
||||
if(e->key()==Qt::Key_S || e->key() == Qt::Key_Space)
|
||||
{
|
||||
this->keyPressEvent(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
}*/
|
||||
|
||||
@ -3,40 +3,48 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSettings>
|
||||
#include "yacreader_global.h"
|
||||
#include "yacreader_global_gui.h"
|
||||
|
||||
#include "yacreader_page_flow_rhi.h"
|
||||
|
||||
using namespace YACReader;
|
||||
|
||||
class QSettings;
|
||||
class GoToFlowToolBar;
|
||||
class QVBoxLayout;
|
||||
class QKeyEvent;
|
||||
|
||||
class GoToFlowWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QVBoxLayout *mainLayout;
|
||||
GoToFlowToolBar *toolBar;
|
||||
|
||||
public:
|
||||
GoToFlowWidget(QWidget *paret = nullptr);
|
||||
~GoToFlowWidget() override = 0;
|
||||
GoToFlowWidget(QWidget *parent = nullptr, FlowType flowType = CoverFlowLike);
|
||||
~GoToFlowWidget() override;
|
||||
|
||||
public slots:
|
||||
virtual void reset() = 0;
|
||||
virtual void centerSlide(int slide) = 0;
|
||||
virtual void setPageNumber(int page);
|
||||
virtual void setFlowType(YACReader::FlowType flowType) = 0;
|
||||
virtual void setNumSlides(unsigned int slides) = 0;
|
||||
virtual void setImageReady(int index, const QByteArray &image) = 0;
|
||||
virtual void updateSize();
|
||||
virtual void updateConfig(QSettings *settings);
|
||||
virtual void setFlowRightToLeft(bool b) = 0;
|
||||
void reset();
|
||||
void centerSlide(int slide);
|
||||
void setPageNumber(int page);
|
||||
void setFlowType(FlowType flowType);
|
||||
void setNumSlides(unsigned int slides);
|
||||
void setImageReady(int index, const QByteArray &image);
|
||||
void updateSize();
|
||||
void updateConfig(QSettings *settings);
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
signals:
|
||||
void goToPage(unsigned int);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
// bool eventFilter(QObject *, QEvent *);
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
QVBoxLayout *mainLayout;
|
||||
GoToFlowToolBar *toolBar;
|
||||
YACReaderPageFlow3D *flow;
|
||||
QSize imageSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -3,17 +3,11 @@
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "configuration.h"
|
||||
#include "goto_flow_widget.h"
|
||||
#include "magnifying_glass.h"
|
||||
#include "render.h"
|
||||
#include "viewer.h"
|
||||
|
||||
#include "goto_flow.h"
|
||||
#ifndef NO_OPENGL
|
||||
#include "goto_flow_gl.h"
|
||||
#else
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
|
||||
using namespace YACReader;
|
||||
|
||||
YACReader::MouseHandler::MouseHandler(Viewer *viewer)
|
||||
|
||||
@ -14,10 +14,7 @@
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "yacreader_spin_slider_widget.h"
|
||||
#include "yacreader_flow_config_widget.h"
|
||||
#ifndef NO_OPENGL
|
||||
#include "yacreader_gl_flow_config_widget.h"
|
||||
#endif
|
||||
#include "yacreader_3d_flow_config_widget.h"
|
||||
|
||||
OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
: YACReaderOptionsDialog(parent)
|
||||
@ -120,19 +117,13 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
quickNavi = new QCheckBox(tr("Quick Navigation Mode"));
|
||||
disableShowOnMouseOver = new QCheckBox(tr("Disable mouse over activation"));
|
||||
|
||||
layoutFlow->addWidget(sw);
|
||||
#ifndef NO_OPENGL
|
||||
layoutFlow->addWidget(gl);
|
||||
layoutFlow->addWidget(useGL);
|
||||
#endif
|
||||
|
||||
layoutFlow->addWidget(quickNavi);
|
||||
layoutFlow->addWidget(disableShowOnMouseOver);
|
||||
layoutFlow->addStretch();
|
||||
|
||||
// disable vSyncCheck
|
||||
#ifndef NO_OPENGL
|
||||
gl->vSyncCheck->hide();
|
||||
#endif
|
||||
|
||||
// PAGE FLOW END -------------------------------------
|
||||
|
||||
@ -249,13 +240,6 @@ void OptionsDialog::saveOptions()
|
||||
{
|
||||
settings->setValue(GO_TO_FLOW_SIZE, QSize(static_cast<int>(slideSize->sliderPosition() / SLIDE_ASPECT_RATIO), slideSize->sliderPosition()));
|
||||
|
||||
if (sw->radio1->isChecked())
|
||||
settings->setValue(FLOW_TYPE_SW, 0);
|
||||
if (sw->radio2->isChecked())
|
||||
settings->setValue(FLOW_TYPE_SW, 1);
|
||||
if (sw->radio3->isChecked())
|
||||
settings->setValue(FLOW_TYPE_SW, 2);
|
||||
|
||||
settings->setValue(PATH, pathEdit->text());
|
||||
|
||||
Configuration::getConfiguration().setShowTimeInInformation(showTimeInInformationLabel->isChecked());
|
||||
@ -289,20 +273,6 @@ void OptionsDialog::restoreOptions(QSettings *settings)
|
||||
YACReaderOptionsDialog::restoreOptions(settings);
|
||||
|
||||
slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height());
|
||||
switch (settings->value(FLOW_TYPE_SW).toInt()) {
|
||||
case 0:
|
||||
sw->radio1->setChecked(true);
|
||||
break;
|
||||
case 1:
|
||||
sw->radio2->setChecked(true);
|
||||
break;
|
||||
case 2:
|
||||
sw->radio3->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
sw->radio1->setChecked(true);
|
||||
break;
|
||||
}
|
||||
|
||||
pathEdit->setText(settings->value(PATH).toString());
|
||||
|
||||
|
||||
@ -1,12 +1,7 @@
|
||||
#include "viewer.h"
|
||||
#include "configuration.h"
|
||||
#include "magnifying_glass.h"
|
||||
#include "goto_flow.h"
|
||||
#ifndef NO_OPENGL
|
||||
#include "goto_flow_gl.h"
|
||||
#else
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
#include "goto_flow_widget.h"
|
||||
#include "bookmarks_dialog.h"
|
||||
#include "render.h"
|
||||
#include "goto_dialog.h"
|
||||
@ -16,8 +11,6 @@
|
||||
#include "comic_db.h"
|
||||
#include "shortcuts_manager.h"
|
||||
|
||||
#include "opengl_checker.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QKeyEvent>
|
||||
|
||||
@ -81,34 +74,9 @@ Viewer::Viewer(QWidget *parent)
|
||||
|
||||
goToDialog = new GoToDialog(this);
|
||||
|
||||
QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReader.ini", QSettings::IniFormat);
|
||||
|
||||
// CONFIG GOTO_FLOW--------------------------------------------------------
|
||||
#ifndef NO_OPENGL
|
||||
goToFlow = new GoToFlowWidget(this, Configuration::getConfiguration().getFlowType());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
// When using RHI, don't check OpenGL - assume hardware acceleration is available
|
||||
bool openGLAvailable = true;
|
||||
|
||||
if (!settings->contains(USE_OPEN_GL))
|
||||
settings->setValue(USE_OPEN_GL, 2);
|
||||
#else
|
||||
OpenGLChecker openGLChecker;
|
||||
bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
|
||||
|
||||
if (openGLAvailable && !settings->contains(USE_OPEN_GL))
|
||||
settings->setValue(USE_OPEN_GL, 2);
|
||||
else if (!openGLAvailable)
|
||||
settings->setValue(USE_OPEN_GL, 0);
|
||||
#endif
|
||||
|
||||
if ((settings->value(USE_OPEN_GL).toBool() == true))
|
||||
goToFlow = new GoToFlowGL(this, Configuration::getConfiguration().getFlowType());
|
||||
else
|
||||
goToFlow = new GoToFlow(this, Configuration::getConfiguration().getFlowType());
|
||||
#else
|
||||
goToFlow = new GoToFlow(this, Configuration::getConfiguration().getFlowType());
|
||||
#endif
|
||||
goToFlow->setFocusPolicy(Qt::StrongFocus);
|
||||
goToFlow->hide();
|
||||
showGoToFlowAnimation = new QPropertyAnimation(goToFlow, "pos");
|
||||
|
||||
Reference in New Issue
Block a user