LeechCraft 0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
selectablebrowser.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "selectablebrowser.h"
10#include <QVBoxLayout>
11
12namespace LC::Util
13{
15 : QWidget (parent)
16 {
17 auto lay = new QVBoxLayout;
18 lay->setContentsMargins (0, 0, 0, 0);
19 setLayout (lay);
20 setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
21
22 PrepareInternal ();
23 }
24
26 {
27 if (browser &&
28 browser->GetWidget ())
29 {
30 Internal_ = false;
31 InternalBrowser_.reset ();
32 ExternalBrowser_.reset (browser->GetWidget ());
33 layout ()->addWidget (ExternalBrowser_->GetQWidget ());
34 }
35 else
36 {
37 ExternalBrowser_.reset ();
38 PrepareInternal ();
39 }
40 }
41
42 void SelectableBrowser::SetHtml (const QString& html, const QUrl& base)
43 {
44 if (Internal_)
45 InternalBrowser_->setHtml (html);
46 else
47 ExternalBrowser_->SetHtml (html, base);
48 }
49
51 {
52 if (!Internal_)
53 ExternalBrowser_->SetNavBarVisible (visible);
54 }
55
57 {
58 if (!Internal_)
59 ExternalBrowser_->SetEverythingElseVisible (visible);
60 }
61
62 void SelectableBrowser::PrepareInternal ()
63 {
64 Internal_ = true;
65 InternalBrowser_ = std::make_unique<QTextBrowser> ();
66 InternalBrowser_->setOpenExternalLinks (true);
67 InternalBrowser_->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
68 layout ()->addWidget (InternalBrowser_.get ());
69 }
70}
Base class for plugins that provide a web browser.
Definition: iwebbrowser.h:83
virtual IWebWidget * GetWidget() const =0
Returns the IWebWidget for use in another modules of LeechCraft.
void SetHtml(const QString &html, const QUrl &base=QUrl())
Sets the HTML content to display.
void SetEverythingElseVisible(bool visible)
Sets whether other UI elements should be visible.
void SetNavBarVisible(bool visible)
Sets whether navigation bar should be visible.
SelectableBrowser(QWidget *parent=nullptr)
Constructs the browser with the given parent.
void Construct(IWebBrowser *browser)
Initialize the widget with the browser plugin.