Claudio Valerio 13 years ago
parent d16520d141
commit e6a2b41904
  1. 25
      src/web/browser/WBBrowserWindow.cpp
  2. 77
      src/web/browser/WBTabWidget.cpp
  3. 2
      src/web/browser/WBTabWidget.h

@ -85,15 +85,12 @@ WBHistoryManager *WBBrowserWindow::sHistoryManager = 0;
WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow, bool isViewerWebInstance) WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWindow, bool isViewerWebInstance)
: QWidget(parent) : QWidget(parent)
, mWebToolBar(0)
, mSearchToolBar(0) , mSearchToolBar(0)
, mTabWidget(new WBTabWidget(this)) , mTabWidget(new WBTabWidget(this))
, mSearchAction(0) , mSearchAction(0)
, mUniboardMainWindow(uniboardMainWindow) , mUniboardMainWindow(uniboardMainWindow)
, mWebToolBar(0)
{ {
qDebug() << "Height: " << this->height();
qDebug() << "width: " << this->width();
QWebSettings *defaultSettings = QWebSettings::globalSettings(); QWebSettings *defaultSettings = QWebSettings::globalSettings();
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true); defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true); defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
@ -110,8 +107,7 @@ WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWi
this->setLayout(layout); this->setLayout(layout);
connect(mTabWidget, SIGNAL(loadPage(const QString &)), connect(mTabWidget, SIGNAL(loadPage(const QString &)), this, SLOT(loadPage(const QString &)));
this, SLOT(loadPage(const QString &)));
connect(mTabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); connect(mTabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &)));
@ -122,12 +118,7 @@ WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWi
connect(mTabWidget, SIGNAL(loadFinished(bool)), this, SIGNAL(activeViewPageChanged())); connect(mTabWidget, SIGNAL(loadFinished(bool)), this, SIGNAL(activeViewPageChanged()));
connect(mTabWidget, SIGNAL(lastTabClosed()), connect(mTabWidget, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &)));
mTabWidget, SLOT(newTab()));
connect(mTabWidget, SIGNAL(geometryChangeRequested(const QRect &)),
this, SLOT(geometryChangeRequested(const QRect &)));
slotUpdateWindowTitle(); slotUpdateWindowTitle();
@ -141,7 +132,15 @@ WBBrowserWindow::WBBrowserWindow(QWidget *parent, Ui::MainWindow* uniboardMainWi
WBBrowserWindow::~WBBrowserWindow() WBBrowserWindow::~WBBrowserWindow()
{ {
// NOOP if(mTabWidget){
delete mTabWidget;
mTabWidget = NULL;
}
if(mSearchToolBar){
delete mSearchToolBar;
mSearchToolBar = NULL;
}
} }

@ -87,8 +87,7 @@ WBTabBar::WBTabBar(QWidget *parent)
connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction()));
} }
setTabsClosable(true); setTabsClosable(true);
connect(this, SIGNAL(tabCloseRequested(int)), connect(this, SIGNAL(tabCloseRequested(int)), this, SIGNAL(closeTab(int)));
this, SIGNAL(closeTab(int)));
setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
setMovable(true); setMovable(true);
setDocumentMode(false); setDocumentMode(false);
@ -116,26 +115,23 @@ void WBTabBar::contextMenuRequested(const QPoint &position)
menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab);
int index = tabAt(position); int index = tabAt(position);
if (-1 != index) { if (-1 != index) {
QAction *action = menu.addAction(tr("Clone Tab"), QAction *action = menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()));
this, SLOT(cloneTab()));
action->setData(index); action->setData(index);
menu.addSeparator(); menu.addSeparator();
action = menu.addAction(tr("&Close Tab"), action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close);
this, SLOT(closeTab()), QKeySequence::Close);
action->setData(index); action->setData(index);
action = menu.addAction(tr("Close &Other Tabs"), action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs()));
this, SLOT(closeOtherTabs()));
action->setData(index); action->setData(index);
menu.addSeparator(); menu.addSeparator();
action = menu.addAction(tr("Reload Tab"), action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh);
this, SLOT(reloadTab()), QKeySequence::Refresh);
action->setData(index); action->setData(index);
} else { }
else {
menu.addSeparator(); menu.addSeparator();
} }
menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs()));
@ -412,45 +408,30 @@ WBWebView *WBTabWidget::newTab(bool makeCurrent)
p.setColor(QPalette::Window, palette().color(QPalette::Base)); p.setColor(QPalette::Window, palette().color(QPalette::Base));
emptyWidget->setPalette(p); emptyWidget->setPalette(p);
emptyWidget->setAutoFillBackground(true); emptyWidget->setAutoFillBackground(true);
disconnect(this, SIGNAL(currentChanged(int)), disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
this, SLOT(currentChanged(int)));
addTab(emptyWidget, tr("(Untitled)")); addTab(emptyWidget, tr("(Untitled)"));
connect(this, SIGNAL(currentChanged(int)), connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
this, SLOT(currentChanged(int)));
return 0; return 0;
} }
// webview // webview
WBWebView *webView = new WBWebView; WBWebView *webView = new WBWebView;
urlLineEdit->setWebView(webView); urlLineEdit->setWebView(webView);
connect(webView, SIGNAL(loadStarted()), connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
this, SLOT(webViewLoadStarted())); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged()));
connect(webView, SIGNAL(loadFinished(bool)), connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged()));
this, SLOT(webViewIconChanged())); connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
connect(webView, SIGNAL(iconChanged()), connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &)));
this, SLOT(webViewIconChanged())); connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
connect(webView, SIGNAL(titleChanged(const QString &)), connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &)));
this, SLOT(webViewTitleChanged(const QString &))); connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *)));
connect(webView, SIGNAL(urlChanged(const QUrl &)), connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
this, SLOT(webViewUrlChanged(const QUrl &))); connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
connect(webView->page(), SIGNAL(windowCloseRequested()), connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
this, SLOT(windowCloseRequested()));
connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), connect(webView, SIGNAL(pixmapCaptured(const QPixmap&, bool)), UBApplication::applicationController, SLOT(addCapturedPixmap(const QPixmap &, bool)));
this, SIGNAL(geometryChangeRequested(const QRect &)));
connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), connect(webView, SIGNAL(embedCodeCaptured(const QString&)), UBApplication::applicationController, SLOT(addCapturedEmbedCode(const QString&)));
this, SIGNAL(printRequested(QWebFrame *)));
connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)),
this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
connect(webView, SIGNAL(pixmapCaptured(const QPixmap&, bool)),
UBApplication::applicationController, SLOT(addCapturedPixmap(const QPixmap &, bool)));
connect(webView, SIGNAL(embedCodeCaptured(const QString&)),
UBApplication::applicationController, SLOT(addCapturedEmbedCode(const QString&)));
addTab(webView, tr("(Untitled)")); addTab(webView, tr("(Untitled)"));
if (makeCurrent) if (makeCurrent)
@ -465,7 +446,6 @@ WBWebView *WBTabWidget::newTab(bool makeCurrent)
if (count() == 1) if (count() == 1)
currentChanged(currentIndex()); currentChanged(currentIndex());
emit tabsChanged();
return webView; return webView;
} }
@ -553,13 +533,13 @@ void WBTabWidget::closeTab(int index)
removeTab(index); removeTab(index);
webView->deleteLater(); webView->deleteLater();
emit tabsChanged();
if (hasFocus && count() > 0) if (hasFocus && count() > 0)
currentWebView()->setFocus(); currentWebView()->setFocus();
if (count() == 0) if (count() == 0){
emit lastTabClosed(); newTab();
emit currentChanged(0);
}
} }
void WBTabWidget::webViewLoadStarted() void WBTabWidget::webViewLoadStarted()
@ -616,7 +596,6 @@ void WBTabWidget::webViewUrlChanged(const QUrl &url)
{ {
mTabBar->setTabData(index, url); mTabBar->setTabData(index, url);
} }
emit tabsChanged();
// web view does not reload sometime on OSX ... force it // web view does not reload sometime on OSX ... force it
webView->show(); webView->show();

@ -143,8 +143,6 @@ class WBTabWidget : public QTabWidget
signals: signals:
// tab widget signals // tab widget signals
void loadPage(const QString &url); void loadPage(const QString &url);
void tabsChanged();
void lastTabClosed();
// current tab signals // current tab signals
void setCurrentTitle(const QString &url); void setCurrentTitle(const QString &url);

Loading…
Cancel
Save