85 lines
2.1 KiB
C++
85 lines
2.1 KiB
C++
#include "WebBrowserPlugin.h"
|
|
#include <QVBoxLayout>
|
|
#include <QWidget>
|
|
|
|
QString WebBrowserPlugin::pname()
|
|
{
|
|
return "Web Browser Plugin";
|
|
}
|
|
|
|
QString WebBrowserPlugin::pdesc()
|
|
{
|
|
return "Simple Web Browser Plugin.";
|
|
}
|
|
|
|
QWidget* WebBrowserPlugin::pcontent()
|
|
{
|
|
QWidget *test = new QWidget();
|
|
test->setWindowTitle(tr("Web Browser Plugin"));
|
|
test->resize(1024, 750);
|
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
|
|
view = new QWebEngineView(test);
|
|
view->setUrl(QUrl("https://rubenwardy.com/minetest_modding_book/en/index.html"));
|
|
view->resize(1024, 750);
|
|
|
|
horizontalGroupBox = new QGroupBox();
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
back = new QPushButton(tr("Back"));
|
|
layout->addWidget(back);
|
|
connect(back, &QPushButton::clicked, this, &WebBrowserPlugin::backpage);
|
|
|
|
forward = new QPushButton(tr("Forward"));
|
|
layout->addWidget(forward);
|
|
connect(forward, &QPushButton::clicked, this, &WebBrowserPlugin::forwardpage);
|
|
|
|
refresh = new QPushButton(tr("Refresh"));
|
|
layout->addWidget(refresh);
|
|
connect(refresh, &QPushButton::clicked, this, &WebBrowserPlugin::refreshpage);
|
|
|
|
smallEditor = new QLineEdit;
|
|
layout->addWidget(smallEditor);
|
|
smallEditor->setText("https://rubenwardy.com/minetest_modding_book/en/index.html");
|
|
|
|
go = new QPushButton(tr("Go"));
|
|
layout->addWidget(go);
|
|
connect(go, &QPushButton::clicked, this, &WebBrowserPlugin::gotourl);
|
|
|
|
horizontalGroupBox->setLayout(layout);
|
|
|
|
|
|
mainLayout->addWidget(horizontalGroupBox);
|
|
mainLayout->addWidget(view,1);
|
|
test->setLayout(mainLayout);
|
|
|
|
QIcon icon = QIcon(":/images/monkey.png");
|
|
test->setWindowIcon(icon);
|
|
return test;
|
|
}
|
|
|
|
void WebBrowserPlugin::gotourl()
|
|
{
|
|
view->setUrl(QUrl(smallEditor->text()));
|
|
}
|
|
|
|
void WebBrowserPlugin::refreshpage()
|
|
{
|
|
view->reload();
|
|
}
|
|
|
|
void WebBrowserPlugin::backpage()
|
|
{
|
|
view->back();
|
|
}
|
|
|
|
void WebBrowserPlugin::forwardpage()
|
|
{
|
|
view->forward();
|
|
}
|
|
|
|
void WebBrowserPlugin::connectToHost(QObject* host)
|
|
{
|
|
Q_UNUSED(host);
|
|
// Calculator plugin doesn't need host signals
|
|
}
|