mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Merge pull request #665 from srazi/master
Fixed: from 'switch to tab' commit.
This commit is contained in:
commit
f30092e7e2
@ -39,6 +39,7 @@ bool countBiggerThan(const QStandardItem* i1, const QStandardItem* i2)
|
|||||||
void LocationCompleterModel::refreshCompletions(const QString &string)
|
void LocationCompleterModel::refreshCompletions(const QString &string)
|
||||||
{
|
{
|
||||||
if (m_lastCompletion == string) {
|
if (m_lastCompletion == string) {
|
||||||
|
refreshTabPositions();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,13 +201,21 @@ QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const
|
|||||||
|
|
||||||
TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const
|
TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const
|
||||||
{
|
{
|
||||||
for(int win=0; win < mApp->windowCount(); ++win) {
|
return tabPositionForEncodedUrl(url.toEncoded());
|
||||||
QupZilla* mainWin = mApp->mainWindows().at(win);
|
}
|
||||||
|
|
||||||
|
TabPosition LocationCompleterModel::tabPositionForEncodedUrl(const QString& encodedUrl) const
|
||||||
|
{
|
||||||
|
QList<QupZilla*> 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<WebTab*> tabs = mainWin->tabWidget()->allTabs();
|
QList<WebTab*> tabs = mainWin->tabWidget()->allTabs();
|
||||||
for(int tab=0; tab < tabs.count(); ++tab) {
|
for(int tab=0; tab < tabs.count(); ++tab) {
|
||||||
if(tabs[tab]->url() == url) {
|
if(tabs[tab]->url().toEncoded() == encodedUrl) {
|
||||||
TabPosition pos;
|
TabPosition pos;
|
||||||
pos.windowIndex = win;
|
pos.windowIndex = win == 0 ? currentWindowIdx : win-1;
|
||||||
pos.tabIndex = tab;
|
pos.tabIndex = tab;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@ -214,3 +223,18 @@ TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const
|
|||||||
}
|
}
|
||||||
return TabPosition();
|
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<TabPosition>(tabPositionForEncodedUrl(aItem->text())), TabPositionRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -62,6 +62,8 @@ private:
|
|||||||
QSqlQuery createQuery(const QString &searchString, const QString &orderBy, const QList<QUrl> &alreadyFound,
|
QSqlQuery createQuery(const QString &searchString, const QString &orderBy, const QList<QUrl> &alreadyFound,
|
||||||
int limit, bool bookmarks = false, bool exactMatch = false);
|
int limit, bool bookmarks = false, bool exactMatch = false);
|
||||||
TabPosition tabPositionForUrl(const QUrl& url) const;
|
TabPosition tabPositionForUrl(const QUrl& url) const;
|
||||||
|
TabPosition tabPositionForEncodedUrl(const QString& encodedUrl) const;
|
||||||
|
void refreshTabPositions();
|
||||||
|
|
||||||
QString m_lastCompletion;
|
QString m_lastCompletion;
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "tabwidget.h"
|
#include "tabwidget.h"
|
||||||
#include "qzsettings.h"
|
#include "qzsettings.h"
|
||||||
|
#include "tabbedwebview.h"
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -75,7 +76,6 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
||||||
if(pos.windowIndex!= -1) {
|
if(pos.windowIndex!= -1) {
|
||||||
activateTab(pos);
|
activateTab(pos);
|
||||||
close();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,7 +256,6 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
if(pos.windowIndex != -1) {
|
if(pos.windowIndex != -1) {
|
||||||
event->accept();
|
event->accept();
|
||||||
activateTab(pos);
|
activateTab(pos);
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QListView::mouseReleaseEvent(event);
|
QListView::mouseReleaseEvent(event);
|
||||||
@ -269,8 +268,17 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
void LocationCompleterView::activateTab(TabPosition pos)
|
void LocationCompleterView::activateTab(TabPosition pos)
|
||||||
{
|
{
|
||||||
emit aboutToActivateTab(pos);
|
|
||||||
QupZilla* win = mApp->mainWindows().at(pos.windowIndex);
|
QupZilla* win = mApp->mainWindows().at(pos.windowIndex);
|
||||||
win->activateWindow();
|
if (mApp->getWindow() != win || mApp->getWindow()->tabWidget()->currentIndex() != pos.tabIndex) {
|
||||||
|
emit aboutToActivateTab(pos);
|
||||||
|
close();
|
||||||
win->tabWidget()->setCurrentIndex(pos.tabIndex);
|
win->tabWidget()->setCurrentIndex(pos.tabIndex);
|
||||||
|
win->show();
|
||||||
|
win->activateWindow();
|
||||||
|
win->raise();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
close();
|
||||||
|
win->weView()->setFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "tabbedwebview.h"
|
#include "tabbedwebview.h"
|
||||||
#include "clearprivatedata.h"
|
#include "clearprivatedata.h"
|
||||||
#include "useragentdialog.h"
|
#include "useragentdialog.h"
|
||||||
|
#include "registerqappassociation.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
Loading…
Reference in New Issue
Block a user