From b1d3bbb584b64b75e41806da66e07566a0d94b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 9 Oct 2013 18:44:46 +0200 Subject: [PATCH] Fixed YACReader compilation under Qt5 (YACReader-YACReaderLibrary communication is broken at runtime) --- YACReader/YACReader.pri | 8 +++++++- YACReader/YACReader.pro | 16 +++++++++++---- YACReader/magnifying_glass.cpp | 2 +- YACReader/main_window_viewer.cpp | 16 +++++++++++---- YACReader/render.cpp | 8 +++++--- YACReader/translator.cpp | 20 +++++++++++++++++-- YACReader/translator.h | 16 ++++++++++++--- YACReaderLibrary/YACReaderLibrary.pro | 17 ++++++++-------- .../server/lib/bfLogging/logger.cpp | 4 ++-- custom_widgets/yacreader_table_view.cpp | 6 +++--- custom_widgets/yacreader_tool_bar_stretch.h | 5 ++--- 11 files changed, 83 insertions(+), 35 deletions(-) diff --git a/YACReader/YACReader.pri b/YACReader/YACReader.pri index 91097615..86fb7a57 100644 --- a/YACReader/YACReader.pri +++ b/YACReader/YACReader.pri @@ -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 \ diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index e884dd6e..3c09f91c 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -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 \ No newline at end of file diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 3751c038..0ff09aa7 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -2,7 +2,7 @@ #include "viewer.h" #include "configuration.h" - +#include MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent) :QLabel(parent),zoomLevel(0.5) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index e43dbc48..eb1adee9 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -18,6 +18,14 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include #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; -} \ No newline at end of file +} diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 110628de..46b48e0f 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include @@ -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 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(); -} \ No newline at end of file +} diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp index 94747f40..4f97e567 100644 --- a/YACReader/translator.cpp +++ b/YACReader/translator.cpp @@ -1,6 +1,11 @@ #include + +#if QT_VERSION >= 0x050000 +#else #include #include +#endif + #include #include #include @@ -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) diff --git a/YACReader/translator.h b/YACReader/translator.h index 71fb49e9..b44d0544 100644 --- a/YACReader/translator.h +++ b/YACReader/translator.h @@ -14,9 +14,13 @@ class YACReaderBusyWidget; #include #include -#include +#if QT_VERSION >= 0x050000 +#else + #include + 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 \ No newline at end of file +#endif diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 9586e2e0..1368bfc0 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -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 } diff --git a/YACReaderLibrary/server/lib/bfLogging/logger.cpp b/YACReaderLibrary/server/lib/bfLogging/logger.cpp index 7f304c54..8e2ed329 100644 --- a/YACReaderLibrary/server/lib/bfLogging/logger.cpp +++ b/YACReaderLibrary/server/lib/bfLogging/logger.cpp @@ -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); diff --git a/custom_widgets/yacreader_table_view.cpp b/custom_widgets/yacreader_table_view.cpp index b38ff5a6..300eb2c0 100644 --- a/custom_widgets/yacreader_table_view.cpp +++ b/custom_widgets/yacreader_table_view.cpp @@ -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 diff --git a/custom_widgets/yacreader_tool_bar_stretch.h b/custom_widgets/yacreader_tool_bar_stretch.h index bcfa5df3..d4817176 100644 --- a/custom_widgets/yacreader_tool_bar_stretch.h +++ b/custom_widgets/yacreader_tool_bar_stretch.h @@ -2,8 +2,7 @@ #define YACREADER_TOOL_BAR_STRETCH_H #include - -class QHBoxLayout; +#include class QToolBarStretch : public QWidget { @@ -16,4 +15,4 @@ public: } }; -#endif // YACREADER_TOOL_BAR_STRETCH_H \ No newline at end of file +#endif // YACREADER_TOOL_BAR_STRETCH_H