Skip to content

Commit

Permalink
Separate to lib plugin and app
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Sep 11, 2022
1 parent 9539bfa commit b9277b9
Show file tree
Hide file tree
Showing 27 changed files with 199 additions and 67 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include(FeatureSummary)
include(GNUInstallDirs)

set(QT_MIN_VERSION "5.11.0")
find_package(Qt5 COMPONENTS Qml Quick Multimedia Sql DBus LinguistTools REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Qml Quick Multimedia Sql DBus LinguistTools REQUIRED)
find_package(Glacier 0.8 COMPONENTS App REQUIRED)
find_package(Qt5QuickCompiler)
find_package(PkgConfig REQUIRED)
Expand Down
23 changes: 5 additions & 18 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,30 @@
set(SRC
artist.cpp
artist.h
audiofile.cpp
audiofile.h
collection.cpp
collection.h
cover.cpp
cover.h
dbadapter.cpp
dbadapter.h
downloader.cpp
downloader.h
item.h
main.cpp
musicbrainzconnect.cpp
musicbrainzconnect.h
rescancollection.cpp
rescancollection.h
track.cpp
track.h
models/artistsqlmodel.cpp
models/artistsqlmodel.h
models/playlistmodel.cpp
models/playlistmodel.h
models/tracksqlmodel.cpp
models/tracksqlmodel.h)
rescancollection.h)

qtquick_compiler_add_resources(RESOURCES qml/glacier-music.qrc)

add_executable(glacier-music ${SRC} ${RESOURCES})
add_subdirectory(lib)
add_subdirectory(plugin)
include_directories("lib")
add_executable(glacier-music ${SRC} ${RESOURCES})

target_link_libraries(glacier-music
Qt5::Qml
Qt5::Quick
Qt5::Multimedia
Qt5::Sql
Qt5::DBus
Glacier::App
Glacier::Music
PkgConfig::TAGLIB
PkgConfig::NEMONOTIFICATIONS)
install(TARGETS glacier-music RUNTIME
Expand Down
25 changes: 25 additions & 0 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(SRC artist.cpp
audiofile.cpp
dbadapter.cpp
track.cpp)

set(HEADERS item.h)

set(PUBLIC_HEADERS artist.h
audiofile.h
dbadapter.h
track.h)

add_library(glaciermusic SHARED ${SRC} ${HEADERS} ${PUBLIC_HEADERS})
add_library(Glacier::Music ALIAS glaciermusic)

target_link_libraries(glaciermusic
Qt5::Core
Qt5::Gui
Qt5::Sql)

install(TARGETS glaciermusic
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/)

install(FILES ${PUBLIC_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glacier-music)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/track.cpp → src/lib/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "track.h"
#include "dbadapter.h"
#include "audiofile.h"
#include "musicbrainzconnect.h"

Track::Track(const QString file, QObject *parent) : QObject(parent)
, m_id(0)
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

#include "collection.h"
#include "cover.h"
#include "models/artistsqlmodel.h"
#include "models/tracksqlmodel.h"
#include "models/playlistmodel.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
Expand All @@ -46,10 +43,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qmlRegisterType<Collection>("org.glacier.music.collection",1,0,"Collection");
qmlRegisterType<Cover>("org.glacier.music.cover",1,0,"Cover");

qmlRegisterType<ArtistSqlModel>("org.glacier.music.artistmodel",1,0,"ArtistModel");
qmlRegisterType<TrackSqlModel>("org.glacier.music.trackmodel",1,0,"TrackModel");
qmlRegisterType<PlayListModel>("org.glacier.music.playlistmodel",1,0,"PlaylistModel");

QQuickWindow *window = GlacierApp::showWindow();
window->setTitle(QObject::tr("Music"));
window->setIcon(QIcon("/usr/share/glacier-music/images/icon-app-music.png"));
Expand Down
25 changes: 0 additions & 25 deletions src/models/tracksqlmodel.h

This file was deleted.

17 changes: 13 additions & 4 deletions src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,32 @@ endfunction()

set(SRC
plugin.cpp
artistsqlmodel.cpp
artistsqlmodel.h
blurredimage.cpp
blurredimage.h
peakscreator.cpp
peakscreator.h
playlistmodel.cpp
playlistmodel.h
tracksqlmodel.cpp
tracksqlmodel.h
wavewidget.cpp
wavewidget.h)

add_library(glaciermusic SHARED ${SRC})
add_library(glaciermusicplugin SHARED ${SRC})
include_directories("../lib")

target_link_libraries(glaciermusic
target_link_libraries(glaciermusicplugin
Qt5::Core
Qt5::Gui
Qt5::Qml
Qt5::Quick
Qt5::Multimedia)
Qt5::Multimedia
Qt5::Sql
Glacier::Music)

FindQtInstallQml()

install(FILES qmldir DESTINATION ${QT_INSTALL_QML}/org/glacier/music/)
install(TARGETS glaciermusic DESTINATION ${QT_INSTALL_QML}/org/glacier/music/)
install(TARGETS glaciermusicplugin DESTINATION ${QT_INSTALL_QML}/org/glacier/music/)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "artistsqlmodel.h"
#include "../dbadapter.h"
#include <dbadapter.h>

#include <QSqlQueryModel>

Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions src/models/playlistmodel.cpp → src/plugin/playlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* Boston, MA 02110-1301, USA.
*/


#include "playlistmodel.h"

#include "../track.h"
#include "../dbadapter.h"
#include <track.h>
#include <dbadapter.h>

#include <QSqlDatabase>
#include <QSqlQuery>
Expand Down
2 changes: 1 addition & 1 deletion src/models/playlistmodel.h → src/plugin/playlistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <QObject>
#include <QAbstractListModel>

#include "../track.h"
#include "track.h"

class PlayListModel: public QAbstractListModel
{
Expand Down
7 changes: 7 additions & 0 deletions src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "blurredimage.h"
#include "wavewidget.h"
#include "artistsqlmodel.h"
#include "tracksqlmodel.h"
#include "playlistmodel.h"

class Q_DECL_EXPORT GlacierMusicPlugin : public QQmlExtensionPlugin
{
Expand All @@ -44,6 +47,10 @@ class Q_DECL_EXPORT GlacierMusicPlugin : public QQmlExtensionPlugin
// @uri org.glacier.music
qmlRegisterType<WaveWidget>(uri ,1,0,"WaveWidget");
qmlRegisterType<BlurredImage>(uri,1,0,"BlurredImage");

qmlRegisterType<ArtistSqlModel>(uri,1,0,"ArtistModel");
qmlRegisterType<TrackSqlModel>(uri,1,0,"TrackModel");
qmlRegisterType<PlayListModel>(uri,1,0,"PlaylistModel");
}
};

Expand Down
21 changes: 20 additions & 1 deletion src/models/tracksqlmodel.cpp → src/plugin/tracksqlmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/*
* Copyright (C) 2021-2022 Chupligin Sergey <neochapay@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 "tracksqlmodel.h"
#include "../dbadapter.h"
#include <dbadapter.h>

#include <QDebug>

Expand Down
43 changes: 43 additions & 0 deletions src/plugin/tracksqlmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2021-2022 Chupligin Sergey <neochapay@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.
*/
#ifndef TRACKSQLMODEL_H
#define TRACKSQLMODEL_H

#include <QSqlQueryModel>

class TrackSqlModel :public QSqlQueryModel
{
Q_OBJECT

public:
explicit TrackSqlModel(QObject *parent = 0);
QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const {return hash;}

private:
const static char* SQL_SELECT;
QHash<int,QByteArray> hash;

public slots:
void refresh();
void setArtist(const int artist_id);
void cleanQuery();
};

#endif // TRACKSQLMODEL_H
2 changes: 1 addition & 1 deletion src/qml/glacier-music.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.nemomobile.settings 1.0
import org.nemomobile.mpris 1.0

import org.glacier.music.collection 1.0
import org.glacier.music.playlistmodel 1.0
import org.glacier.music 1.0
import org.glacier.music.cover 1.0

import Nemo.Dialogs 1.0
Expand Down
21 changes: 20 additions & 1 deletion src/qml/pages/ArtistsPage.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
/*
* Copyright (C) 2021-2022 Chupligin Sergey <neochapay@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.
*/

import QtQuick 2.6

import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import org.glacier.music.artistmodel 1.0
import org.glacier.music 1.0

Item{
id: artistPage
Expand Down
21 changes: 20 additions & 1 deletion src/qml/pages/EditTrackPage.qml
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
/*
* Copyright (C) 2021-2022 Chupligin Sergey <neochapay@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.
*/

import QtQuick 2.6

import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0


import org.glacier.music.trackmodel 1.0
import org.glacier.music 1.0
import "../components"

Page {
Expand Down
Loading

0 comments on commit b9277b9

Please sign in to comment.