diff --git a/plugins/extensions/resourcemanager/entrydetailsdialog.cpp b/plugins/extensions/resourcemanager/entrydetailsdialog.cpp index 3183d48c85..e93c21f220 100644 --- a/plugins/extensions/resourcemanager/entrydetailsdialog.cpp +++ b/plugins/extensions/resourcemanager/entrydetailsdialog.cpp @@ -1,262 +1,262 @@ /* * Copyright (C) 2009 Frederik Gladhorn * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "entrydetailsdialog_p.h" #include #include #include #include EntryDetails::EntryDetails(KNSCore::Engine *engine, Ui::WdgDlgContentDownloader *widget) : QObject(widget->m_listView), m_engine(engine), ui(widget) { init(); } EntryDetails::~EntryDetails() { } void EntryDetails::init() { connect(ui->preview1, &ImagePreviewWidget::clicked, this, &EntryDetails::preview1Selected); ui->ratingWidget->setMaxRating(10); ui->ratingWidget->setHalfStepsEnabled(true); updateButtons(); connect(ui->installButton, &QAbstractButton::clicked, this, &EntryDetails::install); connect(ui->uninstallButton, &QAbstractButton::clicked, this, &EntryDetails::uninstall); // updating is the same as installing connect(ui->updateButton, &QAbstractButton::clicked, this, &EntryDetails::install); // connect(ui->becomeFanButton, &QAbstractButton::clicked, this, &EntryDetails::becomeFan); ui->installButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok"))); ui->updateButton->setIcon(QIcon::fromTheme(QStringLiteral("system-software-update"))); ui->uninstallButton->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete"))); connect(m_engine, &KNSCore::Engine::signalEntryDetailsLoaded, this, &EntryDetails::entryChanged); connect(m_engine, &KNSCore::Engine::signalEntryChanged, this, &EntryDetails::entryStatusChanged); connect(m_engine, &KNSCore::Engine::signalEntryPreviewLoaded, this, &EntryDetails::slotEntryPreviewLoaded); } void EntryDetails::setEntry(const KNSCore::EntryInternal &entry) { m_entry = entry; // immediately show something entryChanged(m_entry); // fetch more preview images m_engine->loadDetails(m_entry); } void EntryDetails::entryChanged(const KNSCore::EntryInternal &entry) { m_entry = entry; ui->m_titleWidget->setText(i18n("Details for %1", m_entry.name())); if (!m_entry.author().homepage().isEmpty()) { ui->authorLabel->setText("" + m_entry.author().name() + ""); } else if (!m_entry.author().email().isEmpty()) { ui->authorLabel->setText("" + m_entry.author().name() + ""); } else { ui->authorLabel->setText(m_entry.author().name()); } QString summary = KNSCore::replaceBBCode(m_entry.summary()).replace('\n', QLatin1String("
")); QString changelog = KNSCore::replaceBBCode(m_entry.changelog()).replace('\n', QLatin1String("
")); QString description = "" + summary; if (!changelog.isEmpty()) { description += "

" + i18n("Changelog:") + "
" + changelog + "

"; } description += QLatin1String(""); - ui->descriptionLabel->setText(description); + ui->descriptionTextEdit->setText(description); QString homepageText("" + i18nc("A link to the description of this Get Hot New Stuff item", "Homepage") + ""); if (!m_entry.donationLink().isEmpty()) { homepageText += "
" + i18nc("A link to make a donation for a Get Hot New Stuff item (opens a web browser)", "Make a donation") + ""; } if (!m_entry.knowledgebaseLink().isEmpty()) { homepageText += "
" + i18ncp("A link to the knowledgebase (like a forum) (opens a web browser)", "Knowledgebase (no entries)", "Knowledgebase (%1 entries)", m_entry.numberKnowledgebaseEntries()) + ""; } ui->homepageLabel->setText(homepageText); ui->homepageLabel->setToolTip(i18nc("Tooltip for a link in a dialog", "Opens in a browser window")); if (m_entry.rating() > 0) { ui->ratingWidget->setVisible(true); disconnect(ui->ratingWidget, static_cast(&KRatingWidget::ratingChanged), this, &EntryDetails::ratingChanged); // Most of the voting is 20 - 80, so rate 20 as 0 stars and 80 as 5 stars int rating = qMax(0, qMin(10, (m_entry.rating() - 20) / 6)); ui->ratingWidget->setRating(rating); connect(ui->ratingWidget, static_cast(&KRatingWidget::ratingChanged), this, &EntryDetails::ratingChanged); } else { ui->ratingWidget->setVisible(false); } bool hideSmallPreviews = m_entry.previewUrl(KNSCore::EntryInternal::PreviewSmall2).isEmpty() && m_entry.previewUrl(KNSCore::EntryInternal::PreviewSmall3).isEmpty(); ui->preview1->setVisible(!hideSmallPreviews); // in static xml we often only get a small preview, use that in details if (m_entry.previewUrl(KNSCore::EntryInternal::PreviewBig1).isEmpty() && !m_entry.previewUrl(KNSCore::EntryInternal::PreviewSmall1).isEmpty()) { m_entry.setPreviewUrl(m_entry.previewUrl(KNSCore::EntryInternal::PreviewSmall1), KNSCore::EntryInternal::PreviewBig1); m_entry.setPreviewImage(m_entry.previewImage(KNSCore::EntryInternal::PreviewSmall1), KNSCore::EntryInternal::PreviewBig1); } for (int type = KNSCore::EntryInternal::PreviewSmall1; type <= KNSCore::EntryInternal::PreviewBig3; ++type) { if (!m_entry.previewUrl((KNSCore::EntryInternal::PreviewType)type).isEmpty()) { if (m_entry.previewImage((KNSCore::EntryInternal::PreviewType)type).isNull()) { m_engine->loadPreview(m_entry, (KNSCore::EntryInternal::PreviewType)type); } else { slotEntryPreviewLoaded(m_entry, (KNSCore::EntryInternal::PreviewType)type); } } } updateButtons(); } void EntryDetails::entryStatusChanged(const KNSCore::EntryInternal &entry) { Q_UNUSED(entry); updateButtons(); } void EntryDetails::updateButtons() { ui->installButton->setVisible(false); ui->uninstallButton->setVisible(false); ui->updateButton->setVisible(false); switch (m_entry.status()) { case KNS3::Entry::Installed: ui->uninstallButton->setVisible(true); ui->uninstallButton->setEnabled(true); break; case KNS3::Entry::Updateable: ui->updateButton->setVisible(true); ui->updateButton->setEnabled(true); ui->uninstallButton->setVisible(true); ui->uninstallButton->setEnabled(true); break; case KNS3::Entry::Invalid: case KNS3::Entry::Downloadable: ui->installButton->setVisible(true); ui->installButton->setEnabled(true); break; case KNS3::Entry::Installing: ui->installButton->setVisible(true); ui->installButton->setEnabled(false); break; case KNS3::Entry::Updating: ui->updateButton->setVisible(true); ui->updateButton->setEnabled(false); ui->uninstallButton->setVisible(true); ui->uninstallButton->setEnabled(false); break; case KNS3::Entry::Deleted: ui->installButton->setVisible(true); ui->installButton->setEnabled(true); break; } if (ui->installButton->menu()) { QMenu *buttonMenu = ui->installButton->menu(); buttonMenu->clear(); ui->installButton->setMenu(nullptr); buttonMenu->deleteLater(); } if (ui->installButton->isVisible() && m_entry.downloadLinkCount() > 1) { QMenu *installMenu = new QMenu(ui->installButton); foreach (KNSCore::EntryInternal::DownloadLinkInformation info, m_entry.downloadLinkInformationList()) { QString text = info.name; if (!info.distributionType.trimmed().isEmpty()) { text + " (" + info.distributionType.trimmed() + ')'; } QAction *installAction = installMenu->addAction(QIcon::fromTheme(QStringLiteral("dialog-ok")), text); installAction->setData(info.id); } ui->installButton->setMenu(installMenu); } } void EntryDetails::install() { m_engine->install(m_entry); } void EntryDetails::uninstall() { m_engine->uninstall(m_entry); } void EntryDetails::slotEntryPreviewLoaded(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::PreviewType type) { if (!(entry == m_entry)) { return; } switch (type) { case KNSCore::EntryInternal::PreviewSmall1: ui->preview1->setImage(entry.previewImage(KNSCore::EntryInternal::PreviewSmall1)); break; default: break; } } void EntryDetails::preview1Selected() { previewSelected(0); } void EntryDetails::preview2Selected() { previewSelected(1); } void EntryDetails::preview3Selected() { previewSelected(2); } void EntryDetails::previewSelected(int current) { KNSCore::EntryInternal::PreviewType type = static_cast(KNSCore::EntryInternal::PreviewBig1 + current); m_currentPreview = m_entry.previewImage(type); } void EntryDetails::ratingChanged(uint rating) { m_engine->vote(m_entry, rating * 10); } diff --git a/plugins/extensions/resourcemanager/wdgdlgcontentdownloader.ui b/plugins/extensions/resourcemanager/wdgdlgcontentdownloader.ui index b32dc76003..3289635efd 100644 --- a/plugins/extensions/resourcemanager/wdgdlgcontentdownloader.ui +++ b/plugins/extensions/resourcemanager/wdgdlgcontentdownloader.ui @@ -1,398 +1,385 @@ WdgDlgContentDownloader 0 0 - 740 - 356 + 895 + 505 100 0 Qt::Horizontal 40 20 12 true true false Order by: m_orderbyCombo Qt::Horizontal 40 20 Category: m_categoryCombo true true 2 0 400 190 true QAbstractItemView::NoSelection QAbstractItemView::ScrollPerPixel Search true 0 0 128 128 128 128 50 false false true 3 + + + + Rating: + + + Website: + + + + + + + 30 10 false Qt::Horizontal 40 20 - - - - Rating: - - - - - - - <a href="http://opendesktop.org">Homepage</a> - - - true - - - 0 0 Author: false Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + - + <a href="http://opendesktop.org">Homepage</a> + + + true - + - Description + Description: - - - Qt::Vertical - - - - 20 - 40 - - - + 0 true true Update true Uninstall Install - preview1 - horizontalLayoutWidget_2 - verticalLayoutWidget KTitleWidget QWidget
ktitlewidget.h
KLineEdit QLineEdit
klineedit.h
KComboBox QComboBox
kcombobox.h
ItemsView QListView
itemsview_p.h
ImagePreviewWidget QWidget
imagepreviewwidget_p.h
KRatingWidget QWidget
kratingwidget.h