From 52754ed4185de5eee4d5bbdc9d960ec3ad5f740e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Apr 2021 00:37:23 +0200 Subject: [PATCH] 2.5d view and help integration --- src/laybasic/laybasic/layBrowserPanel.cc | 28 ++++++++++++++----- src/laybasic/laybasic/layBrowserPanel.h | 5 +++- .../tools/view_25d/lay_plugin/D25View.ui | 4 +-- .../tools/view_25d/lay_plugin/layD25View.cc | 3 ++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/laybasic/laybasic/layBrowserPanel.cc b/src/laybasic/laybasic/layBrowserPanel.cc index a6a16c9a3..b1421b426 100644 --- a/src/laybasic/laybasic/layBrowserPanel.cc +++ b/src/laybasic/laybasic/layBrowserPanel.cc @@ -95,6 +95,7 @@ BookmarkItem::to_string () const BrowserPanel::BrowserPanel (QWidget *parent) : QWidget (parent), m_back_dm (this, &BrowserPanel::back), + m_new_url_dm (this, &BrowserPanel::new_url), mp_dispatcher (0) { init (); @@ -125,6 +126,7 @@ BrowserPanel::init () mp_ui->browser->addAction (mp_ui->action_find); mp_ui->browser->addAction (mp_ui->action_bookmark); + mp_ui->browser->setOpenLinks (false); mp_ui->browser_bookmark_view->addAction (mp_ui->action_delete_bookmark); mp_ui->browser_bookmark_view->setContextMenuPolicy (Qt::ActionsContextMenu); @@ -138,7 +140,8 @@ BrowserPanel::init () connect (mp_ui->search_edit, SIGNAL (textEdited (const QString &)), this, SLOT (search_text_changed (const QString &))); connect (mp_ui->search_edit, SIGNAL (returnPressed ()), this, SLOT (search_edited ())); connect (mp_ui->search_button, SIGNAL (clicked ()), this, SLOT (search_edited ())); - connect (mp_ui->browser, SIGNAL (textChanged ()), this, SLOT (text_changed ())); + connect (mp_ui->browser, SIGNAL (sourceChanged (const QUrl &)), this, SLOT (source_changed ())); + connect (mp_ui->browser, SIGNAL (anchorClicked (const QUrl &)), this, SLOT (anchor_clicked (const QUrl &))); connect (mp_ui->browser, SIGNAL (backwardAvailable (bool)), mp_ui->back_pb, SLOT (setEnabled (bool))); connect (mp_ui->browser, SIGNAL (forwardAvailable (bool)), mp_ui->forward_pb, SLOT (setEnabled (bool))); connect (mp_ui->outline_tree, SIGNAL (itemActivated (QTreeWidgetItem *, int)), this, SLOT (outline_item_clicked (QTreeWidgetItem *))); @@ -218,7 +221,7 @@ BrowserPanel::title () const std::string BrowserPanel::url () const { - return m_cached_url; + return tl::to_string (mp_ui->browser->source ().toString ()); } void @@ -416,13 +419,24 @@ BrowserPanel::search_text_changed (const QString &text) } void -BrowserPanel::text_changed () +BrowserPanel::source_changed () +{ + m_new_url_dm (); +} + +void +BrowserPanel::anchor_clicked (const QUrl &url) +{ + mp_ui->browser->setSource (url); + source_changed (); +} + +void +BrowserPanel::new_url () { QString title = mp_ui->browser->document ()->metaInformation (QTextDocument::DocumentTitle); - if (title != m_current_title) { - m_current_title = title; - emit title_changed (title); - } + m_current_title = title; + emit title_changed (title); // refresh on-page search page_search_edited (); diff --git a/src/laybasic/laybasic/layBrowserPanel.h b/src/laybasic/laybasic/layBrowserPanel.h index 0b3ed3465..2fe7d8aba 100644 --- a/src/laybasic/laybasic/layBrowserPanel.h +++ b/src/laybasic/laybasic/layBrowserPanel.h @@ -441,7 +441,9 @@ protected slots: void page_search_next(); void search_text_changed(const QString &text); void search_edited (); - void text_changed (); + void source_changed (); + void anchor_clicked (const QUrl &url); + void new_url (); void outline_item_clicked (QTreeWidgetItem *item); void bookmark_item_selected (QTreeWidgetItem *item); void delete_bookmark (); @@ -462,6 +464,7 @@ private: Ui::BrowserPanel *mp_ui; bool m_schedule_back; tl::DeferredMethod m_back_dm; + tl::DeferredMethod m_new_url_dm; std::string m_search_url, m_search_query_item; QString m_current_title; QList m_search_selection; diff --git a/src/plugins/tools/view_25d/lay_plugin/D25View.ui b/src/plugins/tools/view_25d/lay_plugin/D25View.ui index 5e509de09..04a6aac27 100644 --- a/src/plugins/tools/view_25d/lay_plugin/D25View.ui +++ b/src/plugins/tools/view_25d/lay_plugin/D25View.ui @@ -350,9 +350,9 @@ 0 - + - Press and hold SHIFT for top view + Press and hold SHIFT for top view (<a href="int:/about/25d_view.xml">more</a>) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index b973cdc7f..6c57d177e 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -23,6 +23,7 @@ #include "layD25View.h" #include "layLayoutView.h" +#include "layQtTools.h" #include "ui_D25View.h" @@ -53,6 +54,8 @@ D25View::D25View (QWidget *parent) connect (mp_ui->d25_view, SIGNAL (init_failed ()), this, SLOT (init_failed ())); mp_ui->gl_stack->setCurrentIndex (0); + + lay::activate_help_links (mp_ui->doc_label); } D25View::~D25View ()