Changeset View
Changeset View
Standalone View
Standalone View
src/editor/browserwidget.cpp
Show All 10 Lines | |||||
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * | ||
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * | ||
13 | * * | 13 | * * | ||
14 | ***************************************************************************/ | 14 | ***************************************************************************/ | ||
15 | 15 | | |||
16 | #include "browserwidget.h" | 16 | #include "browserwidget.h" | ||
17 | 17 | | |||
18 | #include <keduvocexpression.h> | 18 | #include <keduvocexpression.h> | ||
19 | #include <KHTMLPart> | 19 | #include <QtWebEngineWidgets/QWebEngineView> | ||
20 | 20 | | |||
21 | #include <QDragEnterEvent> | 21 | #include <QDragEnterEvent> | ||
22 | 22 | | |||
23 | using namespace Editor; | 23 | using namespace Editor; | ||
24 | 24 | | |||
25 | BrowserWidget::BrowserWidget(QWidget *parent) : QWidget(parent) | 25 | BrowserWidget::BrowserWidget(QWidget *parent) : QWidget(parent) | ||
26 | { | 26 | { | ||
27 | setupUi(this); | 27 | setupUi(this); | ||
28 | m_currentTranslation = -1; | 28 | m_currentTranslation = -1; | ||
29 | m_entry = 0; | 29 | m_entry = 0; | ||
30 | m_currentProvider = 0; ///@todo kconfig? | 30 | m_currentProvider = 0; ///@todo kconfig? | ||
31 | 31 | | |||
32 | m_htmlPart = new KHTMLPart(widget); | 32 | m_htmlPart = new QWebEngineView(widget); | ||
33 | QHBoxLayout *layout = new QHBoxLayout(widget); | 33 | QHBoxLayout *layout = new QHBoxLayout(widget); | ||
34 | widget->setLayout(layout); | 34 | widget->setLayout(layout); | ||
35 | layout->addWidget(m_htmlPart->widget()); | 35 | layout->addWidget(m_htmlPart); | ||
36 | | ||||
37 | connect(m_htmlPart->browserExtension(), SIGNAL(openUrlRequest(const QUrl&, const KParts::OpenUrlArguments&, const KParts::BrowserArguments&)), | | |||
38 | this, SLOT(openUrl(const QUrl&))); | | |||
39 | 36 | | |||
40 | connect(showCurrentButton, &QPushButton::clicked, this, &BrowserWidget::showCurrentTranslation); | 37 | connect(showCurrentButton, &QPushButton::clicked, this, &BrowserWidget::showCurrentTranslation); | ||
41 | 38 | | |||
42 | setupProviders(); | 39 | setupProviders(); | ||
43 | connect(providerComboBox, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &BrowserWidget::providerChanged); | 40 | connect(providerComboBox, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &BrowserWidget::providerChanged); | ||
44 | 41 | | |||
45 | m_htmlPart->setJavaEnabled(false); | | |||
46 | m_htmlPart->setPluginsEnabled(false); | | |||
47 | m_htmlPart->setJScriptEnabled(true); | | |||
48 | m_htmlPart->setMetaRefreshEnabled(true); | | |||
49 | m_htmlPart->setDNDEnabled(true); | | |||
50 | } | 42 | } | ||
51 | 43 | | |||
52 | void BrowserWidget::setupProviders() | 44 | void BrowserWidget::setupProviders() | ||
53 | { | 45 | { | ||
54 | providerComboBox->clear(); | 46 | providerComboBox->clear(); | ||
55 | 47 | | |||
56 | DictionaryProvider provider; | 48 | DictionaryProvider provider; | ||
57 | provider.name = "De-Es Beolingus"; | 49 | provider.name = "De-Es Beolingus"; | ||
Show All 21 Lines | |||||
79 | providerComboBox->addItem(provider.name); | 71 | providerComboBox->addItem(provider.name); | ||
80 | 72 | | |||
81 | provider.name = "De-Fr Leo"; | 73 | provider.name = "De-Fr Leo"; | ||
82 | provider.url = "http://dict.leo.org/?lp=frde&search=\\{@}"; | 74 | provider.url = "http://dict.leo.org/?lp=frde&search=\\{@}"; | ||
83 | provider.languages << "de" << "fr"; | 75 | provider.languages << "de" << "fr"; | ||
84 | m_providers.append(provider); | 76 | m_providers.append(provider); | ||
85 | providerComboBox->addItem(provider.name); | 77 | providerComboBox->addItem(provider.name); | ||
86 | 78 | | |||
87 | provider.name = "De-Es Pons"; | | |||
88 | provider.url = "http://www.ponsline.de/cgi-bin/wb/w.pl?von=pons.de&Richtung=Spanisch&Begriff=\\{@}"; | | |||
89 | provider.languages << "de" << "es"; | | |||
90 | m_providers.append(provider); | | |||
91 | providerComboBox->addItem(provider.name); | | |||
92 | | ||||
93 | provider.name = "Ru-En Multitran"; | 79 | provider.name = "Ru-En Multitran"; | ||
94 | provider.url = "http://multitran.ru/c/m.exe?SHL=1&CL=1&l1=1&s=\\{@}"; | 80 | provider.url = "http://multitran.ru/c/m.exe?SHL=1&CL=1&l1=1&s=\\{@}"; | ||
95 | provider.languages << "ru" << "en"; | 81 | provider.languages << "ru" << "en"; | ||
96 | m_providers.append(provider); | 82 | m_providers.append(provider); | ||
97 | providerComboBox->addItem(provider.name); | 83 | providerComboBox->addItem(provider.name); | ||
98 | 84 | | |||
99 | provider.name = "Ru-De Multitran"; | 85 | provider.name = "Ru-De Multitran"; | ||
100 | provider.url = "http://multitran.ru/c/m.exe?SHL=1&CL=1&l1=3&s=\\{@}"; | 86 | provider.url = "http://multitran.ru/c/m.exe?SHL=1&CL=1&l1=3&s=\\{@}"; | ||
Show All 26 Lines | |||||
127 | } | 113 | } | ||
128 | 114 | | |||
129 | void BrowserWidget::showCurrentTranslation() | 115 | void BrowserWidget::showCurrentTranslation() | ||
130 | { | 116 | { | ||
131 | if (m_entry) { | 117 | if (m_entry) { | ||
132 | if (m_entry->translation(m_currentTranslation)) { | 118 | if (m_entry->translation(m_currentTranslation)) { | ||
133 | QString text = m_entry->translation(m_currentTranslation)->text(); | 119 | QString text = m_entry->translation(m_currentTranslation)->text(); | ||
134 | if (!text.isEmpty()) { | 120 | if (!text.isEmpty()) { | ||
135 | m_htmlPart->openUrl(QUrl(QString(m_providers.value(m_currentProvider).url.replace("\\{@}", text)))); | 121 | m_htmlPart->load(QUrl(QString(m_providers.value(m_currentProvider).url.replace("\\{@}", text)))); | ||
122 | m_htmlPart->show(); | ||||
136 | } | 123 | } | ||
137 | } | 124 | } | ||
138 | } | 125 | } | ||
139 | } | 126 | } | ||
140 | 127 | | |||
141 | void BrowserWidget::openUrl(const QUrl & targetUrl) | 128 | void BrowserWidget::openUrl(const QUrl & targetUrl) | ||
142 | { | 129 | { | ||
143 | m_htmlPart->openUrl(targetUrl); | 130 | m_htmlPart->load(targetUrl); | ||
131 | m_htmlPart->show(); | ||||
144 | } | 132 | } | ||
145 | 133 | | |||
146 | void BrowserWidget::providerChanged(int provider) | 134 | void BrowserWidget::providerChanged(int provider) | ||
147 | { | 135 | { | ||
148 | m_currentProvider = provider; | 136 | m_currentProvider = provider; | ||
149 | showCurrentTranslation(); | 137 | showCurrentTranslation(); | ||
150 | } | 138 | } |