From 6b7e13a29dd5e941dd0a6d84f571c26249696dac Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Fri, 7 Dec 2012 15:47:54 +0330 Subject: [PATCH 1/5] Fixed missing 'include' from default-browser commit --- src/lib/preferences/preferences.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 156d6bf3b..9fe1aefba 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -43,6 +43,7 @@ #include "tabbedwebview.h" #include "clearprivatedata.h" #include "useragentdialog.h" +#include "registerqappassociation.h" #include #include From 379f987280a7371aadfd4291572b301150fd7cf3 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Fri, 7 Dec 2012 21:00:50 +0330 Subject: [PATCH 2/5] Fixed: from 'switch to tab' commit. 1- Renew TabPositionRole's data when 'm_lastCompletion == string' 2- Don't switch to current tab, because we don't want clear its locationbar. --- .../completer/locationcompletermodel.cpp | 23 ++++++++++++++++++- .../completer/locationcompletermodel.h | 2 ++ .../completer/locationcompleterview.cpp | 10 +++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/lib/navigation/completer/locationcompletermodel.cpp b/src/lib/navigation/completer/locationcompletermodel.cpp index 88ab9a6fe..7aff40a80 100644 --- a/src/lib/navigation/completer/locationcompletermodel.cpp +++ b/src/lib/navigation/completer/locationcompletermodel.cpp @@ -39,6 +39,7 @@ bool countBiggerThan(const QStandardItem* i1, const QStandardItem* i2) void LocationCompleterModel::refreshCompletions(const QString &string) { if (m_lastCompletion == string) { + refreshTabPositions(); return; } @@ -199,12 +200,17 @@ QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const } TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const +{ + return tabPositionForEncodedUrl(url.toEncoded()); +} + +TabPosition LocationCompleterModel::tabPositionForEncodedUrl(const QString& encodedUrl) const { for(int win=0; win < mApp->windowCount(); ++win) { QupZilla* mainWin = mApp->mainWindows().at(win); QList tabs = mainWin->tabWidget()->allTabs(); for(int tab=0; tab < tabs.count(); ++tab) { - if(tabs[tab]->url() == url) { + if(tabs[tab]->url().toEncoded() == encodedUrl) { TabPosition pos; pos.windowIndex = win; pos.tabIndex = tab; @@ -214,3 +220,18 @@ TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const } return TabPosition(); } + +void LocationCompleterModel::refreshTabPositions() +{ + if (!qzSettings->showSwitchTab) { + return; + } + + for (int row = 0; row < rowCount(); ++row) { + QStandardItem* aItem = item(row); + if (!aItem) { + continue; + } + aItem->setData(QVariant::fromValue(tabPositionForEncodedUrl(aItem->text())), TabPositionRole); + } +} diff --git a/src/lib/navigation/completer/locationcompletermodel.h b/src/lib/navigation/completer/locationcompletermodel.h index d3f046eab..73d497438 100644 --- a/src/lib/navigation/completer/locationcompletermodel.h +++ b/src/lib/navigation/completer/locationcompletermodel.h @@ -62,6 +62,8 @@ private: QSqlQuery createQuery(const QString &searchString, const QString &orderBy, const QList &alreadyFound, int limit, bool bookmarks = false, bool exactMatch = false); TabPosition tabPositionForUrl(const QUrl& url) const; + TabPosition tabPositionForEncodedUrl(const QString& encodedUrl) const; + void refreshTabPositions(); QString m_lastCompletion; }; diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index d178d20eb..e963edf3d 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -269,8 +269,12 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) void LocationCompleterView::activateTab(TabPosition pos) { - emit aboutToActivateTab(pos); QupZilla* win = mApp->mainWindows().at(pos.windowIndex); - win->activateWindow(); - win->tabWidget()->setCurrentIndex(pos.tabIndex); + if (mApp->getWindow() != win || mApp->getWindow()->tabWidget()->currentIndex() != pos.tabIndex) { + emit aboutToActivateTab(pos); + win->tabWidget()->setCurrentIndex(pos.tabIndex); + win->show(); + win->activateWindow(); + win->raise(); + } } From efebfb8148f1649e06f527a694cd9716a00e3763 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 8 Dec 2012 01:53:26 +0330 Subject: [PATCH 3/5] Fixed bugs 'switch to tab' switch to another window. -see #665 --- src/lib/navigation/completer/locationcompleterview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index e963edf3d..58164630d 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -74,8 +74,8 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event) if(idx.isValid()) { TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value(); if(pos.windowIndex!= -1) { - activateTab(pos); close(); + activateTab(pos); return true; } } @@ -255,8 +255,8 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) TabPosition pos = m_hoveredIndex.data(LocationCompleterModel::TabPositionRole).value(); if(pos.windowIndex != -1) { event->accept(); - activateTab(pos); close(); + activateTab(pos); } else { QListView::mouseReleaseEvent(event); From 234769e9208e1272af16002a39b2fbf48dda89ae Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 8 Dec 2012 02:04:38 +0330 Subject: [PATCH 4/5] Now 'switch to tab' searches current window first. -by ff2000, thank you :) --- src/lib/navigation/completer/locationcompletermodel.cpp | 9 ++++++--- src/lib/navigation/completer/locationcompleterview.cpp | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/navigation/completer/locationcompletermodel.cpp b/src/lib/navigation/completer/locationcompletermodel.cpp index 7aff40a80..869a0f65f 100644 --- a/src/lib/navigation/completer/locationcompletermodel.cpp +++ b/src/lib/navigation/completer/locationcompletermodel.cpp @@ -206,13 +206,16 @@ TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const TabPosition LocationCompleterModel::tabPositionForEncodedUrl(const QString& encodedUrl) const { - for(int win=0; win < mApp->windowCount(); ++win) { - QupZilla* mainWin = mApp->mainWindows().at(win); + QList windows = mApp->mainWindows(); + int currentWindowIdx = windows.indexOf(mApp->getWindow()); + windows.prepend(mApp->getWindow()); + for(int win=0; win < windows.count(); ++win) { + QupZilla* mainWin = windows.at(win); QList tabs = mainWin->tabWidget()->allTabs(); for(int tab=0; tab < tabs.count(); ++tab) { if(tabs[tab]->url().toEncoded() == encodedUrl) { TabPosition pos; - pos.windowIndex = win; + pos.windowIndex = win == 0 ? currentWindowIdx : win-1; pos.tabIndex = tab; return pos; } diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index 58164630d..01af2e2e5 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -23,6 +23,7 @@ #include "history.h" #include "tabwidget.h" #include "qzsettings.h" +#include "tabbedwebview.h" #include #include @@ -277,4 +278,7 @@ void LocationCompleterView::activateTab(TabPosition pos) win->activateWindow(); win->raise(); } + else { + win->weView()->setFocus(); + } } From 6191a76be643d1d568eda8db7c354e5532231879 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 8 Dec 2012 02:19:12 +0330 Subject: [PATCH 5/5] Fixed: issue from last commit that doesn't clear locationbar. --- src/lib/navigation/completer/locationcompleterview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index 01af2e2e5..7e8261138 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -75,7 +75,6 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event) if(idx.isValid()) { TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value(); if(pos.windowIndex!= -1) { - close(); activateTab(pos); return true; } @@ -256,7 +255,6 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) TabPosition pos = m_hoveredIndex.data(LocationCompleterModel::TabPositionRole).value(); if(pos.windowIndex != -1) { event->accept(); - close(); activateTab(pos); } else { @@ -273,12 +271,14 @@ void LocationCompleterView::activateTab(TabPosition pos) QupZilla* win = mApp->mainWindows().at(pos.windowIndex); if (mApp->getWindow() != win || mApp->getWindow()->tabWidget()->currentIndex() != pos.tabIndex) { emit aboutToActivateTab(pos); + close(); win->tabWidget()->setCurrentIndex(pos.tabIndex); win->show(); win->activateWindow(); win->raise(); } else { + close(); win->weView()->setFocus(); } }