Fixed YACReader compilation under Qt5 (YACReader-YACReaderLibrary communication is broken at runtime)

This commit is contained in:
Luis Ángel San Martín 2013-10-09 18:44:46 +02:00
parent d5a35de96c
commit b1d3bbb584
11 changed files with 83 additions and 35 deletions

View File

@ -24,10 +24,16 @@ INCLUDEPATH += /usr/local/include/poppler/qt4
LIBS += -L/usr/local/lib -lpoppler-qt4 LIBS += -L/usr/local/lib -lpoppler-qt4
} }
QT += network phonon opengl QT += network opengl
CONFIG += release CONFIG += release
CONFIG -= flat CONFIG -= flat
isEqual(QT_MAJOR_VERSION, 5) {
QT += multimedia
} else {
QT += phonon
}
# Input # Input
HEADERS += $$PWD/../common/comic.h \ HEADERS += $$PWD/../common/comic.h \
$$PWD/configuration.h \ $$PWD/configuration.h \

View File

@ -2,10 +2,21 @@
# Automatically generated by qmake (2.01a) mié 8. oct 20:54:05 2008 # Automatically generated by qmake (2.01a) mié 8. oct 20:54:05 2008
# ##################################################################### # #####################################################################
TEMPLATE = app TEMPLATE = app
TARGET = TARGET = YACReader
DEPENDPATH += . \ DEPENDPATH += . \
release release
DEFINES += NOMINMAX
isEqual(QT_MAJOR_VERSION, 5) {
Release:DESTDIR = ../release5
Debug:DESTDIR = ../debug5
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
SOURCES += main.cpp SOURCES += main.cpp
include(YACReader.pri) include(YACReader.pri)
@ -21,7 +32,4 @@ TRANSLATIONS = yacreader_es.ts \
yacreader_pt.ts \ yacreader_pt.ts \
yacreader_nl.ts \ yacreader_nl.ts \
yacreader_source.ts yacreader_source.ts
FORMS +=
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug

View File

@ -2,7 +2,7 @@
#include "viewer.h" #include "viewer.h"
#include "configuration.h" #include "configuration.h"
#include <QScrollBar>
MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent) MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent)
:QLabel(parent),zoomLevel(0.5) :QLabel(parent),zoomLevel(0.5)

View File

@ -18,6 +18,14 @@
#include <ctime> #include <ctime>
#include <algorithm> #include <algorithm>
#include <QApplication>
#include <QCoreApplication>
#include <QDesktopWidget>
#include <QToolButton>
#include <QMenu>
#include <QFileDialog>
#include <QMessageBox>
#include <QImage>
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
class MacToolBarSeparator : public QWidget class MacToolBarSeparator : public QWidget
@ -189,7 +197,7 @@ void MainWindowViewer::setupUI()
void MainWindowViewer::openFromArgv() void MainWindowViewer::openFromArgv()
{ {
if(QCoreApplication::argc() == 2) //only path... if(QCoreApplication::arguments().count() == 2) //only path...
{ {
isClient = false; isClient = false;
//TODO: new method open(QString) //TODO: new method open(QString)
@ -202,7 +210,7 @@ void MainWindowViewer::openFromArgv()
enableActions(); enableActions();
viewer->open(pathFile); viewer->open(pathFile);
} }
else if(QCoreApplication::argc() == 4) else if(QCoreApplication::arguments().count() == 4)
{ {
QString pathFile = QCoreApplication::arguments().at(1); QString pathFile = QCoreApplication::arguments().at(1);
@ -226,7 +234,7 @@ void MainWindowViewer::openFromArgv()
open(pathFile+currentComicDB.path,currentComicDB,siblingComics); open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
} }
else else
{isClient = false;/*error*/} {isClient = false; QMessageBox::information(this,"Connection Error", "Unable to connect to YACReaderLibrary");/*error*/}
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma); optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
} }

View File

@ -4,6 +4,8 @@
#include <algorithm> #include <algorithm>
#include <QByteArray> #include <QByteArray>
#include <QPixmap> #include <QPixmap>
#include <QApplication>
#include <QImage>
#include <typeinfo> #include <typeinfo>
@ -48,7 +50,7 @@ QImage changeImage( const QImage& image, int value )
{ {
QImage im = image; QImage im = image;
im.detach(); im.detach();
if( im.numColors() == 0 ) /* truecolor */ if( im.colorCount() == 0 ) /* truecolor */
{ {
if( im.format() != QImage::Format_RGB32 ) /* just in case */ if( im.format() != QImage::Format_RGB32 ) /* just in case */
im = im.convertToFormat( QImage::Format_RGB32 ); im = im.convertToFormat( QImage::Format_RGB32 );
@ -93,7 +95,7 @@ QImage changeImage( const QImage& image, int value )
{ {
QVector<QRgb> colors = im.colorTable(); QVector<QRgb> colors = im.colorTable();
for( int i = 0; for( int i = 0;
i < im.numColors(); i < im.colorCount();
++i ) ++i )
colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ), colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ),
operation( qGreen( colors[ i ] ), value ), operation( qGreen( colors[ i ] ), value ),

View File

@ -1,6 +1,11 @@
#include <QUrl> #include <QUrl>
#if QT_VERSION >= 0x050000
#else
#include <Phonon/MediaObject> #include <Phonon/MediaObject>
#include <Phonon/MediaSource> #include <Phonon/MediaSource>
#endif
#include <QPushButton> #include <QPushButton>
#include <QPalette> #include <QPalette>
#include <QMouseEvent> #include <QMouseEvent>
@ -138,8 +143,6 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
resize(400,479); resize(400,479);
music = createPlayer(MusicCategory);
layout->setMargin(0); layout->setMargin(0);
layout->setContentsMargins(18,12,18,12); layout->setContentsMargins(18,12,18,12);
setContentsMargins(0,0,0,0); setContentsMargins(0,0,0,0);
@ -157,6 +160,13 @@ YACReaderTranslator::YACReaderTranslator(QWidget * parent)
connect(searchButton,SIGNAL(pressed()),this,SLOT(translate())); connect(searchButton,SIGNAL(pressed()),this,SLOT(translate()));
connect(speakButton,SIGNAL(pressed()),this,SLOT(play())); connect(speakButton,SIGNAL(pressed()),this,SLOT(play()));
connect(clearButton,SIGNAL(pressed()),this,SLOT(clear())); connect(clearButton,SIGNAL(pressed()),this,SLOT(clear()));
//multimedia/phonon
#if QT_VERSION >= 0x050000
#else
music = createPlayer(MusicCategory);
#endif
} }
void YACReaderTranslator::hideResults() void YACReaderTranslator::hideResults()
@ -280,15 +290,21 @@ void YACReaderTranslator::populateCombos()
void YACReaderTranslator::play() void YACReaderTranslator::play()
{ {
//QMessageBox::question(this,"xxx",ttsSource.toString()); //QMessageBox::question(this,"xxx",ttsSource.toString());
#if QT_VERSION >= 0x050000
#else
MediaSource src(ttsSource); MediaSource src(ttsSource);
src.setAutoDelete(true); src.setAutoDelete(true);
music->setCurrentSource(src); music->setCurrentSource(src);
music->play(); music->play();
#endif
} }
YACReaderTranslator::~YACReaderTranslator() YACReaderTranslator::~YACReaderTranslator()
{ {
#if QT_VERSION >= 0x050000
#else
delete music; delete music;
#endif
} }
void YACReaderTranslator::mousePressEvent(QMouseEvent *event) void YACReaderTranslator::mousePressEvent(QMouseEvent *event)

View File

@ -14,9 +14,13 @@ class YACReaderBusyWidget;
#include <QThread> #include <QThread>
#include <QUrl> #include <QUrl>
#include<Phonon/MediaObject> #if QT_VERSION >= 0x050000
#else
#include<Phonon/MediaObject>
using namespace Phonon;
#endif
using namespace Phonon;
class YACReaderTranslator : public QWidget class YACReaderTranslator : public QWidget
{ {
@ -45,7 +49,13 @@ protected:
bool drag; bool drag;
QPoint click; QPoint click;
private: private:
#if QT_VERSION >= 0x050000
#else
MediaObject * music; MediaObject * music;
#endif
QTextEdit * text; QTextEdit * text;
QComboBox * from; QComboBox * from;
QComboBox * to; QComboBox * to;

View File

@ -3,7 +3,7 @@
###################################################################### ######################################################################
TEMPLATE = app TEMPLATE = app
TARGET = TARGET = YACReaderLibrary
DEPENDPATH += . DEPENDPATH += .
INCLUDEPATH += . INCLUDEPATH += .
INCLUDEPATH += ../common \ INCLUDEPATH += ../common \
@ -143,12 +143,11 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
yacreaderlibrary_fr.ts \ yacreaderlibrary_fr.ts \
yacreaderlibrary_nl.ts \ yacreaderlibrary_nl.ts \
yacreaderlibrary_source.ts yacreaderlibrary_source.ts
contains(QT_MINOR_VERSION, 5) {
Release:DESTDIR = ../release5 isEqual(QT_MAJOR_VERSION, 5) {
Debug:DESTDIR = ../debug5 Release:DESTDIR = ../release5
} Debug:DESTDIR = ../debug5
!contains(QT_MINOR_VERSION, 5) } else {
{ Release:DESTDIR = ../release
Release:DESTDIR = ../release Debug:DESTDIR = ../debug
Debug:DESTDIR = ../debug
} }

View File

@ -73,7 +73,7 @@ void Logger::msgHandler(const QtMsgType type, const char* message) {
Logger::~Logger() { Logger::~Logger() {
if (defaultLogger==this) { if (defaultLogger==this) {
#if QT_VERSION >= 0x050100 #if QT_VERSION >= 0x050000
qInstallMessageHandler(0); qInstallMessageHandler(0);
#else #else
qInstallMsgHandler(0); qInstallMsgHandler(0);
@ -92,7 +92,7 @@ void Logger::write(const LogMessage* logMessage) {
void Logger::installMsgHandler() { void Logger::installMsgHandler() {
defaultLogger=this; defaultLogger=this;
#if QT_VERSION >= 0x050100 #if QT_VERSION >= 0x050000
//qInstallMessageHandler(msgHandler); TODO Qt5 //qInstallMessageHandler(msgHandler); TODO Qt5
#else #else
qInstallMsgHandler(msgHandler); qInstallMsgHandler(msgHandler);

View File

@ -31,7 +31,7 @@ YACReaderTableView::YACReaderTableView(QWidget *parent) :
setContextMenuPolicy(Qt::ActionsContextMenu); setContextMenuPolicy(Qt::ActionsContextMenu);
setShowGrid(false); setShowGrid(false);
#if QT_VERSION >= 0x050100 #if QT_VERSION >= 0x050000
verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
#else #else
verticalHeader()->setResizeMode(QHeaderView::Fixed); verticalHeader()->setResizeMode(QHeaderView::Fixed);
@ -39,14 +39,14 @@ YACReaderTableView::YACReaderTableView(QWidget *parent) :
//comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); //comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
horizontalHeader()->setStretchLastSection(true); horizontalHeader()->setStretchLastSection(true);
#if QT_VERSION >= 0x050100 #if QT_VERSION >= 0x050000
horizontalHeader()->setSectionsClickable(false); horizontalHeader()->setSectionsClickable(false);
#else #else
horizontalHeader()->setClickable(false); horizontalHeader()->setClickable(false);
#endif #endif
//comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
verticalHeader()->setDefaultSectionSize(24); verticalHeader()->setDefaultSectionSize(24);
#if QT_VERSION >= 0x050100 #if QT_VERSION >= 0x050000
verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo verticalHeader()->setSectionsClickable(false); //TODO comportamiento anómalo
#else #else
verticalHeader()->setClickable(false); //TODO comportamiento anómalo verticalHeader()->setClickable(false); //TODO comportamiento anómalo

View File

@ -2,8 +2,7 @@
#define YACREADER_TOOL_BAR_STRETCH_H #define YACREADER_TOOL_BAR_STRETCH_H
#include <QWidget> #include <QWidget>
#include <QHBoxLayout>
class QHBoxLayout;
class QToolBarStretch : public QWidget class QToolBarStretch : public QWidget
{ {