~zeller-benjamin/qtcreator-plugin-ubuntu/qtc41-beta

« back to all changes in this revision

Viewing changes to src/ubuntu/ubuntuwebmode.cpp

  • Committer: Juhapekka Piiroinen
  • Date: 2013-09-04 15:30:00 UTC
  • mto: (23.1.14 binary-plugin)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: juhapekka.piiroinen@canonical.com-20130904153000-r4lhfhrjlwmop277
Added cordova plugin from ubuntu-qtcreator-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
 
17
 */
 
18
 
 
19
#include "ubuntuwebmode.h"
 
20
#include "ubuntuconstants.h"
 
21
 
 
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>
 
32
#include <QFile>
 
33
 
 
34
using namespace Ubuntu::Internal;
 
35
 
 
36
UbuntuWebMode::UbuntuWebMode(QObject *parent) :
 
37
    Core::IMode(parent)
 
38
{
 
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));
 
44
 
 
45
    QVBoxLayout *layout = new QVBoxLayout;
 
46
    layout->setMargin(0);
 
47
    layout->setSpacing(0);
 
48
    m_modeWidget.setLayout(layout);
 
49
 
 
50
    connect(&m_webView,SIGNAL(urlChanged(QUrl)),SLOT(updateAddress(QUrl)));
 
51
    connect(&m_addressBar,SIGNAL(returnPressed()),SLOT(goToAddress()));
 
52
 
 
53
 
 
54
    Utils::StyledBar* styledBar = new Utils::StyledBar(&m_modeWidget);
 
55
    //layout->addWidget(styledBar);
 
56
 
 
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);
 
63
 
 
64
    connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
 
65
 
 
66
    m_webView.setFocus();
 
67
    setWidget(&m_modeWidget);
 
68
}
 
69
 
 
70
void UbuntuWebMode::updateAddress(QUrl url) {
 
71
    m_addressBar.setText(url.toString());
 
72
}
 
73
 
 
74
void UbuntuWebMode::goToAddress() {
 
75
    m_webView.setUrl(QUrl::fromUserInput(m_addressBar.text()));
 
76
}
 
77
 
 
78
void UbuntuWebMode::initialize() {
 
79
 
 
80
}
 
81
 
 
82
void UbuntuWebMode::modeChanged(Core::IMode*) {
 
83
 
 
84
}
 
85