2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2.1.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
19
#include "ubuntuwebmode.h"
20
#include "ubuntuconstants.h"
22
#include <coreplugin/modemanager.h>
23
#include <coreplugin/editormanager/editormanager.h>
24
#include <coreplugin/dialogs/iwizard.h>
25
#include <coreplugin/coreconstants.h>
26
#include <projectexplorer/projectexplorer.h>
27
#include <coreplugin/icore.h>
28
#include <coreplugin/imode.h>
29
#include <utils/styledbar.h>
30
#include <QVBoxLayout>
31
#include <QScrollArea>
34
using namespace Ubuntu::Internal;
36
UbuntuWebMode::UbuntuWebMode(QObject *parent) :
39
setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_WEB_DISPLAYNAME));
40
setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_WEB_ICON)));
41
setPriority(Ubuntu::Constants::UBUNTU_MODE_WEB_PRIORITY);
42
setId(Ubuntu::Constants::UBUNTU_MODE_WEB);
43
setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_WEB));
45
QVBoxLayout *layout = new QVBoxLayout;
47
layout->setSpacing(0);
48
m_modeWidget.setLayout(layout);
50
connect(&m_webView,SIGNAL(urlChanged(QUrl)),SLOT(updateAddress(QUrl)));
51
connect(&m_addressBar,SIGNAL(returnPressed()),SLOT(goToAddress()));
54
Utils::StyledBar* styledBar = new Utils::StyledBar(&m_modeWidget);
55
//layout->addWidget(styledBar);
57
QScrollArea *scrollArea = new QScrollArea(&m_modeWidget);
58
scrollArea->setFrameShape(QFrame::NoFrame);
59
layout->addWidget(scrollArea);
60
layout->addWidget(&m_addressBar);
61
scrollArea->setWidget(&m_webView);
62
scrollArea->setWidgetResizable(true);
64
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
67
setWidget(&m_modeWidget);
70
void UbuntuWebMode::updateAddress(QUrl url) {
71
m_addressBar.setText(url.toString());
74
void UbuntuWebMode::goToAddress() {
75
m_webView.setUrl(QUrl::fromUserInput(m_addressBar.text()));
78
void UbuntuWebMode::initialize() {
82
void UbuntuWebMode::modeChanged(Core::IMode*) {