|
Post by bigbass on Jun 18, 2022 0:49:37 GMT 1
here is the browser with some callbacks the url only use something,com without http or www then press the Go button its getting there slowly if anyone can move the two buttons on the right a little more to the left I would be happy I just got tired messing with it have fun Joe updated to clean code in callbacks and fix the return key detection
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QLineEdit> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
'--------------------------------------- SUB urlEdit_cb() '--------------------------------------- PRINT "RETURN PRESSED" view->load(("http://"+urlEdit->text())) END SUB
'--------------------------------------- SUB backButton_cb() '--------------------------------------- view->back() END SUB
'--------------------------------------- SUB forwardButton_cb() '--------------------------------------- view->forward() END SUB
'--------------------------------------- SUB reloadButton_cb() '--------------------------------------- view->reload() END SUB
'--------------------------------------- SUB goButton_cb() '--------------------------------------- view->load(("http://"+urlEdit->text())) END SUB
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* DECLARE mainLayout TYPE QGridLayout* DECLARE backButton TYPE QPushButton* DECLARE forwardButton TYPE QPushButton* DECLARE reloadButton TYPE QPushButton* DECLARE goButton TYPE QPushButton* DECLARE urlEdit TYPE QLineEdit*
app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView() urlEdit = new QLineEdit() mainLayout = new QGridLayout(w) urlEdit->setFixedSize(800, 30) backButton = new QPushButton("Back") forwardButton = new QPushButton("Forward") reloadButton = new QPushButton("Reload") goButton = new QPushButton("GO") mainLayout->addWidget(urlEdit,0,1,1,1,Qt::AlignLeft ) mainLayout->addWidget(backButton,1,1,1,1 ,Qt::AlignLeft) mainLayout->addWidget(forwardButton,2,1,1,1,Qt::AlignLeft) mainLayout->addWidget(reloadButton,1,2,1,1,Qt::AlignCenter) mainLayout->addWidget(goButton,1,3,1,1,Qt::AlignCenter) mainLayout->addWidget(view,5,1,1,1,Qt::AlignLeft) mainLayout->setContentsMargins(10, 10, 10, 10) '---CALLBACKS for SUBS QObject::connect(backButton, &QPushButton::released, backButton_cb) QObject::connect(forwardButton, &QPushButton::released,forwardButton_cb) QObject::connect(reloadButton, &QPushButton::released, reloadButton_cb) QObject::connect(goButton, &QPushButton::released, goButton_cb) QObject::connect(urlEdit, &QLineEdit::returnPressed, urlEdit_cb)
view->load(QUrl("http://bing.com")) view->resize(800, 600 ) w->setWindowTitle("Bacon Qt Browser demo 3") w->show() return app->exec()
|
|
|
Post by vovchik on Jun 18, 2022 11:03:59 GMT 1
Dear Joe, Thanks. It works nicely - I think it will soon be a little qt-bassix. With kind regards, vovchik
|
|
|
Post by bigbass on Jun 18, 2022 14:50:39 GMT 1
hello vovchik a little twist to the browser idea saving screen clutter you can close the viewer it will open or reopen if you press go reduced code again got rid of the messy grid code made a macro to simplify the connect events code and a few more surprise macros just for fun almost like coding for fltk
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QLineEdit> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> <QtWidgets/QHBoxLayout> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
'--------------------------------------- SUB urlEdit_cb() '--------------------------------------- PRINT "RETURN PRESSED" view->load(("http://"+urlEdit->text())) view->show() END SUB
'--------------------------------------- SUB backButton_cb() '--------------------------------------- view->back() view->show() END SUB
'--------------------------------------- SUB forwardButton_cb() '--------------------------------------- view->forward() view->show() END SUB
'--------------------------------------- SUB reloadButton_cb() '--------------------------------------- view->reload() view->show() END SUB
'--------------------------------------- SUB goButton_cb() '--------------------------------------- view->load(("http://"+urlEdit->text())) view->show() END SUB '--- some macros to make coding easier for bacon users '--- Make the callback code easier to remember DEF FN CONNECT( widget, event,cb) = QObject::connect(widget,event,cb) DEF FN DISPLAY() = app->exec() DEF FN SHOW( widget) = (widget)->show() DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* DECLARE Layout TYPE QHBoxLayout* DECLARE backButton TYPE QPushButton* DECLARE forwardButton TYPE QPushButton* DECLARE reloadButton TYPE QPushButton* DECLARE goButton TYPE QPushButton* DECLARE urlEdit TYPE QLineEdit* app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView() urlEdit = new QLineEdit() urlEdit->setFixedSize(600, 30) backButton = new QPushButton("Back") forwardButton = new QPushButton("Forward") reloadButton = new QPushButton("Reload") goButton = new QPushButton("GO") Layout = new QHBoxLayout(w) Layout->setGeometry(QRect(20, 30, 501, 61)) Layout->setSpacing(6) Layout->setContentsMargins(11, 11, 11, 11) Layout->addWidget(urlEdit) Layout->addWidget(backButton) Layout->addWidget(forwardButton) Layout->addWidget(reloadButton) Layout->addWidget(goButton) Layout->addWidget(urlEdit)
'--- CONNECT( widget, event,cb) '--- CALLBACKS for SUBS CONNECT( backButton, &QPushButton::released, backButton_cb) CONNECT(backButton, &QPushButton::released, backButton_cb) CONNECT(forwardButton, &QPushButton::released,forwardButton_cb) CONNECT(reloadButton, &QPushButton::released, reloadButton_cb) CONNECT(goButton, &QPushButton::released, goButton_cb) CONNECT(urlEdit, &QLineEdit::returnPressed, urlEdit_cb)
view->load(QUrl("http://bing.com")) view->resize(800, 600 ) w->setWindowTitle("Bacon Qt Browser demo 5") SHOW(w) DISPLAY
|
|
|
Post by bigbass on Jun 20, 2022 1:14:52 GMT 1
Hello finally got the buttons in order using a hbox idea and absolute positioning macro free for the demo code but you see above how it can be done bacon Qt web page viewer
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QLineEdit> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
'--------------------------------------- SUB urlEdit_cb() '--------------------------------------- PRINT "RETURN PRESSED" view->load(("http://"+urlEdit->text())) END SUB
'--------------------------------------- SUB backButton_cb() '--------------------------------------- view->back() END SUB
'--------------------------------------- SUB forwardButton_cb() '--------------------------------------- view->forward() END SUB
'--------------------------------------- SUB reloadButton_cb() '--------------------------------------- view->reload() END SUB
'--------------------------------------- SUB goButton_cb() '--------------------------------------- view->load(("http://"+urlEdit->text())) END SUB
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* DECLARE Layout TYPE QHBoxLayout* DECLARE backButton TYPE QPushButton* DECLARE forwardButton TYPE QPushButton* DECLARE reloadButton TYPE QPushButton* DECLARE goButton TYPE QPushButton* DECLARE urlEdit TYPE QLineEdit* DECLARE HLayout TYPE QWidget* app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget()
view = new QWebView(w) view->setObjectName(QStringLiteral("view")) view->setGeometry(QRect(10, 90, 800, 590)) view->setUrl(QUrl(QStringLiteral("bing.com")))
urlEdit = new QLineEdit(w) urlEdit->setObjectName(QStringLiteral("urlEdit")) urlEdit->setGeometry(QRect(10, 10, 500, 30)) '---tricky to get working the first time '---horizontalLayoutWidget I shortened to HLayout '---this is needed to keep all the buttons in order as you can see it is '---another QWidget inside the main widget w '---I did this so I could use absolute postioning of the widgets HLayout = new QWidget(w) '--- x y length width of the container HLayout->setGeometry(QRect(10, 30, 501, 61)) Layout = new QHBoxLayout(HLayout) Layout->setSpacing(6) Layout->setContentsMargins(11, 11, 11, 11) Layout->setContentsMargins(0, 0, 0, 0)
'--- more code needed when using a layout manager backButton = new QPushButton("Back",HLayout) Layout->addWidget(backButton) forwardButton = new QPushButton("Forward",HLayout) Layout->addWidget(forwardButton) reloadButton = new QPushButton("Reload",HLayout) Layout->addWidget(reloadButton) goButton = new QPushButton("Go",HLayout) Layout->addWidget(goButton) '---CALLBACKS for SUBS QObject::connect(backButton, &QPushButton::released, backButton_cb) QObject::connect(forwardButton, &QPushButton::released,forwardButton_cb) QObject::connect(reloadButton, &QPushButton::released, reloadButton_cb) QObject::connect(goButton, &QPushButton::released, goButton_cb) QObject::connect(urlEdit, &QLineEdit::returnPressed, urlEdit_cb)
view->load(QUrl("http://bing.com")) w->setWindowTitle("Bacon Qt Browser layout demo") w->resize(800, 500) w->show() return app->exec()
|
|
|
Post by vovchik on Jun 20, 2022 20:32:04 GMT 1
Dear Joe, Thanks and nice work. I have already started using this thing with a cli url argument for very quick and dirty browsing. With kind regards, vovchik
|
|
|
Post by bigbass on Jun 23, 2022 2:22:29 GMT 1
Hello vovchik
thanks glad you can use it a minor but important update open a local file or web page html
P.S I wanted to make an audio and video player and now with the open button I can load images audio and video with a lot less code than writing all those apps separately
Joe
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QLineEdit> <QtWidgets/QFileDialog> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> <QtCore/QDebug> <QtCore/QDir> <QtCore/QDir> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
DEF FN PRINTOUT(x) = qDebug() << (x) '--------------------------------------- SUB urlEdit_cb() '--------------------------------------- PRINT "RETURN PRESSED"
LOCAL bstr TYPE QString bstr = urlEdit->text() PRINTOUT( bstr) view->load(("http://"+urlEdit->text())) END SUB
'--------------------------------------- SUB backButton_cb() '--------------------------------------- view->back() END SUB
'--------------------------------------- SUB forwardButton_cb() '--------------------------------------- view->forward() END SUB
'--------------------------------------- SUB reloadButton_cb() '--------------------------------------- view->reload() END SUB
'--------------------------------------- SUB goButton_cb() '--------------------------------------- view->load(("http://"+urlEdit->text())) END SUB
'--------------------------------------- SUB openFile_cb() '--------------------------------------- LOCAL filename TYPE QString
filename = QFileDialog::getOpenFileName(0,"Open a File","","Local File (*.*)") view->load("file://"+filename) view->show() PRINTOUT(filename) END SUB
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* DECLARE Layout TYPE QHBoxLayout* DECLARE backButton TYPE QPushButton* DECLARE forwardButton TYPE QPushButton* DECLARE reloadButton TYPE QPushButton* DECLARE goButton TYPE QPushButton* DECLARE urlEdit TYPE QLineEdit* DECLARE HLayout TYPE QWidget* DECLARE openButton TYPE QPushButton* app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView(w) view->setObjectName(QStringLiteral("view")) view->setGeometry(QRect(10, 90, 800, 590)) view->setUrl(QUrl(QStringLiteral("bing.com")))
urlEdit = new QLineEdit(w) urlEdit->setObjectName(QStringLiteral("urlEdit")) urlEdit->setGeometry(QRect(10, 10, 500, 30)) '---tricky to get working the first time '---horizontalLayoutWidget I shortened to HLayout '---this is needed to keep all the buttons in order as you can see it is '---another QWidget inside the main widget w '---I did this so I could use absolute postioning of the widgets HLayout = new QWidget(w) '--- x y length width of the container HLayout->setGeometry(QRect(10, 30, 501, 61)) Layout = new QHBoxLayout(HLayout) Layout->setSpacing(6) Layout->setContentsMargins(11, 11, 11, 11) Layout->setContentsMargins(0, 0, 0, 0)
'--- more code needed when using a layout manager backButton = new QPushButton("Back",HLayout) Layout->addWidget(backButton) forwardButton = new QPushButton("Forward",HLayout) Layout->addWidget(forwardButton) reloadButton = new QPushButton("Reload",HLayout) Layout->addWidget(reloadButton) goButton = new QPushButton("Go",HLayout) Layout->addWidget(goButton) '---added an option to open a local file or webpage openButton = new QPushButton("Open...",HLayout) Layout->addWidget(openButton) '---CALLBACKS for SUBS QObject::connect(backButton, &QPushButton::released, backButton_cb) QObject::connect(forwardButton, &QPushButton::released,forwardButton_cb) QObject::connect(reloadButton, &QPushButton::released, reloadButton_cb) QObject::connect(goButton, &QPushButton::released, goButton_cb) QObject::connect(urlEdit, &QLineEdit::returnPressed, urlEdit_cb) QObject::connect(openButton, &QPushButton::released, openFile_cb)
view->load(QUrl("http://bing.com")) w->setWindowTitle("Bacon Qt Browser layout demo2") w->resize(800, 500) w->show() return app->exec()
|
|
|
Post by vovchik on Jun 23, 2022 20:11:15 GMT 1
Dear Joe,
I have noticed that drag and drop works - and I can see pdfs, various graphic files (including svgs), but video does not yet work for me. When loading a little .mov file, I got the sound, but not the video - same with .mp4. I am investigating. But it is great as a versatile viewer, too, not just a web browser. Thanks!
With kind regards, vovchik
|
|
|
Post by bigbass on Jun 23, 2022 22:32:52 GMT 1
Hello vovchik while testing some demos I had to install a few things check if you have all of these then try again for the video gstreamer1.0-plugins-good - GStreamer plugins from the "good" set gstreamer1.0-plugins-bad - GStreamer plugins from the "bad" set gstreamer1.0-plugins-base - GStreamer plugins from the "base" set gstreamer1.0-plugins-ugly - GStreamer plugins from the "ugly" set gstreamer1.0-x - GStreamer plugins for X11 and Pango libqt5multimedia5-plugins - Qt 5 Multimedia module plugins qtgstreamer-plugins-qt5 - GStreamer plugins from QtGStreamer - Qt 5 build I cant remember all I used at the moment but that should do it I dont have PDF view working so I have to look whats missing on my side but good to hear it works found the link for deps for Qt doc.qt.io/qt-5/linux-requirements.html#multimedia-dependenciesJoe
|
|
|
Post by vovchik on Jun 24, 2022 20:29:44 GMT 1
Dear Joe, Thanks. I am looking at all those deps now - on my Pi and on Mint. Incidentally, animated SVGs display nicely. Here is a little example: <svg width='300' height='300' viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' preserveAspectRatio='none'> <g id='yinyang'> <circle id='eye' r='48%' cx='50%' cy='50%' fill='black'/> <g id='left' transform='translate(16 16)'> <path fill='black' d='M103 2C11 26-29 132 24 211c33 47 102 71 144 50 8-4 22-20 27-29 20-42-5-89-52-96-5 0-13-2-16-2-42-6-69-54-55-94 7-19 16-27 41-38 5-3 0-2-10 0z'/> <circle id='eye' r='16' cx='50%' cy='68%' fill='white'/> </g> <g id='right' transform='translate(284 284) scale(-1 -1)'> <path fill='white' d='M103 2C11 26-29 132 24 211c33 47 102 71 144 50 8-4 22-20 27-29 20-42-5-89-52-96-5 0-13-2-16-2-42-6-69-54-55-94 7-19 16-27 41-38 5-3 0-2-10 0z'/> <circle id='eye1' r='16' cx='50%' cy='68%' fill='black'/> </g> <animateTransform attributeName='transform' attributeType='XML' type='rotate' from='360 150 150' to='0 150 150' dur='5s' repeatCount='indefinite'/> </g> </svg>
And I added a few "bells and whistles" here: <svg width='300' height='300' viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'> <defs> <linearGradient id='a'> <stop offset='0' stop-color='lightgray'/> <stop offset='.5' stop-color='darkgray'/> <stop offset='1' stop-color='lightgray' /> </linearGradient> <radialGradient id='b' gradientUnits='objectBoundingBox'> <stop offset='0' stop-color='orange'/> <stop offset='.5' stop-color='lightyellow'/> <stop offset='1' stop-color='orange'/> </radialGradient> <radialGradient id='c' gradientUnits='objectBoundingBox' cx='50%' cy='50%' fx='50%' fy='50%' r='50%'> <stop offset='0' stop-color='gray'/> <stop offset='.5' stop-color='lightgray'/> <stop offset='1' stop-color='darkgray'/> </radialGradient> <radialGradient id='d' gradientUnits='userSpaceOnUse' cx='50%' cy='50%' fx='50%' fy='50%' r='50%'> <stop offset='0' stop-color='azure'/> <stop offset='1' stop-color='black'/> </radialGradient> </defs> <g id='yinyang'> <circle id='eye' r='48%' cx='50%' cy='50%' fill='url(#a)'/> <g id='left' transform='translate(16 16)'> <path fill='url(#d)' d='M103 2C11 26-29 132 24 211c33 47 102 71 144 50 8-4 22-20 27-29 20-42-5-89-52-96-5 0-13-2-16-2-42-6-69-54-55-94 7-19 16-27 41-38 5-3 0-2-10 0z'/> <circle id='eye1' r='16' cx='50%' cy='68%' fill='url(#b)'/> </g> <g id='right' transform='translate(284 284) scale(-1 -1)'> <path fill='url(#b)' d='M103 2C11 26-29 132 24 211c33 47 102 71 144 50 8-4 22-20 27-29 20-42-5-89-52-96-5 0-13-2-16-2-42-6-69-54-55-94 7-19 16-27 41-38 5-3 0-2-10 0z'/> <circle id='eye2' r='16' cx='50%' cy='68%' fill='url(#c)'/> </g> <animateTransform attributeName='transform' attributeType='XML' type='rotate' from='360 150 150' to='0 150 150' dur='5s' repeatCount='indefinite'/> </g> </svg>
They show nicely and the animation is smooth in the tiny browser. With kind regards, vovchik
|
|
|
Post by bigbass on Jun 26, 2022 15:06:27 GMT 1
Hello vovchik they work perfectly for me too and some more good news svgs can be used to replace other image formats inside the Qt widgets thanks for all your work with svgs (I still haven't got PDF's to view and I installed everything but what was needed ) but wont give up will just try again another day Joe
|
|
|
Post by bigbass on Jul 22, 2022 22:20:03 GMT 1
Hello I made many improvements to the qt bacon browser it handles local files dnd drag n drop to the entry and the part that is very interesting is I added bacon syntax highlighting to the webview and believe it or not it was done with javascript since this is a web based browser it was the best option to parse the syntax in real time and I wanted to see how and if it could be done *there is still a problem with loading *.bac but this is because bacon isn't seen as a plain text file in Qt working on that idea still qt-bacon-browser-1.0.tar.gz (156 KB) Joe
|
|
|
Post by vovchik on Jul 23, 2022 0:20:42 GMT 1
Dear Joe,
Very nice. I just tried it on x86_64 Mint, and the binary weighs in at 31k!!!!! Amazing. Thanks. Will try it on Pi tomorrow.
With kind regards, vovchik
|
|
|
Post by bigbass on Jul 23, 2022 1:39:29 GMT 1
Hello vovchik thanks for giving it a try on mint Qt has some nice things that I had avoided for many years I am curious to hear the results on the rpi4 try the "monkey button" for the syntax highlighting test area on the button its hard to make out that its a monkey a short background story thanks to your suggesting the notepadqq I had to use an older version of that with webkit called "notepadqq-legacy-webkit" so that I could build it from source code for the rpi3 and they used codemirror for the syntax that way I new it would work with Qt and started hacking at the javascript part for the vbscript.js to get it to work for bacon so all is well that ends well thanks again Joe
|
|
|
Post by Pjot on Jul 24, 2022 13:11:02 GMT 1
Thanks Joe, I have been playing around with your browser but I can't help noticing it sometimes does not display the full page. For example, this code or this site. Do you know why this happens? BR Peter
|
|
|
Post by bigbass on Jul 24, 2022 17:25:51 GMT 1
Hello Peter thanks for the feedback on the window size problem it is fixed here qt-bacon-browser-1.1.tar.gz (157.63 KB) I also added a theme option for testing it only has two themes to keep the code compact but will add in many more for the full version pasting this in the entry then GO will work now http://www.basic-converter.org/qix.bac.html http://www.basic-converter.org/qix.bac
https://antti-juhani.kaijanaho.fi/agora-basic/
idea theme dracula theme P.S I am working on settings some sites crash and doc.qt.io/qt-5/qurlquery.html#detailsfor the future versions we could filter that data TiPS: (press the monkey button first ) then we can clear the syntax highlighting webview box after drag n drop the *bac into the view and we have real time bacon syntax highlighting thanks to javascript replacing the keywords
|
|