Commit 27e17f8b authored by Andrea Scarpino's avatar Andrea Scarpino

First

parents
*~
*.pro.user
*.pro.user.*
*.autosave
The MIT License (MIT)
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
TARGET = harbour-lyrics
CONFIG += sailfishapp
SOURCES += \
src/main.cpp \
src/chartlyricsapi.cpp \
src/lyricsmanager.cpp \
src/lyric.cpp
# src/lyricswikiapi.cpp \
HEADERS += \
src/chartlyricsapi.h \
src/lyricsmanager.h \
src/lyric_p.h \
src/lyric.h
# src/lyricswikiapi.h \
OTHER_FILES += \
qml/cover/CoverPage.qml \
qml/Lyrics.qml \
qml/pages/MainPage.qml \
harbour-lyrics.desktop \
rpm/harbour-lyrics.changes \
rpm/harbour-lyrics.spec \
rpm/harbour-lyrics.yaml \
translations/*.ts
CONFIG += sailfishapp_i18n
TRANSLATIONS += translations/harbour-lyrics-it.ts
# LyricsWiki
#QT += webkitwidgets
# ChartLyrics
QT += xml
# harbour-Lyrics
Music lyrics application for [Sailfish OS](https://sailfishos.org).
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ilpianista&url=https://gitlab.com/ilpianista/harbour-Lyrics&title=harbour-Lyrics&language=&tags=jolla&category=software)
\ No newline at end of file
[Desktop Entry]
Type=Application
X-Nemo-Application-Type=silica-qt5
Categories=Audio;
Icon=harbour-lyrics
Exec=harbour-lyrics
Name=Lyrics
Comment=Music lyrics application
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
import "pages"
ApplicationWindow {
initialPage: Component { MainPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
}
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
CoverBackground {
CoverPlaceholder {
text: "Lyrics"
icon.source: "/usr/share/icons/hicolor/86x86/apps/harbour-lyrics.png"
}
}
/*
The MIT License (MIT)
Copyright (c) 2014-2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
Connections {
target: manager
onSearchResult: {
console.log("Got a lyric response, found: " + found);
artist.enabled = true;
song.enabled = true;
busy.running = false;
busy.visible = false;
search.enabled = true;
if (found) {
songText.text = lyric.text;
} else {
songText.text = "Not found :-("
}
}
}
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height
PullDownMenu {
MenuItem {
text: qsTr("Clear")
onClicked: {
artist.text = "";
song.text = "";
songText.text = "";
}
}
}
Column {
id: column
x: Theme.horizontalPageMargin
width: parent.width - Theme.horizontalPageMargin * 2
PageHeader {
title: qsTr("Lyrics")
}
TextField {
id: artist
width: parent.width
focus: true
placeholderText: qsTr("Artist")
}
TextField {
id: song
width: parent.width
placeholderText: qsTr("Song")
}
BusyIndicator {
id: busy
visible: false
anchors.horizontalCenter: parent.horizontalCenter
}
Button {
id: search
text: qsTr("Search")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
if (artist.text.length !== 0 && song.text.length !== 0) {
songText.text = "";
artist.enabled = false;
song.enabled = false;
busy.visible = true;
busy.running = true;
search.enabled = false;
manager.search(artist.text, song.text);
}
}
}
Text {
id: songText
width: parent.width
color: Theme.secondaryColor
wrapMode: Text.Wrap
}
}
VerticalScrollDecorator {}
}
}
* Sat Jun 26 2015 Andrea Scarpino <me@andreascarpino.it> 0.1-1
- First release!
#
# Do NOT Edit the Auto-generated Part!
# Generated by: spectacle version 0.27
#
Name: harbour-lyrics
# >> macros
# << macros
%{!?qtc_qmake:%define qtc_qmake %qmake}
%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Music lyrics application
Version: 0.1
Release: 1
Group: Qt/Qt
License: MIT
URL: http://www.andreascarpino.it
Source0: %{name}-%{version}.tar.bz2
Source100: harbour-lyrics.yaml
Requires: sailfishsilica-qt5 >= 0.10.9
BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Xml)
BuildRequires: desktop-file-utils
%description
Music lyrics application
%prep
%setup -q -n %{name}-%{version}
# >> setup
# << setup
%build
# >> build pre
# << build pre
%qtc_qmake5
%qtc_make %{?_smp_mflags}
# >> build post
# << build post
%install
rm -rf %{buildroot}
# >> install pre
# << install pre
%qmake5_install
# >> install post
# << install post
desktop-file-install --delete-original \
--dir %{buildroot}%{_datadir}/applications \
%{buildroot}%{_datadir}/applications/*.desktop
%files
%defattr(-,root,root,-)
%{_bindir}
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
# >> files
# << files
Name: harbour-lyrics
Summary: Music lyrics application
Version: 0.1
Release: 1
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
Group: Qt/Qt
URL: http://www.andreascarpino.it
License: MIT
# This must be generated before uploading a package to a remote build service.
# Usually this line does not need to be modified.
Sources:
- '%{name}-%{version}.tar.bz2'
Description: |
Music lyrics application
Configure: none
# The qtc5 builder inserts macros to allow QtCreator to have fine
# control over qmake/make execution
Builder: qtc5
# This section specifies build dependencies that are resolved using pkgconfig.
# This is the preferred way of specifying build dependencies for your package.
PkgConfigBR:
- sailfishapp >= 1.0.2
- Qt5Core
- Qt5Qml
- Qt5Quick
- Qt5Xml # ChartLyrics
# - Qt5WebKitWidgets # LyricsWiki
# Build dependencies without a pkgconfig setup can be listed here
# PkgBR:
# - package-needed-to-build
# Runtime dependencies which are not automatically detected
Requires:
- sailfishsilica-qt5 >= 0.10.9
# All installed files
Files:
- '%{_bindir}'
- '%{_datadir}/%{name}'
- '%{_datadir}/applications/%{name}.desktop'
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
# For more information about yaml and what's supported in Sailfish OS
# build system, please see https://wiki.merproject.org/wiki/Spectacle
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "chartlyricsapi.h"
#include <QDebug>
#include <QDomDocument>
#include <QDomNode>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QUrl>
#include <QUrlQuery>
#include "lyric.h"
const static QString API_URL = QStringLiteral("http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect");
ChartLyricsAPI::ChartLyricsAPI(QObject *parent) :
QObject(parent)
, network(new QNetworkAccessManager(this))
{
}
ChartLyricsAPI::~ChartLyricsAPI()
{
delete network;
}
void ChartLyricsAPI::getLyric(const QString &artist, const QString &song)
{
qDebug() << "Requesting lyric for artist" << artist << ", song" << song;
QUrl url(API_URL);
QUrlQuery query;
query.addQueryItem(QStringLiteral("artist"), artist);
query.addQueryItem(QStringLiteral("song"), song);
url.setQuery(query);
QNetworkRequest req(url);
QNetworkReply* reply = network->get(req);
connect(reply, &QNetworkReply::finished, this, &ChartLyricsAPI::onGetLyricResult);
}
void ChartLyricsAPI::onGetLyricResult()
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>(QObject::sender());
bool found = false;
Lyric* lyric;
if (reply->error() != QNetworkReply::NoError) {
qCritical() << "Cannot fetch lyric";
} else {
QDomDocument xml;
QString errorMsg;
xml.setContent(reply->readAll(), &errorMsg);
if (errorMsg.isEmpty()) {
qDebug() << "Got lyric:\n" << xml.toString();
QDomNodeList results = xml.elementsByTagName(QStringLiteral("GetLyricResult"));
if (!results.isEmpty()) {
QDomNode res = results.at(0);
lyric = new Lyric();
lyric->setArtist(res.namedItem(QStringLiteral("LyricArtist")).toElement().text());
lyric->setSong(res.namedItem(QStringLiteral("LyricSong")).toElement().text());
const QString text = res.namedItem(QStringLiteral("Lyric")).toElement().text();
if (!text.isEmpty()) {
lyric->setText(text);
found = true;
}
} else {
qDebug() << "No lyric found";
}
} else {
qCritical() << "Got an invalid XML:" << errorMsg;
}
}
emit lyricFetched(lyric, found);
reply->deleteLater();
}
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef CHARTLYRICSAPI_H
#define CHARTLYRICSAPI_H
#include <QObject>
#include <QString>
class Lyric;
class QNetworkAccessManager;
class QNetworkReply;
class ChartLyricsAPI : public QObject
{
Q_OBJECT
public:
explicit ChartLyricsAPI(QObject *parent = 0);
virtual ~ChartLyricsAPI();
void getLyric(const QString &artist, const QString &song);
Q_SIGNALS:
void lyricFetched(Lyric *lyric, const bool &found);
private:
void onGetLyricResult();
QNetworkAccessManager *network;
};
#endif // CHARTLYRICSAPI_H
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "lyric.h"
#include "lyric_p.h"
Lyric::Lyric(QObject *parent) : QObject(parent)
, d(new LyricPrivate)
{
}
Lyric::~Lyric()
{
delete d;
}
QString Lyric::artist() const
{
return d->artist;
}
void Lyric::setArtist(const QString &artist)
{
d->artist = artist;
}
QString Lyric::song() const
{
return d->song;
}
void Lyric::setSong(const QString &song)
{
d->song = song;
}
QString Lyric::text() const
{
return d->text;
}
void Lyric::setText(const QString &text)
{
d->text = text;
}
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef LYRIC_H
#define LYRIC_H
#include <QObject>
#include <QString>
class LyricPrivate;
class Lyric : public QObject
{
Q_OBJECT
Q_PROPERTY(QString artist READ artist)
Q_PROPERTY(QString song READ song)
Q_PROPERTY(QString text READ text)
public:
explicit Lyric(QObject *parent = 0);
virtual ~Lyric();
QString artist() const;
void setArtist(const QString &artist);
QString song() const;
void setSong(const QString &song);
QString text() const;
void setText(const QString &text);
private:
LyricPrivate *d;
};
#endif // LYRIC_H
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef LYRIC_PRIVATE_H
#define LYRIC_PRIVATE_H
#include <QString>
struct LyricPrivate {
QString artist;
QString song;
QString text;
};
#endif // LYRIC_PRIVATE_H
/*
The MIT License (MIT)
Copyright (c) 2015 Andrea Scarpino <me@andreascarpino.it>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "lyricsmanager.h"
#include <QDebug>
LyricsManager::LyricsManager(QObject *parent) :
QObject(parent)
{