mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Use continuous scroll mode automatically when a web comic is open
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Build / Publish YACReader10 Pre-release Builds (push) Has been cancelled
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Build / Publish YACReader10 Pre-release Builds (push) Has been cancelled
This commit is contained in:
@ -55,6 +55,68 @@ void MainWindowViewer::afterLaunchTasks()
|
|||||||
whatsNewController.showWhatsNewIfNeeded(this);
|
whatsNewController.showWhatsNewIfNeeded(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::applySavedReaderMode()
|
||||||
|
{
|
||||||
|
Configuration &config = Configuration::getConfiguration();
|
||||||
|
const bool manga = config.getDoubleMangaPage();
|
||||||
|
const bool continuousScroll = config.getContinuousScroll();
|
||||||
|
viewer->setMangaWithoutStoringSetting(manga);
|
||||||
|
viewer->setContinuousScrollWithoutStoringSetting(continuousScroll);
|
||||||
|
syncModeActions(manga, continuousScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::applyLibraryReaderMode(YACReader::FileType type)
|
||||||
|
{
|
||||||
|
Configuration &config = Configuration::getConfiguration();
|
||||||
|
bool manga = false;
|
||||||
|
bool continuousScroll = config.getContinuousScroll();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case YACReader::FileType::Manga:
|
||||||
|
manga = true;
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::WebComic:
|
||||||
|
continuousScroll = true;
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::Comic:
|
||||||
|
case YACReader::FileType::WesternManga:
|
||||||
|
case YACReader::FileType::Yonkoma:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewer->setMangaWithoutStoringSetting(manga);
|
||||||
|
viewer->setContinuousScrollWithoutStoringSetting(continuousScroll);
|
||||||
|
syncModeActions(manga, continuousScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::syncModeActions(bool manga, bool continuousScroll)
|
||||||
|
{
|
||||||
|
doubleMangaPageAction->setChecked(manga);
|
||||||
|
|
||||||
|
if (continuousScroll) {
|
||||||
|
continuousScrollAction->setChecked(true);
|
||||||
|
} else {
|
||||||
|
switch (Configuration::getConfiguration().getFitMode()) {
|
||||||
|
case YACReader::FitMode::ToWidth:
|
||||||
|
adjustWidthAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FitMode::ToHeight:
|
||||||
|
adjustHeightAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FitMode::FullRes:
|
||||||
|
adjustToFullSizeAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FitMode::FullPage:
|
||||||
|
default:
|
||||||
|
fitToPageAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doubleMangaPageSwitch();
|
||||||
|
}
|
||||||
|
|
||||||
MainWindowViewer::~MainWindowViewer()
|
MainWindowViewer::~MainWindowViewer()
|
||||||
{
|
{
|
||||||
delete settings;
|
delete settings;
|
||||||
@ -810,12 +872,7 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList<ComicDB> &siblin
|
|||||||
else
|
else
|
||||||
setWindowTitle("YACReader - " + fi.fileName());
|
setWindowTitle("YACReader - " + fi.fileName());
|
||||||
|
|
||||||
auto type = comic.info.type.value<YACReader::FileType>();
|
applyLibraryReaderMode(comic.info.type.value<YACReader::FileType>());
|
||||||
// TODO: support comic.info.type by adjusting the scrolling and double page mode behaviour depending on the actual type, for now type is mapped to manga mode
|
|
||||||
auto isManga = type == YACReader::FileType::Manga;
|
|
||||||
|
|
||||||
viewer->setMangaWithoutStoringSetting(isManga);
|
|
||||||
doubleMangaPageAction->setChecked(isManga);
|
|
||||||
|
|
||||||
viewer->open(path, comic);
|
viewer->open(path, comic);
|
||||||
enableActions();
|
enableActions();
|
||||||
@ -855,7 +912,6 @@ void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, YACR
|
|||||||
|
|
||||||
void MainWindowViewer::openComicFromPath(QString pathFile)
|
void MainWindowViewer::openComicFromPath(QString pathFile)
|
||||||
{
|
{
|
||||||
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
|
||||||
openComic(pathFile);
|
openComic(pathFile);
|
||||||
isClient = false; // this method is used for direct openings
|
isClient = false; // this method is used for direct openings
|
||||||
updatePrevNextActions(!previousComicPath.isEmpty(), !nextComicPath.isEmpty());
|
updatePrevNextActions(!previousComicPath.isEmpty(), !nextComicPath.isEmpty());
|
||||||
@ -876,6 +932,7 @@ void MainWindowViewer::openComic(QString pathFile)
|
|||||||
setWindowTitle("YACReader - " + fi.fileName());
|
setWindowTitle("YACReader - " + fi.fileName());
|
||||||
|
|
||||||
enableActions();
|
enableActions();
|
||||||
|
applySavedReaderMode();
|
||||||
|
|
||||||
viewer->open(pathFile);
|
viewer->open(pathFile);
|
||||||
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
||||||
@ -901,6 +958,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir)
|
|||||||
setWindowTitle("YACReader - " + fi.fileName());
|
setWindowTitle("YACReader - " + fi.fileName());
|
||||||
|
|
||||||
enableActions();
|
enableActions();
|
||||||
|
applySavedReaderMode();
|
||||||
|
|
||||||
viewer->open(pathDir);
|
viewer->open(pathDir);
|
||||||
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
||||||
@ -916,6 +974,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName)
|
|||||||
setWindowTitle("YACReader - " + fi.fileName());
|
setWindowTitle("YACReader - " + fi.fileName());
|
||||||
|
|
||||||
enableActions();
|
enableActions();
|
||||||
|
applySavedReaderMode();
|
||||||
|
|
||||||
QDir d(pathDir);
|
QDir d(pathDir);
|
||||||
d.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
d.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
|
|||||||
@ -174,6 +174,9 @@ private:
|
|||||||
void setActionsEnabled(bool enabled);
|
void setActionsEnabled(bool enabled);
|
||||||
void setMglassActionsEnabled(bool enabled);
|
void setMglassActionsEnabled(bool enabled);
|
||||||
void setLoadedComicActionsEnabled(bool enabled);
|
void setLoadedComicActionsEnabled(bool enabled);
|
||||||
|
void syncModeActions(bool manga, bool continuousScroll);
|
||||||
|
void applySavedReaderMode();
|
||||||
|
void applyLibraryReaderMode(YACReader::FileType type);
|
||||||
|
|
||||||
//! Manejadores de evento:
|
//! Manejadores de evento:
|
||||||
// void resizeEvent(QResizeEvent * event);
|
// void resizeEvent(QResizeEvent * event);
|
||||||
|
|||||||
@ -111,10 +111,10 @@ Viewer::Viewer(QWidget *parent)
|
|||||||
doublePageSwitch();
|
doublePageSwitch();
|
||||||
|
|
||||||
if (Configuration::getConfiguration().getDoubleMangaPage())
|
if (Configuration::getConfiguration().getDoubleMangaPage())
|
||||||
doubleMangaPageSwitch();
|
setMangaModeImpl(true, false);
|
||||||
|
|
||||||
if (Configuration::getConfiguration().getContinuousScroll())
|
if (Configuration::getConfiguration().getContinuousScroll())
|
||||||
setContinuousScroll(true);
|
setContinuousScrollImpl(true, false);
|
||||||
|
|
||||||
createConnections();
|
createConnections();
|
||||||
|
|
||||||
@ -1188,41 +1188,49 @@ void Viewer::doublePageSwitch()
|
|||||||
Configuration::getConfiguration().setDoublePage(doublePage);
|
Configuration::getConfiguration().setDoublePage(doublePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::setContinuousScroll(bool enabled)
|
void Viewer::setContinuousScrollImpl(bool enabled, bool persistSettings)
|
||||||
{
|
{
|
||||||
if (continuousScroll == enabled) {
|
if (continuousScroll == enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
continuousScroll = enabled;
|
continuousScroll = enabled;
|
||||||
|
if (persistSettings) {
|
||||||
Configuration::getConfiguration().setContinuousScroll(continuousScroll);
|
Configuration::getConfiguration().setContinuousScroll(continuousScroll);
|
||||||
|
}
|
||||||
|
|
||||||
if (continuousScroll) {
|
if (continuousScroll) {
|
||||||
continuousViewModel->setZoomFactor(zoom);
|
continuousViewModel->setZoomFactor(zoom);
|
||||||
if (render->hasLoadedComic()) {
|
if (render->hasLoadedComic()) {
|
||||||
continuousViewModel->setViewportSize(viewport()->width(), viewport()->height());
|
continuousViewModel->setViewportSize(viewport()->width(), viewport()->height());
|
||||||
continuousViewModel->setNumPages(render->numPages());
|
continuousViewModel->setNumPages(render->numPages());
|
||||||
// set the current page as model state before any layout/scroll happens
|
|
||||||
lastCenterPage = render->getIndex();
|
lastCenterPage = render->getIndex();
|
||||||
continuousViewModel->setAnchorPage(lastCenterPage);
|
continuousViewModel->setAnchorPage(lastCenterPage);
|
||||||
// pick up sizes of pages already in the buffer
|
|
||||||
probeContinuousBufferedPages();
|
probeContinuousBufferedPages();
|
||||||
// trigger a render cycle so new pages arrive via pageRendered signal
|
|
||||||
render->update();
|
render->update();
|
||||||
setActiveWidget(continuousWidget);
|
setActiveWidget(continuousWidget);
|
||||||
scrollToCurrentContinuousPage();
|
scrollToCurrentContinuousPage();
|
||||||
continuousWidget->update();
|
continuousWidget->update();
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
// if no comic is loaded, messageLabel stays as the active widget
|
|
||||||
} else {
|
} else {
|
||||||
lastCenterPage = -1;
|
lastCenterPage = -1;
|
||||||
if (render->hasLoadedComic()) {
|
if (render->hasLoadedComic()) {
|
||||||
updatePage();
|
updatePage();
|
||||||
}
|
}
|
||||||
// if no comic is loaded, messageLabel stays as the active widget
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewer::setContinuousScrollWithoutStoringSetting(bool enabled)
|
||||||
|
{
|
||||||
|
setContinuousScrollImpl(enabled, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::setContinuousScroll(bool enabled)
|
||||||
|
{
|
||||||
|
setContinuousScrollImpl(enabled, true);
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::onContinuousScroll(int value)
|
void Viewer::onContinuousScroll(int value)
|
||||||
{
|
{
|
||||||
if (!continuousScroll || !render->hasLoadedComic() || applyingContinuousModelState) {
|
if (!continuousScroll || !render->hasLoadedComic() || applyingContinuousModelState) {
|
||||||
@ -1345,21 +1353,32 @@ void Viewer::onRenderPageChanged(int page)
|
|||||||
scrollToCurrentContinuousPage();
|
scrollToCurrentContinuousPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::setMangaWithoutStoringSetting(bool manga)
|
void Viewer::setMangaModeImpl(bool manga, bool persistSettings)
|
||||||
{
|
{
|
||||||
|
if (doubleMangaPage == manga) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
doubleMangaPage = manga;
|
doubleMangaPage = manga;
|
||||||
|
|
||||||
|
if (persistSettings) {
|
||||||
|
Configuration &config = Configuration::getConfiguration();
|
||||||
|
config.setDoubleMangaPage(doubleMangaPage);
|
||||||
|
goToFlow->updateConfig(config.getSettings());
|
||||||
|
}
|
||||||
|
|
||||||
render->setManga(manga);
|
render->setManga(manga);
|
||||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewer::setMangaWithoutStoringSetting(bool manga)
|
||||||
|
{
|
||||||
|
setMangaModeImpl(manga, false);
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::doubleMangaPageSwitch()
|
void Viewer::doubleMangaPageSwitch()
|
||||||
{
|
{
|
||||||
doubleMangaPage = !doubleMangaPage;
|
setMangaModeImpl(!doubleMangaPage, true);
|
||||||
render->doubleMangaPageSwitch();
|
|
||||||
Configuration &config = Configuration::getConfiguration();
|
|
||||||
config.setDoubleMangaPage(doubleMangaPage);
|
|
||||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
|
||||||
goToFlow->updateConfig(config.getSettings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::resetContent()
|
void Viewer::resetContent()
|
||||||
|
|||||||
@ -86,6 +86,7 @@ public slots:
|
|||||||
void save();
|
void save();
|
||||||
void doublePageSwitch();
|
void doublePageSwitch();
|
||||||
void setMangaWithoutStoringSetting(bool manga);
|
void setMangaWithoutStoringSetting(bool manga);
|
||||||
|
void setContinuousScrollWithoutStoringSetting(bool enabled);
|
||||||
void doubleMangaPageSwitch();
|
void doubleMangaPageSwitch();
|
||||||
void resetContent();
|
void resetContent();
|
||||||
void setLoadingMessage();
|
void setLoadingMessage();
|
||||||
@ -202,6 +203,8 @@ private:
|
|||||||
void onNumPagesReady(unsigned int numPages);
|
void onNumPagesReady(unsigned int numPages);
|
||||||
void onRenderPageChanged(int page);
|
void onRenderPageChanged(int page);
|
||||||
void setActiveWidget(QWidget *w);
|
void setActiveWidget(QWidget *w);
|
||||||
|
void setContinuousScrollImpl(bool enabled, bool persistSettings);
|
||||||
|
void setMangaModeImpl(bool manga, bool persistSettings);
|
||||||
|
|
||||||
//! Mouse handler
|
//! Mouse handler
|
||||||
std::unique_ptr<YACReader::MouseHandler> mouseHandler;
|
std::unique_ptr<YACReader::MouseHandler> mouseHandler;
|
||||||
|
|||||||
Reference in New Issue
Block a user