Skip to content

Commit

Permalink
4 bugfixed
Browse files Browse the repository at this point in the history
- bugfixed: Opening the volume again after reading over 10 pages resulted in an unauthorized termination
- bugfixed: Keyboard input did not work if FolderWindow is displayed in the main window
- bugfixed: The image was not loaded even if switching the volume with the keyboard in FolderWindow
- bugfixed: After switching to another Volume with SpreadViewing, and go back to original Volume, it goes one page
- changed: for including some Qt common headers
  • Loading branch information
kanryu committed Jun 15, 2017
1 parent 8e1b3ea commit c477d7f
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 23 deletions.
8 changes: 5 additions & 3 deletions QuickViewer/QuickViewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ QT += core gui opengl concurrent opengl-private sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

VERSION = 0.7.4
VERSION = 0.7.5

TARGET = QuickViewer
TEMPLATE = app
Expand Down Expand Up @@ -112,7 +112,8 @@ SOURCES += \
src/folderview/folderwindow.cpp \
src/models/pagecontent.cpp \
src/folderview/folderitemdelegate.cpp \
src/models/bookprogressmanager.cpp
src/models/bookprogressmanager.cpp \
src/folderview/foldertreeview.cpp

HEADERS += \
src/qv_init.h \
Expand All @@ -139,7 +140,8 @@ HEADERS += \
src/folderview/folderwindow.h \
src/models/pagecontent.h \
src/folderview/folderitemdelegate.h \
src/models/bookprogressmanager.h
src/models/bookprogressmanager.h \
src/folderview/foldertreeview.h

win32 {
SOURCES += src/mainwindowforwindows.cpp
Expand Down
14 changes: 14 additions & 0 deletions QuickViewer/src/folderview/foldertreeview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "foldertreeview.h"

FolderTreeView::FolderTreeView(QWidget *parent)
: QTreeView(parent)
{

}

void FolderTreeView::selectionChanged(const QItemSelection &selection, const QItemSelection &)
{
auto list = selection.indexes();
if(list.size() > 0)
emit selected(list.first());
}
19 changes: 19 additions & 0 deletions QuickViewer/src/folderview/foldertreeview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef FOLDERTREEVIEW_H
#define FOLDERTREEVIEW_H

#include <QtWidgets>

class FolderTreeView : public QTreeView
{
Q_OBJECT
public:
FolderTreeView(QWidget* parent);

signals:
void selected(const QModelIndex & index);

protected:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
};

#endif // FOLDERTREEVIEW_H
40 changes: 40 additions & 0 deletions QuickViewer/src/folderview/folderwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,41 @@ QString FolderWindow::itemPath(const QModelIndex &index)
return dir.absoluteFilePath(filename);
}

const static QKeySequence seqReturn("Return");
const static QKeySequence seqEnter("Num+Enter");
const static QKeySequence seqBackspace("Backspace");

void FolderWindow::keyPressEvent(QKeyEvent *event)
{
QKeySequence seq(event->key() | event->modifiers());
qDebug() << seq;
if(seq == seqReturn || seq == seqEnter) {
on_currentItem_triggered();
return;
}
if(seq == seqBackspace) {
if(m_historyPrev.empty())
on_parent_triggered();
else
on_prev_triggered();
return;
}
}

void FolderWindow::mousePressEvent(QMouseEvent *event)
{
// 5 buttons mouse forward for browsers
if(event->button() == Qt::ForwardButton) {
on_next_triggered();
return;
}
// 5 buttons mouse back for browsers
if(event->button() == Qt::BackButton) {
on_prev_triggered();
return;
}
}

void FolderWindow::on_home_triggered()
{
if(m_historyPrev.contains(m_currentPath))
Expand Down Expand Up @@ -333,6 +368,11 @@ void FolderWindow::on_itemDoubleClicked(const QModelIndex &index)
setFolderPath(subpath, false);
}

void FolderWindow::on_currentItem_triggered()
{
on_itemDoubleClicked(ui->folderView->currentIndex());
}

void FolderWindow::on_sortMode_triggered()
{
QWidget* widget = ui->sortModeButton;
Expand Down
3 changes: 3 additions & 0 deletions QuickViewer/src/folderview/folderwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class FolderWindow : public QWidget
void resetPathLabel(int maxWidth);
QString currentPath() { return m_currentPath; }
QString itemPath(const QModelIndex& index);
void keyPressEvent(QKeyEvent *event);
void mousePressEvent(QMouseEvent *event);

public slots:
void on_home_triggered();
Expand All @@ -40,6 +42,7 @@ public slots:
void on_volumeChanged_triggered(QString);
void on_itemSingleClicked(const QModelIndex & index);
void on_itemDoubleClicked(const QModelIndex & index);
void on_currentItem_triggered();
void on_setHome_triggered();
void on_sortMode_triggered();
void on_orderByName_triggered();
Expand Down
15 changes: 13 additions & 2 deletions QuickViewer/src/folderview/folderwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ QPushButton:hover {
</widget>
</item>
<item>
<widget class="QTreeView" name="folderView">
<widget class="FolderTreeView" name="folderView">
<property name="focusPolicy">
<enum>Qt::WheelFocus</enum>
</property>
Expand Down Expand Up @@ -398,6 +398,16 @@ QPushButton:hover {
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>FolderTreeView</class>
<extends>QTreeView</extends>
<header location="global">foldertreeview.h</header>
<slots>
<signal>selected(QModelIndex)</signal>
</slots>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>homeButton</tabstop>
<tabstop>prevButton</tabstop>
Expand All @@ -412,7 +422,7 @@ QPushButton:hover {
<connections>
<connection>
<sender>folderView</sender>
<signal>clicked(QModelIndex)</signal>
<signal>selected(QModelIndex)</signal>
<receiver>FolderWindow</receiver>
<slot>on_itemSingleClicked(QModelIndex)</slot>
<hints>
Expand Down Expand Up @@ -600,5 +610,6 @@ QPushButton:hover {
<slot>on_orderByName_triggered()</slot>
<slot>on_orderByUpdatedAt_triggered()</slot>
<slot>on_setHome_triggered()</slot>
<slot>on_currentItem_triggered()</slot>
</slots>
</ui>
21 changes: 18 additions & 3 deletions QuickViewer/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,18 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
QKeySequence seq(event->key() | event->modifiers());
qDebug() << seq;

// if the focus is on searchbar on CatalogWindow
if(isCatalogSearching() && (seq == seqReturn || seq == seqEnter)) {
if(this->focusWidget() != ui->graphicsView)
return;
}
// // if the focus is on searchbar on CatalogWindow
// if(seq == seqReturn || seq == seqEnter) {
// if(isCatalogSearching()) {
// return;
// }
// if(isFolderSearching()) {
// m_folderWindow->on_currentItem_triggered();
// return;
// }
// }
QAction* action = qApp->getAction(seq);
if(action)
action->trigger();
Expand Down Expand Up @@ -680,6 +688,13 @@ bool MainWindow::isCatalogSearching()
return m_catalogWindow->isCatalogSearching();
}

bool MainWindow::isFolderSearching()
{
if(!m_folderWindow || !m_folderWindow->parent())
return false;
return true;
}

void MainWindow::on_openVolumeByCatalog_triggered(QString path)
{
loadVolume(path);
Expand Down
1 change: 1 addition & 0 deletions QuickViewer/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MainWindow : public QMainWindow
void setThumbnailManager(ThumbnailManager* manager);
void loadVolume(QString path);
bool isCatalogSearching();
bool isFolderSearching();

protected:
void dragEnterEvent(QDragEnterEvent *e);
Expand Down
19 changes: 18 additions & 1 deletion QuickViewer/src/models/filevolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,28 @@ bool IFileVolume::findPageByIndex(int idx)
return true;
}

bool IFileVolume::findImageByIndex(int idx) {
if(idx < 0 || idx >= m_filelist.size())
return false;
m_cnt = idx;
on_ready();
return true;
}

bool IFileVolume::findImageByName(QString name) {
int idx = m_filelist.indexOf(name);
if(idx < 0)
return false;
m_cnt = idx;
on_ready();
return true;
}

static IFileVolume* CreateVolumeImpl(QObject* parent, QString path, PageManager* pageManager)
{
QDir dir(path);

// if(dir.exists() && dir.entryList(QDir::Files, QDir::Name).size() > 0) {
// if(dir.exists() && dir.entryList(QDir::Files, QDir::Name).size() > 0) {
if(dir.exists()) {
return new IFileVolume(parent, qApp->ShowSubfolders() ? new FileLoaderSubDirectory(parent, path) : new FileLoaderDirectory(parent, path), pageManager);
}
Expand Down
15 changes: 2 additions & 13 deletions QuickViewer/src/models/filevolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,12 @@ class IFileVolume : public QObject
/**
* @brief Move to the file corresponding to the idx value specified in the file list(Max is size()-1)
*/
bool findImageByIndex(int idx) {
if(idx < 0 || idx >= m_filelist.size())
return false;
m_cnt = idx;
return true;
}
bool findImageByIndex(int idx);

/**
* @brief Move to the file corresponding to the file name specified in the current file list
*/
bool findImageByName(QString name) {
int idx = m_filelist.indexOf(name);
if(idx < 0)
return false;
m_cnt = idx;
return true;
}
bool findImageByName(QString name);

/**
* @brief loadImageByName Reads and returns the image corresponding to the file name specified in the file list without advancing the internal counter
Expand Down
8 changes: 7 additions & 1 deletion QuickViewer/src/models/pagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ PageManager::PageManager(QObject* parent)

bool PageManager::loadVolume(QString path, bool coverOnly)
{
if(m_fileVolume && m_pages.size() == 2) {
m_fileVolume->prevPage();
}
clearPages();
m_fileVolume = nullptr;
IFileVolume* newer = addVolumeCache(path, coverOnly);
Expand Down Expand Up @@ -133,7 +136,7 @@ IFileVolume* PageManager::addVolumeCache(QString path, bool onlyCover)
if(qApp->OpenVolumeWithProgress()
&& qApp->bookshelfManager()->contains(volumepath)) {
BookProgress book = qApp->bookshelfManager()->at(volumepath);
newer->findImageByName(book.CurrenPage);
newer->findPageByIndex(book.Current);
}
}
} else {
Expand Down Expand Up @@ -180,6 +183,9 @@ void PageManager::prevPage()
}
if(m_currentPage < 0)
m_currentPage = 0;

bookProgress();

selectPage(m_currentPage);
}

Expand Down
1 change: 1 addition & 0 deletions QuickViewer/src/models/qvapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QtGui>
#include <QtCore>
#include <QtWidgets>

#include "qv_init.h"
#include "bookprogressmanager.h"
Expand Down

0 comments on commit c477d7f

Please sign in to comment.