-
Notifications
You must be signed in to change notification settings - Fork 2
/
tab.cpp
executable file
·53 lines (53 loc) · 1.41 KB
/
tab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "tab.h"
tab::tab(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout * layout = new QVBoxLayout(this);
locationbar = new QLineEdit();
searchbar = new QLineEdit();
searchbar->setFixedWidth(300);
toparea = new QWidget();
QHBoxLayout * toplayout = new QHBoxLayout(toparea);
toplayout->addWidget(locationbar);
toplayout->addWidget(searchbar);
layout->addWidget(toparea);
view = new webview(this);
layout->addWidget(view);
QObject::connect(locationbar , SIGNAL(returnPressed()) , this , SLOT(loadadress()));
QObject::connect(searchbar , SIGNAL(returnPressed()) , this , SLOT(search()));
QObject::connect(view ,SIGNAL(urlChanged(QUrl)) , this , SLOT(updatelocation(QUrl)));
QObject::connect(view , SIGNAL(linkinnewtab(QString)) , parent , SLOT(newtab(QString)));
}
void tab::loadadress(QString url)
{
view->load(QUrl(url));
}
void tab::search(QString url)
{
view->load(QUrl(("https://www.google.com/search?q=") + url));
}
void tab::loadadress()
{
QString url = locationbar->text();
if(url.isEmpty()) return;
loadadress(url);
}
void tab::search()
{
QString query = searchbar->text();
if(query.isEmpty()) return;
search(query);
}
QWidget * tab::returnwidget()
{
return this;
}
void tab::updatelocation(QUrl url)
{
locationbar->setText(url.toString());
}
void tab::webinspector()
{
QWebInspector * webi = new QWebInspector(this);
this->show();
}