Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Move window selection logic into WebPage
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoran committed May 30, 2012
1 parent aaba4d1 commit 33bc195
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,10 @@ QString WebPage::getWindowName() {
else
return "";
}

bool WebPage::matchesWindowSelector(QString selector) {
return (selector == getWindowName() ||
selector == mainFrame()->title() ||
selector == mainFrame()->url().toString() ||
selector == uuid());
}
1 change: 1 addition & 0 deletions src/WebPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class WebPage : public QWebPage {
QWebPage *createWindow(WebWindowType type);
QString uuid();
QString getWindowName();
bool matchesWindowSelector(QString);

public slots:
bool shouldInterruptJavaScript();
Expand Down
5 changes: 1 addition & 4 deletions src/WindowFocus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ void WindowFocus::focusWindow(QString selector) {
while (pageIterator.hasNext()) {
WebPage *page = pageIterator.next();

if (selector == page->getWindowName() ||
selector == page->mainFrame()->title() ||
selector == page->mainFrame()->url().toString() ||
selector == page->uuid()) {
if (page->matchesWindowSelector(selector)) {
success(page);
return;
}
Expand Down

0 comments on commit 33bc195

Please sign in to comment.