mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +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)
|
||||
{
|
||||
if (m_lastCompletion == string) {
|
||||
refreshTabPositions();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -200,13 +201,21 @@ QSqlQuery LocationCompleterModel::createQuery(const QString &searchString, const
|
||||
|
||||
TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const
|
||||
{
|
||||
for(int win=0; win < mApp->windowCount(); ++win) {
|
||||
QupZilla* mainWin = mApp->mainWindows().at(win);
|
||||
return tabPositionForEncodedUrl(url.toEncoded());
|
||||
}
|
||||
|
||||
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();
|
||||
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.windowIndex = win == 0 ? currentWindowIdx : win-1;
|
||||
pos.tabIndex = tab;
|
||||
return pos;
|
||||
}
|
||||
@ -214,3 +223,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<TabPosition>(tabPositionForEncodedUrl(aItem->text())), TabPositionRole);
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
QSqlQuery createQuery(const QString &searchString, const QString &orderBy, const QList<QUrl> &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;
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "history.h"
|
||||
#include "tabwidget.h"
|
||||
#include "qzsettings.h"
|
||||
#include "tabbedwebview.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QApplication>
|
||||
@ -75,7 +76,6 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
||||
TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
||||
if(pos.windowIndex!= -1) {
|
||||
activateTab(pos);
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -256,7 +256,6 @@ void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
|
||||
if(pos.windowIndex != -1) {
|
||||
event->accept();
|
||||
activateTab(pos);
|
||||
close();
|
||||
}
|
||||
else {
|
||||
QListView::mouseReleaseEvent(event);
|
||||
@ -269,8 +268,17 @@ 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);
|
||||
close();
|
||||
win->tabWidget()->setCurrentIndex(pos.tabIndex);
|
||||
win->show();
|
||||
win->activateWindow();
|
||||
win->raise();
|
||||
}
|
||||
else {
|
||||
close();
|
||||
win->weView()->setFocus();
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "tabbedwebview.h"
|
||||
#include "clearprivatedata.h"
|
||||
#include "useragentdialog.h"
|
||||
#include "registerqappassociation.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QInputDialog>
|
||||
|
Loading…
Reference in New Issue
Block a user