Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
apper
0020-Allow-PackageDetails-to-show-screenshots-f...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0020-Allow-PackageDetails-to-show-screenshots-from-softwa.patch of Package apper
From 784f6d1b31a95a995ebe6b18fb06549ebf627ac5 Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti <dantti12@gmail.com> Date: Fri, 18 Jan 2013 01:39:49 -0200 Subject: [PATCH 20/20] Allow PackageDetails to show screenshots from software.openSUSE.org too --- ApperKCM/PackageDetails.cpp | 44 ++++++++++++++++++++++---------------- ApperKCM/PackageDetails.h | 2 ++ ApperKCM/Updater/DistroUpgrade.cpp | 9 ++++---- CMakeLists.txt | 9 +++++++- config.h.cmake | 3 +++ 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/ApperKCM/PackageDetails.cpp b/ApperKCM/PackageDetails.cpp index 30763f6..8b06944 100644 --- a/ApperKCM/PackageDetails.cpp +++ b/ApperKCM/PackageDetails.cpp @@ -269,11 +269,9 @@ void PackageDetails::setPackage(const QModelIndex &index) m_currentIcon = PkIcons::getIcon(pkgIconPath, QString()).pixmap(64, 64); m_appName = index.data(PackageModel::NameRole).toString(); -#ifdef HAVE_APPSTREAM - m_currentScreenshot = AppStreamDb::instance()->thumbnail(Transaction::packageName(m_packageID)); + m_currentScreenshot = thumbnail(Transaction::packageName(m_packageID)); kDebug() << "current screenshot" << m_currentScreenshot; -#endif - if (!m_currentScreenshot.isEmpty()) { + if (!m_currentScreenshot.isNull()) { if (m_screenshotPath.contains(m_currentScreenshot)) { display(); } else { @@ -297,21 +295,13 @@ void PackageDetails::setPackage(const QModelIndex &index) void PackageDetails::on_screenshotL_clicked() { - kDebug(); -#ifndef HAVE_APPSTREAM - return; -#else - QString screenshot; - - screenshot = AppStreamDb::instance()->screenshot(Transaction::packageName(m_packageID)); - if (screenshot.isEmpty()) { - return; + QString url; + url = screenshot(Transaction::packageName(m_packageID)); + if (!url.isNull()) { + ScreenShotViewer *view = new ScreenShotViewer(url); + view->setWindowTitle(m_appName); + view->show(); } - - ScreenShotViewer *view = new ScreenShotViewer(screenshot); - view->setWindowTitle(m_appName); - view->show(); -#endif } void PackageDetails::hidePackageVersion(bool hide) @@ -717,6 +707,24 @@ QVector<QPair<QString, QString> > PackageDetails::locateApplication(const QStrin return ret; } +QString PackageDetails::thumbnail(const QString &pkgName) const +{ + if (QLatin1String(SCREENSHOT_PROVIDER) == QLatin1String("openSUSE")) { + return QLatin1String("http://software.opensuse.org/package/thumbnail/") % pkgName % QLatin1String(".png");; + } else { + return QLatin1String("http://screenshots.debian.net/thumbnail/") % pkgName; + } +} + +QString PackageDetails::screenshot(const QString &pkgName) const +{ + if (QLatin1String(SCREENSHOT_PROVIDER) == QLatin1String("openSUSE")) { + return QLatin1String("http://software.opensuse.org/package/screenshot/") % pkgName % QLatin1String(".png"); + } else { + return QLatin1String("http://screenshots.debian.net/screenshot/") % pkgName; + } +} + void PackageDetails::description(const QString &packageID, const QString &license, PackageKit::Transaction::Group group, diff --git a/ApperKCM/PackageDetails.h b/ApperKCM/PackageDetails.h index 087c954..c7555c8 100644 --- a/ApperKCM/PackageDetails.h +++ b/ApperKCM/PackageDetails.h @@ -81,6 +81,8 @@ private: void fadeOut(FadeWidgets widgets); void setupDescription(); QVector<QPair<QString, QString> > locateApplication(const QString &_relPath, const QString &menuId) const; + QString thumbnail(const QString &pkgName) const; + QString screenshot(const QString &pkgName) const; Ui::PackageDetails *ui; QActionGroup *m_actionGroup; diff --git a/ApperKCM/Updater/DistroUpgrade.cpp b/ApperKCM/Updater/DistroUpgrade.cpp index 183204e..4987c03 100644 --- a/ApperKCM/Updater/DistroUpgrade.cpp +++ b/ApperKCM/Updater/DistroUpgrade.cpp @@ -42,6 +42,10 @@ DistroUpgrade::DistroUpgrade(QWidget *parent) : addAction(action); } +DistroUpgrade::~DistroUpgrade() +{ +} + void DistroUpgrade::setName(const QString &name) { setText(i18n("Distribution upgrade available: %1", name)); @@ -111,9 +115,4 @@ void DistroUpgrade::distroUpgradeError(QProcess::ProcessError error) } } -DistroUpgrade::~DistroUpgrade() -{ - kDebug() << "~DistroUpgrade()"; -} - #include "DistroUpgrade.moc" diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aca9ff..3215cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,13 @@ if (HAVE_APPSTREAM) message(STATUS "AppStream categories path: " ${AS_CATEGORIES_PATH}) endif (HAVE_APPSTREAM) +# command to edit the packages origins +set(SCREENSHOT_PROVIDER "debian" CACHE STRING "Screen shots provider") +if (SCREENSHOT_PROVIDER) + message(STATUS "Screen shots provider: " ${SCREENSHOT_PROVIDER}) + message(STATUS "Screen shots provider possibilities are: debian, openSUSE") +endif (SCREENSHOT_PROVIDER) + if (DEBCONF_SUPPORT) # Tries to find the package, when it finds it HAVE_DEBCONFKDE is set in config.h find_package(DebconfKDE REQUIRED) @@ -41,7 +48,7 @@ if (DEBCONF_SUPPORT) message(STATUS "Building with Debconf support") endif (DEBCONF_SUPPORT) -set(APP_VERSION 0.8.0) +set(APP_VERSION 0.8.1) # command to edit the packages origins set(EDIT_ORIGNS_DESKTOP_NAME "" CACHE STRING "Edit origins desktop name") diff --git a/config.h.cmake b/config.h.cmake index 4e3caba..176a30b 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -10,6 +10,9 @@ // Define if AppStream data is available. #cmakedefine HAVE_APPSTREAM +// Define if screenshot provider +#cmakedefine SCREENSHOT_PROVIDER "@SCREENSHOT_PROVIDER@" + // Define the AppStream categories path. #cmakedefine AS_CATEGORIES_PATH "@AS_CATEGORIES_PATH@" -- 1.8.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor