diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 792769dd2..c61913f71 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,8 @@ set(SOURCES core/translations.cpp core/systemtrayicon.cpp core/localredirectserver.cpp + core/mimedata.cpp + core/potranslator.cpp utilities/strutils.cpp utilities/envutils.cpp utilities/colorutils.cpp @@ -110,8 +112,10 @@ set(SOURCES playlist/playlistfilter.cpp playlist/playlistheader.cpp playlist/playlistitem.cpp + playlist/playlistitemmimedata.cpp playlist/playlistlistcontainer.cpp playlist/playlistlistmodel.cpp + playlist/playlistlistsortfiltermodel.cpp playlist/playlistlistview.cpp playlist/playlistmanager.cpp playlist/playlistsaveoptionsdialog.cpp @@ -120,6 +124,7 @@ set(SOURCES playlist/playlistundocommands.cpp playlist/playlistview.cpp playlist/playlistproxystyle.cpp + playlist/songmimedata.cpp playlist/songloaderinserter.cpp playlist/songplaylistitem.cpp playlist/dynamicplaylistcontrols.cpp @@ -140,6 +145,7 @@ set(SOURCES smartplaylists/playlistgenerator.cpp smartplaylists/playlistgeneratorinserter.cpp + smartplaylists/playlistgeneratormimedata.cpp smartplaylists/playlistquerygenerator.cpp smartplaylists/smartplaylistquerywizardplugin.cpp smartplaylists/smartplaylistsearch.cpp @@ -270,6 +276,7 @@ set(SOURCES streaming/streamingcollectionview.cpp streaming/streamingcollectionviewcontainer.cpp streaming/streamingsearchview.cpp + streaming/streamsongmimedata.cpp radios/radioservices.cpp radios/radiobackend.cpp @@ -281,6 +288,7 @@ set(SOURCES radios/radiochannel.cpp radios/somafmservice.cpp radios/radioparadiseservice.cpp + radios/radiomimedata.cpp scrobbler/audioscrobbler.cpp scrobbler/scrobblersettings.cpp @@ -764,6 +772,7 @@ optional_source(HAVE_LIBPULSE SOURCES engine/pulsedevicefinder.cpp) optional_source(HAVE_GSTREAMER SOURCES transcoder/transcoder.cpp + transcoder/transcoderoptionsinterface.cpp transcoder/transcodedialog.cpp transcoder/transcoderoptionsdialog.cpp transcoder/transcoderoptionsflac.cpp diff --git a/src/core/mimedata.cpp b/src/core/mimedata.cpp new file mode 100644 index 000000000..3cec05e34 --- /dev/null +++ b/src/core/mimedata.cpp @@ -0,0 +1,44 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "config.h" + +#include + +#include "mimedata.h" + +MimeData::MimeData(const bool clear, const bool play_now, const bool enqueue, const bool enqueue_next_now, const bool open_in_new_playlist, QObject *parent) + : override_user_settings_(false), + clear_first_(clear), + play_now_(play_now), + enqueue_now_(enqueue), + enqueue_next_now_(enqueue_next_now), + open_in_new_playlist_(open_in_new_playlist), + name_for_new_playlist_(QString()), + from_doubleclick_(false) { + + Q_UNUSED(parent); + +} + +QString MimeData::get_name_for_new_playlist() const { + return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_; +} diff --git a/src/core/mimedata.h b/src/core/mimedata.h index d3233fb5b..6002b4484 100644 --- a/src/core/mimedata.h +++ b/src/core/mimedata.h @@ -2,6 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +22,6 @@ #ifndef MIMEDATA_H #define MIMEDATA_H -#include "config.h" - -#include #include #include @@ -31,15 +29,7 @@ class MimeData : public QMimeData { Q_OBJECT public: - explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject* = nullptr) - : override_user_settings_(false), - clear_first_(clear), - play_now_(play_now), - enqueue_now_(enqueue), - enqueue_next_now_(enqueue_next_now), - open_in_new_playlist_(open_in_new_playlist), - name_for_new_playlist_(QString()), - from_doubleclick_(false) {} + explicit MimeData(const bool clear = false, const bool play_now = false, const bool enqueue = false, const bool enqueue_next_now = false, const bool open_in_new_playlist = false, QObject *parent = nullptr); // If this is set then MainWindow will not touch any of the other flags. bool override_user_settings_; @@ -69,9 +59,7 @@ class MimeData : public QMimeData { // Returns a pretty name for a playlist containing songs described by this MimeData object. // By pretty name we mean the value of 'name_for_new_playlist_' or generic "Playlist" string if the 'name_for_new_playlist_' attribute is empty. - QString get_name_for_new_playlist() { - return name_for_new_playlist_.isEmpty() ? tr("Playlist") : name_for_new_playlist_; - } + QString get_name_for_new_playlist() const; }; #endif // MIMEDATA_H diff --git a/src/core/potranslator.cpp b/src/core/potranslator.cpp new file mode 100644 index 000000000..decf8b271 --- /dev/null +++ b/src/core/potranslator.cpp @@ -0,0 +1,34 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include + +#include "potranslator.h" + +PoTranslator::PoTranslator(QObject *parent) : QTranslator(parent) {} + +QString PoTranslator::translate(const char *context, const char *source_text, const char *disambiguation, const int n) const { + + QString ret = QTranslator::translate(context, source_text, disambiguation, n); + if (!ret.isEmpty()) return ret; + return QTranslator::translate(nullptr, source_text, disambiguation, n); + +} diff --git a/src/core/potranslator.h b/src/core/potranslator.h index ee2d262e6..ac0fb4d70 100644 --- a/src/core/potranslator.h +++ b/src/core/potranslator.h @@ -2,6 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +23,7 @@ #define POTRANSLATOR_H #include +#include // We convert from .po files to .qm files, which loses context information. // This translator tries loading strings with an empty context if it can't find any others. @@ -30,12 +32,8 @@ class PoTranslator : public QTranslator { Q_OBJECT public: - PoTranslator(QObject *parent = nullptr) : QTranslator(parent) {} - QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override { - QString ret = QTranslator::translate(context, source_text, disambiguation, n); - if (!ret.isEmpty()) return ret; - return QTranslator::translate(nullptr, source_text, disambiguation, n); - } + explicit PoTranslator(QObject *parent = nullptr); + QString translate(const char *context, const char *source_text, const char *disambiguation = nullptr, int n = -1) const override; }; #endif // POTRANSLATOR_H diff --git a/src/playlist/playlistitemmimedata.cpp b/src/playlist/playlistitemmimedata.cpp new file mode 100644 index 000000000..69ed9d3ad --- /dev/null +++ b/src/playlist/playlistitemmimedata.cpp @@ -0,0 +1,37 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "playlistitemmimedata.h" +#include "playlistitem.h" + +PlaylistItemMimeData::PlaylistItemMimeData(const PlaylistItemPtr &item, QObject *parent) + : items_(PlaylistItemPtrList() << item) { + + Q_UNUSED(parent); + +} + +PlaylistItemMimeData::PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject *parent) + : items_(items) { + + Q_UNUSED(parent); + +} diff --git a/src/playlist/playlistitemmimedata.h b/src/playlist/playlistitemmimedata.h index d6e7ca1bc..d4fc8acd1 100644 --- a/src/playlist/playlistitemmimedata.h +++ b/src/playlist/playlistitemmimedata.h @@ -2,6 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,8 +33,8 @@ class PlaylistItemMimeData : public MimeData { Q_OBJECT public: - explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject* = nullptr) : MimeData(), items_(PlaylistItemPtrList() << item) {} - explicit PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject* = nullptr) : MimeData(), items_(items) {} + explicit PlaylistItemMimeData(const PlaylistItemPtr &item, QObject *parent = nullptr); + explicit PlaylistItemMimeData(const PlaylistItemPtrList &items, QObject *parent = nullptr); PlaylistItemPtrList items_; }; diff --git a/src/playlist/playlistlistsortfiltermodel.cpp b/src/playlist/playlistlistsortfiltermodel.cpp new file mode 100644 index 000000000..9a0607d3e --- /dev/null +++ b/src/playlist/playlistlistsortfiltermodel.cpp @@ -0,0 +1,36 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "playlistlistsortfiltermodel.h" + +PlaylistListSortFilterModel::PlaylistListSortFilterModel(QObject *parent) + : QSortFilterProxyModel(parent) {} + +bool PlaylistListSortFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { + + // Compare the display text first. + const int ret = left.data().toString().localeAwareCompare(right.data().toString()); + if (ret < 0) return true; + if (ret > 0) return false; + + // Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same. + return left.row() < right.row(); +} diff --git a/src/playlist/playlistlistsortfiltermodel.h b/src/playlist/playlistlistsortfiltermodel.h index 7eca0baf3..6abb69512 100644 --- a/src/playlist/playlistlistsortfiltermodel.h +++ b/src/playlist/playlistlistsortfiltermodel.h @@ -2,7 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome - * Copyright 2018-2021, Jonas Kvinge + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,18 +28,9 @@ class PlaylistListSortFilterModel : public QSortFilterProxyModel { Q_OBJECT public: - explicit PlaylistListSortFilterModel(QObject *parent) - : QSortFilterProxyModel(parent) {} + explicit PlaylistListSortFilterModel(QObject *parent); - bool lessThan(const QModelIndex &left, const QModelIndex &right) const override { - // Compare the display text first. - const int ret = left.data().toString().localeAwareCompare(right.data().toString()); - if (ret < 0) return true; - if (ret > 0) return false; - - // Now use the source model row order to ensure we always get a deterministic sorting even when two items are named the same. - return left.row() < right.row(); - } + bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; }; #endif // PLAYLISTLISTSORTFILTERMODEL_H diff --git a/src/playlist/songmimedata.cpp b/src/playlist/songmimedata.cpp new file mode 100644 index 000000000..7c6177d3e --- /dev/null +++ b/src/playlist/songmimedata.cpp @@ -0,0 +1,26 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "songmimedata.h" + +SongMimeData::SongMimeData(QObject *parent) : backend(nullptr) { + Q_UNUSED(parent); +} diff --git a/src/playlist/songmimedata.h b/src/playlist/songmimedata.h index 1d5ba8783..f206d24a1 100644 --- a/src/playlist/songmimedata.h +++ b/src/playlist/songmimedata.h @@ -2,6 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,9 +24,6 @@ #include "config.h" -#include -#include - #include "core/shared_ptr.h" #include "core/mimedata.h" #include "core/song.h" @@ -36,7 +34,7 @@ class SongMimeData : public MimeData { Q_OBJECT public: - explicit SongMimeData(QObject* = nullptr) : MimeData(), backend(nullptr) {} + explicit SongMimeData(QObject *parent = nullptr); SharedPtr backend; SongList songs; diff --git a/src/radios/radiomimedata.cpp b/src/radios/radiomimedata.cpp new file mode 100644 index 000000000..d7192c12c --- /dev/null +++ b/src/radios/radiomimedata.cpp @@ -0,0 +1,26 @@ +/* + * Strawberry Music Player + * Copyright 2021, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "radiomimedata.h" + +RadioMimeData::RadioMimeData(QObject *parent) { + + Q_UNUSED(parent); + +} diff --git a/src/radios/radiomimedata.h b/src/radios/radiomimedata.h index 77a752682..bdf95b835 100644 --- a/src/radios/radiomimedata.h +++ b/src/radios/radiomimedata.h @@ -29,7 +29,7 @@ class RadioMimeData : public MimeData { Q_OBJECT public: - explicit RadioMimeData(QObject* = nullptr) {} + explicit RadioMimeData(QObject *parent = nullptr); SongList songs; }; diff --git a/src/smartplaylists/playlistgeneratormimedata.cpp b/src/smartplaylists/playlistgeneratormimedata.cpp new file mode 100644 index 000000000..4ecfc28dc --- /dev/null +++ b/src/smartplaylists/playlistgeneratormimedata.cpp @@ -0,0 +1,29 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "playlistgeneratormimedata.h" +#include "playlistgenerator_fwd.h" + +PlaylistGeneratorMimeData::PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject *parent) + : generator_(generator) { + + Q_UNUSED(parent); + +} diff --git a/src/smartplaylists/playlistgeneratormimedata.h b/src/smartplaylists/playlistgeneratormimedata.h index 2e596f40e..e33623f41 100644 --- a/src/smartplaylists/playlistgeneratormimedata.h +++ b/src/smartplaylists/playlistgeneratormimedata.h @@ -23,9 +23,6 @@ #include "config.h" -#include -#include - #include "core/mimedata.h" #include "playlistgenerator_fwd.h" @@ -33,7 +30,7 @@ class PlaylistGeneratorMimeData : public MimeData { Q_OBJECT public: - PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject* = nullptr) : generator_(generator) {} + PlaylistGeneratorMimeData(PlaylistGeneratorPtr generator, QObject *parent = nullptr); PlaylistGeneratorPtr generator_; }; diff --git a/src/streaming/streamsongmimedata.cpp b/src/streaming/streamsongmimedata.cpp new file mode 100644 index 000000000..2e47031ea --- /dev/null +++ b/src/streaming/streamsongmimedata.cpp @@ -0,0 +1,27 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2011, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include "core/shared_ptr.h" +#include "streamsongmimedata.h" + +StreamSongMimeData::StreamSongMimeData(SharedPtr _service, QObject *parent) : service(_service) { + Q_UNUSED(parent); +} diff --git a/src/streaming/streamsongmimedata.h b/src/streaming/streamsongmimedata.h index 4ea8f200a..6a21ce0d9 100644 --- a/src/streaming/streamsongmimedata.h +++ b/src/streaming/streamsongmimedata.h @@ -2,6 +2,7 @@ * Strawberry Music Player * This file was part of Clementine. * Copyright 2011, David Sansome + * Copyright 2018-2024, Jonas Kvinge * * Strawberry is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +32,7 @@ class StreamSongMimeData : public MimeData { Q_OBJECT public: - explicit StreamSongMimeData(SharedPtr _service, QObject* = nullptr) : service(_service) {} + explicit StreamSongMimeData(SharedPtr _service, QObject *parent = nullptr); SharedPtr service; SongList songs; diff --git a/src/transcoder/transcoderoptionsinterface.cpp b/src/transcoder/transcoderoptionsinterface.cpp new file mode 100644 index 000000000..2c1300e05 --- /dev/null +++ b/src/transcoder/transcoderoptionsinterface.cpp @@ -0,0 +1,28 @@ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * + * Strawberry is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Strawberry 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Strawberry. If not, see . + * + */ + +#include +#include + +#include "transcoderoptionsinterface.h" + +TranscoderOptionsInterface::TranscoderOptionsInterface(QWidget *parent) : QWidget(parent) {} + +TranscoderOptionsInterface::~TranscoderOptionsInterface() = default; diff --git a/src/transcoder/transcoderoptionsinterface.h b/src/transcoder/transcoderoptionsinterface.h index e1e094af8..3122949d1 100644 --- a/src/transcoder/transcoderoptionsinterface.h +++ b/src/transcoder/transcoderoptionsinterface.h @@ -30,8 +30,8 @@ class TranscoderOptionsInterface : public QWidget { Q_OBJECT public: - explicit TranscoderOptionsInterface(QWidget *parent) : QWidget(parent) {} - ~TranscoderOptionsInterface() override {} + explicit TranscoderOptionsInterface(QWidget *parent); + ~TranscoderOptionsInterface() override; virtual void Load() = 0; virtual void Save() = 0;