Permalink
Browse files

Quick and dirty Qt5 port. Yes we can.

  • Loading branch information...
1 parent 9b3df70 commit cc523c7c41d20e537b3aea8a46fc1c24d6d29320 @greydot greydot committed Apr 4, 2015
View
@@ -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")
View
@@ -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
View
@@ -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)
View
@@ -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)
@@ -19,7 +19,7 @@
#include <QColor>
#include <QDir>
#include <QTextStream>
-#include <QDesktopServices>
+#include <QStandardPaths>
#include <iostream>
#define GRP_VIEW "/View"
@@ -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())
@@ -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())
@@ -48,6 +48,7 @@
#include <QFileInfo>
#include <QToolBar>
#include <QMessageBox>
+#include <QMimeData>
#include <QLabel>
#include <QKeyEvent>
#include <QWidgetAction>
View
@@ -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();
}
@@ -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;
@@ -16,7 +16,7 @@
#include "ImgSink.h"
#include <QStringList>
#include <QMutex>
-#include <poppler-qt4.h>
+#include <poppler-qt5.h>
namespace QComicBook
{
View
@@ -98,6 +98,14 @@ void StatusBar::removeProgressBar()
}
}
+void StatusBar::setShown(bool v)
+{
+ if(v)
+ show();
+ else
+ hide();
+}
+
void StatusBar::clear()
{
setPage(0, 0);
View
@@ -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:
View
@@ -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 );
}
View
@@ -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
{

0 comments on commit cc523c7

Please sign in to comment.