Mercurial > octave
annotate libgui/src/documentation.cc @ 31619:ad014fc78bd6
use individual local gui_settings objects
Previously, we created a single gui_settings object (derived from
QSettings) and accessed it from the resource_manager object. That
design is not necessary and is not the way QSettings was designed to
be used. Instead of managing a single object, we should be using
individual QSettings objects where needed. Each individual QSettings
object manages thread-safe access to a single global collection of
settings. The Qt docs say that operations on QSettings are not thread
safe, but that means that you can't create a QSettings object in one
thread and use it in another without some locking. I'm not sure
whether we were doing that correctly, but with this change it no
longer matters. Each QSettings object does perform locking when
reading or writing the underlying global data.
* resource-manager.h, resource-manager.cc
(resource_manager::m_settings): Delete data member.
(resource_manager::get_settings): Delete.
* annotation-dialog.cc, QTerminal.cc, QTerminal.h, command-widget.cc,
command-widget.h, community-news.cc, dialog.cc,
documentation-bookmarks.cc, documentation-bookmarks.h,
documentation-dock-widget.cc, documentation-dock-widget.h,
documentation.cc, documentation.h, dw-main-window.cc,
dw-main-window.h, external-editor-interface.cc, files-dock-widget.cc,
files-dock-widget.h, find-files-dialog.cc, history-dock-widget.cc,
history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc,
file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc,
octave-qscintilla.cc, main-window.cc, main-window.h, news-reader.cc,
octave-dock-widget.cc, octave-dock-widget.h, qt-interpreter-events.cc,
qt-interpreter-events.h, release-notes.cc, resource-manager.cc,
resource-manager.h, set-path-dialog.cc, settings-dialog.cc,
settings-dialog.h, shortcut-manager.cc, shortcut-manager.h,
terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor.cc,
variable-editor.h, welcome-wizard.cc, workspace-model.cc,
workspace-model.h, workspace-view.cc: Use local gui_settings objects
instead of accessing a pointer to a single gui_settings object owned
by the resource_manager object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Dec 2022 14:23:53 -0500 |
parents | c8ad083a5802 |
children | 0645ea65ca6b |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30398
diff
changeset
|
3 // Copyright (C) 2018-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
25 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
27 # include "config.h" |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
28 #endif |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
29 |
26050
ce46820c5e9f
fix build failure for documentation.cc (bug #55003)
Torsten <mttl@mailbox.org>
parents:
26017
diff
changeset
|
30 #include <QAction> |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
31 #include <QApplication> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
32 #include <QCompleter> |
27612
62236e51a8c6
eliminate unnecessary includes from resource-manager.h
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
33 #include <QDesktopServices> |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
34 #include <QDir> |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
35 #include <QFile> |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
36 #include <QFileInfo> |
31293
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
37 #include <QFontDatabase> |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
38 #include <QHelpContentWidget> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
39 #include <QHelpIndexWidget> |
29118
d34558c873dc
documentation.cc: Include missing header (bug #59553).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29053
diff
changeset
|
40 #if defined (HAVE_NEW_QHELPINDEXWIDGET_API) \ |
d34558c873dc
documentation.cc: Include missing header (bug #59553).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29053
diff
changeset
|
41 || defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER) |
29034
e3bc897115ed
Change feature test to OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API in cset a0ff81c8b8e8.
Rik <rik@octave.org>
parents:
29031
diff
changeset
|
42 # include <QHelpLink> |
29031
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
43 #endif |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
44 #include <QHelpSearchEngine> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
45 #include <QHelpSearchQueryWidget> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
46 #include <QHelpSearchResultWidget> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
47 #include <QLabel> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
48 #include <QLineEdit> |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
49 #include <QMessageBox> |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
50 #include <QTabWidget> |
29692
b4e2c6150976
fix missing contents page at startup of doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29613
diff
changeset
|
51 #include <QTimer> |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
52 #include <QVBoxLayout> |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
53 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
54 #include "documentation.h" |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
55 #include "documentation-bookmarks.h" |
27560
3fcc650de22f
split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
56 #include "gui-preferences-global.h" |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
57 #include "gui-preferences-dc.h" |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
58 #include "gui-preferences-sc.h" |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
59 #include "gui-settings.h" |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
60 #include "octave-qobject.h" |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
61 #include "shortcut-manager.h" |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
62 |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
63 #include "defaults.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
64 #include "file-ops.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
65 #include "oct-env.h" |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
66 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
67 namespace octave |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
68 { |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
69 // The documentation splitter, which is the main widget |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
70 // of the doc dock widget |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
71 documentation::documentation (QWidget *p, base_qobject& oct_qobj) |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
72 : QSplitter (Qt::Horizontal, p), |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
73 m_octave_qobj (oct_qobj), m_doc_widget (this), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
74 m_tool_bar (new QToolBar (this)), |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
75 m_query_string (QString ()), |
29779
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
76 m_indexed (false), |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
77 m_current_ref_name (QString ()), |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
78 m_prev_pages_menu (new QMenu (this)), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
79 m_next_pages_menu (new QMenu (this)), |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
80 m_prev_pages_count (0), |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
81 m_next_pages_count (0), |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
82 m_findnext_shortcut (new QShortcut (this)), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
83 m_findprev_shortcut (new QShortcut (this)) |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
84 { |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
85 // Get original collection |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
86 QString collection = getenv ("OCTAVE_QTHELP_COLLECTION"); |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
87 if (collection.isEmpty ()) |
25460
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
88 collection = QString::fromStdString (config::oct_doc_dir () |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
89 + sys::file_ops::dir_sep_str () |
627d6bde9b8d
solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents:
25440
diff
changeset
|
90 + "octave_interpreter.qhc"); |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
91 |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
92 // Setup the help engine with the original collection, use a writable copy |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
93 // of the original collection and load the help data |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
94 m_help_engine = new QHelpEngine (collection, this); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
95 |
26729
c66f509d9f5c
Mark qt documentation as readonly (bug #53841).
John Donoghue
parents:
26554
diff
changeset
|
96 // Mark help as readonly to avoid error if collection file is stored in a |
c66f509d9f5c
Mark qt documentation as readonly (bug #53841).
John Donoghue
parents:
26554
diff
changeset
|
97 // readonly location |
c66f509d9f5c
Mark qt documentation as readonly (bug #53841).
John Donoghue
parents:
26554
diff
changeset
|
98 m_help_engine->setProperty ("_q_readonly", |
c66f509d9f5c
Mark qt documentation as readonly (bug #53841).
John Donoghue
parents:
26554
diff
changeset
|
99 QVariant::fromValue<bool> (true)); |
c66f509d9f5c
Mark qt documentation as readonly (bug #53841).
John Donoghue
parents:
26554
diff
changeset
|
100 |
31007
497de29f6946
* documentation.cc (ctor): use internal function for temp directory
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30772
diff
changeset
|
101 QString tmpdir = QString::fromStdString (sys::env::get_temp_directory ()); |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
102 m_collection |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25258
diff
changeset
|
103 = QString::fromStdString (sys::tempnam (tmpdir.toStdString (), |
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25258
diff
changeset
|
104 "oct-qhelp-")); |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
105 |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
106 if (m_help_engine->copyCollectionFile (m_collection)) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
107 m_help_engine->setCollectionFile (m_collection); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
108 else |
26064
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
109 #ifdef ENABLE_DOCS |
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
110 // FIXME: Perhaps a better way to do this would be to keep a count |
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
111 // in the GUI preferences file. After issuing this warning 3 times |
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
112 // it would be disabled. The count would need to be reset when a new |
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
113 // version of Octave is installed. |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
114 QMessageBox::warning (this, tr ("Octave Documentation"), |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
115 tr ("Could not copy help collection to temporary\n" |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
116 "file. Search capabilities may be affected.\n" |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
117 "%1").arg (m_help_engine->error ())); |
26064
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
118 #endif |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
119 |
29779
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
120 connect(m_help_engine->searchEngine (), SIGNAL(indexingFinished ()), |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
121 this, SLOT(load_index ())); |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
122 connect(m_help_engine, SIGNAL(setupFinished ()), |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
123 m_help_engine->searchEngine (), SLOT(reindexDocumentation ())); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
124 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
125 if (! m_help_engine->setupData()) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
126 { |
26064
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
127 #ifdef ENABLE_DOCS |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
128 QMessageBox::warning (this, tr ("Octave Documentation"), |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
129 tr ("Could not setup the data required for the\n" |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
130 "documentation viewer. Only help texts in\n" |
25163
3aed4f0ba3cd
Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents:
25121
diff
changeset
|
131 "the Command Window will be available.")); |
26064
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
132 #endif |
26746
3d0f687e4a21
avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26729
diff
changeset
|
133 |
3d0f687e4a21
avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26729
diff
changeset
|
134 disconnect (m_help_engine, 0, 0, 0); |
3d0f687e4a21
avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26729
diff
changeset
|
135 |
3d0f687e4a21
avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26729
diff
changeset
|
136 delete m_help_engine; |
3d0f687e4a21
avoid crash if help engine setup fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26729
diff
changeset
|
137 m_help_engine = nullptr; |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
138 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
139 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
140 // The browser |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
141 QWidget *browser_find = new QWidget (this); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
142 m_doc_browser = new documentation_browser (m_help_engine, browser_find); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
143 connect (m_doc_browser, &documentation_browser::cursorPositionChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
144 this, &documentation::handle_cursor_position_change); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
145 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
146 // Tool bar |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
147 construct_tool_bar (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
148 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
149 // Find bar |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
150 QWidget *find_footer = new QWidget (browser_find); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
151 QLabel *find_label = new QLabel (tr ("Find:"), find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
152 m_find_line_edit = new QLineEdit (find_footer); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
153 connect (m_find_line_edit, &QLineEdit::returnPressed, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
154 this, [=] () { find (); }); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
155 connect (m_find_line_edit, &QLineEdit::textEdited, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
156 this, &documentation::find_forward_from_anchor); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
157 QToolButton *forward_button = new QToolButton (find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
158 forward_button->setText (tr ("Search forward")); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
159 forward_button->setToolTip (tr ("Search forward")); |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
160 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
161 forward_button->setIcon (rmgr.icon ("go-down")); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
162 connect (forward_button, &QToolButton::pressed, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
163 this, [=] () { find (); }); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
164 QToolButton *backward_button = new QToolButton (find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
165 backward_button->setText (tr ("Search backward")); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
166 backward_button->setToolTip (tr ("Search backward")); |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
167 backward_button->setIcon (rmgr.icon ("go-up")); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
168 connect (backward_button, &QToolButton::pressed, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
169 this, &documentation::find_backward); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
170 QHBoxLayout *h_box_find_footer = new QHBoxLayout (find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
171 h_box_find_footer->addWidget (find_label); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
172 h_box_find_footer->addWidget (m_find_line_edit); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
173 h_box_find_footer->addWidget (forward_button); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
174 h_box_find_footer->addWidget (backward_button); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
175 h_box_find_footer->setMargin (2); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
176 find_footer->setLayout (h_box_find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
177 |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
178 QVBoxLayout *v_box_browser_find = new QVBoxLayout (browser_find); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
179 v_box_browser_find->addWidget (m_tool_bar); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
180 v_box_browser_find->addWidget (m_doc_browser); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
181 v_box_browser_find->addWidget (find_footer); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
182 browser_find->setLayout (v_box_browser_find); |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
183 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
184 notice_settings (); |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
185 |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
186 m_findnext_shortcut->setContext (Qt::WidgetWithChildrenShortcut); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
187 connect (m_findnext_shortcut, &QShortcut::activated, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
188 this, [=] () { find (); }); |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
189 m_findprev_shortcut->setContext (Qt::WidgetWithChildrenShortcut); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
190 connect (m_findprev_shortcut, &QShortcut::activated, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
191 this, &documentation::find_backward); |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
192 |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
193 find_footer->hide (); |
25155
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
194 m_search_anchor_position = 0; |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
195 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
196 if (m_help_engine) |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
197 { |
29034
e3bc897115ed
Change feature test to OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API in cset a0ff81c8b8e8.
Rik <rik@octave.org>
parents:
29031
diff
changeset
|
198 #if defined (HAVE_NEW_QHELPINDEXWIDGET_API) |
e3bc897115ed
Change feature test to OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API in cset a0ff81c8b8e8.
Rik <rik@octave.org>
parents:
29031
diff
changeset
|
199 // Starting in Qt 5.15, help engine uses filters instead of old API |
29031
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
200 m_help_engine->setUsesFilterEngine (true); |
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
201 #endif |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
202 // Layout contents, index and search |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
203 QTabWidget *navi = new QTabWidget (this); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
204 navi->setTabsClosable (false); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
205 navi->setMovable (true); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
206 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
207 // Contents |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
208 QHelpContentWidget *content = m_help_engine->contentWidget (); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
209 content->setObjectName ("documentation_tab_contents"); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
210 navi->addTab (content, tr ("Contents")); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
211 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
212 connect (m_help_engine->contentWidget (), |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
213 &QHelpContentWidget::linkActivated, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
214 m_doc_browser, [=] (const QUrl& url) { |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
215 m_doc_browser->handle_index_clicked (url); }); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
216 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
217 // Index |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
218 QHelpIndexWidget *index = m_help_engine->indexWidget (); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
219 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
220 m_filter = new QComboBox (this); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
221 m_filter->setToolTip (tr ("Enter text to search the indices")); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
222 m_filter->setEditable (true); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
223 m_filter->setInsertPolicy (QComboBox::NoInsert); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
224 m_filter->setMaxCount (10); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
225 m_filter->setMaxVisibleItems (10); |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27124
diff
changeset
|
226 m_filter->setSizeAdjustPolicy (QComboBox::AdjustToMinimumContentsLengthWithIcon); |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
227 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
228 m_filter->setSizePolicy (sizePol); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
229 m_filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
230 QLabel *filter_label = new QLabel (tr ("Search")); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
231 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
232 QWidget *filter_all = new QWidget (navi); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
233 QHBoxLayout *h_box_index = new QHBoxLayout (filter_all); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
234 h_box_index->addWidget (filter_label); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
235 h_box_index->addWidget (m_filter); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
236 h_box_index->setMargin (2); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
237 filter_all->setLayout (h_box_index); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
238 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
239 QWidget *index_all = new QWidget (navi); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
240 index_all->setObjectName ("documentation_tab_index"); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
241 QVBoxLayout *v_box_index = new QVBoxLayout (index_all); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
242 v_box_index->addWidget (filter_all); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
243 v_box_index->addWidget (index); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
244 index_all->setLayout (v_box_index); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
245 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
246 navi->addTab (index_all, tr ("Function Index")); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
247 |
29034
e3bc897115ed
Change feature test to OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API in cset a0ff81c8b8e8.
Rik <rik@octave.org>
parents:
29031
diff
changeset
|
248 #if defined (HAVE_NEW_QHELPINDEXWIDGET_API) |
29031
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
249 connect (m_help_engine->indexWidget (), |
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
250 &QHelpIndexWidget::documentActivated, |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
251 this, [=] (const QHelpLink &link) { |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
252 m_doc_browser->handle_index_clicked (link.url); }); |
29031
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
253 #else |
29034
e3bc897115ed
Change feature test to OCTAVE_CHECK_NEW_QHELPINDEXWIDGET_API in cset a0ff81c8b8e8.
Rik <rik@octave.org>
parents:
29031
diff
changeset
|
254 connect (m_help_engine->indexWidget (), |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
255 &QHelpIndexWidget::linkActivated, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
256 m_doc_browser, &documentation_browser::handle_index_clicked); |
29031
a0ff81c8b8e8
fix index in document browser for Qt 5.15 (bug #59375)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
257 #endif |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
258 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
259 connect (m_filter, &QComboBox::editTextChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
260 this, &documentation::filter_update); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
261 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
262 connect (m_filter->lineEdit (), &QLineEdit::editingFinished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
263 this, &documentation::filter_update_history); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
264 |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
265 // Bookmarks (own class) |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
266 m_bookmarks |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
267 = new documentation_bookmarks (this, m_doc_browser, m_octave_qobj, navi); |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
268 navi->addTab (m_bookmarks, tr ("Bookmarks")); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
269 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
270 connect (m_action_bookmark, &QAction::triggered, |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
271 m_bookmarks, [=] () { m_bookmarks->add_bookmark (); }); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
272 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
273 // Search |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
274 QHelpSearchEngine *search_engine = m_help_engine->searchEngine (); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
275 QHelpSearchQueryWidget *search = search_engine->queryWidget (); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
276 QHelpSearchResultWidget *result = search_engine->resultWidget (); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
277 QWidget *search_all = new QWidget (navi); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
278 QVBoxLayout *v_box_search = new QVBoxLayout (search_all); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
279 v_box_search->addWidget (search); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
280 v_box_search->addWidget (result); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
281 search_all->setLayout (v_box_search); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
282 search_all->setObjectName ("documentation_tab_search"); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
283 navi->addTab (search_all, tr ("Search")); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
284 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
285 connect (search, &QHelpSearchQueryWidget::search, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
286 this, &documentation::global_search); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
287 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
288 connect (search_engine, &QHelpSearchEngine::searchingStarted, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
289 this, &documentation::global_search_started); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
290 connect (search_engine, &QHelpSearchEngine::searchingFinished, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
291 this, &documentation::global_search_finished); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
292 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
293 connect (search_engine->resultWidget (), |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
294 &QHelpSearchResultWidget::requestShowLink, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
295 this, &documentation::handle_search_result_clicked); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
296 |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
297 // Fill the splitter |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
298 insertWidget (0, navi); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
299 insertWidget (1, browser_find); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
300 setStretchFactor (1, 1); |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
301 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
302 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
303 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
304 documentation::~documentation (void) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
305 { |
25102
65b7380655f2
prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents:
25101
diff
changeset
|
306 // Cleanup temporary file and directory |
65b7380655f2
prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents:
25101
diff
changeset
|
307 QFile file (m_collection); |
65b7380655f2
prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents:
25101
diff
changeset
|
308 if (file.exists ()) |
65b7380655f2
prevent crash if help data could not be set up (bug #53006)
Torsten <mttl@mailbox.org>
parents:
25101
diff
changeset
|
309 { |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
310 QFileInfo finfo (file); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
311 QString bname = finfo.fileName (); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
312 QDir dir = finfo.absoluteDir (); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
313 dir.setFilter (QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
314 QStringList namefilter; |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
315 namefilter.append ("*" + bname + "*"); |
27676
ea7d36e9f197
use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents:
27672
diff
changeset
|
316 for (const auto& fi : dir.entryInfoList (namefilter)) |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
317 { |
25094
c0d48cfbb59a
use Octave system functions to avoid build failure with Qt 4 (bug #53540)
Mike Miller <mtmiller@octave.org>
parents:
25061
diff
changeset
|
318 std::string file_name = fi.absoluteFilePath ().toStdString (); |
c0d48cfbb59a
use Octave system functions to avoid build failure with Qt 4 (bug #53540)
Mike Miller <mtmiller@octave.org>
parents:
25061
diff
changeset
|
319 sys::recursive_rmdir (file_name); |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
320 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
321 |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
322 file.remove(); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
323 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
324 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
325 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
326 QAction * documentation::add_action (const QIcon& icon, const QString& text, |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
327 const char *member, QWidget *receiver, |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
328 QToolBar *tool_bar) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
329 { |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
330 QAction *a; |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
331 QWidget *r = this; |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
332 if (receiver != nullptr) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
333 r = receiver; |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
334 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
335 a = new QAction (icon, text, this); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
336 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
337 if (member) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
338 connect (a, SIGNAL (triggered ()), r, member); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
339 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
340 if (tool_bar) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
341 tool_bar->addAction (a); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
342 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
343 m_doc_widget->addAction (a); // important for shortcut context |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
344 a->setShortcutContext (Qt::WidgetWithChildrenShortcut); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
345 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
346 return a; |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
347 } |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
348 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
349 void documentation::construct_tool_bar (void) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
350 { |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
351 // Home, Previous, Next |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
352 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
353 m_action_go_home |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
354 = add_action (rmgr.icon ("go-home"), tr ("Go home"), SLOT (home (void)), |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
355 m_doc_browser, m_tool_bar); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
356 |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
357 m_action_go_prev |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
358 = add_action (rmgr.icon ("go-previous"), tr ("Go back"), |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
359 SLOT (backward (void)), m_doc_browser, m_tool_bar); |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
360 m_action_go_prev->setEnabled (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
361 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
362 // popdown menu with prev pages files |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
363 QToolButton *popdown_button_prev_pages = new QToolButton (); |
26300
ef7f95f89407
updated language files for translation (bug #55279)
Torsten <mttl@mailbox.org>
parents:
26257
diff
changeset
|
364 popdown_button_prev_pages->setToolTip (tr ("Previous pages")); |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
365 popdown_button_prev_pages->setMenu (m_prev_pages_menu); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
366 popdown_button_prev_pages->setPopupMode (QToolButton::InstantPopup); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
367 popdown_button_prev_pages->setToolButtonStyle (Qt::ToolButtonTextOnly); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
368 popdown_button_prev_pages->setCheckable (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
369 popdown_button_prev_pages->setArrowType(Qt::DownArrow); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
370 m_tool_bar->addWidget (popdown_button_prev_pages); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
371 |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
372 m_action_go_next |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
373 = add_action (rmgr.icon ("go-next"), tr ("Go forward"), |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
374 SLOT (forward (void)), m_doc_browser, m_tool_bar); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
375 m_action_go_next->setEnabled (false); |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
376 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
377 // popdown menu with prev pages files |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
378 QToolButton *popdown_button_next_pages = new QToolButton (); |
26300
ef7f95f89407
updated language files for translation (bug #55279)
Torsten <mttl@mailbox.org>
parents:
26257
diff
changeset
|
379 popdown_button_next_pages->setToolTip (tr ("Next pages")); |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
380 popdown_button_next_pages->setMenu (m_next_pages_menu); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
381 popdown_button_next_pages->setPopupMode (QToolButton::InstantPopup); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
382 popdown_button_next_pages->setToolButtonStyle (Qt::ToolButtonTextOnly); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
383 popdown_button_next_pages->setArrowType(Qt::DownArrow); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
384 m_tool_bar->addWidget (popdown_button_next_pages); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
385 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
386 connect (m_doc_browser, &documentation_browser::backwardAvailable, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
387 m_action_go_prev, &QAction::setEnabled); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
388 connect (m_doc_browser, &documentation_browser::backwardAvailable, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
389 popdown_button_prev_pages, &QToolButton::setEnabled); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
390 connect (m_doc_browser, &documentation_browser::forwardAvailable, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
391 m_action_go_next, &QAction::setEnabled); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
392 connect (m_doc_browser, &documentation_browser::forwardAvailable, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
393 popdown_button_next_pages, &QToolButton::setEnabled); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
394 connect (m_doc_browser, &documentation_browser::historyChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
395 this, &documentation::update_history_menus); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
396 |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
397 // Init prev/next menus |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
398 for (int i = 0; i < max_history_entries; ++i) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
399 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
400 m_prev_pages_actions[i] = new QAction (this); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
401 m_prev_pages_actions[i]->setVisible (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
402 m_next_pages_actions[i] = new QAction (this); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
403 m_next_pages_actions[i]->setVisible (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
404 m_prev_pages_menu->addAction (m_prev_pages_actions[i]); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
405 m_next_pages_menu->addAction (m_next_pages_actions[i]); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
406 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
407 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
408 connect (m_prev_pages_menu, &QMenu::triggered, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
409 this, &documentation::open_hist_url); |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
410 connect (m_next_pages_menu, &QMenu::triggered, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
411 this, &documentation::open_hist_url); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
412 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
413 // Find |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
414 m_tool_bar->addSeparator (); |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
415 m_action_find |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
416 = add_action (rmgr.icon ("edit-find"), tr ("Find"), |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
417 SLOT (activate_find (void)), this, m_tool_bar); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
418 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
419 // Zoom |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
420 m_tool_bar->addSeparator (); |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
421 m_action_zoom_in |
30772
36dc11ee220d
reorganize GUIs icons
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
422 = add_action (rmgr.icon ("view-zoom-in"), tr ("Zoom in"), |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
423 SLOT (zoom_in (void)), m_doc_browser, m_tool_bar); |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
424 m_action_zoom_out |
30772
36dc11ee220d
reorganize GUIs icons
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
425 = add_action (rmgr.icon ("view-zoom-out"), tr ("Zoom out"), |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
426 SLOT (zoom_out (void)), m_doc_browser, m_tool_bar); |
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
427 m_action_zoom_original |
30772
36dc11ee220d
reorganize GUIs icons
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
428 = add_action (rmgr.icon ("view-zoom-original"), tr ("Zoom original"), |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
429 SLOT (zoom_original (void)), m_doc_browser, m_tool_bar); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
430 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
431 // Bookmarks (connect slots later) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
432 m_tool_bar->addSeparator (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
433 m_action_bookmark |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
434 = add_action (rmgr.icon ("bookmark-new"), tr ("Bookmark current page"), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
435 nullptr, nullptr, m_tool_bar); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
436 } |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
437 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
438 void documentation::global_search (void) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
439 { |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
440 if (! m_help_engine) |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
441 return; |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
442 |
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
443 QString query_string; |
25061
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
444 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
445 QString queries |
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
446 = m_help_engine->searchEngine ()->queryWidget ()->searchInput (); |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
447 query_string = queries; |
25061
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
448 #else |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
449 // FIXME: drop this part when support for Qt4 is dropped |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
450 QList<QHelpSearchQuery> queries |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
451 = m_help_engine->searchEngine ()->queryWidget ()->query (); |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
452 if (queries.count ()) |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
453 query_string = queries.first ().wordList.join (" "); |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
454 else |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
455 query_string = ""; |
25061
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
456 #endif |
5fef743c34d7
build: Check for new help query member in qt 5.9 (bug #53006).
Torsten <mttl@mailbox.org>
parents:
25060
diff
changeset
|
457 |
27112
f8434681af15
* documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
458 if (query_string.isEmpty ()) |
f8434681af15
* documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
459 return; |
f8434681af15
* documentation.cc (global_search): just return if query string is empty (bug #56388)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
460 |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
461 // Get quoted search strings first, then take first string as fall back |
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
462 QRegExp rx ("\"([^\"]*)\""); |
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
463 if (rx.indexIn (query_string, 0) != -1) |
26497
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
464 m_internal_search = rx.cap (1); |
26318
e1b849489e73
improve displaying search result in documentation browser (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26300
diff
changeset
|
465 else |
29049
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
29047
diff
changeset
|
466 #if defined (HAVE_QT_SPLITBEHAVIOR_ENUM) |
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
29047
diff
changeset
|
467 m_internal_search = query_string.split (" ", Qt::SkipEmptyParts).first (); |
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
29047
diff
changeset
|
468 #else |
26497
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
469 m_internal_search = query_string.split (" ", QString::SkipEmptyParts).first (); |
29049
461bd8b9ce91
use Qt::SplitBehavior enum and values if available
John W. Eaton <jwe@octave.org>
parents:
29047
diff
changeset
|
470 #endif |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
471 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
472 m_help_engine->searchEngine ()->search (queries); |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
473 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
474 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
475 void documentation::global_search_started (void) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
476 { |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
477 qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
478 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
479 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
480 void documentation::global_search_finished (int) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
481 { |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
482 if (! m_help_engine) |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
483 return; |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
484 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
485 if (! m_internal_search.isEmpty ()) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
486 { |
26497
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
487 m_query_string = m_internal_search; |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
488 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
489 QHelpSearchEngine *search_engine = m_help_engine->searchEngine (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
490 if (search_engine) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
491 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
492 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
493 QVector<QHelpSearchResult> res |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
494 = search_engine->searchResults (0, search_engine->searchResultCount ()); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
495 #else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
496 QList< QPair<QString, QString> > res |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
497 = search_engine->hits (0, search_engine->hitCount ()); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
498 #endif |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
499 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
500 if (res.count ()) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
501 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
502 QUrl url; |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
503 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
504 if (res.count () == 1) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
505 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
506 url = res.front ().url (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
507 #else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
508 url = res.front ().first; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
509 #endif |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
510 else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
511 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
512 // Remove the quotes we added |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
513 QString search_string = m_internal_search; |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
514 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
515 for (auto r = res.begin (); r != res.end (); r++) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
516 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
517 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
518 QString title = r->title ().toLower (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
519 QUrl tmpurl = r->url (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
520 #else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
521 QString title = r->second.toLower (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
522 QUrl tmpurl = r->first; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
523 #endif |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
524 if (title.contains (search_string.toLower ())) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
525 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
526 if (title.indexOf (search_string.toLower ()) == 0) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
527 { |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
528 url = tmpurl; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
529 break; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
530 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
531 else if (url.isEmpty ()) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
532 url = tmpurl; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
533 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
534 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
535 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
536 |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
537 if (! url.isEmpty ()) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
538 { |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
539 connect (this, &documentation::show_single_result, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
540 this, &documentation::handle_search_result_clicked); |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
541 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
542 emit show_single_result (url); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
543 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
544 } |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
545 } |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
546 |
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
547 m_internal_search = QString (); |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
548 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
549 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
550 qApp->restoreOverrideCursor(); |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
551 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
552 |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
553 void documentation::handle_search_result_clicked (const QUrl& url) |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
554 { |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
555 // Open url with matching text |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
556 m_doc_browser->handle_index_clicked (url); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
557 |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
558 // Select all occurrences of matching text |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
559 select_all_occurrences (m_query_string); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
560 |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
561 // Open search widget with matching text as search string |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
562 m_find_line_edit->setText (m_query_string); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
563 m_find_line_edit->parentWidget ()->show (); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
564 |
26497
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
565 // If no occurrence can be found go to the top of the page |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
566 if (! m_doc_browser->find (m_find_line_edit->text ())) |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
567 m_doc_browser->moveCursor (QTextCursor::Start); |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
568 else |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
569 { |
27929
265b386f8b20
maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
570 // Go to to first occurrence of search text. Going to the end and then |
26497
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
571 // search backwards until the last occurrence ensures the search text |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
572 // is visible in the first line of the visible part of the text. |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
573 m_doc_browser->moveCursor (QTextCursor::End); |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
574 while (m_doc_browser->find (m_find_line_edit->text (), |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
575 QTextDocument::FindBackward)); |
6e0bf8212b40
improve full text search in documentation browser
Torsten <mttl@mailbox.org>
parents:
26408
diff
changeset
|
576 } |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
577 } |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
578 |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
579 void documentation::select_all_occurrences (const QString& text) |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
580 { |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
581 // Get highlight background and text color |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
582 QPalette pal = QApplication::palette (); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
583 QTextCharFormat format; |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
584 QColor col = pal.color (QPalette::Highlight); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
585 col.setAlphaF (0.25); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
586 format.setBackground (QBrush (col)); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
587 format.setForeground (QBrush (pal.color (QPalette::Text))); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
588 |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
589 // Create list for extra selected items |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
590 QList<QTextEdit::ExtraSelection> selected; |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
591 m_doc_browser->moveCursor (QTextCursor::Start); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
592 |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
593 // Find all occurrences and add them to the selection |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
594 while ( m_doc_browser->find (text) ) |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
595 { |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
596 QTextEdit::ExtraSelection selected_item; |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
597 selected_item.cursor = m_doc_browser->textCursor (); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
598 selected_item.format = format; |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
599 selected.append (selected_item); |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
600 } |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
601 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27818
diff
changeset
|
602 // Apply selection and move back to the beginning |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27818
diff
changeset
|
603 m_doc_browser->setExtraSelections (selected); |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27818
diff
changeset
|
604 m_doc_browser->moveCursor (QTextCursor::Start); |
26245
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
605 } |
af99ea9c325f
Doc browser: go to search text when clicking a search result (bug #55228)
Torsten <mttl@mailbox.org>
parents:
26190
diff
changeset
|
606 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
607 void documentation::notice_settings (void) |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
608 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
609 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
610 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27818
diff
changeset
|
611 // If m_help_engine is not defined, the objects accessed by this method |
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27818
diff
changeset
|
612 // are not valid. Thus, just return in this case. |
26408
25dfa8c96b7b
* documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
613 if (! m_help_engine) |
25dfa8c96b7b
* documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
614 return; |
25dfa8c96b7b
* documentation.cc (notice_settings): prevent segfault if help engine does not exist
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
615 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
616 // Icon size in the toolbar. |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
617 int size_idx = settings.value (global_icon_size).toInt (); |
26058
ecd86b8b8979
use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents:
26050
diff
changeset
|
618 size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
619 |
26058
ecd86b8b8979
use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents:
26050
diff
changeset
|
620 QStyle *st = style (); |
ecd86b8b8979
use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents:
26050
diff
changeset
|
621 int icon_size = st->pixelMetric (global_icon_sizes[size_idx]); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
622 m_tool_bar->setIconSize (QSize (icon_size, icon_size)); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
623 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
624 // Shortcuts |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
625 shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
626 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
627 scmgr.set_shortcut (m_action_find, sc_edit_edit_find_replace); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
628 scmgr.shortcut (m_findnext_shortcut, sc_edit_edit_find_next); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
629 scmgr.shortcut (m_findprev_shortcut, sc_edit_edit_find_previous); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
630 scmgr.set_shortcut (m_action_zoom_in, sc_edit_view_zoom_in); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
631 scmgr.set_shortcut (m_action_zoom_out, sc_edit_view_zoom_out); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
632 scmgr.set_shortcut (m_action_zoom_original, sc_edit_view_zoom_normal); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
633 scmgr.set_shortcut (m_action_go_home, sc_doc_go_home); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
634 scmgr.set_shortcut (m_action_go_prev, sc_doc_go_back); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27676
diff
changeset
|
635 scmgr.set_shortcut (m_action_go_next, sc_doc_go_next); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
636 scmgr.set_shortcut (m_action_bookmark, sc_doc_bookmark); |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
637 |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
638 // Settings for the browser |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
639 m_doc_browser->notice_settings (); |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
640 } |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
641 |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
642 void documentation::save_settings (void) |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
643 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
644 gui_settings settings; |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
645 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
646 m_doc_browser->save_settings (); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
647 m_bookmarks->save_settings (); |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25336
diff
changeset
|
648 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
649 |
25962
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
650 void documentation::copyClipboard (void) |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
651 { |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
652 if (m_doc_browser->hasFocus ()) |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
653 { |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
654 m_doc_browser->copy(); |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
655 } |
12ad5eb2328e
Call the document browser copy on clipboard signal (Bug #54879)
John Donoghue
parents:
25609
diff
changeset
|
656 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
657 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
658 void documentation::pasteClipboard (void) { } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
659 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
660 void documentation::selectAll (void) { } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
661 |
29779
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
662 void documentation::load_index (void) |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
663 { |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
664 m_indexed = true; |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
665 |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
666 // Show index if no other page is required. |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
667 if (m_current_ref_name.isEmpty ()) |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
668 m_doc_browser->setSource |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
669 (QUrl ("qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html")); |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
670 else |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
671 load_ref (m_current_ref_name); |
29781
6cbd169e391b
* documentation.cc (load_index): expand the contents tree view at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29779
diff
changeset
|
672 |
6cbd169e391b
* documentation.cc (load_index): expand the contents tree view at startup
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29779
diff
changeset
|
673 m_help_engine->contentWidget ()->expandToDepth (0); |
29779
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
674 } |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
675 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
676 void documentation::load_ref (const QString& ref_name) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
677 { |
26770
2f550a8122d5
Simply show the doc browser when the search query is empty (bug #55756).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26755
diff
changeset
|
678 if (! m_help_engine || ref_name.isEmpty ()) |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
679 return; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
680 |
29779
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
681 m_current_ref_name = ref_name; |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
682 |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
683 if (! m_indexed) |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
684 return; |
58e7df720752
fix doc browser startup when launched from cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29711
diff
changeset
|
685 |
29053
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
686 #if defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER) |
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
687 QList<QHelpLink> found_links |
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
688 = m_help_engine->documentsForIdentifier (ref_name); |
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
689 #else |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
690 QMap<QString, QUrl> found_links |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
691 = m_help_engine->linksForIdentifier (ref_name); |
29053
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
692 #endif |
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
693 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
694 QTabWidget *navi = static_cast<QTabWidget *> (widget (0)); |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
695 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
696 if (found_links.count() > 0) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
697 { |
29174
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
698 // First search in the function index |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
699 #if defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER) |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
700 QUrl first_url = found_links.constFirst().url; |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
701 #else |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
702 QUrl first_url = found_links.constBegin().value (); |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
703 #endif |
4ca50ceb9576
avoid crash due to accessing first element of empty list (bug #59656)
John W. Eaton <jwe@octave.org>
parents:
29118
diff
changeset
|
704 |
29053
0678fdb81efc
avoid deprecated QHelpEngine::linksForIdentifier function
John W. Eaton <jwe@octave.org>
parents:
29050
diff
changeset
|
705 m_doc_browser->setSource (first_url); |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
706 |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
707 // Switch to function index tab |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
708 m_help_engine->indexWidget()->filterIndices (ref_name); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
709 QWidget *index_tab |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
710 = navi->findChild<QWidget *> ("documentation_tab_index"); |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
711 navi->setCurrentWidget (index_tab); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
712 } |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
713 else |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
714 { |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
715 // Use full text search to provide the best match |
25609
506419b5f817
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25541
diff
changeset
|
716 QHelpSearchEngine *search_engine = m_help_engine->searchEngine (); |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
717 QHelpSearchQueryWidget *search_query = search_engine->queryWidget (); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
718 |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
719 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
720 QString query = ref_name; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
721 query.prepend ("\"").append ("\""); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
722 #else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
723 QList<QHelpSearchQuery> query; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
724 query << QHelpSearchQuery (QHelpSearchQuery::DEFAULT, |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
725 QStringList (QString("\"") + ref_name + QString("\""))); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
726 #endif |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
727 m_internal_search = ref_name; |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
728 search_engine->search (query); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
729 |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
730 // Switch to search tab |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
731 #if defined (HAVE_QHELPSEARCHQUERYWIDGET_SEARCHINPUT) |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
732 search_query->setSearchInput (query); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
733 #else |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
734 search_query->setQuery (query); |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
735 #endif |
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
736 QWidget *search_tab |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
737 = navi->findChild<QWidget *> ("documentation_tab_search"); |
25541
517c73173011
doc.m: allow full text search in GUI mode (bug #54053).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25460
diff
changeset
|
738 navi->setCurrentWidget (search_tab); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
739 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
740 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
741 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
742 void documentation::activate_find (void) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
743 { |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
744 if (m_find_line_edit->parentWidget ()->isVisible ()) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
745 { |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
746 m_find_line_edit->parentWidget ()->hide (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
747 m_doc_browser->setFocus (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
748 } |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
749 else |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
750 { |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
751 m_find_line_edit->parentWidget ()->show (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
752 m_find_line_edit->selectAll (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
753 m_find_line_edit->setFocus (); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
754 } |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
755 } |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
756 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
757 void documentation::filter_update (const QString& expression) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
758 { |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
759 if (! m_help_engine) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
760 return; |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
761 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
762 QString wildcard; |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
763 if (expression.contains (QLatin1Char('*'))) |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
764 wildcard = expression; |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
765 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
766 m_help_engine->indexWidget ()->filterIndices(expression, wildcard); |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
767 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
768 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
769 void documentation::filter_update_history (void) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
770 { |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
771 QString text = m_filter->currentText (); // get current text |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
772 int index = m_filter->findText (text); // and its actual index |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
773 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
774 if (index > -1) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
775 m_filter->removeItem (index); // remove if already existing |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
776 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
777 m_filter->insertItem (0, text); // (re)insert at beginning |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
778 m_filter->setCurrentIndex (0); |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
779 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
780 |
27092
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
781 void documentation::find_backward (void) |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
782 { |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
783 find (true); |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
784 } |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
785 |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
786 void documentation::find (bool backward) |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
787 { |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
788 if (! m_help_engine) |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
789 return; |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
790 |
29050
ce849f006568
avoid deprecated QFlags<T>::QFlags(QFlags<T>::Zero) constructor
John W. Eaton <jwe@octave.org>
parents:
29049
diff
changeset
|
791 QTextDocument::FindFlags find_flags; |
27092
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
792 if (backward) |
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
793 find_flags = QTextDocument::FindBackward; |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
794 |
27092
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
795 if (! m_doc_browser->find (m_find_line_edit->text (), find_flags)) |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
796 { |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
797 // Nothing was found, restart search from the begin or end of text |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
798 QTextCursor textcur = m_doc_browser->textCursor (); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
799 if (backward) |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
800 textcur.movePosition (QTextCursor::End); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
801 else |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
802 textcur.movePosition (QTextCursor::Start); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
803 m_doc_browser->setTextCursor (textcur); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
804 m_doc_browser->find (m_find_line_edit->text (), find_flags); |
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27929
diff
changeset
|
805 } |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
806 |
25155
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
807 record_anchor_position (); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
808 } |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
809 |
25155
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
810 void documentation::find_forward_from_anchor (const QString& text) |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
811 { |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
812 if (! m_help_engine) |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
813 return; |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
814 |
27091
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
815 // Search from the current position |
25155
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
816 QTextCursor textcur = m_doc_browser->textCursor (); |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
817 textcur.setPosition (m_search_anchor_position); |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
818 m_doc_browser->setTextCursor (textcur); |
27091
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
819 |
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
820 if (! m_doc_browser->find (text)) |
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
821 { |
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
822 // Nothing was found, restart search from the beginning |
27092
d1fe5bd5e005
wrap while searching in doc browser
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27091
diff
changeset
|
823 textcur.movePosition (QTextCursor::Start); |
27091
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
824 m_doc_browser->setTextCursor (textcur); |
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
825 m_doc_browser->find (text); |
dcc3a8065ccd
wrap during search-while-typing in doc browser (bug #56216)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26770
diff
changeset
|
826 } |
25155
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
827 } |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
828 |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
829 void documentation::record_anchor_position (void) |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
830 { |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
831 if (! m_help_engine) |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
832 return; |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
833 |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
834 m_search_anchor_position = m_doc_browser->textCursor ().position (); |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
835 } |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
836 |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
837 void documentation::handle_cursor_position_change (void) |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
838 { |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
839 if (! m_help_engine) |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
840 return; |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
841 |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
842 if (m_doc_browser->hasFocus ()) |
17387d4edd1d
Add standard key bindings and actions to in-page Documentation find (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25121
diff
changeset
|
843 record_anchor_position (); |
25121
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
844 } |
9578133ca03e
Add a Ctrl+F unhide/hide in-page find footer to the Documentation window (bug #53006)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
25103
diff
changeset
|
845 |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
846 void documentation::registerDoc (const QString& qch) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
847 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
848 if (m_help_engine) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
849 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
850 QString ns = m_help_engine->namespaceName (qch); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
851 bool do_setup = true; |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
852 if (m_help_engine->registeredDocumentations ().contains (ns)) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
853 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
854 if (m_help_engine->documentationFileName (ns) == qch) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
855 do_setup = false; |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
856 else |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
857 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
858 m_help_engine->unregisterDocumentation (ns); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
859 m_help_engine->registerDocumentation (qch); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
860 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
861 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
862 else if (! m_help_engine->registerDocumentation (qch)) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
863 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
864 QMessageBox::warning (this, tr ("Octave Documentation"), |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
865 tr ("Unable to register help file %1."). |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
866 arg (qch)); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
867 return; |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
868 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
869 |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
870 if (do_setup) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
871 m_help_engine->setupData(); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
872 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
873 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
874 |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
875 void documentation::unregisterDoc (const QString& qch) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
876 { |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
877 if (! m_help_engine) |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
878 return; |
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
879 |
25060
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
880 QString ns = m_help_engine->namespaceName (qch); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
881 if (m_help_engine |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
882 && m_help_engine->registeredDocumentations ().contains (ns) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
883 && m_help_engine->documentationFileName (ns) == qch) |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
884 { |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
885 m_help_engine->unregisterDocumentation (ns); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
886 m_help_engine->setupData (); |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
887 } |
1cd3aeda7598
Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
25042
diff
changeset
|
888 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
889 |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
890 void documentation::update_history_menus (void) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
891 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
892 if (m_prev_pages_count != m_doc_browser->backwardHistoryCount ()) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
893 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
894 update_history (m_doc_browser->backwardHistoryCount (), |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
895 m_prev_pages_actions); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
896 m_prev_pages_count = m_doc_browser->backwardHistoryCount (); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
897 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
898 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
899 if (m_next_pages_count != m_doc_browser->forwardHistoryCount ()) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
900 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
901 update_history (m_doc_browser->forwardHistoryCount (), |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
902 m_next_pages_actions); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
903 m_next_pages_count = m_doc_browser->forwardHistoryCount (); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
904 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
905 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
906 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
907 void documentation::update_history (int new_count, QAction **actions) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
908 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
909 // Which menu has to be updated? |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
910 int prev_next = -1; |
26133
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
911 QAction *a = m_action_go_prev; |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
912 if (actions == m_next_pages_actions) |
26133
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
913 { |
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
914 prev_next = 1; |
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
915 a = m_action_go_next; |
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
916 } |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
917 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
918 // Get maximal count limited by array size |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
919 int count = qMin (new_count, int (max_history_entries)); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
920 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
921 // Fill used menu entries |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
922 for (int i = 0; i < count; i++) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
923 { |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
924 QString title |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
925 = title_and_anchor (m_doc_browser->historyTitle (prev_next*(i+1)), |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
926 m_doc_browser->historyUrl (prev_next*(i+1))); |
26144
494452db0477
doc browser: append anchor from url to history titles (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26143
diff
changeset
|
927 |
26133
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
928 if (i == 0) |
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
929 a->setText (title); // set tool tip for prev/next buttons |
84cd950f0f75
fix some tool tips in the documentation browser (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26128
diff
changeset
|
930 |
26128
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
931 actions[i]->setText (title); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
932 actions[i]->setData (m_doc_browser->historyUrl (prev_next*(i+1))); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
933 actions[i]->setEnabled (true); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
934 actions[i]->setVisible (true); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
935 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
936 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
937 // Hide unused menu entries |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
938 for (int j = count; j < max_history_entries; j++) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
939 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
940 actions[j]->setEnabled (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
941 actions[j]->setVisible (false); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
942 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
943 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
944 |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
945 void documentation::open_hist_url (QAction *a) |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
946 { |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
947 m_doc_browser->setSource (a->data ().toUrl ()); |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
948 } |
20b87596b99a
add mru-lists to the doc browser back/forward buttons (bug #54938)
Torsten <mttl@mailbox.org>
parents:
26064
diff
changeset
|
949 |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
950 // Utility functions |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
951 |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
952 QString documentation::title_and_anchor (const QString& title, const QUrl& url) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
953 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
954 QString retval = title; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
955 QString u = url.toString (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
956 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
957 retval.remove (QRegExp ("\\s*\\(*GNU Octave \\(version [^\\)]*\\)[: \\)]*")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
958 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
959 // Since the title only contains the section name and not the |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
960 // specific anchor, extract the latter from the url and append |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
961 // it to the title |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
962 if (u.contains ('#')) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
963 { |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
964 // Get the anchor from the url |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
965 QString anchor = u.split ('#').last (); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
966 // Remove internal string parts |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
967 anchor.remove (QRegExp ("^index-")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
968 anchor.remove (QRegExp ("^SEC_")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
969 anchor.remove (QRegExp ("^XREF")); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
970 anchor.remove ("Concept-Index_cp_letter-"); |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
971 anchor.replace ("-", " "); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
972 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
973 // replace encoded special chars by their unencoded versions |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
974 QRegExp rx = QRegExp ("_00([0-7][0-9a-f])"); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
975 int pos = 0; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
976 while ((pos = rx.indexIn(anchor, pos)) != -1) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
977 { |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
978 anchor.replace ("_00"+rx.cap (1), QChar (rx.cap (1).toInt (nullptr, 16))); |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
979 pos += rx.matchedLength(); |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
980 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
981 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
982 if (retval != anchor) |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
983 retval = retval + ": " + anchor; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
984 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
985 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
986 return retval; |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
987 } |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
988 |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
989 // |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
990 // The documentation browser |
29330
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
991 // |
b92614cfdfed
add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29174
diff
changeset
|
992 |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
993 documentation_browser::documentation_browser (QHelpEngine *he, QWidget *p) |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
994 : QTextBrowser (p), m_help_engine (he), m_zoom_level (max_zoom_level+1) |
26134
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
995 { |
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
996 setOpenLinks (false); |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
997 connect (this, &documentation_browser::anchorClicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
998 this, [=] (const QUrl& url) { handle_index_clicked (url); }); |
31293
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
999 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1000 // Make sure we have access to one of the monospace fonts listed in |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1001 // octave.css for rendering formated code blocks |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1002 QStringList fonts = {"Fantasque Sans Mono", "FreeMono", "Courier New", |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1003 "Cousine", "Courier"}; |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1004 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1005 bool load_default_font = true; |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1006 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1007 for (int i = 0; i < fonts.size (); ++i) |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1008 { |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1009 QFont font (fonts.at (i)); |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1010 if (font.exactMatch ()) |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1011 { |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1012 load_default_font = false; |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1013 break; |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1014 } |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1015 } |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1016 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1017 if (load_default_font) |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1018 { |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1019 QString fonts_dir = |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1020 QString::fromStdString (sys::env::getenv ("OCTAVE_FONTS_DIR") |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1021 + sys::file_ops::dir_sep_str ()); |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1022 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1023 QStringList default_fonts = {"FreeMono", "FreeMonoBold", |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1024 "FreeMonoBoldOblique", "FreeMonoOblique"}; |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1025 |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1026 for (int i = 0; i < default_fonts.size (); ++i) |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1027 { |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1028 QString fontpath = |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1029 fonts_dir + default_fonts.at(i) + QString (".otf"); |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1030 QFontDatabase::addApplicationFont (fontpath); |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1031 } |
17c8048a187b
doc: use a default monospace font in Qt doc browser (bug #63204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
31007
diff
changeset
|
1032 } |
26134
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
1033 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1034 |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1035 void documentation_browser::handle_index_clicked (const QUrl& url, |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1036 const QString&) |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1037 { |
26134
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
1038 if (url.scheme () == "qthelp") |
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
1039 setSource (url); |
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
1040 else |
3a38afebf949
open external links indoc browser help files in the standard browser
Torsten <mttl@mailbox.org>
parents:
26133
diff
changeset
|
1041 QDesktopServices::openUrl (url); |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1042 } |
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1043 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1044 void documentation_browser::notice_settings (void) |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1045 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1046 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1047 |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1048 // Zoom level only at startup, not when other settings have changed |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1049 if (m_zoom_level > max_zoom_level) |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1050 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1051 m_zoom_level = settings.value (dc_browser_zoom_level).toInt (); |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1052 zoomIn (m_zoom_level); |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1053 } |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1054 } |
25042
ba5af45bbfc4
documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1055 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29781
diff
changeset
|
1056 QVariant documentation_browser::loadResource (int type, const QUrl& url) |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
1057 { |
26755
c39d26971f4b
avoid crash in doc browser when help engine init fails (bug #55736)
John W. Eaton <jwe@octave.org>
parents:
26746
diff
changeset
|
1058 if (m_help_engine && url.scheme () == "qthelp") |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
1059 return QVariant (m_help_engine->fileData(url)); |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
1060 else |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
1061 return QTextBrowser::loadResource(type, url); |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25102
diff
changeset
|
1062 } |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1063 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1064 void documentation_browser::save_settings (void) |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1065 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1066 gui_settings settings; |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1067 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1068 settings.setValue (dc_browser_zoom_level.key, m_zoom_level); |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1069 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31548
diff
changeset
|
1070 settings.sync (); |
29711
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1071 } |
7a0be7c8b7ca
restore zoom level in documentation browser at start up
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29692
diff
changeset
|
1072 |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1073 void documentation_browser::zoom_in (void) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1074 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1075 if (m_zoom_level < max_zoom_level) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1076 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1077 zoomIn (); |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1078 m_zoom_level++; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1079 } |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1080 } |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1081 |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1082 void documentation_browser::zoom_out (void) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1083 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1084 if (m_zoom_level > min_zoom_level) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1085 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1086 zoomOut (); |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1087 m_zoom_level--; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1088 } |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1089 } |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1090 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25985
diff
changeset
|
1091 void documentation_browser::zoom_original (void) |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1092 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1093 zoomIn (- m_zoom_level); |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1094 m_zoom_level = 0; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25962
diff
changeset
|
1095 } |
25985
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1096 |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1097 void documentation_browser::wheelEvent (QWheelEvent *we) |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1098 { |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1099 if (we->modifiers () == Qt::ControlModifier) |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1100 { |
29047
94396ec1a89d
avoid warnings about deprecated QWheelEvent methods delta and orientation
John W. Eaton <jwe@octave.org>
parents:
29034
diff
changeset
|
1101 #if defined (HAVE_QWHEELEVENT_ANGLEDELTA) |
94396ec1a89d
avoid warnings about deprecated QWheelEvent methods delta and orientation
John W. Eaton <jwe@octave.org>
parents:
29034
diff
changeset
|
1102 if (we->angleDelta().y () > 0) |
94396ec1a89d
avoid warnings about deprecated QWheelEvent methods delta and orientation
John W. Eaton <jwe@octave.org>
parents:
29034
diff
changeset
|
1103 #else |
94396ec1a89d
avoid warnings about deprecated QWheelEvent methods delta and orientation
John W. Eaton <jwe@octave.org>
parents:
29034
diff
changeset
|
1104 if (we->delta() > 0) |
94396ec1a89d
avoid warnings about deprecated QWheelEvent methods delta and orientation
John W. Eaton <jwe@octave.org>
parents:
29034
diff
changeset
|
1105 #endif |
25985
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1106 zoom_in (); |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1107 else |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1108 zoom_out (); |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1109 |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1110 we->accept (); |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1111 } |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1112 else |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1113 QTextEdit::wheelEvent (we); |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1114 } |
49ffd0e0242d
enable resetting doc browser zoom level even when zooming with mouse wheel
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
1115 |
26064
673b1af42143
Don't complain about missing Qt help files when configure with --disable-docs (bug #53006).
Rik <rik@octave.org>
parents:
26058
diff
changeset
|
1116 } |