Skip to content

Commit

Permalink
Add FolderWindow, CPU Interpolation
Browse files Browse the repository at this point in the history
- FolderWindow provides a simple view for folders/archives on current folder
- support CPU Interpolation, very high quality but shortly slow
  • Loading branch information
kanryu committed May 27, 2017
1 parent 41328f3 commit 26f0b31
Show file tree
Hide file tree
Showing 23 changed files with 953 additions and 158 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "easyexif/easyexif"]
path = easyexif/easyexif
url = https://github.com/mayanklahiri/easyexif
[submodule "zimg/zimg"]
path = zimg/zimg
url = https://github.com/sekrit-twc/zimg
3 changes: 2 additions & 1 deletion QVproject.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ SUBDIRS = \
easyexif \
unrar \
fileloader \
zimg \
QuickViewer \
# QuickCatalog

fileloader.depends = Qt7z/Qt7z/qt7z.pro unrar
QuickViewer.depends = ResizeHalf/resizehalf.pro easyexif fileloader
QuickViewer.depends = ResizeHalf/resizehalf.pro easyexif fileloader zimg



Expand Down
13 changes: 8 additions & 5 deletions QuickViewer/QuickViewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ QT += core gui opengl concurrent opengl-private sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

VERSION = 0.6.6
VERSION = 0.7.0

TARGET = QuickViewer
TEMPLATE = app
CONFIG += plugin

QMAKE_TARGET_COMPANY = KATO Kanryu(k.kanryu@gmail.com)
QMAKE_TARGET_PRODUCT = QuickViewer
QMAKE_TARGET_DESCRIPTION = A image viewer for folders/archives, it can show images very fast
QMAKE_TARGET_DESCRIPTION = QuickViewer for folders/archives
QMAKE_TARGET_COPYRIGHT = (C) 2017 KATO Kanryu

DEFINES += \
Expand Down Expand Up @@ -72,9 +72,10 @@ win32 { !CONFIG(debug, debug|release) {
INCLUDEPATH += ../ResizeHalf/ResizeHalf
INCLUDEPATH += ../easyexif/easyexif
INCLUDEPATH += ../fileloader
INCLUDEPATH += ../zimg
INCLUDEPATH += ./src ./src/catalog ./src/widgets ./src/models ./src/folderview

LIBS += -L../lib -leasyexif -lresizehalf -lfileloader -lQt7z -lunrar
LIBS += -L../lib -leasyexif -lresizehalf -lfileloader -lQt7z -lunrar -lzimg

win32 {
QMAKE_CXXFLAGS += /wd4819
Expand Down Expand Up @@ -106,7 +107,8 @@ SOURCES += \
src/widgets/pageslider.cpp \
src/widgets/shortcutbutton.cpp \
src/folderview/folderitemmodel.cpp \
src/folderview/folderwindow.cpp
src/folderview/folderwindow.cpp \
src/models/pagecontent.cpp

HEADERS += \
src/qv_init.h \
Expand All @@ -130,7 +132,8 @@ HEADERS += \
src/widgets/pageslider.h \
src/widgets/shortcutbutton.h \
src/folderview/folderitemmodel.h \
src/folderview/folderwindow.h
src/folderview/folderwindow.h \
src/models/pagecontent.h

win32 {
SOURCES += src/mainwindowforwindows.cpp
Expand Down
4 changes: 2 additions & 2 deletions QuickViewer/src/folderview/folderitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FolderItemModel::FolderItemModel(QObject *parent)

}

QVariant FolderItemModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant FolderItemModel::headerData(int section, Qt::Orientation , int role) const
{
switch(role) {
case Qt::DisplayRole:
Expand Down Expand Up @@ -71,7 +71,7 @@ int FolderItemModel::columnCount(const QModelIndex &) const
return m_columns;
}

QModelIndex FolderItemModel::index(int row, int column, const QModelIndex &parent) const
QModelIndex FolderItemModel::index(int row, int column, const QModelIndex &) const
{
// if(column > 1 || !m_searchedVolumes)
// return QModelIndex();
Expand Down
54 changes: 34 additions & 20 deletions QuickViewer/src/folderview/folderwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "models/filevolume.h"
#include "models/qvapplication.h"

FolderWindow::FolderWindow(QWidget *parent, Ui::MainWindow *uiMain)
FolderWindow::FolderWindow(QWidget *parent, Ui::MainWindow *)
: QWidget(parent)
, ui(new Ui::FolderWindow)
, m_itemModel(this)
Expand All @@ -19,8 +19,6 @@ FolderWindow::FolderWindow(QWidget *parent, Ui::MainWindow *uiMain)
ui->folderView->installEventFilter(this);

// folderView
// m_itemModel.setHeaderData(0, Qt::Horizontal, tr("Name"));
// m_itemModel.setHeaderData(1, Qt::Horizontal, tr("ModifiedTime"));
ui->folderView->setModel(&m_itemModel);

resetSortMode();
Expand Down Expand Up @@ -62,8 +60,8 @@ static QModelIndex selectedIdx;

bool FolderWindow::eventFilter(QObject *obj, QEvent *event)
{
qDebug() << obj << event << event->type();
QMouseEvent *mouseEvent = NULL;
// qDebug() << obj << event << event->type();
// QMouseEvent *mouseEvent = NULL;
QContextMenuEvent *contextEvent = nullptr;
switch (event->type()) {
case QEvent::ContextMenu:
Expand Down Expand Up @@ -114,9 +112,8 @@ void FolderWindow::dropEvent(QDropEvent *e)
void FolderWindow::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
QFontMetrics fontMetrics(ui->pathLabel->font());
QString pathLabelTxt = fontMetrics.elidedText(m_currentPath, Qt::ElideMiddle, event->size().width()-10);
ui->pathLabel->setText(pathLabelTxt);
resetPathLabel(event->size().width());

}

static bool filenameLessThan(const FolderItem& lhs, const FolderItem& rhs)
Expand All @@ -137,6 +134,8 @@ static bool updatedAtLessThan(const FolderItem& lhs, const FolderItem& rhs)

void FolderWindow::setFolderPath(QString path, bool showParent)
{
if(path.isEmpty())
path = qApp->HomeFolderPath();
QFileInfo fileinfo(path);
if(!fileinfo.exists())
return;
Expand All @@ -148,13 +147,8 @@ void FolderWindow::setFolderPath(QString path, bool showParent)
dir.setPath(QDir::toNativeSeparators(fileinfo.dir().path()));
}

// m_currentPath = fileinfo.isDir() ? path : fileinfo.canonicalPath();
m_currentPath = dir.path();

// Elide text(Otherwise the width of the main window will be forcibly changed)
QFontMetrics fontMetrics(ui->pathLabel->font());
QString pathLabelTxt = fontMetrics.elidedText(m_currentPath, Qt::ElideMiddle, width()-10);
ui->pathLabel->setText(pathLabelTxt);
resetPathLabel(width());

m_volumes.clear();
{
Expand Down Expand Up @@ -202,12 +196,22 @@ void FolderWindow::resetSortMode()
: ui->actionOrderByUpdatedAt->text());
}

void FolderWindow::resetPathLabel(int maxWidth)
{
QFontMetrics fontMetrics(ui->pathLabel->font());
QString pathLabelTxt = fontMetrics.elidedText(
QDir::toNativeSeparators(m_currentPath), Qt::ElideMiddle, maxWidth-10);
ui->pathLabel->setText(pathLabelTxt);
}


void FolderWindow::on_home_triggered()
{
if(m_historyNext.contains(m_currentPath))
m_historyNext.removeOne(m_currentPath);
m_historyNext << m_currentPath;
setFolderPath(qApp->HomeFolderPath(), false);
if(m_historyPrev.contains(m_currentPath))
m_historyPrev.removeOne(m_currentPath);
m_historyPrev << m_currentPath;
setFolderPath(qApp->HomeFolderPath());
emit openVolume(qApp->HomeFolderPath());
}

void FolderWindow::on_prev_triggered()
Expand All @@ -217,7 +221,10 @@ void FolderWindow::on_prev_triggered()
if(m_historyNext.contains(m_currentPath))
m_historyNext.removeOne(m_currentPath);
m_historyNext << m_currentPath;
setFolderPath(m_historyPrev.takeLast(), false);
QString path = m_historyPrev.takeLast();

setFolderPath(path, false);
emit openVolume(path);
}

void FolderWindow::on_next_triggered()
Expand All @@ -227,7 +234,9 @@ void FolderWindow::on_next_triggered()
if(m_historyPrev.contains(m_currentPath))
m_historyPrev.removeOne(m_currentPath);
m_historyPrev << m_currentPath;
setFolderPath(m_historyNext.takeLast(), false);
QString path = m_historyNext.takeLast();
setFolderPath(path, false);
emit openVolume(path);
}

void FolderWindow::on_parent_triggered()
Expand All @@ -236,6 +245,7 @@ void FolderWindow::on_parent_triggered()
return;
QFileInfo info(m_currentPath);
setFolderPath(info.canonicalPath(), false);
emit openVolume(info.canonicalPath());
}

void FolderWindow::on_reload_triggered()
Expand Down Expand Up @@ -287,6 +297,10 @@ void FolderWindow::on_itemDoubleClicked(const QModelIndex &index)
QDir dir(m_currentPath);
QString subpath = dir.absoluteFilePath(item.name);
emit openVolume(subpath);

if(m_historyPrev.contains(m_currentPath))
m_historyPrev.removeOne(m_currentPath);
m_historyPrev << m_currentPath;
setFolderPath(subpath, false);
}

Expand Down
2 changes: 2 additions & 0 deletions QuickViewer/src/folderview/folderwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class FolderWindow : public QWidget
void setFolderPath(QString path, bool showParent=true);
void reset();
void resetSortMode();
void resetPathLabel(int maxWidth);
QString currentPath() { return m_currentPath; }

public slots:
void on_home_triggered();
Expand Down
32 changes: 25 additions & 7 deletions QuickViewer/src/folderview/folderwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
<widget class="QMenuBar" name="menuBar">
<widget class="QMenu" name="menuSort">
<property name="title">
<string>&amp;Sort</string>
<string notr="true">&amp;Sort</string>
</property>
<addaction name="actionOrderByName"/>
<addaction name="actionOrderByUpdatedAt"/>
</widget>
<widget class="QMenu" name="menuItemContext">
<property name="title">
<string>ItemContext</string>
<string notr="true">ItemContext</string>
</property>
<addaction name="actionSetAsHomeFolder"/>
</widget>
Expand Down Expand Up @@ -130,8 +130,11 @@ QPushButton:hover {
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Move to Home</string>
</property>
<property name="text">
<string/>
<string>Move to Home</string>
</property>
<property name="icon">
<iconset resource="../../toolbar.qrc">
Expand All @@ -153,8 +156,11 @@ QPushButton:hover {
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Prev</string>
</property>
<property name="text">
<string/>
<string>Prev</string>
</property>
<property name="icon">
<iconset resource="../../toolbar.qrc">
Expand All @@ -176,8 +182,11 @@ QPushButton:hover {
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Next</string>
</property>
<property name="text">
<string/>
<string>Next</string>
</property>
<property name="icon">
<iconset resource="../../toolbar.qrc">
Expand All @@ -199,8 +208,11 @@ QPushButton:hover {
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>To parent folder</string>
</property>
<property name="text">
<string/>
<string>To parent folder</string>
</property>
<property name="icon">
<iconset resource="../../toolbar.qrc">
Expand All @@ -222,8 +234,11 @@ QPushButton:hover {
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Reload</string>
</property>
<property name="text">
<string/>
<string>Reload</string>
</property>
<property name="icon">
<iconset resource="../../toolbar.qrc">
Expand Down Expand Up @@ -258,6 +273,9 @@ QPushButton:hover {
<underline>true</underline>
</font>
</property>
<property name="toolTip">
<string>ChangeSorting</string>
</property>
<property name="text">
<string>Name</string>
</property>
Expand Down
43 changes: 10 additions & 33 deletions QuickViewer/src/imageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,16 @@ bool ImageView::on_addImage_triggered(ImageContent ic, bool pageNext)
if(m_pageManager == nullptr) return false;
m_ptLeftTop.reset();
QGraphicsScene *s = scene();
QSize size = ic.Image.size();
PageContent pgi(this, s, ic);


QSize size;
QPoint offset;
QGraphicsItem* gitem = nullptr;
int rotate = 0;
if(ic.BaseSize.width() > 0) {
QGraphicsPixmapItem* gpi = s->addPixmap(ic.Image);
gitem = gpi;
size = ic.Image.size();
if(ic.Info.ImageWidth > 0 && ic.Info.Orientation != 1) {
switch(ic.Info.Orientation) {
case 6: // left 90 digree turned
rotate = 90;
break;
case 8: // right 90 digree turned
rotate = 270;
break;
}
}
gpi->setRotation(rotate);
} else {
QGraphicsTextItem* gtext = s->addText(tr("NOT IMAGE"));
gtext->setDefaultTextColor(Qt::white);
//qDebug() << gtext;
gitem = gtext;
size = QSize(100, 100);
}
PageGraphicsItem pgi(ic, gitem, rotate);
if(pageNext)
if(pageNext) {
m_pages.push_back(pgi);
else
connect(&(m_pages.last()), SIGNAL(resizeFinished()), this, SLOT(readyForPaint()));
} else {
m_pages.push_front(pgi);
connect(&(m_pages.first()), SIGNAL(resizeFinished()), this, SLOT(readyForPaint()));
}

m_effectManager.prepareInitialize();

Expand All @@ -155,12 +132,12 @@ void ImageView::readyForPaint() {
int pageCount = m_pageManager->currentPage();
QRect sceneRect;
for(int i = 0; i < m_pages.size(); i++) {
PageGraphicsItem::Fitting fitting = PageGraphicsItem::FitCenter;
PageContent::Fitting fitting = PageContent::FitCenter;
QRect pageRect = QRect(QPoint(), viewport()->size());
if(m_pages.size() == 2) {
fitting = ((i==0 && !qApp->RightSideBook()) || (i==1 && qApp->RightSideBook()))
? PageGraphicsItem::FitRight : PageGraphicsItem::FitLeft;
pageRect = QRect(QPoint(fitting==PageGraphicsItem::FitRight ? 0 : pageRect.width()/2, 0), QSize(pageRect.width()/2,pageRect.height()));
? PageContent::FitRight : PageContent::FitLeft;
pageRect = QRect(QPoint(fitting==PageContent::FitRight ? 0 : pageRect.width()/2, 0), QSize(pageRect.width()/2,pageRect.height()));
}
QRect drawRect;
if(qApp->Fitting()) {
Expand Down
Loading

0 comments on commit 26f0b31

Please sign in to comment.