From a14b8789732b23078628b03aa0c9b23c4f39fba6 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Fri, 9 Feb 2024 17:38:32 -0500 Subject: [PATCH] 2024-02-09 Fred Gleason * Added a 'RDEventFilter' class. * Fixed bugs in rdairplay(1) that caused scroll bars to appear when loading web content into the message widget. Signed-off-by: Fred Gleason --- ChangeLog | 4 +++ configure.ac | 2 +- lib/Makefile.am | 2 ++ lib/librd.pro | 2 ++ lib/rdeventfilter.cpp | 59 +++++++++++++++++++++++++++++++++++++ lib/rdeventfilter.h | 40 +++++++++++++++++++++++++ rdairplay/Makefile.am | 4 +-- rdairplay/messagewidget.cpp | 28 ++++++++++++++++++ rdairplay/messagewidget.h | 3 ++ 9 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 lib/rdeventfilter.cpp create mode 100644 lib/rdeventfilter.h diff --git a/ChangeLog b/ChangeLog index 0a00cc38..01874b29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24654,3 +24654,7 @@ system was configured to use 12 hour time format. 2024-02-08 Fred Gleason * Implemented the 'Load Message" ['LM'] RML. +2024-02-09 Fred Gleason + * Added a 'RDEventFilter' class. + * Fixed bugs in rdairplay(1) that caused scroll bars to appear when + loading web content into the message widget. diff --git a/configure.ac b/configure.ac index 0007e54b..5baf1ee5 100644 --- a/configure.ac +++ b/configure.ac @@ -93,7 +93,7 @@ AC_ARG_ENABLE(i18n-updates,[ --enable-i18n-updates enable I18N metadata updat # # Check for Qt5 (Mandatory) # -PKG_CHECK_MODULES(QT5,Qt5Core Qt5Widgets Qt5Gui Qt5Network Qt5Sql Qt5Xml Qt5WebKit,,[AC_MSG_ERROR([*** Qt5 not found ***])]) +PKG_CHECK_MODULES(QT5,Qt5Core Qt5Widgets Qt5Gui Qt5Network Qt5Sql Qt5Xml Qt5WebKitWidgets,,[AC_MSG_ERROR([*** Qt5 not found ***])]) PKG_CHECK_MODULES(QT5_CLI,Qt5Core Qt5Network Qt5Sql Qt5Xml,,[AC_MSG_ERROR([*** Qt5 not found ***])]) AC_CHECK_PROG(MOC_NAME,moc-qt5,[moc-qt5],[moc]) AC_SUBST(QT_MOC,$MOC_NAME) diff --git a/lib/Makefile.am b/lib/Makefile.am index 6f383659..638b37ec 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -132,6 +132,7 @@ dist_librd_la_SOURCES = dbversion.h\ rdevent.cpp rdevent.h\ rdevent_line.cpp rdevent_line.h\ rdevent_player.cpp rdevent_player.h\ + rdeventfilter.cpp rdeventfilter.h\ rdeventimportlist.cpp rdeventimportlist.h\ rdexport_settings_dialog.cpp rdexport_settings_dialog.h\ rdfeed.cpp rdfeed.h\ @@ -344,6 +345,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\ moc_rdemptycart.cpp\ moc_rdendpointlistmodel.cpp\ moc_rdevent_player.cpp\ + moc_rdeventfilter.cpp\ moc_rdexport_settings_dialog.cpp\ moc_rdfeed.cpp\ moc_rdfeedlistmodel.cpp\ diff --git a/lib/librd.pro b/lib/librd.pro index 0a51f834..158a2bfb 100644 --- a/lib/librd.pro +++ b/lib/librd.pro @@ -102,6 +102,7 @@ SOURCES += rdescape_string.cpp SOURCES += rdevent.cpp SOURCES += rdevent_line.cpp SOURCES += rdeventimportlist.cpp +SOURCES += rdeventfilter.cpp SOURCES += rdexport_settings_dialog.cpp SOURCES += rdfeedlistmodel.cpp SOURCES += rdfontengine.cpp @@ -292,6 +293,7 @@ HEADERS += rdendpointlistmodel.h HEADERS += rdescape_string.h HEADERS += rdevent.h HEADERS += rdevent_line.h +HEADERS += rdeventfilter.h HEADERS += rdeventimportlist.h HEADERS += rdexport_settings_dialog.h HEADERS += rdfeedlistmodel.h diff --git a/lib/rdeventfilter.cpp b/lib/rdeventfilter.cpp new file mode 100644 index 00000000..1e1110b1 --- /dev/null +++ b/lib/rdeventfilter.cpp @@ -0,0 +1,59 @@ +// rdeventfilter.cpp +// +// Filter one or more window system events +// +// (C) Copyright 2024 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include + +#include + +#include "rdeventfilter.h" + +RDEventFilter::RDEventFilter(QObject *parent) +{ +} + + +QList RDEventFilter::filterList() const +{ + return d_filter_types; +} + + +void RDEventFilter::addFilter(QEvent::Type type) +{ + if(!d_filter_types.contains(type)) { + d_filter_types.push_back(type); + } +} + + +void RDEventFilter::removeFilter(QEvent::Type type) +{ + d_filter_types.removeAll(type); +} + + +bool RDEventFilter::eventFilter(QObject *obj,QEvent *e) +{ + if(d_filter_types.contains(e->type())) { + // Block it + return true; + } + return QObject::eventFilter(obj,e); +} diff --git a/lib/rdeventfilter.h b/lib/rdeventfilter.h new file mode 100644 index 00000000..558bff89 --- /dev/null +++ b/lib/rdeventfilter.h @@ -0,0 +1,40 @@ +// rdeventfilter.h +// +// Filter one or more window system events +// +// (C) Copyright 2024 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef RDEVENTFILTER_H +#define RDEVENTFILTER_H + +#include +#include + +class RDEventFilter : public QObject +{ + public: + RDEventFilter(QObject *parent); + QList filterList() const; + void addFilter(QEvent::Type type); + void removeFilter(QEvent::Type type); + + protected: + bool eventFilter(QObject *obj,QEvent *e) override; + QList d_filter_types; +}; + +#endif // RDEVENTFILTER_H diff --git a/rdairplay/Makefile.am b/rdairplay/Makefile.am index 0f498008..5c95c333 100644 --- a/rdairplay/Makefile.am +++ b/rdairplay/Makefile.am @@ -20,7 +20,7 @@ ## ## Use automake to process this into a Makefile.in -AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -I$(top_srcdir)/lib -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ -I/usr/include/qt5/QtWebKitWidgets @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@ +AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -I$(top_srcdir)/lib -Wno-strict-aliasing -std=c++11 -fPIC @QT5_CFLAGS@ @MUSICBRAINZ_CFLAGS@ @IMAGEMAGICK_CFLAGS@ LIBS = -L$(top_srcdir)/lib MOC = @QT_MOC@ @@ -82,7 +82,7 @@ nodist_rdairplay_SOURCES = moc_button_log.cpp\ moc_voicetracker.cpp\ moc_wall_clock.cpp -rdairplay_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ -lQt5WebKitWidgets +rdairplay_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT5_LIBS@ @MUSICBRAINZ_LIBS@ @IMAGEMAGICK_LIBS@ rdairplay_LDFLAGS = -rdynamic EXTRA_DIST = rdairplay.pro\ diff --git a/rdairplay/messagewidget.cpp b/rdairplay/messagewidget.cpp index 61a5c1b7..1e2e5334 100644 --- a/rdairplay/messagewidget.cpp +++ b/rdairplay/messagewidget.cpp @@ -18,6 +18,12 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // +#include +#include +#include + +#include + #include "colors.h" #include "messagewidget.h" @@ -43,7 +49,20 @@ MessageWidget::MessageWidget(QWidget *parent) d_label->setWordWrap(true); d_label->setAlignment(Qt::AlignCenter); d_view=new QWebView(this); + connect(d_view,SIGNAL(loadFinished(bool)), + this,SLOT(webLoadFinishedData(bool))); d_view->hide(); + RDEventFilter *filter=new RDEventFilter(this); + filter->addFilter(QEvent::Enter); + filter->addFilter(QEvent::Leave); + filter->addFilter(QEvent::KeyPress); + filter->addFilter(QEvent::KeyRelease); + filter->addFilter(QEvent::MouseButtonPress); + filter->addFilter(QEvent::MouseButtonRelease); + filter->addFilter(QEvent::MouseButtonDblClick); + filter->addFilter(QEvent::MouseMove); + filter->addFilter(QEvent::Wheel); + d_view->installEventFilter(filter); } @@ -91,6 +110,15 @@ void MessageWidget::clear() } +void MessageWidget::webLoadFinishedData(bool state) +{ + d_view->page()->mainFrame()-> + setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); + d_view->page()->mainFrame()-> + setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); +} + + void MessageWidget::resizeEvent(QResizeEvent *e) { d_label->setGeometry(0,0,size().width(),size().height()); diff --git a/rdairplay/messagewidget.h b/rdairplay/messagewidget.h index 00216a13..88a49ab6 100644 --- a/rdairplay/messagewidget.h +++ b/rdairplay/messagewidget.h @@ -36,6 +36,9 @@ class MessageWidget : public QWidget bool setUrl(const QString &url); void clear(); + private slots: + void webLoadFinishedData(bool state); + protected: void resizeEvent(QResizeEvent *e);