Skip to content

Commit

Permalink
Merge pull request #8 from greydot/master
Browse files Browse the repository at this point in the history
Quick and dirty Qt5 port.
  • Loading branch information
stolowski committed Apr 30, 2015
2 parents 9b3df70 + cc523c7 commit 2b1748f
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 24 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Release")
ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT )
ENDIF()

SET(QT_MIN_VERSION "4.5.0")
FIND_PACKAGE(Qt4 REQUIRED)
#set(CMAKE_AUTOMOC ON)

SET(QT_MIN_VERSION "5.4.0")
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5LinguistTools REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5X11Extras)
#SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
#INCLUDE(${QT_USE_FILE})
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
include_directories(${Qt5X11Extras_INCLUDE_DIRS})
add_definitions(${Qt5Widgets_DEFINITIONS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(POPPLER poppler-qt4>=0.12.4 REQUIRED)
PKG_CHECK_MODULES(POPPLER poppler-qt5>=0.12.4 REQUIRED)

SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
SET(CPACK_SOURCE_GENERATOR "TGZ")
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ mouse or keyboard navigation etc.

2. Requirements
---------------
QComicBook requires Qt library version >=4.5.0 (including moc, uic and
lrelease tools), poppler-qt4 library and cmake.
QComicBook requires Qt libraries version >=5.4.0 (qtcore, qtwidgets, qtprintsupport,
qtx11extras, qtprintsupport), poppler-qt5 library and cmake.

You will also need unzip, rar (or unrar), unace, p7zip and tar (with gzip and
bzip2 support compiled in) somewhere in your PATH to handle archives. If one of
Expand Down
2 changes: 1 addition & 1 deletion i18n/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
file (GLOB translation_src *.ts)

QT4_CREATE_TRANSLATION(qcomicbook_qm ${FILES_TO_TRANSLATE} ${translation_src})
qt5_create_translation(qcomicbook_qm ${FILES_TO_TRANSLATE} ${translation_src})
SET_PROPERTY(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY CLEAN_NO_CUSTOM ON)
ADD_CUSTOM_TARGET(translations DEPENDS ${qcomicbook_qm})
INSTALL(FILES ${qcomicbook_qm} DESTINATION share/${PACKAGE}/i18n)
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ file (GLOB_RECURSE qcomicbook_ui *.ui)
SET(FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${qcomicbook_src}
${qcomicbook_ui} ${qcomicbook_hdr} PARENT_SCOPE)

QT4_ADD_RESOURCES(qcomicbook_res ../data/qcomicbook.qrc)
QT4_WRAP_CPP(qcomicbook_moc_src ${qcomicbook_moc_hdrs})
QT4_WRAP_UI(qcomicbook_ui_src ${qcomicbook_ui})
qt5_add_resources(qcomicbook_res ../data/qcomicbook.qrc)
qt5_wrap_cpp(qcomicbook_moc_src ${qcomicbook_moc_hdrs})
qt5_wrap_ui(qcomicbook_ui_src ${qcomicbook_ui})

ADD_EXECUTABLE(qcomicbook ${qcomicbook_src} ${qcomicbook_moc_src} ${qcomicbook_ui_src} ${qcomicbook_res})
ADD_DEPENDENCIES(qcomicbook translations)
TARGET_LINK_LIBRARIES(qcomicbook ${QT_LIBRARIES})
TARGET_LINK_LIBRARIES(qcomicbook Qt5::Widgets Qt5::PrintSupport Qt5::X11Extras)
TARGET_LINK_LIBRARIES(qcomicbook ${POPPLER_LIBRARIES})

INSTALL(TARGETS qcomicbook DESTINATION bin)
Expand Down
6 changes: 3 additions & 3 deletions src/ComicBookSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <QColor>
#include <QDir>
#include <QTextStream>
#include <QDesktopServices>
#include <QStandardPaths>
#include <iostream>

#define GRP_VIEW "/View"
Expand Down Expand Up @@ -104,7 +104,7 @@ ComicBookSettings::~ComicBookSettings()
bool ComicBookSettings::checkDirs()
{
m_dirsok = false;
m_bkpath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
m_bkpath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);

QDir dir(m_bkpath);
if (!dir.exists())
Expand All @@ -115,7 +115,7 @@ bool ComicBookSettings::checkDirs()
}
}

m_thpath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation) + QDir::separator() + "thumbs";
m_thpath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QDir::separator() + "thumbs";

dir.setPath(m_thpath);
if (!dir.exists())
Expand Down
1 change: 1 addition & 0 deletions src/ComicMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <QFileInfo>
#include <QToolBar>
#include <QMessageBox>
#include <QMimeData>
#include <QLabel>
#include <QKeyEvent>
#include <QWidgetAction>
Expand Down
10 changes: 5 additions & 5 deletions src/ImgCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ void ImgCache::setSize(int size, bool autoAdjust)
void ImgCache::insertImage(int page, const QImage &img)
{
mtx.lock();
if (autoAdjust && (img.numBytes() + maxItemSizeSoFar > cache.maxCost()))
if (autoAdjust && (img.byteCount() + maxItemSizeSoFar > cache.maxCost()))
{
cache.setMaxCost(img.numBytes() + maxItemSizeSoFar);
if (img.numBytes() > maxItemSizeSoFar)
maxItemSizeSoFar = img.numBytes();
cache.setMaxCost(img.byteCount() + maxItemSizeSoFar);
if (img.byteCount() > maxItemSizeSoFar)
maxItemSizeSoFar = img.byteCount();
}
cache.insert(page, new QImage(img), img.numBytes());
cache.insert(page, new QImage(img), img.byteCount());
mtx.unlock();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sink/ImgPdfSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ QImage ImgPdfSink::image(unsigned int num, int &result)
Poppler::Page* pdfpage = pdfdoc->page(num);
if (pdfpage)
{
QImage img = pdfpage->renderToImage(QX11Info::appDpiX(), QX11Info::appDpiY()); //TODO use defaults if not using X11 (e.g. MS Win)
QImage img = pdfpage->renderToImage(QX11Info::appDpiX(), QX11Info::appDpiY()); //TODO: use QScreen
delete pdfpage;
result = 0;
return img;
Expand Down
2 changes: 1 addition & 1 deletion src/Sink/ImgPdfSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "ImgSink.h"
#include <QStringList>
#include <QMutex>
#include <poppler-qt4.h>
#include <poppler-qt5.h>

namespace QComicBook
{
Expand Down
8 changes: 8 additions & 0 deletions src/StatusBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ void StatusBar::removeProgressBar()
}
}

void StatusBar::setShown(bool v)
{
if(v)
show();
else
hide();
}

void StatusBar::clear()
{
setPage(0, 0);
Expand Down
1 change: 1 addition & 0 deletions src/StatusBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace QComicBook
void setName(const QString &n);
void setImageInfo(const Page *img1, const Page *img2 = NULL);
void setProgress(int n, int total);
void setShown(bool);
void clear();

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/Thumbnail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ QString Thumbnail::getFullPath() const

QByteArray Thumbnail::getScrambledName(const QString &in)
{
return QCryptographicHash::hash( in.toAscii(), QCryptographicHash::Sha1 );
return QCryptographicHash::hash( in.toLatin1(), QCryptographicHash::Sha1 );
}
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ int main(int argc, char *argv[])

//
// command line argument
if (app.argc() > 1)
if (app.arguments().size() > 1)
{
win->open(QString::fromLocal8Bit(app.argv()[1]));
win->open(app.arguments().at(1));
}
else
{
Expand Down

0 comments on commit 2b1748f

Please sign in to comment.