Skip to content

Commit

Permalink
add Next page or volume
Browse files Browse the repository at this point in the history
add Prev page or volume
  • Loading branch information
kanryu committed Jan 15, 2018
1 parent d3adbb2 commit 74286a8
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 145 deletions.
32 changes: 32 additions & 0 deletions QuickViewer/src/imageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,38 @@ void ImageView::on_prevPage_triggered()
m_pageBacking = false;
}

void ImageView::onActionNextPageOrVolume_triggered()
{
if(qApp->SeparatePagesWhenWideImage() && m_pages[0].Separation == PageContent::FirstSeparated) {
m_pages[0].Separation = PageContent::SecondSeparated;
readyForPaint();
return;
}
if(m_pageManager)
if(!m_pageManager->nextPage()) {
m_pageManager->nextVolume();
m_pageManager->firstPage();
}
if(isSlideShow())
toggleSlideShow();
}

void ImageView::onActionPrevPageOrVolume_triggered()
{
if(qApp->SeparatePagesWhenWideImage() && m_pages[0].Separation == PageContent::SecondSeparated) {
m_pages[0].Separation = PageContent::FirstSeparated;
readyForPaint();
return;
}
if(m_pageManager)
if(!m_pageManager->prevPage()) {
m_pageManager->prevVolume();
m_pageManager->lastPage();
}
if(isSlideShow())
toggleSlideShow();
}

void ImageView::on_fastForwardPage_triggered()
{
if(m_pageManager)
Expand Down
2 changes: 2 additions & 0 deletions QuickViewer/src/imageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public slots:
// Navigation
void on_nextPage_triggered();
void on_prevPage_triggered();
void onActionNextPageOrVolume_triggered();
void onActionPrevPageOrVolume_triggered();
void on_fastForwardPage_triggered();
void on_fastBackwardPage_triggered();
void on_firstPage_triggered();
Expand Down
60 changes: 49 additions & 11 deletions QuickViewer/src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@
<addaction name="actionPrevVolume"/>
<addaction name="actionNextVolume"/>
<addaction name="separator"/>
<addaction name="actionSlideShow"/>
<addaction name="separator"/>
<addaction name="actionShowFolder"/>
<addaction name="actionShowCatalog"/>
<addaction name="actionShowRetouchWindow"/>
Expand Down Expand Up @@ -338,6 +336,9 @@
<addaction name="actionPrevVolume"/>
<addaction name="separator"/>
<addaction name="actionSlideShow"/>
<addaction name="separator"/>
<addaction name="actionNextPageOrVolume"/>
<addaction name="actionPrevPageOrVolume"/>
</widget>
<widget class="QMenu" name="menuShader">
<property name="title">
Expand All @@ -364,14 +365,14 @@
</property>
<addaction name="actionShaderBilinear"/>
<addaction name="separator"/>
<addaction name="actionShaderBicubic"/>
<addaction name="actionShaderCpuBicubic"/>
<addaction name="actionShaderCpuLanczos4"/>
<addaction name="separator"/>
<addaction name="actionShaderCpuLanczos3"/>
<addaction name="actionShaderNearestNeighbor"/>
<addaction name="actionShaderLanczos"/>
<addaction name="actionShaderBilinearBeforeCpuBicubic"/>
<addaction name="actionShaderCpuBicubic"/>
<addaction name="actionShaderBicubic"/>
</widget>
<widget class="QMenu" name="menuEdit_the_image">
<property name="title">
Expand All @@ -392,26 +393,19 @@
<addaction name="actionFitToWidth"/>
<addaction name="actionFitToWindow"/>
</widget>
<widget class="QMenu" name="menu">
<property name="title">
<string>ここに入力</string>
</property>
</widget>
<addaction name="actionNextOnePage"/>
<addaction name="actionPrevOnePage"/>
<addaction name="separator"/>
<addaction name="menu_Shader"/>
<addaction name="menuFit_mode"/>
<addaction name="menuEdit_the_image"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionScrollWithCursorWhenZooming"/>
<addaction name="separator"/>
<addaction name="actionDualView"/>
<addaction name="actionWideImageAsOneView"/>
<addaction name="actionFirstImageAsOneView"/>
<addaction name="separator"/>
<addaction name="menu"/>
</widget>
<widget class="QMenu" name="menu_Catalog">
<property name="title">
Expand Down Expand Up @@ -1223,6 +1217,16 @@
<string extracomment="Menu that performs Lanczos4 interpolation with CPU when resizing image">Lanczos4 interpolation by CPU</string>
</property>
</action>
<action name="actionNextPageOrVolume">
<property name="text">
<string extracomment="Switch to next image, or to next volume if the page is first button">Next page or volume</string>
</property>
</action>
<action name="actionPrevPageOrVolume">
<property name="text">
<string extracomment="Switch to previous image, or to previous volume if the page is last button">Prev page or volume</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down Expand Up @@ -1263,6 +1267,8 @@
<slot>onActionShowFullscreenSignage_triggered(bool)</slot>
<slot>on_fitToWidth_triggered(bool)</slot>
<slot>on_fitToWindow_triggered(bool)</slot>
<slot>onActionNextPageOrVolume_triggered()</slot>
<slot>onActionPrevPageOrVolume_triggered()</slot>
</slots>
</customwidget>
<customwidget>
Expand Down Expand Up @@ -2731,6 +2737,38 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionPrevPageOrVolume</sender>
<signal>triggered()</signal>
<receiver>graphicsView</receiver>
<slot>onActionPrevPageOrVolume_triggered()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>392</x>
<y>293</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionNextPageOrVolume</sender>
<signal>triggered()</signal>
<receiver>graphicsView</receiver>
<slot>onActionNextPageOrVolume_triggered()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>392</x>
<y>293</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>on_nextPage_triggered()</slot>
Expand Down
14 changes: 8 additions & 6 deletions QuickViewer/src/models/pagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,16 @@ VolumeManager* PageManager::addVolumeCache(QString path, bool onlyCover, bool im
return newer;
}

void PageManager::nextPage()
bool PageManager::nextPage()
{
//qDebug() << "ImageView::nextPage()" << m_currentPage;
if(m_fileVolume == nullptr
|| !m_fileVolume->enumerated()
|| m_fileVolume->pageCount() >= m_fileVolume->size()-1) return;
|| m_fileVolume->pageCount() >= m_fileVolume->size()-1) return false;

m_fileVolume->setCacheMode(VolumeManager::NormalForward);
bool result = m_fileVolume->nextPage();
if(!result) return;
if(!result) return false;

int pageIncr = m_pages.size();
m_currentPage += pageIncr;
Expand All @@ -249,17 +249,18 @@ void PageManager::nextPage()
reloadCurrentPage();
bookProgress();
emit pageChanged();
return true;
}

void PageManager::prevPage()
bool PageManager::prevPage()
{
if(m_fileVolume == nullptr
|| !m_fileVolume->enumerated()
|| m_fileVolume->pageCount() < m_pages.size()) return;
|| m_fileVolume->pageCount() < m_pages.size()) return false;

m_fileVolume->setCacheMode(VolumeManager::NormalBackward);
bool result = m_fileVolume->prevPage();
if(!result) return;
if(!result) return false;
//QVApplication* app = qApp;
m_currentPage--;
if(qApp->DualView() && m_currentPage >= 1) {
Expand All @@ -274,6 +275,7 @@ void PageManager::prevPage()
bookProgress();

selectPage(m_currentPage, VolumeManager::NormalBackward);
return true;
}

#define PAGE_INTERVAL 10
Expand Down
4 changes: 2 additions & 2 deletions QuickViewer/src/models/pagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class PageManager : public QObject, public PageManagerProtocol
void reloadVolumeAfterRemoveImage();

// Pages
void nextPage();
void prevPage();
bool nextPage();
bool prevPage();
void fastForwardPage();
void fastBackwardPage();
void selectPage(int pageNum, VolumeManager::CacheMode cacheMode=VolumeManager::Normal);
Expand Down
2 changes: 2 additions & 0 deletions QuickViewer/src/models/qvapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ void QVApplication::registActions(Ui::MainWindow *ui)
groupName = tr("Bookmark", "Bookmark Action Group");
m_keyActions.registAction("actionNextPage", ui->actionNextPage, groupName);
m_keyActions.registAction("actionPrevPage", ui->actionPrevPage, groupName);
m_keyActions.registAction("actionNextPageOrVolume", ui->actionNextPageOrVolume, groupName);
m_keyActions.registAction("actionPrevPageOrVolume", ui->actionPrevPageOrVolume, groupName);
m_keyActions.registAction("actionTurnPageOnLeft", ui->actionTurnPageOnLeft, groupName);
m_keyActions.registAction("actionTurnPageOnRight", ui->actionTurnPageOnRight, groupName);
m_keyActions.registAction("actionFastForward", ui->actionFastForward, groupName);
Expand Down
4 changes: 2 additions & 2 deletions QuickViewer/src/models/volumemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static ImageContent loadWithSpecifiedFormat(QString path, QSize pageSize, QByteA
// CPU resizing before Page Viewing
if(!pageSize.isEmpty() && !ic.Image.isNull()) {
QSize newsize = ic.Info.Orientation==6 || ic.Info.Orientation==8 ? QSize(pageSize.height(), pageSize.width()) : pageSize;
ic.ResizeMode == qApp->Effect();
ic.ResizeMode = qApp->Effect();
ic.ResizedImage = QZimg::scaled(ic.Image, newsize, Qt::KeepAspectRatio, ShaderEffect2FilterMode(qApp->Effect()));
}
return ic;
Expand Down Expand Up @@ -435,7 +435,7 @@ ImageContent VolumeManager::futureReizeImage(ImageContent ic, QSize pageSize)
{
// qDebug() << "futureReizeImage:" << ic.Path;
QSize newsize = ic.Info.Orientation==6 || ic.Info.Orientation==8 ? QSize(pageSize.height(), pageSize.width()) : pageSize;
ic.ResizeMode == qApp->Effect();
ic.ResizeMode = qApp->Effect();
ic.ResizedImage = QZimg::scaled(ic.Image, newsize, Qt::KeepAspectRatio, ShaderEffect2FilterMode(qApp->Effect()));
return ic;
}
Expand Down
Loading

0 comments on commit 74286a8

Please sign in to comment.