So users are not forced to use the Amarok shopping cart. Especially for countrys where a direct checkout is not possible due to API limitations (.com only atm) this is a big usability improvement.
Git commit a3440557daae2326e4e3b6ffc8b57bdaf206c274 by Sven Krohlas. Committed on 05/05/2012 at 15:13. Pushed by krohlas into branch 'master'. Amazon store: ability to check single items out directly So the user does not have to use the integrated shopping cart (which does not work for Amazon.com at all, due to their API limitations). This currenly only works correctly for Amazon.com, some server side changes are required for the other locales. Those will show up shortly. BUG:288808 FIXED-IN:2.6 M +3 -0 ChangeLog M +14 -0 src/services/amazon/AmazonItemTreeView.cpp M +2 -0 src/services/amazon/AmazonItemTreeView.h M +27 -0 src/services/amazon/AmazonStore.cpp M +6 -1 src/services/amazon/AmazonStore.h http://commits.kde.org/amarok/a3440557daae2326e4e3b6ffc8b57bdaf206c274 diff --git a/ChangeLog b/ChangeLog index be4ec11..70b22fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ VERSION 2.6-Beta 1 * Support for setting cover images for albums on USB Mass Storage devices. * Support for setting and unsetting cover images for iPod albums, can write back covers to file meta-data too, respects configuration. + * Amazon store: ability to check out an item directly without using the Amarok + shopping cart. (BR 288808) + * Amarok now includes the Free Music Charts service by default. * The maximum dimensions for embedded covers are now configurable. (BR 279493) * Small configuration dialog for iPods that shows troubleshooting information and allows to change iPod name. diff --git a/src/services/amazon/AmazonItemTreeView.cpp b/src/services/amazon/AmazonItemTreeView.cpp index 0f3ed4a..c414445 100644 --- a/src/services/amazon/AmazonItemTreeView.cpp +++ b/src/services/amazon/AmazonItemTreeView.cpp @@ -86,6 +86,7 @@ AmazonItemTreeView::contextMenuEvent( QContextMenuEvent *event ) } actions.append( createAddToCartAction() ); + actions.append( createDirectCheckoutAction() ); menu.exec( actions, event->globalPos() ); event->accept(); @@ -196,6 +197,10 @@ AmazonItemTreeView::startDrag( Qt::DropActions supportedActions ) m_pd->addItem( The::popupDropperFactory()->createItem( createAddToCartAction() ) ); + QAction *directCheckoutAction = createDirectCheckoutAction(); + directCheckoutAction->setProperty( "popupdropper_svg_id", "download" ); + m_pd->addItem( The::popupDropperFactory()->createItem( directCheckoutAction ) ); + m_pd->show(); } @@ -294,6 +299,15 @@ AmazonItemTreeView::createDetailsAction() } QAction* +AmazonItemTreeView::createDirectCheckoutAction() +{ + QAction *directCheckoutAction = new QAction( KIcon( "download-amarok" ), QString( i18n( "Direct Checkout" ) ), this ); + connect( directCheckoutAction, SIGNAL( triggered() ), this, SIGNAL( directCheckout() ) ); + + return directCheckoutAction; +} + +QAction* AmazonItemTreeView::createSearchForAlbumAction() { QAction *searchForAlbumAction = new QAction( KIcon( "media-optical-amarok" ), QString( i18n( "Search for Album..." ) ), this ); diff --git a/src/services/amazon/AmazonItemTreeView.h b/src/services/amazon/AmazonItemTreeView.h index 88a151d..1ced620 100644 --- a/src/services/amazon/AmazonItemTreeView.h +++ b/src/services/amazon/AmazonItemTreeView.h @@ -65,10 +65,12 @@ private: QAction* createAddToCartAction(); QAction* createAddToPlaylistAction(); QAction* createDetailsAction(); + QAction* createDirectCheckoutAction(); QAction* createSearchForAlbumAction(); signals: void addToCart(); + void directCheckout(); void itemDoubleClicked( QModelIndex index ); void itemSelected( QModelIndex index ); void searchForAlbum( QModelIndex index ); diff --git a/src/services/amazon/AmazonStore.cpp b/src/services/amazon/AmazonStore.cpp index 085b852..dde7934 100644 --- a/src/services/amazon/AmazonStore.cpp +++ b/src/services/amazon/AmazonStore.cpp @@ -224,6 +224,32 @@ AmazonStore::checkout() } void +AmazonStore::directCheckout() +{ + if( !m_selectedIndex.isValid() ) + return; + + // get item ASIN from collection + int id = m_itemModel->idForIndex( m_selectedIndex ); + QString asin; + Meta::AmazonItem* item; + + if( m_itemModel->isAlbum( m_selectedIndex ) ) // album + item = dynamic_cast<Meta::AmazonItem*>( m_collection->albumById( id ).data() ); + else // track + item = dynamic_cast<Meta::AmazonItem*>( m_collection->trackById( id ).data() ); + + if( !item ) + return; + + asin = item->asin(); + + // create and open direct checkout url + QUrl url( "http://www.mp3-music-store.de/buy.php?Location=" + AmazonConfig::instance()->country() + "&Player=amarok&ASINs[]=" + asin ); + QDesktopServices::openUrl( url ); +} + +void AmazonStore::itemDoubleClicked( QModelIndex index ) { // for albums: search for the album name to get details about it @@ -456,6 +482,7 @@ AmazonStore::initView() connect( m_addToCartButton, SIGNAL( clicked() ), this, SLOT( addToCart() ) ); connect( m_itemView, SIGNAL( addToCart() ), this, SLOT( addToCart() ) ); + connect( m_itemView, SIGNAL( directCheckout() ), this, SLOT( directCheckout() ) ); connect( m_viewCartButton, SIGNAL( clicked() ), this, SLOT( viewCart() ) ); connect( m_checkoutButton, SIGNAL( clicked() ), this, SLOT( checkout() ) ); } diff --git a/src/services/amazon/AmazonStore.h b/src/services/amazon/AmazonStore.h index bfc310c..19f1085 100644 --- a/src/services/amazon/AmazonStore.h +++ b/src/services/amazon/AmazonStore.h @@ -87,11 +87,16 @@ public slots: void viewCart(); /** - * Checks the none-empty cart out. + * Checks the non-empty cart out. */ void checkout(); /** + * Checks the currently selected item out directly, without adding it to the local Amarok shopping cart. + */ + void directCheckout(); + + /** * React to a double click on an item. * @param index The QModelIndex of the item. */