Skip to content

Commit

Permalink
Implement createWindow() allowing creation of windows from ctrl-click…
Browse files Browse the repository at this point in the history
…s and context menu 'Open in new window' action.
  • Loading branch information
Krzysztof Zych committed Oct 3, 2014
1 parent a40d15c commit 1248cad
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion zeal/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class MainWindow : public QMainWindow
~MainWindow();
void bringToFrontAndSearch(const QString);
bool startHidden();
void createTab();

private:
void bringToFront(bool withHack);
void displayViewActions();
void loadSections(const QString docsetName, const QUrl &url);
void setupSearchBoxCompletions();
void createTab();
void reloadTabState();
void displayTabs();
void updateTreeView(QString text);
Expand Down
3 changes: 2 additions & 1 deletion zeal/widgets/searchablewebview.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QWebView>
#include <QWebSettings>
#include "zealwebview.h"
#include "../lineedit.h"

class SearchableWebView : public QWidget
Expand Down Expand Up @@ -34,7 +35,7 @@ public slots:

private:
LineEdit lineEdit;
QWebView webView;
ZealWebView webView;
QString searchText;
void moveLineEdit();
};
Expand Down
6 changes: 4 additions & 2 deletions zeal/widgets/widgets.pri
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
HEADERS += widgets/searchablewebview.h \
widgets/zealsearchedit.h \
widgets/razorshortcutbutton.h \
widgets/razorshortcutbutton_p.h
widgets/razorshortcutbutton_p.h \
widgets/zealwebview.h

SOURCES += widgets/searchablewebview.cpp \
widgets/zealsearchedit.cpp \
widgets/razorshortcutbutton.cpp
widgets/razorshortcutbutton.cpp \
widgets/zealwebview.cpp
12 changes: 12 additions & 0 deletions zeal/widgets/zealwebview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "zealwebview.h"
#include "../mainwindow.h"

ZealWebView::ZealWebView(QWidget *parent) : QWebView(parent) {};

QWebView *ZealWebView::createWindow(QWebPage::WebWindowType type) {
Q_UNUSED(type)

MainWindow *mw = qobject_cast<MainWindow *>(qApp->activeWindow());
mw->createTab();
return this;
}
22 changes: 22 additions & 0 deletions zeal/widgets/zealwebview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef ZEALWEBVIEW_H
#define ZEALWEBVIEW_H

#include <QWebView>

// Subclass QWebView so we can override createWindow
class ZealWebView : public QWebView
{
Q_OBJECT
public:
explicit ZealWebView(QWidget *parent = 0);

protected:
virtual QWebView *createWindow(QWebPage::WebWindowType type);

signals:

public slots:

};

#endif // ZEALWEBVIEW_H

0 comments on commit 1248cad

Please sign in to comment.