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
}
QT += network phonon opengl
QT += network opengl
CONFIG += release
CONFIG -= flat
isEqual(QT_MAJOR_VERSION, 5) {
QT += multimedia
} else {
QT += phonon
}
# Input
HEADERS += $$PWD/../common/comic.h \
$$PWD/configuration.h \

View File

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

View File

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

View File

@ -18,6 +18,14 @@
#include <ctime>
#include <algorithm>
#include <QApplication>
#include <QCoreApplication>
#include <QDesktopWidget>
#include <QToolButton>
#include <QMenu>
#include <QFileDialog>
#include <QMessageBox>
#include <QImage>
#ifdef Q_OS_MAC
class MacToolBarSeparator : public QWidget
@ -189,7 +197,7 @@ void MainWindowViewer::setupUI()
void MainWindowViewer::openFromArgv()
{
if(QCoreApplication::argc() == 2) //only path...
if(QCoreApplication::arguments().count() == 2) //only path...
{
isClient = false;
//TODO: new method open(QString)
@ -202,7 +210,7 @@ void MainWindowViewer::openFromArgv()
enableActions();
viewer->open(pathFile);
}
else if(QCoreApplication::argc() == 4)
else if(QCoreApplication::arguments().count() == 4)
{
QString pathFile = QCoreApplication::arguments().at(1);
@ -226,7 +234,7 @@ void MainWindowViewer::openFromArgv()
open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
}
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);
}
@ -1079,4 +1087,4 @@ void MainWindowViewer::sendComic()
client->sendComicInfo(libraryId,currentComicDB);
connect(client,SIGNAL(finished()),client,SLOT(deleteLater()));
//delete client;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,7 @@
#define YACREADER_TOOL_BAR_STRETCH_H
#include <QWidget>
class QHBoxLayout;
#include <QHBoxLayout>
class QToolBarStretch : public QWidget
{
@ -16,4 +15,4 @@ public:
}
};
#endif // YACREADER_TOOL_BAR_STRETCH_H
#endif // YACREADER_TOOL_BAR_STRETCH_H