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);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
delete settings;
|
||||
@ -810,12 +872,7 @@ void MainWindowViewer::open(QString path, ComicDB &comic, QList<ComicDB> &siblin
|
||||
else
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
auto type = 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);
|
||||
applyLibraryReaderMode(comic.info.type.value<YACReader::FileType>());
|
||||
|
||||
viewer->open(path, comic);
|
||||
enableActions();
|
||||
@ -855,7 +912,6 @@ void MainWindowViewer::open(QString path, qint64 comicId, qint64 libraryId, YACR
|
||||
|
||||
void MainWindowViewer::openComicFromPath(QString pathFile)
|
||||
{
|
||||
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
||||
openComic(pathFile);
|
||||
isClient = false; // this method is used for direct openings
|
||||
updatePrevNextActions(!previousComicPath.isEmpty(), !nextComicPath.isEmpty());
|
||||
@ -876,6 +932,7 @@ void MainWindowViewer::openComic(QString pathFile)
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
enableActions();
|
||||
applySavedReaderMode();
|
||||
|
||||
viewer->open(pathFile);
|
||||
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
||||
@ -901,6 +958,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir)
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
enableActions();
|
||||
applySavedReaderMode();
|
||||
|
||||
viewer->open(pathDir);
|
||||
Configuration::getConfiguration().updateOpenRecentList(fi.absoluteFilePath());
|
||||
@ -916,6 +974,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName)
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
enableActions();
|
||||
applySavedReaderMode();
|
||||
|
||||
QDir d(pathDir);
|
||||
d.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||
|
||||
@ -174,6 +174,9 @@ private:
|
||||
void setActionsEnabled(bool enabled);
|
||||
void setMglassActionsEnabled(bool enabled);
|
||||
void setLoadedComicActionsEnabled(bool enabled);
|
||||
void syncModeActions(bool manga, bool continuousScroll);
|
||||
void applySavedReaderMode();
|
||||
void applyLibraryReaderMode(YACReader::FileType type);
|
||||
|
||||
//! Manejadores de evento:
|
||||
// void resizeEvent(QResizeEvent * event);
|
||||
|
||||
@ -111,10 +111,10 @@ Viewer::Viewer(QWidget *parent)
|
||||
doublePageSwitch();
|
||||
|
||||
if (Configuration::getConfiguration().getDoubleMangaPage())
|
||||
doubleMangaPageSwitch();
|
||||
setMangaModeImpl(true, false);
|
||||
|
||||
if (Configuration::getConfiguration().getContinuousScroll())
|
||||
setContinuousScroll(true);
|
||||
setContinuousScrollImpl(true, false);
|
||||
|
||||
createConnections();
|
||||
|
||||
@ -1188,41 +1188,49 @@ void Viewer::doublePageSwitch()
|
||||
Configuration::getConfiguration().setDoublePage(doublePage);
|
||||
}
|
||||
|
||||
void Viewer::setContinuousScroll(bool enabled)
|
||||
void Viewer::setContinuousScrollImpl(bool enabled, bool persistSettings)
|
||||
{
|
||||
if (continuousScroll == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
continuousScroll = enabled;
|
||||
Configuration::getConfiguration().setContinuousScroll(continuousScroll);
|
||||
if (persistSettings) {
|
||||
Configuration::getConfiguration().setContinuousScroll(continuousScroll);
|
||||
}
|
||||
|
||||
if (continuousScroll) {
|
||||
continuousViewModel->setZoomFactor(zoom);
|
||||
if (render->hasLoadedComic()) {
|
||||
continuousViewModel->setViewportSize(viewport()->width(), viewport()->height());
|
||||
continuousViewModel->setNumPages(render->numPages());
|
||||
// set the current page as model state before any layout/scroll happens
|
||||
lastCenterPage = render->getIndex();
|
||||
continuousViewModel->setAnchorPage(lastCenterPage);
|
||||
// pick up sizes of pages already in the buffer
|
||||
probeContinuousBufferedPages();
|
||||
// trigger a render cycle so new pages arrive via pageRendered signal
|
||||
render->update();
|
||||
setActiveWidget(continuousWidget);
|
||||
scrollToCurrentContinuousPage();
|
||||
continuousWidget->update();
|
||||
viewport()->update();
|
||||
}
|
||||
// if no comic is loaded, messageLabel stays as the active widget
|
||||
} else {
|
||||
lastCenterPage = -1;
|
||||
if (render->hasLoadedComic()) {
|
||||
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)
|
||||
{
|
||||
if (!continuousScroll || !render->hasLoadedComic() || applyingContinuousModelState) {
|
||||
@ -1345,21 +1353,32 @@ void Viewer::onRenderPageChanged(int page)
|
||||
scrollToCurrentContinuousPage();
|
||||
}
|
||||
|
||||
void Viewer::setMangaWithoutStoringSetting(bool manga)
|
||||
void Viewer::setMangaModeImpl(bool manga, bool persistSettings)
|
||||
{
|
||||
if (doubleMangaPage == manga) {
|
||||
return;
|
||||
}
|
||||
|
||||
doubleMangaPage = manga;
|
||||
|
||||
if (persistSettings) {
|
||||
Configuration &config = Configuration::getConfiguration();
|
||||
config.setDoubleMangaPage(doubleMangaPage);
|
||||
goToFlow->updateConfig(config.getSettings());
|
||||
}
|
||||
|
||||
render->setManga(manga);
|
||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
||||
}
|
||||
|
||||
void Viewer::setMangaWithoutStoringSetting(bool manga)
|
||||
{
|
||||
setMangaModeImpl(manga, false);
|
||||
}
|
||||
|
||||
void Viewer::doubleMangaPageSwitch()
|
||||
{
|
||||
doubleMangaPage = !doubleMangaPage;
|
||||
render->doubleMangaPageSwitch();
|
||||
Configuration &config = Configuration::getConfiguration();
|
||||
config.setDoubleMangaPage(doubleMangaPage);
|
||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
||||
goToFlow->updateConfig(config.getSettings());
|
||||
setMangaModeImpl(!doubleMangaPage, true);
|
||||
}
|
||||
|
||||
void Viewer::resetContent()
|
||||
|
||||
@ -86,6 +86,7 @@ public slots:
|
||||
void save();
|
||||
void doublePageSwitch();
|
||||
void setMangaWithoutStoringSetting(bool manga);
|
||||
void setContinuousScrollWithoutStoringSetting(bool enabled);
|
||||
void doubleMangaPageSwitch();
|
||||
void resetContent();
|
||||
void setLoadingMessage();
|
||||
@ -202,6 +203,8 @@ private:
|
||||
void onNumPagesReady(unsigned int numPages);
|
||||
void onRenderPageChanged(int page);
|
||||
void setActiveWidget(QWidget *w);
|
||||
void setContinuousScrollImpl(bool enabled, bool persistSettings);
|
||||
void setMangaModeImpl(bool manga, bool persistSettings);
|
||||
|
||||
//! Mouse handler
|
||||
std::unique_ptr<YACReader::MouseHandler> mouseHandler;
|
||||
|
||||
Reference in New Issue
Block a user