Implement Plugin Loading.
This commit adds plugin laoding which are then added as sub winows onto the main window. This commit also adds 2 plugins however more will follow
This commit is contained in:
78
plugins/WebBrowserPlugin/WebBrowserPlugin.cpp
Normal file
78
plugins/WebBrowserPlugin/WebBrowserPlugin.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#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();
|
||||
}
|
||||
Reference in New Issue
Block a user