MoeNavigator is an attempt to write a web browser that is highly configurable, secure, anonymous and fast.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

110 lines
2.6 KiB

/*
This file is part of MoeNavigator
Copyright (C) 2012-2019 Moritz Strohm <ncc1988@posteo.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
*/
#include "BrowserTabWidget.h"
BrowserTabWidget::BrowserTabWidget(
QTabWidget* parent,
GUIHandler* gui_handler,
std::string engine_name
)
: QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
this->setSizePolicy(
QSizePolicy::Expanding,
QSizePolicy::Expanding
);
this->setLayout(new QGridLayout());
this->engine = nullptr;
this->engine_name = engine_name;
this->gui_handler = gui_handler;
this->setupEngine();
this->urlText = "";
}
void BrowserTabWidget::setupEngine()
{
if (this->engine != nullptr) {
this->engine = nullptr;
}
if (this->engine_name == "mne") {
this->engine = std::shared_ptr<EngineInterface>(
new EngineInterface_MNE(this)
);
}
//No else here, since no other browser engine is supported at the moment.
if ((this->engine != nullptr) && (this->gui_handler != nullptr)) {
this->engine->setGUIHandler(this->gui_handler);
this->connect(
this->gui_handler,
SIGNAL(TitleChanged(QObject*,QString)),
this,
SLOT(updateTitle(QObject*, QString))
);
}
}
void BrowserTabWidget::setEngine(std::string engine_name)
{
this->engine_name = engine_name;
this->setupEngine();
}
std::string BrowserTabWidget::getEngineName()
{
return this->engine_name;
}
std::shared_ptr<EngineInterface> BrowserTabWidget::getEngine()
{
return this->engine;
}
void BrowserTabWidget::updateTitle(QString new_title)
{
QTabWidget* parent = (QTabWidget*)this->parent();
if (parent != nullptr) {
int index = parent->indexOf(this);
parent->setTabText(index, new_title);
}
}
void BrowserTabWidget::updateTitle(QObject* sender, QString new_title)
{
this->updateTitle(new_title);
}
BrowserTabWidget::~BrowserTabWidget()
{
this->engine = nullptr;
}