mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Move switchToTab to QzSettings.
This commit is contained in:
parent
4c33d3563d
commit
e9a8b8d7d8
@ -325,7 +325,6 @@ HEADERS += \
|
||||
tools/focusselectlineedit.h \
|
||||
navigation/completer/locationcompleterdelegate.h \
|
||||
navigation/completer/locationcompleter.h \
|
||||
navigation/completer/locationcompletermodel.h \
|
||||
navigation/completer/locationcompleterview.h \
|
||||
history/history.h \
|
||||
history/historymodel.h \
|
||||
|
@ -33,6 +33,7 @@ LocationCompleter::LocationCompleter(QObject* parent)
|
||||
s_view = new LocationCompleterView;
|
||||
|
||||
s_view->setModel(s_model);
|
||||
s_view->setItemDelegate(new LocationCompleterDelegate(s_view));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,6 @@ LocationCompleterModel::LocationCompleterModel(QObject* parent)
|
||||
: QStandardItemModel(parent)
|
||||
, m_lastCompletion(QChar(QChar::Nbsp))
|
||||
{
|
||||
connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(receiveMessage(Qz::AppMessageType,bool)));
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
bool countBiggerThan(const QStandardItem* i1, const QStandardItem* i2)
|
||||
@ -74,7 +72,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
|
||||
item->setData(query.value(3), CountRole);
|
||||
item->setData(QVariant(true), BookmarkRole);
|
||||
item->setData(string, SearchStringRole);
|
||||
if(m_switchTabs) {
|
||||
if(qzSettings->showSwitchTab) {
|
||||
item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole);
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@ void LocationCompleterModel::refreshCompletions(const QString &string)
|
||||
item->setData(query.value(3), CountRole);
|
||||
item->setData(QVariant(false), BookmarkRole);
|
||||
item->setData(string, SearchStringRole);
|
||||
if(m_switchTabs) {
|
||||
if(qzSettings->showSwitchTab) {
|
||||
item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole);
|
||||
}
|
||||
|
||||
@ -130,7 +128,7 @@ void LocationCompleterModel::showMostVisited()
|
||||
item->setData(query.value(0), IdRole);
|
||||
item->setData(query.value(2), TitleRole);
|
||||
item->setData(QVariant(false), BookmarkRole);
|
||||
if(m_switchTabs) {
|
||||
if(qzSettings->showSwitchTab) {
|
||||
item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole);
|
||||
}
|
||||
|
||||
@ -216,17 +214,3 @@ TabPosition LocationCompleterModel::tabPositionForUrl(const QUrl& url) const
|
||||
}
|
||||
return TabPosition();
|
||||
}
|
||||
|
||||
void LocationCompleterModel::receiveMessage(Qz::AppMessageType mes, bool state)
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
if(mes == Qz::AM_ReloadSettings) {
|
||||
loadSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void LocationCompleterModel::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
m_switchTabs = settings.value("AddressBar/showSwitchTab", true).toBool();
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ Q_DECLARE_METATYPE(TabPosition)
|
||||
|
||||
class LocationCompleterModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Role {
|
||||
TitleRole = Qt::UserRole + 1,
|
||||
@ -52,10 +51,6 @@ public:
|
||||
void refreshCompletions(const QString &string);
|
||||
void showMostVisited();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
enum Type {
|
||||
HistoryAndBookmarks = 0,
|
||||
@ -67,13 +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;
|
||||
void loadSettings();
|
||||
|
||||
QString m_lastCompletion;
|
||||
bool m_switchTabs;
|
||||
|
||||
private slots:
|
||||
void receiveMessage(Qz::AppMessageType mes, bool state);
|
||||
};
|
||||
|
||||
#endif // LOCATIONCOMPLETERMODEL_H
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "qupzilla.h"
|
||||
#include "history.h"
|
||||
#include "tabwidget.h"
|
||||
#include "settings.h"
|
||||
#include "qzsettings.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QApplication>
|
||||
@ -44,11 +44,6 @@ LocationCompleterView::LocationCompleterView()
|
||||
|
||||
setMouseTracking(true);
|
||||
installEventFilter(this);
|
||||
|
||||
connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(receiveMessage(Qz::AppMessageType,bool)));
|
||||
|
||||
setItemDelegate(new LocationCompleterDelegate(this));
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
QPersistentModelIndex LocationCompleterView::hoveredIndex() const
|
||||
@ -74,7 +69,7 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
||||
switch (keyEvent->key()) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
if(m_switchTabs && !(keyEvent->modifiers() & Qt::ShiftModifier)) {
|
||||
if(qzSettings->showSwitchTab && !(keyEvent->modifiers() & Qt::ShiftModifier)) {
|
||||
QModelIndex idx = selectionModel()->currentIndex();
|
||||
if(idx.isValid()) {
|
||||
TabPosition pos = idx.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
||||
@ -161,7 +156,7 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
||||
|
||||
case Qt::Key_Shift:
|
||||
// don't switch if there is no hovered or selected index to not disturb typing
|
||||
if(m_switchTabs && (selectionModel()->currentIndex().isValid() || m_hoveredIndex.isValid())) {
|
||||
if(qzSettings->showSwitchTab && (selectionModel()->currentIndex().isValid() || m_hoveredIndex.isValid())) {
|
||||
static_cast<LocationCompleterDelegate*>(itemDelegate())->drawSwitchToTab(false);
|
||||
viewport()->update();
|
||||
return true;
|
||||
@ -178,7 +173,7 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
||||
|
||||
switch(keyEvent->key()) {
|
||||
case Qt::Key_Shift:
|
||||
if(m_switchTabs) {
|
||||
if(qzSettings->showSwitchTab) {
|
||||
static_cast<LocationCompleterDelegate*>(itemDelegate())->drawSwitchToTab(true);
|
||||
viewport()->update();
|
||||
return true;
|
||||
@ -217,7 +212,7 @@ void LocationCompleterView::close()
|
||||
|
||||
QListView::hide();
|
||||
verticalScrollBar()->setValue(0);
|
||||
if(m_switchTabs) {
|
||||
if(qzSettings->showSwitchTab) {
|
||||
static_cast<LocationCompleterDelegate*>(itemDelegate())->drawSwitchToTab(true);
|
||||
}
|
||||
}
|
||||
@ -256,7 +251,7 @@ void LocationCompleterView::mouseMoveEvent(QMouseEvent* event)
|
||||
|
||||
void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if(m_switchTabs && !(event->modifiers() & Qt::ShiftModifier) && m_hoveredIndex.isValid()) {
|
||||
if(qzSettings->showSwitchTab && !(event->modifiers() & Qt::ShiftModifier) && m_hoveredIndex.isValid()) {
|
||||
TabPosition pos = m_hoveredIndex.data(LocationCompleterModel::TabPositionRole).value<TabPosition>();
|
||||
if(pos.windowIndex != -1) {
|
||||
event->accept();
|
||||
@ -279,18 +274,3 @@ void LocationCompleterView::activateTab(TabPosition pos)
|
||||
win->activateWindow();
|
||||
win->tabWidget()->setCurrentIndex(pos.tabIndex);
|
||||
}
|
||||
|
||||
void LocationCompleterView::receiveMessage(Qz::AppMessageType mes, bool state)
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
if(mes == Qz::AM_ReloadSettings) {
|
||||
loadSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void LocationCompleterView::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
m_switchTabs = settings.value("AddressBar/showSwitchTab", true).toBool();
|
||||
static_cast<LocationCompleterDelegate*>(itemDelegate())->drawSwitchToTab(m_switchTabs);
|
||||
}
|
||||
|
@ -42,20 +42,16 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void activateTab(TabPosition pos);private slots:
|
||||
void receiveMessage(Qz::AppMessageType mes, bool state);
|
||||
void activateTab(TabPosition pos);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
|
||||
bool m_ignoreNextMouseMove;
|
||||
|
||||
QPersistentModelIndex m_hoveredIndex;
|
||||
bool m_switchTabs;
|
||||
};
|
||||
|
||||
#endif // LOCATIONCOMPLETERVIEW_H
|
||||
|
@ -32,6 +32,7 @@ void QzSettings::loadSettings()
|
||||
addCountryWithAlt = settings.value("AddCountryDomainWithAltKey", true).toBool();
|
||||
showLoadingProgress = settings.value("ShowLoadingProgress", false).toBool();
|
||||
showLocationSuggestions = settings.value("showSuggestions", 0).toInt();
|
||||
showSwitchTab = settings.value("showSwitchTab", true).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("SearchEngines");
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
bool addCountryWithAlt;
|
||||
bool showLoadingProgress;
|
||||
int showLocationSuggestions;
|
||||
bool showSwitchTab;
|
||||
|
||||
// SearchEngines
|
||||
bool showSearchSuggestions;
|
||||
|
Loading…
Reference in New Issue
Block a user