diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,6 @@ CoreAddons DocTools I18n - KHtml Parts Plotting Solid @@ -74,7 +73,7 @@ VARIABLE_PREFIX KALZIUMLIB ) -# search packages used by KDE +# search packages used by KDE if(WIN32) find_package(KDEWIN32 REQUIRED) # detect oxygen icon dir at configure time based on KDEDIRS - there may be different package installation locations diff --git a/data/htmlview/CMakeLists.txt b/data/htmlview/CMakeLists.txt --- a/data/htmlview/CMakeLists.txt +++ b/data/htmlview/CMakeLists.txt @@ -1,9 +1,8 @@ FILE(GLOB HTMLVIEW_ICONS "*.png") -install( FILES +install( FILES ${HTMLVIEW_ICONS} - icons.svg - style.css + icons.svg DESTINATION ${DATA_INSTALL_DIR}/kalzium/data/htmlview ) diff --git a/data/htmlview/characteristics.png b/data/htmlview/characteristics.png deleted file mode 100644 index db7afa34f0cf5836192943b48e44e451734166be..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@4nJ@ErzW#^d=bQh5jgR3=A9lx&I`x0{Ld1E{-7@=aXxWFtGI`e6m+I z;%D3N>A;nGHn)<4|1-P_Bzn^>*0-oO_Z&QN;D`YiN5e%0B@Tv%)oiQ>7>wS69Pa7r K=d#Wzp$P!1DLr!l diff --git a/data/htmlview/header.png b/data/htmlview/header.png deleted file mode 100644 index 56eb9596d50f488cd7d1d513528187a90a8dbe96..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@Y*2Br#z=2oUARtClj+6IOO1_!JBR{^!Lmw5WRvR`Et7ci3kVD+;d zD8yOd5n0T@z;_sg8IR|$NC676q&xaLGB9lH=l+w(3gkz4x;TbZ+_%cN4w^t*S@Uo9sDM m_htmlpages; + QMap m_htmlpages; int m_tableTyp; @@ -104,14 +105,14 @@ * @returns the pointer to the resulting KHTMLPart, needed for * writing HTML code on it */ - KHTMLPart* addHTMLTab(const QString& title, const QString& icontext, const QString& iconname); + QTextBrowser* addHTMLTab(const QString& title, const QString& icontext, const QString& iconname); /** * Change the HTML code in an HTML page. * - * @param htmlpart the KHTMLPart to edit + * @param browser the QTextBrowser to edit * @param htmlcode the HTML code to display */ - void fillHTMLTab(KHTMLPart* htmlpart, const QString& htmlcode); + void fillHTMLTab(QTextBrowser *browser, const QString& htmlcode); /** * Creates a localized link to Wikipedia. diff --git a/src/detailinfodlg.cpp b/src/detailinfodlg.cpp --- a/src/detailinfodlg.cpp +++ b/src/detailinfodlg.cpp @@ -35,14 +35,11 @@ #include #include #include +#include #include -#include -#include #include #include -#include -#include #include #include #include @@ -130,58 +127,31 @@ m_tableTyp = tableTyp; } -KHTMLPart* DetailedInfoDlg::addHTMLTab(const QString& title, const QString& icontext, const QString& iconname) +QTextBrowser* DetailedInfoDlg::addHTMLTab(const QString& title, const QString& icontext, const QString& iconname) { QWidget* frame = new QWidget(this); KPageWidgetItem *item = addPage(frame, title); item->setHeader(icontext); item->setIcon(QIcon::fromTheme(iconname)); QVBoxLayout *layout = new QVBoxLayout(frame); layout->setContentsMargins(0, 0, 0, 0); - - KHTMLPart *w = new KHTMLPart(frame, frame); - w->setJScriptEnabled(false); - w->setJavaEnabled(false); - w->setMetaRefreshEnabled(false); - w->setPluginsEnabled(false); - connect(w->browserExtension(), &KParts::BrowserExtension::openUrlRequest, this, &DetailedInfoDlg::slotLinkClicked); - layout->addWidget(w->view()); - - return w; + QTextBrowser *browser = new QTextBrowser(frame); + browser->setOpenExternalLinks(true); + layout->addWidget(browser); + return browser; } -void DetailedInfoDlg::fillHTMLTab(KHTMLPart* htmlpart, const QString& htmlcode) +void DetailedInfoDlg::fillHTMLTab(QTextBrowser *browser, const QString& htmlcode) { - if (!htmlpart) { + if (!browser) { return; } - - htmlpart->begin(); - htmlpart->write(htmlcode); - - // set the background color of the document to match that of the dialog - DOM::HTMLElement element = htmlpart->htmlDocument().body(); - if (element.tagName() == "body") { - const QColor backgroundColor = palette().window().color(); - ((DOM::HTMLBodyElement)element).setBgColor(backgroundColor.name()); - } - - htmlpart->end(); + browser->setHtml(htmlcode); } QString DetailedInfoDlg::getHtml(DATATYPE type) { - QString html = - "" - "Chemical data" - "" - "" - "
" - "
" + m_element->dataAsString(ChemicalDataObject::symbol) + "" - + createWikiLink(m_element->dataAsString(ChemicalDataObject::name)) + "" - + i18n("Block: %1", m_element->dataAsString(ChemicalDataObject::periodTableBlock)) + - "
" - ""; + QString html = "
"; switch (type) { case MISC: @@ -305,7 +275,7 @@ //http://education.jlab.org/itselemental/ele001.html html.append ("
"); - html.append ("dataAsString(ChemicalDataObject::atomicNumber), 3, '0')); html.append (".html"); @@ -316,7 +286,7 @@ // FIXME only works with english locals html.append ("
"); - html.append ("dataAsString(ChemicalDataObject::name).toLower()); // hydrogen @@ -346,24 +316,21 @@ QList list = KalziumDataObject::instance()->isotopes(m_elementNumber); QString html; - - html = QStringLiteral("
"); - html += i18n("Isotope-Table"); - html += QLatin1String("
"); + html = QStringLiteral(""); + html += QLatin1String(""); foreach (Isotope *isotope, list) { html.append("
"); html += i18n("Mass"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Neutrons"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Percentage"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Half-life period"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Energy and Mode of Decay"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Spin and Parity"); - html += QLatin1String(""); + html += QLatin1String(""); html += i18n("Magnetic Moment"); - html += QLatin1String("
"); @@ -378,7 +345,8 @@ } html.append(""); if ((isotope)->halflife() > 0.0) { - html.append(i18nc("The first argument is the value, the second is the unit. For example '17 s' for '17 seconds',.", "%1 %2", (isotope)->halflife(), (isotope)->halflifeUnit())); + html.append(i18nc("The first argument is the value, the second is the unit. For example '17 s' for '17 seconds',.", "%1 %2", + (isotope)->halflife(), (isotope)->halflifeUnit())); } html.append(""); if ((isotope)->alphalikeliness() > 0.0) { @@ -490,7 +458,6 @@ m_htmlpages[QStringLiteral("isotopes")] = addHTMLTab(i18n("Isotopes"), i18n("Isotopes"), QStringLiteral("isotopemap")); m_htmlpages[QStringLiteral("misc")] = addHTMLTab(i18n("Miscellaneous"), i18n("Miscellaneous"), QStringLiteral("misc")); - // spectrum widget tab QWidget *m_pSpectrumTab = new QWidget(this); item = addPage(m_pSpectrumTab, i18n("Spectrum")); @@ -514,13 +481,12 @@ { // reading the most common data const QString element_name = m_element->dataAsString(ChemicalDataObject::name); -// const QString element_symbol = m_element->dataAsString(ChemicalDataObject::symbol); + const QString element_symbol = m_element->dataAsString(ChemicalDataObject::symbol); + const QString element_block = m_element->dataAsString(ChemicalDataObject::periodTableBlock); // updating caption - setWindowTitle(i18nc("For example Carbon (6)", "%1 (%2)", element_name, m_elementNumber)); - - // updating overview tab -// dTab->setElement(m_elementNumber); + setWindowTitle(i18nc("For example: [C] Carbon (6 - Block p)", "[%1] %2 (%3 - Block %4)", + element_symbol, element_name, m_elementNumber, element_block)); //X // updating picture tab //X QString picpath = m_picsdir + element_symbol + ".jpg"; @@ -573,16 +539,16 @@ QString language(QLocale().uiLanguages().first()); //Wikipedia.org - html.append (" "); html.append (displayString); html.append (""); - // Example from the comment "http://en.wikipedia.org/wiki/hydrogen" + // Example from the comment "https://en.wikipedia.org/wiki/hydrogen" - return html; + return html; } void DetailedInfoDlg::slotLinkClicked(const QUrl &url) diff --git a/src/kalzium.cpp b/src/kalzium.cpp --- a/src/kalzium.cpp +++ b/src/kalzium.cpp @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include diff --git a/src/kdeeduglossary.h b/src/kdeeduglossary.h --- a/src/kdeeduglossary.h +++ b/src/kdeeduglossary.h @@ -234,8 +234,6 @@ Private * const d; Q_PRIVATE_SLOT(d, void itemActivated(QTreeWidgetItem *, int)) - Q_PRIVATE_SLOT(d, void displayItem(const QUrl &, const KParts::OpenUrlArguments &, - const KParts::BrowserArguments &)) }; #endif // KDEEDUGLOSSARY_H diff --git a/src/kdeeduglossary.cpp b/src/kdeeduglossary.cpp --- a/src/kdeeduglossary.cpp +++ b/src/kdeeduglossary.cpp @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include @@ -40,6 +38,7 @@ #include #include #include +#include #include #include @@ -108,15 +107,12 @@ // slots void itemActivated(QTreeWidgetItem * item, int column); - // The user clicked on a href. Find and display the right item - void displayItem(const QUrl &url, const KParts::OpenUrlArguments& arguments, - const KParts::BrowserArguments &browserArguments); GlossaryDialog *q; QList< GlossaryInfo > m_glossaries; - KHTMLPart *m_htmlpart; + QTextBrowser *m_htmlpart; QTreeWidget *m_glosstree; KTreeWidgetSearchLine *m_search; QString m_htmlbasestring; @@ -242,17 +238,17 @@ reflist.clear(); GlossaryItem *item = new GlossaryItem(); - itemElement = (const QDomElement&) itemList.item(i).toElement(); + itemElement = itemList.item(i).toElement(); QDomNode nameNode = itemElement.namedItem(QStringLiteral("name")); QDomNode descNode = itemElement.namedItem(QStringLiteral("desc")); QString picName = itemElement.namedItem(QStringLiteral("picture")).toElement().text(); - QDomElement refNode = (const QDomElement&) itemElement.namedItem(QStringLiteral("references")).toElement(); + QDomElement refNode = itemElement.namedItem(QStringLiteral("references")).toElement(); QString desc = i18n(descNode.toElement().text().toUtf8().constData()); if (!picName.isEmpty()) { - desc.prepend("[img]" + picName + "[/img][brclear][br]"); + desc.prepend("[br][img]" + picName + "[/img][brclear][br]"); } item->setName(i18n(nameNode.toElement().text().toUtf8().constData())); @@ -349,12 +345,27 @@ d->m_search->addTreeWidget(d->m_glosstree); - d->m_htmlpart = new KHTMLPart(vs); + d->m_htmlpart = new QTextBrowser(vs); + d->m_htmlpart->setOpenLinks(false); - connect(d->m_htmlpart->browserExtension(), SIGNAL(openUrlRequestDelayed(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), - this, SLOT(displayItem(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments))); connect(d->m_glosstree, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int))); + connect(d->m_htmlpart, &QTextBrowser::anchorClicked, this, [=](const QUrl &link){ + // using the "path" part of a qurl as reference + QString myurl = link.path().toLower(); + QTreeWidgetItemIterator it(this->d->m_glosstree); + while (*it) { + if ((*it)->type() == GlossaryTreeItemType && (*it)->text(0).toLower() == myurl) { + // force the item to be selected + this->d->m_glosstree->setCurrentItem(*it); + // display its content + emit this->d->itemActivated((*it), 0); + break; + } else { + ++it; + } + } + }); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); connect(buttonBox, &QDialogButtonBox::rejected, this, &GlossaryDialog::reject); @@ -377,25 +388,6 @@ QDialog::keyPressEvent(e); } -void GlossaryDialog::Private::displayItem(const QUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments &) -{ - // using the "path" part of a qurl as reference - QString myurl = url.path().toLower(); - - QTreeWidgetItemIterator it(m_glosstree); - while (*it) { - if ((*it)->type() == GlossaryTreeItemType && (*it)->text(0).toLower() == myurl) { - // force the item to be selected - m_glosstree->setCurrentItem(*it); - // display its content - itemActivated((*it), 0); - break; - } else { - ++it; - } - } -} - void GlossaryDialog::Private::rebuildTree() { m_glosstree->clear(); @@ -477,9 +469,7 @@ html = m_htmlbasestring.arg(html); html += glossitem->toHtml() + ""; - m_htmlpart->begin(); - m_htmlpart->write(html); - m_htmlpart->end(); + m_htmlpart->setHtml(html); } void GlossaryItem::setRef(const QStringList& s)