Commit e326b090 authored by Esteban Blanc's avatar Esteban Blanc

Qt5 upgrade

See merge request !1
parents 9781958a 167e3ce3
......@@ -20,7 +20,7 @@ Optional:
Mandatory if you want to build the QT version of ProviewR:
> apt-get install qt4-dev-tools libphonon-dev
> apt-get install qt5-default
Mandatory if you want to build the GTK version of ProviewR:
......
......@@ -75,7 +75,11 @@ fi
btype="dbg"
ename=$ver$hw
desc=$verl
gui="gtk"
if [ ! -z $1 ]; then
gui="$1"
else
gui="qt"
fi
if [ $gui == "qt" ]; then
export pwre_conf_qt=1
......
......@@ -84,7 +84,7 @@ endif
$(bld_dir)/%_moc.o : %.cqt
@ echo "Generating $(sname)_moc.cpp from $(sname).h using moc"
@ moc $(csetos) $(sname).h -o $(bld_dir)/$(sname)_moc.cpp
@ moc -DPWRE_CONF_QT $(pwre_conf_cc_define) $(sname).h -o $(bld_dir)/$(sname)_moc.cpp
@ echo "Compiling $(sname)_moc.cpp"
@ $(cxx) $(cxxflags) $(csetos) $(cinc) -o $(bld_dir)/$(sname)_moc.o $(bld_dir)/$(sname)_moc.cpp
......@@ -123,7 +123,7 @@ ifeq ($(nodep),)
| sed '\''s|$*\.o[ ]*|$(obj_dir)/&|g'\'' > $(obj_dir)/$(sname).d'
endif
@ echo "Generating $(sname)_moc.cpp from $(sname).h using moc"
@ moc $(csetos) $(cinc) $(sname).h \
@ moc -DPWRE_CONF_QT $(pwre_conf_cc_define) $(cinc) $(sname).h \
-o $(bld_dir)/$(sname)_moc.cpp
@ echo "Compiling $(sname)_moc.cpp"
@ $(cxx) $(cxxflags) $(csetos) $(cinc) -o $(bld_dir)/$(sname)_moc.o $(bld_dir)/$(sname)_moc.cpp
......
......@@ -88,7 +88,7 @@ pre_so =
log_done =
ifeq ($(pwre_conf_qt),1)
csetos := -DPWRE_CONF_QT $(pwre_conf_cc_define)
csetos := -DPWRE_CONF_QT $(pwre_conf_cc_define) -fPIC
cinc := -I$(inc_dir) -I$(einc_dir) -I$(co_source) $(pwre_conf_incdir) $(pwre_conf_incdirqt)
else
ifeq ($(pwre_conf_gtk),1)
......@@ -158,7 +158,7 @@ else
endif
explinkflags := $(cross_compile) -g -L$(elib_dir)
cxxflags := -std=gnu++11 $(cflags)
cxxflags := -std=gnu++11 $(cflags) -Wno-deprecated-copy
clis = /lis=$(list)
dolist = /lis=$(list)
domap = -Xlinker -Map -Xlinker $(map)
......
......@@ -190,8 +190,8 @@ pwre_config_check_lib()
conf_libgtk=$conf_libgtk" \\\`pkg-config --libs gtk+-2.0\\\`"
conf_incdirgtk=$conf_incdirgtk" \\\`pkg-config --cflags gtk+-2.0\\\`"
elif test $3 == "qt"; then
conf_libqt=$conf_libqt" \\\`pkg-config --libs QtCore QtGui QtNetwork phonon\\\`"
conf_incdirqt=$conf_incdirqt" \\\`pkg-config --cflags QtCore QtGui QtNetwork phonon\\\`"
conf_libqt=$conf_libqt" \\\`pkg-config --libs Qt5Core Qt5Widgets Qt5Gui Qt5Network Qt5PrintSupport Qt5Multimedia Qt5MultimediaWidgets Qt5WebSockets\\\`"
conf_incdirqt=$conf_incdirqt" \\\`pkg-config --cflags Qt5Core Qt5Widgets Qt5Gui Qt5Network Qt5PrintSupport Qt5Multimedia Qt5MultimediaWidgets Qt5WebSockets\\\`"
elif test $3 == "gst"; then
conf_libgst=$conf_libgst" \\\`pkg-config --libs gstreamer-video-1.0 gstreamer-1.0\\\`"
conf_incdirgst=$conf_incdirgst" \\\`pkg-config --cflags gstreamer-video-1.0 gstreamer-1.0\\\`"
......@@ -352,11 +352,11 @@ if [ $pwre_hw == "hw_arm" ] && [ $ebuild -eq 1 ]; then
echo "Arm ebuild"
# if [ $pwre_conf_qt -eq 1 ]; then
pwre_config_check_lib qt QT qt qt 0 "/usr/lib/libQtGui.so:/usr/lib/$hwpl-linux-$gnu/libQtGui.so"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtGui"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtCore/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtGui/QtGui"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtNetwork/QtNetwork"
pwre_config_check_lib qt QT qt qt 0 "/usr/lib/$hwpl-linux-$gnu/libQt5Gui.so"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtCore/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtWidgets/QtWidgets"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtGui/QtGui"
# fi
# if [ $pwre_conf_gtk -eq 1 ]; then
pwre_config_check_lib gtk GTK gtk gtk 0 "/usr/lib/libgtk-x11-2.0.so:/usr/lib/$hwpl-linux-$gnu/libgtk-x11-2.0.so"
......@@ -431,11 +431,11 @@ else
echo ""
echo "Gui either Qt or Gtk :"
# if [ ! -z $pwre_conf_qt ]; then
pwre_config_check_lib qt QT qt qt 0 "/usr/lib/libQtGui.so:/usr/lib/$hwpl-linux-$gnu/libQtGui.so"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtGui"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtCore/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtGui/QtGui"
pwre_config_check_include qt QT 0 "/usr/include/qt4/QtNetwork/QtNetwork"
pwre_config_check_lib qt QT qt qt 0 "/usr/lib/$hwpl-linux-$gnu/libQt5Gui.so"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtCore/QtCore"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtWidgets/QtWidgets"
pwre_config_check_include qt QT 0 "/usr/include/$hwpl-linux-$gnu/qt5/QtGui/QtGui"
# else
pwre_config_check_lib gtk GTK gtk gtk 0 "/usr/lib/libgtk-x11-2.0.so:/usr/lib/$hwpl-linux-$gnu/libgtk-x11-2.0.so"
pwre_config_check_include gtk GTK 0 "/usr/local/include/gtk-2.0/gtk.h:/usr/local/include/gtk-2.0/gtk/gtk.h:/usr/include/gtk-2.0/gtk/gtk.h"
......
......@@ -267,6 +267,8 @@ WVselQt::WVselQt(pwr_tStatus* status, void* wv_parent_ctx,
volumelist->setSelectionMode(QAbstractItemView::SingleSelection);
volumelist->setColumnCount(3);
volumelist->header()->setSectionResizeMode(0, QHeaderView::Stretch);
volumelist->header()->setStretchLastSection(false);
volumelist->header()->close();
QDialogButtonBox* buttons = new QDialogButtonBox();
......
......@@ -43,7 +43,7 @@
#include <QFile>
#include <QTextStream>
PwrStyle::PwrStyle() : QGtkStyle() {
PwrStyle::PwrStyle() : QProxyStyle() {
loadPalette("$HOME/.pwr_style");
}
......@@ -66,7 +66,7 @@ int PwrStyle::pixelMetric(PixelMetric which, const QStyleOption* option,
case PM_ToolBarItemSpacing:
return 0;
default:
return QGtkStyle::pixelMetric(which, option, widget);
return QProxyStyle::pixelMetric(which, option, widget);
}
}
......@@ -76,7 +76,7 @@ int PwrStyle::styleHint(StyleHint hint, const QStyleOption* option,
return QDialogButtonBox::WinLayout;
}
return QGtkStyle::styleHint(hint, option, widget, returnData);
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
void PwrStyle::loadPalette(const char* path) {
......@@ -105,52 +105,4 @@ void PwrStyle::loadPalette(const char* path) {
}
}
QApplication::setPalette(*pal);
}
void PwrStyle::drawPrimitive(PrimitiveElement element,
const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
if (pal) {
if (element == PE_PanelButtonCommand) {
QWindowsStyle::drawPrimitive(element, option, painter, widget);
return;
}
QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
} else {
QGtkStyle::drawPrimitive(element, option, painter, widget);
}
}
void PwrStyle::drawControl(ControlElement control, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const {
if (pal) {
QCleanlooksStyle::drawControl(control, option, painter, widget);
} else {
QGtkStyle::drawControl(control, option, painter, widget);
}
}
void PwrStyle::drawComplexControl(ComplexControl control,
const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget)
const {
if (pal) {
QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
} else {
QGtkStyle::drawComplexControl(control, option, painter, widget);
}
}
void PwrStyle::polish(QApplication *app) {
if (pal) {
QCleanlooksStyle::polish(app);
} else {
QGtkStyle::polish(app);
}
}
void PwrStyle::unpolish(QApplication *app) {
if (pal) {
QCleanlooksStyle::unpolish(app);
} else {
QGtkStyle::unpolish(app);
}
}
\ No newline at end of file
......@@ -37,32 +37,20 @@
#ifndef cow_style_qt_h
#define cow_style_qt_h
#include <QGtkStyle>
class PwrStyle : public QGtkStyle {
Q_OBJECT
#include <QProxyStyle>
class PwrStyle : public QProxyStyle {
public:
PwrStyle();
~PwrStyle();
int pixelMetric(PixelMetric which, const QStyleOption* option,
int pixelMetric(PixelMetric which, const QStyleOption* option = 0,
const QWidget* widget = 0) const;
int styleHint(StyleHint hint, const QStyleOption* option,
const QWidget* widget, QStyleHintReturn* returnData = 0) const;
int styleHint(StyleHint hint, const QStyleOption* option = 0,
const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
void loadPalette(const char* path);
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const;
void drawControl(ControlElement control, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const;
void drawComplexControl(ComplexControl control,
const QStyleOptionComplex *option, QPainter *painter,
const QWidget *widget) const;
void polish(QApplication *app);
void unpolish(QApplication *app);
private:
QPalette *pal = NULL;
};
......
......@@ -166,7 +166,7 @@ void CoWowQt::DisplayError(
QMessageBox msgBox(QMessageBox::Critical, fl(title), ctext,
QMessageBox::NoButton, object->parent_wid->window());
QDialogButtonBox* buttonBox = qFindChild<QDialogButtonBox*>(&msgBox);
QDialogButtonBox* buttonBox = msgBox.findChildren<QDialogButtonBox*>()[0];
Q_ASSERT(buttonBox != 0);
QPushButton* button = msgBox.addButton(QMessageBox::Ok);
......
......@@ -343,12 +343,12 @@ int GlowDrawQt::event_handler(QEvent* event, QWidget* target)
keysym = keyEvent->key();
if (keysym >= Qt::Key_Space && keysym <= Qt::Key_AsciiTilde) {
char buff = QChar(keysym).toAscii();
const char* buff = qPrintable(keyEvent->text());
if (keyEvent->modifiers() & Qt::ControlModifier) {
sts = ctx->event_handler(glow_eEvent_Key_CtrlAscii, 0, 0, buff, 0);
sts = ctx->event_handler(glow_eEvent_Key_CtrlAscii, 0, 0, buff[0], 0);
} else {
sts = ctx->event_handler(glow_eEvent_Key_Ascii, 0, 0, buff, 0);
sts = ctx->event_handler(glow_eEvent_Key_Ascii, 0, 0, buff[0], 0);
}
} else {
switch (keysym) {
......
......@@ -52,9 +52,7 @@
#include <QLabel>
#include <QMenu>
#include <QPainter>
#include <phonon/MediaObject>
#include <phonon/MediaSource>
#include <QVideoWidget>
/* This function is called when the main window is closed */
void XttStreamQtWidget::closeEvent(QCloseEvent* event)
......@@ -74,7 +72,7 @@ void XttStreamQtWidget::closeEvent(QCloseEvent* event)
* new position here. */
void XttStreamQtWidget::slider_cb(int value)
{
stream->playbin2->seek(value * 1000);
stream->playbin2->setPosition(value * 1000);
}
static void refresh_ui(XttStreamQt* strm)
......@@ -86,11 +84,11 @@ static void refresh_ui(XttStreamQt* strm)
/* We do not want to update anything unless we are in the PAUSED or PLAYING
* states */
if (!(strm->state == Phonon::PausedState || strm->state == Phonon::PlayingState)) {
if (!(strm->state == QMediaPlayer::PausedState || strm->state == QMediaPlayer::PlayingState)) {
return;
}
qint64 current = strm->playbin2->totalTime();
qint64 current = strm->playbin2->duration();
strm->slider->setRange(0, current / 1000);
strm->toplevel->update();
}
......@@ -105,9 +103,9 @@ void XttStreamQt::reconnect(void* data)
{
XttStreamQt* strm = (XttStreamQt*)data;
printf("Try to reconnect %d 1\n", strm->playbin2->mediaObject()->state());
printf("Try to reconnect %d 1\n", strm->playbin2->state());
if (strm->playbin2->mediaObject()->state() == Phonon::PlayingState) {
if (strm->playbin2->state() == QMediaPlayer::PlayingState) {
return;
}
......@@ -142,7 +140,7 @@ void XttStreamQt::reconnect(void* data)
strcpy(luri, strm->uri);
}
strm->playbin2->load(Phonon::MediaSource(QUrl(fl(luri))));
strm->playbin2->setMedia(QUrl(fl(luri)));
} else {
strm->playbin2->play();
}
......@@ -159,12 +157,13 @@ static void refresh(void* data)
/* This function is called when the pipeline changes states. We use it to
* keep track of the current state. */
void XttStreamQtWidget::state_changed_cb(Phonon::State new_state, Phonon::State old_state)
void XttStreamQtWidget::state_changed_cb(QMediaPlayer::State new_state, QMediaPlayer::State old_state)
{
if (new_state == Phonon::ErrorState) {
printf("Error: %s\n", qPrintable(stream->playbin2->mediaObject()->errorString()));
if (stream->playbin2->error() != QMediaPlayer::Error::NoError) {
printf("Error: %s\n", qPrintable(stream->playbin2->errorString()));
if (stream->playbin2->mediaObject()->errorType() == Phonon::FatalError) {
if (stream->playbin2->error() == QMediaPlayer::ResourceError ||
stream->playbin2->error() == QMediaPlayer::ServiceMissingError) {
stream->no_uri = 1;
}
......@@ -178,8 +177,8 @@ void XttStreamQtWidget::state_changed_cb(Phonon::State new_state, Phonon::State
stream->reconnect_timerid->add(
int(stream->reconnect_time * 1000), stream->reconnect, stream);
}
if (stream->state == Phonon::StoppedState
&& new_state == Phonon::PausedState) {
if (stream->state == QMediaPlayer::StoppedState
&& new_state == QMediaPlayer::PausedState) {
/* For extra responsiveness, we refresh the GUI as soon as we reach the
* PAUSED state */
refresh_ui(stream);
......@@ -347,9 +346,9 @@ XttStreamQt::XttStreamQt(void* st_parent_ctx, const char* name,
toplevel = new XttStreamQtWidget(this);
/* Create the elements */
playbin2 = new Phonon::VideoPlayer(toplevel);
QObject::connect(playbin2->mediaObject(), SIGNAL(stateChanged(Phonon::State, Phonon::State)),
toplevel, SLOT(state_changed_cb(Phonon::State, Phonon::State)));
playbin2 = new QMediaPlayer(toplevel, QMediaPlayer::VideoSurface);
QObject::connect(playbin2, SIGNAL(stateChanged(QMediaPlayer::State, QMediaPlayer::State)),
toplevel, SLOT(state_changed_cb(QMediaPlayer::State, QMediaPlayer::State)));
/* Set the URI to play, eg "http://192.168.67.248/mjpg/video.mjpg" */
char luri[250];
......@@ -374,7 +373,7 @@ XttStreamQt::XttStreamQt(void* st_parent_ctx, const char* name,
strcpy(luri, uri);
}
playbin2->load(Phonon::MediaSource(QUrl(fl(luri))));
playbin2->setMedia(QUrl(fl(luri)));
if (!embedded) {
toplevel->setWindowTitle(QString::fromLatin1(name));
......@@ -496,17 +495,19 @@ XttStreamQt::XttStreamQt(void* st_parent_ctx, const char* name,
}
}
add_expanding(main_layout, playbin2);
QVideoWidget *videoWidget = new QVideoWidget();
add_expanding(main_layout, videoWidget);
playbin2->setVideoOutput(videoWidget);
if (options & strm_mOptions_VideoControlPanel) {
QToolBar* controlbuttons = new QToolBar();
addToolItem(playbin2, controlbuttons, "Play",
SLOT(Phonon::VideoPlayer::play()), "$pwr_exe/xtt_play.png");
SLOT(QMediaPlayer::play()), "$pwr_exe/xtt_play.png");
addToolItem(playbin2, controlbuttons, "Pause",
SLOT(Phonon::VideoPlayer::pause()), "$pwr_exe/xtt_pause.png");
SLOT(QMediaPlayer::pause()), "$pwr_exe/xtt_pause.png");
addToolItem(playbin2, controlbuttons, "Stop",
SLOT(Phonon::VideoPlayer::stop()), "$pwr_exe/xtt_stop.png");
SLOT(QMediaPlayer::stop()), "$pwr_exe/xtt_stop.png");
if (options & strm_mOptions_VideoProgressBar) {
slider = new QSlider(Qt::Horizontal);
......
......@@ -42,19 +42,18 @@
#include "cow_wow_qt.h"
#include <QLabel>
#include <QMediaPlayer>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QToolBar>
#include <QWheelEvent>
#include <phonon/VideoPlayer>
class XttStreamQtWidget;
class XttStreamQt : public XttStream {
public:
Phonon::VideoPlayer* playbin2; /* Our one and only pipeline */
Phonon::State state; /* Current state of the pipeline */
QMediaPlayer* playbin2; /* Our one and only pipeline */
QMediaPlayer::State state; /* Current state of the pipeline */
pwr_tTime mb_press_time;
int mb_press_x;
int mb_press_y;
......@@ -110,7 +109,7 @@ protected:
public slots:
void slider_cb(int value);
void state_changed_cb(Phonon::State new_state, Phonon::State old_state);
void state_changed_cb(QMediaPlayer::State new_state, QMediaPlayer::State old_state);
void activate_preset_position();
void activate_preset_store_pos();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment