Fix wikpedia/last.fm link in track view

This commit is contained in:
craig.p.drummond
2014-06-10 19:45:08 +00:00
committed by craig.p.drummond
parent 110ca299c1
commit 27bc161f39
9 changed files with 48 additions and 24 deletions

View File

@@ -35,7 +35,6 @@
#include <QScrollBar>
#include <QFile>
#include <QUrl>
#include <QProcess>
#include <QMenu>
#include <QTimer>
#include <QCoreApplication>
@@ -160,11 +159,7 @@ void AlbumView::playSong(const QUrl &url)
if (QLatin1String("cantata")==url.scheme()) {
emit playSong(url.path().mid(1)); // Remove leading /
} else {
#ifdef Q_OS_WIN
QProcess::startDetached(QLatin1String("cmd"), QStringList() << QLatin1String("/c") << QLatin1String("start") << url.toString());
#else
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << url.toString());
#endif
Utils::openBrowser(url);
}
}

View File

@@ -38,7 +38,6 @@
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
#include <QProcess>
#include <QXmlStreamReader>
#include <QPixmap>
#include <QFile>
@@ -477,11 +476,7 @@ void ArtistView::show(const QUrl &url)
}
}
} else {
#ifdef Q_OS_WIN
QProcess::startDetached(QLatin1String("cmd"), QStringList() << QLatin1String("/c") << QLatin1String("start") << url.toString());
#else
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << url.toString());
#endif
Utils::openBrowser(url);
}
}

View File

@@ -138,6 +138,9 @@ SongView::SongView(QWidget *p)
connect(refreshInfoAction, SIGNAL(triggered()), SLOT(refreshInfo()));
connect(cancelInfoJobAction, SIGNAL(triggered()), SLOT(abortInfoSearch()));
connect(engine, SIGNAL(searchResult(QString,QString)), this, SLOT(infoSearchResponse(QString,QString)));
foreach (TextBrowser *t, texts) {
connect(t, SIGNAL(anchorClicked(QUrl)), SLOT(showMoreInfo(QUrl)));
}
text->setContextMenuPolicy(Qt::CustomContextMenu);
connect(text, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
@@ -454,6 +457,11 @@ void SongView::abortInfoSearch()
}
}
void SongView::showMoreInfo(const QUrl &url)
{
Utils::openBrowser(url);
}
void SongView::hideSpinner()
{
if (!cancelInfoJobAction->isEnabled() && !cancelJobAction->isEnabled()) {

View File

@@ -84,6 +84,7 @@ private Q_SLOTS:
void refreshInfo();
void infoSearchResponse(const QString &resp, const QString &lang);
void abortInfoSearch();
void showMoreInfo(const QUrl &url);
private:
void loadInfo();

View File

@@ -28,10 +28,8 @@
#include "support/localize.h"
#include "support/messagebox.h"
#include "support/actioncollection.h"
#include "support/utils.h"
#include "stdactions.h"
#ifndef Q_OS_WIN
#include <QProcess>
#endif
FolderPage::FolderPage(QWidget *p)
: QWidget(p)
@@ -40,7 +38,7 @@ FolderPage::FolderPage(QWidget *p)
setupUi(this);
addToPlayQueue->setDefaultAction(StdActions::self()->addToPlayQueueAction);
replacePlayQueue->setDefaultAction(StdActions::self()->replacePlayQueueAction);
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
browseAction = ActionCollection::get()->createAction("openfilemanager", i18n("Open In File Manager"), "system-file-manager");
#endif
@@ -58,7 +56,7 @@ FolderPage::FolderPage(QWidget *p)
view->addAction(StdActions::self()->replaygainAction);
#endif // TAGLIB_FOUND
#endif
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
view->addAction(browseAction);
#endif
#ifdef ENABLE_DEVICES_SUPPORT
@@ -76,7 +74,7 @@ FolderPage::FolderPage(QWidget *p)
connect(view, SIGNAL(searchItems()), this, SLOT(searchItems()));
connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
connect(browseAction, SIGNAL(triggered(bool)), this, SLOT(openFileManager()));
#endif
connect(MPDConnection::self(), SIGNAL(updatingFileList()), this, SLOT(showSpinner()));
@@ -166,7 +164,7 @@ void FolderPage::controlActions()
#endif
#endif // TAGLIB_FOUND
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
browseAction->setEnabled(false);
if (1==selected.count() && MPDConnection::self()->getDetails().dirReadable) {
DirViewItem *item = static_cast<DirViewItem *>(proxy.mapToSource(selected.at(0)).internalPointer());
@@ -190,7 +188,7 @@ void FolderPage::itemDoubleClicked(const QModelIndex &)
void FolderPage::openFileManager()
{
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
const QModelIndexList selected = view->selectedIndexes(false); // Dont need sorted selection here...
if (1!=selected.size()) {
return;
@@ -199,7 +197,7 @@ void FolderPage::openFileManager()
DirViewItem *item = static_cast<DirViewItem *>(proxy.mapToSource(selected.at(0)).internalPointer());
if (DirViewItem::Type_Dir==item->type()) {
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << MPDConnection::self()->getDetails().dir+item->fullName());
Utils::openFileManager(MPDConnection::self()->getDetails().dir+item->fullName());
}
#endif
}

View File

@@ -84,7 +84,7 @@ private:
private:
bool loaded;
#ifndef Q_OS_WIN
#if !defined Q_OS_WIN && !defined Q_OS_MAC
Action *browseAction;
#endif
DirViewProxyModel proxy;

View File

@@ -48,7 +48,6 @@
#include <QFile>
#include <QXmlStreamReader>
#include <QCryptographicHash>
#include <QProcess>
#include <QCache>
#include <QImage>
#include <QBuffer>
@@ -314,7 +313,7 @@ void PodcastPage::jobFinished()
void PodcastPage::openLink(const QUrl &url)
{
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << url.toString());
Utils::openBrowser(url);
}
PodcastSearchPage::PodcastSearchPage(QWidget *p, const QString &n, const QString &i, const QUrl &qu, const QString &qk, const QStringList &other)

View File

@@ -27,6 +27,8 @@
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QUrl>
#include <QProcess>
#include <QSet>
#include <QThread>
#include <QApplication>
@@ -727,6 +729,29 @@ QString Utils::helper(const QString &app)
#endif
}
void Utils::openBrowser(const QUrl &url)
{
#if defined Q_OS_WIN
QProcess::startDetached(QLatin1String("cmd"), QStringList() << QLatin1String("/c") << QLatin1String("start") << url.toString());
//#elif definedQ_OS_MAC
// TODO!!!
#else
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << url.toString());
#endif
}
void Utils::openFileManager(const QString &dir)
{
#if defined Q_OS_WIN
Q_UNUSED(dir) // TODO!!!
#elif definedQ_OS_MAC
Q_UNUSED(dir) // TODO!!!
#else
QProcess::startDetached(QLatin1String("xdg-open"), QStringList() << dir);
#endif
}
bool Utils::moveFile(const QString &from, const QString &to)
{
return !from.isEmpty() && !to.isEmpty() && from!=to && QFile::exists(from) && !QFile::exists(to) && QFile::rename(from, to);

View File

@@ -44,6 +44,7 @@
class QString;
class QWidget;
class QUrl;
namespace Utils
{
@@ -98,6 +99,8 @@ namespace Utils
extern QString cacheDir(const QString &sub=QString(), bool create=true);
extern QString systemDir(const QString &sub);
extern QString helper(const QString &app);
extern void openBrowser(const QUrl &url);
extern void openFileManager(const QString &dir);
extern bool moveFile(const QString &from, const QString &to);
extern void moveDir(const QString &from, const QString &to);
extern void clearOldCache(const QString &sub, int maxAge);