Merge branch 'haasn-lastfocus'

This commit is contained in:
Florian Bruhin 2016-08-10 09:13:50 +02:00
commit b025ea9da2
9 changed files with 54 additions and 50 deletions

View File

@ -55,6 +55,9 @@ Changed
title is changed via javascript. title is changed via javascript.
- `:hint` now has a `--mode <mode>` flag to override the hint mode configured - `:hint` now has a `--mode <mode>` flag to override the hint mode configured
using the `hints -> mode` setting. using the `hints -> mode` setting.
- With `new-instance-open-target` set to a tab option, the tab is now opened in
the most recently focused (instead of the last opened) window. This can be
configured with the new `new-instance-open-target.window` setting.
Removed Removed
~~~~~~~ ~~~~~~~
@ -63,6 +66,8 @@ Removed
and thus removed. and thus removed.
- The `:completion-item-prev` and `:completion-item-next` commands got merged - The `:completion-item-prev` and `:completion-item-next` commands got merged
into a new `:completion-focus {prev,next}` command and thus removed. into a new `:completion-focus {prev,next}` command and thus removed.
- The `ui -> hide-mouse-cursor` setting since it was completely broken and
nobody seemed to care.
v0.8.3 (unreleased) v0.8.3 (unreleased)
------------------- -------------------

View File

@ -177,6 +177,7 @@ Contributors, sorted by the number of commits in descending order:
* Oliver Caldwell * Oliver Caldwell
* Jonas Schürmann * Jonas Schürmann
* error800 * error800
* Niklas Haas
* Liam BEGUIN * Liam BEGUIN
* skinnay * skinnay
* Zach-Button * Zach-Button
@ -202,7 +203,6 @@ Contributors, sorted by the number of commits in descending order:
* Samuel Loury * Samuel Loury
* Peter Michely * Peter Michely
* Panashe M. Fundira * Panashe M. Fundira
* Niklas Haas
* Link * Link
* Larry Hynes * Larry Hynes
* Johannes Altmanninger * Johannes Altmanninger

View File

@ -23,6 +23,7 @@
|<<general-site-specific-quirks,site-specific-quirks>>|Enable workarounds for broken sites. |<<general-site-specific-quirks,site-specific-quirks>>|Enable workarounds for broken sites.
|<<general-default-encoding,default-encoding>>|Default encoding to use for websites. |<<general-default-encoding,default-encoding>>|Default encoding to use for websites.
|<<general-new-instance-open-target,new-instance-open-target>>|How to open links in an existing instance if a new one is launched. |<<general-new-instance-open-target,new-instance-open-target>>|How to open links in an existing instance if a new one is launched.
|<<general-new-instance-open-target.window,new-instance-open-target.window>>|Which window to choose when opening links as new tabs.
|<<general-log-javascript-console,log-javascript-console>>|How to log javascript console messages. |<<general-log-javascript-console,log-javascript-console>>|How to log javascript console messages.
|<<general-save-session,save-session>>|Whether to always save the open pages. |<<general-save-session,save-session>>|Whether to always save the open pages.
|<<general-session-default-name,session-default-name>>|The name of the session to save by default, or empty for the last loaded session. |<<general-session-default-name,session-default-name>>|The name of the session to save by default, or empty for the last loaded session.
@ -49,7 +50,6 @@
|<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown. |<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown.
|<<ui-statusbar-padding,statusbar-padding>>|Padding for statusbar (top, bottom, left, right). |<<ui-statusbar-padding,statusbar-padding>>|Padding for statusbar (top, bottom, left, right).
|<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined: |<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined:
|<<ui-hide-mouse-cursor,hide-mouse-cursor>>|Whether to hide the mouse cursor.
|<<ui-modal-js-dialog,modal-js-dialog>>|Use standard JavaScript modal dialog for alert() and confirm() |<<ui-modal-js-dialog,modal-js-dialog>>|Use standard JavaScript modal dialog for alert() and confirm()
|<<ui-hide-wayland-decoration,hide-wayland-decoration>>|Hide the window decoration when using wayland (requires restart) |<<ui-hide-wayland-decoration,hide-wayland-decoration>>|Hide the window decoration when using wayland (requires restart)
|<<ui-keyhint-blacklist,keyhint-blacklist>>|Keychains that shouldn't be shown in the keyhint dialog |<<ui-keyhint-blacklist,keyhint-blacklist>>|Keychains that shouldn't be shown in the keyhint dialog
@ -448,6 +448,17 @@ Valid values:
Default: +pass:[tab]+ Default: +pass:[tab]+
[[general-new-instance-open-target.window]]
=== new-instance-open-target.window
Which window to choose when opening links as new tabs.
Valid values:
* +last-opened+: Open new tabs in the last opened window.
* +last-focused+: Open new tabs in the most recently focused window.
Default: +pass:[last-focused]+
[[general-log-javascript-console]] [[general-log-javascript-console]]
=== log-javascript-console === log-javascript-console
How to log javascript console messages. How to log javascript console messages.
@ -651,17 +662,6 @@ The format to use for the window title. The following placeholders are defined:
Default: +pass:[{perc}{title}{title_sep}qutebrowser]+ Default: +pass:[{perc}{title}{title_sep}qutebrowser]+
[[ui-hide-mouse-cursor]]
=== hide-mouse-cursor
Whether to hide the mouse cursor.
Valid values:
* +true+
* +false+
Default: +pass:[false]+
[[ui-modal-js-dialog]] [[ui-modal-js-dialog]]
=== modal-js-dialog === modal-js-dialog
Use standard JavaScript modal dialog for alert() and confirm() Use standard JavaScript modal dialog for alert() and confirm()

View File

@ -33,9 +33,9 @@ import tokenize
from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QWindow
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl, from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QTimer, QUrl,
QObject, Qt, QEvent, pyqtSignal) QObject, QEvent, pyqtSignal)
try: try:
import hunter import hunter
except ImportError: except ImportError:
@ -339,19 +339,17 @@ def _save_version():
def on_focus_changed(_old, new): def on_focus_changed(_old, new):
"""Register currently focused main window in the object registry.""" """Register currently focused main window in the object registry."""
if not isinstance(new, QWidget) and new is not None: if new is None:
return
if not isinstance(new, QWidget):
log.misc.debug("on_focus_changed called with non-QWidget {!r}".format( log.misc.debug("on_focus_changed called with non-QWidget {!r}".format(
new)) new))
return
if new is None or not isinstance(new, mainwindow.MainWindow): window = new.window()
try: if isinstance(window, mainwindow.MainWindow):
objreg.delete('last-focused-main-window') objreg.register('last-focused-main-window', window, update=True)
except KeyError:
pass
qApp.restoreOverrideCursor()
else:
objreg.register('last-focused-main-window', new.window(), update=True)
_maybe_hide_mouse_cursor()
def open_desktopservices_url(url): def open_desktopservices_url(url):
@ -362,17 +360,6 @@ def open_desktopservices_url(url):
tabbed_browser.tabopen(url) tabbed_browser.tabopen(url)
@config.change_filter('ui', 'hide-mouse-cursor', function=True)
def _maybe_hide_mouse_cursor():
"""Hide the mouse cursor if it isn't yet and it's configured."""
if config.get('ui', 'hide-mouse-cursor'):
if qApp.overrideCursor() is not None:
return
qApp.setOverrideCursor(QCursor(Qt.BlankCursor))
else:
qApp.restoreOverrideCursor()
def _init_modules(args, crash_handler): def _init_modules(args, crash_handler):
"""Initialize all 'modules' which need to be initialized. """Initialize all 'modules' which need to be initialized.
@ -434,8 +421,6 @@ def _init_modules(args, crash_handler):
os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
else: else:
os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None) os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
_maybe_hide_mouse_cursor()
objreg.get('config').changed.connect(_maybe_hide_mouse_cursor)
temp_downloads = downloads.TempDownloadManager(qApp) temp_downloads = downloads.TempDownloadManager(qApp)
objreg.register('temporary-downloads', temp_downloads) objreg.register('temporary-downloads', temp_downloads)

View File

@ -350,6 +350,7 @@ class ConfigManager(QObject):
('tabs', 'auto-hide'), ('tabs', 'auto-hide'),
('tabs', 'hide-always'), ('tabs', 'hide-always'),
('ui', 'display-statusbar-messages'), ('ui', 'display-statusbar-messages'),
('ui', 'hide-mouse-cursor'),
('general', 'wrap-search'), ('general', 'wrap-search'),
] ]
CHANGED_OPTIONS = { CHANGED_OPTIONS = {

View File

@ -227,6 +227,16 @@ def data(readonly=False):
"How to open links in an existing instance if a new one is " "How to open links in an existing instance if a new one is "
"launched."), "launched."),
('new-instance-open-target.window',
SettingValue(typ.String(
valid_values=typ.ValidValues(
('last-opened', "Open new tabs in the last opened "
"window."),
('last-focused', "Open new tabs in the most recently "
"focused window.")
)), 'last-focused'),
"Which window to choose when opening links as new tabs."),
('log-javascript-console', ('log-javascript-console',
SettingValue(typ.String( SettingValue(typ.String(
valid_values=typ.ValidValues( valid_values=typ.ValidValues(
@ -346,10 +356,6 @@ def data(readonly=False):
"* `{scroll_pos}`: The page scroll position.\n" "* `{scroll_pos}`: The page scroll position.\n"
"* `{host}`: The host of the current web page."), "* `{host}`: The host of the current web page."),
('hide-mouse-cursor',
SettingValue(typ.Bool(), 'false'),
"Whether to hide the mouse cursor."),
('modal-js-dialog', ('modal-js-dialog',
SettingValue(typ.Bool(), 'false'), SettingValue(typ.Bool(), 'false'),
"Use standard JavaScript modal dialog for alert() and confirm()"), "Use standard JavaScript modal dialog for alert() and confirm()"),

View File

@ -69,6 +69,10 @@ def get_window(via_ipc, force_window=False, force_tab=False,
window_to_raise = window window_to_raise = window
else: else:
try: try:
win_mode = config.get('general', 'new-instance-open-target.window')
if win_mode == 'last-focused':
window = objreg.last_focused_window()
elif win_mode == 'last-opened':
window = objreg.last_window() window = objreg.last_window()
except objreg.NoWindow: except objreg.NoWindow:
# There is no window left, so we open a new one # There is no window left, so we open a new one
@ -175,9 +179,6 @@ class MainWindow(QWidget):
QTimer.singleShot(0, self._connect_resize_keyhint) QTimer.singleShot(0, self._connect_resize_keyhint)
objreg.get('config').changed.connect(self.on_config_changed) objreg.get('config').changed.connect(self.on_config_changed)
if config.get('ui', 'hide-mouse-cursor'):
self.setCursor(Qt.BlankCursor)
objreg.get("app").new_window.emit(self) objreg.get("app").new_window.emit(self)
def _init_downloadmanager(self): def _init_downloadmanager(self):

View File

@ -178,10 +178,7 @@ def _get_window_registry(window):
app = get('app') app = get('app')
win = app.activeWindow() win = app.activeWindow()
elif window == 'last-focused': elif window == 'last-focused':
try: win = last_focused_window()
win = get('last-focused-main-window')
except KeyError:
win = last_window()
else: else:
win = window_registry[window] win = window_registry[window]
except (KeyError, NoWindow): except (KeyError, NoWindow):
@ -276,6 +273,14 @@ def dump_objects():
return lines return lines
def last_focused_window():
"""Get the last focused window, or the last window if none."""
try:
return get('last-focused-main-window')
except KeyError:
return last_window()
def last_window(): def last_window():
"""Get the last opened window object.""" """Get the last opened window object."""
if not window_registry: if not window_registry:

View File

@ -330,6 +330,7 @@ class QuteProc(testprocess.Process):
settings = [ settings = [
('ui', 'message-timeout', '0'), ('ui', 'message-timeout', '0'),
('general', 'auto-save-interval', '0'), ('general', 'auto-save-interval', '0'),
('general', 'new-instance-open-target.window', 'last-opened')
] ]
if not self._webengine: if not self._webengine:
settings.append(('network', 'ssl-strict', 'false')) settings.append(('network', 'ssl-strict', 'false'))