Changeset View
Changeset View
Standalone View
Standalone View
docs/phpdocumentationwidget.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include "phpdocumentationwidget.h" | 22 | #include "phpdocumentationwidget.h" | ||
23 | 23 | | |||
24 | #include <QProgressBar> | 24 | #include <QProgressBar> | ||
25 | #include <QLabel> | 25 | #include <QLabel> | ||
26 | #include <QVBoxLayout> | 26 | #include <QVBoxLayout> | ||
27 | #include <QTemporaryFile> | 27 | #include <QTemporaryFile> | ||
28 | #include <QTextStream> | 28 | #include <QTextStream> | ||
29 | #include <QUrl> | ||||
29 | 30 | | |||
30 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
31 | 32 | | |||
32 | #include "phpdocsplugin.h" | 33 | #include "phpdocsplugin.h" | ||
33 | #include <documentation/standarddocumentationview.h> | 34 | #include <documentation/standarddocumentationview.h> | ||
34 | 35 | | |||
35 | QTemporaryFile* createStyleSheet(QObject* parent) | 36 | QTemporaryFile* createStyleSheet(QObject* parent) | ||
36 | { | 37 | { | ||
Show All 10 Lines | |||||
47 | PhpDocumentationWidget::PhpDocumentationWidget(KDevelop::DocumentationFindWidget* find, const QUrl &url, | 48 | PhpDocumentationWidget::PhpDocumentationWidget(KDevelop::DocumentationFindWidget* find, const QUrl &url, | ||
48 | PhpDocsPlugin* provider, QWidget* parent) | 49 | PhpDocsPlugin* provider, QWidget* parent) | ||
49 | : QStackedWidget(parent) | 50 | : QStackedWidget(parent) | ||
50 | , m_loading(new QWidget(this)) | 51 | , m_loading(new QWidget(this)) | ||
51 | , m_styleSheet(createStyleSheet(this)) | 52 | , m_styleSheet(createStyleSheet(this)) | ||
52 | , m_provider(provider) | 53 | , m_provider(provider) | ||
53 | { | 54 | { | ||
54 | m_part = new KDevelop::StandardDocumentationView(find, this); | 55 | m_part = new KDevelop::StandardDocumentationView(find, this); | ||
55 | m_part->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); | 56 | m_part->setDelegateLinks(true); | ||
56 | addWidget(m_part); | 57 | addWidget(m_part); | ||
57 | addWidget(m_loading); | 58 | addWidget(m_loading); | ||
58 | 59 | | |||
59 | QProgressBar* progressbar = new QProgressBar; | 60 | QProgressBar* progressbar = new QProgressBar; | ||
60 | progressbar->setValue(0); | 61 | progressbar->setValue(0); | ||
61 | progressbar->setMinimum(0); | 62 | progressbar->setMinimum(0); | ||
62 | progressbar->setMaximum(100); | 63 | progressbar->setMaximum(100); | ||
63 | progressbar->setAlignment(Qt::AlignCenter); | 64 | progressbar->setAlignment(Qt::AlignCenter); | ||
64 | 65 | | |||
66 | // temporary disabled for initial porting to QWidget-only StandardDocumentationView | ||||
67 | #if 0 | ||||
65 | connect( m_part, &KDevelop::StandardDocumentationView::loadProgress, | 68 | connect( m_part, &KDevelop::StandardDocumentationView::loadProgress, | ||
66 | progressbar, &QProgressBar::setValue ); | 69 | progressbar, &QProgressBar::setValue ); | ||
70 | #endif | ||||
67 | 71 | | |||
68 | QVBoxLayout* layout = new QVBoxLayout; | 72 | QVBoxLayout* layout = new QVBoxLayout; | ||
69 | layout->addStretch(); | 73 | layout->addStretch(); | ||
70 | QLabel* label = new QLabel(i18n("...loading documentation...")); | 74 | QLabel* label = new QLabel(i18n("...loading documentation...")); | ||
71 | label->setAlignment(Qt::AlignCenter); | 75 | label->setAlignment(Qt::AlignCenter); | ||
72 | layout->addWidget(label); | 76 | layout->addWidget(label); | ||
73 | layout->addWidget(progressbar); | 77 | layout->addWidget(progressbar); | ||
74 | layout->addStretch(); | 78 | layout->addStretch(); | ||
75 | m_loading->setLayout(layout); | 79 | m_loading->setLayout(layout); | ||
80 | // temporary disabled for initial porting to QWidget-only StandardDocumentationView | ||||
81 | #if 0 | ||||
76 | setCurrentWidget(m_loading); | 82 | setCurrentWidget(m_loading); | ||
83 | #endif | ||||
84 | // instead directly show part | ||||
85 | setCurrentWidget(m_part); | ||||
77 | 86 | | |||
78 | 87 | | |||
79 | connect(m_part, &KDevelop::StandardDocumentationView::linkClicked, this, &PhpDocumentationWidget::linkClicked); | 88 | connect(m_part, &KDevelop::StandardDocumentationView::linkClicked, this, &PhpDocumentationWidget::linkClicked); | ||
89 | // temporary disabled for initial porting to QWidget-only StandardDocumentationView | ||||
90 | #if 0 | ||||
80 | connect(m_part, &KDevelop::StandardDocumentationView::loadFinished, this, &PhpDocumentationWidget::documentLoaded); | 91 | connect(m_part, &KDevelop::StandardDocumentationView::loadFinished, this, &PhpDocumentationWidget::documentLoaded); | ||
81 | 92 | #endif | |||
82 | m_part->load( url ); | 93 | m_part->load( url ); | ||
83 | } | 94 | } | ||
84 | 95 | | |||
85 | PhpDocumentationWidget::~PhpDocumentationWidget() | 96 | PhpDocumentationWidget::~PhpDocumentationWidget() | ||
86 | { | 97 | { | ||
87 | // make sure we don't get called by any of the m_part signals on shutdown, see also: | 98 | // make sure we don't get called by any of the m_part signals on shutdown, see also: | ||
88 | // https://codereview.qt-project.org/#/c/83800/ | 99 | // https://codereview.qt-project.org/#/c/83800/ | ||
89 | disconnect(m_part, 0, this, 0); | 100 | disconnect(m_part, nullptr, this, nullptr); | ||
90 | } | 101 | } | ||
91 | 102 | | |||
92 | void PhpDocumentationWidget::linkClicked(const QUrl& url) | 103 | void PhpDocumentationWidget::linkClicked(const QUrl& url) | ||
93 | { | 104 | { | ||
94 | m_part->load(url); | 105 | m_part->load(url); | ||
95 | m_provider->addToHistory(url); | 106 | m_provider->addToHistory(url); | ||
96 | } | 107 | } | ||
97 | 108 | | |||
98 | void PhpDocumentationWidget::documentLoaded() | 109 | void PhpDocumentationWidget::documentLoaded() | ||
99 | { | 110 | { | ||
100 | m_part->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile(m_styleSheet->fileName())); | 111 | m_part->setOverrideCss(QUrl::fromLocalFile(m_styleSheet->fileName())); | ||
101 | 112 | | |||
102 | setCurrentWidget(m_part); | 113 | setCurrentWidget(m_part); | ||
103 | removeWidget(m_loading); | 114 | removeWidget(m_loading); | ||
104 | delete m_loading; | 115 | delete m_loading; | ||
105 | m_loading = 0; | 116 | m_loading = nullptr; | ||
106 | } | 117 | } |